:root {
  color-scheme: light;
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f0f3f7; --ink: #0b1220; --ink-2: #4a5568; --muted: #8791a1;
  --line: #e3e8ef; --brand: #1d4ed8; --brand-ink: #ffffff; --brand-soft: #e6eefc;
  --good: #0a8f3c; --good-soft: #e3f6ea; --warn: #b7791f; --warn-soft: #fdf3dc; --bad: #c53030; --bad-soft: #fde8e8;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
  --radius: 16px; --nav-h: 64px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17; --surface: #131a26; --surface-2: #1a2332; --ink: #eef2f8; --ink-2: #b4bfd0; --muted: #7d8aa0;
  --line: #243044; --brand: #5b8def; --brand-ink: #0b0f17; --brand-soft: #172540;
  --good: #3ecf75; --good-soft: #10281b; --warn: #f2b24a; --warn-soft: #2b2210; --bad: #f26b6b; --bad-soft: #2d1515;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#shell { min-height: 100dvh; }
main { padding: 16px 16px calc(var(--nav-h) + 28px); max-width: 1180px; margin: 0 auto; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.top .sub { color: var(--muted); font-size: 13px; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; }

nav#nav { position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav-h); display: flex; background: var(--surface); border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom); box-sizing: content-box; }
nav#nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; color: var(--muted); text-decoration: none; }
nav#nav a.on { color: var(--brand); font-weight: 600; }
nav#nav .brand, nav#nav .only-wide { display: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(2, 1fr); margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi .v { font-size: clamp(18px, 6vw, 28px); font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .d { font-size: 12.5px; color: var(--ink-2); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 13.5px; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px 3px 8px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.badge svg.i { width: 14px; height: 14px; }
.badge.good { background: var(--good-soft); color: var(--good); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.bad { background: var(--bad-soft); color: var(--bad); }

.btn { white-space: nowrap; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 9px 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.field label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
input, select { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; min-height: 42px; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.pw { position: relative; } .pw input { padding-right: 44px; } .pw button { position: absolute; right: 4px; top: 4px; width: 34px; height: 34px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .field { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; margin: 0 -4px; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart { width: 100%; position: relative; } .chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 11px; }
.tip { position: fixed; z-index: 60; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; max-width: 240px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.tip b { display: block; margin-bottom: 2px; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; height: 22px; }
.strip i { border-radius: 3px; background: var(--s1); }

.sheet-bg { position: fixed; inset: 0; background: rgba(5, 10, 20, .5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; max-height: 88dvh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 18px calc(var(--nav-h) + 24px); }
.sheet h2 { font-size: 18px; }
pre.json { background: var(--surface-2); border-radius: 12px; padding: 12px; overflow: auto; max-height: 340px; font-size: 12px; margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 70; font-size: 14px; max-width: 90vw; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: sp .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }
.keybox { display: flex; gap: 6px; align-items: center; background: var(--surface-2); border-radius: 12px; padding: 6px 6px 6px 12px; min-width: 0; }
.keybox span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.flight { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.flight .fares { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.flight .fare { background: var(--surface-2); border-radius: 8px; padding: 3px 8px; font-size: 12.5px; }
.login { max-width: 380px; margin: 14vh auto 0; padding: 0 16px; }

@media (min-width: 900px) {
  :root { --nav-w: 232px; }
  main { margin-left: var(--nav-w); max-width: none; padding: 28px 36px 48px; }
  main > * { max-width: 1120px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: repeat(6, 1fr); }
  nav#nav { top: 0; bottom: auto; right: auto; width: var(--nav-w); height: 100dvh; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 18px 12px; box-sizing: border-box; overflow: auto; }
  nav#nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 14.5px; padding: 11px 12px; border-radius: 12px; }
  nav#nav a.on { background: var(--brand-soft); }
  nav#nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 4px 12px 18px; }
  nav#nav .only-wide { display: flex; }
  nav#nav .mobile-only { display: none; }
  .sheet-bg { align-items: center; } .sheet { border-radius: 20px; padding-bottom: 24px; }
  .toast { bottom: 24px; }
}
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(6, 1fr); } .kpis.three { grid-template-columns: repeat(3, 1fr); } }
