:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b9eff;
  --good: #34d399;
  --warn: #fbbf24;
  --deal: #22c55e;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.header {
  background: linear-gradient(135deg, #1a2a44 0%, #0f1419 60%);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.last-update {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}

.stat-card .label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .value {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 0.2rem;
}

.stat-card.deal .value {
  color: var(--deal);
}

.trend-charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.trend-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem 0.65rem;
}

.trend-chart-card h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.trend-chart-sub {
  margin: 0.15rem 0 0.5rem;
  font-size: 0.72rem;
}

.trend-chart-wrap {
  position: relative;
  height: 88px;
}

.trend-chart-wrap canvas {
  width: 100% !important;
  height: 88px !important;
}

.trend-chart-empty {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 1.5rem 0;
  text-align: center;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.filters-panel {
  padding-bottom: 1rem;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.field input,
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.65rem;
}

.field input[type="date"] {
  color-scheme: dark;
  min-height: 2.25rem;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(59, 158, 255, 0.35);
  border-color: var(--accent);
}

.filter-summary {
  margin: 0.75rem 0 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 0.75rem;
}

.muted {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th {
  text-align: left;
  padding: 0.6rem 0.65rem;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.7rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

tbody tr:hover,
tbody tr:focus-visible {
  background: var(--surface-hover);
  outline: none;
}

.route-tag {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
}

.route-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.dates-cell .trip-inline {
  display: none;
}

.col-trip {
  white-space: nowrap;
}

.provider {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #243044;
  color: var(--accent);
}

.provider-google_flights {
  color: #93c5fd;
}

.provider-air_canada {
  color: #fca5a5;
}

.provider-westjet {
  color: #86efac;
}

.price-cell .price {
  display: block;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.price-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.delta {
  font-size: 0.8rem;
  white-space: nowrap;
}

.delta.down {
  color: var(--deal);
}

.delta.up {
  color: var(--warn);
}

.muted-cell {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.actions {
  white-space: nowrap;
}

.actions .btn-link + .btn-link {
  margin-left: 0.5rem;
}

.badge {
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-weight: 600;
  margin-right: 0.2rem;
}

.badge.deal {
  background: rgba(34, 197, 94, 0.15);
  color: var(--deal);
}

.badge.ok {
  background: rgba(59, 158, 255, 0.12);
  color: var(--accent);
}

.badge.high {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warn);
}

.badge.low {
  background: rgba(167, 139, 250, 0.15);
  color: #c4b5fd;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem !important;
}

.chart-panel.hidden {
  display: none;
}

#price-chart {
  max-height: 300px;
}

.chart-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.chart-meta a {
  color: var(--accent);
}

@media (max-width: 900px) {
  .trend-charts {
    grid-template-columns: 1fr;
  }

  th:nth-child(6),
  td:nth-child(6),
  th.col-status,
  td.col-status {
    display: none;
  }

  th.col-trip,
  td.col-trip {
    display: none;
  }

  .dates-cell .trip-inline {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.72rem;
    color: var(--muted);
  }
}

@media (max-width: 600px) {
  h1 {
    font-size: 1.35rem;
  }

  th:nth-child(8),
  td:nth-child(8) {
    display: none;
  }
}
