/* =====================================================================
   Техникийн өрөөний нэгдсэн хяналт — Demo · Design system
   Light / Dark themes · compact enterprise density (13px base)
   ===================================================================== */

:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;

  --r: 10px; --r-sm: 7px; --r-lg: 14px;
  --sb-w: 228px; --sb-w-c: 64px; --tb-h: 54px;

  /* surfaces & ink (light) */
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef1f5;
  --border: #e3e7ed;
  --border-2: #d4dae3;
  --grid: #ebeef2;
  --axis: #c2c9d3;
  --text: #172030;
  --text-2: #5a6474;
  --text-3: #8a93a2;

  --primary: #2370cd;
  --primary-2: #1757ac;
  --primary-ink: #1b64be;
  --primary-soft: #e9f1fc;

  /* status (reserved) */
  --good: #0aac23;     --good-ink: #067a18;    --good-soft: #e5f6e8;
  --warn: #fbb315;     --warn-ink: #855600;    --warn-soft: #fff4d8;
  --serious: #f18a59;  --serious-ink: #ad4515; --serious-soft: #fdeee5;
  --crit: #dc3c3d;     --crit-ink: #b42324;    --crit-soft: #fdeaea;
  --info: #2370cd;     --info-ink: #1b64be;    --info-soft: #e9f1fc;
  --off: #9aa3b1;      --off-ink: #5a6474;     --off-soft: #eef1f5;

  /* categorical series (validated) */
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
  --s5: #ee7fac; --s6: #008a17; --s7: #6a4ce2; --s8: #ec4647;
  --area: rgba(37, 125, 224, .10);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 3px 8px rgba(16, 24, 40, .05);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .16), 0 2px 8px rgba(16, 24, 40, .06);

  --sb-bg: #0f1724;
  --sb-bg-2: #172133;
  --sb-border: #1e293b;
  --sb-text: #c2cad7;
  --sb-text-2: #7f8a9d;

  --land: #e8edf4;
  --land-stroke: #b5c1d1;
  --water: #cfe1f4;
  --map-bg: #f8fafc;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1b222b;
  --surface-3: #232b36;
  --border: #29323e;
  --border-2: #343e4c;
  --grid: #242c37;
  --axis: #3f4958;
  --text: #e6ebf1;
  --text-2: #9ba6b5;
  --text-3: #6f7a8a;

  --primary: #338ced;
  --primary-2: #519ced;
  --primary-ink: #7cb6f3;
  --primary-soft: rgba(51, 140, 237, .15);

  --good-ink: #5fcf62;    --good-soft: rgba(10, 172, 35, .15);
  --warn-ink: #fcc94f;    --warn-soft: rgba(251, 179, 21, .14);
  --serious-ink: #f6a57f; --serious-soft: rgba(241, 138, 89, .15);
  --crit-ink: #f27c7d;    --crit-soft: rgba(220, 60, 61, .17);
  --info: #338ced; --info-ink: #7cb6f3; --info-soft: rgba(51, 140, 237, .15);
  --off: #6f7a8a; --off-ink: #9ba6b5; --off-soft: rgba(111, 122, 138, .17);

  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
  --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
  --area: rgba(51, 140, 237, .12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 8px rgba(0, 0, 0, .25);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);

  --sb-bg: #0a0e15;
  --sb-bg-2: #121926;
  --sb-border: #1a2231;

  --land: #1b232e;
  --land-stroke: #3a4656;
  --water: #1b324c;
  --map-bg: #11161d;

  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
.i { flex: none; display: inline-block; vertical-align: middle; }
.mono { font-family: var(--mono); font-size: .94em; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.row.gap4 { gap: 4px; } .row.gap12 { gap: 12px; } .row.gap16 { gap: 16px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.right { margin-left: auto; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--primary-soft); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- app shell ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sb-w);
  background: var(--sb-bg); color: var(--sb-text);
  display: flex; flex-direction: column; z-index: 30;
  border-right: 1px solid var(--sb-border);
  transition: width .18s ease;
}
.sb-brand { height: var(--tb-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--sb-border); flex: none; }
.sb-logo { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, #3a8af0 0%, #1d56b3 100%); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.sb-name { min-width: 0; overflow: hidden; }
.sb-title { color: #fff; font-weight: 600; font-size: 13px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-sub { color: var(--sb-text-2); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 10px 12px; }
.sb-group { margin: 16px 8px 6px; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--sb-text-2); font-weight: 600; white-space: nowrap; }
.sb-link { position: relative; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; margin: 1px 0;
  border-radius: 8px; color: var(--sb-text); font-size: 13px; white-space: nowrap; cursor: pointer; text-decoration: none; }
.sb-link:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.sb-link.active { background: rgba(51,140,237,.17); color: #fff; }
.sb-link.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #4c9bf0; }
.sb-link .i { opacity: .9; }
.sb-link .cnt { margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; font-size: 11px; font-weight: 600;
  display: inline-grid; place-items: center; background: rgba(255,255,255,.08); color: var(--sb-text); }
.sb-link .cnt.hot { background: var(--crit); color: #fff; }
.sb-foot { flex: none; border-top: 1px solid var(--sb-border); padding: 12px 14px; font-size: 11.5px; color: var(--sb-text-2); }
.sb-foot .row { gap: 8px; }
.sb-health { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin-top: 8px; }
.sb-health span:nth-child(even) { color: var(--sb-text); text-align: right; }

body.sb-collapsed .sidebar { width: var(--sb-w-c); }
body.sb-collapsed .sb-name, body.sb-collapsed .sb-group, body.sb-collapsed .sb-link span,
body.sb-collapsed .sb-link .cnt, body.sb-collapsed .sb-foot .hide-c { display: none; }
body.sb-collapsed .sb-link { justify-content: center; padding: 0; }
body.sb-collapsed .sb-brand { justify-content: center; padding: 0; }
body.sb-collapsed .sb-group-sep { display: block; height: 1px; background: var(--sb-border); margin: 10px 6px; }
.sb-group-sep { display: none; }

.main { margin-left: var(--sb-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .18s ease; }
body.sb-collapsed .main { margin-left: var(--sb-w-c); }

.topbar { position: sticky; top: 0; z-index: 25; height: var(--tb-h); flex: none;
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border); }
.tb-title { display: flex; flex-direction: column; min-width: 0; flex-shrink: 1; overflow: hidden; }
.tb-title h1 { font-size: 15px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-crumb { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-search { position: relative; width: 280px; margin-left: 12px; flex-shrink: 0; }
.tb-search .input { width: 100%; padding-left: 32px; padding-right: 34px; background: var(--surface-2); }
.tb-search > .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.tb-search .kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.live { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; border-radius: 999px;
  background: var(--good-soft); color: var(--good-ink); font-size: 12px; font-weight: 600; white-space: nowrap; }
.live .dot { background: var(--good); box-shadow: 0 0 0 0 rgba(10,172,35,.5); animation: livePulse 2s infinite; }
.live.paused { background: var(--off-soft); color: var(--off-ink); }
.live.paused .dot { background: var(--off); animation: none; }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(10,172,35,.45); } 70% { box-shadow: 0 0 0 7px rgba(10,172,35,0); } 100% { box-shadow: 0 0 0 0 rgba(10,172,35,0); } }
.clock { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text-2); padding: 0 4px; white-space: nowrap; }
.clock b { color: var(--text); font-weight: 600; }
.demo-badge { height: 22px; padding: 0 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  display: inline-grid; place-items: center; color: var(--warn-ink); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); }
.bell { position: relative; }
.bell .cnt { position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--crit); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.user { display: flex; align-items: center; gap: 8px; padding-left: 8px; margin-left: 4px; border-left: 1px solid var(--border); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; color: #fff; flex: none;
  background: linear-gradient(140deg, #4a90e2, #2b5fb8); }
.user-n { font-size: 12.5px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.user-r { font-size: 11px; color: var(--text-3); line-height: 1.2; white-space: nowrap; }

.content { flex: 1; padding: 20px 24px 32px; min-width: 0; }
.page { display: flex; flex-direction: column; gap: 16px; animation: pageIn .22s ease-out; }
@keyframes pageIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 18px; line-height: 1.25; letter-spacing: -.005em; }
.page-head .sub { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- grid ---------- */
.grid { display: grid; gap: 16px; }
.g12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; } .span-12 { grid-column: span 12; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.k5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1500px) {
  .tb-search { width: 210px; flex-shrink: 0; }
  .user-meta { display: none; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .md-span-6 { grid-column: span 6; } .md-span-12 { grid-column: span 12; }
}
@media (max-width: 1180px) {
  .span-3, .span-4, .span-5 { grid-column: span 6; }
  .span-7, .span-8, .span-9, .md-span-6 { grid-column: span 12; }
  .kpis.k4, .kpis.k5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb-search { width: 200px; }
  .user-meta { display: none; }
}

/* ---------- card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 11px 16px; min-height: 46px; border-bottom: 1px solid var(--border); flex: none; }
.card-h.nb { border-bottom: 0; padding-bottom: 4px; }
.card-t { font-size: 13px; font-weight: 600; white-space: nowrap; }
.card-s { font-size: 11.5px; color: var(--text-3); }
.card-h .tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.card-b { padding: 14px 16px; flex: 1; min-height: 0; position: relative; }
.card-b.flush { padding: 0; }
.card-b.scroll { overflow: auto; }
.card-f { padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 8px; flex: none; }
.card.hl { border-color: color-mix(in srgb, var(--crit) 50%, var(--border)); box-shadow: 0 0 0 3px var(--crit-soft); }

/* ---------- KPI tiles ---------- */
.kpi { padding: 13px 16px 12px; display: flex; flex-direction: column; gap: 5px; min-height: 96px; }
.kpi-l { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.kpi-l .i { color: var(--text-3); }
.kpi-v { font-size: 22px; font-weight: 600; letter-spacing: -.01em; line-height: 1.15; display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.kpi-v small { font-size: 12px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.kpi-f { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.kpi .spark { margin-left: auto; }
.kpi-f .meter { flex: 1; min-width: 40px; }
.page-head.center { align-items: center; }
.delta { font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.delta.up-good, .delta.down-good { color: var(--good-ink); }
.delta.up-bad, .delta.down-bad { color: var(--crit-ink); }

/* ---------- buttons & controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: var(--r-sm); border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-2); border-color: var(--axis); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible, .chip:focus-visible, .tab:focus-visible, .seg button:focus-visible, .sb-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--crit-ink); border-color: color-mix(in srgb, var(--crit) 35%, var(--border-2)); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.solid-danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.solid-danger:hover { filter: brightness(.95); }
.btn.good { color: var(--good-ink); border-color: color-mix(in srgb, var(--good) 35%, var(--border-2)); }
.btn.good:hover { background: var(--good-soft); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn.xs { height: 22px; padding: 0 7px; font-size: 11.5px; border-radius: 5px; gap: 4px; }
.btn.icon { width: 30px; padding: 0; }
.btn.icon.sm { width: 26px; }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.btn.accent { background: linear-gradient(135deg, #2f7be6, #1d56b3); border: 0; color: #fff; box-shadow: 0 1px 2px rgba(29,86,179,.35); }
.btn.accent:hover { filter: brightness(1.06); }
.btn.on { background: var(--primary-soft); color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary) 40%, var(--border-2)); }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 2px; gap: 2px; flex: none; }
.seg button { height: 26px; padding: 0 10px; border: 0; background: transparent; border-radius: 6px; font-size: 12px; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border-2); background: var(--surface); font-size: 12px; color: var(--text-2); cursor: pointer; white-space: nowrap; user-select: none; }
.chip:hover { border-color: var(--axis); color: var(--text); }
.chip.on { border-color: color-mix(in srgb, var(--primary) 55%, transparent); color: var(--primary-ink); background: var(--primary-soft); font-weight: 600; }
.chip .n { font-variant-numeric: tabular-nums; color: var(--text-3); font-weight: 500; }
.chip.on .n { color: var(--primary-ink); }

.input, .select, .textarea { height: 30px; border: 1px solid var(--border-2); border-radius: var(--r-sm); background: var(--surface);
  color: var(--text); padding: 0 10px; font: inherit; font-size: 12.5px; outline: none; transition: border-color .12s, box-shadow .12s; }
.textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; width: 100%; line-height: 1.45; }
.select { padding-right: 28px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .lbl { font-size: 11.5px; color: var(--text-2); font-weight: 600; }
.search-in { position: relative; }
.search-in > .i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-in .input { padding-left: 30px; }

.switch { position: relative; width: 32px; height: 18px; display: inline-block; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border-2); border-radius: 999px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 19px; padding: 0 5px; border-radius: 5px; font-size: 10.5px; font-weight: 600;
  font-family: var(--font); color: var(--text-3); background: var(--surface); border: 1px solid var(--border-2); border-bottom-width: 2px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab { height: 38px; padding: 0 12px; border: 0; background: transparent; color: var(--text-2); font-size: 13px; cursor: pointer;
  position: relative; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); font-weight: 600; }
.tab.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--primary); border-radius: 2px; }
.tab .n { font-size: 11px; font-weight: 600; color: var(--text-3); background: var(--surface-3); border-radius: 9px; padding: 1px 6px; }
.tab.on .n { color: var(--primary-ink); background: var(--primary-soft); }

/* ---------- pills, badges, dots ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); line-height: 1; }
.pill .i { width: 12px; height: 12px; }
.pill.good, .pill.normal { background: var(--good-soft); color: var(--good-ink); }
.pill.warning, .pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.critical, .pill.serious { background: var(--serious-soft); color: var(--serious-ink); }
.pill.emergency, .pill.alarm, .pill.crit { background: var(--crit-soft); color: var(--crit-ink); }
.pill.info, .pill.primary { background: var(--info-soft); color: var(--info-ink); }
.pill.offline, .pill.off { background: var(--off-soft); color: var(--off-ink); }
.pill.outline { background: transparent; border: 1px solid var(--border-2); color: var(--text-2); font-weight: 500; }
.pill.sq { border-radius: 5px; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.tag.mono { font-family: var(--mono); font-weight: 500; font-size: 11px; }
.code-badge { font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--off); }
.dot.lg { width: 10px; height: 10px; }
.dot.good, .dot.normal { background: var(--good); }
.dot.warning { background: var(--warn); }
.dot.critical { background: var(--serious); }
.dot.alarm, .dot.emergency { background: var(--crit); }
.dot.info { background: var(--info); }
.dot.offline { background: transparent; box-shadow: inset 0 0 0 2px var(--off); }
.dot.blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* severity carriers */
.sev-emergency { --sevc: var(--crit);    --sev-soft: var(--crit-soft);    --sev-ink: var(--crit-ink); }
.sev-critical  { --sevc: var(--serious); --sev-soft: var(--serious-soft); --sev-ink: var(--serious-ink); }
.sev-warning   { --sevc: var(--warn);    --sev-soft: var(--warn-soft);    --sev-ink: var(--warn-ink); }
.sev-info      { --sevc: var(--info);    --sev-soft: var(--info-soft);    --sev-ink: var(--info-ink); }
.st-normal  { --stc: var(--good); --st-soft: var(--good-soft); --st-ink: var(--good-ink); }
.st-warning { --stc: var(--warn); --st-soft: var(--warn-soft); --st-ink: var(--warn-ink); }
.st-alarm   { --stc: var(--crit); --st-soft: var(--crit-soft); --st-ink: var(--crit-ink); }
.st-offline { --stc: var(--off);  --st-soft: var(--off-soft);  --st-ink: var(--off-ink); }

/* ---------- tables ---------- */
.tbl-wrap { overflow: auto; position: relative; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.tbl th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 11.5px;
  text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .sort { opacity: .5; margin-left: 2px; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tr.click { cursor: pointer; }
.tbl tr.sel td { background: var(--primary-soft) !important; }
.tbl tr.row-alarm td:first-child { box-shadow: inset 3px 0 0 var(--crit); }
.tbl tr.row-warning td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tbl tr.row-offline td { color: var(--text-3); }
.tbl .num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl.compact td { padding: 6px 10px; }
.tbl.compact th { padding: 6px 10px; }
.tbl td.wrap { white-space: normal; }
.cell-site { display: flex; flex-direction: column; line-height: 1.25; }
.cell-site b { font-weight: 600; }
.cell-site span { font-size: 11px; color: var(--text-3); }
.pager { display: flex; align-items: center; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.pager .right { display: flex; gap: 4px; align-items: center; }

/* key-value lists */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 12.5px; }
.kv dt { color: var(--text-2); white-space: nowrap; }
.kv dd { margin: 0; text-align: right; font-weight: 500; min-width: 0; }
.kv.left dd { text-align: left; }
.kv-sep { grid-column: 1 / -1; height: 1px; background: var(--border); margin: 3px 0; }

/* ---------- lists: alarms / feed ---------- */
.al { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.al::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--sevc); }
.al:hover { background: var(--surface-2); }
.al:last-child { border-bottom: 0; }
.al.cleared { opacity: .78; }
.al-ic { width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--sev-soft); color: var(--sev-ink); }
.al-b { min-width: 0; flex: 1; }
.al-t { font-weight: 600; font-size: 12.5px; line-height: 1.3; display: flex; gap: 6px; align-items: center; }
.al-m { font-size: 11.5px; color: var(--text-2); margin-top: 2px; }
.al-m b { color: var(--text); font-weight: 600; }
.al-r { text-align: right; font-size: 11px; color: var(--text-3); flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.al.new .al-ic { animation: sevPulse 1.6s ease-out infinite; }
@keyframes sevPulse { 0% { box-shadow: 0 0 0 0 var(--sev-soft); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.al.flash { animation: rowFlash 1.4s ease-out; }
@keyframes rowFlash { 0% { background: var(--sev-soft); } 100% { background: transparent; } }

.feed { display: flex; flex-direction: column; }
.feed-i { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.feed-i:last-child { border-bottom: 0; }
.feed-i.enter { animation: feedIn .35s ease-out; }
@keyframes feedIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.feed-ic { width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.feed-ic.good { background: var(--good-soft); color: var(--good-ink); }
.feed-ic.warning { background: var(--warn-soft); color: var(--warn-ink); }
.feed-ic.critical { background: var(--serious-soft); color: var(--serious-ink); }
.feed-ic.emergency, .feed-ic.alarm { background: var(--crit-soft); color: var(--crit-ink); }
.feed-ic.info { background: var(--info-soft); color: var(--info-ink); }
.feed-t { font-size: 12.5px; line-height: 1.35; min-width: 0; }
.feed-t b { font-weight: 600; }
.feed-m { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.empty { padding: 28px 16px; text-align: center; color: var(--text-3); font-size: 12.5px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .i { color: var(--good); }

/* ---------- meters / bars ---------- */
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; position: relative; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--primary); }
.meter.thin { height: 4px; }
.meter.good > i { background: var(--good); } .meter.warning > i { background: var(--warn); } .meter.crit > i { background: var(--crit); }
.mlist { display: flex; flex-direction: column; gap: 10px; }
.mrow { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 4px 10px; align-items: center; font-size: 12.5px; }
.mrow .meter { grid-column: 1 / -1; }
.mrow .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.segbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; background: transparent; }
.segbar > i { display: block; height: 100%; }
.segbar > i:first-child { border-radius: 4px 0 0 4px; }
.segbar > i:last-child { border-radius: 0 4px 4px 0; }
.segbar > i:only-child { border-radius: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; color: var(--text-2); align-items: center; }
.legend .k { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .ln { width: 14px; height: 2px; border-radius: 2px; flex: none; }
.legend .k b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gl { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .ax { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tk { font-size: 10.5px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .th-line { stroke: var(--serious); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .th-lbl { font-size: 10px; fill: var(--text-3); }
.chart .xh { stroke: var(--axis); stroke-width: 1; pointer-events: none; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .bar:hover, .chart .bar.hov { filter: brightness(1.12); }
.chart .lbl { font-size: 10.5px; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.chart-table { max-height: 260px; overflow: auto; }
.spark { display: block; overflow: visible; }

/* ---------- tooltip ---------- */
.tooltip { position: fixed; z-index: 95; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12px; min-width: 120px; max-width: 320px;
  opacity: 0; transform: translateY(3px); transition: opacity .1s, transform .1s; }
.tooltip.on { opacity: 1; transform: none; }
.tt-h { font-weight: 600; font-size: 12px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.tt-s { font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.tt-r { display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 1.6; }
.tt-r .ln { width: 12px; height: 2px; border-radius: 2px; flex: none; }
.tt-r .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tt-r .v { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 12px; }
.tt-r .n { color: var(--text-2); }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: calc(var(--tb-h) + 10px); right: 18px; z-index: 85; display: flex; flex-direction: column; gap: 8px; width: 370px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 10px 12px 10px 14px; display: flex; gap: 10px; align-items: flex-start; position: relative; overflow: hidden; animation: toastIn .24s ease-out; }
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sevc, var(--info)); }
.toast.out { animation: toastOut .2s ease-in forwards; }
.toast .al-ic { width: 30px; height: 30px; }
.toast-b { flex: 1; min-width: 0; }
.toast-t { font-weight: 600; font-size: 12.5px; }
.toast-m { font-size: 11.5px; color: var(--text-2); margin-top: 1px; }
.toast-a { display: flex; gap: 6px; margin-top: 7px; }
.toast .x { color: var(--text-3); cursor: pointer; border: 0; background: transparent; padding: 2px; border-radius: 4px; }
.toast .x:hover { color: var(--text); background: var(--surface-3); }
.toast .bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--sevc, var(--info)); opacity: .5; animation: toastBar linear forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }
@keyframes toastBar { from { width: 100%; } to { width: 0; } }

/* ---------- drawer & modal ---------- */
.drawer-back { position: fixed; inset: 0; background: rgba(12, 18, 28, .30); z-index: 60; animation: fade .15s ease-out; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 470px; max-width: 94vw; background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); z-index: 61; display: flex; flex-direction: column; animation: slideIn .2s ease-out; }
.drawer.wide { width: 620px; }
.drawer-h { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; flex: none; }
.drawer-h h3 { font-size: 15px; line-height: 1.3; }
.drawer-h .sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.drawer-b { flex: 1; overflow: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 16px; }
.drawer-f { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; background: var(--surface-2); flex: none; flex-wrap: wrap; }
.section-t { font-size: 11.5px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.box { border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; background: var(--surface); }
.box.soft { background: var(--surface-2); }
.modal-back { position: fixed; inset: 0; background: rgba(8, 12, 20, .52); z-index: 70; display: grid; place-items: center; padding: 24px; animation: fade .15s ease-out; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 520px; max-width: 100%; max-height: 100%;
  display: flex; flex-direction: column; overflow: hidden; animation: pop .18s ease-out; border: 1px solid var(--border); }
.modal.md { width: 720px; } .modal.lg { width: 1020px; } .modal.xl { width: 1240px; }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex: none; }
.modal-h h3 { font-size: 15px; }
.modal-b { padding: 16px 18px; overflow: auto; flex: 1; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); flex: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* timeline */
.tl { position: relative; display: flex; flex-direction: column; gap: 0; }
.tl-i { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 0 0 12px; position: relative; }
.tl-i::before { content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 1px; background: var(--border-2); }
.tl-i:last-child::before { display: none; }
.tl-i:last-child { padding-bottom: 0; }
.tl-d { width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); position: relative; z-index: 1; }
.tl-d.good { background: var(--good-soft); color: var(--good-ink); }
.tl-d.alarm { background: var(--crit-soft); color: var(--crit-ink); }
.tl-d.warning { background: var(--warn-soft); color: var(--warn-ink); }
.tl-d.info { background: var(--info-soft); color: var(--info-ink); }
.tl-t { font-size: 12.5px; line-height: 1.4; padding-top: 1px; }
.tl-t .who { color: var(--text-2); font-size: 11.5px; }
.tl-ts { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; padding-top: 2px; white-space: nowrap; }

/* steps */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.step { height: 4px; border-radius: 2px; background: var(--surface-3); }
.step.done { background: var(--primary); }
.step-l { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 10.5px; color: var(--text-3); margin-top: 5px; }
.step-l .on { color: var(--text); font-weight: 600; }

/* ---------- map ---------- */
.map { position: relative; width: 100%; height: 100%; min-height: 320px; background: var(--map-bg); overflow: hidden; user-select: none; touch-action: none; border-radius: 0 0 var(--r) var(--r); }
.map svg { width: 100%; height: 100%; display: block; cursor: grab; }
.map svg.drag { cursor: grabbing; }
.map .land { fill: var(--land); stroke: var(--land-stroke); stroke-width: 1.1; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.map .land-shadow { fill: none; stroke: var(--land-stroke); stroke-opacity: .25; stroke-width: 6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.map .grat { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; fill: none; }
.map .lake { fill: var(--water); stroke: none; }
.map .alabel { fill: var(--text-3); font-weight: 600; pointer-events: none; letter-spacing: .02em; paint-order: stroke; stroke: var(--land); stroke-linejoin: round; }
.map .slabel { fill: var(--text-2); pointer-events: none; font-weight: 500; paint-order: stroke; stroke: var(--map-bg); stroke-linejoin: round; }
.map .s { cursor: pointer; }
.map .s .m { stroke: var(--map-bg); vector-effect: non-scaling-stroke; }
.map .s:hover .m { filter: brightness(1.1); }
.map .s.sel .m { stroke: var(--text); }
.map .s .m.normal { fill: var(--good); }
.map .s .m.warning { fill: var(--warn); }
.map .s .m.alarm { fill: var(--crit); }
.map .s .m.offline { fill: var(--map-bg); stroke: var(--off); }
.map .ring { fill: none; stroke: var(--crit); vector-effect: non-scaling-stroke; transform-box: fill-box; transform-origin: center; animation: mapPulse 1.8s ease-out infinite; pointer-events: none; }
.map .ring.warning { stroke: var(--warn); animation-duration: 2.6s; }
@keyframes mapPulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(3.4); opacity: 0; } }
.map .hq { fill: var(--primary); stroke: var(--map-bg); vector-effect: non-scaling-stroke; }
.map .hq-l { fill: var(--primary-ink); font-weight: 700; paint-order: stroke; stroke: var(--map-bg); stroke-linejoin: round; pointer-events: none; }
.map .cov-in { fill: var(--primary); fill-opacity: .10; stroke: var(--primary); stroke-opacity: .55; vector-effect: non-scaling-stroke; }
.map .cov-out { fill: var(--primary); fill-opacity: .04; stroke: var(--primary); stroke-opacity: .35; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.map .rp { fill: var(--surface); stroke: var(--s7); vector-effect: non-scaling-stroke; cursor: pointer; }
.map .rp.alarm { fill: var(--crit); stroke: var(--surface); }
.map .rp-link { stroke: var(--s7); stroke-opacity: .7; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; fill: none; }
.map .flow { stroke: var(--primary); stroke-opacity: .22; vector-effect: non-scaling-stroke; fill: none; }
.map-ctrl { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 4px; z-index: 2; }
.map-ctrl .btn { background: var(--surface); box-shadow: var(--shadow-sm); }
.map-legend { position: absolute; left: 12px; bottom: 12px; z-index: 2; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; display: flex; gap: 12px; font-size: 11.5px; color: var(--text-2); backdrop-filter: blur(6px); flex-wrap: wrap; max-width: calc(100% - 80px); }
.map-legend .k { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.map-legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.map-scale { position: absolute; right: 12px; bottom: 12px; z-index: 2; font-size: 10.5px; color: var(--text-3); display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.map-scale i { display: block; height: 4px; border: 1px solid var(--text-3); border-top: 0; }

/* ---------- status matrix ---------- */
.matrix { display: flex; flex-direction: column; gap: 10px; }
.mx-g { display: grid; grid-template-columns: 112px 1fr; gap: 10px; align-items: start; }
.mx-l { font-size: 12px; color: var(--text-2); padding-top: 1px; line-height: 1.3; }
.mx-l b { color: var(--text); font-weight: 600; display: block; }
.mx-cells { display: flex; flex-wrap: wrap; gap: 3px; }
.mx-c { width: 16px; height: 16px; border-radius: 4px; background: var(--good); cursor: pointer; position: relative; transition: transform .1s; }
.mx-c:hover { transform: scale(1.25); z-index: 1; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text-3); }
.mx-c.warning { background: var(--warn); }
.mx-c.alarm { background: var(--crit); }
.mx-c.alarm::after { content: ""; position: absolute; inset: 4px; border-radius: 2px; background: rgba(255,255,255,.85); animation: blink 1.1s steps(2, start) infinite; }
.mx-c.offline { background: transparent; box-shadow: inset 0 0 0 2px var(--off); }

/* ---------- site tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(188px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 7px; position: relative; transition: border-color .12s, box-shadow .12s; }
.tile:hover { border-color: var(--axis); box-shadow: var(--shadow); }
.tile::before { content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--stc); }
.tile-h { display: flex; align-items: center; gap: 6px; }
.tile-h b { font-size: 12.5px; }
.tile-v { display: flex; gap: 10px; font-size: 12px; color: var(--text-2); align-items: center; }
.tile-v .i { color: var(--text-3); }
.tile-v b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-icons { display: flex; gap: 6px; }
.ico-st { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); }
.ico-st.ok { background: var(--good-soft); color: var(--good-ink); }
.ico-st.bad { background: var(--crit-soft); color: var(--crit-ink); }
.ico-st.warn { background: var(--warn-soft); color: var(--warn-ink); }

/* ---------- metric tiles (site) ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 10px; }
.metric { border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); position: relative; min-height: 84px; }
.metric.alarm { border-color: color-mix(in srgb, var(--crit) 45%, var(--border)); background: linear-gradient(0deg, var(--crit-soft), var(--crit-soft)), var(--surface); }
.metric.warning { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); background: linear-gradient(0deg, var(--warn-soft), var(--warn-soft)), var(--surface); }
.metric-l { font-size: 11.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.metric-l .i { color: var(--text-3); }
.metric-v { font-size: 18px; font-weight: 600; line-height: 1.2; display: flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.metric-v small { font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.metric-f { font-size: 11px; color: var(--text-3); margin-top: auto; display: flex; align-items: center; gap: 6px; }
.metric .spark { position: absolute; right: 10px; top: 32px; }

/* ---------- floor plan ---------- */
.plan { position: relative; }
.plan svg { width: 100%; height: auto; display: block; }
.plan .room-floor { fill: var(--surface-2); }
.plan .wall { fill: none; stroke: var(--text-2); stroke-width: 5; stroke-linejoin: round; }
.plan .door-gap { stroke: var(--surface-2); stroke-width: 7; }
.plan .door-leaf { stroke: var(--text-2); stroke-width: 3; stroke-linecap: round; transition: transform .6s ease; transform-origin: 62px 322px; }
.plan .door-arc { fill: none; stroke: var(--border-2); stroke-width: 1; stroke-dasharray: 3 3; }
.plan .rack { fill: var(--surface-3); stroke: var(--border-2); stroke-width: 1; }
.plan .rack-l { font-size: 9.5px; fill: var(--text-3); text-anchor: middle; font-weight: 600; letter-spacing: .02em; }
.plan .fx { fill: var(--surface); stroke: var(--border-2); stroke-width: 1; }
.plan .fx-l { font-size: 9.5px; fill: var(--text-3); }
.plan .zone-l { font-size: 10px; fill: var(--text-3); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.plan .rope { fill: none; stroke: #d9a514; stroke-width: 2.5; stroke-dasharray: 5 3; stroke-linecap: round; }
.plan .rope.wet { stroke: #2b8be8; stroke-dasharray: none; filter: drop-shadow(0 0 3px rgba(43,139,232,.7)); }
.plan .wire { fill: none; stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 2 3; }
.plan .ipwire { fill: none; stroke: var(--s2); stroke-opacity: 0; stroke-width: 1; transition: stroke-opacity .2s; }
.plan .lora { fill: none; stroke: var(--s1); stroke-opacity: .0; stroke-width: 1; stroke-dasharray: 3 4; transition: stroke-opacity .2s; }
.plan.show-links .lora { stroke-opacity: .4; }
.plan.show-links .ipwire { stroke-opacity: .45; }
.plan .fov { fill: var(--s2); fill-opacity: .045; stroke: none; }
.plan .pir { fill: var(--s1); fill-opacity: .035; stroke: none; transition: fill-opacity .3s; }
.plan .pir.on { fill-opacity: .15; }
.plan .dev { cursor: pointer; }
.plan .dev .bg { fill: var(--surface); stroke: var(--good); stroke-width: 2; transition: stroke .2s; }
.plan .dev .gl { stroke: none; }
.plan .dev.c-env .gl { fill: var(--s1); } .plan .dev.c-cam .gl { fill: var(--s2); } .plan .dev.c-acs .gl { fill: var(--s3); }
.plan .dev .gl.st { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.plan .dev.c-env .gl.st { stroke: var(--s1); } .plan .dev.c-cam .gl.st { stroke: var(--s2); } .plan .dev.c-acs .gl.st { stroke: var(--s3); }
.plan .dev.rx .bg { stroke: var(--s1); stroke-width: 4; }
.plan .dev.offline .gl { opacity: .45; }
.plan .dev.warning .bg { stroke: var(--warn); }
.plan .dev.alarm .bg { stroke: var(--crit); fill: var(--crit-soft); }
.plan .dev.offline .bg { stroke: var(--off); }
.plan .dev.passive .bg { stroke: var(--border-2); stroke-dasharray: 2 2; }
.plan .dev:hover .bg { stroke-width: 3; }
.plan .dev .ring { fill: none; stroke: var(--crit); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: mapPulse 1.6s ease-out infinite; }
.plan .dev-l { font-size: 9px; fill: var(--text-2); pointer-events: none; font-weight: 600; paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; stroke-linejoin: round; }
.plan.hide-labels .dev-l { display: none; }
.plan .tower { fill: none; stroke: var(--text-3); stroke-width: 1.2; }
.plan .ground { fill: var(--surface); }
.plan .packet { fill: var(--s1); }
.plan .heat { pointer-events: none; transition: opacity .8s; }
.plan .smoke { pointer-events: none; transition: opacity 1s; }
.plan .puddle { pointer-events: none; transition: opacity .6s; }
.plan .dark { fill: #0b1220; pointer-events: none; transition: opacity .6s; }
.plan .person { transition: opacity .4s, transform 1.5s ease; }
.plan-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); align-items: center; }
.plan-legend .sw { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* ---------- camera ---------- */
.cam { position: relative; background: #070a0e; border-radius: 9px; overflow: hidden; aspect-ratio: 16 / 9; }
.cam canvas { width: 100%; height: 100%; display: block; }
.cam-ov { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.cam-foot { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: linear-gradient(transparent, rgba(0,0,0,.62)); color: #fff; font-size: 11.5px; pointer-events: auto; }
.cam-foot b { font-weight: 600; }
.cam-foot .pill { height: 18px; font-size: 10.5px; }
.cam-tag { position: absolute; top: 8px; right: 8px; }
.cam.alarm { box-shadow: 0 0 0 2px var(--crit); }
.cam.clickable { cursor: pointer; }
.cam.clickable:hover { box-shadow: 0 0 0 2px var(--primary); }
.vwall { display: grid; gap: 8px; }
.vwall.g2 { grid-template-columns: repeat(2, 1fr); } .vwall.g3 { grid-template-columns: repeat(3, 1fr); } .vwall.g4 { grid-template-columns: repeat(4, 1fr); }
.playbar { height: 34px; border-radius: 7px; background: var(--surface-3); position: relative; overflow: hidden; cursor: pointer; }
.playbar .rec { position: absolute; top: 12px; height: 10px; background: color-mix(in srgb, var(--primary) 35%, transparent); border-radius: 2px; }
.playbar .ev { position: absolute; top: 6px; width: 3px; height: 22px; border-radius: 2px; background: var(--crit); }
.playbar .ev.acs { background: var(--s3); }
.playbar .head { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); }
.playbar-t { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-3); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- devices ---------- */
.prod { display: flex; gap: 12px; align-items: center; }
.prod-img { width: 52px; height: 52px; border-radius: 9px; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; flex: none; }
.prod-img img { max-width: 86%; max-height: 86%; object-fit: contain; }
.prod-img.sm { width: 34px; height: 34px; border-radius: 7px; }
.prod-img.lg { width: 120px; height: 120px; border-radius: 12px; }
.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.model { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; gap: 12px; align-items: center; background: var(--surface); cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.model:hover { border-color: var(--axis); box-shadow: var(--shadow); }
.model-n { font-weight: 600; font-size: 12.5px; line-height: 1.3; }
.model-m { font-size: 11.5px; color: var(--text-2); }
.model-s { display: flex; gap: 8px; font-size: 11px; color: var(--text-3); margin-top: 3px; align-items: center; }
.cat-h { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.cat-h .sw { width: 10px; height: 10px; border-radius: 3px; }
.cat-h b { font-size: 13px; }

/* ---------- architecture ---------- */
.arch svg { width: 100%; height: auto; display: block; }
.arch .zone { fill: var(--surface-2); stroke: var(--border); }
.arch .zone-t { font-size: 11px; font-weight: 700; fill: var(--text-2); letter-spacing: .06em; }
.arch .node { fill: var(--surface); stroke: var(--border-2); }
.arch .node.dark { fill: #142034; stroke: #142034; }
.arch .node.acc { fill: var(--primary-soft); stroke: color-mix(in srgb, var(--primary) 45%, transparent); }
.arch .nt { font-size: 12px; font-weight: 600; fill: var(--text); }
.arch .ns { font-size: 10.5px; fill: var(--text-2); }
.arch .node.dark + .nt, .arch .nt.inv { fill: #fff; }
.arch .ns.inv { fill: #b9c6da; }
.arch .flow { fill: none; stroke-width: 1.6; }
.arch .flow.anim { stroke-dasharray: 6 6; animation: dash 1.2s linear infinite; }
.arch .f-tel { stroke: var(--s1); } .arch .f-vid { stroke: var(--s2); } .arch .f-acs { stroke: var(--s3); } .arch .f-mgmt { stroke: var(--text-3); } .arch .f-lte { stroke: var(--s1); stroke-dasharray: 4 4; }
@keyframes dash { to { stroke-dashoffset: -24; } }
.arch .dotflow { fill: var(--s1); }

.callouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1180px) { .callouts { grid-template-columns: 1fr; } }
.callout { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface); display: flex; gap: 12px; }
.callout .ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-ink); flex: none; }
.callout h4 { font-size: 13px; margin-bottom: 3px; }
.callout p { font-size: 12px; color: var(--text-2); line-height: 1.5; }

.flowsteps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 1280px) { .flowsteps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.fstep { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; }
.fstep .n { width: 20px; height: 20px; border-radius: 50%; background: var(--text); color: var(--surface); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.fstep b { font-size: 12.5px; }
.fstep p { font-size: 11.5px; color: var(--text-2); line-height: 1.45; }
.fstep .t { margin-top: auto; font-size: 11.5px; font-weight: 600; color: var(--primary-ink); }

/* ---------- demo panel ---------- */
.demo-panel { position: fixed; right: 18px; bottom: 18px; width: 392px; max-height: calc(100vh - var(--tb-h) - 34px); background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 66; display: flex; flex-direction: column; overflow: hidden; animation: pop .18s ease-out; }
.demo-h { padding: 12px 14px; background: linear-gradient(135deg, #17417f 0%, #2a6fd6 100%); color: #fff; display: flex; align-items: center; gap: 10px; flex: none; }
.demo-h h3 { font-size: 13.5px; }
.demo-h .sub { font-size: 11.5px; color: rgba(255,255,255,.75); }
.demo-h .btn.ghost { color: rgba(255,255,255,.85); }
.demo-h .btn.ghost:hover { background: rgba(255,255,255,.14); color: #fff; }
.demo-c { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; flex: none; background: var(--surface-2); }
.demo-c .row { gap: 8px; }
.demo-c .select { flex: 1; min-width: 0; }
.demo-list { overflow-y: auto; padding: 6px; flex: 1; }
.scn { display: flex; gap: 10px; padding: 8px 8px; border-radius: 9px; align-items: center; }
.scn:hover { background: var(--surface-2); }
.scn-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.scn-b { flex: 1; min-width: 0; }
.scn-t { font-size: 12.5px; font-weight: 600; }
.scn-d { font-size: 11px; color: var(--text-3); line-height: 1.35; }
.scn.run .scn-ic { background: var(--crit-soft); color: var(--crit-ink); }
.scn .prog { height: 3px; border-radius: 2px; background: var(--surface-3); margin-top: 5px; overflow: hidden; }
.scn .prog i { display: block; height: 100%; background: var(--crit); }
.demo-f { padding: 9px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-2); flex: none; }

/* search palette */
.palette { position: fixed; inset: 0; z-index: 90; background: rgba(8,12,20,.42); display: flex; justify-content: center; padding-top: 12vh; animation: fade .12s; }
.palette-box { width: 560px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; height: fit-content; animation: pop .15s ease-out; }
.palette-in { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.palette-in input { flex: 1; border: 0; outline: 0; height: 48px; font: inherit; font-size: 14px; background: transparent; color: var(--text); }
.palette-res { max-height: 380px; overflow: auto; padding: 6px; }
.palette-i { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.palette-i.on, .palette-i:hover { background: var(--surface-3); }
.palette-i .meta { margin-left: auto; font-size: 11.5px; color: var(--text-3); }

/* misc */
.hr { height: 1px; background: var(--border); margin: 4px 0; }
.note { font-size: 11.5px; color: var(--text-3); display: flex; gap: 6px; align-items: flex-start; line-height: 1.45; }
.note .i { margin-top: 1px; }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; font-size: 12.5px;
  background: var(--info-soft); color: var(--info-ink); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.banner.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.banner.crit { background: var(--crit-soft); color: var(--crit-ink); border-color: color-mix(in srgb, var(--crit) 30%, transparent); }
.banner b { font-weight: 700; }
.stat-mini { display: flex; flex-direction: column; gap: 2px; }
.stat-mini .l { font-size: 11px; color: var(--text-3); }
.stat-mini .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.rule-row td .input { width: 64px; height: 26px; text-align: right; }
.img-well { background: #fff; border: 1px solid var(--border); border-radius: 12px; display: grid; place-items: center; padding: 10px; }
.icon-circle { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.click { cursor: pointer; }
.link { color: var(--primary-ink); cursor: pointer; }
.link:hover { text-decoration: underline; }
.blink-text { animation: blink 1.1s steps(2, start) infinite; }
.fade-in { animation: fade .3s ease-out; }
.scroll-y { overflow-y: auto; }
.h-100 { height: 100%; }
.pad { padding: 14px 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1280px) { .split { grid-template-columns: 1fr; } }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media print {
  .sidebar, .topbar, .demo-panel, .toasts { display: none !important; }
  .main { margin: 0 !important; }
}
