.viz-root {
  color-scheme: light;
  --surface-0: #f6f7f9;
  --surface-1: #ffffff;
  --border: #e3e5ea;
  --grid: #eceef2;
  --text-primary: #191919;
  --text-secondary: #666666;
  --seq-150: #b6d5f8; --seq-300: #6aabf1; --seq-450: #257de0; --seq-600: #1757ac; --seq-700: #0e3d7e;
  --metro: #505050; --metro-line: #111111;
  --secondary: #ff5252; --secondary-line: #e53935;
  --proposed: #9c27b0; --proposed-line: #8e24aa;
  --critical: #dc3c3d;
  --accent: #257de0;
  --wm-150: #fdd9c2; --wm-300: #f8a878; --wm-450: #f47230; --wm-600: #c4531a; --wm-700: #8f3a10;
  --tech: #006e12; --tech-recent: #008a17; --tech-mid: #7cc98a; --tech-idle: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--surface-0); color: var(--text-primary);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
h1 { font-size: 20px; margin: 0; font-weight: 700; }
h2 { font-size: 15px; margin: 0; font-weight: 650; }
.sub, .note { color: var(--text-secondary); font-size: 12.5px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 22px; background: var(--surface-1); border-bottom: 1px solid var(--border); }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.filters select { font: inherit; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.btn { font: inherit; padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.refresh { color: var(--text-secondary); font-size: 12px; margin-left: 6px; }
.refresh.stale { color: var(--critical); font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 12px; padding: 14px 22px 0; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.kpi .lab { font-size: 12px; color: var(--text-secondary); }
.kpi .val { font-size: 26px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi .cmp { font-size: 12px; color: var(--text-secondary); }
.kpi .cmp b { color: var(--text-primary); font-weight: 600; }
.kpi.pending { background: transparent; border-style: dashed; }
.kpi-empty { min-height: 84px; }
.kpi.pending .val { color: #b0b4bc; font-size: 15px; padding: 8px 0 4px; font-weight: 600; }

.mapwrap { position: relative; margin: 14px 22px 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
#map { height: 58vh; min-height: 420px; background: #e9edf2; }
.legend { position: absolute; left: 12px; bottom: 12px; z-index: 500; background: rgba(255,255,255,.96);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 12px; line-height: 1.7; max-width: 300px; }
.legend .row { display: flex; align-items: center; gap: 8px; }
.sw { display: inline-block; width: 14px; height: 10px; border: 2px solid; border-radius: 2px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #c9ccd2; }
.ring { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--seq-700); background: #fff; }
.legend .ttl { font-weight: 650; margin-top: 4px; }
.legend .wmfilter { gap: 10px; flex-wrap: wrap; }
.legend .wmfilter label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.legend .wmfilter input { margin: 0; accent-color: var(--wm-700); }

.grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; padding: 14px 22px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.card-h.second { margin-top: 18px; }
.tabs { display: flex; gap: 4px; }
.tab { font: inherit; font-size: 12.5px; border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 3px 10px; cursor: pointer; }
.tab.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 12px; border-bottom: 1px solid var(--border); padding: 6px 8px; white-space: nowrap; }
td { border-bottom: 1px solid var(--grid); padding: 6px 8px; vertical-align: top; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f2f7fe; }
tr.sel td { background: #e6f0fd; }
tr.cov td:first-child { font-weight: 650; }
tr.total td { font-weight: 650; border-top: 1px solid var(--border); }
.tablewrap { overflow-x: auto; }
.flag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--seq-700);
  border: 1px solid var(--seq-300); background: #eef5fe; border-radius: 10px; padding: 0 7px; white-space: nowrap; }
.muted { color: var(--text-secondary); }
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { cursor: default; }
.chart .bar:hover, .chart .hit:hover + .bar { opacity: .8; }

.tip { position: fixed; z-index: 2000; pointer-events: none; background: #191919; color: #fff; font-size: 12px;
  padding: 6px 9px; border-radius: 6px; line-height: 1.45; max-width: 260px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.popup h3 { margin: 0 0 2px; font-size: 14px; }
.popup .meta { color: var(--text-secondary); font-size: 12px; margin-bottom: 6px; }
.popup table { font-size: 12px; }
.popup td, .popup th { padding: 3px 5px; }
.leaflet-popup-content { margin: 10px 12px; min-width: 260px; }

details summary { display: flex; align-items: baseline; gap: 12px; cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary h2::before { content: "▸ "; color: var(--text-secondary); }
details[open] summary h2::before { content: "▾ "; }
#health { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
#health h3 { font-size: 13px; margin: 6px 0; }
footer { color: var(--text-secondary); font-size: 12px; padding: 0 22px 22px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid { grid-template-columns: 1fr; }
  #health { grid-template-columns: 1fr; }
}
.popup td:first-child { white-space: nowrap; }

.banner { margin: 12px 22px 0; padding: 10px 14px; border-radius: 8px; border: 1px solid #f1b0b0; background: #fdf1f1; font-size: 13px; }
.banner b { color: var(--critical); }
.scroll { max-height: 420px; overflow-y: auto; }
.rank { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center;
  background: var(--text-primary); color: #fff; font-size: 12px; font-weight: 700; }
.prio-pin { background: var(--text-primary); color: #fff; border: 2px solid #fff; border-radius: 50%; width: 26px !important; height: 26px !important;
  display: flex !important; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.chip { display: inline-block; font-size: 11.5px; border-radius: 10px; padding: 0 7px; border: 1px solid var(--border); white-space: nowrap; }
.chip.wm { border-color: var(--wm-300); background: #fff4ec; color: var(--wm-700); }
.chip.idle { border-color: #d6d8dd; background: #f4f5f7; color: var(--text-secondary); }
.chip.prio { border-color: #c9ccd2; background: #191919; color: #fff; }
.sub2 { color: var(--text-secondary); font-size: 12px; }
.wmlist h3 { font-size: 13px; margin: 10px 0 4px; }
.tdot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #191919; vertical-align: -1px; }

/* filter change in progress */
.loadinfo { font-size: 12px; font-weight: 600; color: var(--seq-700, #0b4f9c); }
.viz-root.loading .kpis, .viz-root.loading .grid, .viz-root.loading #map { opacity: .55; transition: opacity .15s; }
