/* VConnecTech ILMS dashboard — light + dark themes via CSS variables */
:root {
  color-scheme: light;
  --brand: #2f78bd;
  --brand-ink: #1d5c99;
  --brand-soft: #e7f0fa;
  --nav: #0b2545;
  --nav-2: #13315c;
  --nav-ink: #c9d6e8;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --border: #e1e6ed;
  --text: #0f1b2d;
  --text-2: #4b5a6e;
  --muted: #7d8a9c;
  --grid: #e9edf2;

  /* light (luminaire) states — always shown with a text label */
  --st-on: #0ca30c;
  --st-dim: #2a78d6;
  --st-off: #98a2b3;
  --st-fault: #d03b3b;
  --st-offline: #52514e;

  /* status / fault-age bands (Bondada CCMS Doc 1 o.vii) */
  --age-1: #fab219;  /* 0–12 h */
  --age-2: #ec835a;  /* 12–24 h */
  --age-3: #d03b3b;  /* 24–48 h */
  --age-4: #8b1e1e;  /* > 48 h, SLA breached */
  --good: #0ca30c;
  --good-ink: #067306;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-base: #98a2b3;

  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 1px 8px rgba(15, 27, 45, .04);
  --radius: 10px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #4b93d8;
  --brand-ink: #8cbcf0;
  --brand-soft: #1b2a3d;
  --nav: #0a1424;
  --nav-2: #142238;
  --bg: #10151c;
  --surface: #1a1f27;
  --surface-2: #202631;
  --border: #2c3441;
  --text: #eef1f5;
  --text-2: #b8c1cd;
  --muted: #8691a1;
  --grid: #2a313c;
  --st-dim: #3987e5;
  --st-off: #6b7587;
  --st-offline: #a8a69d;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-base: #6b7587;
  --good-ink: #3fcf3f;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------- login ---------------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: linear-gradient(160deg, #0b2545 0%, #13315c 55%, #1d5c99 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero h1 { font-size: 34px; line-height: 1.15; margin: 0 0 12px; font-weight: 650; }
.login-hero p { color: #c9d6e8; max-width: 460px; margin: 0; }
.login-hero .feat { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; margin-top: 32px; max-width: 520px; }
.login-hero .feat div { display: flex; gap: 10px; align-items: center; color: #dfe8f4; font-size: 13.5px; }
.login-hero .feat svg { flex: none; }
.login-hero img.prod { width: 300px; border-radius: 12px; background: #fff; padding: 10px; margin-top: 28px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-hero .foot { font-size: 12px; color: #8ea6c4; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--surface); }
.login-card { width: 100%; max-width: 380px; }
.login-card img.logo { width: 250px; display: block; margin-bottom: 28px; }
.login-card h2 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--text-2); margin: 0 0 22px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 9px 11px; outline: none; width: 100%; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.hint { font-size: 12px; color: var(--muted); margin-top: 14px; line-height: 1.6; }
.hint code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }

/* ---------------- shell ---------------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--nav); color: var(--nav-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { background: #fff; padding: 14px 16px 12px; border-bottom: 3px solid var(--brand); }
.side .brand img { width: 100%; display: block; }
.side .brand small { display: block; color: #4b5a6e; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; margin-top: 7px; font-weight: 600; text-align: center; }
.side nav { padding: 10px 8px; overflow-y: auto; flex: 1; }
.side .grp { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #6f87a8; padding: 12px 12px 5px; }
.side a.nav { display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 7px; color: var(--nav-ink); text-decoration: none; font-size: 13.5px; }
.side a.nav:hover { background: var(--nav-2); color: #fff; }
.side a.nav.active { background: var(--brand); color: #fff; }
.side a.nav .badge { margin-left: auto; background: var(--st-fault); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.side .side-foot { padding: 12px 16px; font-size: 11.5px; color: #6f87a8; border-top: 1px solid var(--nav-2); }
.side .side-foot b { color: #c9d6e8; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 22px; position: sticky; top: 0; z-index: 20; }
.top h1 { font-size: 18px; margin: 0; font-weight: 650; }
.top .crumb { color: var(--muted); font-size: 12.5px; }
.top .spacer { flex: 1; }
.top .chip { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: 5px 10px; border-radius: 20px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--good); flex: none; }
.dot.pulse { box-shadow: 0 0 0 0 rgba(12,163,12,.5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12,163,12,.45); } 70% { box-shadow: 0 0 0 7px rgba(12,163,12,0); } 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); } }
.user { display: flex; align-items: center; gap: 9px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user .who { line-height: 1.15; font-size: 12.5px; } .user .who small { color: var(--muted); display: block; text-transform: capitalize; }

.content { padding: 20px 22px 40px; display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card.flush { padding: 0; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card.flush .card-h { padding: 14px 18px 0; }
.card-h h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.card-h .sub { color: var(--muted); font-size: 12.5px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: flex-start; }
.tile .ic { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.tile .lab { font-size: 12.5px; color: var(--text-2); }
.tile .val { font-size: 25px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile .val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.tile .foot { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* buttons */
.btn { border: 1px solid var(--border); background: var(--surface); padding: 7px 13px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.on { background: var(--st-on); border-color: var(--st-on); color: #fff; }
.btn.on:hover { filter: brightness(.93); }
.btn.off { background: #3d4757; border-color: #3d4757; color: #fff; }
.btn.off:hover { filter: brightness(1.15); }
.btn.danger { color: var(--st-fault); border-color: color-mix(in srgb, var(--st-fault) 40%, var(--border)); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.lg { padding: 11px 18px; font-size: 14px; }
.btn.block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 11px; font-size: 12.5px; cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--brand); color: #fff; }

/* switch */
.switch { position: relative; width: 42px; height: 23px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--st-off); border-radius: 23px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--st-on); }
.switch input:checked + span::before { transform: translateX(19px); }
.switch input:disabled + span { opacity: .45; cursor: not-allowed; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.pill i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pill.st-on i { background: var(--st-on); } .pill.st-on { color: var(--good-ink); }
.pill.st-dimmed i { background: var(--st-dim); } .pill.st-dimmed { color: var(--st-dim); }
.pill.st-off i { background: var(--st-off); }
.pill.st-fault i { background: var(--st-fault); } .pill.st-fault { color: var(--st-fault); }
.pill.st-offline i { background: transparent; border: 2px solid var(--st-offline); width: 9px; height: 9px; }
.pill.sev-critical { color: #fff; background: var(--st-fault); border-color: var(--st-fault); }
.pill.sev-serious { color: #7a3214; background: #fde3d6; border-color: #f6c2a9; }
.pill.sev-warning { color: #6d4a00; background: #fff1cc; border-color: #f7da8a; }
:root[data-theme="dark"] .pill.sev-serious { color: #f6b597; background: #3a2318; border-color: #5a3424; }
:root[data-theme="dark"] .pill.sev-warning { color: #f5cd6b; background: #352a10; border-color: #574317; }
.pill.ok { color: var(--good-ink); } .pill.ok i { background: var(--good); }
.pill.brand { color: var(--brand-ink); background: var(--brand-soft); border-color: transparent; }
.pill.pending i { background: var(--brand); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.age { display: inline-block; width: 4px; align-self: stretch; border-radius: 3px; flex: none; }
.age-1 { background: var(--age-1); } .age-2 { background: var(--age-2); } .age-3 { background: var(--age-3); } .age-4 { background: var(--age-4); }
.age-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.age-legend span { display: inline-flex; align-items: center; gap: 6px; }
.age-legend span::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--c); }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 9px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tr.clickable { cursor: pointer; }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .muted, .muted { color: var(--muted); }
.tbl input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--brand); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.toolbar .input { width: auto; padding: 6px 10px; font-size: 13px; }
.toolbar .search { min-width: 220px; }
.bulkbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 18px; background: var(--brand-soft); border-bottom: 1px solid var(--border); font-size: 13px; }
.bulkbar b { color: var(--brand-ink); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 18px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); }

/* dim slider */
.dim { display: flex; align-items: center; gap: 8px; min-width: 170px; }
.tbl .btn-row { flex-wrap: nowrap; }
.dim input[type=range] { width: 92px; accent-color: var(--brand); }
.dim .v { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-2); width: 38px; text-align: right; }
.levelbar { width: 70px; height: 6px; background: var(--grid); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.levelbar i { display: block; height: 100%; background: var(--st-dim); border-radius: 4px; }

/* segbar + legend */
.segbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--surface); }
.segbar span { display: block; min-width: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.legend i.line { height: 0; border-top: 2px dashed; border-radius: 0; width: 14px; }

/* charts */
.chart { width: 100%; position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .grid.base { stroke: var(--border); }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .xhair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.spark { display: block; height: 44px; }
#tip { position: fixed; z-index: 100; pointer-events: none; display: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: 8px 10px; font-size: 12px; min-width: 150px; }
#tip .tip-h { font-weight: 650; margin-bottom: 4px; }
#tip .tip-r { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
#tip .tip-r i { width: 8px; height: 8px; border-radius: 2px; }
#tip .tip-r b { margin-left: auto; padding-left: 12px; color: var(--text); font-variant-numeric: tabular-nums; }

/* master control */
.master { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.master .btn { justify-content: center; padding: 12px; font-size: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 550; text-align: right; font-variant-numeric: tabular-nums; }
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.meter div { background: var(--surface); padding: 9px 10px; }
.meter small { display: block; color: var(--muted); font-size: 11px; }
.meter b { font-size: 16px; font-variant-numeric: tabular-nums; }
.meter b em { font-style: normal; font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 2px; }

/* zone rows */
.zone-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) auto; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.zone-row:last-child { border-bottom: 0; }
.zone-row .zn { font-weight: 650; } .zone-row .zs { font-size: 12px; color: var(--muted); }

/* alerts list */
.alist { display: flex; flex-direction: column; }
.aitem { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: center; }
.aitem:last-child { border-bottom: 0; }
.aitem .t { font-weight: 600; font-size: 13px; }
.aitem .d { font-size: 12px; color: var(--muted); }
.aitem .when { margin-left: auto; text-align: right; font-size: 12px; color: var(--text-2); white-space: nowrap; }

/* panel cards */
.pcard .ph { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.pcard .ph h3 { margin: 0; font-size: 15px; } .pcard .ph .sub { font-size: 12px; color: var(--muted); }
.pcard .ph .right { margin-left: auto; display: flex; gap: 6px; }
.pcard .row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.leds { display: flex; gap: 12px; font-size: 11.5px; color: var(--text-2); }
.leds span { display: inline-flex; align-items: center; gap: 5px; }
.led { width: 9px; height: 9px; border-radius: 50%; background: var(--st-on); box-shadow: 0 0 6px var(--st-on); }
.led.off { background: var(--st-off); box-shadow: none; }
.led.blink { animation: blink 1s infinite; }
.led.err { background: var(--st-fault); box-shadow: 0 0 6px var(--st-fault); }

/* map */
.map-wrap { position: relative; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.map-wrap svg { display: block; width: 100%; height: auto; }
.map-road { stroke: #cfd6df; stroke-width: 16; stroke-linecap: round; }
:root[data-theme="dark"] .map-road { stroke: #343d4b; }
.map-road-c { stroke: #fff; stroke-width: 1.2; stroke-dasharray: 8 8; opacity: .8; }
:root[data-theme="dark"] .map-road-c { stroke: #556; }
.map-block { fill: #e9edf2; } :root[data-theme="dark"] .map-block { fill: #1e242d; }
.map-label { font-size: 12px; fill: var(--text-2); font-weight: 600; }
.map-small { font-size: 10.5px; fill: var(--muted); }
.lamp { cursor: pointer; }
.lamp:hover circle.core { stroke: var(--text); stroke-width: 2; }
.gw-cover { fill: var(--brand); opacity: .05; stroke: var(--brand); stroke-dasharray: 5 5; stroke-opacity: .5; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(8, 15, 28, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 100%; background: var(--surface); z-index: 50; box-shadow: -10px 0 30px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.drawer .dh { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.drawer .dh h2 { margin: 0; font-size: 18px; }
.drawer .dh .sub { color: var(--muted); font-size: 12.5px; }
.drawer .db { padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.drawer h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.x { margin-left: auto; border: 0; background: none; cursor: pointer; font-size: 22px; color: var(--muted); line-height: 1; padding: 2px 6px; }
.events { font-size: 12.5px; }
.events div { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.events div span:first-child { color: var(--muted); width: 92px; flex: none; }

/* modal */
.modal { position: fixed; z-index: 60; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 440px; max-width: calc(100% - 30px); background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal .mh { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal .mh h3 { margin: 0; font-size: 16px; }
.modal .mb { padding: 16px 20px; }
.modal .mf { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 380px; display: flex; gap: 10px; align-items: center; animation: slide .2s ease-out; }
.toast.err { background: var(--st-fault); color: #fff; }
.toast.ok { background: #0b6b2e; color: #fff; }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

/* schedules */
.sched-bar { position: relative; height: 34px; border-radius: 6px; background: var(--grid); overflow: hidden; }
.sched-bar .seg-on { position: absolute; top: 0; bottom: 0; }
.sched-bar .now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--st-fault); }
.sched-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.steps { width: 100%; border-collapse: collapse; font-size: 13px; }
.steps td { padding: 5px 4px; }
.steps .input { padding: 5px 8px; }

/* progress */
.prog { height: 8px; background: var(--grid); border-radius: 5px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--brand); transition: width .2s; }

/* empty */
.empty { padding: 30px; text-align: center; color: var(--muted); }
.note { font-size: 12px; color: var(--muted); }
.readonly-banner { background: #fff6dd; border: 1px solid #f3dc9a; color: #6d4a00; padding: 8px 14px; border-radius: 8px; font-size: 13px; }
:root[data-theme="dark"] .readonly-banner { background: #352a10; border-color: #574317; color: #f5cd6b; }

.prod-card { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: center; }
.prod-card img { width: 100%; border-radius: 8px; background: #fff; border: 1px solid var(--border); }
.speclist { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px 18px; font-size: 13px; margin: 0; padding: 0; list-style: none; }
.speclist li { display: flex; gap: 8px; align-items: center; color: var(--text-2); }
.speclist li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); flex: none; }

@media (max-width: 1200px) { .tiles { grid-template-columns: repeat(2, 1fr); } .g4 { grid-template-columns: repeat(2, 1fr); } .g-21, .g-12, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .app { grid-template-columns: 1fr; } .side { position: static; height: auto; } .login-wrap { grid-template-columns: 1fr; } .login-hero { display: none; } .g2 { grid-template-columns: 1fr; } .zone-row { grid-template-columns: 1fr; } }

/* ===================== v2 additions: detail page, cards, reports, audit ===================== */
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.pill.sev-info { color: var(--brand-ink); background: var(--brand-soft); border-color: transparent; }
a.idlink { color: var(--brand-ink); text-decoration: none; border-bottom: 1px dashed color-mix(in srgb, var(--brand) 55%, transparent); }
a.idlink:hover { border-bottom-style: solid; }
.iconbtn { border: 0; background: none; padding: 1px 3px; cursor: pointer; color: var(--muted); vertical-align: middle; border-radius: 4px; }
.iconbtn:hover { color: var(--brand-ink); background: var(--brand-soft); }
.tile.link { cursor: pointer; transition: border-color .12s, transform .12s; }
.tile.link:hover { border-color: var(--brand); transform: translateY(-1px); }
.tile .go { color: var(--brand); opacity: 0; transition: opacity .12s; }
.tile.link:hover .go { opacity: 1; }
.zone-row .zn a { color: inherit; text-decoration: none; border-bottom: 1px dashed var(--border); }
.zone-row .zn a:hover { color: var(--brand-ink); }
.sig { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; vertical-align: middle; }
.sig i { width: 4px; background: var(--grid); border-radius: 1px; }
.sig i.lit { background: var(--series-1); }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chips:empty { display: none; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; font-size: 13px; background: var(--brand-soft); color: var(--text); margin: 10px 0; }
.callout svg { flex: none; margin-top: 1px; }
.callout.crit { background: color-mix(in srgb, var(--st-fault) 10%, transparent); color: var(--st-fault); border: 1px solid color-mix(in srgb, var(--st-fault) 30%, transparent); }
.callout.warn { background: #fff6dd; color: #6d4a00; border: 1px solid #f3dc9a; }
:root[data-theme="dark"] .callout.warn { background: #352a10; color: #f5cd6b; border-color: #574317; }

/* fleet job progress */
#jobs:empty { display: none; }
#jobs { display: flex; flex-direction: column; gap: 8px; }
.job { display: grid; grid-template-columns: auto auto minmax(120px, 1fr) auto auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; }
.prog2 { height: 8px; background: var(--grid); border-radius: 5px; overflow: hidden; display: flex; }
.prog2 i { display: block; height: 100%; transition: width .2s; }

/* light cards */
.lcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; padding: 14px 18px; }
.lcard { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.lcard:hover { border-color: color-mix(in srgb, var(--brand) 60%, var(--border)); box-shadow: 0 2px 10px rgba(15,27,45,.06); }
.lcard.sel { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.lcard.is-off { background: var(--surface-2); }
.lc-h { display: flex; gap: 10px; align-items: flex-start; }
.lc-h input { margin-top: 3px; accent-color: var(--brand); }
.lc-state { display: flex; gap: 12px; align-items: center; }
.lc-word { font-weight: 700; font-size: 15px; }
.lamp { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--st-off); border: 1px solid var(--border); }
.lamp.st-on { background: color-mix(in srgb, var(--st-on) 16%, transparent); color: var(--st-on); box-shadow: 0 0 18px color-mix(in srgb, var(--st-on) 35%, transparent); border-color: transparent; }
.lamp.st-dimmed { background: color-mix(in srgb, var(--st-dim) 14%, transparent); color: var(--st-dim); border-color: transparent; }
.lamp.st-fault { background: color-mix(in srgb, var(--st-fault) 12%, transparent); color: var(--st-fault); border-color: transparent; }
.lamp.st-offline { color: var(--st-offline); border: 2px dashed var(--st-offline); background: transparent; }
.lamp.big { width: 72px; height: 72px; }
.lc-m { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lc-m div { background: var(--surface); padding: 6px 8px; }
.lc-m small { display: block; color: var(--muted); font-size: 10.5px; }
.lc-m b { font-size: 14px; font-variant-numeric: tabular-nums; } .lc-m b em { font-style: normal; font-size: 10.5px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.lc-ctl { display: flex; gap: 10px; align-items: center; cursor: default; }
.lc-ctl select { margin-left: auto; padding: 5px 8px; }
.lc-f { display: flex; gap: 8px; align-items: center; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 8px; }

/* detail page */
.crumbs { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.crumbs a { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.crumbs > span { color: var(--muted); } .crumbs .spacer { flex: 1; }
.dhead { align-items: start; }
.dtop { display: flex; gap: 16px; align-items: center; margin-bottom: 6px; }
.dctl { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 0; margin-top: 6px; border-top: 1px solid var(--border); }
.dctl .sep { width: 1px; height: 26px; background: var(--border); }
.switch.lg { width: 54px; height: 30px; }
.switch.lg span::before { width: 24px; height: 24px; }
.switch.lg input:checked + span::before { transform: translateX(24px); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.stat-grid.wide { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.stat .s-l { font-size: 11.5px; color: var(--muted); }
.stat .s-v { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 1px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 12px 14px 10px; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.dtab { padding: 16px 18px; }
.dtab > .grid { gap: 14px; }
.sub-h { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tline { position: relative; height: 26px; background: var(--grid); border-radius: 6px; overflow: hidden; }
.tline i { position: absolute; top: 0; bottom: 0; }
.week { display: grid; grid-template-columns: 40px repeat(24, minmax(14px, 1fr)); gap: 2px; font-size: 11px; }
.week .wd { color: var(--text-2); font-weight: 600; align-self: center; }
.week .wh { color: var(--muted); }
.week .wc { position: relative; height: 22px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 3px; }
.week .wc b { position: absolute; top: 3px; bottom: 3px; width: 4px; border-radius: 2px; }
pre.json { margin: 0; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; max-height: 420px; }
.tbl tr.selrow td { background: var(--brand-soft) !important; }
.danger-zone { border-color: color-mix(in srgb, var(--st-fault) 35%, var(--border)); }
.scroll-420 { max-height: 420px; overflow: auto; }
.tbl tfoot td { border-top: 2px solid var(--border); background: var(--surface-2); }

/* schedules */
.daypick { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.daypick button { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 4px 9px; font-size: 12px; cursor: pointer; }
.daypick button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.daypick button:disabled { opacity: .5; cursor: not-allowed; }
.choose { max-height: 420px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.cgh { font-size: 13px; margin-bottom: 4px; } .cgh a { font-size: 12px; }
.cgl { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.cgl label { display: flex; gap: 4px; align-items: center; font-size: 12px; padding: 3px 5px; border: 1px solid var(--border); border-radius: 5px; cursor: pointer; }
.cgl input { accent-color: var(--brand); margin: 0; }
.merr { display: none; margin-top: 10px; padding: 8px 10px; border-radius: 7px; font-size: 12.5px; color: var(--st-fault); background: color-mix(in srgb, var(--st-fault) 9%, transparent); }

/* reports */
.heat { display: grid; gap: 3px; align-items: center; font-size: 11.5px; }
.heat .hl a { font-weight: 600; text-decoration: none; }
.heat span { height: 20px; border-radius: 3px; }
.heat .hx { color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.h4 { background: #1baf7a; } .h3 { background: #8fd5b2; } .h2 { background: #f7c35c; } .h1 { background: #e0693f; }
:root[data-theme="dark"] .h4 { background: #199e70; } :root[data-theme="dark"] .h3 { background: #2f6b55; } :root[data-theme="dark"] .h2 { background: #9c7a26; } :root[data-theme="dark"] .h1 { background: #b0502c; }
.legend i.h1, .legend i.h2, .legend i.h3, .legend i.h4 { width: 12px; height: 12px; }
.avail { display: inline-block; padding: 1px 7px; border-radius: 10px; color: #0f1b2d; font-weight: 600; font-size: 12px; }
.avail.h4 { color: #fff; } .avail.h1 { color: #fff; }
a.sortlink { color: inherit; text-decoration: none; } a.sortlink.on { color: var(--brand-ink); }
.print-only { display: none; }
.print-head { align-items: center; gap: 16px; padding: 0 0 10px; border-bottom: 2px solid var(--brand); }
.print-head img { width: 180px; }

/* street map */
.osm { height: 620px; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; background: var(--surface-2); }
.osm .empty { padding-top: 120px; }

@media (max-width: 1200px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .job { grid-template-columns: 1fr auto; } .cgl { grid-template-columns: repeat(6, 1fr); } }


/* ===================== phones and tablets ===================== */
.menu-btn, .side-scrim { display: none; }
.top .ttl { min-width: 0; }
@media (max-width: 860px) {
  .app { display: block; }
  .side { position: fixed; top: 0; left: 0; bottom: 0; width: 272px; max-width: 86vw; height: 100%; z-index: 70; transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  .app.menu-open .side { transform: none; box-shadow: 10px 0 30px rgba(0,0,0,.3); }
  .app.menu-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(8, 15, 28, .45); z-index: 65; }
  .side a.nav { padding: 11px 12px; font-size: 14.5px; }
  .menu-btn { display: inline-flex; padding: 7px 9px; }
  .top { height: auto; min-height: 56px; gap: 8px; padding: 8px 12px; flex-wrap: wrap; }
  .top .ttl { flex: 1; }
  .top .spacer { display: none; }
  .top h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top .crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top .chip { font-size: 11.5px; padding: 4px 8px; }
  #astroChip, .user .who { display: none; }
  .content { padding: 12px 12px 32px; gap: 12px; }
  .grid { gap: 12px; }
  .g4, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 14px; overflow-x: auto; }
  .card.flush .card-h { padding: 12px 14px 0; }
  .card-h { flex-wrap: wrap; }
  .card-h .right { flex-wrap: wrap; }
  .toolbar { padding: 10px 12px; }
  .toolbar .search { min-width: 0; flex: 1 1 100%; }
  .toolbar select.input { flex: 1 1 140px; }
  .bulkbar, .pager { padding: 10px 12px; }
  .lcards { grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); padding: 12px; }
  .meter { grid-template-columns: repeat(2, 1fr); }
  .prod-card { grid-template-columns: 1fr; }
  .speclist { grid-template-columns: 1fr; }
  .cgl { grid-template-columns: repeat(4, 1fr); }
  .job { grid-template-columns: 1fr auto; }
  .dtop { flex-wrap: wrap; }
  .dctl .sep { display: none; }
  .dtab { padding: 12px; }
  .osm { height: 62vh; min-height: 320px; }
  .drawer { width: 100%; }
  .drawer .dh, .drawer .db { padding-left: 14px; padding-right: 14px; }
  .modal { width: calc(100% - 20px); max-height: calc(100% - 40px); overflow-y: auto; }
  .modal .mf { flex-wrap: wrap; }
  .toasts { left: 10px; right: 10px; bottom: 10px; }
  .toast { max-width: none; }
  .aitem { flex-wrap: wrap; }
  .aitem .when { margin-left: 0; text-align: left; }
  /* bigger touch targets; 16px inputs stop phones zooming in */
  .btn.sm { padding: 6px 10px; }
  .input, select.input, textarea.input, .toolbar .input { font-size: 16px; }
  .login-panel { padding: 24px 18px; }
  .login-card img.logo { width: 200px; margin-bottom: 20px; }
}
@media (max-width: 560px) {
  /* header: menu · title over live status · theme · sign out */
  .top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto auto; column-gap: 6px; row-gap: 2px; align-items: center; }
  .top .menu-btn { grid-column: 1; grid-row: 1 / 3; }
  .top .ttl { grid-column: 2; grid-row: 1; }
  .top #liveChip { grid-column: 2; grid-row: 2; justify-self: start; background: none; border: 0; padding: 0; }
  .top [data-act="theme"] { grid-column: 3; grid-row: 1 / 3; }
  .top [data-act="pw-own"] { grid-column: 4; grid-row: 1 / 3; }
  .top [data-act="logout"] { grid-column: 5; grid-row: 1 / 3; }
  .top .user { display: none; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px 12px; gap: 8px; flex-direction: column; }
  .tile .ic { width: 32px; height: 32px; }
  .tile .val { font-size: 21px; }
  .top .crumb { display: none; }
  .master .btn { padding: 12px 8px; font-size: 13.5px; }
  .seg { flex-wrap: wrap; }
}
@media (max-width: 380px) {
  .g4, .stat-grid { grid-template-columns: 1fr; }
}

@media print {
  .side, .top, .no-print, #toasts, #overlay, .readonly-banner, .pager, .toolbar .btn, .tile .go { display: none !important; }
  .app { display: block; } .content { padding: 0; }
  .print-only { display: flex !important; }
  body { background: #fff; }
  .card, .tile { box-shadow: none; break-inside: avoid; }
  .scroll-420, .tbl-wrap { max-height: none !important; overflow: visible !important; }
}
