:root {
  --bg: #f6f5f2; --surface: #fffefc; --ink: #1d1d1b; --ink2: #52514e; --muted: #807e78; --line: #e4e3df;
  --accent: #2a78d6; --accent-soft: #d6e6f8; --warn: #c9541f; --alert: #d99a00; --wrong: #d0342c;
  --dry: #8a5a2b; --mid: #dedbd3; --wet: #1557a8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121314; --surface: #1b1c1e; --ink: #ecebe7; --ink2: #b9b7b1; --muted: #8d8b85; --line: #2e2f32;
    --accent: #5b9ee8; --accent-soft: #23374f; --warn: #e07a45; --alert: #e8b52c; --wrong: #ef5b52;
    --dry: #b07a45; --mid: #3a3a3c; --wet: #4f95e6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121314; --surface: #1b1c1e; --ink: #ecebe7; --ink2: #b9b7b1; --muted: #8d8b85; --line: #2e2f32;
  --accent: #5b9ee8; --accent-soft: #23374f; --warn: #e07a45; --alert: #e8b52c; --wrong: #ef5b52;
  --dry: #b07a45; --mid: #3a3a3c; --wet: #4f95e6;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink2); margin: 0 0 10px; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
button:hover { border-color: var(--ink2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button:disabled { opacity: .5; cursor: wait; }
select { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand b { font-size: 16px; }
.logo { width: 14px; height: 14px; border-radius: 3px; background: linear-gradient(90deg, var(--dry) 50%, var(--wet) 50%); align-self: center; }
.sub { color: var(--muted); font-size: 12px; }
.badge { font-size: 12px; border: 1px solid var(--warn); color: var(--warn); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }

.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) 380px; gap: 16px; padding: 16px; align-items: start; }
@media (max-width: 1200px) { .layout { grid-template-columns: 240px minmax(0, 1fr); } .detail { grid-column: 1 / -1; } }
@media (max-width: 760px) { .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; } }
.controls, .stage, .detail { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }

.slider { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin-bottom: 10px; font-size: 13px; }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.slider .v { color: var(--ink2); font-variant-numeric: tabular-nums; }
.slider .hint { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.row { display: grid; gap: 4px; font-size: 13px; margin: 6px 0 12px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.about { margin-top: 14px; font-size: 12px; color: var(--ink2); }
.about summary { cursor: pointer; color: var(--ink); }
.k { display: inline-block; width: 10px; height: 10px; vertical-align: -1px; }
.k-pass { border: 2px solid var(--ink); border-radius: 2px; }
.k-wrong { border: 2px dashed var(--wrong); border-radius: 2px; }
.k-alert { background: var(--alert); border-radius: 50%; }
.k-irr { border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid var(--accent); width: 0; height: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.kpi { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.kpi .l { font-size: 11px; color: var(--muted); }
.kpi .n { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 11px; color: var(--ink2); }
.toolbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 5px 11px; }
.seg button.on { background: var(--accent-soft); font-weight: 600; }
.time { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 260px; }
.time input { flex: 1; accent-color: var(--accent); }
.mapwrap { position: relative; }
canvas#map { width: 100%; display: block; cursor: pointer; border-radius: 6px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: 12px; color: var(--ink2); }
.legend .bar { width: 260px; height: 10px; border-radius: 3px; }
.legend .ticks { display: flex; justify-content: space-between; width: 260px; font-size: 11px; color: var(--muted); }
.tip { position: absolute; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.12); white-space: nowrap; z-index: 5; }
.tip b { font-weight: 600; }

.detail { position: relative; }
#finfo { font-size: 13px; margin-bottom: 6px; }
#finfo .grid { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; }
svg#chart { width: 100%; height: 260px; display: block; }
svg#chart text { fill: var(--muted); font-size: 10px; }
.ask { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.asklabel { width: 100%; font-size: 13px; color: var(--ink2); }
#answer { width: 100%; font-size: 13px; }
#answer table { border-collapse: collapse; width: 100%; margin-top: 6px; font-variant-numeric: tabular-nums; }
#answer td, #answer th { border-bottom: 1px solid var(--line); padding: 3px 4px; text-align: right; }
#answer th:first-child, #answer td:first-child { text-align: left; }
.season { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; font-size: 13px; }
.season table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.season td { padding: 2px 0; border-bottom: 1px solid var(--line); }
.season td:last-child { text-align: right; }
