/* Datum — interface styles. Builds on ../theme.css (Weblab's shared look) and keeps Datum's magenta accent.
   Layout: full-bleed map; a floating layer panel docked left, the inspector docked right, a slim status strip along the bottom. */

/* Local names (also used by ui.js inline styles) mapped onto the shared tokens. */
:root {
  --paper: var(--wl-surface); --panel: var(--wl-bg); --panel-2: var(--wl-surface); --panel-3: var(--wl-surface-2);
  --ink: var(--wl-ink); --ink-2: var(--wl-ink-2); --ink-3: var(--wl-ink-3); --rule: var(--wl-edge);
  --accent: #b0127a; --accent-ink: #ffffff; --accent-soft: #f8e6f1;
  --good: #1e8e4a; --warn: #a86a00; --serious: #c9541a; --bad: #c0262d;
  --series-1: #2a78d6; --series-2: #eb6834;
  --shadow: 0 1px 2px rgb(20 22 26 / .06), 0 12px 32px -10px rgb(20 22 26 / .22);
  --font: var(--wl-font);
  --mono: var(--wl-mono);
  --panel-w: 352px; --bar-h: 30px; --invert: 0;
}
:root:not([data-theme="light"]) {
  --accent: #f26bbb; --accent-ink: #20091a; --accent-soft: #3a1a2e;
  --good: #4cc47a; --warn: #e0a83a; --serious: #f08a4b; --bad: #f0686c;
  --series-1: #3987e5; --series-2: #d95926;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 14px 36px -10px rgb(0 0 0 / .6); --invert: 1;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
a { color: var(--accent); text-underline-offset: 2px; }

#map { position: absolute; inset: 0 0 var(--bar-h) 0; background: var(--paper); }
#progress { position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 30; overflow: hidden; pointer-events: none; }
#progress::before { content: ''; position: absolute; inset: 0; width: 40%; background: var(--accent); border-radius: 3px; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) { #progress::before { animation: none; width: 100%; opacity: .6; } * { transition: none !important; } }

/* ---------- panel ---------- */
#panel { position: absolute; z-index: 20; top: 12px; left: 12px; bottom: calc(var(--bar-h) + 12px); width: var(--panel-w); display: flex; flex-direction: column;
  background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; transition: transform .22s ease; }
#panel.closed { transform: translateX(calc(-100% - 24px)); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 16px 12px 12px 18px; }
.mark { width: 30px; height: 30px; flex: none; }
.brand { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.brand strong { font: 750 20px/1.05 var(--font); letter-spacing: -.035em; }
.brand span { font: 500 12.5px/1.3 var(--font); color: var(--ink-3); letter-spacing: -.005em; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--wl-pill); color: var(--ink-2); flex: none; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

#search { position: relative; padding: 0 14px 12px; }
#search-input, #filter-input { width: 100%; height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--wl-radius-sm); background: var(--panel-2); transition: background .15s, border-color .15s, box-shadow .15s; }
#search-input:hover, #filter-input:hover { background: var(--panel-3); }
#search-input:focus, #filter-input:focus { outline: none; background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#search-input::placeholder, #filter-input::placeholder { color: var(--ink-3); }
#search-results { position: absolute; z-index: 5; left: 14px; right: 14px; top: 46px; margin: 0; padding: 6px; list-style: none; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--wl-radius-md); box-shadow: var(--wl-shadow-lift); max-height: 300px; overflow: auto; }
#search-results button { width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; display: flex; flex-direction: column; gap: 1px; font-weight: 500; }
#search-results button:hover, #search-results button:focus-visible { background: var(--panel-2); }
#search-results small { color: var(--ink-3); font-size: 12px; font-weight: 400; }
#search-results .none { padding: 8px 10px; color: var(--ink-3); }

.quick { padding: 0 14px 12px; }
.quick-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.quick-head span { font: 650 13px var(--font); letter-spacing: -.01em; color: var(--ink); }
.quick-head .linkish { margin-right: auto; text-decoration: none; font-weight: 500; }
.quick-head .linkish:hover { text-decoration: underline; }
.quick-head .btn { height: 28px; }
#presets { display: flex; flex-wrap: wrap; gap: 6px; max-height: 66px; overflow: hidden; }   /* two rows until "Show all" */
#presets.all { max-height: none; }
.chip { height: 30px; padding: 0 12px; border-radius: var(--wl-pill); background: var(--panel-2); font: 500 12.5px var(--font); color: var(--ink-2); white-space: nowrap; transition: background .15s, color .15s; }
.chip:hover { background: var(--accent-soft); color: var(--accent); }

.tabs { display: flex; margin: 0 14px; padding: 4px; gap: 4px; background: var(--panel-2); border-radius: var(--wl-pill); }
.tabs button { flex: 1; height: 32px; display: flex; align-items: center; justify-content: center; gap: 6px; border-radius: var(--wl-pill); font: 600 13px var(--font); letter-spacing: -.01em; color: var(--ink-2); transition: background .15s, color .15s; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgb(20 22 26 / .12); }
.tabs b { font: 600 11px/1 var(--font); font-variant-numeric: tabular-nums; background: var(--panel-3); color: var(--ink-2); border-radius: var(--wl-pill); padding: 3px 7px; }
.tabs button[aria-selected="true"] b { background: var(--accent-soft); color: var(--accent); }

.pane { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 16px; scrollbar-width: thin; }
#filter-input { margin-bottom: 8px; height: 36px; }

.grp { border-bottom: 1px solid var(--rule); }
.grp:last-child { border-bottom: 0; }
.grp-head, .sec-head { width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; }
.grp-head { padding: 11px 4px; }
.grp.open > .grp-head { position: sticky; top: -12px; z-index: 2; background: var(--panel); }   /* stays in view while its layers scroll */
.grp-head h3 { margin: 0; flex: 1; font: 650 15px var(--font); letter-spacing: -.02em; }
.n { font: 500 11.5px var(--font); font-variant-numeric: tabular-nums; color: var(--ink-3); }
.n.has { color: var(--accent); font-weight: 650; }
.chev { width: 12px; height: 12px; display: grid; place-items: center; color: var(--ink-3); transition: transform .15s; flex: none; }
.chev svg { width: 100%; height: 100%; stroke-width: 2.4; }
.grp.open > .grp-head .chev, .sec.open > .sec-head .chev { transform: rotate(90deg); }
.grp-blurb { margin: -4px 4px 8px; font-size: 12.5px; color: var(--ink-3); }
.grp-body { padding-bottom: 10px; }
.grp:not(.open) > .grp-body, .sec:not(.open) > .sec-body { display: none; }
.sec { margin-left: 2px; border-left: 2px solid var(--rule); padding-left: 10px; }
.sec + .sec { margin-top: 1px; }
.sec.open { border-left-color: var(--accent); margin-bottom: 6px; }
.sec-head { padding: 7px 2px 7px 0; border-radius: 6px; }
.sec-head:hover h4 { color: var(--ink); }
.sec-head h4 { margin: 0; flex: 1; font: 600 13px var(--font); letter-spacing: -.01em; color: var(--ink-2); }
.sec-head .chev { width: 10px; height: 10px; }
/* while the filter box has text, everything that matches is laid open */
.filtering .grp > .grp-body, .filtering .sec > .sec-body { display: block; }
.filtering .grp-blurb, .filtering .chev { display: none; }
.filtering .grp.open > .grp-head { position: static; }

.row { display: grid; grid-template-columns: 38px 1fr 26px; align-items: start; padding: 6px 2px 6px 4px; border-radius: var(--wl-radius-sm); transition: background .12s; }
.row:hover { background: var(--panel-2); }
.sw { position: relative; width: 30px; height: 18px; margin-top: 1px; display: block; cursor: pointer; }
.sw input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.sw i { position: absolute; inset: 0; border-radius: var(--wl-pill); background: var(--panel-3); box-shadow: inset 0 0 0 1px var(--rule); transition: background .15s; }
.sw i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s; }
.sw input:checked + i { background: var(--accent); box-shadow: none; }
.sw input:checked + i::after { transform: translateX(12px); }
.sw input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw input:disabled + i { opacity: .45; }
.row-name { font-size: 13.5px; font-weight: 500; line-height: 1.35; cursor: pointer; letter-spacing: -.005em; }
.tag { display: inline-block; font: 600 10px/1 var(--font); letter-spacing: .01em; padding: 3px 7px; border-radius: var(--wl-pill); background: var(--panel-3); color: var(--ink-2); vertical-align: 1px; margin-left: 4px; }
.tag.live { background: var(--accent-soft); color: var(--accent); }
.row-meta { font: 12px/1.4 var(--font); color: var(--ink-3); min-height: 0; margin-top: 1px; }
.row-meta:empty { display: none; }
.row-meta.err { color: var(--bad); }
.row-meta button { text-decoration: underline; text-underline-offset: 2px; }
.row-meta .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 5px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.row-info { width: 26px; height: 24px; display: grid; place-items: center; color: var(--ink-3); border-radius: var(--wl-pill); }
.row-info:hover { color: var(--ink); background: var(--panel-3); }
.row-info svg { width: 15px; height: 15px; }
.more { grid-column: 2 / 4; padding: 6px 8px 8px 0; font-size: 12.5px; color: var(--ink-2); }
.more p { margin: 0 0 6px; }
.more .src { font-size: 11.5px; color: var(--ink-3); }
.op { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); margin-top: 6px; font-variant-numeric: tabular-nums; }
.op input { flex: 1; accent-color: var(--accent); height: 16px; }
.legend { display: grid; gap: 4px; margin: 6px 0 2px; font-size: 12px; color: var(--ink-2); }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { flex: none; width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, .4); }
.legend.line i { width: 16px; height: 3px; border-radius: 2px; border: 0; }
.legend.fill i { border-radius: 3px; }
.legend img { max-height: 20px; border-radius: 4px; }
.linkish { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; font-size: 12.5px; }
.empty { color: var(--ink-3); font-size: 13px; padding: 14px 2px; }

.param { margin: 6px 0 3px; }
.param-row { display: flex; align-items: center; gap: 4px; }
.param-row span { font-size: 12px; color: var(--ink-3); margin-right: 2px; }
.param select, .param input { flex: 1; min-width: 0; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: var(--panel-3); font: 500 12.5px var(--font); font-variant-numeric: tabular-nums; }
.param select:focus, .param input:focus { outline: none; border-color: var(--accent); background: var(--panel); }
.param .step { width: 30px; height: 30px; border-radius: 8px; background: var(--panel-3); font-size: 16px; line-height: 1; color: var(--ink-2); flex: none; }
.param .step:hover { background: var(--accent-soft); color: var(--accent); }
.param .linkish { display: block; margin-top: 4px; text-align: left; }
.act-tools { display: flex; gap: 6px; }
.act { padding: 10px 2px; border-bottom: 1px solid var(--rule); }
.act-top { display: flex; align-items: center; gap: 8px; }
.act-top span { flex: 1; font-size: 13.5px; font-weight: 500; min-width: 0; }
.panel-foot { border-top: 1px solid var(--rule); padding: 9px 16px; font: 11.5px/1.45 var(--font); color: var(--ink-3); }
.panel-foot .ok { color: var(--good); }

#panel-open { position: absolute; z-index: 19; top: 12px; left: 12px; height: 42px; padding: 0 16px 0 13px; display: flex; align-items: center; gap: 8px; background: var(--panel); border-radius: var(--wl-pill); box-shadow: var(--shadow); font: 600 14px var(--font); letter-spacing: -.01em; }
#panel-open:hover { color: var(--accent); }
#panel-open svg { width: 18px; height: 18px; }

/* ---------- view bar ---------- */
#viewbar { position: absolute; z-index: 15; top: 12px; right: 12px; display: flex; gap: 6px; }
.vb { height: 38px; min-width: 38px; padding: 0 13px; display: flex; align-items: center; justify-content: center; gap: 7px; background: var(--panel); border-radius: var(--wl-pill); box-shadow: var(--shadow); font: 600 13px var(--font); letter-spacing: -.01em; color: var(--ink-2); transition: color .15s, background .15s; }
.vb svg { width: 17px; height: 17px; flex: none; }
.vb:hover { color: var(--ink); }
.vb[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.pop { position: absolute; top: 46px; right: 0; width: 280px; padding: 14px; background: var(--panel); border-radius: var(--wl-radius-md); box-shadow: var(--wl-shadow-lift), var(--shadow); }
.pop h4 { margin: 0 0 10px; font: 650 13px var(--font); letter-spacing: -.01em; color: var(--ink); }
.bm-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bm { display: flex; flex-direction: column; gap: 5px; align-items: stretch; font-size: 11.5px; line-height: 1.15; color: var(--ink-2); text-align: center; }
.bm i { display: block; height: 40px; border-radius: 10px; border: 2px solid var(--rule); }
.bm:hover i { border-color: var(--ink-3); }
.bm[aria-pressed="true"] i { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.bm[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
.pop label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); margin-top: 12px; }
.pop input[type=range] { flex: 1; accent-color: var(--accent); }
.maplibregl-ctrl-top-right { top: 50px; right: 2px; }
.maplibregl-ctrl-group { background: var(--panel); border-radius: 12px !important; box-shadow: var(--shadow) !important; overflow: hidden; }
.maplibregl-ctrl-group button + button { border-top-color: var(--rule); }
.maplibregl-ctrl-group button:not(:disabled):hover { background-color: var(--panel-2) !important; }
.maplibregl-ctrl-group .maplibregl-ctrl-icon { filter: invert(var(--invert)); }
.maplibregl-ctrl-bottom-left { left: calc(var(--panel-w) + 16px); transition: left .22s; }
body.panel-closed .maplibregl-ctrl-bottom-left { left: 0; }
.maplibregl-ctrl-scale { cursor: pointer; font: 500 10.5px var(--font); }

/* ---------- inspector ---------- */
#inspector { position: absolute; z-index: 18; top: 60px; right: 60px; bottom: calc(var(--bar-h) + 36px); width: 348px; display: flex; flex-direction: column;
  background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.insp-head { display: flex; align-items: center; padding: 12px 10px 10px 18px; border-bottom: 1px solid var(--rule); }
.insp-head h2 { flex: 1; margin: 0; font: 700 16px var(--font); letter-spacing: -.025em; color: var(--ink); }
#insp-body { flex: 1; overflow-y: auto; scrollbar-width: thin; }
.card { padding: 14px 18px 15px; border-bottom: 1px solid var(--rule); }
.card.hot { box-shadow: inset 3px 0 0 var(--accent); }
.card h3 { margin: 0; font: 700 17px/1.25 var(--font); letter-spacing: -.025em; text-wrap: balance; overflow-wrap: anywhere; }
.card .sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.card .from { font: 600 11.5px var(--font); color: var(--accent); margin-bottom: 3px; }
.kv { display: grid; grid-template-columns: minmax(84px, 38%) 1fr; gap: 4px 12px; margin: 10px 0 0; font-size: 12.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv-h { margin: 12px 0 0; font: 650 12.5px var(--font); letter-spacing: -.01em; color: var(--ink); }
.card .links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 12.5px; font-weight: 500; }
.card .note { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-2); }
.card pre { margin: 8px 0 0; padding: 10px 12px; background: var(--panel-2); border-radius: var(--wl-radius-sm); font: 11.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.card .wait { margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.more-attrs { margin-top: 8px; font-size: 12px; }

/* ---------- charts ---------- */
.chart { margin-top: 12px; position: relative; }
.chart-t { font: 650 12.5px var(--font); letter-spacing: -.01em; color: var(--ink); display: flex; justify-content: space-between; gap: 8px; }
.chart-t span { font: 400 11.5px var(--font); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font: 10px var(--font); font-variant-numeric: tabular-nums; }
.chart .s1 { stroke: var(--series-1); } .chart .s2 { stroke: var(--series-2); }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln.dash { stroke-dasharray: 5 4; }
.chart .now { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .ref { stroke-width: 1; stroke-dasharray: 6 3; }
.chart .ref.warning { stroke: var(--warn); } .chart .ref.serious { stroke: var(--serious); } .chart .ref.critical { stroke: var(--bad); }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; }
.chart .dotm { stroke: var(--panel); stroke-width: 2; }
.chart .dotm.s1 { fill: var(--series-1); } .chart .dotm.s2 { fill: var(--series-2); }
.chart-key { display: flex; flex-wrap: wrap; gap: 3px 14px; margin-top: 6px; font-size: 11.5px; color: var(--ink-2); }
.chart-key i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 5px; }
.chart-key i.s1 { border-color: var(--series-1); } .chart-key i.s2 { border-color: var(--series-2); } .chart-key i.dash { border-top-style: dashed; }
.chart-key i.warning { border-color: var(--warn); border-top-style: dashed; } .chart-key i.serious { border-color: var(--serious); border-top-style: dashed; } .chart-key i.critical { border-color: var(--bad); border-top-style: dashed; }
.tip { position: absolute; z-index: 3; pointer-events: none; padding: 6px 9px; background: var(--ink); color: var(--panel); border-radius: 8px; font: 500 11.5px/1.4 var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; transform: translate(-50%, -100%); box-shadow: var(--shadow); }

/* ---------- measure ---------- */
#measure { position: absolute; z-index: 16; top: 60px; right: 60px; width: 348px; padding: 16px 18px; background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); }
#measure h4 { margin: 0 0 6px; font: 650 14px var(--font); letter-spacing: -.015em; color: var(--ink-2); }
#measure .big { font: 700 24px/1.2 var(--font); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
#measure .alt { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
#measure .btns { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.btn { height: 32px; padding: 0 14px; border-radius: var(--wl-pill); background: var(--panel-2); font: 600 12.5px var(--font); letter-spacing: -.005em; color: var(--ink-2); transition: background .15s, color .15s; }
.btn:hover { background: var(--accent-soft); color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { background: var(--panel-2); color: var(--ink-2); }

/* ---------- status strip ---------- */
#status { position: absolute; z-index: 25; left: 0; right: 0; bottom: 0; height: var(--bar-h); display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: var(--panel); border-top: 1px solid var(--rule); font: 500 12px var(--font); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
#st-coords { min-width: 200px; text-align: left; color: var(--ink); font-family: var(--mono); font-size: 11.5px; font-weight: 400; }
#st-north { color: var(--accent); font-weight: 600; }
#st-north:hover { text-decoration: underline; text-underline-offset: 2px; }
.maplibregl-ctrl-attrib { font: 10.5px var(--font); }
.maplibregl-ctrl-bottom-right { bottom: 0; }

#toasts { position: absolute; z-index: 40; left: 50%; bottom: calc(var(--bar-h) + 18px); transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { padding: 11px 16px; background: var(--ink); color: var(--panel); border-radius: var(--wl-radius-md); font-size: 13px; font-weight: 500; box-shadow: var(--wl-shadow-lift); }

/* ---------- small screens: panels become sheets ---------- */
@media (max-width: 760px) {
  :root { --panel-w: 0px; }
  #panel { top: auto; left: 0; right: 0; bottom: var(--bar-h); width: auto; height: min(68vh, 560px); border-radius: 22px 22px 0 0; }
  #panel.closed { transform: translateY(calc(100% + 40px)); }
  #inspector, #measure { top: auto; left: 0; right: 0; bottom: var(--bar-h); width: auto; border-radius: 22px 22px 0 0; }
  #inspector { height: min(56vh, 460px); z-index: 22; }
  .maplibregl-ctrl-bottom-left { left: 0; }
  #st-zoom { display: none; }
  #st-coords { min-width: 0; }
  .vb { padding: 0; width: 38px; }
  .vb span { display: none; }
  .pop { right: -46px; }
}
