:root {
  color-scheme: light;
  --page: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f2f1ee;
  --text-primary: #17171a;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e6e5e0;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.08);
  --border-strong: rgba(11, 11, 11, 0.14);
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #4a3aa7;
  --seq-100: #cde2fb;
  --seq-250: #86b6ef;
  --seq-400: #3987e5;
  --seq-550: #1c5cab;
  --seq-700: #0d366b;
  --shadow-sm: 0 1px 2px rgba(11, 11, 11, 0.04), 0 1px 1px rgba(11, 11, 11, 0.03);
  --shadow-md: 0 4px 16px rgba(11, 11, 11, 0.06), 0 1px 2px rgba(11, 11, 11, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0b0b0c;
    --surface: #18181a;
    --surface-2: #202022;
    --text-primary: #f5f5f4;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8d86;
    --gridline: #2c2c2a;
    --baseline: #3a3a38;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --accent: #5b9cec;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #9085e9;
    --seq-100: #184f95;
    --seq-250: #1c5cab;
    --seq-400: #2a78d6;
    --seq-550: #6da7ec;
    --seq-700: #cde2fb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse 1200px 900px at 15% -10%, color-mix(in srgb, var(--series-1) 20%, transparent), transparent 60%),
    radial-gradient(ellipse 1000px 700px at 100% 10%, color-mix(in srgb, var(--series-3) 16%, transparent), transparent 60%),
    linear-gradient(180deg, var(--page) 0%, var(--page) 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 20px 16px 56px;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
}

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

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 22px 24px;
}

.hero-sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle 280px at 78% 52%, rgba(255, 219, 163, 0.9), rgba(255, 163, 102, 0.45) 42%, transparent 72%),
    linear-gradient(180deg, #16324f 0%, #35618a 32%, #d98a5a 66%, #f0b378 82%, #f6cd9a 100%);
}

.hero-mountains,
.hero-mountains::after {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
}

.hero-mountains {
  height: 48%;
  background: #1c2836;
  opacity: 0.5;
  clip-path: polygon(0% 100%, 0% 58%, 8% 42%, 16% 62%, 26% 32%, 36% 60%, 46% 22%, 58% 54%, 68% 36%, 78% 60%, 88% 44%, 100% 62%, 100% 100%);
}

.hero-mountains::after {
  content: "";
  top: 18%;
  background: #0c141e;
  opacity: 0.85;
  clip-path: polygon(0% 100%, 0% 74%, 10% 58%, 20% 78%, 32% 52%, 44% 76%, 56% 48%, 68% 74%, 80% 55%, 92% 78%, 100% 62%, 100% 100%);
}

.hero-plane {
  position: absolute;
  top: 38%;
  right: 32%;
  width: 50px;
  transform: rotate(-24deg);
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.35));
}

.hero-plane-icon {
  width: 100%;
  height: auto;
  fill: #fff;
}

.hero-dest {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
}

.hero-dest select {
  font-size: 0.85rem;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(13, 19, 28, 0.45);
  color: #fff;
  backdrop-filter: blur(4px);
  font-family: inherit;
}

.hero-dest select:focus {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 60ch;
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-logo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
}

h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.hero-tagline {
  margin: 8px 0 6px;
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
}

.hero-content .subtitle {
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
}

@media (max-width: 640px) {
  .hero {
    min-height: 220px;
    padding: 18px;
  }
  .hero-dest {
    position: static;
    margin-bottom: 14px;
    align-self: flex-start;
  }
  .hero-dest select {
    width: 100%;
  }
  .hero-content {
    max-width: none;
  }
  .hero-plane {
    width: 34px;
    top: 10%;
    right: 10%;
  }
}

/* ---------- Cards & section rhythm ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  font-size: 1.02rem;
  font-weight: 650;
  margin: 0 0 4px;
  letter-spacing: -0.005em;
}

.card .hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0 0 16px;
  line-height: 1.4;
}

.card h3 {
  font-size: 0.82rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 28px 0 10px;
  color: var(--text-muted);
}

.card h3:first-of-type {
  margin-top: 4px;
}

/* ---------- Quick stats ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.stat-tile::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--tile-color, var(--accent));
}

.stat-tile-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-tile-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.stat-tile-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.controls select,
.header-dest select {
  font-size: 0.92rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
}

.controls select:focus,
.header-dest select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Legend ---------- */

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

/* ---------- Charts ---------- */

svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: hidden;
  font-family: inherit;
}

.axis-label {
  fill: var(--text-muted);
  font-size: 10px;
}

.gridline {
  stroke: var(--gridline);
  stroke-width: 1;
}

.baseline {
  stroke: var(--baseline);
  stroke-width: 1;
}

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  display: none;
  white-space: nowrap;
  z-index: 5;
}

.chart-shell {
  position: relative;
}

.mini-chart-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.mini-chart-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1px;
}

.mini-chart-value {
  margin-left: auto;
  font-size: 0.86rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.status-line {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 10px;
}

.empty-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 16px;
  text-align: center;
  background: var(--surface-2);
  border-radius: 10px;
}

/* ---------- Table ---------- */

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.history-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 650;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.history-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-table tbody tr:hover {
  background: var(--surface-2);
}

/* ---------- Totals / ranked list ---------- */

.totals-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.totals-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.totals-rank {
  width: 20px;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.totals-row-best {
  background: color-mix(in srgb, var(--series-1) 8%, var(--surface-2));
  border-color: color-mix(in srgb, var(--series-1) 35%, var(--border));
}

.totals-row-best .totals-rank {
  color: var(--series-1);
}

.totals-airline {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-primary);
}

.totals-price {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}
