/* SIMPO Monitor — no external assets (works on an isolated LAN) */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f5;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e3e8ef;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --primary-soft: #e8efff;

  --side-bg: #0f172a; --side-text: #cbd5e1; --side-muted: #64748b; --side-active: rgba(255, 255, 255, .08);

  --normal: #16803c;   --normal-bg: #e7f6ec;
  --fire: #dc2626;     --fire-bg: #fdecec;
  --prealarm: #ea580c; --prealarm-bg: #fff0e5;
  --fault: #b45309;    --fault-bg: #fdf4e3;
  --disabled: #6d4fd8; --disabled-bg: #f1edfd;
  --offline: #64748b;  --offline-bg: #eef1f5;
  --info: #2563eb;     --info-bg: #e8efff;

  --radius: 16px;
  --radius-sm: 11px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --bottom-nav-h: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17; --surface: #131923; --surface-2: #19202c; --surface-3: #202837; --text: #e6eaf1; --muted: #94a0b4;
    --border: #253043; --shadow: 0 1px 2px rgba(0,0,0,.35); --shadow-lg: 0 16px 50px rgba(0,0,0,.55);
    --primary: #5b8cff; --primary-soft: #18264a;
    --side-bg: #0a0e15; --side-active: rgba(255, 255, 255, .07);
    --normal: #3ccf74;   --normal-bg: #11261a;
    --fire: #ff5c5c;     --fire-bg: #361616;
    --prealarm: #ff8d45; --prealarm-bg: #33200f;
    --fault: #e9b44a;    --fault-bg: #2e2510;
    --disabled: #a08cff; --disabled-bg: #221d3b;
    --offline: #94a0b4;  --offline-bg: #1e2532;
    --info: #6f9bff;     --info-bg: #16223d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--primary); }
code, .mono { font-family: var(--mono); font-size: .9em; }
h1 { font-size: 24px; line-height: 1.2; margin: 0; font-weight: 750; letter-spacing: -.01em; }
h2 { font-size: 15.5px; margin: 0; font-weight: 680; }
h3 { margin: 0 0 6px; font-size: 19px; font-weight: 720; }
svg.ic { width: 18px; height: 18px; flex: none; }
.grow { flex: 1; }
.stack { display: grid; gap: 16px; align-content: start; }
.hint { color: var(--muted); font-size: 13px; }
.form-error { color: var(--fire); font-size: 13px; min-height: 18px; }
.empty { color: var(--muted); padding: 22px 8px; text-align: center; }

/* buttons & inputs */
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 9px 16px; font: inherit; font-weight: 620; cursor: pointer; background: var(--surface-3);
  color: var(--text); text-decoration: none; transition: filter .15s, background .15s, transform .05s; white-space: nowrap; }
.btn:hover { filter: brightness(.96); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg.ic { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-danger { background: var(--fire); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--border); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn-lg { padding: 13px 18px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 10px;
  width: 36px; height: 36px; display: inline-grid; place-items: center; cursor: pointer; flex: none; font-size: 18px; }
.icon-btn:hover { color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--fire); border-color: var(--fire); background: var(--fire-bg); }
.link-btn { border: 0; background: none; color: var(--primary); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; }
input, select { width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; }
input:focus, select:focus, .btn:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
label.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-weight: 550; font-size: 14px; cursor: pointer; }
label.check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.select-inline { width: auto; margin: 0; padding: 7px 10px; font-weight: 620; }
.form { display: grid; gap: 12px; align-content: start; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row label { flex: 1 1 80px; }
.form-row label.grow { flex: 3 1 180px; }

/* toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0;
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: var(--surface-3); border: 1px solid var(--border);
  position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch[aria-checked="true"] { color: var(--text); }
.switch[aria-checked="true"] .track { background: var(--normal); border-color: var(--normal); }
.switch[aria-checked="true"] .track::after { transform: translateX(16px); }
.switch.warn[aria-checked="true"] .track { background: var(--prealarm); border-color: var(--prealarm); }
.switch:disabled { opacity: .6; cursor: default; }

/* login */
.login-view { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side { background: var(--side-bg); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.login-side .brand-sub { color: var(--side-text); }
.login-claim { font-size: 20px; line-height: 1.45; color: var(--side-text); max-width: 420px; margin: 0; }
.login-card { align-self: center; justify-self: center; width: 100%; max-width: 380px; padding: 28px; display: grid; gap: 14px; }
.login-card h1 { margin-bottom: 4px; }

/* brand */
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.brand-title { font-weight: 760; letter-spacing: .01em; }
.brand-sub { color: var(--muted); font-size: 12px; }
.brand-lg .brand-title { font-size: 22px; }

/* app shell */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--side-bg) 252px, var(--bg) 252px); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--side-bg); color: var(--side-text); display: flex;
  flex-direction: column; gap: 14px; padding: 18px 12px; overflow-y: auto; }
.sidebar .brand { padding: 4px 8px; color: #fff; }
.sidebar .brand-sub { color: var(--side-muted); }
.tenant-pick { padding: 0 8px; color: var(--side-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.sidebar .tenant-select { background: rgba(255,255,255,.06); color: #fff; border-color: rgba(255,255,255,.12); font-weight: 600;
  text-transform: none; letter-spacing: 0; }
.sidebar .tenant-select option { color: #0f172a; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--side-text);
  text-decoration: none; font-weight: 560; font-size: 14.5px; }
.side-nav a:hover { background: var(--side-active); color: #fff; }
.side-nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.side-nav a span { flex: 1; }
.nav-label { margin: 14px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--side-muted); font-weight: 700; }
.nav-count { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--fire); color: #fff; font-size: 11.5px;
  line-height: 20px; text-align: center; animation: pulse 1.2s infinite; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot .icon-btn { background: transparent; border-color: rgba(255,255,255,.12); color: var(--side-text); }
.user-card { flex: 1; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; color: #fff; text-decoration: none; min-width: 0; }
.user-card:hover, .user-card.active { background: var(--side-active); }
.user-card b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.user-card small { display: block; color: var(--side-muted); font-size: 11.5px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center;
  font-weight: 750; flex: none; text-transform: uppercase; }
.avatar-lg { width: 52px; height: 52px; font-size: 20px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 26px 28px 28px; flex: 1; }
.view { display: grid; gap: 18px; align-content: start; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-head .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.back { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface);
  border: 1px solid var(--border); color: var(--text); flex: none; }
.footer { max-width: 1180px; width: 100%; margin: 0 auto; padding: 4px 28px 26px; color: var(--muted); font-size: 12px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bottom-nav { display: none; }
.mobile-only { display: none; }

/* alarm banner (any panel of the tenant in FIRE / PREALARM) */
.alarm-banner { display: grid; gap: 6px; width: 100%; max-width: 1180px; margin: 18px auto 0; padding: 0 28px; }
.alarm-banner a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px;
  background: var(--prealarm); color: #fff; text-decoration: none; font-size: 14.5px; box-shadow: var(--shadow); }
.alarm-banner.fire a.is-fire { background: var(--fire); animation: firepulse 1.2s infinite; }
.alarm-banner svg.ic { width: 24px; height: 24px; }
.alarm-banner .ab-text { display: grid; flex: 1; min-width: 0; }
.alarm-banner .ab-where { font-weight: 720; }
.alarm-banner .ab-why { opacity: .92; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alarm-banner .ab-go { font-weight: 700; font-size: 13px; white-space: nowrap; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* rows (lists that work on phones too) */
.rows { display: grid; }
.rows > * { min-width: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); min-width: 0; }
.row:last-child { border-bottom: 0; }
.row-link { color: var(--text); text-decoration: none; border-radius: 10px; padding: 12px 10px; }
.row-link:hover { background: var(--surface-2); }
.row .main { flex: 1; min-width: 0; }
.row .main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .main small { display: block; color: var(--muted); font-size: 12.5px; }
.row .row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.row .row-actions select { width: auto; margin: 0; padding: 6px 8px; font-size: 13px; }

/* toolbar + chips */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.search { max-width: 320px; margin: 0; background: var(--surface); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px;
  padding: 6px 13px; font: inherit; font-size: 13px; font-weight: 620; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip .n { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--surface-3); color: var(--text); font-size: 11.5px; line-height: 18px; text-align: center; }
.chip.active .n { background: rgba(255,255,255,.2); color: inherit; }
.chip .n.red { background: var(--fire); color: #fff; }

/* home: site cards */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 18px; align-items: start; }
.site-card { padding: 0; overflow: hidden; border-top: 4px solid var(--c, var(--border)); }
.site-card .site-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 16px 18px 10px; }
.site-card .site-head .hint { margin-top: 2px; }
.site-card .rows { padding: 0 8px 8px; }
.prow { display: flex; align-items: center; gap: 12px; padding: 11px 10px; border-radius: 12px; color: var(--text); text-decoration: none; }
.prow:hover { background: var(--surface-2); }
.prow + .prow { border-top: 1px solid var(--border); }
.prow .dot-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--c-bg, var(--offline-bg));
  color: var(--c, var(--offline)); flex: none; }
.prow .dot-ic svg.ic { width: 21px; height: 21px; }
.prow .main { flex: 1; min-width: 0; }
.prow .main b { display: block; }
.prow .main small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .st { font-weight: 760; font-size: 12.5px; color: var(--c, var(--offline)); letter-spacing: .02em; white-space: nowrap; }
.prow > svg.ic:last-child { color: var(--muted); }
.prow.is-FIRE { background: var(--fire); color: #fff; animation: firepulse 1.2s infinite; }
.prow.is-FIRE .main small, .prow.is-FIRE .st, .prow.is-FIRE > svg.ic:last-child { color: #fff; }
.prow.is-FIRE .dot-ic { background: #fff; color: var(--fire); }
.s-FIRE { --c: var(--fire); --c-bg: var(--fire-bg); }
.s-PREALARM { --c: var(--prealarm); --c-bg: var(--prealarm-bg); }
.s-FAULT { --c: var(--fault); --c-bg: var(--fault-bg); }
.s-DISABLED { --c: var(--disabled); --c-bg: var(--disabled-bg); }
.s-NORMAL { --c: var(--normal); --c-bg: var(--normal-bg); }
.s-OFFLINE, .s-INACTIVE { --c: var(--offline); --c-bg: var(--offline-bg); }
.s-STARTING { --c: var(--info); --c-bg: var(--info-bg); }
.empty-hero { text-align: center; padding: 40px 20px; display: grid; gap: 12px; justify-items: center; }
.empty-hero .big-ic { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.empty-hero .big-ic svg.ic { width: 28px; height: 28px; }

/* panel page */
.conn-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 650; background: var(--offline-bg); color: var(--offline); white-space: nowrap; }
.conn-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn-pill.online { background: var(--normal-bg); color: var(--normal); }
.conn-pill.online .dot { animation: pulse 2s infinite; }
.hero { display: flex; align-items: center; gap: 18px; padding: 22px 24px; border-radius: 20px;
  background: var(--c-bg, var(--offline-bg)); color: var(--c, var(--offline)); border: 1px solid color-mix(in srgb, currentColor 22%, transparent); }
.hero-icon { width: 58px; height: 58px; border-radius: 17px; display: grid; place-items: center; flex: none; background: currentColor; }
.hero-icon svg.ic { width: 30px; height: 30px; color: var(--surface); }
.hero-body { flex: 1; min-width: 0; }
.hero-title { font-size: 27px; font-weight: 820; letter-spacing: .02em; }
.hero-sub { color: var(--text); opacity: .88; margin-top: 2px; font-size: 14px; }
.hero-sub .reason { display: inline-block; margin: 5px 6px 0 0; padding: 3px 10px; border-radius: 999px; font-size: 12.5px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.hero-meta { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.hero.s-FIRE { background: var(--fire); color: #fff; border-color: transparent; animation: firepulse 1.2s infinite; }
.hero.s-FIRE .hero-icon { background: #fff; } .hero.s-FIRE .hero-icon svg.ic { color: var(--fire); }
.hero.s-FIRE .hero-sub, .hero.s-FIRE .hero-meta { color: #fff; }

.segtabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 13px; overflow-x: auto; scrollbar-width: none; }
.segtabs::-webkit-scrollbar { display: none; }
.segtabs button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 640; padding: 8px 14px;
  border-radius: 10px; cursor: pointer; white-space: nowrap; flex: 1 0 auto; }
.segtabs button:hover { color: var(--text); }
.segtabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segtabs button.alert::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%;
  background: var(--fire); vertical-align: middle; animation: pulse 1s infinite; }
.tab-panel { display: grid; gap: 18px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 620; }
.stat-value { font-size: 26px; font-weight: 780; margin-top: 2px; }
.stat.c-fire .stat-value { color: var(--fire); } .stat.c-fault .stat-value { color: var(--fault); }
.stat.c-disabled .stat-value { color: var(--disabled); } .stat.c-normal .stat-value { color: var(--normal); }

/* flags */
.flag-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.flag-list li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.flag-list li:hover { background: var(--surface-2); }
.flag-list .led { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex: none; }
.flag-list li.on .led { background: var(--cat, var(--fault)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat, var(--fault)) 22%, transparent); }
.flag-list li.on { font-weight: 620; }
.flag-list li.off { color: var(--muted); }
.raw-line { margin-top: 10px; color: var(--muted); font: 12px var(--mono); }

/* confidence badges (admins) */
.conf { font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.conf-confirmed { background: var(--normal-bg); color: var(--normal); }
.conf-supported { background: var(--info-bg); color: var(--info); }
.conf-hypothesis { background: var(--offline-bg); color: var(--offline); }

/* events */
.event-list { list-style: none; margin: 0; padding: 0; display: grid; }
.event-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 9px 4px;
  border-bottom: 1px solid var(--border); font-size: 13.5px; }
.event-list li:last-child { border-bottom: 0; }
.event-list .ev-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--c-bg, var(--surface-3)); color: var(--c, var(--muted)); }
.event-list .ev-ic svg.ic { width: 16px; height: 16px; }
.event-list .ev-text small { display: block; color: var(--muted); font-size: 12px; }
.event-time { color: var(--muted); font: 12px var(--mono); white-space: nowrap; }
.alarm-banner .ab-more { justify-content: center; background: var(--surface); color: var(--fire); border: 1px solid var(--fire); font-weight: 700; }

/* zones */
.zone-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
.zone { display: flex; flex-direction: column; border-radius: 13px; padding: 10px 11px; background: var(--normal-bg); color: var(--normal);
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent); min-height: 70px; }
.zone .zn { font-weight: 760; font-size: 13.5px; color: var(--text); }
.zone .zs { font-size: 12px; font-weight: 650; margin-top: 3px; }
.zone.c-alarm { background: var(--fire); color: #fff; } .zone.c-alarm .zn { color: #fff; }
.zone.c-prealarm { background: var(--prealarm-bg); color: var(--prealarm); }
.zone.c-fault, .zone.c-unknown { background: var(--fault-bg); color: var(--fault); }
.zone.c-disabled { background: repeating-linear-gradient(135deg, var(--disabled-bg) 0 8px, var(--surface) 8px 16px); color: var(--disabled); }
.zone .zbtn { align-self: flex-start; margin-top: 8px; border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  background: var(--surface); color: inherit; border-radius: 8px; padding: 3px 9px; font: inherit; font-size: 12px; font-weight: 680; cursor: pointer; }
.zone .zbtn:hover { background: color-mix(in srgb, currentColor 12%, var(--surface)); }
.zone-hint { margin: -6px 0 12px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.sw-normal { background: var(--normal); } .sw-alarm { background: var(--fire); } .sw-prealarm { background: var(--prealarm); }
.sw-fault { background: var(--fault); } .sw-disabled { background: var(--disabled); } .sw-none { background: var(--offline); }

/* floor plan */
.plan-head { align-items: center; }
.plan-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plan-actions, .plan-admin { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.plan-pages { margin-bottom: 12px; }
.plan-pages:empty { display: none; }
.plan-pages .chip .cnt { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--fire); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.plan-editbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px;
  border: 1px dashed var(--primary); border-radius: 12px; background: var(--info-bg); }
.plan-editbar .hint { flex-basis: 260px; flex-grow: 2; }
.plan-ref { display: flex; align-items: center; gap: 6px; color: var(--text); }
.plan-ref input { width: 76px; margin: 0; padding: 6px 8px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 620; padding: 6px 12px; cursor: pointer; }
.seg button.active { background: var(--text); color: var(--surface); }
.plan-busy { padding: 40px; text-align: center; color: var(--muted); }
.plan-wrap { position: relative; }
.plan-view { overflow: auto; max-height: 66vh; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
  touch-action: pan-x pan-y pinch-zoom; }
.plan-stage { position: relative; width: 100%; margin: 0 auto; }
.plan-stage img { display: block; width: 100%; height: auto; user-select: none; background: #fff; }
.plan-stage.editing { cursor: crosshair; }
.plan-markers { position: absolute; inset: 0; }
.pm { position: absolute; transform: translate(-50%, -50%); min-width: 30px; height: 30px; padding: 0 7px; border-radius: 15px;
  display: grid; place-items: center; font: 700 12px/1 var(--font); color: #fff; background: var(--c, var(--offline));
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: pointer; white-space: nowrap; user-select: none; }
.pm.k-device { border-radius: 7px; }
.pm.c-normal { --c: var(--normal); }
.pm.c-alarm { --c: var(--fire); animation: pm-pulse 1s ease-in-out infinite; }
.pm.c-prealarm { --c: var(--prealarm); animation: pm-pulse 1.6s ease-in-out infinite; }
.pm.c-fault { --c: var(--fault); }
.pm.c-disabled { --c: var(--disabled); background: repeating-linear-gradient(135deg, var(--disabled) 0 5px, #8f7be6 5px 10px); }
.pm.c-none { --c: var(--offline); opacity: .85; }
.pm.sel { outline: 3px solid var(--primary); outline-offset: 2px; }
.plan-stage.editing .pm { cursor: grab; animation: none; }
.plan-stage.editing .pm.dragging { cursor: grabbing; opacity: .8; }
@keyframes pm-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 70%, transparent); }
  50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--c) 0%, transparent); } }
.plan-pop { position: absolute; z-index: 5; min-width: 190px; max-width: min(260px, calc(100% - 8px));
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
  box-shadow: var(--shadow-lg); font-size: 13px; }
.plan-pop .pt { font-weight: 700; font-size: 14px; }
.plan-pop .ps { margin: 4px 0 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.plan-pop .pa { display: flex; gap: 6px; flex-wrap: wrap; }
.plan-pop .px { position: absolute; top: 4px; right: 6px; border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }
.plan-zoom { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.plan-zoom span { min-width: 40px; text-align: center; color: var(--muted); }

/* tables (audit) */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 620; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 680; white-space: nowrap; }
.p-normal { background: var(--normal-bg); color: var(--normal); } .p-alarm { background: var(--fire-bg); color: var(--fire); }
.p-prealarm { background: var(--prealarm-bg); color: var(--prealarm); } .p-fault, .p-unknown { background: var(--fault-bg); color: var(--fault); }
.p-disabled { background: var(--disabled-bg); color: var(--disabled); } .p-offline { background: var(--offline-bg); color: var(--offline); }
.p-info, .p-none, .p-warning { background: var(--info-bg); color: var(--info); }
.tag { white-space: nowrap; font-size: 11.5px; font-weight: 620; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tag-warn { background: var(--fault-bg); color: var(--fault); border-color: transparent; }

/* commands */
.notice { border-radius: var(--radius); padding: 14px 16px; background: var(--info-bg); color: var(--text); border: 1px solid var(--border); font-size: 14px; }
.notice.off { background: var(--offline-bg); }
.notice.warn { background: var(--fault-bg); }
.cmd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.cmd-card { display: grid; gap: 12px; align-content: space-between; }
.cmd-card p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.cmd-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cmd-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.cmd-row .btn { padding: 13px 14px; }

/* manage */
.site-admin .site-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.panel-row { display: grid; grid-template-columns: minmax(150px, 1.3fr) auto auto auto; gap: 18px; align-items: center;
  padding: 12px 4px; border-bottom: 1px solid var(--border); }
.panel-row .sw-col { display: flex; gap: 18px; }
.panel-row .main a { color: var(--text); text-decoration: none; }
.row .dot-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3);
  color: var(--muted); flex: none; }
.panel-row:last-child { border-bottom: 0; }
.panel-row .main b { display: block; }
.panel-row .main small { color: var(--muted); font: 12px var(--mono); }
.panel-row .acts { display: flex; gap: 4px; }

/* notifications + account */
.device-state { display: flex; gap: 16px; align-items: flex-start; }
.device-state .big-ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--c-bg); color: var(--c); }
.device-state .big-ic svg.ic { width: 26px; height: 26px; }
.device-state p { margin: 4px 0 12px; color: var(--muted); font-size: 14px; }
.device-state .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.pref-list { display: grid; }
.pref { display: flex; align-items: center; gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.pref:last-child { border-bottom: 0; }
.pref .main { flex: 1; }
.pref .main small { display: block; color: var(--muted); font-size: 12.5px; }
.profile { display: flex; gap: 14px; align-items: center; }
.steps-ios { margin: 8px 0 0; padding-left: 20px; color: var(--text); font-size: 14px; }

/* dialog */
.dialog { border: 1px solid var(--border); border-radius: 20px; padding: 24px; width: min(460px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog-wide { width: min(560px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(8, 12, 20, .55); backdrop-filter: blur(2px); }
.dialog form { display: grid; gap: 12px; }
.dialog p { margin: 0; color: var(--muted); }
.dialog .warn { background: var(--fault-bg); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.dialog .frame { font: 12.5px var(--mono); color: var(--muted); }
#ui-body { display: grid; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.role-opts { display: grid; gap: 8px; }
.role-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; color: var(--text); font-weight: 600; font-size: 14px; }
.role-opt input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); }
.role-opt small { display: block; color: var(--muted); font-weight: 500; font-size: 12.5px; }
.role-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.stepper { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 4px; counter-reset: st; }
.stepper li { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--muted); counter-increment: st; }
.stepper li::before { content: counter(st); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 12px; flex: none; }
.stepper li.on { color: var(--text); }
.stepper li.on::before { background: var(--primary); color: #fff; }
.stepper li.done::before { content: "✓"; background: var(--normal); color: #fff; }
.wstep { display: grid; gap: 12px; }
.summary { display: grid; gap: 6px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; font-size: 14px; }
.summary div { display: flex; justify-content: space-between; gap: 12px; }
.summary span { color: var(--muted); }

/* incidents, maintenance, names, map, settings */
.itag { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px;
  font-weight: 700; background: var(--surface); color: var(--fire); border: 1px solid currentColor; width: fit-content; }
.itag.ok { color: var(--normal); }
.itag svg.ic { width: 13px; height: 13px; }
.prow.is-FIRE .itag { background: #fff; }
.due { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 650; background: var(--fault-bg); color: var(--fault); }
.due.late { background: var(--fire-bg); color: var(--fire); }
.due svg.ic { width: 14px; height: 14px; }
.incident-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--text); font-size: 14px; }
.incident-bar > svg.ic { color: var(--normal); }
.incident-bar span { flex: 1; min-width: 180px; }
.ack-btn { background: var(--text); color: var(--surface); }
.alarm-banner .ab-ack { margin-left: 8px; padding: 0 8px; border-radius: 999px; background: rgba(255,255,255,.22); font-size: 12px; font-weight: 700; }
.zone .zname { font-size: 11.5px; color: var(--text); opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone.c-alarm .zname { color: #fff; }
.names-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 12px; max-height: 46vh; overflow: auto;
  padding: 2px 4px 4px 0; }
.names-grid input { margin-top: 3px; padding: 7px 9px; }
#ui-body h4 { margin: 6px 0 0; font-size: 14px; }
.tdf-import { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.file-btn { width: fit-content; cursor: pointer; }
fieldset.chan { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin: 0; display: grid; gap: 6px; }
fieldset.chan legend { font-size: 13px; color: var(--muted); font-weight: 650; padding: 0 4px; }
.toolbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar-right .search { width: 280px; }
.map-card { padding: 12px; }
.site-map { height: 62vh; min-height: 320px; border-radius: 12px; overflow: hidden; z-index: 0; }
.map-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 14px; }
.map-card .hint { margin: 8px 2px 0; }
.leaflet-popup-content a { color: var(--primary); }
.actions-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.report-row { align-items: flex-end; }
.report-row .btn { margin-bottom: 1px; }
.dot-ic.s-FAULT, .dot-ic.s-PREALARM, .dot-ic.s-FIRE, .dot-ic.s-NORMAL { background: var(--c-bg); color: var(--c); }
.ev-ic.s-NORMAL { --c: var(--normal); --c-bg: var(--normal-bg); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--bottom-nav-h)); transform: translateX(-50%); background: var(--text); color: var(--surface);
  padding: 11px 18px; border-radius: 12px; font-weight: 620; box-shadow: var(--shadow-lg); z-index: 50; max-width: calc(100vw - 32px); }
.toast.err { background: var(--fire); color: #fff; }

@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }
@keyframes firepulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5) } 50% { box-shadow: 0 0 0 9px rgba(220,38,38,0) } }
@media (prefers-reduced-motion: reduce) {
  .hero.s-FIRE, .conn-pill.online .dot, .prow.is-FIRE, .alarm-banner a, .nav-count, .pm.c-alarm, .pm.c-prealarm { animation: none !important; }
}

/* tablets */
@media (max-width: 1100px) {
  .panel-row { grid-template-columns: 1fr auto auto; gap: 10px 14px; }
  .panel-row .sw-col { grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; }
}
@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .hero-meta { display: none; }
  .site-grid { grid-template-columns: 1fr; }
}

/* phones: no sidebar, top bar + bottom navigation */
@media (max-width: 760px) {
  :root { --bottom-nav-h: 64px; }
  .login-view { grid-template-columns: 1fr; }
  .login-side { padding: 32px 22px 8px; background: none; color: var(--text); gap: 12px; }
  .login-side .brand-sub, .login-claim { color: var(--muted); }
  .login-claim { font-size: 15px; }
  .login-card { padding: 16px 22px 32px; align-self: start; }
  .shell { display: block; }
  .sidebar { display: none; }
  .topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
  .topbar-title { flex: 1; min-width: 0; display: grid; }
  .topbar-title b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-title small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding: 16px 14px calc(var(--bottom-nav-h) + 22px); }
  .footer { display: none; }
  .alarm-banner { padding: 0 14px; margin-top: 12px; gap: 6px; }
  .alarm-banner a { padding: 10px 12px; font-size: 13.5px; }
  .alarm-banner .ab-why { display: none; }   /* the panel page shows the reasons */
  .page-head h1, .page-head .sub { display: none; }   /* the top bar shows the page title */
  .page-head:not(:has(.actions:not([hidden]))):not(:has(.head-left)) { display: none; }
  #view-home .page-head { display: none; }
  #view-panel .page-head { align-items: center; }
  .bottom-nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: flex; height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 95%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; position: relative;
    color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 620; }
  .bottom-nav a svg.ic { width: 23px; height: 23px; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav .nav-count { position: absolute; top: 6px; left: calc(50% + 6px); line-height: 18px; min-width: 18px; font-size: 11px; }
  .mobile-only { display: block; }
  .search { max-width: none; flex: 1 1 100%; }
  .cmd-row { grid-template-columns: 1fr 1fr; }
  .hero { padding: 16px; gap: 14px; border-radius: 16px; }
  .hero-icon { width: 48px; height: 48px; border-radius: 14px; }
  .hero-title { font-size: 22px; }
  .card { padding: 16px; }
  .zone-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
  .event-list li { grid-template-columns: auto 1fr; }
  .event-list li .conf, .event-list li .event-time { grid-column: 2; }
  .event-list li .event-time { order: -1; }
  .row { flex-wrap: wrap; }
  .row .row-actions { width: 100%; justify-content: flex-start; }
  .dialog { padding: 20px; border-radius: 18px; }
  .stepper li { font-size: 0; gap: 0; flex: 0 0 auto; }
  .stepper li.on { font-size: 13px; gap: 8px; flex: 1; }
}
