/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0f172a;
  --surface:    #1e293b;
  --surface2:   #334155;
  --text:       #f1f5f9;
  --text-muted: #94a3b8;
  --border:     #334155;
  --radius:     12px;

  --zeer-goedkoop: #16a34a;
  --goedkoop:      #4ade80;
  --normaal:       #fbbf24;
  --duur:          #f97316;
  --zeer-duur:     #ef4444;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.875rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.nav-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface2);
  border-radius: 999px;
  padding: 3px;
}

.nav-tab {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.875rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-tab:hover { color: var(--text); }

.nav-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ===== Main layout ===== */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

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

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

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

.subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ===== Hero ===== */
.hero-card {
  text-align: center;
  padding: 2rem 1.25rem;
}

.hero-label {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.hero-category {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.hero-prices {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.hero-prices strong {
  color: var(--text);
}

.hero-time {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge.forecast { color: #93c5fd; border-color: #3b82f6; }

/* ===== Timeline chart ===== */
/* .chart-wrap is shared with performance.html */

/* ===== Horizon slider ===== */
.slider-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.slider-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.deadline-selector {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface2);
}

.deadline-weekday {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.4rem 0 0.4rem 0.625rem;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

input[type="date"],
input[type="time"] {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text);
  font-size: 0.875rem;
  padding: 0.4rem 0.5rem;
  outline: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  color-scheme: dark;
}

input[type="date"]:focus,
input[type="time"]:focus {
  background: rgba(255,255,255,0.04);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.slider-cap {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 1.5rem;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--surface2);
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* ===== 7-day overview ===== */
.days-overview {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.day-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.day-name {
  font-weight: 600;
  font-size: 0.9375rem;
  min-width: 3rem;
  white-space: nowrap;
}

.day-date {
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.day-bars-wrap {
  flex: 1;
  min-width: 0;
}

.day-mini-bars {
  display: flex;
  gap: 1px;
}

.day-mini-bar {
  height: 18px;
  flex: 1;
  border-radius: 2px;
  cursor: default;
  min-width: 0;
}

.day-mini-bar--past {
  opacity: 0.35;
}

.day-mini-bar--empty {
  background: transparent;
  pointer-events: none;
}

.day-time-ticks {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  margin-top: 2px;
  font-size: 0.625rem;
  color: var(--text-muted);
  text-align: center;
}

/* ===== Performance page ===== */
.chart-wrap {
  position: relative;
  height: 260px;
  margin-top: 1rem;
}

.perf-note {
  font-size: 0.8125rem;
  color: #93c5fd;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

.bucket-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

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

.bucket-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

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

.accuracy-bar-bg {
  background: var(--surface2);
  border-radius: 999px;
  height: 6px;
  margin-top: 4px;
  overflow: hidden;
}

.accuracy-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #3b82f6;
}

.accuracy-bar-fill.neighbour { background: #22c55e; }

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.legend-item {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.legend-item strong { font-size: 0.875rem; }
.legend-item span { font-size: 0.8125rem; color: var(--text-muted); }

/* ===== Cheapest window ===== */
.cheapest-window {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  line-height: 1.5;
  border: 1px solid transparent;
}

.cheapest-window.cw-actual {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.3);
  color: #86efac;
}

.cheapest-window.cw-forecast {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
  color: var(--text-muted);
}

.cw-label {
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.cheapest-window strong {
  color: var(--text);
}

.cw-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-left: 0.375rem;
}

/* ===== Price legend ===== */
.price-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.legend-cat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-cat-label {
  color: var(--text);
  font-weight: 500;
}

.legend-range {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-left: 0.125rem;
}

/* ===== Info page ===== */
#weather-map {
  height: 320px;
  border-radius: 8px;
  overflow: hidden;
  margin: 1rem 0 0.75rem;
}

.info-body {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.info-body strong { color: var(--text); }

.info-usecases {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.info-usecase {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.75rem;
}

.usecase-icon { font-size: 1.25rem; flex-shrink: 0; line-height: 1.4; }

.info-usecase strong { display: block; font-size: 0.9375rem; margin-bottom: 0.125rem; }
.info-usecase span   { font-size: 0.8125rem; color: var(--text-muted); }

.info-steps { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.25rem; }

.info-step {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
}

.info-step strong { display: block; font-size: 0.9375rem; margin-bottom: 0.125rem; }
.info-step span   { font-size: 0.8125rem; color: var(--text-muted); line-height: 1.5; }

.info-features { margin-top: 0.25rem; }
.info-features h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.75rem; }

.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
}

.feature-icon { font-size: 1rem; }

.feature-item--new {
  border: 1px solid #1d4ed8;
  background: #1e3a5f;
}

.info-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
}

.location-list { display: flex; flex-direction: column; gap: 0.625rem; }

.location-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.loc-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.25rem;
  border: 2px solid #fff;
}

.location-item strong { display: block; font-size: 0.9375rem; margin-bottom: 0.125rem; }
.location-item span   { font-size: 0.8125rem; color: var(--text-muted); }

.cat-table { display: flex; flex-direction: column; gap: 0.5rem; }

.cat-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.cat-row:last-child { border-bottom: none; }
.cat-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.cat-name { font-weight: 600; font-size: 0.9375rem; min-width: 7.5rem; }
.cat-pct  { font-size: 0.8125rem; color: var(--text-muted); }

.source-list { display: flex; flex-direction: column; gap: 0.75rem; }

.source-item strong { display: block; font-size: 0.9375rem; margin-bottom: 0.125rem; }
.source-item span   { font-size: 0.8125rem; color: var(--text-muted); line-height: 1.5; }

/* ===== Footer ===== */
footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-top: 1px solid var(--border);
  width: 100%;
}

/* ===== Data warning banner ===== */
.data-warning-banner {
  background: #431407;
  border: 1px solid #f97316;
  color: #fed7aa;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.warning-refresh-btn {
  background: #f97316;
  border: none;
  color: #fff;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  cursor: pointer;
  white-space: nowrap;
}
.warning-refresh-btn:disabled { opacity: 0.6; cursor: default; }

/* ===== Analytics stats ===== */
.stats-grid {
  display: flex;
  gap: 2rem;
  margin: 1rem 0 0.75rem;
}
.stat-item  { display: flex; flex-direction: column; gap: 0.25rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); }
.stat-note  { font-size: 0.75rem; color: #475569; margin-top: 0.5rem; }
.stat-note a { color: #64748b; }

/* ===== Fetch status (footer) ===== */
.fetch-status {
  font-size: 0.6875rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}
.fetch-muted { color: #475569; }
.fetch-err   { color: #f97316; }
.fetch-refresh-btn {
  background: none;
  border: 1px solid #334155;
  color: #64748b;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.6875rem;
  cursor: pointer;
  line-height: 1.6;
}
.fetch-refresh-btn:hover    { border-color: #64748b; color: #94a3b8; }
.fetch-refresh-btn:disabled { opacity: 0.5; cursor: default; }
.fetch-backfill-btn         { border-color: #1d4ed8; color: #93c5fd; }
.fetch-backfill-btn:hover   { border-color: #3b82f6; color: #bfdbfe; }

/* ===== Tooltip ===== */
.tooltip {
  position: fixed;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ===== Toggles ===== */
.toggles-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.toggle-group {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;       /* min ~44px touch target height */
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.toggle-btn:hover { color: var(--text); }
.toggle-btn:active { background: var(--surface2); }

.toggle-btn.active {
  background: var(--surface2);
  color: var(--text);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .legend-grid { grid-template-columns: 1fr; }

  /* Slightly more breathing room */
  main { padding: 0.75rem; gap: 0.75rem; }
  .card { padding: 1rem; }

  /* Hero bigger on mobile — it's the main thing you look at */
  .hero-card { padding: 1.75rem 1rem; }
  .hero-category { font-size: 1.75rem; }
  .hero-prices { font-size: 1rem; }

  /* Toggles: full width on very small screens */
  .toggles-row { gap: 0.5rem; }
  .toggle-group { flex: 1; justify-content: center; }

  /* Advice items: stack price below time on small screens */
  .advice-item { flex-wrap: wrap; gap: 0.5rem; }
  .advice-price { flex-basis: 100%; text-align: left; padding-left: 2.25rem; }

  /* Day name shorter column */
  .day-name { min-width: 2.75rem; font-size: 0.8125rem; }

  /* Chart iets lager op mobile */
  .chart-wrap { height: 200px; }
}
