.efb-shell {
    --efb-bg: #111923;
    --efb-panel: #172231;
    --efb-panel-2: #202d3d;
    --efb-border: #344355;
    --efb-text: #f2f6fa;
    --efb-muted: #9caabd;
    --efb-accent: #36a8ff;
    --efb-accent-strong: #1687dc;
    --efb-success: #43c889;
    --efb-warning: #f5ba4c;
    --efb-danger: #ff6b73;
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-rows: 68px minmax(0, 1fr) 88px;
    grid-template-areas:
        "status status"
        "context main"
        "context tasks";
    color: var(--efb-text);
    background: var(--efb-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden;
    color-scheme: dark;
}

.efb-shell.efb-light {
    --efb-bg: #edf2f7;
    --efb-panel: #ffffff;
    --efb-panel-2: #f3f6f9;
    --efb-border: #cbd5df;
    --efb-text: #172333;
    --efb-muted: #5f6e7e;
    --efb-accent: #0878c9;
    --efb-accent-strong: #0565ab;
    color-scheme: light;
}

.efb-status-strip {
    grid-area: status;
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr) auto;
    align-items: center;
    min-width: 0;
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--efb-border);
    background: var(--efb-panel);
}

.efb-wordmark {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    color: var(--efb-text);
    font-weight: 700;
    text-decoration: none;
}

.efb-wordmark:hover { color: var(--efb-text); text-decoration: none; }
.efb-wordmark-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: linear-gradient(145deg, #d81f36, #702376 55%, #1674b7);
    color: white;
    font-size: .78rem;
    letter-spacing: .08em;
}

.efb-flight-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 2vw, 28px);
    min-width: 0;
    color: var(--efb-muted);
    font-size: .86rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    overflow: hidden;
}

.efb-status-flight { color: var(--efb-text); font-size: 1rem; font-weight: 750; }
.efb-status-actions { display: flex; align-items: center; gap: 10px; }
.efb-icon-button, .efb-exit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--efb-border);
    border-radius: 9px;
    background: var(--efb-panel-2);
    color: var(--efb-text);
    text-decoration: none;
    cursor: pointer;
}
.efb-icon-button { font-size: 1.25rem; }
.efb-exit { padding: 0 14px; font-weight: 650; }
.efb-exit:hover { color: var(--efb-text); text-decoration: none; }

.efb-context-nav {
    grid-area: context;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 18px max(12px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-bottom));
    border-right: 1px solid var(--efb-border);
    background: var(--efb-panel);
}

.efb-context-heading { display: flex; align-items: center; gap: 12px; padding: 6px 10px 18px; }
.efb-context-heading > span { color: var(--efb-accent); font-size: 1.6rem; }
.efb-context-heading small { display: block; color: var(--efb-muted); font-size: .62rem; font-weight: 750; letter-spacing: .18em; }
.efb-context-heading strong { display: block; font-size: 1.12rem; }
.efb-context-nav nav { display: grid; gap: 7px; }
.efb-context-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--efb-muted);
    font-weight: 650;
    text-decoration: none;
}
.efb-context-link:hover { color: var(--efb-text); text-decoration: none; background: var(--efb-panel-2); }
.efb-context-link.active { border-color: color-mix(in srgb, var(--efb-accent) 46%, transparent); background: color-mix(in srgb, var(--efb-accent) 15%, var(--efb-panel)); color: var(--efb-text); }
.efb-context-link > span:first-child { width: 24px; text-align: center; color: var(--efb-accent); font-size: 1.15rem; }
.efb-context-footer { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 14px 10px 0; color: var(--efb-muted); font-size: .78rem; }
.efb-connection-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--efb-success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--efb-success) 15%, transparent); }

.efb-main {
    grid-area: main;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: clamp(16px, 2.2vw, 28px);
    background: var(--efb-bg);
}

.efb-taskbar {
    grid-area: tasks;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 9px max(12px, env(safe-area-inset-right)) max(9px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-top: 1px solid var(--efb-border);
    background: var(--efb-panel);
}
.efb-task {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 58px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--efb-muted);
    font-size: .76rem;
    font-weight: 650;
    text-decoration: none;
}
.efb-task:hover { color: var(--efb-text); text-decoration: none; background: var(--efb-panel-2); }
.efb-task.active { border-color: color-mix(in srgb, var(--efb-accent) 45%, transparent); background: color-mix(in srgb, var(--efb-accent) 16%, var(--efb-panel)); color: var(--efb-text); }
.efb-task-icon { color: var(--efb-accent); font-size: 1.35rem; line-height: 1; }

.efb-connectivity {
    position: fixed;
    z-index: 1100;
    top: calc(76px + env(safe-area-inset-top));
    right: max(18px, env(safe-area-inset-right));
    display: none;
    max-width: min(390px, calc(100vw - 36px));
    padding: 13px 16px;
    border: 1px solid var(--efb-warning);
    border-radius: 10px;
    background: #3e321e;
    color: #fff5d8;
    box-shadow: 0 12px 32px rgba(0,0,0,.28);
}
.efb-connectivity strong, .efb-connectivity span { display: block; }
.efb-connectivity span { margin-top: 2px; font-size: .82rem; }
.efb-offline .efb-connectivity { display: block; }
.efb-offline .efb-connection-dot { background: var(--efb-warning); }

.efb-page { max-width: 1500px; margin: 0 auto; }
.efb-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.efb-page-header h1 { margin: 0; color: var(--efb-text); font-size: clamp(1.45rem, 2.2vw, 2rem); font-weight: 720; }
.efb-page-header p { margin: 4px 0 0; color: var(--efb-muted); }
.efb-card {
    border: 1px solid var(--efb-border);
    border-radius: 13px;
    background: var(--efb-panel);
    box-shadow: 0 10px 28px rgba(0,0,0,.09);
}
.efb-card-header { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 10px 16px; border-bottom: 1px solid var(--efb-border); }
.efb-card-header h2 { margin: 0; color: var(--efb-text); font-size: 1rem; font-weight: 700; }
.efb-card-body { padding: 16px; }
.efb-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.efb-span-4 { grid-column: span 4; }
.efb-span-6 { grid-column: span 6; }
.efb-span-8 { grid-column: span 8; }
.efb-span-12 { grid-column: 1 / -1; }
.efb-data { min-height: 78px; padding: 13px 14px; border: 1px solid var(--efb-border); border-radius: 10px; background: var(--efb-panel-2); }
.efb-data-label { display: block; margin-bottom: 5px; color: var(--efb-muted); font-size: .68rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.efb-data-value { color: var(--efb-text); font-size: 1.08rem; font-weight: 680; overflow-wrap: anywhere; }
.efb-status-pill { display: inline-flex; align-items: center; min-height: 32px; padding: 0 11px; border: 1px solid color-mix(in srgb, var(--efb-success) 45%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--efb-success) 14%, var(--efb-panel)); color: var(--efb-success); font-size: .78rem; font-weight: 750; text-transform: uppercase; }
.efb-status-pill.neutral { border-color: var(--efb-border); background: var(--efb-panel-2); color: var(--efb-muted); }
.efb-route { margin: 0; color: var(--efb-text); font-family: "SFMono-Regular", Consolas, monospace; line-height: 1.65; overflow-wrap: anywhere; }
.efb-map-frame { padding: 14px; text-align: center; background: var(--efb-panel-2); }
.efb-map-frame img { display: block; max-width: 100%; max-height: 58vh; margin: auto; object-fit: contain; border-radius: 8px; }
.efb-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 44px;
    padding: 0 15px;
    border: 1px solid var(--efb-border);
    border-radius: 9px;
    background: var(--efb-panel-2);
    color: var(--efb-text);
    font-weight: 650;
    cursor: pointer;
}
.efb-button-primary { border-color: var(--efb-accent-strong); background: var(--efb-accent-strong); color: white; }
.efb-button:disabled { opacity: .55; cursor: default; }
.efb-state-card { display: grid; place-items: center; align-content: center; min-height: 55vh; padding: 28px; text-align: center; color: var(--efb-text); }
.efb-state-card h1 { margin: 15px 0 5px; font-size: 1.35rem; }
.efb-state-card p { max-width: 560px; color: var(--efb-muted); }
.efb-spinner { width: 34px; height: 34px; border: 3px solid var(--efb-border); border-top-color: var(--efb-accent); border-radius: 50%; animation: efb-spin .8s linear infinite; }
@keyframes efb-spin { to { transform: rotate(360deg); } }

.efb-document-shell { display: flex; flex-direction: column; height: calc(100vh - 212px); min-height: 420px; overflow: hidden; }
.efb-document-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--efb-border); background: var(--efb-panel); }
.efb-document-toolbar .efb-toolbar-spacer { flex: 1; }
.efb-document-viewport { flex: 1; min-height: 0; overflow: auto; padding: 18px; background: #d9dee5; color: #111; -webkit-overflow-scrolling: touch; }
.efb-document-paper { width: min(100%, 1100px); min-height: 100%; margin: 0 auto; padding: clamp(18px, 3vw, 42px); background: white; box-shadow: 0 8px 28px rgba(0,0,0,.18); transform-origin: top left; }
.efb-document-paper pre { margin: 0; color: #111; font: 500 13px/1.48 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; }
.efb-pdf-page { height: 100%; }
.efb-pdf-shell { display: flex; flex-direction: column; height: calc(100vh - 212px); min-height: 420px; overflow: hidden; }
.efb-pdf-frame { flex: 1; width: 100%; min-height: 0; border: 0; background: #525659; }
.efb-pdf-fallback { padding: 6px 12px; border-top: 1px solid var(--efb-border); color: var(--efb-muted); font-size: .72rem; text-align: center; }
.efb-pdf-fallback button { padding: 0; border: 0; background: none; color: var(--efb-accent); }
.efb-library-layout { display: grid; grid-template-columns: minmax(240px, 310px) minmax(0, 1fr); gap: 14px; min-height: calc(100vh - 180px); }
.efb-library-index { min-height: 0; overflow: hidden; }
.efb-library-index .efb-card-body { display: flex; flex-direction: column; height: 100%; }
.efb-input { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--efb-border); border-radius: 9px; background: var(--efb-panel-2); color: var(--efb-text); font-size: 1rem; }
.efb-airport-list { display: grid; gap: 7px; margin-top: 12px; overflow: auto; -webkit-overflow-scrolling: touch; }
.efb-airport-choice { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; min-height: 52px; padding: 0 12px; border: 1px solid var(--efb-border); border-radius: 9px; background: var(--efb-panel-2); color: var(--efb-text); text-align: left; }
.efb-airport-choice span { color: var(--efb-muted); font-size: .78rem; }
.efb-airport-choice.active { border-color: var(--efb-accent); background: color-mix(in srgb, var(--efb-accent) 15%, var(--efb-panel)); }
.efb-library-viewer { min-width: 0; }
.efb-library-viewer .efb-pdf-shell { height: calc(100vh - 180px); }
.efb-empty-note { color: var(--efb-muted); }
.efb-fuel-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr); gap: 14px; margin-top: 14px; }
.efb-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.efb-form-grid label > span { display: block; margin-bottom: 5px; color: var(--efb-muted); font-size: .72rem; font-weight: 700; }
.efb-readout { display: flex; align-items: center; min-height: 46px; padding: 0 13px; border: 1px solid var(--efb-border); border-radius: 9px; background: var(--efb-panel-2); color: var(--efb-text); }
.efb-table-wrap { overflow-x: auto; }
.efb-fuel-table { width: 100%; min-width: 620px; border-collapse: collapse; color: var(--efb-text); }
.efb-fuel-table th, .efb-fuel-table td { padding: 12px; border-bottom: 1px solid var(--efb-border); text-align: right; }
.efb-fuel-table th:first-child { text-align: left; }
.efb-fuel-table thead th { color: var(--efb-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.efb-fuel-table tr.editable { background: color-mix(in srgb, var(--efb-accent) 9%, transparent); }
.efb-fuel-state { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 22px; }
.efb-fuel-state .efb-connection-dot { flex: 0 0 auto; margin-top: 6px; }
.efb-fuel-state p { margin: 3px 0 0; color: var(--efb-muted); }
.efb-fuel-action .efb-button { width: 100%; }
.efb-button-danger { border-color: var(--efb-danger); background: transparent; color: var(--efb-danger); }

.efb-flight-picker { max-width: 1000px; margin: 0 auto; }
.efb-flight-list { display: grid; gap: 9px; margin-top: 16px; }
.efb-flight-choice { display: grid; grid-template-columns: 120px 110px minmax(170px, 1fr) 80px auto; align-items: center; gap: 12px; width: 100%; min-height: 62px; padding: 9px 14px; border: 1px solid var(--efb-border); border-radius: 10px; background: var(--efb-panel-2); color: var(--efb-text); text-align: left; cursor: pointer; }
.efb-flight-choice strong { font-size: 1rem; }
.efb-flight-choice small { color: var(--efb-muted); }

@media (max-width: 900px) {
    .efb-shell { grid-template-columns: 190px minmax(0, 1fr); }
    .efb-status-strip { grid-template-columns: 190px minmax(0, 1fr) auto; }
    .efb-wordmark > span:last-child { display: none; }
    .efb-flight-status span:nth-child(n+4) { display: none; }
    .efb-span-4, .efb-span-8 { grid-column: span 6; }
}

@media (max-width: 700px) {
    .efb-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 62px auto minmax(0, 1fr) 80px;
        grid-template-areas: "status" "context" "main" "tasks";
    }
    .efb-status-strip { grid-template-columns: auto minmax(0, 1fr) auto; padding-left: 10px; padding-right: 10px; }
    .efb-wordmark { width: 44px; }
    .efb-flight-status { justify-content: flex-start; padding-left: 6px; }
    .efb-flight-status span:nth-child(n+3) { display: none; }
    .efb-exit { width: 44px; padding: 0; font-size: 0; }
    .efb-exit::after { content: "↗"; font-size: 1.2rem; }
    .efb-context-nav { display: block; padding: 6px 10px; border-right: 0; border-bottom: 1px solid var(--efb-border); overflow-x: auto; }
    .efb-context-heading, .efb-context-footer { display: none; }
    .efb-context-nav nav { display: flex; gap: 7px; }
    .efb-context-link { flex: 0 0 auto; min-height: 44px; padding: 0 12px; }
    .efb-main { padding: 14px; }
    .efb-taskbar { gap: 3px; padding: 6px 6px max(6px, env(safe-area-inset-bottom)); }
    .efb-task { min-height: 62px; font-size: .66rem; }
    .efb-document-shell { height: calc(100vh - 236px); min-height: 320px; }
    .efb-pdf-shell { height: calc(100vh - 236px); min-height: 320px; }
    .efb-library-layout { grid-template-columns: 1fr; min-height: 0; }
    .efb-library-index { max-height: 260px; }
    .efb-library-viewer .efb-pdf-shell { height: calc(100vh - 280px); min-height: 360px; }
    .efb-fuel-layout, .efb-form-grid { grid-template-columns: 1fr; }
    .efb-span-4, .efb-span-6, .efb-span-8 { grid-column: 1 / -1; }
    .efb-flight-choice { grid-template-columns: 1fr 1fr; }
    .efb-flight-choice > *:nth-child(3) { grid-column: 1 / -1; }
}

@media (display-mode: standalone) {
    .efb-shell { padding-top: 0; }
}
