/* Layout: control-room shell — graphite sidebar + calm work canvas; hairline data cards; brand orange only for interaction and focus. */
:root {
  --bg: #f3f2f0;
  --surface: #ffffff;
  --surface-2: #f8f7f5;
  --surface-3: #efede9;
  --border: #e3e0db;
  --border-strong: #cfcac3;
  --fg: #1d1c1a;
  --fg-2: #57534e;
  --muted: #736e67;
  --accent: #ff6e20;
  --accent-ink: #b8440a;
  --accent-soft: #ffeadc;
  --on-accent: #1d1c1a;
  --side-bg: #1f1e1c;
  --side-fg: #ebe8e3;
  --side-muted: #9d978f;
  --side-hover: #2a2826;
  --side-active: #34302c;
  --side-border: #33302d;
  --grid: #ece9e4;
  --axis: #c9c4bc;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --deemph: #b9b4ad;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --offline: #8f8a83;
  --good-soft: #e5f5e5;
  --warning-soft: #fff3d6;
  --serious-soft: #fdece4;
  --critical-soft: #fbe6e6;
  --offline-soft: #efede9;
  --delta-good: #006300;
  --delta-bad: #b3261e;
  --map-bg: #eceeed;
  --map-block: #e2e4e2;
  --map-road: #ffffff;
  --map-road-edge: #d6d8d6;
  --map-water: #b9d7f2;
  --map-park: #dce9d5;
  --odo-bg: #1d1c1a;
  --odo-fg: #f6f4f0;
  --odo-red: #c9302c;
  --shadow: 0 1px 2px rgba(29, 28, 26, 0.06), 0 8px 24px rgba(29, 28, 26, 0.08);
  --focus: 0 0 0 3px rgba(255, 110, 32, 0.35);
  --font-ui: "Sofia Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-cond: "Sofia Sans Condensed", "Sofia Sans", system-ui, -apple-system, "Segoe UI", Arial Narrow, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --side-w: 248px;
  --top-h: 58px;
  --radius: 10px;
  --radius-sm: 7px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110; --surface: #1b1a19; --surface-2: #211f1e; --surface-3: #2a2826; --border: #302e2b; --border-strong: #45423e;
    --fg: #f0eeea; --fg-2: #bdb8b0; --muted: #8f8a83; --accent: #ff7a33; --accent-ink: #ff9a5c; --accent-soft: #3b2516; --on-accent: #1d1c1a;
    --side-bg: #0b0b0a; --side-fg: #e9e6e1; --side-muted: #8f8a83; --side-hover: #1a1918; --side-active: #262422; --side-border: #1f1e1c;
    --grid: #2a2826; --axis: #45423e; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --deemph: #55524d;
    --seq-1: #0d366b; --seq-2: #104281; --seq-3: #184f95; --seq-4: #1c5cab; --seq-5: #2a78d6; --seq-6: #5598e7; --seq-7: #9ec5f4;
    --good-soft: #13291a; --warning-soft: #33290f; --serious-soft: #35211a; --critical-soft: #3a1918; --offline-soft: #262422;
    --delta-good: #3ec43e; --delta-bad: #f07167;
    --map-bg: #171817; --map-block: #1f201f; --map-road: #2c2d2c; --map-road-edge: #232423; --map-water: #1b3550; --map-park: #1c2a1c;
    --odo-bg: #0b0b0a; --odo-fg: #f6f4f0; --odo-red: #d9443f;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 32px rgba(0,0,0,0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111110; --surface: #1b1a19; --surface-2: #211f1e; --surface-3: #2a2826; --border: #302e2b; --border-strong: #45423e;
  --fg: #f0eeea; --fg-2: #bdb8b0; --muted: #8f8a83; --accent: #ff7a33; --accent-ink: #ff9a5c; --accent-soft: #3b2516; --on-accent: #1d1c1a;
  --side-bg: #0b0b0a; --side-fg: #e9e6e1; --side-muted: #8f8a83; --side-hover: #1a1918; --side-active: #262422; --side-border: #1f1e1c;
  --grid: #2a2826; --axis: #45423e; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --deemph: #55524d;
  --seq-1: #0d366b; --seq-2: #104281; --seq-3: #184f95; --seq-4: #1c5cab; --seq-5: #2a78d6; --seq-6: #5598e7; --seq-7: #9ec5f4;
  --good-soft: #13291a; --warning-soft: #33290f; --serious-soft: #35211a; --critical-soft: #3a1918; --offline-soft: #262422;
  --delta-good: #3ec43e; --delta-bad: #f07167;
  --map-bg: #171817; --map-block: #1f201f; --map-road: #2c2d2c; --map-road-edge: #232423; --map-water: #1b3550; --map-park: #1c2a1c;
  --odo-bg: #0b0b0a; --odo-fg: #f6f4f0; --odo-red: #d9443f;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 32px rgba(0,0,0,0.45);
  color-scheme: dark;
}

html, body, #fw { height: 100%; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
svg { display: block; }
.mono { font-family: var(--font-mono); font-size: 0.86em; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.fg2 { color: var(--fg-2); }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 15px; height: 15px; }
.ico.lg { width: 22px; height: 22px; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100%; }
.side { background: var(--side-bg); color: var(--side-fg); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--side-border); }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.side-brand .mark { height: 34px; width: auto; }
.side-brand .word { height: 34px; width: auto; filter: invert(1) brightness(1.35); }
.side-product { padding: 0 18px 12px; display: flex; align-items: baseline; gap: 8px; color: var(--side-muted); font-size: 12.5px; white-space: nowrap; }
.side-product b { color: var(--accent); font-family: var(--font-cond); font-weight: 800; font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; }
.util { margin: 0 14px 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 10px; background: var(--side-hover); }
.util button { border: 0; background: transparent; color: var(--side-muted); border-radius: 7px; padding: 6px 0 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; cursor: pointer; }
.util button.on { background: var(--side-active); color: var(--side-fg); }
.util button.on .ico { color: var(--accent); }
.util button[aria-disabled="true"] { opacity: 0.55; cursor: help; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.nav-sec { font-family: var(--font-cond); font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--side-muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; color: var(--side-fg); text-decoration: none; padding: 8px 10px; border-radius: 8px; position: relative; font-size: 14.5px; }
.nav a .ico { color: var(--side-muted); }
.nav a:hover { background: var(--side-hover); }
.nav a.on { background: var(--side-active); font-weight: 600; }
.nav a.on::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a.on .ico { color: var(--accent); }
.nav .badge { margin-left: auto; background: var(--critical); color: #fff; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.side-foot { padding: 12px 18px 16px; border-top: 1px solid var(--side-border); font-size: 12px; color: var(--side-muted); }

.mainwrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; height: var(--top-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.topbar .burger { display: none; }
.topbar .tenant { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.topbar .tenant b { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .tenant span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.topbar .grow { flex: 1; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 12px; height: 36px; width: min(320px, 28vw); color: var(--muted); }
.search input { border: 0; background: transparent; outline: none; width: 100%; color: var(--fg); font-size: 14px; }
.demo-badge { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); border-radius: 999px; padding: 4px 10px; white-space: nowrap; cursor: help; }
.proto-pill { font-family: var(--font-cond); font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.tb-btn { height: 36px; min-width: 36px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; cursor: pointer; color: var(--fg-2); position: relative; white-space: nowrap; }
.tb-btn:hover { background: var(--surface-2); color: var(--fg); }
.tb-btn .dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 999px; background: var(--critical); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); }
.lang { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; height: 36px; flex: none; }
.lang button { border: 0; background: transparent; padding: 0 10px; font-weight: 700; font-size: 12.5px; letter-spacing: 0.06em; color: var(--muted); cursor: pointer; }
.lang button.on { background: var(--fg); color: var(--surface); }
.role-btn { height: 36px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); display: inline-flex; align-items: center; gap: 8px; padding: 0 12px 0 6px; cursor: pointer; }
.role-btn .av { width: 26px; height: 26px; border-radius: 50%; background: var(--fg); color: var(--surface); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; }
.role-btn .rl { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.role-btn .rl small { font-size: 11px; color: var(--muted); }
.role-btn .rl b { font-size: 13px; }
.menu { position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 260px; }
.menu .mi { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 8px; cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left; }
.menu .mi:hover { background: var(--surface-2); }
.menu .mi.on { background: var(--accent-soft); }
.menu .mi small { display: block; color: var(--muted); font-size: 12.5px; }
.menu .mi .ico { margin-top: 2px; color: var(--fg-2); }
.menu .mh { font-family: var(--font-cond); font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 4px; font-weight: 700; }

.content { flex: 1; overflow-y: auto; overflow-x: hidden; padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); padding-block: 22px 40px; min-width: 0; }
.page { max-width: 1480px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.ph { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; justify-content: space-between; }
.ph h1 { font-size: 27px; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
.ph .sub { color: var(--fg-2); font-size: 14px; margin-top: 4px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--fg-2); text-decoration: none; cursor: pointer; }
.crumbs a:hover { color: var(--accent-ink); text-decoration: underline; }
.ph-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--fg-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--fg); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn.danger { color: var(--delta-bad); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 13.5px; font-weight: 600; color: var(--fg-2); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.sel { height: 36px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); padding: 0 32px 0 14px; font-size: 14px; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--fg-2) 50%), linear-gradient(135deg, var(--fg-2) 50%, transparent 50%); background-position: calc(100% - 17px) 15px, calc(100% - 12px) 15px; background-size: 5px 5px; background-repeat: no-repeat; max-width: 100%; }
.inp { height: 36px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); padding: 0 12px; font-size: 14px; width: 100%; }
.inp:focus, .sel:focus { outline: none; box-shadow: var(--focus); border-color: var(--accent); }
textarea.inp { height: auto; padding: 10px 12px; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 12.5px; font-weight: 700; color: var(--fg-2); }
.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; font-weight: 600; font-size: 14.5px; color: var(--fg-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs button.on { color: var(--fg); border-bottom-color: var(--accent); }
.tabs button .cnt { font-size: 12px; background: var(--surface-3); border-radius: 999px; padding: 0 7px; color: var(--fg-2); font-variant-numeric: tabular-nums; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; display: flex; flex-direction: column; }
.card-h { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 14px 18px 0; }
.card-h h2, .card-h h3 { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: 0.005em; }
.card-h .hs { color: var(--muted); font-size: 13px; }
.card-h .tools { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-b { padding: 14px 18px 16px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.card-b.flush { padding: 10px 0 4px; }
.card-f { padding: 10px 18px 14px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 13px; color: var(--fg-2); }
.grid { display: grid; gap: 18px; min-width: 0; align-items: start; }
.g2 { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.g2w { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
.g2e { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpis.n6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpis.n5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpis.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* ---------- KPI tile ---------- */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi .klab { font-size: 13px; color: var(--fg-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .kval { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.kpi .kval b { font-size: 29px; line-height: 1.05; font-weight: 800; letter-spacing: -0.01em; }
.kpi .kval span { font-size: 14px; color: var(--fg-2); font-weight: 600; }
.kpi .kfoot { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px 10px; min-height: 26px; flex-wrap: wrap; min-width: 0; }
.delta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0 3px; font-size: 12.5px; font-weight: 700; min-width: 0; }
.delta small { white-space: nowrap; }
.delta.good { color: var(--delta-good); }
.delta.bad { color: var(--delta-bad); }
.delta.neu { color: var(--fg-2); }
.delta small { font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Status chips ---------- */
.st { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 6px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--offline-soft); color: var(--fg); line-height: 1.5; }
.st .ico { width: 14px; height: 14px; stroke-width: 2.2; }
.st.good { background: var(--good-soft); } .st.good .ico { color: var(--good); }
.st.warning { background: var(--warning-soft); } .st.warning .ico { color: #c98500; }
.st.serious { background: var(--serious-soft); } .st.serious .ico { color: var(--serious); }
.st.critical { background: var(--critical-soft); } .st.critical .ico { color: var(--critical); }
.st.offline .ico { color: var(--offline); }
.st.info { background: var(--surface-3); } .st.info .ico { color: var(--s1); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px; font-size: 12.5px; font-weight: 600; background: var(--surface-3); color: var(--fg-2); white-space: nowrap; }
.tag.src-dev { background: transparent; border: 1px solid var(--border-strong); }
.flag { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border); font-size: 13.5px; font-weight: 600; }
.flag.on { border-color: transparent; }
.flag.on.critical { background: var(--critical-soft); }
.flag.on.warning { background: var(--warning-soft); }
.flag .ico { color: var(--good); }
.flag.on.critical .ico { color: var(--critical); }
.flag.on.warning .ico { color: #c98500; }
.flag small { font-weight: 500; color: var(--muted); }
.sdot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.sdot.good { background: var(--good); } .sdot.warning { background: var(--warning); } .sdot.serious { background: var(--serious); } .sdot.critical { background: var(--critical); } .sdot.offline { background: var(--offline); }

/* ---------- Tables ---------- */
.tw { overflow-x: auto; min-width: 0; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-family: var(--font-cond); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t td.r, .t th.r { text-align: right; }
.t td.c, .t th.c { text-align: center; }
.t td.num, .t .num { font-variant-numeric: tabular-nums; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: var(--surface-2); }
.t tbody tr.sel td { background: var(--accent-soft); }
.t .sub { display: block; color: var(--muted); font-size: 12.5px; }
.t th:first-child, .t td:first-child { padding-left: 18px; }
.t th:last-child, .t td:last-child { padding-right: 18px; }
.t .grp th { background: var(--surface); text-align: center; border-bottom: 0; padding-bottom: 0; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 18px 12px; font-size: 13px; color: var(--fg-2); border-top: 1px solid var(--border); }
.bar-m { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.bar-m .trk { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.bar-m .fil { height: 100%; border-radius: 999px; }
.batt { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.batt i { width: 22px; height: 11px; border: 1.5px solid var(--fg-2); border-radius: 3px; position: relative; display: inline-block; }
.batt i::after { content: ""; position: absolute; right: -4px; top: 2.5px; width: 2px; height: 4px; background: var(--fg-2); border-radius: 0 1px 1px 0; }
.batt i b { position: absolute; left: 1.5px; top: 1.5px; bottom: 1.5px; border-radius: 1px; }
.sig { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.sig i { width: 3px; border-radius: 1px; background: var(--border-strong); display: inline-block; }
.sig i.on { background: var(--fg-2); }
.dchip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 6px; font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; min-width: 0; }
.chart svg text { fill: var(--muted); font-family: var(--font-ui); font-size: 11.5px; }
.chart svg .tl { fill: var(--fg-2); font-weight: 600; }
.chart svg .ttl { fill: var(--fg); font-weight: 700; font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--fg-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; flex: none; }
.legend i.ln { width: 16px; height: 2.5px; border-radius: 2px; }
.legend i.bx { width: 10px; height: 10px; border-radius: 3px; }
.legend i.dash { width: 16px; height: 0; border-top: 1.5px dashed var(--fg-2); }
.tip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 9px 11px; font-size: 13px; min-width: 150px; max-width: 280px; }
.tip .th { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.tip .tr { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .tr .k { display: flex; align-items: center; gap: 6px; color: var(--fg-2); font-size: 12.5px; }
.tip .tr .k i { width: 12px; height: 2.5px; border-radius: 2px; display: inline-block; }
.tip .tr b { font-variant-numeric: tabular-nums; font-size: 13.5px; }
.cvt { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.cvt button { border: 0; background: transparent; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.cvt button.on { background: var(--surface-3); color: var(--fg); }
.ctable { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.ctable table.t { font-size: 13px; }
.ctable .t th:first-child, .ctable .t td:first-child { padding-left: 12px; }
.spark { display: inline-block; vertical-align: middle; }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.heat-legend .ramp { display: flex; height: 8px; border-radius: 4px; overflow: hidden; width: 140px; }
.heat-legend .ramp i { flex: 1; }

/* ---------- Domain components ---------- */
.odo { display: inline-flex; align-items: stretch; gap: 3px; font-family: var(--font-mono); font-weight: 600; }
.odo i { font-style: normal; background: var(--odo-bg); color: var(--odo-fg); width: 1.15em; text-align: center; border-radius: 4px; padding: 0.12em 0; box-shadow: inset 0 -0.35em 0.5em rgba(255,255,255,0.06), inset 0 0.3em 0.4em rgba(0,0,0,0.5); }
.odo i.red { background: var(--odo-red); }
.odo .sepc { width: auto; background: transparent; box-shadow: none; color: var(--fg-2); padding: 0 1px; }
.odo .u { align-self: flex-end; font-family: var(--font-ui); font-weight: 700; color: var(--fg-2); margin-left: 6px; font-size: 0.6em; }
.odo.big { font-size: 34px; }
.odo.md { font-size: 22px; }
.odo.sm { font-size: 15px; gap: 2px; }
.meterface { display: flex; flex-direction: column; gap: 6px; }
.meterface .cap { font-size: 12.5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 7px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.formula { font-family: var(--font-mono); font-size: 13px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 10px 12px; line-height: 1.6; color: var(--fg-2); overflow-x: auto; }
.formula b { color: var(--fg); font-weight: 600; }
.balance-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface); }
.balance-bar > div { display: flex; align-items: center; padding: 0 8px; font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; min-width: 0; }
.bigstat { display: flex; flex-direction: column; gap: 2px; }
.bigstat .l { font-size: 13px; color: var(--fg-2); font-weight: 600; }
.bigstat .v { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.1; }
.bigstat .v small { font-size: 14px; color: var(--fg-2); font-weight: 600; margin-left: 4px; }
.eq { display: grid; grid-template-columns: repeat(5, auto); align-items: center; gap: 10px 16px; justify-content: start; }
.eq .op { font-size: 22px; color: var(--muted); font-weight: 300; }

/* alarms */
.alist { display: flex; flex-direction: column; }
.ai { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 0 12px; padding: 11px 18px 11px 0; border-bottom: 1px solid var(--border); cursor: pointer; align-items: start; }
.ai:last-child { border-bottom: 0; }
.ai:hover { background: var(--surface-2); }
.ai .stripe { width: 4px; align-self: stretch; border-radius: 0 3px 3px 0; }
.ai .stripe.critical { background: var(--critical); } .ai .stripe.warning { background: var(--warning); } .ai .stripe.serious { background: var(--serious); } .ai .stripe.info { background: var(--s1); }
.ai .stripe.offline { background: var(--offline); } .ai .stripe.good { background: var(--good); }
.ai .at { font-weight: 700; font-size: 14px; }
.ai .am { color: var(--fg-2); font-size: 13px; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ai .aw { text-align: right; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* tree */
.tree { font-size: 14px; display: flex; flex-direction: column; padding: 6px 6px 10px; max-height: 70vh; overflow: auto; position: relative; }
.tn { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 7px; cursor: pointer; min-width: 0; border: 0; background: transparent; text-align: left; width: 100%; }
.tn:hover { background: var(--surface-2); }
.tn.on { background: var(--accent-soft); font-weight: 700; }
.tn .tw2 { width: 16px; flex: none; color: var(--muted); display: grid; place-items: center; }
.tn .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn .ico { color: var(--fg-2); }
.tn .lv { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* map */
.mapwrap { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--map-bg); border: 1px solid var(--border); touch-action: none; }
.map-ctl { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 6px; }
.map-ctl button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: grid; place-items: center; color: var(--fg-2); }
.map-legend { position: absolute; left: 12px; bottom: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; max-width: calc(100% - 24px); }
.map-legend .row { gap: 6px 12px; }
.map-legend .row > span { white-space: nowrap; }
.map-panel { position: absolute; top: 12px; left: 12px; width: min(320px, calc(100% - 70px)); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.mk { cursor: pointer; }
.mk:hover { filter: brightness(1.1); }
.layers { display: flex; flex-wrap: wrap; gap: 6px; }
.layers label { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; cursor: pointer; background: var(--surface); }
.layers label:has(input:checked) { border-color: var(--fg-2); background: var(--surface-2); }
.layers input { accent-color: var(--accent); }

/* tank */
.tankbox { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 18px; align-items: center; }

/* drawer, toast */
.scrim { position: fixed; inset: 0; background: rgba(15, 14, 13, 0.38); z-index: 70; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); z-index: 80; box-shadow: var(--shadow); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px); }
.drawer-h { display: flex; align-items: flex-start; gap: 10px; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.drawer-h h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.drawer-b { flex: 1; overflow-y: auto; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.drawer-f { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.drawer.wide { width: min(880px, 100%); }
.drawer.wide .drawer-b > * { flex-shrink: 0; }  /* tables keep their height; the drawer body scrolls */
/* Excel import report (73-import.js): collapsible error / warning tables */
.imp-issues > summary { cursor: pointer; padding: 6px 0; font-size: 14px; }
.imp-issues .t td { vertical-align: top; }
.toast { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--surface); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 120; box-shadow: var(--shadow); display: flex; gap: 8px; align-items: center; max-width: calc(100% - 32px); }
.timeline { display: flex; flex-direction: column; gap: 0; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline .ev { position: relative; padding: 0 0 14px 16px; font-size: 13.5px; }
.timeline .ev::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--fg-2); }
.timeline .ev.on::before { border-color: var(--accent); background: var(--accent); }
.timeline .ev small { display: block; color: var(--muted); }
.note { font-size: 13px; color: var(--fg-2); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; display: flex; gap: 8px; align-items: flex-start; }
.note .ico { color: var(--s1); margin-top: 1px; }
.note.warn .ico { color: #c98500; }
.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 14px; }

/* screens index */
.idx { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.idx a { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--fg); cursor: pointer; }
.idx a:hover { border-color: var(--accent); }
.idx a small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.idx a .ico { color: var(--accent-ink); margin-top: 2px; }
.cmp td:first-child { font-weight: 600; }

/* consumer */
.cons-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.big-ok { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 10px; background: var(--critical-soft); }
.big-ok .ico { color: var(--critical); width: 24px; height: 24px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }

/* sectors */
.sectors { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.sectors div { border: 1px solid var(--border); border-radius: 8px; padding: 8px; text-align: center; font-size: 12.5px; }
.sectors b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }

/* type cards */
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tc { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; background: var(--surface); text-align: left; }
.tc:hover { border-color: var(--border-strong); }
.tc.on { border-color: var(--accent); box-shadow: var(--focus); }
.tc .row b { font-size: 15px; }
.tc > .tag { align-self: flex-start; }
.chs { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------- AI reports ---------- */
.tb-btn.ai-tb { color: var(--accent-ink); font-weight: 700; font-size: 13px; }
.tb-btn.ai-tb.on { border-color: var(--accent); background: var(--accent-soft); }
.selbar { flex-direction: row; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; border-color: var(--accent); }
.ai-wrap { display: flex; flex-direction: column; gap: 18px; width: 100%; max-width: 1240px; margin: 0 auto; min-width: 0; }
.ai-thread { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.ai-ex { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.ai-ex button { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--fg); line-height: 1.35; }
.ai-ex button:hover { border-color: var(--accent); }
.ai-ex button .ico { color: var(--accent-ink); margin-top: 1px; }
.ai-ex button b { font-weight: 600; }
.ai-ex small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.ai-m { display: flex; gap: 12px; min-width: 0; }
.ai-m.user { justify-content: flex-end; }
.ai-bubble { background: var(--surface-3); border-radius: 16px 16px 4px 16px; padding: 10px 14px; max-width: min(760px, 88%); font-size: 14.5px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ai-utext { white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-av { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; flex: none; margin-top: 1px; }
.ai-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.ai-meta { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.ai-txt { font-size: 14.5px; line-height: 1.5; max-width: 860px; overflow-wrap: anywhere; }
.ai-txt:empty { display: none; }
.ai-txt p { margin: 0 0 6px; }
.ai-txt p:last-child { margin-bottom: 0; }
.ai-txt ul, .ai-txt ol { margin: 0 0 6px; padding-left: 20px; display: flex; flex-direction: column; gap: 3px; }
.ai-txt code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-3); border-radius: 4px; padding: 0 4px; }
.ai-think { display: inline-flex; gap: 8px; align-items: center; color: var(--fg-2); font-size: 14px; }
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); display: inline-block; animation: aiDot 1.2s infinite ease-in-out; }
.ai-dots i:nth-child(2) { animation-delay: .15s; } .ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes aiDot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ai-step { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }
.ai-step.err { color: var(--delta-bad); }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--fg); display: inline-flex; gap: 4px; align-items: center; }
.ai-chip:hover { border-color: var(--accent); }
.ai-rep { min-width: 0; }
.ai-rep .card-b { padding-bottom: 10px; }
.ai-rep .card-f { align-items: flex-start; }
.ai-rid { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); border-radius: 5px; padding: 1px 6px; margin-right: 8px; vertical-align: 2px; }
.ai-ints { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-int { display: inline-flex; gap: 5px; align-items: baseline; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; color: var(--muted); }
.ai-int b { color: var(--fg); font-weight: 600; }
.ai-t td { vertical-align: top; }
.ai-t td.num, .ai-t td.r { white-space: nowrap; }
.ai-t .ai-sub { min-width: 230px; }
.ai-t .ai-sub > b { white-space: nowrap; }
.content.ai-scr { padding-bottom: 0; }
.content.ai-scr .page { padding-bottom: 10px; }
dl.kv { margin: 0; }
.ai-t .bar-m { min-width: 130px; }
.ai-t tfoot td { border-top: 1px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
.ai-more { padding: 10px 18px 4px; }
.ai-api { font-size: 13px; color: var(--fg-2); min-width: 0; max-width: 100%; }
.ai-api summary { cursor: pointer; font-weight: 600; }
.ai-api pre { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }
.ai-composer { position: sticky; bottom: 0; z-index: 6; padding: 14px 0 max(8px, env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, transparent, var(--bg) 16px); }
.ai-cbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ai-ctx { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--fg); border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12.5px; font-weight: 600; align-self: flex-start; }
.ai-bubble .ai-ctx { padding-right: 10px; }
.ai-ctx button { border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--fg-2); padding: 2px; border-radius: 50%; }
.ai-ctx button:hover { background: var(--surface); }
.ai-box { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; padding: 7px 7px 7px 16px; display: flex; gap: 8px; align-items: flex-end; box-shadow: var(--shadow); }
.ai-box:focus-within { border-color: var(--accent); box-shadow: var(--focus), var(--shadow); }
.ai-box textarea { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; resize: none; min-height: 24px; max-height: 180px; padding: 7px 0; line-height: 1.45; font-size: 15px; color: var(--fg); }
.ai-box textarea:focus-visible { box-shadow: none; }
.ai-send { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; cursor: pointer; flex: none; }
.ai-send:hover { filter: brightness(1.05); }
.ai-send.stop { background: var(--fg); color: var(--surface); }
.ai-send .ico { stroke-width: 2.2; }
.ai-foot { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); padding: 7px 4px 0; }
.ai-tier button { font-size: 12px; padding: 3px 10px; }
@media (max-width: 560px) {
  .tb-btn.ai-tb { display: none; }
  .demo-badge .t { display: none; }
  .ai-bubble { max-width: 92%; }
  .ai-av { display: none; }
  .ai-m { gap: 0; }
}

/* ---------- Data states, dialogs ---------- */
.skel { border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: skel 1.4s ease infinite; }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.loading { display: flex; flex-direction: column; gap: 10px; padding: 14px 18px; min-width: 0; }
.card-b > .loading, .drawer-b > .loading { padding: 0; }
.state { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 14px; min-width: 0; }
.state > div { min-width: 0; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.state.err { background: var(--critical-soft); }
.state.err > .ico { color: var(--critical); margin-top: 2px; }
.state .btn { margin-top: 6px; }
.card > .state, .card-b.flush > .state { margin: 12px 18px; }
.toast.bad { background: var(--critical); color: #fff; }
.dialog { position: fixed; z-index: 100; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.dialog-f { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.secret { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.secret code { font-family: var(--font-mono); font-size: 13.5px; overflow-wrap: anywhere; flex: 1; min-width: 0; user-select: all; }
.btn.danger-fill { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn.danger-fill:hover { filter: brightness(1.05); background: var(--critical); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; min-width: 0; }
.ro-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; min-width: 0; }
.inp.ro { background: var(--surface-2); color: var(--fg-2); }
.inp.sm, .sel.sm { height: 30px; font-size: 13px; }
.sel.sm { padding: 0 28px 0 11px; background-position: calc(100% - 15px) 12px, calc(100% - 10px) 12px; }
.custom-per .inp { width: auto; min-width: 0; max-width: 150px; }
.flag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tenant-pick { display: block; min-width: 0; }
.tenant-pick .sel { max-width: 260px; font-weight: 700; height: 30px; }

/* ---------- Overview tiles, logs ---------- */
.mnf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; min-width: 0; }
.mnf-tile { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; min-width: 0; overflow: hidden; }
.mnf-tile:hover { border-color: var(--border-strong); background: var(--surface-2); }
.mnf-tile svg { max-width: 100%; }
.t tbody tr.fresh td { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: transparent; } }
.ai.on { background: var(--accent-soft); }
.notif.unread .at { color: var(--fg); }
.notif .at .ico, .ai .at .ico { display: inline-block; vertical-align: -3px; }

/* ---------- Map (Leaflet) ---------- */
.mapwrap { isolation: isolate; }
#bigmap { height: calc(100vh - 250px); min-height: 440px; }
.mapwrap.mini { height: 250px; cursor: pointer; touch-action: auto; }
.lmap-slot { position: absolute; inset: 0; }
.lmap { position: absolute; inset: 0; background: var(--map-bg); font-family: var(--font-ui); z-index: 0; }
.lmap.mini { pointer-events: none; }
.map-load { padding: 20px; }
.map-ctl, .map-legend, .map-panel { z-index: 1001; }
.lmap .leaflet-control-attribution { font-size: 10.5px; background: rgba(255, 255, 255, 0.8); color: #333; }
.lmap .leaflet-control-attribution a { color: #0b57d0; }
.zpoly { stroke-linejoin: round; }
.zpoly.good { stroke: var(--good); fill: var(--good); }
.zpoly.warning { stroke: var(--warning); fill: var(--warning); }
.zpoly.serious { stroke: var(--serious); fill: var(--serious); }
.zpoly.critical { stroke: var(--critical); fill: var(--critical); }
.zpoly.info { stroke: var(--offline); fill: var(--offline); }
.zpoly.on { stroke: var(--fg); }
.bs-cov { stroke: var(--s1); fill: var(--s1); }
.bs-ray { stroke: var(--s1); stroke-opacity: 0.45; }
.mk { background: transparent; border: 0; }
.mk-sp { display: block; width: 14px; height: 14px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px rgba(0,0,0,0.35); background: var(--good); }
.mk-sp.bldg { border-radius: 3px; }
.mk-sp.house { border-radius: 50%; }
.mk-sp.site { transform: rotate(45deg) scale(0.86); border-radius: 2px; }
.mk-sp.late { background: var(--warning); } .mk-sp.offline { background: var(--offline); } .mk-sp.alarm { background: var(--critical); }
.mk-sp.on { box-shadow: 0 0 0 3px var(--accent); }
.mk-sp.lg { width: 12px; height: 12px; display: inline-block; }
.mk-wm { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 999px; background: var(--surface); color: var(--fg); border: 1.5px solid var(--fg-2); font: 700 11px/1 var(--font-ui); font-style: normal; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.mk-wm.warn { border-color: var(--warning); } .mk-wm.bad { border-color: var(--critical); color: var(--critical); }
.mk-wm.on { box-shadow: 0 0 0 3px var(--accent); }
.mk-dev path, .mk-dev circle { fill: var(--surface); stroke: var(--good); stroke-width: 2; }
.mk-dev text { fill: var(--fg); font: 800 10px var(--font-ui); }
.mk-dev.late path, .mk-dev.late circle { stroke: var(--warning); }
.mk-dev.offline path, .mk-dev.offline circle { stroke: var(--offline); }
.mk-dev.alarm path, .mk-dev.alarm circle, .mk-dev.warnc path, .mk-dev.warnc circle { stroke: var(--critical); }
.mk-dev.on path, .mk-dev.on circle { stroke: var(--accent); stroke-width: 3; }
.mk-tank rect { fill: var(--surface); stroke: var(--s1); stroke-width: 2; }
.mk-tank .lvl { fill: var(--s1); stroke: none; opacity: 0.75; }
.mk-tank.warnc rect:first-child { stroke: var(--warning); }
.mk-tank.on rect:first-child { stroke: var(--accent); stroke-width: 3; }
.mk-bs circle { fill: var(--surface); stroke: var(--s1); stroke-width: 1.8; }
.mk-bs path { fill: none; stroke: var(--s1); stroke-width: 1.4; }
.mk-bs.on circle { stroke: var(--accent); stroke-width: 3; }
.mk-hot { display: block; width: 16px; height: 16px; border-radius: 50%; background: var(--critical); border: 2px solid var(--surface); box-shadow: 0 0 0 4px rgba(208, 59, 59, 0.25); }
.mk-hot.warning, .mk-hot.serious { background: var(--serious); box-shadow: 0 0 0 4px rgba(236, 131, 90, 0.25); }
.mk-label { background: transparent; border: 0; width: 0 !important; height: 0 !important; overflow: visible; pointer-events: none; }
.mk-label b, .mk-label span { display: block; width: max-content; transform: translateX(-50%); white-space: nowrap; text-align: center; }
.mk-label b { margin-top: -17px; font-weight: 800; font-size: 13px; color: var(--fg); text-shadow: 0 0 3px var(--map-bg), 0 0 3px var(--map-bg), 0 0 6px var(--map-bg); }
.mk-label span { font-size: 11.5px; color: var(--fg-2); text-shadow: 0 0 3px var(--map-bg), 0 0 3px var(--map-bg); }
.mk-label span.sm { margin-top: 14px; font-size: 11px; }
.leaflet-tooltip.mk-tip { background: var(--surface); color: var(--fg); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); font: 600 12.5px var(--font-ui); padding: 4px 8px; }
.leaflet-tooltip-top.mk-tip::before { border-top-color: var(--surface); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lmap .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); }
  :root:not([data-theme="light"]) .lmap .leaflet-control-attribution { background: rgba(27, 26, 25, 0.85); color: #bdb8b0; }
  :root:not([data-theme="light"]) .lmap .leaflet-control-attribution a { color: #9ec5f4; }
  :root:not([data-theme="light"]) .login-brand .word { filter: invert(1) brightness(1.35); }
}
:root[data-theme="dark"] .lmap .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); }
:root[data-theme="dark"] .lmap .leaflet-control-attribution { background: rgba(27, 26, 25, 0.85); color: #bdb8b0; }
:root[data-theme="dark"] .lmap .leaflet-control-attribution a { color: #9ec5f4; }
:root[data-theme="dark"] .login-brand .word { filter: invert(1) brightness(1.35); }

/* ---------- Sign-in ---------- */
.login-wrap { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 16px 24px; gap: 14px; position: relative; }
.login-tools { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; }
.login-card { width: min(420px, 100%); padding: 26px 26px 22px; gap: 14px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 21px; margin: 2px 0 0; line-height: 1.2; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand .mark { height: 36px; width: auto; }
.login-brand .word { height: 30px; width: auto; }
.login-product { color: var(--accent-ink); font-family: var(--font-cond); font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; font-size: 13px; margin-top: -6px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-btn { justify-content: center; height: 40px; font-size: 15px; }
.login-foot { color: var(--muted); font-size: 12.5px; text-align: center; margin: 0; max-width: 420px; }
.boot { display: grid; place-items: center; }
.boot .mark { height: 52px; width: auto; animation: bootPulse 1.4s ease-in-out infinite; }
@keyframes bootPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 1360px) {
  .kpis.n6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1280px) {
  .g2, .g2w { grid-template-columns: minmax(0, 1fr); }
  .topbar .search { width: 200px; }
}
@media (max-width: 1100px) {
  .kpis.n4, .kpis.n5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .tree { max-height: 320px; }
  .topbar .search { display: none; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 90; transform: translateX(-102%); transition: transform .2s ease; padding-left: env(safe-area-inset-left, 0px); padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .topbar .burger { display: inline-flex; }
  .topbar { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); gap: 8px; }
  .proto-pill { display: none; }
  .content { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px 32px; }
  .g2e, .g3 { grid-template-columns: minmax(0, 1fr); }
  .cons-hero { grid-template-columns: minmax(0, 1fr); }
  .tankbox { grid-template-columns: minmax(0, 1fr); }
  .sectors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .ph h1 { font-size: 23px; }
  .role-btn .rl { display: none; }
  .role-btn { padding: 0 6px; }
  .topbar .tenant span { display: none; }
  .kpis, .kpis.n6, .kpis.n4, .kpis.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis.n3, .kpis.n5 { grid-template-columns: minmax(0, 1fr); }
  .kpi { padding: 12px; }
  .kpi .kval b { font-size: 23px; }
  .card-h { padding: 12px 14px 0; }
  .card-b { padding: 12px 14px 14px; }
  .t th:first-child, .t td:first-child { padding-left: 14px; }
  .t th:last-child, .t td:last-child { padding-right: 14px; }
  .odo.big { font-size: 26px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .eq { grid-template-columns: minmax(0, 1fr); }
  .eq .op { display: none; }
  .lang button { padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media (max-width: 900px) {
  #bigmap { height: calc(100vh - 230px); min-height: 380px; }
  .tenant-pick .sel { max-width: 170px; }
}
@media (max-width: 560px) {
  #bigmap { min-height: 340px; }
  .mapwrap.mini { height: 210px; }
  .login-card { padding: 20px 18px 18px; }
  .custom-per .inp { max-width: 132px; }
  .tenant-pick .sel { max-width: 140px; }
}
