:root {
  --bg-base: #0a0f1a;
  --bg-card: #111827;
  --bg-hover: #1a2332;
  --bg-elevated: #1e293b;
  --border: #1e293b;
  --border-light: #2a3a4e;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;
  --accent: #38bdf8;
  --accent-dim: rgba(56,189,248,.12);
  --green: #34d399;
  --green-dim: rgba(52,211,153,.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251,191,36,.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,.12);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-pill: 20px;
  --shadow-card: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.3);
  --transition: .18s cubic-bezier(.4,0,.2,1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  position: relative;
}
body::before {
  content: '';
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: url('https://images.unsplash.com/photo-1542296332-2e4473faf563?w=1920&q=80&auto=format') center/cover no-repeat;
  opacity: .1;
  z-index: 0;
  pointer-events: none;
  filter: blur(2px);
}
.header, .mobile-stats, .filter-bar, .dest-bar, .airline-bar, .container { position: relative; z-index: 1; }

/* ── Header ── */
.header {
  background: linear-gradient(180deg, #111827 0%, var(--bg-base) 100%);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.header-row {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 1200px; margin: 0 auto;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.brand {
  font-size: 24px; font-weight: 700; color: var(--text-primary);
  letter-spacing: -.3px;
  display: inline-flex; align-items: center; gap: 10px;
  line-height: 32px;
}
.brand em { font-style: normal; color: var(--accent); }
.brand-logo { width: 32px; height: 32px; flex-shrink: 0; display: block; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.85)} }
.header-meta {
  font-size: 11px; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
}
.header-banner {
  text-align: center; padding: 6px 12px;
  font-size: 12px; color: var(--text-muted);
  letter-spacing: .3px;
  position: relative; z-index: 1;
}
.header-right { display: flex; align-items: center; gap: 10px; }
.stat-pills { display: flex; gap: 6px; }
.stat-pill {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
  white-space: nowrap; cursor: pointer;
  transition: all var(--transition); font-family: inherit;
}
.stat-pill:hover { border-color: var(--border-light); }
.stat-pill.active { border-color: var(--accent); background: var(--accent-dim); }
.stat-pill .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-pill.sp-visible .num { color: var(--green); }
.stat-pill.sp-hidden .num { color: var(--yellow); }
.stat-pill.sp-cancel .num { color: var(--red); }

/* ── Toolbar ── */
.toolbar {
  max-width: 1200px; margin: 0 auto;
  padding: 12px 20px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.filter-bar {
  max-width: 1200px; margin: 0 auto;
  padding: 10px 20px 4px;
  display: flex; justify-content: space-between; align-items: center;
}
.filter-group {
  display: flex; gap: 4px;
}
.dep-filter {
  display: flex; gap: 4px;
}
.dep-btn {
  padding: 4px 10px; border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-dim); cursor: pointer; font-size: 12px; font-weight: 600;
  font-family: inherit; border-radius: var(--radius-pill);
  transition: all var(--transition); letter-spacing: .3px;
}
.dep-btn .dep-count {
  font-weight: 400; opacity: .6; font-size: 11px;
}
.dep-btn:hover { border-color: var(--border-light); color: var(--text-secondary); }
.dep-btn.active.dep-mct { border-color: #38bdf8; color: #38bdf8; background: rgba(56,189,248,.08); }
.dep-btn.active.dep-dxb { border-color: #fbbf24; color: #fbbf24; background: rgba(251,191,36,.08); }
.filter-btn {
  padding: 6px 14px; border: none; background: transparent;
  color: var(--text-dim); cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all var(--transition); position: relative;
  font-family: inherit; border-radius: var(--radius-pill);
}
.filter-btn .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.filter-btn:hover { color: var(--text-primary); }
.filter-btn.active {
  color: var(--text-primary); font-weight: 700;
}
.filter-btn.active::after {
  content: ''; position: absolute; bottom: 0; left: 20%; right: 20%;
  height: 2px; background: var(--accent); border-radius: 2px;
}
.filter-sep { color: var(--text-dim); opacity: 0.3; margin: 0 4px; user-select: none; }
.toggle-group { display: flex; gap: 12px; margin-left: 8px; }
.toggle-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 0; border-radius: 0;
  background: transparent; border: none;
  font-size: 12px; color: var(--text-dim); cursor: pointer;
  transition: all var(--transition); user-select: none; -webkit-user-select: none;
}
.toggle-chip:hover { color: var(--text-secondary); }
.toggle-chip.on { color: var(--accent); }
.toggle-chip input { display: none; }
.toggle-icon { font-size: 13px; opacity: .6; }
.toggle-chip.on .toggle-icon { opacity: 1; }

/* ── Dest filter ── */
.dest-bar {
  max-width: 1200px; margin: 0 auto; padding: 0 20px 8px;
}
.dest-toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 0; user-select: none; -webkit-user-select: none;
}
.dest-toggle-label {
  font-size: 11px; color: var(--text-dim); font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px;
}
.dest-toggle-arrow {
  font-size: 9px; color: var(--text-dim); transition: transform .2s;
  display: inline-block;
}
.dest-toggle-arrow.open { transform: rotate(90deg); }
.dest-summary { font-size: 11px; color: var(--text-dim); }
.dest-actions { display: flex; gap: 4px; margin-left: auto; }
.dest-action-btn {
  font-size: 10px; font-weight: 600; font-family: inherit;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); padding: 2px 8px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition); text-transform: uppercase;
  letter-spacing: .3px;
}
.dest-action-btn:hover { border-color: var(--text-muted); color: var(--text-secondary); }
.dest-panel {
  max-height: 0; overflow: hidden; transition: max-height .35s ease;
}
.dest-panel.open { max-height: 800px; }

/* Region row */
.region-row {
  display: flex; align-items: flex-start; gap: 0;
  padding: 5px 0; border-bottom: 1px solid var(--border);
}
.region-row:last-child { border-bottom: none; }
.region-head {
  flex-shrink: 0; width: 120px; min-width: 120px;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0;
}
.region-name {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.region-count {
  font-size: 10px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.region-toggle-btn {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 4px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-dim); cursor: pointer; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); margin-left: 4px; margin-top: 3px;
  font-family: inherit;
}
.region-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.region-toggle-btn.all-visible { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.region-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
  flex: 1; min-width: 0; padding: 2px 0;
}
.dest-chip {
  padding: 3px 7px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-primary); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all .12s;
  text-align: center; font-family: inherit;
  letter-spacing: .3px; line-height: 1.2;
}
.dest-chip:active { transform: scale(.93); }
.dest-chip.hidden {
  background: transparent; color: var(--text-dim); border-color: transparent;
  opacity: .4;
}
.dest-chip:not(.hidden):hover {
  border-color: var(--accent); color: var(--accent);
}

@media (max-width: 768px) {
  .region-head { width: 90px; min-width: 90px; }
  .region-name { font-size: 10px; }
}

/* ── Content ── */
.container { max-width: 1200px; margin: 0 auto; padding: 4px 20px 40px; }

/* ── Column header ── */
.col-header-row,
.flight-row.col-header {
  display: grid;
  grid-template-columns: 90px 180px 1fr 160px 100px 110px;
  gap: 12px; padding: 6px 14px;
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .5px;
  border: none; background: transparent;
  cursor: default;
}
.flight-row.col-header span:nth-child(4),
.flight-row.col-header span:nth-child(5),
.flight-row.col-header span:nth-child(6) { text-align: center; }
.flight-row.col-header:hover {
  background: transparent; box-shadow: none; transform: none;
  border-color: transparent;
}

/* ── Date section ── */
.date-group { margin-bottom: 20px; }
.date-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 0 10px; margin-bottom: 2px;
  font-size: 15px; font-weight: 700; color: var(--text-primary);
  text-transform: uppercase; letter-spacing: .5px;
}
.date-header .count {
  font-size: 12px; color: var(--text-dim);
  font-weight: 500; margin-left: auto;
}
.date-arrow {
  font-size: 10px; color: var(--text-dim); transition: transform .2s;
  display: inline-block;
}
.date-arrow.open { transform: rotate(90deg); }
.flight-list.collapsed { display: none; }

/* ── Flight row (universal) ── */
.flight-list { display: flex; flex-direction: column; gap: 4px; }
.flight-row {
  display: grid;
  grid-template-columns: 90px 180px 1fr 160px 100px 110px;
  align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  text-decoration: none; color: inherit;
  cursor: default;
}
.col-header-row {
  display: grid;
  grid-template-columns: 90px 180px 1fr 160px 100px 110px;
  gap: 12px; padding: 6px 14px;
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  position: sticky; top: 53px; z-index: 50;
  background: var(--bg-base);
}
.flight-row:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
.flight-row.past { opacity: .35; }
.flight-row.past:hover { opacity: .55; }
.flight-row.cancelled {
  opacity: .4;
  text-decoration: line-through;
  text-decoration-color: var(--text-dim);
}
.flight-row.cancelled:hover { opacity: .6; }

.fr-flight {
  font-weight: 700; font-size: 14px; color: var(--text-primary);
  letter-spacing: .2px;
}
.fr-time {
  font-variant-numeric: tabular-nums; font-weight: 600;
  font-size: 14px; color: var(--text-primary);
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
}
.fr-sched {
  font-size: 11px; color: var(--text-dim); font-weight: 400;
  text-decoration: line-through; opacity: .7;
}
.delay-tag {
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.delay-tag.on-time { color: var(--green); }
.delay-tag.delayed { color: var(--yellow); }
.delay-tag.delay-severe { color: var(--red); }
.fr-route {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.fr-dep {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 1px 5px; border-radius: 3px;
  flex-shrink: 0; line-height: 1.4;
}
.dep-mct { background: rgba(56,189,248,.15); color: #38bdf8; }
.dep-dxb { background: rgba(251,191,36,.15); color: #fbbf24; }
.fr-dest {
  font-weight: 800; font-size: 15px; color: var(--yellow);
  flex-shrink: 0; letter-spacing: .5px;
}
.fr-sep {
  color: var(--text-dim); font-size: 13px; flex-shrink: 0;
  transform: rotate(-20deg); display: inline-block;
  opacity: .5; margin: 0 2px;
}
.fr-city {
  color: var(--text-secondary); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fr-airline {
  color: var(--accent); font-size: 12px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .2px; text-align: center;
}
.fr-price { justify-self: center; }
.fr-track { justify-self: center; }
.fr-right {
  display: flex; align-items: center; gap: 8px;
  justify-self: end;
}

/* ── Status badges ── */
.status-badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600; white-space: nowrap;
  letter-spacing: .2px;
}
.status-scheduled { background: var(--bg-elevated); color: var(--text-muted); }
.status-departed { background: var(--green-dim); color: var(--green); }
.status-delayed { background: var(--yellow-dim); color: var(--yellow); }
.status-landed { background: var(--accent-dim); color: var(--accent); }
.status-cancelled { background: var(--red-dim); color: var(--red); }
.status-unknown { background: var(--bg-elevated); color: var(--text-dim); }

/* ── Ticket buttons ── */
.ticket-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; text-decoration: none;
  transition: all var(--transition); white-space: nowrap;
  cursor: pointer;
}
.ticket-btn.has-price {
  color: var(--green); background: var(--green-dim);
  border: 1px solid rgba(52,211,153,.2);
}
.ticket-btn.has-price:hover {
  background: rgba(52,211,153,.2); border-color: var(--green);
}
.ticket-btn.no-price {
  color: var(--text-muted); background: transparent;
  border: 1px solid var(--border);
}
.ticket-btn.no-price:hover {
  border-color: var(--text-dim); color: var(--text-secondary);
}
.ticket-btn.no-ticket {
  color: var(--text-dim); background: transparent;
  border: 1px solid var(--border); opacity: .6;
}
.ticket-btn.no-ticket:hover {
  border-color: var(--text-dim); opacity: .85; color: var(--text-secondary);
}
.ticket-btn.no-data {
  color: var(--text-dim); background: transparent;
  border: 1px solid var(--border); opacity: .5;
  text-decoration: none;
}
.ticket-btn.no-data:hover {
  border-color: var(--text-dim); opacity: .7;
}
.ticket-btn.no-ticket .ticket-arrow,
.ticket-btn.no-data .ticket-arrow {
  opacity: .6;
}
.ticket-arrow { font-size: 10px; }
.price-time {
  display: block; font-size: 10px; color: var(--text-dim);
  text-align: center; margin-top: 1px; opacity: .7;
}

/* ── Sparkline ── */
.ticket-spark {
  display: inline-flex; align-items: center; gap: 6px;
}
.spark-slot {
  display: inline-flex; align-items: center;
  width: 110px; min-width: 110px; max-width: 110px;
  justify-content: flex-end;
  overflow: hidden; flex-shrink: 0;
}
.sparkline {
  display: block; vertical-align: middle;
}
.spark-tooltip {
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 6px 10px;
  font-size: 11px; color: var(--text-primary); white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity .15s;
  z-index: 10; box-shadow: 0 4px 12px rgba(0,0,0,.5);
}
.spark-wrap { position: relative; display: inline-flex; cursor: pointer; flex-shrink: 0; max-width: 110px; }
.spark-wrap:hover .spark-tooltip { opacity: 1; }
.spark-delta {
  font-size: 10px; font-weight: 600; padding: 1px 5px;
  border-radius: 4px; white-space: nowrap;
}
.spark-delta.up { color: var(--red); background: var(--red-dim); }
.spark-delta.down { color: var(--green); background: var(--green-dim); }
.spark-delta.flat { color: var(--text-dim); background: var(--bg-elevated); }

/* ── Skeleton loading ── */
.skeleton-list { display: flex; flex-direction: column; gap: 4px; }
.skeleton-row {
  height: 48px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Empty / Error / Status ── */
.error-box {
  background: var(--red-dim); border: 1px solid rgba(248,113,113,.2);
  border-radius: var(--radius); padding: 24px; text-align: center;
  color: #fca5a5; font-size: 14px;
}
.empty-box {
  text-align: center; padding: 48px 20px;
  color: var(--text-dim); font-size: 14px;
}
.status-box {
  border-radius: var(--radius); padding: 48px 24px;
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 10px;
}
.status-box.loading {
  background: var(--accent-dim); border: 1px solid rgba(56,189,248,.15);
}
.status-box.error {
  background: var(--red-dim); border: 1px solid rgba(248,113,113,.15);
}
.status-icon { font-size: 32px; line-height: 1; }
.status-title {
  font-size: 16px; font-weight: 600;
  color: var(--text-primary);
}
.status-detail {
  font-size: 13px; color: var(--text-muted);
  max-width: 360px; line-height: 1.5;
}
.status-spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .header { padding: 8px 12px; }
  .header-row { flex-wrap: nowrap; gap: 8px; }
  .header-left { flex-shrink: 0; }
  .brand { font-size: 15px; gap: 6px; white-space: nowrap; }
  .brand-logo { width: 24px; height: 24px; }
  .header-right { flex-shrink: 1; min-width: 0; }
  .header-meta { flex-wrap: wrap; font-size: 10px; line-height: 1.4; text-align: right; }
  .stat-pills { display: none; }
  .toolbar { padding: 8px 12px; gap: 6px; }
  .dest-bar { padding: 0 12px 4px; }
  .container { padding: 2px 8px 32px; }

  /* Hide mobile-stats — filter buttons already show counts */
  .mobile-stats { display: none !important; }

  /* Filter bar: 2-col grid — filters left, dep right */
  .filter-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    padding: 6px 12px 2px; gap: 0 8px;
    align-items: center;
  }
  /* Filter group: row 1+2 left, wraps into 2 rows */
  .filter-group {
    grid-column: 1; grid-row: 1 / 3;
    display: flex; flex-wrap: wrap; gap: 2px;
  }
  .filter-btn { padding: 4px 8px; font-size: 11px; white-space: nowrap; }
  /* Separator forces line break */
  .filter-sep {
    flex-basis: 100%; height: 0; margin: 0; overflow: hidden;
    border: none; opacity: 0;
  }
  /* Dep filter: row 1 right, vertically centered */
  .dep-filter {
    grid-column: 2; grid-row: 1 / 3;
    display: flex; flex-direction: column; gap: 4px;
    align-self: center;
  }
  .dep-btn { font-size: 11px; padding: 3px 8px; }

  /* Hide column header on mobile */
  .flight-row.col-header { display: none; }

  /* Flight card layout */
  .flight-row {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 2px 6px;
    padding: 8px 10px;
    border-radius: 8px;
  }
  .flight-list { gap: 3px; }
  .fr-flight { grid-column: 1; grid-row: 1; font-size: 13px; }
  .fr-time { grid-column: 2; grid-row: 1; justify-self: end; font-size: 13px; }
  .fr-route { grid-column: 1; grid-row: 2; gap: 4px; }
  .fr-dest { font-size: 13px; }
  .fr-city { font-size: 11px; }
  .fr-sep { font-size: 11px; }
  .fr-dep { font-size: 9px; padding: 1px 4px; }
  .fr-airline { grid-column: 2; grid-row: 2; justify-self: end; font-size: 11px; }
  .fr-price { grid-column: 1; grid-row: 3; justify-self: start; }
  .fr-track { grid-column: 2; grid-row: 3; justify-self: end; }
  .fr-price {
    padding-top: 4px; margin-top: 2px;
    border-top: 1px solid var(--border);
  }
  .fr-track {
    padding-top: 4px; margin-top: 2px;
    border-top: 1px solid transparent;
  }

  .fr-right {
    grid-column: 1 / -1; grid-row: 3;
    justify-self: stretch;
    justify-content: space-between;
    padding-top: 4px; border-top: 1px solid var(--border);
    margin-top: 2px;
  }

  /* Ticket button mobile sizing */
  .ticket-btn { font-size: 11px; padding: 3px 8px; }
  .price-time { font-size: 9px; }

  /* Sparkline mobile */
  .spark-slot { width: 80px; min-width: 80px; max-width: 80px; }

  /* Date header */
  .date-group { margin-bottom: 12px; }
  .date-header { font-size: 13px; padding: 8px 0 4px; }
  .date-header .count { font-size: 11px; }

  /* Region chips mobile */
  .region-head { width: 70px; min-width: 70px; }
  .region-name { font-size: 9px; }
  .dest-chip { font-size: 10px; padding: 2px 5px; }
}
@media (min-width: 769px) {
  .mobile-stats { display: none; }
}
