/* FRANKCAS X3 Cloud — styles.
   Visual idea: every emergency fitting is drawn as its charge-indicator LED.
   Steady green = healthy, amber = on battery, red = fault (pulses), blue = testing.
   Palette from emergency signage: ISO 7010 safety green on cool paper. */

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #F3F6F4;
  --surface: #FFFFFF;
  --surface-2: #E9EFEB;
  --ink: #13241C;
  --ink-2: #4F6158;
  --ink-3: #7C8D84;
  --line: #D5DFD9;
  --green: #00824A;
  --green-ink: #006B3C;
  --green-soft: #DDF1E6;
  --amber: #C98A00;
  --amber-soft: #FBF0D4;
  --red: #D3263A;
  --red-ink: #B3172B;
  --red-soft: #FBE3E6;
  --blue: #1F7AE0;
  --blue-soft: #E1EEFC;
  --muted: #A3B1AA;
  --focus: #1F7AE0;
  --on-green: #FFFFFF;
  --shadow: 0 1px 2px rgba(19, 36, 28, .06), 0 8px 24px -12px rgba(19, 36, 28, .18);
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --rail: 232px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0C1712;
    --surface: #13211A;
    --surface-2: #1A2B22;
    --ink: #E4EEE8;
    --ink-2: #9DB2A7;
    --ink-3: #6F857A;
    --line: #243A2F;
    --green: #2BC77A;
    --green-ink: #6FE0A6;
    --green-soft: #12351F;
    --amber: #F0B429;
    --amber-soft: #3A2E0E;
    --red: #FF5A6A;
    --red-ink: #FF8A96;
    --red-soft: #3D1A1F;
    --blue: #4EA3FF;
    --blue-soft: #132C47;
    --muted: #4C6157;
    --on-green: #04130B;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0C1712;
  --surface: #13211A;
  --surface-2: #1A2B22;
  --ink: #E4EEE8;
  --ink-2: #9DB2A7;
  --ink-3: #6F857A;
  --line: #243A2F;
  --green: #2BC77A;
  --green-ink: #6FE0A6;
  --green-soft: #12351F;
  --amber: #F0B429;
  --amber-soft: #3A2E0E;
  --red: #FF5A6A;
  --red-ink: #FF8A96;
  --red-soft: #3D1A1F;
  --blue: #4EA3FF;
  --blue-soft: #132C47;
  --muted: #4C6157;
  --on-green: #04130B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green-ink); }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- type ---------- */
h1, h2, h3, .wide { font-stretch: 118%; letter-spacing: -0.01em; }
h1 { font-size: clamp(26px, 3.4vw, 36px); line-height: 1.1; font-weight: 750; margin: 0; }
h2 { font-size: 19px; line-height: 1.25; font-weight: 700; margin: 0; }
h3 { font-size: 15.5px; font-weight: 650; margin: 0; }
.sub { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- LED: the signature element ---------- */
.led {
  --c: var(--green);
  display: inline-block; flex: none;
  width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.75) 0 18%, transparent 42%), var(--c);
  box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--c) 22%, transparent), 0 0 10px color-mix(in srgb, var(--c) 55%, transparent);
}
.led.ok { --c: var(--green); }
.led.warn { --c: var(--amber); }
.led.fault { --c: var(--red); animation: pulse 1.6s ease-in-out infinite; }
.led.testing { --c: var(--blue); animation: blink 1.1s steps(2, jump-none) infinite; }
.led.muted, .led.off { --c: var(--muted); box-shadow: none; background: var(--c); }
.led.lg { width: 16px; height: 16px; }
.led.xl { width: 22px; height: 22px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 0%, transparent), 0 0 18px var(--c); } }
@keyframes blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  .led.fault, .led.testing { animation: none; }
  * { scroll-behavior: auto !important; transition: none !important; }
}

.strip { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.strip .led { width: 10px; height: 10px; }
.strip .more { font-size: 12px; color: var(--ink-3); margin-left: 2px; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 14px; gap: 4px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 22px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--green);
  display: grid; place-items: center; color: #fff; font-stretch: 125%; font-weight: 800; font-size: 14px;
  position: relative;
}
.brand-mark::after { content: ""; position: absolute; right: -3px; top: -3px; width: 9px; height: 9px; border-radius: 50%;
  background: #7CF2B0; box-shadow: 0 0 0 2px var(--surface), 0 0 8px #7CF2B0; }
.brand b { display: block; font-stretch: 120%; font-weight: 750; font-size: 15px; line-height: 1.15; }
.brand > span:last-child > span { font-size: 12.5px; color: var(--ink-2); display: block; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-weight: 550;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--green-soft); color: var(--green-ink); }
.nav svg { width: 20px; height: 20px; flex: none; }
.nav .badge { margin-left: auto; }
.rail-foot { margin-top: auto; padding: 10px 12px; font-size: 12.5px; color: var(--ink-3); }
.rail-foot .conn { display: flex; gap: 8px; align-items: center; }
.main { margin-left: var(--rail); padding: 30px clamp(18px, 3.5vw, 44px) 60px; max-width: calc(1240px + var(--rail)); }

.tabbar { display: none; }
.topbar { display: none; }

@media (max-width: 899px) {
  .rail { display: none; }
  .main { margin-left: 0; padding: calc(12px + var(--safe-t)) 16px calc(92px + var(--safe-b)); }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b));
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-decoration: none; padding: 6px 0; position: relative;
  }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a[aria-current="page"] { color: var(--green-ink); }
  .tabbar .badge { position: absolute; top: 2px; left: calc(50% + 6px); }
}

.badge {
  min-width: 19px; height: 19px; border-radius: 10px; padding: 0 6px;
  background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700;
  display: inline-grid; place-items: center;
}

/* ---------- buttons, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 15px; border-radius: 10px; font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: 40px; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--on-green); }
.btn.primary:hover { background: var(--green-ink); border-color: var(--green-ink); }
.btn.danger { color: var(--red-ink); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 6px 11px; min-height: 34px; font-size: 13.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 42px; font-size: 16px;
}
.input:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }
.hint { font-size: 12.5px; color: var(--ink-3); margin-top: -2px; }

.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 11px; width: 18px; height: 18px; color: var(--ink-3); }
.search .input { padding-left: 36px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 20px;
  padding: 6px 13px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
  display: inline-flex; gap: 7px; align-items: center;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip .n { font-weight: 700; opacity: .8; }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--muted); border-radius: 20px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2.5px solid var(--focus); outline-offset: 2px; }

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.page-head .lead { margin: 8px 0 0; color: var(--ink-2); max-width: 62ch; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.back svg { width: 18px; height: 18px; }

/* ---------- fleet ---------- */
.fleet-hero { display: flex; align-items: center; gap: 16px; margin: 4px 0 6px; }
.fleet-stats { display: flex; flex-wrap: wrap; gap: 8px 30px; margin: 18px 0 26px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fleet-stats div { display: flex; flex-direction: column; }
.fleet-stats b { font-size: 26px; font-stretch: 112%; font-weight: 700; line-height: 1.1; }
.fleet-stats span { font-size: 13px; color: var(--ink-2); }
.fleet-stats .bad b { color: var(--red-ink); }
.fleet-stats .warnc b { color: var(--amber); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 18px; }

.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
@media (max-width: 420px) { .sites { grid-template-columns: 1fr; } }
.site-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); text-decoration: none; color: inherit; display: flex; flex-direction: column;
  overflow: hidden; transition: transform .15s ease, border-color .15s;
}
.site-card:hover { border-color: color-mix(in srgb, var(--green) 45%, var(--line)); }
.site-card:active { transform: scale(.995); }
.site-card .band {
  padding: 13px 18px; display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 14px;
  background: var(--green-soft); color: var(--green-ink);
}
.site-card.s-fault .band { background: var(--red-soft); color: var(--red-ink); }
.site-card.s-critical .band { background: var(--red); color: #fff; }
.site-card.s-critical .band .led { --c: #fff; }
.site-card.s-warning .band { background: var(--amber-soft); color: color-mix(in srgb, var(--amber) 75%, var(--ink)); }
.site-card.s-offline .band { background: var(--surface-2); color: var(--ink-2); }
.site-card .band .when { margin-left: auto; font-weight: 500; font-size: 12.5px; opacity: .85; }
.site-card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.site-card h2 { font-size: 20px; }
.site-card .where { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
.site-card .facts { display: flex; gap: 22px; margin-top: auto; padding-top: 4px; }
.site-card .facts div { display: flex; flex-direction: column; font-size: 12.5px; color: var(--ink-2); }
.site-card .facts b { font-size: 17px; color: var(--ink); font-weight: 700; }
.site-card .facts .bad b { color: var(--red-ink); }
.site-card.s-offline .strip { opacity: .45; filter: grayscale(.6); }
.site-card.archived { opacity: .6; }

.empty { text-align: left; padding: 40px 28px; border: 1.5px dashed var(--line); border-radius: var(--r-lg); color: var(--ink-2); max-width: 640px; }
.empty h2 { color: var(--ink); margin-bottom: 8px; }

/* ---------- site ---------- */
.site-title { display: flex; flex-direction: column; gap: 6px; }
.site-title .where { color: var(--ink-2); }
.conn-pill { display: inline-flex; align-items: center; gap: 9px; padding: 7px 13px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tag { font-size: 12.5px; padding: 3px 10px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); font-weight: 550; }

.seg { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 24px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg a { padding: 10px 14px 12px; color: var(--ink-2); text-decoration: none; font-weight: 600; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.seg a[aria-current="page"] { color: var(--ink); border-color: var(--green); }
.seg a .badge { margin-left: 4px; }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1080px) { .grid2 { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 18px; }
.panel h2 { margin-bottom: 14px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
@media (max-width: 899px) { .panel { padding: 16px; border-radius: 14px; } }

.verdict { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 22px; }
.verdict .led { margin-top: 10px; }
.verdict h2 { font-size: clamp(22px, 2.6vw, 30px); line-height: 1.15; font-weight: 750; }
.verdict p { margin: 6px 0 0; color: var(--ink-2); }

.wall { display: flex; flex-direction: column; gap: 16px; }
.wall .zone { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: start; }
.wall .zone > span { font-size: 13px; color: var(--ink-2); font-weight: 600; padding-top: 1px; }
@media (max-width: 600px) { .wall .zone { grid-template-columns: 1fr; gap: 6px; } }
.wall .strip { gap: 9px; }
.wall button.led { border: 0; cursor: pointer; padding: 0; width: 14px; height: 14px; }
.wall button.led:hover { transform: scale(1.35); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--ink-2); margin-top: 18px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .led { width: 9px; height: 9px; animation: none; }

.meter { margin: 0 0 16px; }
.meter .row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.meter .row b { font-weight: 650; }
.meter .bar { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.meter .bar i { display: block; height: 100%; border-radius: 6px; background: var(--green); transition: width .6s ease; }
.meter.warn .bar i { background: var(--amber); }
.meter.bad .bar i { background: var(--red); }

.next { display: flex; gap: 16px; align-items: center; }
.next .count { font-size: 30px; font-weight: 750; font-stretch: 115%; line-height: 1; }
.next .count small { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 0 6px 0 2px; font-stretch: 100%; }

.running { border: 1.5px solid var(--blue); background: var(--blue-soft); border-radius: var(--r-md); padding: 14px 16px; display: flex; gap: 14px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.running .grow { flex: 1; min-width: 180px; }
.progress { height: 6px; border-radius: 4px; background: color-mix(in srgb, var(--blue) 20%, transparent); margin-top: 8px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--blue); border-radius: 4px; transition: width .5s; }

.list { display: flex; flex-direction: column; }
.list .item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--line); }
.list .item:first-child { border-top: 0; padding-top: 2px; }
.list .item .led { margin-top: 6px; }
.list .item .grow { flex: 1; min-width: 0; }
.list .item b { font-weight: 650; }
.list .item .d { font-size: 13.5px; color: var(--ink-2); }
.list .item time { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }

.air { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.air div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.air b { display: block; font-size: 20px; font-weight: 700; }
.air span { font-size: 12.5px; color: var(--ink-2); }
.air .poor b { color: var(--red-ink); }
.air .fair b { color: var(--amber); }

.spark { width: 100%; height: 70px; display: block; }

/* fittings table */
.ftable { width: 100%; border-collapse: collapse; }
.ftable th { text-align: left; font-size: 12.5px; color: var(--ink-2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ftable td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
.ftable tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.ftable tr { cursor: pointer; }
.ftable .nm { font-weight: 650; }
.ftable .st.fault { color: var(--red-ink); font-weight: 600; }
.ftable .st.warn { color: var(--amber); font-weight: 600; }
.ftable .st.testing { color: var(--blue); font-weight: 600; }
.ftable td.cb, .ftable th.cb { width: 36px; padding-right: 0; }
.ftable input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); }
.res-pass { color: var(--green-ink); font-weight: 600; }
.res-fail { color: var(--red-ink); font-weight: 600; }
.old { color: var(--amber); }
.batt { display: inline-flex; align-items: center; gap: 6px; }
.batt i { width: 26px; height: 11px; border: 1.5px solid var(--ink-3); border-radius: 3px; position: relative; display: inline-block; }
.batt i::after { content: ""; position: absolute; left: 1px; top: 1px; bottom: 1px; width: calc(var(--p) * 0.215px); background: var(--green); border-radius: 1px; }
.batt.low i::after { background: var(--red); }

.cards { display: none; }
@media (max-width: 760px) {
  .ftable-wrap { display: none; }
  .cards { display: flex; flex-direction: column; gap: 10px; }
  .fcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; display: flex; gap: 12px; align-items: flex-start; }
  .fcard .led { margin-top: 6px; }
  .fcard .grow { flex: 1; min-width: 0; }
  .fcard .nm { font-weight: 650; }
  .fcard .ln { font-size: 13px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 2px; }
  .fcard input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--green); margin-top: 2px; }
}

.selbar {
  position: sticky; bottom: 14px; z-index: 15; margin-top: 16px;
  background: var(--ink); color: var(--paper); border-radius: 14px; padding: 10px 12px 10px 18px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; box-shadow: 0 12px 30px -10px rgba(0,0,0,.45);
}
.selbar .grow { flex: 1; font-weight: 600; }
.selbar .btn { background: transparent; color: var(--paper); border-color: color-mix(in srgb, var(--paper) 35%, transparent); }
.selbar .btn.primary { background: var(--green); border-color: var(--green); color: var(--on-green); }
@media (max-width: 899px) { .selbar { bottom: calc(80px + var(--safe-b)); } }

/* floor plans */
.floor-tabs { margin-bottom: 14px; }
.plan {
  position: relative; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  height: min(70vh, 760px); overflow: hidden; touch-action: none; cursor: grab; user-select: none;
}
.plan.grabbing { cursor: grabbing; }
.plan .stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.plan .stage img { display: block; pointer-events: none; -webkit-user-drag: none; }
.plan .mk {
  position: absolute; transform: translate(-50%, -50%); border: 0; padding: 0; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.plan .mk .led { width: 14px; height: 14px; }
.plan .mk.sel { outline: 3px solid var(--focus); }
.plan .mk .lab { position: absolute; top: 30px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 11.5px; font-weight: 650; background: var(--surface); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); }
.plan .zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
.plan .zoom button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; font-weight: 600; cursor: pointer; display: grid; place-items: center; }
.plan .zoom svg { width: 20px; height: 20px; }
.plan .waiting { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-2); text-align: center; padding: 20px; }
.pop {
  position: absolute; z-index: 5; width: 280px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 16px 40px -12px rgba(0,0,0,.4); padding: 14px 16px; cursor: default;
}
.pop h3 { display: flex; gap: 9px; align-items: center; }
.pop dl, .sheet dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13.5px; margin: 10px 0 12px; }
.pop dt, .sheet dt { color: var(--ink-2); }
.pop dd, .sheet dd { margin: 0; font-weight: 550; }
.plan-foot { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; margin-top: 12px; }

/* schedules */
.sched { display: flex; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.sched:first-child { border-top: 0; }
.sched .grow { flex: 1; min-width: 0; }
.sched .d { font-size: 13.5px; color: var(--ink-2); }
.sched .nx { font-size: 13px; color: var(--ink-3); }
@media (max-width: 600px) { .sched { flex-wrap: wrap; } .sched .acts { width: 100%; } }
.runbox { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.runbox .opt { border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.runbox .opt p { margin: 0; font-size: 13.5px; color: var(--ink-2); flex: 1; }

/* history */
.timeline .item { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; }
.tl-ic { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.tl-ic svg { width: 14px; height: 14px; }
.tl-ic.test { background: var(--blue-soft); color: var(--blue); }
.tl-ic.fault, .tl-ic.critical { background: var(--red-soft); color: var(--red-ink); }
.tl-ic.repair, .tl-ic.cleared { background: var(--green-soft); color: var(--green-ink); }
.tl-ic.warning { background: var(--amber-soft); color: var(--amber); }
.dl-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* alerts */
.alert-site { margin-bottom: 22px; }
.alert-site > a { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--ink); margin-bottom: 8px; }
.sev { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.sev.critical { background: var(--red); color: #fff; }
.sev.fault { background: var(--red-soft); color: var(--red-ink); }
.sev.warning { background: var(--amber-soft); color: color-mix(in srgb, var(--amber) 75%, var(--ink)); }
.sev.info { background: var(--surface-2); color: var(--ink-2); }

/* sheet / dialog */
.scrim { position: fixed; inset: 0; background: rgba(8, 18, 13, .45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s ease; }
.sheet {
  background: var(--surface); border-radius: 20px; width: min(560px, 100%); max-height: min(88vh, 900px); overflow: auto;
  padding: 22px 24px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); animation: rise .2s ease;
}
.sheet h2 { margin-bottom: 6px; }
.sheet .acts { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; position: sticky; bottom: -22px; background: var(--surface); padding: 12px 0 2px; }
@media (max-width: 600px) {
  .scrim { align-items: flex-end; padding: 0; }
  .sheet { border-radius: 20px 20px 0 0; width: 100%; padding: 20px 18px calc(20px + var(--safe-b)); max-height: 92vh; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 480px) { .cols2 { grid-template-columns: 1fr; } }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { display: inline-flex; }
.days input { position: absolute; opacity: 0; }
.days span { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.days input:checked + span { background: var(--green); border-color: var(--green); color: var(--on-green); }
.days input:focus-visible + span { outline: 2.5px solid var(--focus); outline-offset: 2px; }

/* toast */
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 32px)); }
@media (max-width: 899px) { .toasts { bottom: calc(86px + var(--safe-b)); } }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; font-weight: 550; box-shadow: 0 12px 30px -10px rgba(0,0,0,.45); display: flex; gap: 10px; align-items: center; animation: rise .2s ease; }
.toast.bad { background: var(--red); color: #fff; }
.toast.good .led { --c: #7CF2B0; }

/* login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 480px); }
.login .art { background: #0E2219; color: #E4EEE8; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .art h1 { font-size: clamp(34px, 4.6vw, 58px); max-width: 12ch; line-height: 1.02; font-stretch: 125%; }
.login .art p { color: #9DB2A7; max-width: 44ch; font-size: 16px; }
.login .art .brand { color: #E4EEE8; padding: 0; }
.login .art .brand > span:last-child > span { color: #9DB2A7; }
.login .art .brand-mark::after { box-shadow: 0 0 0 2px #0E2219, 0 0 8px #7CF2B0; }
.login .ledfield { position: absolute; right: -20px; bottom: -20px; display: grid; grid-template-columns: repeat(14, 22px); gap: 18px; opacity: .9; }
.login .ledfield .led { width: 9px; height: 9px; }
.login form { padding: 48px clamp(24px, 5vw, 56px); display: flex; flex-direction: column; justify-content: center; background: var(--surface); }
.login form h2 { font-size: 26px; margin-bottom: 6px; }
.login form .sub { margin: 0 0 26px; }
.login .err { background: var(--red-soft); color: var(--red-ink); padding: 10px 12px; border-radius: 10px; font-weight: 550; margin-bottom: 14px; font-size: 14px; }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login .art { padding: calc(28px + var(--safe-t)) 24px 30px; min-height: 0; }
  .login .art h1 { font-size: 32px; margin-top: 26px; }
  .login .art p { display: none; }
  .login .ledfield { display: none; }
  .login form { padding: 28px 24px calc(40px + var(--safe-b)); justify-content: flex-start; }
}

.skeleton { height: 140px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shine 1.3s linear infinite; }
@keyframes shine { to { background-position: -200% 0; } }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.stack > * + * { margin-top: 18px; }
.offline-note { background: var(--surface-2); border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 18px; color: var(--ink-2); font-size: 14px; display: flex; gap: 12px; align-items: center; }

/* phone: small brand line on top-level pages */
.mtop { display: none; }
@media (max-width: 899px) {
  .mtop { display: flex; align-items: center; gap: 10px; margin: 2px 0 18px; font-weight: 700; font-stretch: 118%; }
  .mtop .brand-mark { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; }
  .mtop .brand-mark::after { width: 7px; height: 7px; box-shadow: 0 0 0 2px var(--paper), 0 0 6px #7CF2B0; }
  .mtop .conn { margin-left: auto; font-size: 12.5px; font-weight: 500; font-stretch: 100%; color: var(--ink-2); display: flex; gap: 7px; align-items: center; }
  .meta-row .tag.sid { display: none; }
  .plan { height: 62vh; }
}
