/* AWD Monitor. Paddy-field palette: deep green ink and sidebar, water blue accent;
   amber and red are kept for warnings and "irrigate now". */
:root {
  --bg: #f2f5f1;
  --surface: #ffffff;
  --surface-2: #f6f8f5;
  --surface-3: #edf1ec;
  --border: #dde5da;
  --border-strong: #c9d4c6;
  --ink: #142519;
  --ink-2: #4b5d52;
  --ink-3: #7c8b82;
  --brand: #1d6b45;
  --brand-strong: #14532f;
  --brand-soft: #e2f1e7;
  --accent: #1f74c8;
  --accent-soft: #e3eefb;
  --side: #10331f;
  --side-2: #174429;
  --side-ink: #e6f2ea;
  --side-ink-2: #9ec2aa;
  --band0: #2a7fd5;
  --band1: #13a191;
  --band2: #e0a019;
  --band3: #d4402e;
  --band-none: #9aa8a0;
  --ok: #24935a;
  --ok-soft: #e0f3e7;
  --warn: #c27c0e;
  --warn-soft: #fbefd6;
  --danger: #c93a2a;
  --danger-soft: #fbe2de;
  --muted: #7d8a83;
  --muted-soft: #eceff0;
  --focus: #1f74c8;
  --shadow-sm: 0 1px 2px rgba(16, 40, 25, 0.06);
  --shadow: 0 1px 2px rgba(16, 40, 25, 0.05), 0 6px 20px rgba(16, 40, 25, 0.07);
  --shadow-lg: 0 20px 60px rgba(10, 30, 18, 0.25);
  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1611;
    --surface: #142019;
    --surface-2: #18261e;
    --surface-3: #1d2d24;
    --border: #253a2e;
    --border-strong: #335040;
    --ink: #e5efe8;
    --ink-2: #a9bcb0;
    --ink-3: #7b9184;
    --brand: #3fae76;
    --brand-strong: #5cc58e;
    --brand-soft: #193726;
    --accent: #5aa7f0;
    --accent-soft: #15283b;
    --side: #0a2416;
    --side-2: #11331f;
    --ok: #47c07f;
    --ok-soft: #153422;
    --warn: #e8a63a;
    --warn-soft: #3a2c12;
    --danger: #f06a59;
    --danger-soft: #3d1a16;
    --muted: #8a9a91;
    --muted-soft: #1f2b25;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
small, .small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 0.95em; }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------------------------ boot */
.boot { display: grid; place-items: center; height: 100vh; }
.boot-mark { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; color: var(--ink-2); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, var(--side) 0%, #0c2a19 100%); color: var(--side-ink); padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; color: var(--side-ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 36px; height: 36px; }
.brand b { display: block; font-size: 16px; letter-spacing: 0.01em; }
.brand small { color: var(--side-ink-2); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { color: var(--side-ink-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  color: var(--side-ink-2); font-weight: 550; transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: var(--side-ink); text-decoration: none; }
.nav a.active { background: var(--side-2); color: #fff; box-shadow: inset 3px 0 0 #6fd39a; }
.nav .count { margin-left: auto; background: var(--band3); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #2c6b48; color: #e8f7ee; font-weight: 700; font-size: 13px;
}
.me { min-width: 0; flex: 1; }
.me b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me span { color: var(--side-ink-2); font-size: 11.5px; text-transform: capitalize; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 0;
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(127, 140, 130, 0.16); }
.sidebar .icon-btn { color: var(--side-ink-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 500; display: flex; align-items: center; gap: 16px;
  padding: 16px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.mobile-brand { display: none; }
.view { padding: 4px 28px 40px; min-width: 0; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .mobile-brand { display: flex; align-items: center; }
  .mobile-brand img { width: 30px; height: 30px; }
  .view { padding: 4px 16px calc(88px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; z-index: 900; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    background: var(--side); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.15);
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; color: var(--side-ink-2); font-size: 10.5px; font-weight: 600; padding: 4px 0; border-radius: 10px; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: #fff; background: var(--side-2); }
  .tabbar svg.i { width: 21px; height: 21px; }
  h1 { font-size: 19px; }
}

/* ------------------------------------------------------------------ building blocks */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) { .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-head h2 { flex: 1; min-width: 0; }
.card-head .sub { color: var(--ink-3); font-size: 12.5px; flex-basis: 100%; margin-top: -4px; }
.card-body { padding: 16px 18px 18px; }
.card-body.flush { padding: 10px 0 4px; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1250px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.kpi .kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.kpi .kpi-value { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .kpi-note { color: var(--ink-3); font-size: 12px; }
.kpi.tone-ok .kpi-icon { background: var(--ok-soft); color: var(--ok); }
.kpi.tone-water .kpi-icon { background: var(--accent-soft); color: var(--accent); }
.kpi.tone-warn .kpi-icon { background: var(--warn-soft); color: var(--warn); }
.kpi.tone-danger .kpi-icon { background: var(--danger-soft); color: var(--danger); }
.kpi.alarm { border-color: color-mix(in srgb, var(--band3) 45%, var(--border)); background: linear-gradient(160deg, var(--danger-soft), var(--surface) 60%); }
.kpi.alarm .kpi-value { color: var(--danger); }

.greeting { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 18px; }
.greeting h1 { font-size: 24px; }
.greeting p { margin: 4px 0 0; color: var(--ink-3); }

/* ------------------------------------------------------------------ buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn svg.i { width: 16px; height: 16px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field > small { color: var(--ink-3); }
.input, .select, textarea.input {
  width: 100%; height: 38px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font: 14px var(--font); transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.with-icon { padding-left: 34px; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search svg.i { position: absolute; left: 10px; top: 10px; color: var(--ink-3); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.form-section { margin: 18px 0 10px; display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 12px; font-weight: 600; margin-bottom: 12px; }

.segmented { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; color: var(--ink-2); font: 600 12.5px var(--font); height: 30px; padding: 0 11px; border-radius: 8px; cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ pills and chips */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.muted { background: var(--muted-soft); color: var(--muted); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.plain::before { display: none; }
.band { display: inline-flex; align-items: center; gap: 7px; font-weight: 650; white-space: nowrap; }
.band i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.b0 { --c: var(--band0); } .b1 { --c: var(--band1); } .b2 { --c: var(--band2); } .b3 { --c: var(--band3); } .bn { --c: var(--band-none); }
.band i { background: var(--c); }
.band.b3 { color: var(--band3); }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); font-size: 11.5px; font-weight: 650; text-transform: capitalize; }
.chip.role-admin { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------------ tables */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .select { width: auto; min-width: 150px; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.link { cursor: pointer; transition: background 0.12s; }
.table tbody tr.link:hover { background: var(--surface-2); }
.cell-main { font-weight: 650; }
.cell-sub { color: var(--ink-3); font-size: 12.5px; }
.count-note { color: var(--ink-3); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 760px) {
  table.table.cards thead { display: none; }
  table.table.cards, table.table.cards tbody, table.table.cards tr, table.table.cards td { display: block; width: 100%; }
  table.table.cards tr { padding: 12px 14px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
  table.table.cards td { padding: 0; border: 0; }
  table.table.cards td[data-label]::before { content: attr(data-label) " "; color: var(--ink-3); font-size: 11.5px; }
  table.table.cards td.hide-sm { display: none; }
}

/* ------------------------------------------------------------------ lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list a.li-link { display: flex; align-items: center; gap: 12px; color: inherit; flex: 1; min-width: 0; }
.list a.li-link:hover { text-decoration: none; }
.list .li-main { min-width: 0; flex: 1; }
.list .li-title, .list .li-sub { display: block; }
.list .li-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .li-sub { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .li-end { text-align: right; flex: none; color: var(--ink-3); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c, var(--band-none)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--band-none)) 22%, transparent); }
.arrow { color: var(--ink-3); margin: 0 4px; }
.empty { padding: 28px 18px; text-align: center; color: var(--ink-3); }
.empty svg.i { width: 28px; height: 28px; display: block; margin: 0 auto 8px; color: var(--ink-3); }

/* ------------------------------------------------------------------ key-value */
dl.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 9px 16px; margin: 0; }
dl.kv dt { color: var(--ink-3); font-size: 12.5px; }
dl.kv dd { margin: 0; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.kv-section { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); margin: 16px 0 8px; }
.kv-section:first-child { margin-top: 0; }
.stat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border-radius: 11px; padding: 11px 12px; display: flex; gap: 10px; align-items: center; min-width: 0; }
.stat svg.i { color: var(--ink-3); }
.stat b { display: block; font-size: 15px; }
.stat span { color: var(--ink-3); font-size: 12px; }

/* ------------------------------------------------------------------ unit page */
.unit-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin: 4px 0 18px; }
.unit-head .back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.unit-head h1 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.unit-head h1 .mono { font-size: 15px; color: var(--ink-3); font-weight: 600; }
.unit-head .row { margin-top: 8px; }
.gauge-wrap { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; align-items: center; }
@media (max-width: 480px) { .gauge-wrap { grid-template-columns: 120px minmax(0, 1fr); } }
.gauge { width: 100%; height: auto; }
.gauge .soil { fill: #8a6a43; opacity: 0.18; }
.gauge .pipe { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1.5; }
.gauge .water { fill: var(--band0); opacity: 0.35; }
.gauge .water-line { stroke: var(--band0); stroke-width: 2; }
.gauge .ground { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 3; }
.gauge .tick { stroke: var(--ink-3); stroke-width: 1; }
.gauge .lbl { fill: var(--ink-3); font: 600 10px var(--font); }
.gauge .el { stroke: var(--surface); stroke-width: 2; }
.gauge .el.wet { fill: var(--band0); }
.gauge .el.dry { fill: var(--band-none); }
.gauge .com { fill: var(--ink-2); }
.level-big { font-size: 22px; font-weight: 750; letter-spacing: -0.01em; }
.level-big.b3 { color: var(--band3); }
.advice { margin-top: 8px; padding: 9px 11px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); font-size: 13px; }
.advice.alarm { background: var(--danger-soft); color: var(--danger); font-weight: 650; }
.electrodes { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 12.5px; }
.electrodes td { padding: 4px 0; border-top: 1px dashed var(--border); }
.electrodes td:last-child { text-align: right; color: var(--ink-3); }
.faults { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.mini-map { height: 260px; border-radius: 0 0 var(--radius) var(--radius); }
.map-empty { height: 260px; display: grid; place-items: center; text-align: center; color: var(--ink-3); padding: 18px; }

/* ------------------------------------------------------------------ charts */
.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font: 600 10.5px var(--font); }
.chart .stripe { opacity: 0.09; }
.chart .stripe.b0 { fill: var(--band0); } .chart .stripe.b1 { fill: var(--band1); } .chart .stripe.b2 { fill: var(--band2); } .chart .stripe.b3 { fill: var(--band3); opacity: 0.13; }
.chart .level-line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.chart .batt-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; }
.chart .batt-area { fill: var(--brand); opacity: 0.08; }
.chart .low-line { stroke: var(--warn); stroke-dasharray: 5 4; stroke-width: 1.2; }
.chart-title { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 650; color: var(--ink-2); margin: 4px 0 6px; }
.bars .bar-bg { fill: var(--surface-3); }
.bars .bar { fill: var(--c); }
.bars text { fill: var(--ink-2); font: 600 12px var(--font); }
.bars .val { fill: var(--ink); font-weight: 700; }

/* ------------------------------------------------------------------ map */
.map-page { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; height: calc(100vh - 150px); min-height: 460px; }
.map-page .map-card { position: relative; overflow: hidden; }
.map-page #map { position: absolute; inset: 0; }
.map-side { display: flex; flex-direction: column; min-height: 0; }
.map-side .list { overflow-y: auto; }
@media (max-width: 980px) {
  .map-page { grid-template-columns: minmax(0, 1fr); height: auto; }
  .map-page .map-card { height: 62vh; min-height: 380px; }
}
.overview-map { height: 340px; border-radius: 0 0 var(--radius) var(--radius); }
.legend { position: absolute; z-index: 600; left: 12px; bottom: 26px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px; font-size: 12px; display: grid; gap: 5px; }
.legend b { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); }
.legend .band { font-weight: 600; }
.pin-wrap { background: none; border: 0; }
.pin { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3)); overflow: visible; }
.pin .pin-body { fill: var(--c, var(--band-none)); stroke: #fff; stroke-width: 1.6; }
.pin.off .pin-body { fill: #a8b1ac; stroke-dasharray: 3 2; }
.pin .pin-dot { fill: #fff; }
.pin .pin-badge { fill: #f59e0b; stroke: #fff; stroke-width: 1.4; }
.pin .pin-badge-t { fill: #fff; font: 800 9px var(--font); text-anchor: middle; }
.pin.b3 .pin-body { animation: alarm 1.4s ease-in-out infinite; }
@keyframes alarm { 50% { fill: #ff6f5c; } }
@media (prefers-reduced-motion: reduce) { .pin.b3 .pin-body { animation: none; } .boot-mark { animation: none; } }
.leaflet-container { font: 13px var(--font); background: var(--surface-3); }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow-lg); background: var(--surface); color: var(--ink); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 12px 14px; min-width: 210px; }
.pop h3 { font-size: 14px; margin-bottom: 2px; }
.pop .cell-sub { margin-bottom: 8px; }
.pop dl.kv { grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 12.5px; }
.pop .btn { margin-top: 10px; width: 100%; color: #fff; }
.pick-map { height: 230px; border-radius: 10px; border: 1px solid var(--border); margin-top: 6px; }

/* ------------------------------------------------------------------ modal and toasts */
.modal-backdrop { position: fixed; inset: 0; z-index: 2000; background: rgba(8, 22, 14, 0.55); display: grid; place-items: center; padding: 18px; animation: fade 0.15s ease-out; }
.modal { width: min(640px, 100%); max-height: calc(100vh - 36px); display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: rise 0.18s ease-out; }
.modal.wide { width: min(820px, 100%); }
.modal.narrow { width: min(440px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.modal-head h2 { flex: 1; font-size: 17px; }
.modal-body { padding: 10px 20px 4px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
@media (max-width: 620px) { .modal-backdrop { padding: 0; align-items: end; } .modal { border-radius: 18px 18px 0 0; max-height: 92vh; } }
.secret { display: flex; align-items: center; gap: 8px; background: var(--surface-3); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 10px 12px; font: 600 15px var(--mono); word-break: break-all; }
.secret span { flex: 1; }
pre.console { background: #0e1d14; color: #cfe9d8; border-radius: 10px; padding: 12px 14px; font: 13px/1.6 var(--mono); overflow-x: auto; margin: 10px 0 0; }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 9px 12px; font-size: 13px; font-weight: 600; margin-top: 12px; }
.toasts { position: fixed; z-index: 3000; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 11px; box-shadow: var(--shadow-lg); font-weight: 600; display: flex; gap: 8px; align-items: center; animation: rise 0.2s ease-out; max-width: 360px; }
.toast.error { background: var(--danger); color: #fff; }
@media (max-width: 860px) { .toasts { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); } }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.loading-block { height: 120px; }

/* ------------------------------------------------------------------ sign-in */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-hero {
  position: relative; overflow: hidden; color: #eaf6ee; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(120% 90% at 10% 0%, #1f6a43 0%, #10331f 55%, #0a2214 100%);
}
.login-hero .brand { padding: 0; }
.login-hero h1 { font-size: 38px; line-height: 1.12; max-width: 460px; margin-top: 30px; letter-spacing: -0.02em; }
.login-hero p { color: #a9cdb6; max-width: 440px; font-size: 15px; }
.login-hero .facts { display: flex; gap: 26px; flex-wrap: wrap; color: #cde6d6; font-size: 13px; }
.login-hero .facts b { display: block; font-size: 22px; color: #fff; }
.login-hero svg.fields { position: absolute; right: -40px; bottom: -10px; width: 78%; opacity: 0.55; pointer-events: none; }
.login-form-wrap { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: min(380px, 100%); }
.login-card h2 { font-size: 24px; margin-bottom: 4px; }
.login-card p.lead { color: var(--ink-3); margin: 0 0 22px; }
.login-card form { display: grid; gap: 14px; }
.login-card .btn { height: 42px; font-size: 14.5px; }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; right: 2px; top: 2px; color: var(--ink-3); }
.login-foot { margin-top: 26px; color: var(--ink-3); font-size: 12px; text-align: center; }
@media (max-width: 900px) {
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-hero { padding: 28px 22px 26px; min-height: 220px; }
  .login-hero h1 { font-size: 26px; margin-top: 18px; }
  .login-hero .facts, .login-hero p { display: none; }
}

/* ------------------------------------------------------------------ utilities (the CSP forbids inline styles) */
.mt-8 { margin-top: 8px; } .mt-14 { margin-top: 14px; } .mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; }
.full-height { min-height: 100vh; }
.w-520 { width: min(520px, 100%); }
