/* Dark Clinical Theme — radar-route-nowcast */
:root {
  --bg-primary: #1a1d23;
  --bg-secondary: #24272d;
  --bg-tertiary: #1a1d23;
  --border-primary: #363a42;
  --border-secondary: #374151;
  --border-subtle: #2d3238;
  --text-primary: #ffffff;
  --text-secondary: #e1e5e9;
  --text-muted: #9ca3af;
  --text-subtle: #6b7280;
  --status-safe: #10b981;
  --status-caution: #f59e0b;
  --status-danger: #ef4444;
  --accent-primary: #3b82f6;
  --accent-secondary: #60a5fa;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-secondary);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px 18px 64px; }

.header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding-bottom: 16px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 18px; }
.header h1 { font-size: 1.5em; font-weight: 600; color: var(--text-primary); letter-spacing: -0.4px; }
.header .sub { color: var(--text-muted); font-size: 0.92em; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab {
  flex: 1; padding: 12px; background: var(--bg-secondary); border: 1px solid var(--border-primary);
  border-radius: 8px; color: var(--text-muted); font-weight: 600; font-size: 0.95em;
  cursor: pointer; transition: all 0.15s; text-align: center;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--text-primary); border-color: var(--accent-primary);
  box-shadow: inset 0 0 0 1px var(--accent-primary); }

.view { display: none; }
.view.active { display: block; }

/* Cards */
.card { background: var(--bg-secondary); border: 1px solid var(--border-primary);
  border-radius: 8px; padding: 22px; margin-bottom: 18px; }
.card-title { font-size: 0.78em; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 14px; }

/* Form */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { margin-bottom: 14px; }
label { display: block; margin-bottom: 6px; color: #d1d5db; font-weight: 500; font-size: 0.85em; }
input[type="text"] {
  width: 100%; padding: 12px 14px; background: var(--bg-primary);
  border: 1px solid #4b5563; border-radius: 6px; color: var(--text-primary); font-size: 1em;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus { outline: none; border-color: var(--accent-secondary);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.12); }

.btn {
  width: 100%; padding: 14px; background: var(--accent-primary); border: none; border-radius: 6px;
  color: #fff; font-weight: 600; font-size: 1em; cursor: pointer; transition: background 0.15s;
}
.btn:hover { background: #2563eb; }
.btn:active { background: #1d4ed8; }
.btn:disabled { background: #2b3850; color: #7c89a0; cursor: not-allowed; }
.btn.stop { background: var(--status-danger); }
.btn.stop:hover { background: #dc2626; }

.status-line { color: var(--text-muted); font-size: 0.9em; padding: 6px 2px; min-height: 22px; }
.status-line.err { color: #fca5a5; }

/* Recommendation card */
.rec { border-left: 4px solid var(--accent-primary);
  background: linear-gradient(90deg, rgba(59,130,246,0.06) 0%, transparent 60%); }
.rec.safe { border-left-color: var(--status-safe);
  background: linear-gradient(90deg, rgba(16,185,129,0.06) 0%, transparent 60%); }
.rec.caution { border-left-color: var(--status-caution);
  background: linear-gradient(90deg, rgba(245,158,11,0.06) 0%, transparent 60%); }
.rec.danger { border-left-color: var(--status-danger);
  background: linear-gradient(90deg, rgba(239,68,68,0.06) 0%, transparent 60%); }

.rec-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.rec-depart { font-size: 2.0em; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; }
.rec-when { font-size: 1.05em; color: var(--accent-secondary); font-weight: 600; }
.rec-eta { color: var(--text-muted); font-size: 0.92em; }
.rec-why { color: var(--text-secondary); margin: 10px 0 4px; font-size: 0.98em; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 5px;
  font-size: 0.78em; font-weight: 600; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.within { background: rgba(16,185,129,0.12); color: var(--status-safe); }
.badge.within .dot { background: var(--status-safe); }
.badge.beyond { background: rgba(245,158,11,0.12); color: var(--status-caution); }
.badge.beyond .dot { background: var(--status-caution); }

.metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-top: 16px; }
.metric { background: var(--bg-primary); border: 1px solid var(--border-secondary);
  border-radius: 6px; padding: 12px; }
.metric .k { font-size: 0.72em; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.metric .v { font-size: 1.3em; font-weight: 600; color: var(--text-primary); margin-top: 2px; }
.metric .u { font-size: 0.6em; color: var(--text-subtle); font-weight: 400; }
.note { color: var(--text-muted); font-size: 0.86em; margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--border-subtle); }

/* Canvas / chart wrappers */
.chart-wrap { position: relative; width: 100%; }
canvas { display: block; width: 100%; }
.legend { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 0.78em; color: var(--text-muted); }
.legend .bar { height: 10px; flex: 1; border-radius: 3px; max-width: 260px; }
.hov-tip { position: absolute; pointer-events: none; background: #0e1014ee; border: 1px solid var(--border-primary);
  border-radius: 5px; padding: 6px 9px; font-size: 0.78em; color: var(--text-secondary); white-space: nowrap;
  transform: translate(-50%, -130%); display: none; z-index: 5; }

#map { width: 100%; height: 280px; border-radius: 6px; border: 1px solid var(--border-primary); background: #11131a; }
.leaflet-tile { filter: brightness(0.65) contrast(1.05) saturate(0.85); }

/* Drive mode */
.drive-card { text-align: center; padding: 30px 22px; border-width: 2px; }
.drive-card.clear { border-color: var(--status-safe); }
.drive-card.rain_ahead { border-color: var(--status-caution); }
.drive-card.in_rain { border-color: var(--status-danger); }
.drive-status-big { font-size: 2.1em; font-weight: 800; letter-spacing: -0.5px; color: var(--text-primary); }
.drive-card.clear .drive-status-big { color: var(--status-safe); }
.drive-card.rain_ahead .drive-status-big { color: var(--status-caution); }
.drive-card.in_rain .drive-status-big { color: var(--status-danger); }
.drive-advice { font-size: 1.15em; color: var(--text-secondary); margin-top: 8px; }

.strip-wrap { margin-top: 4px; }
.strip-axis { display: flex; justify-content: space-between; font-size: 0.72em; color: var(--text-subtle); margin-top: 4px; }

.dgrid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-top: 16px; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

details { margin-top: 4px; }
summary { cursor: pointer; color: var(--text-muted); font-size: 0.85em; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 0.85em; margin-top: 10px; }
.kv .k { color: var(--text-subtle); }
.kv .v { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.empty { text-align: center; color: var(--text-subtle); padding: 40px 20px; font-size: 0.95em; }

/* Rain timeline */
.tl-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
#tl-dep { background: var(--bg-primary); border: 1px solid #4b5563; color: var(--text-primary);
  border-radius: 6px; padding: 7px 10px; font-size: 0.85em; }
.tl-totals { display: flex; align-items: baseline; gap: 8px 22px; flex-wrap: wrap;
  padding: 4px 0 6px; }
.tl-big { font-size: 2.0em; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; }
.tl-big .u { font-size: 0.45em; color: var(--text-muted); font-weight: 500; }
.tl-sub { color: var(--text-muted); font-size: 0.9em; }
.tl-sub b { color: var(--text-secondary); font-weight: 600; }
.tl-dry { color: var(--status-safe); font-weight: 600; font-size: 1.05em; }

.band { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--border-subtle); }
.band:first-child { border-top: none; }
.band .when { font-variant-numeric: tabular-nums; }
.band .when .t { color: var(--text-primary); font-weight: 600; font-size: 0.95em; }
.band .when .d { color: var(--text-subtle); font-size: 0.78em; }
.band .where .place { color: var(--text-secondary); font-weight: 500; }
.band .where .meta { color: var(--text-muted); font-size: 0.82em; margin-top: 2px; }
.band .amt { text-align: right; }
.band .amt .v { font-weight: 700; font-size: 1.05em; }
.band .amt .u { color: var(--text-subtle); font-size: 0.75em; }
.tier-pill { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 0.72em;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-right: 6px; }
.tier-light { background: rgba(43,182,115,0.15); color: #34d399; }
.tier-moderate { background: rgba(245,158,11,0.15); color: #fbbf24; }
.tier-heavy { background: rgba(239,68,68,0.15); color: #f87171; }
.beyond-tag { color: var(--status-caution); font-size: 0.72em; font-weight: 600; }
.band.amt-heavy .amt .v { color: #f87171; }
.band.amt-moderate .amt .v { color: #fbbf24; }
.band.amt-light .amt .v { color: #34d399; }

@media (max-width: 720px) {
  .form-row { grid-template-columns: 1fr; }
  .metrics, .dgrid { grid-template-columns: repeat(2,1fr); }
  .rec-depart { font-size: 1.7em; }
  .drive-status-big { font-size: 1.8em; }
}
