/* Colors follow the forecast walkthrough: history slate, forecast teal, range light teal. */
:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --fg: #17222b;
  --muted: #5a6873;
  --line: #d5dde2;
  --hist: #5e7381;
  --model: #0f7a72;
  --model-soft: rgba(15, 122, 114, 0.14);
  --so-far: #c27a12;
  --zero: #b23a3a;
  --sel: #e3f1ef;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11181d; --surface: #182229; --fg: #e3eaee; --muted: #9aa8b2; --line: #2b3943;
    --hist: #8fa1ad; --model: #3cb7aa; --model-soft: rgba(60, 183, 170, 0.18); --so-far: #e7a548;
    --zero: #e07272; --sel: #1d3b39; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
code { font-family: Consolas, ui-monospace, monospace; font-size: 0.9em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

button, .btn {
  font: inherit; font-size: 0.9rem; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer;
  display: inline-block;
}
button:hover, .btn:hover { border-color: var(--muted); }
.primary { background: var(--model); border-color: var(--model); color: #fff; }
button:focus-visible, .btn:focus-visible, input:focus-visible, tr:focus-visible {
  outline: 2px solid var(--model); outline-offset: 2px;
}

/* header */
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; }
.brand h1 { font-size: 1.35rem; }
.sub { color: var(--muted); font-size: 0.9rem; }
.top-actions { display: flex; gap: 8px; }
main { padding: 20px 24px 48px; max-width: 1500px; margin: 0 auto; }

/* empty state */
.empty { display: grid; gap: 20px; max-width: 760px; margin: 24px auto; }
.drop {
  display: grid; gap: 6px; place-items: center; text-align: center; padding: 48px 24px;
  background: var(--surface); border: 2px dashed var(--line); border-radius: 12px; cursor: pointer;
}
.drop.over, .drop:hover { border-color: var(--model); }
.drop strong { font-size: 1.1rem; }
.drop span { color: var(--muted); }
.format { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; }
.format h2 { font-size: 1rem; margin-bottom: 6px; }
.format p { margin: 6px 0; }
.format table { border-collapse: collapse; margin: 8px 0; }
.format th { text-align: left; padding: 3px 16px 3px 0; white-space: nowrap; vertical-align: top; }
.format td { padding: 3px 0; }
.error { color: var(--zero); background: var(--surface); border: 1px solid var(--zero); border-radius: 8px; padding: 10px 14px; margin: 0; }
.loading { color: var(--muted); margin: 0; }

/* summary */
.summary {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; align-content: start; }
.tile { display: grid; gap: 2px; }
.tile b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 0.82rem; }
.tile.main { grid-column: span 2; }
.tile.main b { color: var(--model); font-size: 1.6rem; white-space: nowrap; }
.segline { grid-column: 1 / -1; color: var(--muted); font-size: 0.85rem; }
.chart-box { position: relative; height: 200px; min-width: 0; }

/* list + detail */
.layout { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
.list-pane, .detail-pane { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.list-pane { padding: 14px; }
.detail-pane { padding: 18px 20px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.filters { display: grid; gap: 10px; margin-bottom: 10px; }
.filters input[type="search"] {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--fg); width: 100%;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { font-size: 0.82rem; padding: 3px 10px; border-radius: 999px; }
.chips button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.check { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--muted); }
.table-wrap { overflow: auto; max-height: calc(100vh - 360px); min-height: 240px; }
table.items { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.items th {
  position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 0.78rem;
  color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.items th.num { text-align: right; }
.items th[aria-sort]::after { content: " ▾"; }
.items th[aria-sort="ascending"]::after { content: " ▴"; }
.items td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.items tbody tr { cursor: pointer; }
.items tbody tr:hover { background: var(--bg); }
.items tbody tr[aria-selected="true"] { background: var(--sel); }
.items .code { font-weight: 600; }
.items .name { display: block; color: var(--muted); font-size: 0.82rem; }
.up { color: var(--model); } .down { color: var(--zero); }

.badge { display: inline-block; font-size: 0.75rem; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.seg-regular { color: #2e6ea8; } .seg-young { color: #3b8a4f; } .seg-new { color: #b8741a; }
.seg-intermittent { color: var(--muted); } .seg-seasonal { color: #7a68b8; } .seg-inactive { color: var(--zero); }
@media (prefers-color-scheme: dark) {
  .seg-regular { color: #7fb2e5; } .seg-young { color: #7cc48e; } .seg-new { color: #e7a548; } .seg-seasonal { color: #b3a6e8; }
}

/* detail */
.d-head { display: grid; gap: 6px; margin-bottom: 14px; }
.d-head h2 { font-size: 1.3rem; }
.d-head .note { color: var(--muted); font-size: 0.9rem; }
.d-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 14px; }
.d-tiles .tile b { font-size: 1.2rem; }
.d-tiles .tile.main { grid-column: auto; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.seg-toggle { display: flex; }
.seg-toggle button { border-radius: 0; }
.seg-toggle button:first-child { border-radius: 6px 0 0 6px; }
.seg-toggle button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.seg-toggle button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.8rem; color: var(--muted); }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.legend i.box { height: 10px; border: 0; }
.detail-chart { position: relative; height: 270px; margin: 8px 0 4px; }
.progress { font-size: 0.85rem; color: var(--muted); margin: 0 0 12px; }
.d-section { margin-top: 18px; }
.d-section h3 { font-size: 0.95rem; margin-bottom: 6px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.grid th { text-align: right; color: var(--muted); font-weight: 600; font-size: 0.76rem; padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid th:first-child, .grid td:first-child { text-align: left; }
.grid td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid td:first-child { white-space: normal; }
.grid tfoot td { font-weight: 600; border-bottom: 0; }
.grid-wrap { overflow-x: auto; }
dl.model { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; font-size: 0.88rem; }
dl.model dt { color: var(--muted); }
dl.model dd { margin: 0; font-variant-numeric: tabular-nums; }
.placeholder { color: var(--muted); padding: 40px 10px; text-align: center; }

@media (max-width: 1000px) {
  .layout, .summary { grid-template-columns: minmax(0, 1fr); }
  .detail-pane { position: static; max-height: none; }
  .table-wrap { max-height: 420px; }
  main { padding: 14px 16px 40px; }
  .top { padding: 12px 16px; }
}
