/* DWDPheno Studio — calm scientific-desktop look, light + dark (prefers-color-scheme). */
:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --panel: #fcfcfb;
  --panel-2: #f7f8f7;
  --raised: #ffffff;
  --border: #dfe3e1;
  --border-strong: #c6ccc9;
  --text: #17201d;
  --text-2: #4c5753;
  --muted: #7d8783;
  --accent: #2e7d4f;          /* leaf green: primary actions */
  --accent-hover: #256b42;
  --accent-soft: #e3f0e8;
  --blue: #2a78d6;
  --focus: #2a78d6;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --row-hover: #f0f4f2;
  --row-sel: #e6f0fb;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  /* categorical slots (reference palette, fixed order) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --rep-annual: var(--s1); --rep-immediate: var(--s2); --rep-both: var(--s3);
  --sel-ring: #0b0b0b;
  --div-neg: #2a78d6; --div-pos: #e34948; --div-mid: #f0efec;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 2px 8px rgba(16, 24, 20, .06);
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1312;
    --panel: #171c1a;
    --panel-2: #1b211f;
    --raised: #1f2623;
    --border: #2a322f;
    --border-strong: #3a4440;
    --text: #e6ece9;
    --text-2: #b9c3bf;
    --muted: #87928d;
    --accent: #3f9d66;
    --accent-hover: #4bb176;
    --accent-soft: #1c3226;
    --blue: #3987e5;
    --focus: #3987e5;
    --danger: #e0614f;
    --danger-soft: #3a1f1b;
    --row-hover: #1f2825;
    --row-sel: #1a2b3d;
    --grid: #2c2c2a;
    --axis: #383835;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --sel-ring: #f0efec;
    --div-neg: #3987e5; --div-pos: #e66767; --div-mid: #383835;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 10px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app {
  height: 100vh;
  display: grid;
  grid-template-columns: 330px 1fr;
  grid-template-rows: 44px auto 1fr 26px;
  grid-template-areas: "top top" "banner banner" "side main" "status status";
}

/* ── top bar ─────────────────────────────────────────── */
.topbar { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--border); }
.logo { display: block; }
.brand { font-size: 15px; letter-spacing: .1px; }
.brand b { font-weight: 650; color: var(--accent); }
.sub { color: var(--muted); font-size: 12px; padding-left: 10px; border-left: 1px solid var(--border); }
.spacer { flex: 1; }
.chip { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); background: var(--panel-2); white-space: nowrap; }
.chip.ok::before, .chip.bad::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.chip.ok::before { background: #0ca30c; }
.chip.bad { color: var(--danger); border-color: var(--danger); }
.chip.bad::before { background: var(--danger); }

.banner { grid-area: banner; padding: 9px 16px; background: var(--danger-soft); color: var(--text); border-bottom: 1px solid var(--danger); font-size: 12.5px; }
.banner b { color: var(--danger); }
.banner code { font-size: 12px; background: rgba(127,127,127,.15); padding: 0 4px; border-radius: 3px; }

/* ── sidebar ─────────────────────────────────────────── */
.sidebar { grid-area: side; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--border); padding: 6px 0 14px; }
.sec { border-bottom: 1px solid var(--border); }
.sec > summary { list-style: none; cursor: pointer; padding: 10px 14px 8px; font-weight: 600; font-size: 12.5px; letter-spacing: .3px; text-transform: uppercase; color: var(--text-2); display: flex; align-items: center; gap: 8px; user-select: none; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
.sec:not([open]) > summary::after { transform: rotate(-45deg); }
.step { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; }
.sec-body { padding: 0 14px 12px; }
.lbl { display: block; font-size: 11.5px; color: var(--text-2); margin: 8px 0 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1.1fr; gap: 8px; }
.inline { display: flex; align-items: center; gap: 6px; }
.unit { color: var(--muted); font-size: 12px; min-width: 40px; }
.centre-opts { margin-top: 8px; align-items: center; }

input[type=text], input[type=search], input[type=number], select {
  width: 100%; height: 30px; padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--raised); outline: none;
}
input[type=number] { font-variant-numeric: tabular-nums; }
input:focus, select:focus { border-color: var(--focus); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 25%, transparent); }
input::placeholder { color: var(--muted); }
.chk { display: flex; align-items: center; gap: 7px; margin: 9px 0 0; cursor: pointer; color: var(--text-2); }
.chk input { accent-color: var(--accent); margin: 0; }
.chk.small { font-size: 11.5px; margin-top: 5px; }

.btn { height: 30px; padding: 0 12px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--raised); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.small { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.big { height: 36px; flex: 1; font-size: 13.5px; }
.btnrow { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.btnrow.tight { margin-top: 6px; }
.result-line { display: flex; gap: 6px; align-items: center; margin-top: 10px; padding: 7px 8px; border-radius: 5px; background: var(--accent-soft); font-size: 12px; }
.result-line #f-count { font-weight: 600; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 5px; overflow: hidden; background: var(--raised); }
.seg button { border: 0; background: transparent; padding: 4px 10px; cursor: pointer; font-size: 12px; color: var(--text-2); border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; padding: 6px 0; }

.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--border); font-size: 10.5px; font-weight: 600; color: var(--text-2); text-align: center; text-transform: none; letter-spacing: 0; }
.badge:empty { display: none; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.pad { padding: 10px; }

/* autocomplete */
.ac-wrap { position: relative; }
.ac-list { position: absolute; z-index: 2000; top: 31px; left: 0; right: 0; max-height: 240px; overflow-y: auto; background: var(--raised); border: 1px solid var(--border-strong); border-radius: 5px; box-shadow: var(--shadow); }
.ac-item { padding: 5px 9px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.ac-item:hover, .ac-item.on { background: var(--row-hover); }
.ac-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .m { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* crops */
#crop-q { margin-bottom: 6px; }
.crop-list { max-height: 210px; overflow-y: auto; border: 1px solid var(--border); border-radius: 5px; background: var(--raised); }
.crop-group { position: sticky; top: 0; background: var(--panel-2); padding: 3px 9px; font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); z-index: 1; }
.crop { display: grid; grid-template-columns: 16px 1fr auto; gap: 7px; align-items: center; padding: 4px 9px; cursor: pointer; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.crop:hover { background: var(--row-hover); }
.crop input { margin: 0; accent-color: var(--accent); }
.crop .cn { overflow: hidden; }
.crop .tok { display: block; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crop .en { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crop .yr { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.crop.on { background: var(--accent-soft); }

/* year slider */
.dual { position: relative; height: 26px; margin: 4px 2px 2px; }
.dual-track { position: absolute; left: 0; right: 0; top: 11px; height: 4px; border-radius: 2px; background: var(--border); }
.dual-fill { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 2px; }
.dual input[type=range] { position: absolute; left: 0; width: 100%; top: 4px; margin: 0; pointer-events: none; -webkit-appearance: none; appearance: none; background: transparent; height: 18px; }
.dual input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 14px; height: 14px; border-radius: 50%; background: var(--raised); border: 2px solid var(--accent); cursor: pointer; }
.dual input[type=range]::-moz-range-thumb { pointer-events: auto; width: 12px; height: 12px; border-radius: 50%; background: var(--raised); border: 2px solid var(--accent); cursor: pointer; }

/* download */
.sidebar { display: flex; flex-direction: column; padding-bottom: 0; }
.sec.dl { padding: 10px 14px 10px; border-bottom: 0; border-top: 1px solid var(--border); position: sticky; bottom: 0; margin-top: auto; background: var(--panel); box-shadow: 0 -6px 12px -8px rgba(0,0,0,.18); z-index: 5; }
.sec.dl .btnrow { margin-top: 8px; }
.dl-what { font-size: 12px; color: var(--text-2); background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; padding: 7px 9px; }
.dl-what b { color: var(--text); }
.dl-what .warn { color: var(--danger); }
.progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 10px; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress.indet .bar { width: 30%; animation: indet 1.2s infinite ease-in-out; }
@keyframes indet { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
#dl-text { margin-top: 5px; min-height: 16px; }

/* ── main / tabs ─────────────────────────────────────── */
.main { grid-area: main; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 6px 10px 0; background: var(--panel); border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: transparent; padding: 7px 14px 8px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; font-weight: 500; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.pane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.pane.on { display: flex; }

/* map */
.mapwrap { position: relative; flex: 1; min-height: 160px; }
#map { position: absolute; inset: 0; background: var(--panel-2); }
.leaflet-container { font: inherit; }
.maptools { position: absolute; z-index: 800; top: 10px; left: 54px; display: flex; gap: 2px; padding: 3px; background: var(--raised); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: var(--shadow); }
.maptools button { width: 30px; height: 28px; border: 0; border-radius: 4px; background: transparent; cursor: pointer; color: var(--text-2); display: grid; place-items: center; }
.maptools button svg { width: 18px; height: 18px; }
.maptools button:hover { background: var(--row-hover); color: var(--text); }
.maptools button.on { background: var(--accent-soft); color: var(--accent); }
.maptools .sep { width: 1px; background: var(--border); margin: 3px 3px; }
.maphint { position: absolute; z-index: 800; top: 10px; left: 50%; transform: translateX(-50%); padding: 5px 12px; border-radius: 5px; background: var(--text); color: var(--panel); font-size: 12px; box-shadow: var(--shadow); pointer-events: none; }
.hoverinfo { position: absolute; z-index: 800; top: 10px; right: 10px; padding: 5px 10px; border-radius: 5px; background: var(--raised); border: 1px solid var(--border); font-size: 12px; box-shadow: var(--shadow); pointer-events: none; max-width: 300px; }
.hoverinfo .k { color: var(--muted); font-size: 11px; }
.legend { position: absolute; z-index: 800; bottom: 22px; right: 10px; padding: 8px 11px; border-radius: 6px; background: color-mix(in srgb, var(--raised) 94%, transparent); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 12px; line-height: 1.7; }
.lg-title { font-weight: 600; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: -1px; border: 1.5px solid var(--raised); box-shadow: 0 0 0 .5px var(--border-strong); }
.rep-annual { background: var(--rep-annual); }
.rep-immediate { background: var(--rep-immediate); }
.rep-both { background: var(--rep-both); }
.dot.sel { background: transparent; border: 2.5px solid var(--sel-ring); box-shadow: none; }
.leaflet-tooltip.st-tip { padding: 6px 9px; font: 12px/1.45 var(--font); background: var(--raised); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow); }
.leaflet-tooltip.st-tip::before { display: none; }
.st-tip b { font-size: 12.5px; }
.st-tip .k { color: var(--muted); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--raised); color: var(--text); }
.leaflet-popup-content { margin: 10px 12px; font: 12.5px/1.45 var(--font); }
.pop .btn { margin-top: 8px; margin-right: 6px; }
.leaflet-bar a { background: var(--raised); color: var(--text); border-bottom-color: var(--border); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--raised) 80%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--blue); }
.map-notiles .leaflet-tile-pane { display: none; }
@media (prefers-color-scheme: dark) { .leaflet-tile-pane { filter: saturate(.55) brightness(.62) contrast(1.08); } }

.splitter { height: 6px; cursor: row-resize; background: var(--panel); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); position: relative; }
.splitter::after { content: ""; position: absolute; left: 50%; top: 1px; width: 36px; height: 2px; margin-left: -18px; border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); }
.stable { height: 34%; min-height: 110px; display: flex; flex-direction: column; background: var(--panel); }

/* tables */
.ttools { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--border); background: var(--panel); flex-wrap: nowrap; }
.ttools input[type=search] { width: 240px; height: 28px; }
.ttools select { width: 170px; height: 28px; }
.tablebox { flex: 1; min-height: 0; overflow: auto; background: var(--panel); position: relative; }
.tablebox.grow { flex: 1; }
table.dt { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
table.dt th { position: sticky; top: 0; z-index: 2; background: var(--panel-2); text-align: left; font-weight: 600; color: var(--text-2); padding: 6px 9px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; cursor: pointer; user-select: none; font-size: 12px; }
table.dt th.num, table.dt td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.dt th .ar { color: var(--accent); margin-left: 3px; font-size: 10px; }
table.dt td { padding: 4px 9px; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
table.dt tbody tr:hover td { background: var(--row-hover); }
table.dt tbody tr.sel td { background: var(--row-sel); }
table.dt tbody tr.click { cursor: pointer; }
table.dt td.ck { width: 30px; text-align: center; }
table.dt td.ck input { margin: 0; accent-color: var(--accent); cursor: pointer; }
.pager { position: sticky; bottom: 0; left: 0; display: flex; align-items: center; gap: 6px; padding: 5px 10px; background: var(--panel-2); border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); z-index: 3; }
.pager button { height: 24px; min-width: 28px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--raised); cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.rep-tag { display: inline-flex; align-items: center; gap: 5px; }
.rep-tag i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.trend { display: inline-flex; align-items: center; gap: 5px; justify-content: flex-end; }
.trend i { display: inline-block; height: 8px; border-radius: 2px; }
.tag-diss { color: var(--muted); }
.q-bad { color: var(--danger); }

/* series */
.series { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px 1fr; }
.series-ctl { padding: 4px 14px 14px; border-right: 1px solid var(--border); background: var(--panel); overflow-y: auto; }
.series-ctl .note { margin-top: 14px; line-height: 1.5; }
.se-crops { display: flex; flex-direction: column; gap: 2px; }
.se-crop { display: flex; align-items: center; gap: 7px; padding: 3px 0; cursor: pointer; }
.se-crop input { margin: 0; accent-color: var(--accent); }
.se-crop .sw { width: 14px; height: 3px; border-radius: 2px; }
.se-crop .n { color: var(--muted); font-size: 11px; margin-left: auto; font-variant-numeric: tabular-nums; }
.series-plot { position: relative; min-width: 0; min-height: 0; background: var(--panel); display: flex; flex-direction: column; }
.se-head { display: flex; align-items: center; gap: 10px; padding: 8px 14px 4px 16px; }
.se-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.se-plotbox { position: relative; flex: 1; min-height: 0; }
#se-plot { position: absolute; inset: 0 8px 4px 4px; }
.series-plot .empty { position: absolute; inset: 0; display: grid; place-items: center; }

/* status bar */
.statusbar { grid-area: status; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--panel); border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; }
.statusbar .dotsep { color: var(--muted); }
.statusbar .last { overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.statusbar .attrib { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.statusbar .attrib a { color: inherit; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
.statusbar .attrib a:hover { color: var(--blue); }
.sb-link { flex: none; border: 0; padding: 0; background: transparent; color: var(--blue); font-size: 11px; cursor: pointer; }
.sb-link:hover { text-decoration: underline; }
.chip-btn { cursor: pointer; }
.chip-btn:hover { border-color: var(--muted); color: var(--text); }

/* licences & credits dialog */
.credits { width: min(780px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--raised); color: var(--text); box-shadow: 0 12px 40px rgba(0, 0, 0, .28); }
.credits[open] { display: flex; flex-direction: column; }
.credits::backdrop { background: rgba(10, 16, 13, .45); }
.cr-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel); }
.cr-head h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 650; }
.cr-body { overflow: auto; padding: 4px 16px 16px; font-size: 12.5px; line-height: 1.5; }
.cr-body a { color: var(--blue); overflow-wrap: anywhere; }
.cr-body h3 { margin: 16px 0 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--text-2); }
.cr-lead { margin: 12px 0 0; color: var(--text-2); }
.cr-list { margin: 0; }
.cr-list dt { margin-top: 8px; font-weight: 600; }
.cr-list dd { margin: 1px 0 0; }
.cr-list dd .muted { display: block; font-size: 11.5px; }
.cr-refs { margin: 0; padding-left: 18px; }
.cr-refs li { margin: 3px 0; }
.cr-table { width: 100%; border-collapse: collapse; }
.cr-table th, .cr-table td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.cr-table th { font-size: 11px; font-weight: 600; color: var(--muted); }
.cr-table td:last-child { white-space: nowrap; color: var(--text-2); }
.cr-body p.small { margin: 8px 0 0; }
.cr-pre { max-height: 50vh; overflow: auto; margin: 8px 0 0; padding: 10px; white-space: pre-wrap; overflow-wrap: anywhere; font: 11.5px/1.45 ui-monospace, Consolas, "Cascadia Mono", monospace; background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; }
@media (max-width: 640px) { .cr-table td:last-child { white-space: normal; } .hide-narrow { display: none; } }

.toast { position: fixed; z-index: 5000; bottom: 40px; left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 6px; background: var(--text); color: var(--panel); box-shadow: var(--shadow); font-size: 12.5px; max-width: 70vw; }
.toast.err { background: var(--danger); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1180px) {
  #app { grid-template-columns: 300px 1fr; }
  .sub { display: none; }
  .ttools input[type=search] { width: 180px; }
}

/* ── data quality ──────────────────────────────────────
   status colours (fixed, never a series colour) + always a text label */
:root { --q-ok: #0ca30c; --q-warn: #c98500; --q-serious: #e0703f; --q-bad: #d03b3b; --q-none: #8a938f; }
@media (prefers-color-scheme: dark) { :root { --q-ok: #2fbf4f; --q-warn: #fab219; --q-serious: #ec835a; --q-bad: #ef5b5b; --q-none: #87928d; } }
.q1 { --qc: var(--q-ok); } .q2, .q3 { --qc: var(--q-warn); } .q5 { --qc: var(--q-serious); } .q8 { --qc: var(--q-bad); } .q0 { --qc: var(--q-none); }
.qgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.qgrid .chk { margin-top: 4px; font-size: 12px; }
.qgrid .chk i { width: 8px; height: 8px; border-radius: 50%; background: var(--qc, var(--muted)); flex: none; }
.qgrid .chk .code { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 14px; }
.badge.warn { background: color-mix(in srgb, var(--q-warn) 18%, transparent); border-color: var(--q-warn); color: var(--text); }
.qb { display: inline-flex; align-items: center; gap: 5px; padding: 0 7px 0 5px; border-radius: 9px; font-size: 11.5px; line-height: 18px;
      background: color-mix(in srgb, var(--qc) 13%, transparent); color: var(--text); white-space: nowrap; }
.qb::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--qc); }
.qb.q1 { background: transparent; color: var(--text-2); }
.qchips { display: inline-flex; gap: 3px; }
.qc { display: inline-block; min-width: 20px; padding: 0 4px; border-radius: 4px; font-size: 11px; line-height: 17px; text-align: center; font-variant-numeric: tabular-nums;
      background: color-mix(in srgb, var(--qc) 16%, transparent); border-left: 3px solid var(--qc); color: var(--text); }
.ql { font-variant-numeric: tabular-nums; color: var(--text-2); }
.se-qlegend { display: flex; flex-direction: column; gap: 3px; margin: 4px 0 2px 22px; font-size: 11.5px; color: var(--text-2); white-space: nowrap; }
.se-qlegend span { display: inline-flex; align-items: center; gap: 5px; }
.se-qlegend svg { width: 12px; height: 12px; fill: var(--muted); stroke: none; }
.se-qlegend .bad svg circle { fill: var(--muted); stroke: var(--q-bad); stroke-width: 1.4; }
.se-qlegend .bad svg path { stroke: var(--q-bad); stroke-width: 1.6; fill: none; }
.tabs .badge.warn { margin-left: 2px; }

/* plot workspace lists */
.ws-list { max-height: 168px; overflow-y: auto; border: 1px solid var(--border); border-radius: 5px; background: var(--raised); margin-top: 4px; }
.ws-list.short { max-height: 120px; }
.ws-item { display: flex; align-items: center; gap: 7px; padding: 3px 8px; cursor: pointer; font-size: 12px; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.ws-item:hover { background: var(--row-hover); }
.ws-item.on { background: var(--accent-soft); }
.ws-item input { margin: 0; accent-color: var(--accent); }
.ws-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-item .n { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ws-item .sw { width: 14px; height: 3px; border-radius: 2px; flex: none; }
#ws-st-q { margin-top: 2px; height: 28px; }
#ws-chart { margin: 10px 0 2px; }
.dl-what .warn, .warn { color: var(--q-warn); }

/* ── phones: stack sidebar above the map/tables, page scrolls ── */
@media (max-width: 760px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; grid-template-columns: 1fr; grid-template-rows: auto auto auto auto auto;
    grid-template-areas: "top" "banner" "side" "main" "status"; }
  .topbar { height: 44px; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; }
  .sec.dl { position: static; box-shadow: none; }
  .main { height: 88vh; }
  .tabs { overflow-x: auto; }
  .tabs button { white-space: nowrap; padding: 7px 10px 8px; }
  .splitter { display: none; }
  .stable { height: 40%; }
  .ttools { flex-wrap: wrap; }
  .ttools input[type=search], .ttools select { width: 100%; }
  .series { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .series-ctl { border-right: 0; border-bottom: 1px solid var(--border); max-height: 30vh; }
  .legend { bottom: 18px; font-size: 11px; line-height: 1.5; padding: 5px 8px; }
  .hoverinfo { display: none; }
  .statusbar { height: auto; min-height: 26px; flex-wrap: wrap; padding: 4px 12px; white-space: normal; }
  .statusbar .last { max-width: none; }
}
