:root {
  --bg: #0f1117;
  --card-bg: #1a1d27;
  --border: #2a2d3a;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #6c8cff;
  --green: #2ecc71;
  --amber: #f39c12;
  --red: #e74c3c;
  --radius: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 1rem;
  overflow-x: hidden;
}

header {
  text-align: center;
  padding: 1.5rem 0 1rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 400;
}

main {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow: hidden;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header h2 {
  margin-bottom: 0;
}

/* Current status */
.current-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.big-number {
  font-size: 2.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.big-number .separator {
  color: var(--text-dim);
  font-weight: 300;
  margin: 0 0.15em;
}

#current-max {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 1.5rem;
}

.status-badge {
  padding: 0.35rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.light {
  background: rgba(46, 204, 113, 0.15);
  color: var(--green);
}

.status-badge.moderate {
  background: rgba(243, 156, 18, 0.15);
  color: var(--amber);
}

.status-badge.heavy {
  background: rgba(231, 76, 60, 0.15);
  color: var(--red);
}

.gauge-container {
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.gauge-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.8s ease, background-color 0.8s ease;
  width: 0%;
}

.gauge-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
}

/* Typical forecast row */
.typical-forecast {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2rem;
  margin-top: 0.75rem;
}

.typical-forecast-header {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  align-self: center;
}

.typical-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.typical-slot-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.typical-slot-pct {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.vs-typical {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 0.35rem;
}

.vs-typical.vs-higher {
  color: var(--red);
}

.vs-typical.vs-lower {
  color: var(--green);
}

/* Best times to arrive today */
.best-times-today {
  margin-top: 0.75rem;
  text-align: center;
}

.best-times-header {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.best-times-list {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

.best-time-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.best-time-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--green);
}

.best-time-occ {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.timestamp {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 0.5rem;
}

/* Toggle buttons */
.toggle-group {
  display: flex;
  gap: 2px;
  background: var(--border);
  border-radius: 6px;
  padding: 2px;
}

.toggle-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.3rem 0.75rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
}

.toggle-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Charts */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
}

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

/* Heatmap */
.heatmap-container {
  overflow-x: auto;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: 50px repeat(24, 1fr);
  grid-template-rows: auto repeat(7, 32px);
  gap: 2px;
  min-width: 600px;
}

.heatmap-grid .hour-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.2;
  padding-bottom: 4px;
}

.heatmap-grid .day-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  padding-right: 6px;
}

.heatmap-cell {
  border-radius: 3px;
  position: relative;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
}

.heatmap-cell .tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

.heatmap-cell:hover .tooltip {
  display: block;
}

.heatmap-now {
  outline: 2px solid #fff;
  outline-offset: -1px;
  z-index: 1;
}

.heatmap-now-label {
  color: #fff;
  font-weight: 700;
}

/* Bar list rows (day-of-week / hourly averages) */
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.bar-row .bar-label {
  width: 55px;
  text-align: right;
  color: var(--text-dim);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.bar-row .bar-track {
  flex: 1;
  height: 20px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.bar-row .bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.bar-row .bar-stats {
  width: 140px;
  text-align: right;
  color: var(--text-dim);
  font-size: 0.75rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Recent changes table */
.table-wrap {
  overflow-x: auto;
}

.changes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.changes-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.changes-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

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

@media (max-width: 600px) {
  body {
    padding: 0.5rem;
  }

  .card {
    padding: 1rem;
  }

  .big-number {
    font-size: 2rem;
  }

  #current-max {
    font-size: 1.2rem;
  }

  .chart-wrap {
    height: 220px;
  }

  /* Heatmap: scrollable within card */
  .heatmap-grid {
    min-width: 500px;
    grid-template-rows: auto repeat(7, 28px);
  }

  .heatmap-cell {
    font-size: 0.45rem;
  }

  /* Bar rows: stack stats below bar */
  .bar-row {
    flex-wrap: wrap;
    gap: 4px;
  }

  .bar-row .bar-label {
    width: 45px;
    font-size: 0.8rem;
  }

  .bar-row .bar-track {
    flex: 1;
    min-width: 0;
  }

  .bar-row .bar-stats {
    width: 100%;
    text-align: left;
    padding-left: 55px;
    font-size: 0.7rem;
  }

  /* Changes table: smaller text */
  .changes-table {
    font-size: 0.75rem;
  }

  .changes-table th,
  .changes-table td {
    padding: 0.3rem 0.4rem;
  }
}
