/* airhistory — light and dark are both selected, not one flipped from the other. */

:root {
  color-scheme: light;

  --page:            #f9f9f7;
  --surface-1:       #fcfcfb;
  --surface-2:       #f2f1ed;
  --text-primary:    #0b0b0b;
  --text-secondary:  #52514e;
  --muted:           #898781;
  --grid:            #e1e0d9;
  --axis:            #c3c2b7;
  --border:          rgba(11, 11, 11, 0.10);
  --shadow:          0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);

  --series-1:        #2a78d6;
  --series-2:        #eb6834;
  --series-3:        #1baf7a;

  /* Ordinal ramp: cabins are ordered (economy → first), so one hue, stepped.
     Light mode starts no lighter than step 250 so the first step stays visible. */
  --ordinal-1:       #86b6ef;
  --ordinal-2:       #5598e7;
  --ordinal-3:       #2a78d6;
  --ordinal-4:       #1c5cab;

  --good:            #0ca30c;
  --warning:         #fab219;
  --critical:        #d03b3b;
  --success-text:    #006300;

  --radius:          10px;
  --radius-sm:       6px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:           #0d0d0d;
    --surface-1:      #1a1a19;
    --surface-2:      #232322;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --muted:          #898781;
    --grid:           #2c2c2a;
    --axis:           #383835;
    --border:         rgba(255, 255, 255, 0.10);
    --shadow:         none;

    --series-1:       #3987e5;
    --series-2:       #d95926;
    --series-3:       #199e70;

    --ordinal-1:      #184f95;
    --ordinal-2:      #256abf;
    --ordinal-3:      #3987e5;
    --ordinal-4:      #6da7ec;

    --success-text:   #0ca30c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page:           #0d0d0d;
  --surface-1:      #1a1a19;
  --surface-2:      #232322;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --muted:          #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --border:         rgba(255, 255, 255, 0.10);
  --shadow:         none;

  --series-1:       #3987e5;
  --series-2:       #d95926;
  --series-3:       #199e70;

  --ordinal-1:      #184f95;
  --ordinal-2:      #256abf;
  --ordinal-3:      #3987e5;
  --ordinal-4:      #6da7ec;

  --success-text:   #0ca30c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px 64px; }

/* --- header --------------------------------------------------------- */

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 56px;
}
.brand {
  font-weight: 620;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand svg { color: var(--series-1); }

.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text-primary); }
.nav a.active { background: var(--surface-2); color: var(--text-primary); font-weight: 560; }

.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: var(--series-2);
  color: #fff;
  font-size: 11px;
  font-weight: 620;
  text-align: center;
  line-height: 18px;
}

.icon-button {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.icon-button:hover { color: var(--text-primary); background: var(--surface-2); }

/* --- filter row ------------------------------------------------------ */

.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 20px 0 4px;
}
.filters form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.chip:hover { color: var(--text-primary); text-decoration: none; }
.chip.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--page);
  font-weight: 560;
}
.filters .spacer { flex: 1; }

/* --- page heading ---------------------------------------------------- */

.page-head { padding: 14px 0 20px; }
h1 {
  font-size: 26px;
  font-weight: 620;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.page-head p { margin: 0; color: var(--text-secondary); font-size: 14px; }

h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 2px;
}
h3 { font-size: 14px; font-weight: 600; margin: 0 0 10px; color: var(--text-secondary); }

/* --- cards & grid ---------------------------------------------------- */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stack { display: grid; gap: 14px; }

@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

/* --- stat tiles ------------------------------------------------------ */

.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.tile .label, .hero .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 560;
}
.tile .value {
  font-size: 30px;
  font-weight: 640;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-top: 6px;
  /* Proportional figures: tabular-nums makes a large standalone number loose. */
}
.tile .value .unit { font-size: 15px; font-weight: 500; color: var(--text-secondary); margin-left: 3px; letter-spacing: 0; }
.tile .hint, .hero .hint { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

.hero {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.hero .value { font-size: 44px; font-weight: 660; letter-spacing: -0.035em; line-height: 1.05; }
.hero .value .unit { font-size: 18px; font-weight: 500; color: var(--text-secondary); margin-left: 4px; letter-spacing: 0; }

/* --- tables ---------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-weight: 560;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
td {
  padding: 9px 10px 9px 0;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; }
.route-cell { font-weight: 560; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: 12px; }

/* --- badges ---------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 560;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.cabin-business, .badge.cabin-first { background: var(--series-1); border-color: transparent; color: #fff; }
.badge.cabin-premium_economy { background: var(--ordinal-2); border-color: transparent; color: #fff; }
.badge.estimated { color: var(--muted); }
.badge.ok { color: var(--success-text); }
.badge.warn { color: var(--critical); }

/* --- forms ----------------------------------------------------------- */

label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 560; }
input[type="text"], input[type="date"], input[type="time"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--page);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--series-1); outline-offset: -1px; border-color: transparent; }
.field { margin-bottom: 12px; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.checkline { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.checkline input { width: auto; }
.checkline label { margin: 0; font-size: 14px; color: var(--text-primary); font-weight: 400; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--series-1);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
}
.button:hover { text-decoration: none; filter: brightness(1.06); }
.button.secondary { background: var(--surface-1); color: var(--text-primary); border-color: var(--border); }
.button.secondary:hover { background: var(--surface-2); filter: none; }
.button.danger { background: transparent; color: var(--critical); border-color: var(--border); }
.button.small { padding: 5px 10px; font-size: 13px; }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- messages -------------------------------------------------------- */

.note {
  border: 1px solid var(--border);
  border-left: 3px solid var(--axis);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface-1);
  font-size: 14px;
  color: var(--text-secondary);
}
.note.warn { border-left-color: var(--warning); }
.note.bad { border-left-color: var(--critical); }
.note.good { border-left-color: var(--good); }
.note strong { color: var(--text-primary); }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty h2 { color: var(--text-primary); margin-bottom: 6px; }

/* --- charts ---------------------------------------------------------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .bar { fill: var(--series-1); }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.chart .bar-hit:hover + .bar, .chart .bar-hit:focus + .bar { filter: brightness(1.15); }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-1); opacity: 0.08; }
.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .value-label { fill: var(--text-secondary); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--page);
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 90ms ease;
  z-index: 30;
}
.tooltip.show { opacity: 1; }
.tooltip b { font-weight: 620; }

.chart-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
}
.chart-toggle:hover { color: var(--text-primary); text-decoration: underline; }
.chart-table { display: none; margin-top: 12px; }
.chart-table.show { display: block; }

/* --- share bars (splits) --------------------------------------------- */

.shares { display: grid; gap: 10px; }
.share-row { display: grid; grid-template-columns: 108px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.share-label { color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.share-track { background: var(--surface-2); border-radius: 3px; height: 8px; overflow: hidden; }
.share-fill { height: 100%; border-radius: 3px; background: var(--series-1); }
.share-value { font-variant-numeric: tabular-nums; color: var(--text-secondary); min-width: 72px; text-align: right; }

/* --- map ------------------------------------------------------------- */

.map-wrap { position: relative; background: var(--surface-1); border-radius: var(--radius); }
.map-wrap svg { display: block; width: 100%; height: auto; }
.map-land { fill: var(--surface-2); stroke: var(--grid); stroke-width: 0.4; }
.map-graticule { stroke: var(--grid); stroke-width: 0.4; fill: none; opacity: 0.7; }
.map-arc { fill: none; stroke: var(--series-1); stroke-linecap: round; opacity: 0.75; }
.map-node { fill: var(--series-2); stroke: var(--surface-1); stroke-width: 1.2; }
.map-node-label { fill: var(--text-secondary); font-size: 8px; font-family: var(--font); }

/* --- scan preview ---------------------------------------------------- */

.scan { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.scan img { display: block; width: 100%; height: auto; }

.dropzone {
  border: 2px dashed var(--axis);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  background: var(--surface-1);
  transition: border-color 120ms ease, background 120ms ease;
  cursor: pointer;
}
.dropzone.over { border-color: var(--series-1); background: var(--surface-2); }
.dropzone p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.dropzone strong { font-size: 15px; }
.file-list { margin-top: 12px; font-size: 13px; color: var(--text-secondary); text-align: left; }

/* --- detail lists ---------------------------------------------------- */

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; }
.fact .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 560; }
.fact .v { font-size: 15px; margin-top: 2px; }
.fact .v.mono { font-variant-numeric: tabular-nums; }

.route-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.route-hero .code { font-size: 32px; font-weight: 660; letter-spacing: -0.02em; line-height: 1; }
.route-hero .place { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.route-hero .arrow { color: var(--muted); flex: none; }

.timeline { display: grid; gap: 0; }
.tl-row { display: grid; grid-template-columns: 62px 20px 1fr; gap: 10px; align-items: start; padding: 7px 0; }
.tl-time { font-variant-numeric: tabular-nums; font-weight: 560; text-align: right; font-size: 14px; }
.tl-dot { position: relative; display: grid; place-items: center; }
.tl-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--series-1); margin-top: 6px; }
.tl-row:not(:last-child) .tl-dot::after { content: ""; position: absolute; top: 16px; bottom: -14px; width: 1px; background: var(--grid); }
.tl-what { font-size: 14px; }
.tl-what .sub { display: block; }

footer { color: var(--muted); font-size: 12px; padding: 32px 0 0; text-align: center; }
