/* Layout: operations console — the map is the stage, filters on the left rail, the intelligence panel on the right. */
:root {
  --bg: #e9eff0;
  --surface: #ffffff;
  --surface-2: #f3f7f7;
  --ink: #0f2328;
  --ink-2: #455b61;
  --muted: #6f8389;
  --line: #d3dee0;
  --accent: #0b6670;
  --accent-ink: #ffffff;
  --accent-soft: #d9ecec;
  --sea: #dbe6e8;
  --land: #f7faf9;
  --land-line: #b3c5c8;
  --shadow: 0 1px 2px rgba(15, 35, 40, .06), 0 6px 20px rgba(15, 35, 40, .08);
  /* status (risk) palette — always paired with icon + label */
  --r-very_high: #d03b3b;
  --r-high: #ec835a;
  --r-moderate: #fab219;
  --r-low: #0ca30c;
  --r-none: #8a9a9e;
  /* sequential (choropleth) */
  --q0: var(--land); --q1: #cde2fb; --q2: #9ec5f4; --q3: #5598e7; --q4: #2a78d6; --q5: #184f95;
  --font-display: "Kanit", "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
  --font-body: "IBM Plex Sans Thai", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-md: .9375rem; --fs-lg: 1.125rem; --fs-xl: 1.5rem;
  --radius: 10px; --radius-sm: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1315; --surface: #101c1f; --surface-2: #152429; --ink: #e2edef; --ink-2: #a3b7bc; --muted: #73888d;
    --line: #233539; --accent: #46b9c3; --accent-ink: #052024; --accent-soft: #123539;
    --sea: #081012; --land: #142226; --land-line: #2d474c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --q1: #104281; --q2: #184f95; --q3: #2a78d6; --q4: #5598e7; --q5: #9ec5f4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1315; --surface: #101c1f; --surface-2: #152429; --ink: #e2edef; --ink-2: #a3b7bc; --muted: #73888d;
  --line: #233539; --accent: #46b9c3; --accent-ink: #052024; --accent-soft: #123539;
  --sea: #081012; --land: #142226; --land-line: #2d474c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --q1: #104281; --q2: #184f95; --q3: #2a78d6; --q4: #5598e7; --q5: #9ec5f4;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--fs-md)/1.55 var(--font-body); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 1.1em; height: 1.1em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.18em; }
[data-icon] { display: inline-flex; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; margin: 0; text-wrap: balance; }
kbd { font: 500 var(--fs-xs)/1 var(--font-body); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 6px; color: var(--muted); background: var(--surface); }

/* ---------- app grid ---------- */
.app { height: 100%; display: grid; grid-template-columns: 280px minmax(0, 1fr) 400px; grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top top" "filters stage panel"; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 1200; }
.filters { grid-area: filters; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); z-index: 1100; }
.stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; }
.panel { grid-area: panel; position: relative; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); }

/* ---------- top bar ---------- */
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font: 600 var(--fs-lg)/1.1 var(--font-display); letter-spacing: .01em; }
.brand-th { color: var(--accent); }
.brand-sub { font-size: var(--fs-xs); color: var(--muted); }
.search { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 38px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.search:focus-within { border-color: var(--accent); background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.updated { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mode-badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 500; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.mode-badge.demo { background: color-mix(in srgb, var(--r-moderate) 22%, var(--surface)); color: var(--ink); }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--ink-2); font-size: 18px; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.solid { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
.help-btn { color: var(--accent); }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: var(--fs-sm); letter-spacing: .04em; }
.seg-btn:hover { border-color: var(--accent); color: var(--accent); }
.only-narrow { display: none; }

/* ---------- filters ---------- */
.filters-head { display: flex; align-items: center; gap: 6px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.filters-head h2 { display: flex; align-items: center; gap: 8px; font-size: var(--fs-lg); }
.filters-head .link-btn { margin-left: auto; }
.filters-body { overflow-y: auto; padding: 4px 16px 24px; display: flex; flex-direction: column; }
.f-group { padding: 14px 0; border-bottom: 1px dashed var(--line); display: flex; flex-direction: column; gap: 8px; }
.f-group.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f-group.two > div { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.f-group h3 { font: 500 var(--fs-xs)/1.3 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 4px; }
select, input[type="date"], .save-row input { width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
select:focus, input:focus { border-color: var(--accent); outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-sm); }
.chip:hover { border-color: var(--accent); }
.chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.date-row label { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-xs); color: var(--muted); }
.checks { display: flex; flex-direction: column; gap: 2px; }
.check { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--radius-sm); font-size: var(--fs-sm); cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.check .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: var(--fs-xs); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.group-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.gbtn { display: flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 8px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-xs); text-align: left; line-height: 1.25; }
.gbtn svg { font-size: 15px; color: var(--accent); }
.gbtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 500; }
.saved { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.saved-chip { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.saved-chip button { border: 0; background: transparent; padding: 4px 10px; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 6px; }
.saved-chip button + button { padding: 4px 8px; color: var(--muted); border-left: 1px solid var(--line); }
.saved-chip button:hover { color: var(--accent); }
.save-row { display: flex; gap: 6px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); font-weight: 500; font-size: var(--fs-sm); white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.lock { border-style: dashed; }
.link-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--accent); font-size: var(--fs-sm); font-weight: 500; padding: 4px 6px; border-radius: var(--radius-sm); }
.link-btn:hover { background: var(--accent-soft); }
.tip { border: 0; background: none; color: var(--muted); padding: 2px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 14px; }
.tip:hover, .tip[aria-expanded="true"] { color: var(--accent); }
.tip.solid { width: 36px; height: 36px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 9px; font-size: 18px; }
.privacy-note { margin: 16px 0 0; display: flex; gap: 8px; font-size: var(--fs-xs); color: var(--muted); line-height: 1.5; }
.privacy-note svg { color: var(--accent); margin-top: 2px; }

/* ---------- map ---------- */
.map { position: absolute; inset: 0; background: var(--sea); }
.leaflet-container { background: var(--sea); font-family: var(--font-body); }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: var(--shadow) !important; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--ink-2) !important; }
.leaflet-tooltip { background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius-sm); font: var(--fs-sm)/1.4 var(--font-body); padding: 6px 10px; }
.leaflet-tooltip-top:before { border-top-color: var(--surface); }
.tt-title { font-weight: 600; display: block; }
.tt-sub { color: var(--muted); font-size: var(--fs-xs); }
.map-tools { position: absolute; top: 12px; right: 12px; z-index: 800; display: flex; gap: 8px; align-items: center; }
.seg { display: flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; font-size: var(--fs-sm); color: var(--ink-2); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.legend { position: absolute; left: 12px; bottom: 26px; z-index: 800; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; font-size: var(--fs-xs); display: flex; flex-direction: column; gap: 6px; max-width: 240px; }
.legend h4 { margin: 0; font: 500 var(--fs-xs)/1.2 var(--font-body); color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.legend-row { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-ramp { display: flex; gap: 2px; }
.legend-ramp span { width: 30px; height: 10px; border-radius: 2px; }
.legend-ramp-labels { display: flex; justify-content: space-between; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend .hint { color: var(--muted); }
.result-count { position: absolute; left: 56px; top: 12px; z-index: 800; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: var(--fs-sm); font-weight: 500; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }

/* markers */
.ev-pin { background: none; border: 0; }
.ev-pin .p { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; border: 2px solid var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.35); position: relative; }
.ev-pin .p svg { width: 15px; height: 15px; }
.ev-pin.pending .p { border-style: dashed; border-color: var(--ink); }
.ev-pin.sel .p { outline: 3px solid var(--accent); outline-offset: 2px; }
.ev-pin.new .p::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid currentColor; color: inherit; animation: pulse 1.8s ease-out infinite; }
.ev-pin.risk-moderate .p, .ev-pin.risk-moderate .p svg { color: #1a1300; }
@keyframes pulse { from { opacity: .8; transform: scale(.7); } to { opacity: 0; transform: scale(1.5); } }
.bg-very_high { background: var(--r-very_high); } .bg-high { background: var(--r-high); } .bg-moderate { background: var(--r-moderate); } .bg-low { background: var(--r-low); } .bg-none { background: var(--r-none); }
.ev-pin .p.bg-very_high::after { border-color: var(--r-very_high); } .ev-pin .p.bg-high::after { border-color: var(--r-high); }
.ev-pin .p.bg-moderate::after { border-color: var(--r-moderate); } .ev-pin .p.bg-low::after { border-color: var(--r-low); }
.cl-pin { background: none; }
.cl-pin div { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 600 var(--fs-sm)/1 var(--font-display); color: var(--ink); background: var(--surface); border: 4px solid var(--r-low); box-shadow: 0 1px 6px rgba(0,0,0,.3); }
.cl-pin.cl-very_high div { border-color: var(--r-very_high); } .cl-pin.cl-high div { border-color: var(--r-high); } .cl-pin.cl-moderate div { border-color: var(--r-moderate); }

/* ---------- panel ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; flex: none; }
.tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 46px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-2); font-weight: 500; font-size: var(--fs-sm); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { font-size: var(--fs-xs); background: var(--surface-2); color: var(--ink-2); border-radius: 999px; padding: 0 7px; min-width: 22px; font-variant-numeric: tabular-nums; }
.tabs .count.alert:not(:empty) { background: var(--r-very_high); color: #fff; }
.tab-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 24px; }
.list-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sort { display: flex; align-items: center; gap: 6px; flex: 1; color: var(--muted); }
.sort select { height: 32px; font-size: var(--fs-sm); }
.ev-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ev { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 8px; border-bottom: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.ev:hover, .ev:focus-visible { background: var(--surface-2); }
.ev.sel { background: var(--accent-soft); }
.ev-ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 16px; }
.ev-ic.bg-moderate { color: #1a1300; }
.ev-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ev-title { font-weight: 500; font-size: var(--fs-sm); line-height: 1.4; }
.ev-meta { font-size: var(--fs-xs); color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 8px; }
.ev-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.ev-num { text-align: right; font-variant-numeric: tabular-nums; font-size: var(--fs-xs); color: var(--muted); line-height: 1.35; white-space: nowrap; }
.ev-num b { font: 600 var(--fs-md)/1.2 var(--font-display); color: var(--ink); display: block; }
.ev-num .d { color: var(--r-very_high); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 500; padding: 1px 8px 1px 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); white-space: nowrap; line-height: 1.6; }
.pill svg { width: 12px; height: 12px; }
.pill.risk { border-color: transparent; color: var(--ink); background: color-mix(in srgb, var(--pc) 20%, var(--surface)); }
.pill.risk svg { color: var(--pc); }
.pill.st-pending { border-style: dashed; }
.pill.st-discarded { text-decoration: line-through; }
.more { margin: 12px auto 0; display: flex; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty svg { font-size: 28px; }

/* overview */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.kpi { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .k { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; line-height: 1.3; }
.kpi .v { font: 500 var(--fs-xl)/1.15 var(--font-display); font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 11px; color: var(--muted); }
.kpi .s.warn { color: var(--r-very_high); font-weight: 500; }
.chart-card { margin: 0 0 18px; }
.chart-card figcaption { font: 500 var(--fs-sm)/1.3 var(--font-display); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text, .chart text { fill: var(--muted); font: 10px var(--font-body); }
.chart .grid line { stroke: var(--line); }
.chart .baseline { stroke: var(--ink-2); }
.chart rect.hit { fill: transparent; }
.chart-tt { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius-sm); padding: 6px 10px; font-size: var(--fs-xs); white-space: nowrap; z-index: 5; transform: translate(-50%, -100%); }
.chart-tt b { display: block; font-size: var(--fs-sm); }
.chart-tt .row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--fs-xs); color: var(--ink-2); margin-top: 6px; }
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar { display: grid; grid-template-columns: minmax(0, 9.5em) minmax(0, 1fr) 2.6em; align-items: center; gap: 8px; font-size: var(--fs-xs); border: 0; background: none; padding: 2px 4px; border-radius: 4px; text-align: left; }
.hbar:hover { background: var(--surface-2); }
.hbar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.hbar .track { height: 12px; display: flex; gap: 2px; }
.hbar .track span { height: 100%; border-radius: 0 3px 3px 0; background: var(--accent); min-width: 2px; }
.hbar .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; }
.brief-box { display: flex; align-items: center; gap: 6px; }

/* signals */
.tab-intro { font-size: var(--fs-xs); color: var(--muted); margin: 0 0 12px; }
.sig-sec { margin-bottom: 16px; }
.sig-sec h3 { font-size: var(--fs-sm); display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.sig { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--surface); }
.sig-t { font-weight: 500; font-size: var(--fs-sm); display: flex; align-items: center; gap: 6px; }
.sig-d { font-size: var(--fs-xs); color: var(--muted); grid-column: 1; }
.sig .spark { grid-column: 1 / -1; display: flex; align-items: flex-end; gap: 2px; height: 22px; }
.sig .spark span { flex: 1; background: var(--q2); border-radius: 2px 2px 0 0; min-height: 2px; }
.sig .spark span.cur { background: var(--r-very_high); }
.sig button { grid-row: 1 / span 2; grid-column: 2; }
.ratio { font: 600 var(--fs-xs)/1 var(--font-display); color: var(--r-very_high); background: color-mix(in srgb, var(--r-very_high) 14%, var(--surface)); padding: 3px 6px; border-radius: 4px; }

/* detail */
.detail { position: absolute; inset: 0; background: var(--surface); z-index: 20; overflow-y: auto; padding: 0 16px 24px; }
.d-head { position: sticky; top: 0; background: var(--surface); display: flex; align-items: center; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); z-index: 2; }
.d-id { font: 500 var(--fs-sm)/1 var(--font-body); color: var(--muted); letter-spacing: .03em; font-variant-numeric: tabular-nums; margin-left: auto; }
.d-title { font-size: var(--fs-lg); line-height: 1.35; margin: 14px 0 8px; }
.d-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.d-nums { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.d-nums div { background: var(--surface); padding: 8px 12px; }
.d-nums dt { font-size: 11px; color: var(--muted); }
.d-nums dd { margin: 0; font: 500 var(--fs-lg)/1.3 var(--font-display); font-variant-numeric: tabular-nums; }
.d-nums dd.small { font: 500 var(--fs-sm)/1.5 var(--font-body); }
.d-sec { margin-bottom: 16px; }
.d-sec h3 { font: 500 var(--fs-xs)/1.3 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.d-sec p { margin: 0; font-size: var(--fs-sm); }
.d-note { font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 6px; margin-top: 6px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl li { position: relative; padding: 0 0 12px 22px; font-size: var(--fs-sm); }
.tl li::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: -6px; width: 2px; background: var(--line); }
.tl li:last-child::before { display: none; }
.tl li::after { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tl li.open::after { border-style: dashed; border-color: var(--muted); }
.tl time { display: block; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.rel { display: flex; flex-direction: column; gap: 4px; }
.rel button { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; text-align: left; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 6px 10px; font-size: var(--fs-xs); }
.rel button:hover { border-color: var(--accent); }
.rel .km { color: var(--muted); font-variant-numeric: tabular-nums; }

/* modal, popover, toast */
.modal { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--ink) 45%, transparent); }
.modal-card { position: relative; width: min(560px, 100%); max-height: calc(100% - 32px); overflow-y: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 24px; }
.modal-x { position: absolute; top: 12px; right: 12px; }
.modal h2 { font-size: var(--fs-xl); margin: 0 40px 4px 0; }
.modal .lead { color: var(--muted); margin: 0 0 16px; font-size: var(--fs-sm); }
.steps { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; align-items: start; }
.steps .si { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 18px; }
.steps b { font-family: var(--font-display); font-weight: 500; display: block; }
.steps span.t { font-size: var(--fs-sm); color: var(--ink-2); }
.kbd-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: 18px; align-items: center; }
.deep-list { margin: 0 0 16px; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.deep-list li { display: flex; gap: 8px; align-items: center; }
.deep-list svg { color: var(--muted); }
.lock-hero { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 24px; margin-bottom: 12px; }
.demo-note { font-size: var(--fs-xs); color: var(--muted); margin: 10px 0 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.popover { position: fixed; z-index: 3100; max-width: 280px; background: var(--ink); color: var(--bg); border-radius: var(--radius-sm); padding: 8px 12px; font-size: var(--fs-xs); line-height: 1.5; box-shadow: var(--shadow); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 3200; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: var(--fs-sm); box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.scrim { display: none; }
.copy-fallback { width: 100%; min-height: 160px; font: var(--fs-xs)/1.5 var(--font-body); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); padding: 8px; color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: minmax(0, 1fr) 380px; grid-template-areas: "top top" "stage panel"; }
  .only-narrow { display: inline-grid; }
  .filters { position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 88vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); z-index: 2500; padding-top: env(safe-area-inset-top, 0px); }
  .filters.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 2400; background: color-mix(in srgb, var(--ink) 35%, transparent); }
  .scrim[hidden] { display: none; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 52vh minmax(0, 1fr); grid-template-areas: "top" "stage" "panel"; }
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .brand-sub, .hide-narrow { display: none; }
  .search { order: 5; flex-basis: 100%; max-width: none; height: 36px; }
  .top-actions { gap: 4px; }
  .mode-badge #mode-text { display: none; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .map-tools { top: 8px; right: 8px; }
  .seg button span:not([data-icon]) { display: none; }
  .legend { left: 8px; bottom: 20px; padding: 6px 8px; max-width: 180px; }
  .legend .hint { display: none; }
  .result-count { top: 8px; left: 50px; }
  .brand { flex: 1; min-width: 0; }
  .brand-mark { width: 32px; height: 32px; font-size: 18px; }
  .seg-btn { padding: 0 8px; }
  .seg-btn [data-icon] { display: none; }
  .top-actions { margin-left: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .ev-pin.new .p::after { animation: none; opacity: .6; }
  .filters { transition: none; }
}
.help-btn { position: relative; }
.help-btn.nudge::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--r-very_high); border: 2px solid var(--surface); }
.muted { color: var(--muted); }
