:root {
  color-scheme: light;
  --bg: #f2f4f1;
  --surface: #ffffff;
  --surface-2: #f7f8f6;
  --ink: #1c2427;
  --muted: #5d6a6e;
  --faint: #8a9699;
  --line: #d8ded9;
  --soft: #e8ece8;
  --accent: #17706b;          /* interactive: nav, selected chips, buttons */
  --accent-soft: #dcefec;
  --truck: #b8730e;           /* dump truck series */
  --excavator: #3c6491;       /* excavator series */
  --absent: #7b52ab;          /* no excavator: purple, as in the hopper report */
  --person: #a2406b;          /* person series */
  --ok: #2c8a55;
  --warn: #b97a16;
  --danger: #b73838;
  --ok-soft: #e1f2e7;
  --warn-soft: #f8edd8;
  --danger-soft: #f8e1e1;
  --display: "Barlow Semi Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101517; --surface: #181f22; --surface-2: #1c2427; --ink: #e2e8e6; --muted: #9aa7aa;
    --faint: #6f7d80; --line: #2c3638; --soft: #222b2e; --accent: #4fb7ae; --accent-soft: #173734;
    --truck: #e0a03e; --excavator: #7da5d6; --person: #e07fa8; --absent: #b08ee0;
    --ok: #5cc28a; --warn: #e4ac4a; --danger: #ec7070;
    --ok-soft: #173326; --warn-soft: #3a2d14; --danger-soft: #3d1c1c;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--body); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--surface); }
.brand-text { display: grid; line-height: 1.2; }
.brand-text b { font: 700 17px var(--display); letter-spacing: .01em; }
.brand-text small { font: 500 10.5px var(--mono); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.nav { display: grid; gap: 4px; padding: 14px 10px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; border-left: 3px solid transparent; }
.nav a:hover { background: var(--soft); }
.nav a.active { background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent); }
.nav-badge { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font: 600 11px/20px var(--mono); text-align: center; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.sidebar-foot b { font: 600 10.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink); }
.sidebar-foot code { font: 400 11px var(--mono); word-break: break-all; }
/* Icons only unless opened (app.js): the same look as on a narrow screen. */
.app { transition: grid-template-columns .15s ease; }
.app.nav-collapsed { grid-template-columns: 64px minmax(0, 1fr); }
.app.nav-collapsed .brand-text, .app.nav-collapsed .nav-label, .app.nav-collapsed .sidebar-foot { display: none; }
.app.nav-collapsed .brand { justify-content: center; padding: 16px 8px; }
.app.nav-collapsed .nav { padding: 14px 6px; }
.app.nav-collapsed .nav a { justify-content: center; padding: 10px; position: relative; }
.app.nav-collapsed .nav-badge { position: absolute; top: 2px; right: 2px; margin: 0; min-width: 18px; padding: 0 4px; font-size: 10px; line-height: 16px; }
.nav-toggle { align-self: flex-end; margin: 6px 10px 0; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 6px; width: 28px; height: 24px; cursor: pointer; font: 600 14px/1 var(--mono); }
.app.nav-collapsed .nav-toggle { align-self: center; margin: 6px 0 0; }
.nav-toggle:hover { background: var(--soft); color: var(--ink); }
.app.nav-collapsed .nav-toggle-close, .app:not(.nav-collapsed) .nav-toggle-open { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font: 700 22px var(--display); }
.spacer { flex: 1; }
.clock { font-size: 14px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; color: var(--muted); background: var(--surface); }
.pill.mode .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.pill.mode.live { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.pill.mode.live .dot { background: var(--ok); animation: pulse 2s infinite; }
.pill.mode.demo { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.pill.mode.demo .dot { background: var(--warn); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .pill.mode.live .dot { animation: none; } }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; font-size: 13px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.ghost { background: transparent; }

.content { padding: 22px 24px 48px; display: grid; gap: 18px; align-content: start; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font: 700 18px var(--display); }
.panel-note { font-size: 12px; color: var(--faint); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.stack { display: grid; gap: 18px; min-width: 0; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 6px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-value { display: flex; align-items: baseline; gap: 6px; }
.kpi-value b { font: 600 30px var(--mono); letter-spacing: -.02em; }
.kpi-value span { color: var(--muted); font-size: 13px; }
.kpi-foot { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.kpi-foot svg { flex: none; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 13px; }
.chip .count { font: 500 11px var(--mono); color: var(--muted); }
.chip:hover { border-color: var(--accent); }
.chip.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.selected .count { color: var(--accent); }

/* ---------- tags ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.truck { background: color-mix(in srgb, var(--truck) 16%, transparent); color: var(--truck); }
.tag.excavator { background: color-mix(in srgb, var(--excavator) 16%, transparent); color: var(--excavator); }
.tag.person { background: color-mix(in srgb, var(--person) 16%, transparent); color: var(--person); }
.tag.light { background: var(--soft); color: var(--muted); }
.tag.high { background: var(--danger-soft); color: var(--danger); }
.tag.medium { background: var(--warn-soft); color: var(--warn); }
.tag.low { background: var(--soft); color: var(--muted); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.mono { font-family: var(--mono); font-size: 11.5px; background: var(--soft); color: var(--ink); }

/* ---------- events ---------- */
.events { display: grid; max-height: 640px; overflow-y: auto; }
.event { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 9px 2px; border-bottom: 1px solid var(--soft); font-size: 13px; }
.event:last-child { border-bottom: 0; }
.event.fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: transparent; } }
.event .ev-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; }
.ev-icon.truck { background: color-mix(in srgb, var(--truck) 15%, transparent); color: var(--truck); }
.ev-icon.excavator { background: color-mix(in srgb, var(--excavator) 15%, transparent); color: var(--excavator); }
.ev-icon.person { background: color-mix(in srgb, var(--person) 15%, transparent); color: var(--person); }
.ev-icon.light { background: var(--soft); color: var(--muted); }
.event .ev-sub { color: var(--muted); font-size: 12px; }
.event time { font: 400 12px var(--mono); color: var(--faint); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--soft); vertical-align: middle; }
td.r, th.r { text-align: right; }
tr:hover td { background: var(--surface-2); }

/* ---------- alerts ---------- */
.queue { display: grid; }
.alert-row { display: grid; grid-template-columns: auto auto minmax(180px, 1fr) 120px auto auto auto; gap: 12px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--soft); font-size: 13px; }
.alert-row:last-child { border-bottom: 0; }
.conf { display: flex; align-items: center; gap: 8px; font: 400 12px var(--mono); color: var(--muted); }
.conf-bar { flex: 1; height: 5px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.conf-bar i { display: block; height: 100%; background: var(--ok); }
.conf-bar.low i { background: var(--danger); }
.cam { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; background: var(--soft); font: 400 11.5px var(--mono); white-space: nowrap; }
.panel.review { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.panel.review > .panel-head { background: var(--danger-soft); margin: -16px -18px 12px; padding: 12px 18px; border-radius: var(--radius) var(--radius) 0 0; }
.count-badge { font: 600 11.5px var(--mono); padding: 1px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }

/* ---------- cameras ---------- */
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.cam-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; }
.cam-card h3 { margin: 0; font: 600 13px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cam-card .cam-status { white-space: nowrap; flex: none; }
.cam-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.cam-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.cam-status.active .dot { background: var(--ok); }
.cam-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cam-counts div { background: var(--surface-2); border-radius: 7px; padding: 6px 8px; display: grid; }
.cam-counts b { font: 600 18px var(--mono); }
.cam-counts span { font-size: 11.5px; color: var(--muted); }
.cam-links { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }

/* ---------- player ---------- */
.player { position: relative; background: #0b0f10; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; max-height: 62vh; display: grid; place-items: center; }
.player video { width: 100%; height: 100%; object-fit: contain; display: block; }
.player-msg { position: absolute; inset: auto 12px 12px 12px; padding: 8px 12px; border-radius: 6px; background: rgba(0, 0, 0, .65); color: #e8eeec; font-size: 13px; }
.btn.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: var(--soft); }
.chart .axis text { fill: var(--faint); font: 400 11px var(--mono); }
.chart .val { fill: var(--muted); font: 400 11px var(--mono); }
.chart .lab { fill: var(--ink); font: 400 12.5px var(--body); }
.bar-truck { fill: var(--truck); }
.bar-excavator { fill: var(--excavator); }
.bar-person { fill: var(--person); }
.bar-light { fill: var(--faint); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.cells rect { rx: 2px; }
.cell-0 { fill: var(--soft); }
.cell-truck { fill: var(--truck); }
.cell-person { fill: var(--person); }
.cell-both { fill: var(--danger); }
.cell-excavator { fill: var(--excavator); }

.empty { padding: 28px 10px; text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.empty b { color: var(--ink); font-weight: 600; }

/* ---------- photo pop-up ---------- */
.photo-back { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(8, 12, 14, .72); }
.photo-back[hidden] { display: none; }
.photo-dialog { width: min(1200px, 100%); max-height: calc(100vh - 32px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.photo-head { display: flex; align-items: center; gap: 10px; }
.photo-head h2 { margin: 0; font: 700 18px var(--display); }
.photo-frame { position: relative; display: grid; place-items: center; min-height: 200px; background: #0b0f10; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; max-height: calc(100vh - 160px); }
.photo-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-msg { position: absolute; color: #e8eeec; font-size: 13px; }
.photo-note { font-size: 13px; color: var(--muted); }
.link-btn { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

/* ---------- evaluation ---------- */
.eval-kpi.ok .kpi-value b { color: var(--ok); }
.eval-kpi.warn .kpi-value b { color: var(--warn); }
.eval-kpi.rate .kpi-value b { color: var(--accent); }
.eval-id { font: 600 13px var(--mono); }
.eval-id.read { color: var(--accent); }
.eval-id.unregistered { color: var(--warn); }
.eval-id.none { color: var(--danger); }
.thumb { padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #0b0f10; cursor: zoom-in; display: block; width: 120px; aspect-ratio: 16 / 9; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.eval-table td { vertical-align: middle; }
.axis-t { fill: var(--faint); font: 400 11px var(--mono); }
.bar-good { fill: var(--ok); } .bar-mid { fill: var(--warn); } .bar-bad { fill: var(--danger); } .bar-empty { fill: var(--soft); }
.legend .bar-good-i { background: var(--ok); } .legend .bar-mid-i { background: var(--warn); } .legend .bar-bad-i { background: var(--danger); }

/* ---------- fleet register ---------- */
.reg-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reg-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 14px; align-items: end; }
.reg-form .panel-head, .reg-form .wide, .reg-form .reg-actions { grid-column: 1 / -1; }
.reg-form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.reg-form input, .reg-form select, .reg-form textarea { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; min-width: 0; }
.reg-form textarea { font-family: var(--mono); resize: vertical; }
.reg-form input:focus, .reg-form select:focus, .reg-form textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.reg-actions { display: flex; gap: 8px; }

/* ---------- admin ---------- */
.algo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.algo { display: grid; align-content: start; gap: 4px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.algo b { font-weight: 600; }
.algo span { color: var(--muted); }
.algo small { color: var(--faint); font-size: 12px; }
.search { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; min-width: 0; width: 180px; }
.search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.admin-msg { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); font-size: 13px; }
.admin-msg.error { background: var(--danger-soft); color: var(--danger); }
.admin-msg.view-only { background: var(--warn-soft); color: var(--warn); }
.admin-table th.c, .admin-table td.c { text-align: center; }
.admin-table tr.busy td { opacity: .55; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled { cursor: progress; }
@media (prefers-reduced-motion: reduce) { .switch span, .switch span::after { transition: none; } }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .alert-row { grid-template-columns: auto auto 1fr; }
  .alert-row .conf, .alert-row .cam, .alert-row time { grid-column: span 1; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 64px minmax(0, 1fr); }
  .brand-text, .nav-label, .sidebar-foot { display: none; }
  .nav a { justify-content: center; padding: 10px; }
  .nav-badge { position: absolute; margin: -22px 0 0 22px; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px; }
}

/* Excavators page */
.exc-live-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
#exc-side .exc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#exc-setup { margin-top: 12px; }
@media (max-width: 900px) { .exc-live-grid { grid-template-columns: 1fr; } }
.exc-player { position: relative; }
.exc-zones { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: auto; }
.exc-zones.drawing { cursor: crosshair; }
.z-dump { fill: rgba(214, 69, 69, .14); stroke: #e05252; stroke-width: 4; vector-effect: non-scaling-stroke; }
.z-dig { fill: rgba(60, 170, 100, .14); stroke: #3fb46c; stroke-width: 4; vector-effect: non-scaling-stroke; }
.z-dump-l, .z-dig-l { font: 700 34px var(--display); paint-order: stroke; stroke: rgba(0, 0, 0, .55); stroke-width: 6px; }
.z-dump-l { fill: #ff8a8a; } .z-dig-l { fill: #8ce3ae; }
.z-dump-t { color: #d04545; } .z-dig-t { color: #2f9a58; }
.exc-setup { display: grid; gap: 12px; font-size: 13.5px; }
.exc-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.exc-dl dt { color: var(--muted); } .exc-dl dd { margin: 0; }
.exc-edit { display: grid; gap: 10px; }
.exc-edit label { display: grid; grid-template-columns: 1fr 110px; align-items: center; gap: 8px; }
.exc-edit input { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.exc-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; }
.kpi-unit { font-size: 14px; color: var(--muted); font-weight: 500; }
.eval-kpi.bad .kpi-value b { color: var(--danger); }
.dot-cycle { fill: var(--excavator); opacity: .75; }
.line-median { fill: none; stroke: var(--warn); stroke-width: 2; }
.ph-dig { fill: #8a6a3d; } .ph-swl { fill: var(--excavator); } .ph-dump { fill: var(--danger); } .ph-swe { fill: #93b4d9; } .ph-still { fill: var(--soft); }
.legend .ph-dig-i { background: #8a6a3d; } .legend .ph-swl-i { background: var(--excavator); } .legend .ph-dump-i { background: var(--danger); }
.legend .ph-swe-i { background: #93b4d9; } .legend .ph-still-i { background: var(--soft); border: 1px solid var(--line); }
.st-working { fill: var(--ok); } .st-idle { fill: var(--warn); } .st-absent { fill: var(--soft); }
.legend .st-working-i { background: var(--ok); } .legend .st-idle-i { background: var(--warn); } .legend .st-absent-i { background: var(--soft); border: 1px solid var(--line); }
.bar-idle { fill: var(--warn); }

/* Excavators: site tiles, live meter, states */
.exc-kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.exc-kpis .kpi-value { flex-wrap: wrap; row-gap: 0; }
.exc-kpis .kpi-value b { font-size: clamp(20px, 2vw, 26px); overflow-wrap: anywhere; }
.exc-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: 18px; }
@media (max-width: 640px) { .exc-tiles { grid-template-columns: 1fr; } }
.exc-tile .panel-head { align-items: center; }
.exc-tile-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 12px; }
@media (max-width: 520px) { .exc-tile-grid { grid-template-columns: 1fr; } }
.exc-tile-photo { position: relative; padding: 0; border: 0; background: #0b0f10; border-radius: 8px; overflow: hidden; cursor: pointer; aspect-ratio: 16 / 10; display: grid; place-items: center; }
.exc-tile-photo img, .exc-tile-photo video { width: 100%; height: 100%; object-fit: cover; display: block; }
.exc-vid { position: absolute; inset: 0; }
.exc-tile-zones { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.exc-tile { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.exc-tile:hover, .exc-tile:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); outline: none; }
.exc-line { display: grid; gap: 10px; }
.exc-line-h { margin: 6px 0 0; font: 700 13px var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.exc-badges { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.exc-badge.view-helper, .exc-badge.view-blocked { color: var(--warn); border-style: dashed; }
.kpi.absent .kpi-value b { color: var(--absent); }
.exc-hours td.hg-hidden button { outline: 2px dotted var(--muted); outline-offset: -3px; }
.btn.small.on { border-color: var(--accent); color: var(--accent); }
.exc-tile-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.exc-stat { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: grid; gap: 2px; min-width: 0; }
.exc-stat span { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.exc-stat b { font: 700 clamp(14px, 1.4vw, 19px) var(--display); overflow-wrap: anywhere; line-height: 1.15; }
.exc-stat small { font-size: 11.5px; color: var(--faint); overflow-wrap: anywhere; }
.exc-stat span { overflow-wrap: anywhere; }
.exc-strip { display: grid; grid-template-columns: repeat(60, 1fr); gap: 2px; margin-top: 12px; height: 16px; }
.exc-strip i { border-radius: 2px; background: var(--soft); }
.exc-strip i.st-working { background: var(--ok); } .exc-strip i.st-idle { background: var(--warn); }
.exc-strip i.st-absent { background: var(--absent); opacity: .75; } .exc-strip i.st-nodata { background: var(--faint); opacity: .5; }
/* Bar charts: each bar's number, the average line. */
.chart .bar-value { font: 600 10px var(--mono); fill: var(--ink); }
.chart .avg-line { stroke: var(--danger); stroke-width: 1.6; stroke-dasharray: 6 4; }
.chart .avg-label { font: 700 11px var(--mono); fill: var(--danger); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.range-select { display: inline-flex; align-items: center; gap: 8px; }
.range-select select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px; }
/* Excavators: hour-by-hour grid (feeders x hours). */
.exc-hours { border-collapse: separate; border-spacing: 3px; width: auto; }
.exc-hours th { font: 600 11px var(--mono); color: var(--faint); text-align: center; white-space: nowrap; padding: 2px 4px; border: 0; }
.exc-hours tbody th { text-align: left; color: var(--text); font-family: inherit; font-size: 12px; padding-right: 10px; }
.exc-hours th.hg-now { color: var(--accent); }
.exc-hours td { padding: 0; border: 0; border-radius: 4px; background: var(--soft); min-width: 44px; }
.exc-hours td button { all: unset; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; min-height: 40px; padding: 3px 4px; cursor: pointer; border-radius: 4px; }
.exc-hours td button:hover, .exc-hours td button:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
.exc-hours td b { font: 700 14px var(--mono); line-height: 1.1; }
.exc-hours td small { font-size: 10px; opacity: .8; }
.exc-hours td.hg-ok { background: color-mix(in srgb, var(--ok) 30%, transparent); }
.exc-hours td.hg-warn { background: color-mix(in srgb, var(--warn) 32%, transparent); }
.exc-hours td.hg-bad { background: color-mix(in srgb, var(--danger) 30%, transparent); }
.exc-hours td.hg-absent { background: color-mix(in srgb, var(--absent) 26%, transparent); }
.exc-hours td.hg-nodata { background: repeating-linear-gradient(45deg, var(--soft), var(--soft) 4px, transparent 4px, transparent 8px); }
.exc-hours tr.hg-total td { background: none; text-align: center; padding: 4px; }
.range-hour select.range-date { min-width: 120px; }
.exc-strip-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 4px; font-family: var(--mono); }
.exc-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .04em; border: 1px solid currentColor; }
.exc-badge.st-working { color: var(--ok); } .exc-badge.st-idle { color: var(--warn); }
.exc-badge.st-absent { color: var(--absent); } .exc-badge.st-nodata { color: var(--faint); }
.st-nodata { fill: var(--faint); opacity: .5; } .st-absent { fill: var(--absent); opacity: .75; }
.legend .st-nodata-i { background: var(--faint); opacity: .5; } .legend .st-absent-i { background: var(--absent); opacity: .75; border: 0; }
.exc-meter { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.exc-meter-in { display: inline-flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.exc-meter-in b { font: 700 15px var(--display); color: var(--ink); }
.exc-meter-bar { display: inline-block; width: 140px; height: 10px; border-radius: 3px; background: var(--soft); position: relative; overflow: hidden; }
.exc-meter-bar i { position: absolute; inset: 0 auto 0 0; background: var(--excavator); }
.exc-meter-in.compact { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; background: rgba(0, 0, 0, .62); color: #dfe6e4; justify-content: flex-start; }
.exc-meter-in.compact b { color: #fff; font-size: 13px; }
.exc-meter-in.compact .exc-meter-bar { width: 80px; background: rgba(255, 255, 255, .2); }
.dump-tick { stroke: var(--danger); stroke-width: 1.5; }
.legend .dump-tick-i { background: var(--danger); width: 3px; }
.exc-review { display: inline-flex; gap: 6px; }
.rv { width: 28px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; color: var(--muted); }
.rv.ok.on { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.rv.no.on { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.muted-row td { opacity: .5; }
button.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; }

/* Safety page */
.safety-kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.ppe-ok { fill: var(--ok); } .ppe-helmet { fill: var(--danger); } .ppe-vest { fill: var(--warn); }
.ppe-both { fill: #7a2323; } .ppe-unk { fill: var(--soft); } .ppe-bad { fill: var(--danger); }
.legend .ppe-ok-i { background: var(--ok); } .legend .ppe-helmet-i { background: var(--danger); } .legend .ppe-vest-i { background: var(--warn); }
.legend .ppe-both-i { background: #7a2323; } .legend .ppe-unk-i { background: var(--soft); border: 1px solid var(--line); }

/* Reports page */
.rep-form { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; display: grid; gap: 12px; background: var(--bg); }
.rep-form h3 { margin: 0; font: 700 16px var(--display); }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.rep-form label, .rep-quick label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.rep-form input[type=text], .rep-form input[type=time], .rep-form select, .rep-form textarea, .rep-quick select {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px; }
.rep-form textarea { resize: vertical; }
.rep-wide { display: grid; gap: 6px; }
.rep-label { font-size: 12.5px; color: var(--muted); }
.rep-check { display: flex !important; grid-auto-flow: column; align-items: center; gap: 8px !important; color: var(--ink) !important; }
.rep-quick { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.rep-form .chip { cursor: pointer; }

/* ---------- period and area filters (range.js) ---------- */
.filters { display: grid; gap: 10px; }
.range-date { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }
.range-date:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.range-span { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.search-box { width: min(100%, 340px); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; }
.search-box:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Conveyors page (js/pages/conveyors.js): belts running / stopped / no data. */
.bs-running { fill: var(--ok); } .bs-stopped { fill: var(--warn); } .bs-nodata { fill: var(--faint); opacity: .5; }
.bs-none { fill: var(--soft); }
.legend .bs-running-i { background: var(--ok); } .legend .bs-stopped-i { background: var(--warn); }
.legend .bs-nodata-i { background: var(--faint); opacity: .5; } .legend .bs-none-i { background: var(--soft); border: 1px solid var(--line); }
.cv-strip i.bs-running { background: var(--ok); } .cv-strip i.bs-stopped { background: var(--warn); }
.cv-strip i.bs-nodata { background: var(--faint); opacity: .5; } .cv-strip i.bs-none { background: var(--soft); }
.cv-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .04em; border: 1px solid currentColor; white-space: nowrap; }
.cv-badge.bs-running, .cv-badge.bs-ok { color: var(--ok); } .cv-badge.bs-stopped { color: var(--warn); }
.cv-badge.bs-nodata, .cv-badge.bs-unknown { color: var(--faint); } .cv-badge.bs-problem { color: var(--danger); }
.cv-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(560px, 1fr)); gap: 18px; }
@media (max-width: 680px) { .cv-tiles { grid-template-columns: 1fr; } }
.cv-tile .panel-head { align-items: center; gap: 8px; }
.cv-tile-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; align-items: start; }
@media (max-width: 680px) { .cv-tile-grid { grid-template-columns: 1fr; } }
.cv-belts { display: grid; gap: 12px; }
.cv-belt { display: grid; gap: 6px; }
.cv-belt-head { display: flex; align-items: center; gap: 8px; }
.cv-belt-head b { font-size: 14px; }
.cv-belt-sub { font-size: 12px; color: var(--muted); }
.cv-belt .exc-strip { margin-top: 2px; height: 12px; }
.cv-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cv-c0 { background: #ff9f1a; } .cv-c1 { background: #22c3e6; }
.cv-now-belt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.cv-now-belt small { color: var(--muted); }
.cv-still { width: 100%; height: 100%; object-fit: contain; display: block; }
.cv-tl-label { font-size: 12px; fill: var(--ink); }
.z-belt { stroke-width: 4; vector-effect: non-scaling-stroke; }
.z-belt0 { fill: rgba(255, 159, 26, .06); stroke: #ff9f1a; } .z-belt1 { fill: rgba(34, 195, 230, .06); stroke: #22c3e6; }
.z-belt-l { font: 700 30px var(--display); paint-order: stroke; stroke: rgba(0, 0, 0, .6); stroke-width: 6px; }
.z-belt0-l { fill: #ffc06a; } .z-belt1-l { fill: #8fe3f5; }
.z-check { fill: rgba(200, 80, 200, .06); stroke: #d070d0; stroke-width: 3; stroke-dasharray: 8 6; vector-effect: non-scaling-stroke; }
.z-draft { fill: none; stroke: #fff; stroke-width: 3; stroke-dasharray: 10 6; vector-effect: non-scaling-stroke; }
.z-draft-pt { fill: #fff; stroke: #000; stroke-width: 2; vector-effect: non-scaling-stroke; }
.cv-setup-belt { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 8px; }
.cv-setup-belt .panel-note { grid-column: 2; }
.cv-edit fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; margin: 0; }
.cv-edit fieldset[disabled] { opacity: .55; }
.cv-edit legend { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px; font-weight: 600; font-size: 13px; }
.cv-edit label { display: grid; grid-template-columns: 1fr 150px; align-items: center; gap: 8px; }
.cv-edit input { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.cv-hour b { display: block; font-size: 14px; } .cv-hour small { display: block; font-size: 11px; color: var(--faint); white-space: nowrap; }
.cv-hour.ok b { color: var(--ok); } .cv-hour.warn b { color: var(--warn); } .cv-hour.bad b { color: var(--danger); }
.cv-dot.cv-danger { background: #e04545; }
.z-danger { fill: rgba(224, 69, 69, .06); stroke: #e04545; stroke-width: 3; stroke-dasharray: 12 6; vector-effect: non-scaling-stroke; }
.z-danger-l { font: 700 28px var(--display); fill: #ff9a9a; paint-order: stroke; stroke: rgba(0, 0, 0, .6); stroke-width: 6px; }
.cv-dot.cv-chute { background: #ffd23f; }
.z-chute { fill: rgba(255, 210, 63, .08); stroke: #ffd23f; stroke-width: 3; stroke-dasharray: 4 5; vector-effect: non-scaling-stroke; }
.z-chute-l { font: 700 28px var(--display); fill: #ffe38a; paint-order: stroke; stroke: rgba(0, 0, 0, .6); stroke-width: 6px; }
.cv-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; }
.cv-edit label.cv-check { display: inline-flex; grid-template-columns: none; align-items: center; gap: 5px; }
.cv-danger-now { font-weight: 600; animation: pulse 2s infinite; }
.cv-tile-photo { aspect-ratio: 16 / 9; }
.cv-tile-photo img { object-fit: fill; }
.cv-tile-zones { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cv-tile-zones .z-belt, .cv-tile-zones .z-danger, .cv-tile-zones .z-check, .cv-tile-zones .z-chute { stroke-width: 2; }
.cv-outline-toggle { gap: 6px; }
.bs-light { fill: #8fd1a8; } .legend .bs-light-i { background: #8fd1a8; }
.cv-strip i.bs-light { background: #8fd1a8; }
.cv-badge.bs-light { color: #3c9a62; border-style: dashed; }
.cv-stats4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Admin: the AI shift review's settings */
.review-form { display: grid; gap: 12px; margin: 4px 0 16px; font-size: 13px; }
.review-form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: grid; gap: 6px; margin: 0; }
.review-form legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
.review-form label { display: flex; gap: 8px; align-items: center; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.review-grid label, .review-form label.wide { flex-direction: column; align-items: stretch; gap: 4px; color: var(--muted); }
.review-form select, .review-form input[type=number], .review-form input[type=text], .review-form input[type=password], .review-form input[type=time], .review-form textarea {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.review-form .switch-row { gap: 10px; }
.rule-editor { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 6px 0 16px; background: var(--surface); }
.rule-editor h3 { margin: 0; font-size: 14px; }
.rule-cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 12px; margin-top: 6px; }
.rule-cams[hidden] { display: none; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding-left: 10px; border-left: 1px solid var(--line); }
.user-chip[hidden] { display: none; }
.user-name { font-weight: 600; color: var(--ink); font-size: 13px; }
.user-role { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.nav a[hidden] { display: none; }
.reg-bar .switch-row { display: inline-flex; align-items: center; gap: 10px; }
/* The customer portal (role "user"): no back-end extras. */
body.role-user #export-btn, body.role-user #mode-pill, body.role-user #source-note, body.role-user .tech { display: none !important; }
.muted-row td { color: var(--faint); }

/* ---- the smelter layout (js/layout.js) ---- */
.lay-mode .chip { display: inline-flex; align-items: center; gap: 6px; }
.lay-cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.lay-wrap { padding-top: 16px; }
.lay-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lay-head h2 { margin: 0; font: 700 20px var(--display); }
.lay-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.lay-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lay-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--lay-c); }
.lay-key.lay-soon { background: #dde1df; border: 1px dashed #aab2b0; }
.lay-canvas { width: 100%; overflow-x: auto; }
.lay-svg { width: 100%; min-width: 900px; height: auto; display: block; }
.lay-run { --lay-c: #4f9a2c; } .lay-stop { --lay-c: #d9443d; } .lay-nosig { --lay-c: #9aa4a6; } .lay-soon { --lay-c: #d3d8d6; }
/* The mimic (js/layout.js): ISA-101 style -- grey equipment on a neutral ground, colour for state only. */
.hmi { --hmi-flow: #fff; --hmi-bg: #e3e6e5; --hmi-area: #eceeed; --hmi-eq: #c4c9c8; --hmi-stroke: #5d6567; --hmi-text: #2c3436; --hmi-dim: #6e7779; --hmi-run: #59636a; }
.lay-svg.hmi { min-width: 980px; border-radius: 6px; }
.hmi-bg { fill: var(--hmi-bg); }
.hmi-area { fill: var(--hmi-area); stroke: #b4bbba; stroke-width: 1; }
.hmi-area-tab { fill: #4f585a; }
.hmi-area-t { font: 600 13px var(--mono); letter-spacing: .08em; fill: #fff; }
.hmi-in { fill: none; stroke: var(--hmi-dim); stroke-width: 2; }
.hmi-eq { fill: var(--hmi-eq); stroke: var(--hmi-stroke); stroke-width: 1.5; }
.hmi-tyre, .hmi-elec { fill: #8d9597; stroke: var(--hmi-stroke); stroke-width: 1; }
.hmi-line { fill: none; stroke: var(--hmi-stroke); stroke-width: 1.5; }
.hmi-name { font: 600 13px var(--mono); letter-spacing: .06em; fill: var(--hmi-text); }
.hmi-sub { font: 400 13px var(--body); fill: var(--hmi-dim); }
.hmi-nofeed .hmi-eq { fill: #d6d9d8; stroke-dasharray: 4 3; }
.hmi-alarm { fill: #e0a526; } .hmi-alarm-t { font: 700 12px var(--mono); letter-spacing: .06em; fill: #1f2324; }
.hmi-conv { fill: #fff; stroke: var(--hmi-stroke); stroke-width: 1.5; }
.hmi-pulley { fill: var(--hmi-stroke); }
.lay-run .hmi-conv { fill: var(--hmi-run); }
.hmi-flow { stroke: var(--hmi-flow); stroke-width: 3; stroke-dasharray: 8 8; animation: hmi-flow .8s linear infinite; }
@keyframes hmi-flow { to { stroke-dashoffset: -16; } }
@media (prefers-reduced-motion: reduce) { .hmi-flow { animation: none; } }
.lay-stop .hmi-conv { fill: #fff; stroke: #c4302b; stroke-width: 2.5; }
.lay-nosig .hmi-conv { fill: #d3d7d6; stroke-dasharray: 3 3; }
.lay-soon .hmi-conv { fill: none; stroke: #9aa3a4; stroke-dasharray: 5 4; } .lay-soon .hmi-pulley { fill: #9aa3a4; }
.hmi-tag { font: 700 14px var(--mono); fill: var(--hmi-text); }
.lay-soon .hmi-tag { fill: #8b9496; }
.hmi-state { fill: #fff; stroke: var(--lay-c); stroke-width: 1.5; }
.hmi-state-t { font: 700 11px var(--mono); letter-spacing: .06em; fill: var(--lay-c); }
.lay-run .hmi-state-t { fill: #2f7a12; }
.lay-stop .hmi-state { fill: #c4302b; stroke: #c4302b; } .lay-stop .hmi-state-t { fill: #fff; }
.lay-nosig .hmi-state { fill: #eceeed; stroke: #8b9496; } .lay-nosig .hmi-state-t { fill: #5d6567; }
.lay-soon .hmi-state { fill: none; stroke: #a8b0b0; stroke-dasharray: 3 2; } .lay-soon .hmi-state-t { fill: #8b9496; }
.hmi-hit { fill: transparent; }
.lay-click:hover .hmi-hit, .lay-click:focus-visible .hmi-hit { fill: rgba(23, 112, 107, .12); stroke: var(--accent); stroke-width: 1.5; }
.lay-click { cursor: pointer; }
.lay-click:focus-visible { outline: none; }
.hmi-key { width: auto; height: auto; padding: 2px 7px; border-radius: 2px; font: 700 10.5px var(--mono); font-style: normal; letter-spacing: .06em;
  background: #fff; color: var(--lay-c); border: 1.5px solid var(--lay-c); }
.lay-run .hmi-key { color: #2f7a12; }
.lay-stop .hmi-key { background: #c4302b; border-color: #c4302b; color: #fff; }
.lay-nosig .hmi-key { background: #eceeed; border-color: #8b9496; color: #5d6567; }
.lay-soon .hmi-key { background: transparent; border: 1.5px dashed #a8b0b0; color: #8b9496; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hmi { --hmi-flow: #1d2426; --hmi-bg: #1d2426; --hmi-area: #232b2d; --hmi-eq: #5b6466; --hmi-stroke: #a9b2b3; --hmi-text: #dfe5e4; --hmi-dim: #9aa5a6; --hmi-run: #a9b2b3; } }
:root[data-theme="dark"] .hmi { --hmi-flow: #1d2426; --hmi-bg: #1d2426; --hmi-area: #232b2d; --hmi-eq: #5b6466; --hmi-stroke: #a9b2b3; --hmi-text: #dfe5e4; --hmi-dim: #9aa5a6; --hmi-run: #a9b2b3; }
.lay-hint { margin: 6px 0 0; }
.lay-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.lay-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.lay-row:first-of-type { border-top: 0; }
.lay-row-id { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 52px; }
.lay-row-name { flex: 1; color: var(--ink); }
.lay-row.lay-click:hover .lay-row-name { color: var(--accent); }
.lay-pill { display: inline-block; padding: 3px 11px; border-radius: 7px; font-size: 13px; font-weight: 500;
  color: var(--lay-c); background: color-mix(in srgb, var(--lay-c) 14%, transparent); }
.lay-soon.lay-pill, .lay-nosig.lay-pill { color: #6b7577; background: #eef0ef; }
.lay-backdrop { position: fixed; inset: 0; background: rgba(16, 21, 23, .32); z-index: 40; }
.lay-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); z-index: 41;
  box-shadow: -12px 0 30px rgba(0, 0, 0, .14); padding: 22px 24px; overflow-y: auto; display: grid; align-content: start; gap: 12px; }
.lay-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.lay-panel-head h2 { font: 700 26px var(--display); margin: 0; }
.lay-panel-name { margin: 2px 0 8px; color: var(--muted); }
.lay-panel h3 { font: 700 15px var(--display); margin: 6px 0 0; }
.lay-since { margin: 0; font-size: 14px; color: var(--muted); }
.lay-since b { color: var(--ink); }
.lay-player { aspect-ratio: 16 / 9; background: #0b0f10; border-radius: 10px; overflow: hidden; position: relative; display: grid; place-items: center; }
.lay-player video, .lay-player img { width: 100%; height: 100%; object-fit: cover; }
.lay-strip { position: relative; height: 18px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.lay-strip i { position: absolute; top: 0; bottom: 0; background: var(--lay-c); }
.lay-strip-axis { display: flex; justify-content: space-between; font: 500 11px var(--mono); color: var(--faint); }
.lay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.lay-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.lay-card.lay-click:hover { border-color: var(--accent); }
.lay-card-pic { aspect-ratio: 16 / 9; background: #e7ebe9; display: grid; place-items: center; color: var(--muted); font-weight: 600; }
.lay-card-pic img { width: 100%; height: 100%; object-fit: cover; }
.lay-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; }
.lay-card-foot b { font: 700 16px var(--display); display: block; }
.lay-card-foot small { color: var(--muted); }

/* ---- the customer's alerts (pages/myalerts.js) ---- */
.usage-h { margin: 4px 0 8px; font: 700 14px var(--display); color: var(--muted); }
/* Alert page: compact cards in a grid, and the step-by-step modal. */
.ma-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.ma-card { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 14px 14px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ma-card.ma-off { opacity: .55; }
.ma-card.ma-off:hover, .ma-card.ma-off:focus-within { opacity: .85; }
.ma-card-head { display: flex; align-items: center; gap: 10px; }
.ma-type { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--accent); background: var(--accent-soft); }
.ma-name { flex: 1; min-width: 0; font: 700 16px var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ma-toggle { flex: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.ma-card:not(.ma-off) .ma-state { color: var(--accent); }
.ma-rule { margin: 4px 0 0; font-size: 14px; }
.ma-line { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--muted); }
.ma-line svg { flex: none; }
.ma-chs { margin-left: auto; display: inline-flex; gap: 4px; color: var(--ink); }
.ma-ch { display: inline-grid; place-items: center; }
.ma-card-actions { display: flex; justify-content: flex-end; gap: 2px; margin-top: 2px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover, .icon-btn:focus-visible { color: var(--ink); background: var(--soft); }
.icon-btn.danger:hover, .icon-btn.danger:focus-visible { color: var(--danger); background: var(--danger-soft); }
.ma-backdrop { position: fixed; inset: 0; background: rgba(16, 21, 23, .36); z-index: 50; }
.ma-modal { position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 32px)); max-height: calc(100% - 32px);
  display: grid; grid-template-rows: auto auto 1fr auto; background: var(--surface); border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .22); outline: none; overflow: hidden; }
.ma-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 4px; }
.ma-modal-head h3 { margin: 0; font: 700 20px var(--display); }
.ma-steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 8px 18px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--faint); flex-wrap: wrap; }
.ma-steps li { display: inline-flex; align-items: center; gap: 6px; }
.ma-steps li + li::before { content: ""; width: 14px; height: 1px; background: var(--line); }
.ma-steps span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); font-size: 11px; font-weight: 600; }
.ma-steps li.on { color: var(--ink); font-weight: 600; }
.ma-steps li.on span { background: var(--accent); border-color: var(--accent); color: #fff; }
.ma-steps li.done span { border-color: var(--accent); color: var(--accent); }
.ma-modal-body { overflow-y: auto; padding: 16px 18px; display: grid; gap: 16px; align-content: start; }
.ma-modal-body fieldset { border: 0; padding: 0; margin: 0; }
.ma-modal-body legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; padding: 0; }
.ma-modal-body .admin-msg { margin: 0; }
.ma-modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.ma-q { margin: 0; font-weight: 600; }
.ma-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ma-type-card { display: grid; justify-items: start; gap: 6px; padding: 14px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; }
.ma-type-card svg { color: var(--accent); }
.ma-type-card b { font: 700 16px var(--display); }
.ma-type-card small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.ma-type-card:hover, .ma-type-card:focus-visible, .ma-type-card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.ma-field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.ma-field input { font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.ma-choices { display: flex; gap: 10px; flex-wrap: wrap; }
.ma-choices.ma-col { display: grid; }
.ma-choice { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 14.5px; }
.ma-choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ma-choice small { display: block; font-size: 11.5px; color: var(--muted); }
.ma-choice.ma-disabled { opacity: .5; cursor: not-allowed; }
/* The Nuralindo logo is white line art: drawn dark on the light sidebar, white on the dark one. */
.brand-logo { width: 34px; height: 34px; flex: none; display: block; filter: invert(1) brightness(.2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-logo { filter: none; } }
:root[data-theme="dark"] .brand-logo { filter: none; }
.brand-text small.brand-sub { text-transform: none; letter-spacing: .02em; font-size: 11.5px; }
/* No menu link that depends on the role shows before the role is known: a
   customer never sees the admin pages flash in the sidebar. */
body:not(.role-ready) .nav a[data-role] { display: none; }
/* Timeline strips: boxes of the period still to come are an empty track
   (unlike "not reported", which is filled); a thin mark shows now. */
.exc-strip { position: relative; }
.exc-strip i.st-future, .exc-strip i.bs-future { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.exc-strip .strip-now { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; pointer-events: none; }
.cv-belt .exc-strip-axis { margin-top: 2px; font-size: 10.5px; }
/* Safety: period, area and camera on one row, wrapping on a phone. */
.filter-row { align-items: center; gap: 10px 16px; }
.filter-row > .range-bar { flex: 0 1 auto; }
@media (max-width: 560px) { .filter-row .range-select { width: 100%; } .filter-row .range-select select { flex: 1; min-width: 0; } }
/* The conveyor pop-up with its figures: wider, scrolls, the × always in reach. */
/* Block flow, not a grid: in a fixed-height grid the video box (overflow hidden)
   shrinks to nothing once the content is taller than the screen. */
.lay-panel { width: min(720px, 100%); display: block; }
.lay-panel > * + * { margin-top: 12px; }
.lay-panel > .lay-strip-axis { margin-top: 4px; }
.lay-panel-head { position: sticky; top: -22px; z-index: 2; margin: -22px -24px 0; padding: 22px 24px 10px; background: var(--surface); border-bottom: 1px solid transparent; }
.lay-panel-detail .panel { padding: 14px; }
.lay-panel-detail .kpis { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.lay-panel-range { margin-top: 6px; }
@media (max-width: 560px) { .lay-panel { padding: 16px; } .lay-panel-head { top: -16px; margin: -16px -16px 0; padding: 16px 16px 8px; } }
/* The page column never grows past the screen: a wide table or chart scrolls in
   its own box instead of pushing the whole page sideways on a phone. */
.content, .stack { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 560px) { .content { padding: 16px 16px 40px; } }
.ma-grid { grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); }
/* Health page (js/pages/health.js) */
.hl-top { display: grid; gap: 14px; border-left: 5px solid var(--ok); }
.hl-top.hl-warn { border-left-color: var(--warn); } .hl-top.hl-bad { border-left-color: var(--danger); }
.hl-status { display: grid; gap: 2px; }
.hl-status b { font: 700 22px var(--display); }
.hl-ok .hl-status b { color: var(--ok); } .hl-warn .hl-status b { color: var(--warn); } .hl-bad .hl-status b { color: var(--danger); }
.hl-status span { color: var(--muted); font-size: 13.5px; }
.hl-host { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.hl-cell { display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.hl-cell span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.hl-cell b { font: 600 17px var(--mono); display: flex; align-items: center; gap: 8px; }
.hl-cell small { color: var(--muted); font-size: 12px; }
.hl-cell.warn b { color: var(--warn); } .hl-cell.bad b { color: var(--danger); }
.hl-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; display: block; }
.hl-bar i { display: block; height: 100%; background: var(--accent); }
.hl-cell.bad .hl-bar i { background: var(--danger); }
.hl-mute-all { display: flex; gap: 8px; align-items: center; }
.hl-sev { display: inline-block; padding: 2px 8px; border-radius: 4px; font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.hl-critical { background: var(--danger); color: #fff; } .hl-warning { background: var(--warn-soft); color: var(--warn); } .hl-info { background: var(--soft); color: var(--muted); }
.hl-detail { font-size: 13px; color: var(--muted); max-width: 420px; }
.hl-models { display: grid; gap: 2px; font-size: 12.5px; }
.hl-model.ok { color: var(--ok); } .hl-model.bad { color: var(--danger); font-weight: 600; }
.hl-model small { color: var(--muted); font-weight: 400; }
.hl-ok-t { color: var(--ok); } .hl-bad-t { color: var(--danger); font-weight: 600; }
.hl-reason { font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); min-width: 220px; flex: 1; }
.hl-okb { background: var(--ok-soft); color: var(--ok); }
/* Admin: Fail-safe alerts (js/pages/failsafe.js) */
.fs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 14px; }
.fs-grid small { font-size: 11.5px; color: var(--faint); }
.fs-grid select { font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.fs-pair { display: flex; align-items: center; gap: 8px; }
.fs-pair input { min-width: 0; flex: 1; font: inherit; font-size: 15px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.fs-checks th.c, .fs-checks td.c { text-align: center; }
.fs-checks select { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.fs-num { width: 68px; font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); text-align: right; }
.fs-checks small { color: var(--muted); }
.fs-cams { margin-bottom: 14px; }
/* People intrusion: the area, drawn on the live picture (js/pages/myalerts.js) */
.ia-player { max-height: none; }
.ia-poly { fill: rgba(217, 68, 61, .22); stroke: #ff5a4f; stroke-width: 3; vector-effect: non-scaling-stroke; }
.ma-modal-body .fs-pair { max-width: 340px; }
/* Admin: renaming a camera */
.cam-name { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cam-name .icon-btn { width: 26px; height: 26px; }
.cam-id { display: block; color: var(--faint); font: 400 11px var(--mono); margin-top: 2px; white-space: normal; max-width: 280px; }
.cam-rename { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cam-rename input { font: inherit; font-size: 14px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); width: 170px; }
.cam-rename-err { display: block; margin-top: 4px; padding: 4px 8px; font-size: 12px; }

/* Reports page: one card per module (pages/reports.js modulesPanel) */
.mod-cards { display: grid; gap: 14px; }
.mod-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; background: var(--bg); display: grid; gap: 10px; }
.mod-head, .mod-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mod-head h3 { margin: 0; font: 700 16px var(--display); }
.mod-row { display: grid; grid-template-columns: 190px repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 14px; align-items: end; padding-top: 10px; border-top: 1px solid var(--line); }
.mod-row label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.mod-row input[type=text], .mod-row input[type=time], .mod-row select { width: 100%; }
.mod-what { display: grid; gap: 2px; align-self: start; }
.mod-wide { grid-column: span 2; }
.mod-check { display: flex !important; align-items: center; gap: 6px; }
.mod-status { font-size: 12.5px; align-self: center; }
@media (max-width: 720px) { .mod-row { grid-template-columns: 1fr; } .mod-wide { grid-column: auto; } }

/* Conveyors: the camera tiles by process area, and the site's cameras not connected yet */
.cv-area { display: grid; gap: 10px; }
.cv-area .cv-tiles { grid-template-columns: repeat(auto-fill, minmax(560px, 1fr)); }   /* one camera in an area keeps a tile's width */
.cv-area-h { margin: 6px 0 0; font: 700 15px var(--display); letter-spacing: .02em; color: var(--muted); text-transform: uppercase; }
.cv-area-off { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); border: 1.5px dashed var(--line); border-radius: 8px; padding: 8px 12px; }
.cv-nvr { font: 500 11px var(--mono); color: var(--muted); }
.lay-cam { --lay-c: #6f7a7c; }
.lay-cam .hmi-key { color: #4f585a; }
.hmi-eq-off { fill: none; stroke-dasharray: 5 4; }
.lay-link { cursor: pointer; }
.lay-link:hover .hmi-eq, .lay-link:focus-visible .hmi-eq { stroke: var(--accent); stroke-width: 2; }

/* Apron feeders on the conveyor layout (layout.js feeder) */
.lay-idle { --lay-c: #b97a16; } .lay-absent { --lay-c: #7b52ab; }
.lay-idle .hmi-state-t { fill: #8f5d0c; }
.lay-absent .hmi-state { fill: #f1ecf7; } .lay-absent .hmi-state-t { fill: #5e3d88; }
.hmi-feeder-pan { fill: var(--hmi-eq); stroke: var(--hmi-stroke); stroke-width: 1.5; }
.lay-run .hmi-feeder-pan { fill: var(--hmi-run); }
.hmi-from { font: 600 12px var(--mono); letter-spacing: .06em; fill: var(--hmi-dim); }
.lay-idle .hmi-key { color: #8f5d0c; } .lay-absent .hmi-key { color: #5e3d88; }

/* One frame for the whole conveyor layout: areas split by dashed lines, a dashed box round a conveyor's belts */
.hmi-divider { fill: none; stroke: #9aa3a4; stroke-width: 1.5; stroke-dasharray: 8 6; }
.hmi-group { fill: none; stroke: #7f888a; stroke-width: 1.2; stroke-dasharray: 5 4; }
.hmi-group-t { font: 600 11.5px var(--mono); letter-spacing: .05em; fill: var(--hmi-dim); }
.hmi-return { stroke-linejoin: round; }

/* A belt whose camera is connected, AI not set up yet (layout.js setup) */
.lay-setup { --lay-c: #5f7f99; }
.lay-setup .hmi-conv { fill: none; stroke: #5f7f99; stroke-width: 1.5; }
.lay-setup .hmi-state { fill: #eef3f7; } .lay-setup .hmi-state-t { fill: #3f5f79; }
.lay-setup .hmi-key { color: #3f5f79; }
