:root {
  --bg: #101418;
  --bg-2: #181e25;
  --card: #1c242d;
  --ink: #e8eef4;
  --muted: #9aa7b4;
  --line: #2c3844;
  --accent: #c9bbff;
  --accent-2: #d4c4ff;
  --danger: #e35d5d;
  --font: "Source Sans 3", "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", "ui-monospace", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: #8ec8ff; }
h1 { font-size: 1.35rem; margin: 0 0 0.2rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 0.95rem; margin: 0 0 0.55rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: #c9d4de; }
.sub, .fine, .legend, .aoi, footer { color: var(--muted); }
.sub { margin: 0; font-size: 0.92rem; max-width: 62rem; }
.fine { font-size: 0.8rem; margin: 0 0 0.6rem; line-height: 1.4; }
header.top {
  display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-end;
  padding: 1rem 1.25rem 0.9rem; border-bottom: 1px solid var(--line); background: var(--bg-2);
  flex-wrap: wrap;
}
.controls { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
select, .btn {
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 4px; padding: 0.45rem 0.7rem; font: inherit; cursor: pointer;
}
select { min-width: 12rem; }
.btn:hover, select:hover { border-color: #4a5b6c; }
.btn.primary { background: var(--accent); color: #1a1408; border-color: var(--accent); font-weight: 650; }
.btn.active { outline: 2px solid var(--accent-2); }
.layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(20rem, 0.8fr); gap: 0; flex: 1; }
.map-pane { padding: 0.8rem 1rem 0.4rem; display: flex; flex-direction: column; min-height: 28rem; }
#map { flex: 1; min-height: 26rem; border: 1px solid var(--line); border-radius: 6px; background: #0b0e12; }
.legend, .aoi { font-size: 0.78rem; margin: 0.4rem 0 0; }
.side { padding: 0.8rem 1rem 1rem 0.4rem; display: flex; flex-direction: column; gap: 0.7rem; overflow: auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 0.8rem 0.9rem; }
.calendar-pane { padding: 0.4rem 1.25rem 1.25rem; }
.cal-head { margin-bottom: 0.4rem; }
#calendar { overflow-x: auto; }
table.metrics, table.cal { border-collapse: collapse; width: 100%; font-size: 0.8rem; }
table.metrics th, table.metrics td { text-align: left; padding: 0.28rem 0.4rem; border-bottom: 1px solid var(--line); }
table.metrics th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
table.metrics td.num { font-family: var(--mono); text-align: right; }
table.metrics tr.best td { color: #c9bbff; }
table.metrics tr.ref td { color: var(--muted); }
table.cal { font-family: var(--mono); font-size: 0.72rem; }
table.cal th { color: var(--muted); font-weight: 600; padding: 0.2rem 0.15rem; }
table.cal td {
  width: 2.6rem; height: 1.35rem; text-align: center; cursor: pointer;
  border: 1px solid var(--bg); position: relative;
}
table.cal td.unusual { outline: 2px solid #3ee0e8; outline-offset: -2px; }
table.cal td.backcast { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }
table.cal .year { color: var(--muted); text-align: right; padding-right: 0.45rem; width: 3rem; }
table.cal .split td { border-top: 2px dashed #d9dde2; }
.reasons dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 0.8rem; font-size: 0.82rem; }
.reasons dt { color: var(--muted); }
.reasons dd { margin: 0; font-family: var(--mono); text-align: right; }
.reasons p { font-size: 0.8rem; color: var(--muted); line-height: 1.45; margin: 0.6rem 0 0; }
.tooltip {
  position: fixed; z-index: 2000; background: #0d1218; color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px; padding: 0.45rem 0.6rem;
  font-size: 0.78rem; pointer-events: none; max-width: 18rem; line-height: 1.35;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
footer { border-top: 1px solid var(--line); padding: 0.8rem 1.25rem 1.2rem; font-size: 0.75rem; line-height: 1.45; }
footer p { margin: 0.2rem 0; }
.leaflet-container { background: #0b0e12; font-family: var(--font); }
#status.err { color: var(--danger); }
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  #map { min-height: 22rem; }
  .side { padding: 0.4rem 1rem 1rem; }
}
