/* ═══════════════════════════════════════════════════════════
   STATISTICS DASHBOARD
═══════════════════════════════════════════════════════════ */
#stats-modal .modal-card.st-modal-card {
    width: min(1280px, 96vw);
    max-width: none;
    max-height: 94vh;
    padding: 0;
    background: #070a0d;
    border: 1px solid #16202a;
    border-radius: 14px;
}

.st-root {
    --st-card: #0c1116;
    --st-line: #18222b;
    --st-text: #e6edf3;
    --st-dim: #8593a0;
    --st-faint: #4f5d6a;
    --st-accent: #00d8f0;
    --st-alt: #8a7dff;
    --st-good: #3ddc84;
    --st-warn: #f5b942;
    --st-bad: #ff5a4d;
    --st-up: #2c3a46;
    --st-mono: 'Share Tech Mono', 'Be Vietnam Pro', monospace;
    font-family: 'Be Vietnam Pro', system-ui, sans-serif;
    color: var(--st-text);
    padding: 0 22px 22px;
    padding-bottom: max(22px, env(safe-area-inset-bottom));
    text-transform: none;
}
.st-root h2, .st-root h3, .st-root p { margin: 0; }
.st-root button { font: inherit; color: inherit; }

/* ── header ─────────────────────────────────────────────── */
.st-top {
    position: sticky; top: 0; z-index: 3;
    background: #070a0d;
    padding: 18px 0 12px;
    border-bottom: 1px solid var(--st-line);
}
.st-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.st-title { min-width: 0; }
.st-title h2 {
    font-family: 'Orbitron', var(--st-mono); font-weight: 700;
    font-size: clamp(16px, 2.1vw, 22px); letter-spacing: .12em; color: var(--st-accent);
}
.st-root:lang(vi) .st-title h2 { font-family: 'Be Vietnam Pro', sans-serif; letter-spacing: .06em; }
.st-title p { margin-top: 5px; color: var(--st-dim); font-size: 12.5px; }
.st-actions { display: flex; gap: 6px; flex-shrink: 0; }
.st-btn {
    font-family: var(--st-mono) !important; font-size: 12px !important; letter-spacing: .08em;
    color: var(--st-dim) !important; background: transparent; border: 1px solid var(--st-line); border-radius: 7px;
    padding: 7px 10px; cursor: pointer; white-space: nowrap;
}
.st-btn:hover { color: var(--st-text) !important; border-color: #2a3a48; }
.st-close { min-width: 34px; }

.st-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.st-seg {
    display: inline-flex; gap: 2px; padding: 3px;
    background: var(--st-card); border: 1px solid var(--st-line); border-radius: 9px;
}
.st-seg button {
    font-family: var(--st-mono) !important; font-size: 12px !important; letter-spacing: .06em;
    color: var(--st-dim) !important; background: transparent; border: 0; border-radius: 6px;
    padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.st-seg button small { opacity: .65; margin-left: 4px; font-size: 11px; }
.st-seg button.on { background: #11303a; color: var(--st-accent) !important; }
.st-seg button:hover:not(.on) { color: var(--st-text) !important; }

/* ── KPI tiles ──────────────────────────────────────────── */
.st-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 16px 0 12px; }
.st-kpi {
    background: var(--st-card); border: 1px solid var(--st-line); border-radius: 12px;
    padding: 12px 14px; min-width: 0;
}
.st-kpi-l { font-family: var(--st-mono); font-size: 11px; letter-spacing: .14em; color: var(--st-dim); }
.st-kpi-v {
    font-family: 'Orbitron', var(--st-mono); font-weight: 700; font-variant-numeric: tabular-nums;
    font-size: clamp(22px, 2.5vw, 31px); line-height: 1.15; margin: 7px 0 5px;
}
.st-kpi-v small { font-size: .55em; margin-left: 2px; }
.st-kpi-s { font-size: 12px; color: var(--st-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-kpi-prog { height: 4px; border-radius: 2px; background: #18222b; overflow: hidden; margin: 0 0 6px; }
.st-kpi-prog i { display: block; height: 100%; background: var(--st-accent); }

/* ── layout ─────────────────────────────────────────────── */
.st-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.st-span-full { grid-column: 1 / -1; }
.st-span-7 { grid-column: span 7; }
.st-span-5 { grid-column: span 5; }
.st-span-4 { grid-column: span 4; }

.st-card {
    background: var(--st-card); border: 1px solid var(--st-line); border-radius: 12px;
    padding: 14px 16px 16px; min-width: 0;
}
.st-card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.st-card-h h3 { font-family: var(--st-mono); font-weight: 400; font-size: 12.5px; letter-spacing: .18em; color: var(--st-text); }
.st-aside { font-family: var(--st-mono); font-size: 11px; letter-spacing: .08em; color: var(--st-faint); white-space: nowrap; }
.st-mini { font-family: var(--st-mono); font-size: 10.5px; letter-spacing: .14em; color: var(--st-faint); margin-bottom: 8px; }
.st-sep { height: 1px; background: var(--st-line); margin: 12px 0; }
.st-num { font-family: var(--st-mono); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }

.st-good { color: var(--st-good); }
.st-warn { color: var(--st-warn); }
.st-bad { color: var(--st-bad); }
.st-muted { color: var(--st-faint); }

/* bars and category colours */
.st-bar { height: 6px; min-width: 24px; border-radius: 3px; background: #141c24; overflow: hidden; }
.st-bar i { display: block; height: 100%; border-radius: 3px; background: var(--st-accent); }
.st-root .st-c-ontime { background: var(--st-good); }
.st-root .st-c-delayed { background: var(--st-warn); }
.st-root .st-c-cancelled { background: var(--st-bad); }
.st-root .st-c-upcoming { background: var(--st-up); }
.st-root .st-c-accent { background: var(--st-accent); }
.st-root .st-c-alt { background: var(--st-alt); }

.st-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--st-dim); }
.st-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.st-legend b { color: var(--st-text); font-weight: 600; margin-left: 3px; }
.st-stack { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: #141c24; margin-bottom: 10px; }
.st-stack i { display: block; height: 100%; }

/* ── hourly chart ───────────────────────────────────────── */
.st-chart { position: relative; margin-top: 14px; }
.st-plot { position: relative; height: 210px; margin: 0 0 24px 26px; }
.st-grid-line { position: absolute; left: 0; right: 0; border-top: 1px dashed #1b2630; }
.st-grid-line span {
    position: absolute; left: -28px; top: -7px; width: 22px; text-align: right;
    font-family: var(--st-mono); font-size: 10px; color: var(--st-faint);
}
.st-plot::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; border-top: 1px solid #22303c; }
.st-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; }
.st-hcol {
    position: relative; height: 100%; padding: 0; border: 0; background: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.st-hcol:focus { outline: none; }
.st-hcol:focus-visible { outline: 1px solid var(--st-accent); outline-offset: 2px; }
.st-hcol.on::before { content: ''; position: absolute; inset: 0 -2px; border-radius: 4px; background: rgba(0, 216, 240, .08); }
.st-hstack { position: relative; display: flex; flex-direction: column-reverse; height: 100%; }
.st-hstack i { display: block; width: 100%; flex: none; }
.st-hstack i:last-child { border-radius: 3px 3px 0 0; }
.st-hcol:hover .st-hstack, .st-hcol.on .st-hstack { filter: brightness(1.2); }
.st-hlbl {
    position: absolute; bottom: -19px; left: 50%; transform: translateX(-50%);
    font-family: var(--st-mono); font-size: 10px; color: var(--st-dim);
}
.st-hlbl.st-minor { color: var(--st-faint); }
.st-now { position: absolute; top: -4px; bottom: 0; border-left: 1.5px solid #ff5a8a; pointer-events: none; z-index: 1; }
.st-now span {
    position: absolute; top: -10px; left: 4px; white-space: nowrap;
    font-family: var(--st-mono); font-size: 9px; letter-spacing: .12em; color: #ff5a8a;
}
.st-tip {
    position: absolute; top: -6px; z-index: 2; min-width: 180px;
    background: #0f1820; border: 1px solid #23323f; border-radius: 9px; padding: 9px 11px;
    font-size: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, .55); pointer-events: none;
}
.st-tip div { display: flex; align-items: center; gap: 7px; color: var(--st-dim); line-height: 1.75; }
.st-tip b { margin-left: auto; padding-left: 12px; color: var(--st-text); font-family: var(--st-mono); font-weight: 400; }
.st-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.st-tip .st-tip-h { color: var(--st-text); font-family: var(--st-mono); letter-spacing: .04em; margin-bottom: 2px; }
.st-tip .st-tip-f { border-top: 1px solid #23323f; margin-top: 4px; padding-top: 4px; }

/* ── airline table ──────────────────────────────────────── */
.st-al-row {
    display: grid; grid-template-columns: 20px 36px minmax(0, 1.7fr) minmax(36px, 1fr) 44px 46px 60px;
    align-items: center; gap: 10px; width: 100%; padding: 7px 6px;
    background: none; border: 0; border-radius: 8px; text-align: left; cursor: pointer;
}
.st-al-row:hover { background: #111a22; }
.st-al-head { cursor: default; padding-top: 0; padding-bottom: 4px; }
.st-al-head:hover { background: none; }
.st-al-head .st-num { font-size: 10px; letter-spacing: .1em; color: var(--st-faint); }
.st-rank { font-family: var(--st-mono); font-size: 12px; color: var(--st-faint); text-align: right; }
.st-al-logo {
    width: 36px; height: 26px; display: flex; align-items: center; justify-content: center;
    background: #fff; border-radius: 6px; overflow: hidden;
}
.st-logo { max-width: 32px; max-height: 22px; object-fit: contain; }
.st-al-name, .st-rt-name { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.st-al-name b, .st-rt-name b { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-al-name small, .st-rt-name small { color: var(--st-faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-more {
    width: 100%; margin-top: 8px; padding: 8px; cursor: pointer;
    background: none; border: 1px dashed #22303c; border-radius: 8px;
    font-family: var(--st-mono) !important; font-size: 12px !important; letter-spacing: .1em; color: var(--st-dim) !important;
}
.st-more:hover { color: var(--st-text) !important; border-color: #2e4050; }

/* ── routes / countries ─────────────────────────────────── */
.st-rt-row {
    display: grid; grid-template-columns: 24px minmax(0, 1.5fr) minmax(36px, 1fr) 32px;
    align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid #10181f;
}
.st-rt-row:last-of-type { border-bottom: 0; }
.st-flag { font-size: 17px; line-height: 1; text-align: center; }

/* ── delays ─────────────────────────────────────────────── */
.st-dl-row { display: grid; grid-template-columns: 52px 1fr 32px; gap: 10px; align-items: center; padding: 3px 0; font-size: 12px; color: var(--st-dim); }
.st-dl-row .st-bar { height: 8px; }
.st-md-row {
    display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center;
    width: 100%; padding: 6px 4px; background: none; border: 0; border-radius: 8px; text-align: left; cursor: pointer;
}
.st-md-row:hover { background: #111a22; }
.st-md-d {
    display: flex; flex-direction: column; align-items: flex-end;
    font-family: 'Orbitron', var(--st-mono); font-weight: 700; font-size: 14px; color: var(--st-bad);
}
.st-md-d small { font-family: 'Be Vietnam Pro', sans-serif; font-weight: 400; font-size: 10.5px; color: var(--st-faint); }
.st-md-d.st-exp { color: var(--st-warn); }

/* ── fleet & terminals ──────────────────────────────────── */
.st-split { margin-bottom: 12px; }
.st-fl summary {
    display: grid; grid-template-columns: 96px 1fr 32px; gap: 10px; align-items: center;
    padding: 6px 4px; border-radius: 6px; cursor: pointer; list-style: none;
}
.st-fl summary::-webkit-details-marker { display: none; }
.st-fl summary:hover { background: #111a22; }
.st-fl-name { font-family: var(--st-mono); font-size: 13px; letter-spacing: .05em; white-space: nowrap; }
.st-fl-name::before { content: '▸'; display: inline-block; margin-right: 7px; color: var(--st-faint); transition: transform .15s; }
.st-fl[open] .st-fl-name::before { transform: rotate(90deg); }
.st-fl-vars { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 4px 10px 22px; }
.st-fl-vars span {
    font-family: var(--st-mono); font-size: 11.5px; color: var(--st-dim);
    background: #111a22; border: 1px solid var(--st-line); border-radius: 5px; padding: 3px 7px;
}
.st-fl-vars b { color: var(--st-text); font-weight: 400; margin-left: 4px; }
.st-terms { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; }
.st-term { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: #0f161d; border: 1px solid var(--st-line); border-radius: 8px; }
.st-term b { font-family: var(--st-mono); font-weight: 400; font-size: 11px; letter-spacing: .12em; color: var(--st-dim); }
.st-term span { font-family: 'Orbitron', var(--st-mono); font-weight: 700; font-size: 18px; }
.st-term small { font-size: 11px; color: var(--st-faint); }

.st-foot { margin: 16px 2px 0; font-size: 11.5px; color: var(--st-faint); }
.st-empty { color: var(--st-faint); text-align: center; margin: 10px 0; }
.st-empty-big { padding: 70px 0; font-size: 14px; }

/* ── export (off-screen copy) ───────────────────────────── */
.st-export-host { position: fixed; left: -100000px; top: 0; background: #070a0d; }
.st-exporting .st-top { position: static; }
.st-exporting .st-actions, .st-exporting .st-more { display: none; }

/* ── responsive ─────────────────────────────────────────── */
@media (max-width: 1100px) {
    .st-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .st-span-7 { grid-column: 1 / -1; }
    .st-span-5, .st-span-4 { grid-column: span 6; }
}
@media (max-width: 720px) {
    .st-root { padding: 0 12px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .st-top { padding: 12px 0 10px; padding-top: max(12px, env(safe-area-inset-top)); }
    .st-controls { gap: 6px; margin-top: 10px; }
    .st-seg button { padding: 6px 9px; font-size: 11.5px !important; }
    .st-btn { padding: 6px 8px; font-size: 11px !important; }
    .st-kpis { gap: 8px; margin-top: 12px; }
    .st-kpi { padding: 10px 11px; }
    .st-span-5, .st-span-4 { grid-column: 1 / -1; }
    .st-card { padding: 12px 12px 14px; }
    .st-plot { height: 170px; margin-left: 22px; }
    .st-cols { gap: 2px; }
    .st-hlbl.st-minor { display: none; }
}
@media (max-width: 760px) {
    #stats-modal .modal-card.st-modal-card { width: 100vw; border: 0; border-radius: 0; max-height: 100dvh; }
}
@media (max-width: 520px) {
    .st-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .st-al-row { grid-template-columns: 18px 34px minmax(0, 1fr) 38px 44px; gap: 8px; }
    .st-al-bar, .st-al-avg { display: none; }
    .st-btn[title] { display: none; }
}

/* ── taxi times ─────────────────────────────────────────── */
.st-taxi { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 22px; }
.st-taxi-ks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.st-taxi-k { display: flex; flex-direction: column; gap: 3px; padding: 10px; background: #0f161d; border: 1px solid var(--st-line); border-radius: 8px; }
.st-taxi-k b { font-family: 'Orbitron', var(--st-mono); font-size: 22px; font-weight: 700; }
.st-taxi-k b small { font-size: .6em; margin-left: 1px; }
.st-taxi-k span { font-size: 11.5px; color: var(--st-dim); }
.st-tx-chart { position: relative; height: 150px; margin-bottom: 22px; display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; align-items: end; border-bottom: 1px solid #22303c; }
.st-tx-col { position: relative; height: 100%; display: flex; align-items: flex-end; }
.st-tx-col i { display: block; width: 100%; border-radius: 3px 3px 0 0; min-height: 0; }
@media (max-width: 720px) {
    .st-taxi { grid-template-columns: 1fr; }
    .st-tx-chart { gap: 2px; height: 120px; }
}
