/* ── Theme tokens (mirrored from network/web index.css) ───────────────── */
:root {
  --radius: 0.625rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --border: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
ul { list-style: none; padding: 0; margin: 0; }

.muted { color: var(--muted-foreground); }
.small { font-size: 11px; }
.hidden { display: none !important; }

/* ── Layout ───────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar (mirrors network/web Sidebar.tsx) ────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: color-mix(in oklab, var(--muted) 30%, transparent);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand { font-weight: 600; font-size: 13px; }
.icon { width: 20px; height: 20px; }
.icon-primary { color: var(--primary); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.nav-section .nav-label {
  margin: 0 0 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--foreground);
  transition: background 120ms;
}
.nav-link:hover { background: var(--accent); }
.nav-link.active {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 500;
}
.nav-section ul { display: flex; flex-direction: column; gap: 2px; }

/* ── Main ─────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
  background: var(--background);
}
/* ── Filter bar ───────────────────────────────────────────────────────── */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0;
  padding: 14px 32px;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 24px;
  align-items: flex-end;
  flex-wrap: wrap;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}
.filter { display: flex; flex-direction: column; gap: 6px; }
.filter label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filter-bases { flex: 0 0 auto; min-width: 0; }
.year-filter { flex: 0 0 110px; }
#year-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  outline: none;
  margin: 12px 0 8px;
}
#year-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  border: none;
}
#year-slider::-moz-range-track {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  border: none;
}
#year-slider::-moz-range-progress { background: var(--border); height: 4px; border-radius: 999px; }
#year-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--background);
  cursor: pointer;
  margin-top: -5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
#year-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--background);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.filter-airline, .filter-view { flex: 0 0 auto; }

.chips { display: flex; flex-wrap: nowrap; gap: 4px; }
.chip {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--muted-foreground);
  transition: all 120ms;
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}
.chip:hover { border-color: var(--ring); }

.multi-dropdown { position: relative; }
.multi-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  min-width: 160px;
  justify-content: space-between;
  cursor: pointer;
}
.multi-dropdown-toggle .caret { font-size: 10px; color: var(--muted-foreground); }
.multi-dropdown-toggle:hover { border-color: var(--ring); }
.multi-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  min-width: 180px;
  max-height: 280px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.multi-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--foreground);
  border-radius: 4px;
  cursor: pointer;
}
.multi-dropdown-item:hover { background: var(--muted); }
.multi-dropdown-item input[type="checkbox"] { margin: 0; cursor: pointer; }

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  background: var(--background);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.seg-btn {
  border: none;
  background: transparent;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 4px;
  color: var(--muted-foreground);
}
.seg-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.dual-range {
  position: relative;
  height: 28px;
  display: flex;
  align-items: center;
}
.dual-range .track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  background: var(--border);
  border-radius: 999px;
}
.dual-range .track-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--primary);
  border-radius: 999px;
}
.dual-range input[type="range"] {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  height: 28px;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.dual-range input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
  height: 4px;
}
.dual-range input[type="range"]::-moz-range-track {
  background: transparent;
  height: 4px;
}
.dual-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--background);
  border: 2px solid var(--primary);
  cursor: grab;
  margin-top: -5px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.dual-range input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--background);
  border: 2px solid var(--primary);
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.btn-ghost {
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  height: fit-content;
}
.btn-ghost:hover { background: var(--accent); }

/* ── Sections & cards ─────────────────────────────────────────────────── */
.section {
  padding: 32px;
  border-bottom: 1px solid var(--border);
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.section-head .section-sub { margin-bottom: 0; }
.section-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.section-sub { margin: 0 0 20px; font-size: 13px; }

.grid-1 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
}
.grid-asym {
  display: grid;
  grid-template-columns: minmax(360px, 38fr) minmax(420px, 62fr);
  gap: 16px;
}
.grid-1 + .grid-1,
.grid-1 + .grid-2,
.grid-1 + .grid-asym,
.grid-2 + .grid-1,
.grid-2 + .grid-2,
.grid-2 + .grid-asym,
.grid-asym + .grid-1,
.grid-asym + .grid-2,
.grid-asym + .grid-asym { margin-top: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  min-height: 360px;
}
.grid-2 > .card { min-height: 396px; }
.grid-2 > .card .chart-area { min-height: 330px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.card-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.card-actions { display: flex; gap: 4px; }
.card-actions button {
  border: 1px solid var(--border);
  background: var(--background);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 4px;
  color: var(--muted-foreground);
}
.card-actions button.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.chart-area { flex: 1; min-height: 300px; }
.card-tall { min-height: 612px; }
.card-tall .chart-area { min-height: 561px; }
.card-medium { min-height: 520px; }
.card-medium .chart-area { min-height: 460px; }

.table-wrap {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
th, td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
thead th {
  background: var(--muted);
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}

/* ── Per-base deep-dive card ─────────────────────────────────────────── */
.card-deepdive { min-height: 440px; }
.deepdive-body {
  display: flex;
  gap: 14px;
  flex: 1;
  min-height: 0;
}
.deepdive-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 64px;
  border-right: 1px solid var(--border);
  padding-right: 8px;
  overflow-y: auto;
}
.deepdive-tabs button {
  border: none;
  background: transparent;
  padding: 6px 8px;
  font-size: 12px;
  text-align: left;
  border-radius: 6px;
  color: var(--muted-foreground);
  transition: background 120ms, color 120ms;
}
.deepdive-tabs button:hover { background: var(--accent); color: var(--foreground); }
.deepdive-tabs button.active {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 500;
}
.deepdive-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.deepdive-main .chart-area { flex: 1; }

.card-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted-foreground);
}
.card-controls label { font-weight: 500; }
.card-controls .ml { margin-left: 12px; }
.card-controls.inline { margin-bottom: 0; }
.card-controls select {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
}
