/* Sri Lanka tanks — the static dashboard (ADR-0020, redesigned in M7).
   Five views, one at a time; the map fills three of them and the panels float over it.
   Colour roles come from the project's validated data-viz palette: one sequential blue
   ramp for magnitude, a red-grey-blue diverging pair for polarity, categorical slots
   1-3 for the few series that ever share a chart, and the status colours reserved for
   the record's states. Nothing here picks a hue for decoration. */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --surface-2: #f3f3f0;
  --plane: #f9f9f7;
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --unobserved: #b6b5ae;
  --glass: rgba(252, 252, 251, 0.90);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19; --surface-2: #232322; --plane: #0d0d0d;
    --ink-1: #ffffff; --ink-2: #c3c2b7; --ink-muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --unobserved: #4a4a46; --glass: rgba(26, 26, 25, 0.90);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19; --surface-2: #232322; --plane: #0d0d0d;
  --ink-1: #ffffff; --ink-2: #c3c2b7; --ink-muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --unobserved: #4a4a46; --glass: rgba(26, 26, 25, 0.90);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--plane); color: var(--ink-1); overflow: hidden;
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }
b { font-weight: 600; }
code { font-size: 11.5px; }
.spacer { flex: 1; }
.hint { color: var(--ink-muted); font-size: 11.5px; font-weight: 400; }

/* ---------------------------------------------------------------- chrome */
.banner { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 900; max-width: 90vw;
          background: var(--warning); color: #0b0b0b; padding: 6px 12px; border-radius: 6px; font-size: 13px;
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
header.top {
  position: fixed; top: 0; left: 0; right: 0; height: 48px; z-index: 1000;
  display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub { font-weight: 400; color: var(--ink-muted); margin-left: 8px; font-size: 12px; }
nav.views { display: flex; gap: 2px; }
nav.views button {
  font: inherit; font-size: 13px; padding: 6px 12px; border: none; background: none;
  color: var(--ink-2); border-radius: 8px; cursor: pointer;
}
nav.views button[aria-selected="true"] { background: var(--surface-2); color: var(--ink-1); font-weight: 600; }
.find { position: relative; margin-left: auto; }
.find input {
  font: inherit; width: 260px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--plane); color: var(--ink-1);
}
.find.small { margin-left: 0; }
.find.small input { width: 180px; padding: 3px 8px; font-size: 12px; }
.find-list {
  position: absolute; top: 36px; left: 0; width: 380px; max-height: 340px; overflow: auto;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); z-index: 1100; padding: 4px;
}
.find.small .find-list { top: 30px; width: 320px; }
.find-list div { padding: 6px 10px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.find-list div:hover, .find-list div.active { background: var(--surface-2); }
.find-list .hint { margin-left: auto; }
button.icon {
  font: inherit; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--ink-2); cursor: pointer; padding: 0; line-height: 1;
}
button.icon[aria-pressed="true"] { background: var(--series-1); color: #fff; border-color: transparent; }

main { position: absolute; top: 48px; left: 0; right: 0; bottom: 0; }
.view { position: absolute; inset: 0; }
.view.scroll { overflow: auto; padding: 14px 18px 48px; }
.mapfill { position: absolute; inset: 0; }
.leaflet-container { background: var(--plane); font: inherit; }
/* A dark basemap without a keyed provider: invert and desaturate the OSM tiles. The
   imagery layer on the tank map is not touched. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .base-osm { filter: invert(1) hue-rotate(180deg) brightness(0.72) saturate(0.35) contrast(0.95); }
}
:root[data-theme="dark"] .base-osm { filter: invert(1) hue-rotate(180deg) brightness(0.72) saturate(0.35) contrast(0.95); }
:root[data-theme="light"] .base-osm { filter: saturate(0.55) brightness(1.02); }
@media (prefers-color-scheme: light) { :root:where(:not([data-theme="dark"])) .base-osm { filter: saturate(0.55) brightness(1.02); } }
.leaflet-container .leaflet-control-attribution { font-size: 9px; background: var(--glass); color: var(--ink-muted); }
.leaflet-tooltip { font: 12px/1.4 system-ui, sans-serif; background: var(--surface-1); color: var(--ink-1);
                   border: 1px solid var(--border); box-shadow: var(--shadow); }
.leaflet-tooltip::before { display: none; }
.leaflet-bar a { background: var(--surface-1); color: var(--ink-1); border-bottom-color: var(--border); }

/* Floating panels over a map. */
.panel {
  position: absolute; z-index: 500; background: var(--glass); backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow);
}
.panel-left { top: 12px; left: 12px; width: 212px; max-height: calc(100% - 90px); overflow: auto; }
.panel-right { top: 12px; right: 12px; width: 236px; }
.panel-right.wide { width: 420px; bottom: 64px; overflow: auto; right: 64px; }
.panel-head h2 { font-size: 16px; margin: 0 0 2px; }
.timebar {
  position: absolute; left: 12px; right: 64px; bottom: 12px; z-index: 500; display: flex;
  align-items: center; gap: 10px; padding: 7px 12px; background: var(--glass); backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.timebar input[type="range"] { flex: 1; min-width: 200px; }
.drawer {
  position: absolute; left: 12px; right: 64px; bottom: 62px; z-index: 500; display: grid;
  grid-template-columns: 1fr 1fr 1fr; gap: 14px; padding: 10px 12px; background: var(--glass);
  backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.readout { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 8ch; }
.readout-sub { color: var(--ink-muted); font-size: 11.5px; min-width: 12ch; }
input[type="range"] { accent-color: var(--series-1); }

/* ---------------------------------------------------------------- chips, tiers, info */
.chip {
  font: inherit; font-size: 12px; padding: 3px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--ink-2); white-space: nowrap;
}
.chip.small { font-size: 11px; padding: 2px 8px; }
.chip.ghost { border-color: transparent; }
.chip[aria-pressed="true"] { background: var(--series-1); color: #fff; border-color: transparent; }
.chip:hover:not([aria-pressed="true"]) { background: var(--surface-2); }
select.chip { appearance: auto; padding: 2px 6px; }
.modes h4, .layers h4 {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted);
  margin: 8px 0 4px; font-weight: 600;
}
.modes h4:first-child { margin-top: 0; }
.modes .row, .layers .row { display: flex; flex-wrap: wrap; gap: 4px; }
.layers { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 4px; }
.tier {
  display: inline-block; font-size: 9.5px; font-weight: 700; padding: 0 5px; border-radius: 4px;
  border: 1px solid var(--border); color: var(--ink-2); vertical-align: 1px; line-height: 14px; margin-left: 4px;
}
.tier.A { color: var(--good); border-color: var(--good); }
.tier.B { color: var(--series-1); border-color: var(--series-1); }
.tier.C { color: var(--serious); border-color: var(--serious); }
button.info {
  width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--ink-muted); color: var(--ink-muted);
  background: none; cursor: pointer; padding: 0; line-height: 13px; font: italic 700 10px Georgia, serif;
  flex: none; vertical-align: 1px;
}
button.info::before { content: 'i'; }
button.info:hover { color: var(--series-1); border-color: var(--series-1); }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.facts span { font-size: 11.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 6px; padding: 1px 7px; }
.facts span.dry { color: var(--serious); }
.facts span.wet { color: var(--series-1); }

/* The popover and the hover tip. */
.pop {
  position: fixed; z-index: 2000; max-width: 400px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 12.5px; line-height: 1.5;
}
.pop p { margin: 4px 0 0; }
.pop .pt { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.pop .pu { color: var(--ink-muted); font-size: 11.5px; }
.pop .reg { color: var(--ink-muted); font-size: 11px; margin-top: 6px; }
.tip {
  position: fixed; z-index: 2100; pointer-events: none; background: var(--surface-1); color: var(--ink-1);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px; font-size: 12px; box-shadow: var(--shadow);
  white-space: nowrap; font-variant-numeric: tabular-nums; max-width: 360px;
}
dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-1); color: var(--ink-1);
         padding: 14px 16px; max-width: 520px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.help div { display: flex; gap: 8px; align-items: baseline; margin: 6px 0; font-size: 12.5px; }
.help .tier { margin: 0; flex: none; }

/* ---------------------------------------------------------------- cards and kpis */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.card-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2 > .card { margin-bottom: 14px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpis.inline { display: flex; gap: 8px; flex-wrap: wrap; }
.kpi { background: var(--surface-2); border-radius: 8px; padding: 6px 9px; min-width: 96px; }
.kpi .v { font-size: 19px; font-weight: 600; line-height: 1.15; white-space: nowrap; }
.kpi .v.small { font-size: 14px; }
.kpi .k { font-size: 10.5px; color: var(--ink-muted); line-height: 1.25; margin-top: 2px; }
.kpi .x { font-size: 10.5px; color: var(--ink-2); }
.kpi.good .v { color: var(--good); }
.kpi.bad .v { color: var(--critical); }
.kpi.up .v::after { content: ' ↗'; color: var(--series-1); font-weight: 400; }
.kpi.down .v::after { content: ' ↘'; color: var(--critical); font-weight: 400; }

/* ---------------------------------------------------------------- legends */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 11px; color: var(--ink-2); margin-top: 10px; }
.legend.inline { margin: 0 0 8px; }
.legend .ramp { display: flex; height: 9px; border-radius: 3px; overflow: hidden; width: 110px; }
.legend .ramp i { flex: 1; }
.legend .sw, .help .sw, .ckeys i {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid var(--border);
  vertical-align: -1px; margin-right: 4px; flex: none;
}
.legend .sw.hollow, .help .sw.hollow { background: transparent; border: 1.5px solid var(--unobserved); }
.legend .sw.pass { background: var(--good); border-radius: 2px; }
.legend .sw.fail { background: var(--critical); border-radius: 2px; }
.legend .sw.open { background: var(--unobserved); border-radius: 2px; }
.legend .sw.cand { background: transparent; border: 1.5px dashed var(--series-2); }
.help .sw.gap { width: 18px; height: 2px; border-radius: 0; border: none; background: linear-gradient(90deg, var(--series-1) 40%, transparent 40%, transparent 60%, var(--series-1) 60%); }
.legend .lt { width: 100%; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 4px; }

/* ---------------------------------------------------------------- charts */
.chart { position: relative; margin-top: 6px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .ttip {
  position: absolute; pointer-events: none; background: var(--surface-1); color: var(--ink-1);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px; font-size: 12px;
  box-shadow: var(--shadow); white-space: nowrap; opacity: 0; transition: opacity .08s;
  font-variant-numeric: tabular-nums; z-index: 5;
}
.ct { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); margin-bottom: 1px; min-height: 18px; }
.ct .cl { font-weight: 600; }
.ckeys { display: inline-flex; gap: 10px; margin-left: 6px; font-size: 11px; color: var(--ink-muted); }
.ckeys span { display: inline-flex; align-items: center; gap: 4px; }
.ckeys i { border-radius: 2px; border: none; margin: 0; }
.ckeys i.dot { border-radius: 50%; background: var(--ink-1); width: 7px; height: 7px; }
.empty-note { color: var(--ink-muted); font-size: 12px; padding: 8px 0; }

/* Two radial "clocks", one per magnitude, sharing the angular axis. */
.clocks { display: flex; gap: 12px; justify-content: space-around; margin-bottom: 8px; }
.clocks > div { flex: 1; min-width: 0; }
.clock svg text { fill: var(--ink-muted); font-size: 9px; }

/* ---------------------------------------------------------------- the record grid */
.record { display: grid; grid-template-columns: 58px 1fr; gap: 6px 8px; align-items: start; }
.record .grp { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-muted); padding-top: 8px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.record .cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.record.big .cells { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cell {
  position: relative; border-left: 3px solid var(--st, var(--unobserved)); background: var(--surface-2);
  border-radius: 6px; padding: 5px 8px 5px 9px; cursor: pointer; min-height: 46px;
}
.cell:hover { outline: 1px solid var(--series-1); }
.cell .q { font-size: 10.5px; color: var(--ink-muted); line-height: 1.25; padding-right: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .v { font-size: 15px; font-weight: 600; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.cell .v.dim { color: var(--ink-muted); font-weight: 500; }
.cell .x { font-size: 10.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record.big .cell .v { font-size: 13px; }
.cell .tier { position: absolute; top: 4px; right: 4px; margin: 0; }
.cell.measured, .cell.built { --st: var(--good); }
.cell.partial { --st: var(--warning); }
.cell.no_data { --st: var(--unobserved); }
.cell.not_built { --st: var(--unobserved); border-left-style: dashed; }
.cell.not_measurable { --st: var(--critical); }
.cell.unobtained { --st: var(--serious); }
.st { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; border: 1px solid; white-space: nowrap; }
.st.measured, .st.built { color: var(--good); }
.st.partial { color: var(--warning); }
.st.no_data, .st.not_built { color: var(--ink-muted); }
.st.not_measurable { color: var(--critical); }
.st.unobtained { color: var(--serious); }

/* ---------------------------------------------------------------- heat strip */
.heat { display: grid; gap: 2px; align-items: center; font-size: 11px; margin-top: 4px; }
.heat .hc { text-align: center; color: var(--ink-muted); font-size: 10px; padding-bottom: 2px; }
.heat .hc.muted { opacity: 0.5; }
.heat .hr { color: var(--ink-2); padding-right: 8px; white-space: nowrap; display: flex; align-items: center; }
.heat .cellv {
  height: 22px; border-radius: 3px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--ink-1); background: var(--grid); font-variant-numeric: tabular-nums;
}
.heat .cellv.dark { color: #fff; }
.heat .cellv.empty { background: transparent; border: 1px dashed var(--axis); }
.heat .cellv.trunc { opacity: 0.45; }

/* ---------------------------------------------------------------- chain diagram */
.chain .link { display: grid; grid-template-columns: 22px 1fr 52px 120px 34px; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.chain .link.here { background: rgba(42, 120, 214, 0.12); }
.chain .link .pos { color: var(--ink-muted); font-size: 11px; text-align: right; }
.chain .link .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.chain .link .nm.off { color: var(--ink-muted); }
.chain .link .el { color: var(--ink-muted); font-size: 10.5px; text-align: right; font-variant-numeric: tabular-nums; }
.chain .bars i { display: block; height: 5px; border-radius: 2px; margin: 1px 0; background: var(--series-1); }
.chain .bars i.carry { background: var(--series-3); }
.chain .bars i.none { background: transparent; border: 1px dashed var(--axis); height: 3px; }
.chain .on { font-size: 10.5px; color: var(--ink-2); text-align: center; }
.chain .arrow { text-align: center; color: var(--ink-muted); font-size: 10px; line-height: 9px; padding-left: 12px; }
.chain .head { display: grid; grid-template-columns: 22px 1fr 52px 120px 34px; gap: 8px; font-size: 10px; color: var(--ink-muted); padding: 0 6px 4px; }
.chain .head span:nth-child(3) { text-align: right; }

/* ---------------------------------------------------------------- squares, meters, spans */
.squares { display: flex; flex-wrap: wrap; gap: 3px; }
.sq { width: 15px; height: 15px; border-radius: 3px; cursor: default; }
.sq.pass { background: var(--good); } .sq.fail { background: var(--critical); } .sq.open { background: var(--unobserved); }
.sq:hover { outline: 2px solid var(--ink-1); }
.meters { display: grid; gap: 5px; margin-bottom: 8px; }
.meter { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-2); }
.meter .track { position: relative; height: 8px; background: var(--grid); border-radius: 4px; }
.meter .track i { position: absolute; top: 0; height: 100%; border-radius: 4px; }
.meter .track b { position: absolute; top: -2px; width: 1px; height: 12px; background: var(--axis); }
.meter .val { text-align: right; font-weight: 600; color: var(--ink-1); font-variant-numeric: tabular-nums; }
.meter.empty .val { color: var(--ink-muted); font-weight: 400; }
.spans { display: grid; grid-template-columns: 158px 1fr 60px; gap: 4px 8px; align-items: center; font-size: 11.5px; }
.spans .sl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spans .track { position: relative; height: 10px; background: var(--grid); border-radius: 3px; }
.spans .track i { position: absolute; top: 0; height: 100%; border-radius: 3px; background: var(--series-1); }
.spans .sn { color: var(--ink-muted); text-align: right; font-variant-numeric: tabular-nums; }
.spans .ax { grid-column: 2; display: flex; justify-content: space-between; color: var(--ink-muted); font-size: 10px; }

/* ---------------------------------------------------------------- tank page */
.tank-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.tank-title h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; line-height: 1.2; }
.mapwrap { position: relative; }
#tankmap { height: 380px; border-radius: 8px; border: 1px solid var(--border); }
#tankrelief { position: absolute; inset: 0; z-index: 600; display: flex; flex-direction: column; background: var(--plane);
              border-radius: 8px; border: 1px solid var(--border); overflow: hidden; }
#relief-canvas { flex: 1; width: 100%; min-height: 0; cursor: grab; touch-action: none; display: block; }
.relief-bar { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-top: 1px solid var(--border); background: var(--glass); }
.relief-bar input[type="range"] { width: 90px; vertical-align: middle; }
.help .help-ramp { width: 60px; height: 9px; border-radius: 3px; flex: none; display: inline-block;
                   background: linear-gradient(90deg, #b7191c, #e36927, #d2ba92, #53b6eb, #285cc2); }
.shorebar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.shorebar input[type="range"] { flex: 1; }
.events { position: relative; height: 34px; margin: 8px 0 4px; }
.events svg { width: 100%; height: 34px; display: block; overflow: visible; }
