/* LogBridge 2.0 PWA - Dark Theme (matches AppTheme.swift) */

:root {
    /* iOS safe areas (standalone PWA + Safari); extra top gap clears Dynamic Island */
    --safe-top: max(16px, calc(env(safe-area-inset-top, 0px) + 10px));
    --safe-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    --safe-x: max(16px, env(safe-area-inset-left, 0px));
    --bg: #0f1419;
    --card-bg: #242b33;
    --input-bg: #2d353f;
    --text-primary: #e7edf4;
    --text-secondary: #8b98a5;
    --text-muted: #6e7a87;
    --accent: #0d9488;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --border: #38444d;
    --collapse-duration: 0.34s;
    --collapse-ease: cubic-bezier(0.33, 1, 0.32, 1);
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --collapse-duration: 0.01ms;
    }
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    height: 100dvh;
    /* Disables double-tap zoom; keeps pan scroll + pinch zoom */
    touch-action: manipulation;
}

html, body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Rounded', 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
    max-width: 100%;
}

body {
    min-height: 100%;
    min-height: 100dvh;
    touch-action: manipulation;
}

/* Lock scroll during intro — iOS Safari otherwise shifts fixed layers / “vh” when the bar shows */
body.startup-active:not(.startup-done) {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    width: 100%;
    height: 100%;
    position: fixed;
    left: 0;
    top: 0;
}

/* --- PWA startup splash (~4.35s): plane departs → logo rises/scales → UI fades bottom→top --- */
.startup-splash {
    position: fixed;
    inset: 0;
    z-index: 100000;
    pointer-events: auto;
    /* Allow plane to exit up-right without clipping */
    overflow: visible;
    /* iOS: fill viewport when 100vh/dvh disagree with the dynamic toolbar */
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    box-sizing: border-box;
}

.startup-splash__bg {
    position: absolute;
    inset: 0;
    background: var(--bg);
    animation: startup-bg-fade 4.35s linear forwards;
}

@keyframes startup-bg-fade {
    0%, 71% { opacity: 1; }
    78%, 100% { opacity: 0; }
}

.startup-splash__mark {
    position: absolute;
    left: 50%;
    /* Dead center: anchor point at viewport center, then center the mark box on it */
    top: 50%;
    top: 50dvh;
    z-index: 3;
    width: 100%;
    max-width: 640px;
    padding: 0 var(--safe-x);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    pointer-events: none;
    transform: translate3d(-50%, -50%, 0);
    backface-visibility: hidden;
    /* Rise starts just after plane finishes (~3.05s) */
    animation: startup-mark-rise 1s cubic-bezier(0.22, 1, 0.36, 1) 3.1s both;
}

.startup-splash__brand {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: clamp(2.75rem, 11vw, 3.65rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--accent);
    line-height: 1.05;
    transform: scale3d(1, 1, 1);
    /* Top anchor: matches header h1 flow — center origin made the glyph sit low vs real title */
    transform-origin: top center;
    backface-visibility: hidden;
    /* Scale instead of font-size (avoids layout thrash / jitter) */
    animation: startup-brand-scale 1s cubic-bezier(0.22, 1, 0.36, 1) 3.1s both;
}

.startup-splash__wordmark {
    white-space: nowrap;
}

.startup-splash__plane {
    position: absolute;
    left: 100%;
    top: 50%;
    width: 0.85em;
    height: 0.85em;
    margin-left: 0.28em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
    transform: translate3d(0, -50%, 0);
    backface-visibility: hidden;
    /* Transform + opacity only — no width/margin keyframes */
    animation: startup-plane-depart 1.05s cubic-bezier(0.33, 0.12, 0.22, 1) 2s forwards;
}

.startup-splash__plane-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.startup-splash__version {
    position: absolute;
    left: 50%;
    bottom: max(14px, calc(env(safe-area-inset-bottom, 0px) + 8px));
    z-index: 2;
    margin: 0;
    transform: translateX(-50%);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    opacity: 0.9;
    pointer-events: none;
    user-select: none;
    /* Same duration as .startup-splash__bg — fade out in the last segment as the splash ends */
    animation: startup-version-fade 4.35s linear forwards;
}

@keyframes startup-version-fade {
    0%, 76% {
        opacity: 0.9;
    }
    100% {
        opacity: 0;
    }
}

/* One quick overshoot after metrics snap, before the overlay is removed */
@keyframes startup-handoff-pop {
    0% {
        transform: scale(0.9);
        opacity: 0.92;
    }
    55% {
        transform: scale(1.045);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.startup-splash__brand.startup-splash__brand--handoff-pop {
    animation: startup-handoff-pop 0.42s cubic-bezier(0.34, 1.5, 0.52, 1) both !important;
    transform-origin: center center;
}

/* 45° up-right; interpolate translate + translate (no % mixed with vmin mid-path) */
@keyframes startup-plane-depart {
    0% {
        opacity: 1;
        transform: translateY(-50%) translate3d(0, 0, 0) rotate(-10deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-50%) translate3d(72vmin, -72vmin, 0) rotate(32deg);
    }
}

/* ~1.75rem / ~3.6rem headline — matches final h1 visually */
@keyframes startup-brand-scale {
    0% {
        transform: scale3d(1, 1, 1);
    }
    100% {
        transform: scale3d(0.485, 0.485, 1);
    }
}

@keyframes startup-mark-rise {
    0% {
        top: 50%;
        top: 50dvh;
        transform: translate3d(-50%, -50%, 0);
    }
    100% {
        /* Same vertical band as .app-header padding-top + first line of h1 */
        top: calc(var(--safe-top) + 12px);
        transform: translate3d(-50%, 0, 0);
    }
}

@keyframes startup-content-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* In-flow but invisible under splash — no opacity transition (avoids flash when overlay is removed) */
.app-header .accent-title {
    opacity: 1;
}

body.startup-active:not(.startup-done) .app-header .accent-title {
    opacity: 0;
}

/* Bottom → top (timed with logo rise ~3–4s) */
body.startup-active:not(.startup-done) .pwa-install-footer:not([hidden]) {
    opacity: 0;
    animation: startup-content-fade 0.5s cubic-bezier(0.33, 1, 0.32, 1) 3.12s both;
}

body.startup-active:not(.startup-done) #view-home.active .home-content {
    opacity: 0;
    animation: startup-content-fade 0.52s cubic-bezier(0.33, 1, 0.32, 1) 3.34s both;
}

body.startup-active:not(.startup-done) .step-indicator {
    opacity: 0;
    animation: startup-content-fade 0.48s cubic-bezier(0.33, 1, 0.32, 1) 3.56s both;
}

body.startup-active:not(.startup-done) .app-header .subtitle {
    opacity: 0;
    animation: startup-content-fade 0.5s cubic-bezier(0.33, 1, 0.32, 1) 3.78s both;
}

body.startup-done #startup-splash {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .startup-splash {
        display: none !important;
    }

    body.startup-active:not(.startup-done) .app-header .accent-title {
        opacity: 1;
    }

    body.startup-active:not(.startup-done) .app-header .subtitle,
    body.startup-active:not(.startup-done) .step-indicator,
    body.startup-active:not(.startup-done) #view-home.active .home-content,
    body.startup-active:not(.startup-done) .pwa-install-footer:not([hidden]) {
        opacity: 1 !important;
        animation: none !important;
    }
}


/* App Shell */
#app {
    max-width: 640px;
    margin: 0 auto;
    padding: var(--safe-top) var(--safe-x) var(--safe-bottom);
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Header - matches Swift: teal title */
.app-header {
    text-align: center;
    padding: 12px 0 8px;
    flex-shrink: 0;
}

.app-header h1 {
    margin: 0;
    padding: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.app-header h1.accent-title {
    color: var(--accent);
}

.app-header .subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Step Indicator */
.step-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 20px;
    flex-shrink: 0;
}

.step-indicator .step-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.step-indicator .step-bar {
    flex: 1;
    height: 4px;
    background: var(--input-bg);
    border-radius: 2px;
    overflow: hidden;
}

.step-indicator .step-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Views */
.view {
    display: none;
    flex: 1;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.view.active {
    display: flex;
}

/* Section titles (used outside cards) */
.section-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.section-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    border: none;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    width: 100%;
    text-align: center;
    font-family: inherit;
}

.btn:active {
    opacity: 0.85;
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-secondary {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-sm {
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 10px;
    width: auto;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 8px;
    font-family: inherit;
}

.btn-text:hover { color: var(--text-primary); }

.btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-cancel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--accent);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 20px;
    font-family: inherit;
}

.btn-cancel:active { opacity: 0.8; }

/* Paste view buttons */
.btn-paste-clip {
    margin-top: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 14px;
    border-radius: 12px;
}

.btn-parse {
    margin-top: 10px;
    font-size: 1rem;
    padding: 16px;
    border-radius: 12px;
}

.btn-import {
    padding: 22px;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 20px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.4;
}

/* Alert banners */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 10px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

.alert-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.alert-success .alert-icon { color: var(--accent-green); }
.alert-warning .alert-icon { color: var(--accent-orange); }

/* Form inputs */
.field-group {
    display: flex;
    gap: 12px;
}

.field {
    flex: 1;
    min-width: 0;
}

.field-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

/* 16px minimum prevents iOS Safari / PWA from zooming the viewport on focus */
.field-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    font-size: 16px;
    line-height: 1.35;
    outline: none;
}

.field-input:focus {
    border-color: var(--accent);
}

.field-subtitle {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 4px;
    min-height: 1em;
}

.field-input[readonly] {
    cursor: default;
    opacity: 0.9;
}

select.field-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4l3 3.5L9 4' stroke='%230d9488' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    font-family: inherit;
    font-weight: 600;
    color: var(--accent);
}

/* Toggle switches */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    gap: 12px;
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: #fff;
}

/* Flight cards */
.flight-card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.flight-card.skipped {
    opacity: 0.6;
}

.flight-card.unselected {
    opacity: 0.65;
}

.flight-card-header {
    display: flex;
    align-items: stretch;
}

/* Step 2 / 3: left ≈75% (flex 3), right ≈25% (flex 1) */
.flight-card-hit-left {
    flex: 3 1 0;
    min-width: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.flight-card-hit-right {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.flight-card-header-main {
    flex: 1;
    padding: 14px 16px;
    min-width: 0;
}

.flight-route {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
}

.flight-cities {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.flight-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    align-items: center;
}

.flight-meta .mono {
    font-family: 'SF Mono', 'Menlo', monospace;
}

.flight-card-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 12px;
    color: var(--text-muted);
}

.flight-card-chevron svg {
    width: 14px;
    height: 14px;
}

/* Select flight checkbox */
.flight-checkbox-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    min-width: 0;
}

.checkbox-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.checkbox-icon.checked {
    color: var(--accent);
}

.checkbox-icon svg {
    width: 24px;
    height: 24px;
}

/* Flight details expand — padding/gap only when open (avoids sliver at grid 0fr, same as trip-group-legs-body) */
.flight-card-details {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    transition:
        padding var(--collapse-duration) var(--collapse-ease),
        gap var(--collapse-duration) var(--collapse-ease);
}

.collapse-panel.expanded > .flight-card-details {
    padding: 6px 12px 12px;
    gap: 10px;
}

.flight-card-details .divider {
    height: 1px;
    background: var(--border);
}

/* Step 3: skip / include in right column */
.review-skip-zone {
    border-left: 1px solid var(--border);
}

.review-skip-zone .skip-btn {
    width: 100%;
    min-height: 100%;
    padding: 12px 8px;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
}

.review-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.review-card-chevron {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--text-muted);
}

.review-card-chevron svg {
    width: 14px;
    height: 14px;
    display: block;
}

.review-card-left {
    padding: 14px 16px;
}

/* Skip button */
.skip-btn {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
    padding: 6px 12px;
    font-family: inherit;
}

.skip-btn.include {
    color: var(--accent-green);
}

/* Aircraft source indicator */
.source-indicator {
    display: inline-flex;
    align-items: center;
}

.source-indicator svg {
    width: 14px;
    height: 14px;
}

.source-indicator.live { color: var(--accent-green); }
.source-indicator.cache { color: var(--accent-orange); }
.source-indicator.fleet-equip { color: var(--accent); }
.source-indicator.notFound { color: var(--accent-red); }

/* Crew section */
.crew-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crew-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crew-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.crew-status {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.crew-status .role-name {
    font-weight: 700;
    color: var(--accent);
}

.crew-status.all-assigned {
    color: var(--accent-green);
}

.crew-row {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--input-bg);
    border-radius: 10px;
}

.crew-info {
    flex: 1;
    min-width: 0;
}

.crew-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.crew-id {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.crew-role-badge {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    background: var(--accent-green);
    padding: 5px 12px;
    border-radius: 6px;
    min-width: 36px;
    text-align: center;
}

.crew-assign-btn {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--accent);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    min-width: 36px;
    text-align: center;
}

.crew-assign-btn:hover { background: rgba(13, 148, 136, 0.1); }

.crew-clear-btn {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--border);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 6px;
    line-height: 1;
}

.crew-clear-btn:hover { color: var(--text-primary); }

/* Action bar */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
}

/* Collapsible header */
.collapsible-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

/* Rule only when body is open — avoids hairline when collapsed (export options, JSON preview, etc.) */
.card:has(> .collapsible-content.expanded) > .collapsible-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.collapsible-header .auto-saved {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 8px;
}

.collapsible-header .chevron {
    margin-left: auto;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: transform 0.2s;
}

.collapsible-header .chevron.open {
    transform: rotate(180deg);
}

.collapsible-inner {
    min-height: 0;
    overflow: hidden;
    padding-top: 0;
    transition: padding-top var(--collapse-duration) var(--collapse-ease);
}

.collapsible-content.expanded .collapsible-inner {
    padding-top: 16px;
}

/* Typeahead dropdown */
.typeahead-wrapper {
    position: relative;
}

.typeahead-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
    min-width: 260px;
}

.typeahead-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.typeahead-item:last-child {
    border-bottom: none;
}

.typeahead-item:hover {
    background: var(--input-bg);
}

.typeahead-code {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.typeahead-name {
    font-size: 0.72rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* JSON preview */
.json-preview {
    background: var(--input-bg);
    border-radius: 8px;
    padding: 12px;
    max-height: 300px;
    overflow: auto;
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}

.json-actions {
    display: flex;
    gap: 16px;
    padding-top: 10px;
}

.json-actions button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 500;
}

/* Paste area */
.paste-area {
    width: 100%;
    min-height: 200px;
    padding: 14px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 16px;
    resize: vertical;
    outline: none;
    line-height: 1.6;
}

.paste-area:focus {
    border-color: var(--accent);
}

.paste-area::placeholder {
    color: var(--text-muted);
}

/* PWA install (footer — pinned to bottom when content is short) */
.pwa-install-footer {
    margin-top: auto;
    padding-top: 16px;
    flex-shrink: 0;
}

.pwa-install-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
}

.pwa-install-lead {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 10px 0;
    line-height: 1.35;
}

.pwa-install-sub {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.pwa-install-sub .pwa-kbd {
    color: var(--accent);
    font-weight: 600;
}

.pwa-install-cta {
    width: 100%;
    margin-top: 4px;
    padding: 12px 16px;
    font-size: 0.95rem;
    border-radius: 12px;
}

.pwa-install-panel-ios .pwa-install-lead {
    margin-bottom: 8px;
}

/* Home view centering — flex fills remaining space without forcing extra scroll */
.home-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    min-height: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.csv-trip-actions {
    margin-top: 16px;
}

.csv-trip-slider-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.csv-trip-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.csv-trip-slider-end {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    flex: 0 0 auto;
    min-width: 2rem;
    text-align: center;
}

/* Range: dark track (not white), teal thumb */
.csv-trip-slider {
    flex: 1;
    min-width: 0;
    height: 28px;
    cursor: pointer;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.csv-trip-slider::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 4px;
    background: var(--input-bg);
    border: 1px solid var(--border);
}

.csv-trip-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    margin-top: -8px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--card-bg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.csv-trip-slider::-moz-range-track {
    height: 8px;
    border-radius: 4px;
    background: var(--input-bg);
    border: 1px solid var(--border);
}

.csv-trip-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--card-bg);
    cursor: pointer;
}

.csv-trip-slider-readout {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 14px;
    min-height: 2.5em;
    line-height: 1.35;
}

.csv-trip-import-btn {
    width: 100%;
    margin-top: 4px;
}

/* Trip groups (select + review) */
.trip-group {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: var(--card-bg);
}

.trip-group-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-bottom: none;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    gap: 12px;
    -webkit-tap-highlight-color: transparent;
}

.trip-group-bar:active {
    opacity: 0.92;
}

.trip-group-head-text {
    min-width: 0;
    flex: 1;
}

.trip-group-pairing {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
    line-height: 1.35;
    word-break: break-word;
}

.trip-group-dates {
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.35;
    letter-spacing: normal;
}

.card-export-options {
    cursor: pointer;
}

.card-export-options .toggle-row {
    cursor: default;
}

.card-export-options .toggle-row label.toggle {
    cursor: pointer;
}

.trip-group-bar-split {
    display: flex;
    align-items: stretch;
    width: 100%;
    background: var(--input-bg);
    border: none;
    border-bottom: none;
    padding: 0;
}

.trip-group:has(> .trip-pairing-panel.expanded) > .trip-group-bar,
.trip-group:has(> .trip-pairing-panel.expanded) > .trip-group-bar-split {
    border-bottom: 1px solid var(--border);
}

/* Air above the rule before leg rows (pairing / trip line vs first leg meta) */
.trip-group:has(> .trip-pairing-panel.expanded) > .trip-group-bar {
    padding-bottom: 18px;
}

.trip-group:has(> .trip-pairing-panel.expanded) > .trip-group-bar-split {
    padding-bottom: 6px;
}

.trip-group-bar-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px 14px 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    gap: 12px;
    -webkit-tap-highlight-color: transparent;
}

.trip-group-bar-main:active {
    opacity: 0.92;
}

.trip-group-pair-skip {
    flex-shrink: 0;
    align-self: stretch;
    margin: 8px 10px 8px 0;
    padding: 0 14px;
    min-height: 36px;
}

.trip-group-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.trip-group-chevron {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.trip-group-chevron.open {
    transform: rotate(180deg);
}

/* Pairing leg list — padding only when open (avoids 1px sliver when grid is 0fr) */
.trip-group-legs-body {
    padding: 0;
    background: var(--card-bg);
    transition: padding var(--collapse-duration) var(--collapse-ease);
}

.trip-pairing-panel.expanded .trip-group-legs-body {
    padding: 16px 10px 12px 14px;
}

/* Leg rows use inline margin-bottom for spacing; zero when trip is collapsed (beats inline, avoids sliver). */
.trip-pairing-panel:not(.expanded) .trip-group-legs-body .trip-leg-card {
    margin-bottom: 0 !important;
}

/**
 * Site-wide expand/collapse: no .expanded = closed, .expanded = open.
 * Grid 0fr→1fr animates intrinsic height (smooth). Pairing toggles update .expanded in-place in JS.
 */
.collapse-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows var(--collapse-duration) var(--collapse-ease);
    overflow: hidden;
}

.collapse-panel.expanded {
    grid-template-rows: 1fr;
}

.collapse-panel > * {
    min-height: 0;
    overflow: hidden;
}

/* Leg row: separator only when details are open (no hairline above collapsed panel) */
.trip-leg-card:has(> .collapse-panel.expanded) > .flight-card-header {
    border-bottom: 1px solid var(--border);
}

.trip-leg-card .flight-card-details > .divider:first-child {
    display: none;
}

.trip-leg-card {
    margin-left: 0 !important;
}

/* Date / flight no. row sits a touch lower under route + cities */
.trip-leg-card .flight-meta {
    margin-top: 7px;
}

.trip-leg-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    background: rgba(13, 148, 136, 0.15);
    padding: 2px 8px;
    border-radius: 6px;
    margin-right: 8px;
    vertical-align: middle;
}

.csv-trip-orphans {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.csv-trip-orphans-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.csv-trip-orphans-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 180px;
    overflow-y: auto;
}

.csv-trip-orphans-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.csv-trip-orphans-list li:last-child {
    border-bottom: none;
}

.csv-trip-orphan-route {
    color: var(--text-primary);
    font-weight: 600;
}

.csv-trip-orphan-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* Readonly field in export */
.readonly-value {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 0.85rem;
    padding: 10px;
    background: var(--input-bg);
    border-radius: 8px;
    color: var(--text-primary);
    min-height: 40px;
}

/* Export crew list */
.export-crew-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.export-crew-role {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    width: 30px;
}

.export-crew-name {
    font-size: 0.78rem;
    color: var(--text-primary);
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toast.show {
    opacity: 1;
}

/* Responsive */
@media (max-width: 480px) {
    :root {
        --safe-top: max(12px, calc(env(safe-area-inset-top, 0px) + 10px));
        --safe-x: max(12px, env(safe-area-inset-left, 0px));
    }
    .card { padding: 16px; }
}

/* Chevron rotation */
.chevron-icon {
    transition: transform 0.2s ease;
}

.chevron-icon.open {
    transform: rotate(180deg);
}

/* Select flight detail row - label on top, value below, all in one line */
.select-detail-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
    font-size: 0.7rem;
    padding: 4px 0;
    white-space: nowrap;
}

.select-detail-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.select-detail-item .detail-label {
    font-size: 0.6rem;
}

.select-detail-item .detail-value {
    font-weight: 500;
}

.select-detail-row .detail-label {
    color: var(--text-muted);
}

.select-detail-row .detail-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Type + source icon inline alignment */
.meta-type {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* Deadhead badge */
.dh-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--accent-orange);
    background: rgba(245, 158, 11, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    letter-spacing: 0.02em;
    line-height: 1;
}

/* Loading spinner */
.loading-text {
    font-size: 0.72rem;
    color: var(--text-muted);
}
