:root {
  --bg: #060910;
  --bg2: #0b1018;
  --panel: #101722;
  --panel2: #172131;
  --glass: linear-gradient(160deg, rgba(27, 38, 54, .82) 0%, rgba(14, 20, 29, .9) 55%, rgba(11, 16, 23, .94) 100%);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 24px 48px -24px rgba(0, 0, 0, .75), 0 2px 6px rgba(0, 0, 0, .25);
  --line: rgba(255, 255, 255, 0.07);
  --line2: rgba(255, 255, 255, 0.12);
  --ink: #eef2f6;
  --ink2: #b7c1cd;
  --muted: #7d8794;
  --accent: #3ad1ff;
  --accent2: #3987e5;
  --good: #0ca30c;
  --good-ink: #2bd576;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --crit-ink: #ff5a4f;
  --low: #7d8794;
  --radius: 14px;
  --font: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; }
body {
  background:
    radial-gradient(1100px 620px at 18% -12%, rgba(57, 135, 229, 0.16), transparent 62%),
    radial-gradient(900px 520px at 100% -5%, rgba(58, 209, 255, 0.09), transparent 60%),
    radial-gradient(800px 600px at 60% 110%, rgba(124, 92, 255, 0.07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
/* faint engineering grid behind everything */
body.app::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image: linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 90%);
}
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
h2 { font-size: 17px; font-weight: 750; }
h3 { font-size: 14px; font-weight: 700; }

/* ------------------------------ icon chips ------------------------------ */
.svg-i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.ic {
  --tone: #3ad1ff;
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--tone);
  background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 24%, transparent), color-mix(in srgb, var(--tone) 8%, transparent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 32%, transparent), 0 6px 16px -8px color-mix(in srgb, var(--tone) 70%, transparent);
}
.ic.sm { width: 22px; height: 22px; flex-basis: 22px; border-radius: 7px; }
.ic.sm .svg-i { width: 13px; height: 13px; }
.tone-cyan { --tone: #3ad1ff; } .tone-blue { --tone: #5b9dff; } .tone-green { --tone: #2bd576; }
.tone-amber { --tone: #fab219; } .tone-orange { --tone: #f08a5d; } .tone-red { --tone: #ff5a4f; }
.tone-violet { --tone: #a78bfa; } .tone-slate { --tone: #9aa7b8; } .tone-pink { --tone: #f472b6; }
h2[data-ico] { display: flex; align-items: center; gap: 10px; }
h2[data-ico] .ic { width: 28px; height: 28px; flex-basis: 28px; }
.muted { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; }
button { font-family: inherit; }
code { font-family: var(--mono); font-size: 12px; color: var(--ink2); }

/* ------------------------------- top bar ------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 24px; min-height: 68px;
  background: linear-gradient(180deg, rgba(8, 12, 18, .9), rgba(8, 12, 18, .72));
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 30px -20px rgba(0, 0, 0, .8);
}
.icon-btn .svg-i { width: 17px; height: 17px; }
.icon-btn.bell { position: relative; }
.bell-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: linear-gradient(180deg, #ff6b61, #d03b3b); color: #fff; font-size: 10.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px #0a0f16, 0 4px 10px rgba(208, 59, 59, .5); }
.bell-badge[hidden] { display: none; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .03); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; color: #04121b; background: linear-gradient(135deg, #3ad1ff, #7c5cff); box-shadow: 0 0 0 2px rgba(58, 209, 255, .25); }
.uc-txt { display: flex; flex-direction: column; line-height: 1.15; }
.uc-txt b { font-size: 12.5px; }
.uc-txt small { font-size: 11px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.logo { width: 42px; height: 42px; flex: 0 0 auto; filter: drop-shadow(0 6px 16px rgba(58, 209, 255, .35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 850; font-size: 21px; letter-spacing: -0.03em; }
.brand-name span { background: linear-gradient(90deg, #46dbff, #9b84ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-tag { font-size: 9.5px; font-weight: 750; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

/* ------------------------------ app shell ------------------------------ */
body.app { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 40; display: flex; flex-direction: column;
  padding: 24px 18px 18px; overflow-y: auto;
  background:
    radial-gradient(260px 220px at 20% 0%, rgba(58, 209, 255, .12), transparent 70%),
    radial-gradient(240px 260px at 100% 100%, rgba(124, 92, 255, .08), transparent 70%),
    linear-gradient(180deg, #0c131c 0%, #070b10 100%);
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 40px -30px rgba(0, 0, 0, .9);
}
.sidebar .brand { padding: 2px 6px 28px; }
.side-label { font-size: 11px; font-weight: 650; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding: 0 10px 12px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  position: relative; display: flex; align-items: center; gap: 13px; padding: 11px 12px; border-radius: 12px;
  color: var(--ink2); text-decoration: none; font-weight: 650; font-size: 14.5px; border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.side-nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; opacity: .9; }
.side-nav a:hover { background: rgba(255, 255, 255, .04); color: #fff; }
.side-nav a.on { color: #d6f6ff; background: linear-gradient(90deg, rgba(58, 209, 255, .2), rgba(58, 209, 255, .05) 70%, transparent); border-color: rgba(58, 209, 255, .28); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 8px 24px -14px rgba(58, 209, 255, .6); }
.side-nav a.on svg { color: var(--accent); filter: drop-shadow(0 0 6px rgba(58, 209, 255, .6)); }
.side-nav a.on::before { content: ""; position: absolute; left: -19px; top: 50%; transform: translateY(-50%); width: 4px; height: 26px; border-radius: 0 4px 4px 0; background: var(--accent); box-shadow: 0 0 12px rgba(58, 209, 255, .8); }
.nav-badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--critical); color: #fff; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.nav-badge[hidden] { display: none; }
.side-card { margin-top: auto; padding: 14px 14px 12px; border-radius: 16px; border: 1px solid var(--line2); background: var(--glass); box-shadow: var(--shadow); font-size: 12.5px; }
.side-card .sc-row span { display: inline-flex; align-items: center; gap: 7px; }
.side-card .sc-row .svg-i { width: 14px; height: 14px; color: var(--muted); }
.side-card .sc-title { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.side-card .sc-title i { width: 8px; height: 8px; border-radius: 50%; background: var(--good-ink); box-shadow: 0 0 8px var(--good-ink); flex: 0 0 auto; }
.side-card .sc-row { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--ink2); }
.side-card .sc-row b { color: #fff; font-weight: 750; }
.side-card p { margin: 10px 0 10px; color: var(--muted); line-height: 1.5; }
.side-card a { display: block; text-align: center; font-size: 12px; font-weight: 650; color: var(--ink2); text-decoration: none; padding: 7px; border-radius: 9px; border: 1px solid var(--line2); }
.side-card a:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.side-scrim { display: none; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.icon-btn.menu-btn { display: none; }
.crumbs { flex: 1; min-width: 0; }
.crumb-top { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-top #crumbInd { color: var(--muted); font-weight: 650; }
.crumb-top .sep { color: var(--line2); margin: 0 8px; }
.crumb-sub { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page[hidden] { display: none; }
.section-head.first { margin-top: 2px; }
.btn.small { padding: 5px 10px; font-size: 11.5px; text-decoration: none; }
a.btn { text-decoration: none; }

.report-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 22px; flex-wrap: wrap; background: radial-gradient(600px 200px at 0% 0%, rgba(58, 209, 255, .12), transparent), linear-gradient(180deg, var(--panel), #0f151d); }
.report-head h2 { font-size: 24px; margin: 4px 0 2px; }

/* overview zone cards */
.ov-zones { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ovz { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: var(--glass); box-shadow: var(--shadow); cursor: zoom-in; transition: transform .2s, box-shadow .2s; }
.ovz:hover { transform: translateY(-3px); box-shadow: var(--shadow), 0 22px 44px -24px rgba(58, 209, 255, .6); }
.ovz-media { position: relative; }
.ovz-media .live-tag { position: absolute; top: 10px; left: 10px; }
.ovz-media .cam-id { position: absolute; top: 10px; right: 10px; padding: 2px 7px; border-radius: 6px; background: rgba(6, 10, 15, .7); color: #dbe7f3; backdrop-filter: blur(6px); }
.ovz canvas { width: 100%; aspect-ratio: 16 / 9; display: block; background: #000; }
.ovz-body { padding: 10px 12px 12px; }
.ovz-top { display: flex; align-items: center; gap: 8px; }
.ovz-top b { font-size: 13.5px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ovz .chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.ovz .risk { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.ovz .risk b { color: var(--ink2); }

/* alert center */
.ac-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.alert-center { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 10px; }
.alert-center .alert { margin: 0; grid-template-columns: 170px 1fr; }
.alert-center .alert img { width: 170px; height: 96px; }
.alert-center .empty { color: var(--muted); padding: 24px; grid-column: 1 / -1; }

/* settings */
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.set-card { padding: 16px 18px; }
.set-card h3 { margin: 0 0 6px; font-size: 15px; }
.set-card .muted { margin-bottom: 12px; }
.set-card.span-all { grid-column: 1 / -1; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row b { display: block; font-size: 13.5px; }
.set-row span { font-size: 12px; color: var(--muted); }
.switch { width: 44px; height: 24px; border-radius: 12px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .08); position: relative; cursor: pointer; flex: 0 0 auto; }
.switch i { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #c7d0da; transition: left .2s, background .2s; }
.switch[aria-pressed="true"] { background: rgba(58, 209, 255, .35); border-color: rgba(58, 209, 255, .6); }
.switch[aria-pressed="true"] i { left: 22px; background: #fff; }
.range { display: flex; align-items: center; gap: 10px; }
.range input { accent-color: #3ad1ff; width: 140px; }
.range output { font-family: var(--mono); font-size: 12.5px; min-width: 64px; text-align: right; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 650; text-align: right; }
.rule-chip { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 5px; background: rgba(255, 255, 255, .06); color: var(--ink2); margin: 2px 3px 2px 0; white-space: nowrap; }
.rule-chip.ppe { background: rgba(58, 209, 255, .12); color: #bff1ff; }
.top-right { display: flex; align-items: center; gap: 12px; }
.live-pill { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink2); padding: 6px 12px; border: 1px solid var(--line2); border-radius: 999px; }
.live-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #ff3b30; box-shadow: 0 0 0 0 rgba(255, 59, 48, .6); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, .6); } 70% { box-shadow: 0 0 0 8px rgba(255, 59, 48, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); } }
.clock { font-family: var(--mono); font-size: 13px; color: var(--ink2); min-width: 70px; text-align: right; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; color: var(--ink2); border: 0; padding: 6px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.seg button.on { background: rgba(58, 209, 255, 0.16); color: #fff; }
.seg.small button { padding: 5px 9px; font-size: 11.5px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(255, 255, 255, 0.035); color: var(--ink2); cursor: pointer; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; transition: background .15s, color .15s, border-color .15s; }
.icon-btn:hover { background: rgba(58, 209, 255, 0.1); color: #fff; border-color: rgba(58, 209, 255, .35); }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 12.5px; font-weight: 650;
  border: 1px solid rgba(58, 209, 255, 0.38); color: #e6f9ff;
  background: linear-gradient(180deg, rgba(58, 209, 255, 0.2), rgba(57, 135, 229, 0.12));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 8px 20px -12px rgba(58, 209, 255, .6);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); background: linear-gradient(180deg, rgba(58, 209, 255, 0.3), rgba(57, 135, 229, 0.18)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 12px 26px -12px rgba(58, 209, 255, .7); }
.btn .svg-i { width: 15px; height: 15px; }

main { padding: 18px 24px 40px; width: 100%; max-width: 1920px; margin: 0 auto; }

/* ------------------------------ panels ------------------------------ */
/* glass surface with a gradient hairline border */
.panel { position: relative; background: var(--glass); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.panel::before, .kpi::before, .insight::before, .cam-card::before, .ovz::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .03) 35%, transparent 60%, rgba(58, 209, 255, .14));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; }
.panel-head h2 { display: flex; align-items: center; gap: 10px; }
.eyebrow { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 750; display: inline-flex; align-items: center; gap: 7px; }
.eyebrow .svg-i { width: 14px; height: 14px; }

/* --------------------------- overview hero --------------------------- */
.hero-banner {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center;
  padding: 28px 30px; border-radius: 22px; margin-bottom: 16px; min-height: 196px;
  border: 1px solid rgba(255, 255, 255, .08); box-shadow: var(--shadow);
  background: linear-gradient(100deg, rgba(6, 10, 16, .97) 0%, rgba(6, 10, 16, .86) 42%, rgba(6, 10, 16, .45) 100%), var(--hero-img, none) center 40% / cover no-repeat, #0b1119;
}
.hero-banner::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(500px 220px at 0% 0%, rgba(58, 209, 255, .18), transparent 70%), radial-gradient(400px 260px at 100% 100%, rgba(124, 92, 255, .14), transparent 70%); }
.hero-banner > * { position: relative; z-index: 1; }
.hero-banner h1 { font-size: clamp(28px, 2.6vw, 40px); font-weight: 850; letter-spacing: -0.03em; margin: 8px 0 12px; background: linear-gradient(90deg, #fff 30%, #a9e9ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hb-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hb-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--ink2); background: rgba(255, 255, 255, .05); border: 1px solid var(--line2); backdrop-filter: blur(6px); }
.hb-chip .svg-i { width: 14px; height: 14px; color: var(--accent); }
.hb-status { display: inline-flex; align-items: center; gap: 9px; margin-top: 16px; padding: 8px 14px; border-radius: 12px; font-size: 13px; font-weight: 650; background: rgba(43, 213, 118, .1); border: 1px solid rgba(43, 213, 118, .3); color: #b9f7d2; }
.hb-status i { width: 9px; height: 9px; border-radius: 50%; background: var(--good-ink); box-shadow: 0 0 0 4px rgba(43, 213, 118, .18); animation: breathe 2s infinite; }
.hb-status.crit { background: rgba(255, 90, 79, .12); border-color: rgba(255, 90, 79, .4); color: #ffd0cc; }
.hb-status.crit i { background: var(--crit-ink); box-shadow: 0 0 0 4px rgba(255, 90, 79, .2); }
@keyframes breathe { 50% { transform: scale(1.25); } }
.hb-right { display: flex; align-items: center; gap: 22px; }
.hb-ring svg { width: 148px; height: 148px; display: block; filter: drop-shadow(0 10px 30px rgba(58, 209, 255, .25)); }
.hb-mini { display: grid; gap: 10px; }
.hb-mini div { padding: 10px 14px; border-radius: 13px; background: rgba(10, 16, 24, .6); border: 1px solid var(--line2); backdrop-filter: blur(8px); min-width: 150px; }
.hb-mini b { display: block; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.hb-mini span { font-size: 11px; color: var(--muted); }

/* ------------------------------- KPI tiles ------------------------------- */
/* KPI rows size to the content area (not the viewport), so tiles never get cramped */
main { container-type: inline-size; }
.kpi-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.kpi-row.hist { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-row + .kpi-row, .kpi-row + .kpi-group { margin-top: 14px; }
@container (min-width: 1150px) { .kpi-row, .kpi-row.ov-q { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@container (min-width: 1720px) { .kpi-row.hist { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
@container (max-width: 720px) { .kpi-row, .kpi-row.hist, .kpi-row.ov-q { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi-group { display: flex; align-items: center; gap: 10px; margin: 0 2px 10px; font-size: 11.5px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kpi-group::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line2), transparent); }
.kpi-group i { width: 7px; height: 7px; border-radius: 50%; background: #ff5a4f; box-shadow: 0 0 8px #ff5a4f; }
.kpi {
  --tone: #3ad1ff;
  position: relative; overflow: hidden; min-width: 0;
  padding: 14px 16px 14px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--glass); box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.kpi::after { content: ""; position: absolute; left: 18px; right: 18px; top: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--tone), transparent); opacity: .55; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 18px 40px -22px color-mix(in srgb, var(--tone) 60%, transparent); }
.k-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kpi .k-label { font-size: 12px; color: var(--ink2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-val { font-size: 28px; font-weight: 800; margin-top: 12px; letter-spacing: -0.035em; line-height: 1.05; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.kpi .k-val small { font-size: 13px; font-weight: 650; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi .k-foot { font-size: 11.5px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; position: relative; z-index: 1; flex-wrap: wrap; }
/* sparkline lives in its own strip under the text, never behind it */
.kpi.has-spark { padding-bottom: 50px; }
.kpi svg.spark { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 40px; opacity: .95; }
.delta { font-weight: 750; display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; border-radius: 6px; }
.delta.good { color: var(--good-ink); background: rgba(43, 213, 118, .1); }
.delta.bad { color: var(--crit-ink); background: rgba(255, 90, 79, .1); }
.kpi.alertish { border-color: rgba(255, 90, 79, .3); }
.kpi.alertish .k-val { color: #ff8a80; }

/* ---------------------------- camera wall ---------------------------- */
.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; margin-bottom: 28px; }
.cam-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 0 16px 16px; }
.cam-card { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #070b10; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.cam-card:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 20px 40px -24px rgba(58, 209, 255, .55); }
.cam-card.flash { box-shadow: 0 0 0 2px var(--critical), 0 0 34px rgba(208, 59, 59, .5); }
.cam-head { display: flex; align-items: center; gap: 9px; padding: 10px 12px; background: linear-gradient(180deg, rgba(20, 28, 40, .95), rgba(12, 17, 25, .95)); border-bottom: 1px solid var(--line); }
.live-tag { font-size: 9.5px; font-weight: 850; letter-spacing: .08em; color: #fff; padding: 2px 6px; border-radius: 5px; background: linear-gradient(180deg, #ff5a4f, #c62f2f); box-shadow: 0 0 10px rgba(255, 90, 79, .45); }
.zcode { font-family: var(--mono); font-size: 11px; font-weight: 800; color: #04121b; background: linear-gradient(135deg, #5fe0ff, #3a9cf0); padding: 2px 7px; border-radius: 6px; box-shadow: 0 4px 12px -4px rgba(58, 209, 255, .7); }
.zname { font-weight: 650; font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-id { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good-ink); box-shadow: 0 0 8px var(--good-ink); }
.status-dot.warn { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.status-dot.crit { background: var(--crit-ink); box-shadow: 0 0 8px var(--crit-ink); }
.cam-view { position: relative; aspect-ratio: 16 / 9; cursor: zoom-in; }
.cam-view canvas { width: 100%; height: 100%; display: block; }
.zoom-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(8, 12, 16, .65); color: #fff; cursor: pointer; backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; opacity: .85; transition: opacity .15s, transform .15s, background .15s;
}
.cam-view:hover .zoom-btn { opacity: 1; }
.zoom-btn:hover { background: rgba(58, 209, 255, .35); transform: scale(1.06); }
.zoom-btn svg { width: 17px; height: 17px; }
.cam-foot { display: flex; gap: 6px; padding: 9px 12px; background: linear-gradient(180deg, rgba(14, 20, 29, .95), rgba(10, 15, 22, .95)); border-top: 1px solid var(--line); flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; color: var(--ink2); padding: 4px 9px; border-radius: 8px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .05); white-space: nowrap; }
.chip .svg-i { width: 13px; height: 13px; }
.chip.bad { background: rgba(208, 59, 59, .18); color: #ffb3ad; }
.chip.warn { background: rgba(250, 178, 25, .14); color: #ffd98a; }
.chip.ok { background: rgba(12, 163, 12, .14); color: #9ff0b5; }

.layer-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.ltog { font-size: 11.5px; font-weight: 600; padding: 5px 9px; border-radius: 7px; border: 1px solid var(--line2); background: transparent; color: var(--muted); cursor: pointer; }
.ltog.on { color: #dff6ff; border-color: rgba(58, 209, 255, .45); background: rgba(58, 209, 255, .12); }

/* ------------------------------ alerts ------------------------------ */
.alerts-panel { display: flex; flex-direction: column; max-height: calc(100vh - 120px); position: sticky; top: 74px; align-self: start; }
.sev-counters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 14px 10px; }
.sevc { border-radius: 9px; padding: 7px 8px; background: rgba(255, 255, 255, .03); border: 1px solid var(--line); }
.sevc .n { font-size: 18px; font-weight: 800; }
.sevc .l { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 5px; }
.sevc .l i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.alert-list { overflow-y: auto; padding: 0 10px 12px; flex: 1; min-height: 300px; }
.alert-list .empty { color: var(--muted); padding: 30px 10px; text-align: center; font-size: 13px; }
.alert {
  display: grid; grid-template-columns: 118px 1fr; gap: 11px; padding: 10px; margin-bottom: 8px;
  border-radius: 14px; border: 1px solid var(--line); background: linear-gradient(160deg, rgba(24, 33, 46, .7), rgba(12, 17, 24, .8));
  border-left: 3px solid var(--low); animation: slidein .35s ease; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
  transition: transform .15s, border-color .15s;
}
.alert:hover { transform: translateX(2px); }
.a-title { display: flex; align-items: center; gap: 8px; }
@keyframes slidein { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.alert.sev-critical { border-left-color: var(--critical); background: linear-gradient(90deg, rgba(208, 59, 59, .12), rgba(255, 255, 255, .01)); }
.alert.sev-high { border-left-color: var(--serious); }
.alert.sev-medium { border-left-color: var(--warning); }
.alert.acked { opacity: .5; }
.alert img { width: 118px; height: 66px; object-fit: cover; border-radius: 7px; display: block; background: #000; cursor: zoom-in; }
.a-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.sev-badge { font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; display: inline-flex; gap: 4px; align-items: center; }
.sev-badge.critical { background: var(--critical); color: #fff; }
.sev-badge.high { background: var(--serious); color: #1a0a04; }
.sev-badge.medium { background: var(--warning); color: #1a1204; }
.sev-badge.low { background: #3a424d; color: #dde3ea; }
.a-time { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.a-title { font-weight: 700; font-size: 13px; margin: 4px 0 2px; }
.a-meta { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.a-actions { display: flex; gap: 6px; margin-top: 6px; }
.a-actions button { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line2); background: transparent; color: var(--ink2); cursor: pointer; }
.a-actions button:hover { background: rgba(255, 255, 255, .06); color: #fff; }

/* --------------------------- analytics grid --------------------------- */
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 30px 2px 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 19px; }
.section-head h2 + .muted { margin-left: 38px; }
.dataset-badge { font-family: var(--mono); font-size: 11.5px; color: var(--ink2); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line2); background: rgba(255, 255, 255, .02); }
.chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.chart-card { padding: 14px 16px 12px; min-width: 0; }
.span-2 { grid-column: span 2; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head .muted { margin: 0; font-size: 11.5px; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 280px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.heatmap { display: grid; gap: 2px; font-size: 11px; }
.heatmap .hm-row { display: grid; grid-template-columns: 150px repeat(24, minmax(0, 1fr)); gap: 2px; align-items: center; }
.heatmap .hm-lab { color: var(--ink2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 6px; }
.heatmap .hm-cell { height: 30px; border-radius: 3px; position: relative; cursor: default; }
.heatmap .hm-cell:hover { outline: 2px solid #fff; z-index: 2; }
.heatmap .hm-hours span { color: var(--muted); text-align: center; font-family: var(--mono); font-size: 10px; }
.hm-scale { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.hm-scale .bar { flex: 0 0 160px; height: 8px; border-radius: 4px; }

.table-wrap { overflow: auto; }
.ztable, .ltable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ztable th, .ltable th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line2); position: sticky; top: 0; background: var(--panel); }
.ztable td, .ltable td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ztable tr:hover td, .ltable tr:hover td { background: rgba(255, 255, 255, .02); }
.num { text-align: right; }
.riskbar { display: flex; align-items: center; gap: 8px; }
.riskbar .b { height: 6px; border-radius: 3px; background: linear-gradient(90deg, #fab219, #d03b3b); }
.table-wrap.log { max-height: 460px; }
.ltable .live-row td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.tag-live { font-size: 10px; font-weight: 800; color: #06131c; background: var(--accent); padding: 1px 5px; border-radius: 4px; margin-left: 6px; }
.log-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.log-tools select, .log-tools input { background: var(--panel); color: var(--ink); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 10px; font-family: inherit; font-size: 12.5px; }
.log-tools input { min-width: 220px; }

.insights { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.insight {
  --tone: #9aa7b8;
  position: relative; overflow: hidden; padding: 16px 18px; border-radius: 16px; border: 1px solid var(--line);
  background: radial-gradient(320px 140px at 0% 0%, color-mix(in srgb, var(--tone) 14%, transparent), transparent 70%), var(--glass);
  box-shadow: var(--shadow);
}
.insight::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--tone), transparent 85%); }
.insight.critical { --tone: #ff5a4f; }
.insight.high { --tone: #f08a5d; }
.insight.medium { --tone: #fab219; }
.insight.good { --tone: #2bd576; }
.insight .i-lev { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--tone); display: flex; gap: 8px; align-items: center; }
.insight h4 { margin: 6px 0 6px; font-size: 14.5px; }
.insight p { margin: 0 0 8px; color: var(--ink2); font-size: 12.5px; line-height: 1.5; }
.insight .act { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: #d6f4ff; background: linear-gradient(90deg, rgba(58, 209, 255, .1), rgba(58, 209, 255, .03)); border: 1px solid rgba(58, 209, 255, .2); padding: 9px 11px; border-radius: 10px; line-height: 1.45; }
.insight .act .svg-i { width: 14px; height: 14px; margin-top: 2px; color: var(--accent); }
.t-title { display: flex; align-items: center; gap: 8px; }

.foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--line, rgba(255,255,255,.06)); color: var(--muted); font-size: 12px; }
.powered { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 4px; text-decoration: none; opacity: .85; transition: opacity .2s; }
.powered:hover { opacity: 1; }
.powered span { font-size: 8.5px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.powered img { display: block; height: 26px; width: auto; }
@media (max-width: 640px) { .foot { justify-content: center; text-align: center; } .powered { align-items: center; } }

/* --------------------------- view switcher --------------------------- */
.ok-ink { color: var(--good-ink); }
.bad-ink { color: var(--crit-ink); }
.span-3 { grid-column: 1 / -1; }

/* ------------------------------ quality ------------------------------ */
.qlines { display: grid; grid-template-columns: repeat(auto-fit, minmax(640px, 1fr)); gap: 14px; }
.qline { padding: 0; overflow: hidden; }
.ql-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ql-head .ql-name { font-weight: 750; font-size: 14.5px; }
.ql-head .ql-prod { font-size: 12px; color: var(--ink2); padding: 3px 8px; border-radius: 6px; background: rgba(255, 255, 255, .05); }
.ql-head .sp { flex: 1; }
.ql-body { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(240px, 1fr); align-items: center; background: #000; }
.ql-video { position: relative; aspect-ratio: 16 / 9; background: #000; cursor: zoom-in; }
.ql-stats { background: linear-gradient(180deg, var(--panel), #0f151d); align-self: stretch; }
.ql-video canvas { width: 100%; height: 100%; display: block; }
.ql-video .zoom-btn { opacity: 1; }
.ql-stats { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; border-left: 1px solid var(--line); }
.ql-counts { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: center; }
.qc-box { border-radius: 10px; padding: 8px 10px; border: 1px solid var(--line); }
.qc-box.good { background: rgba(12, 163, 12, .10); border-color: rgba(43, 213, 118, .3); }
.qc-box.bad { background: rgba(208, 59, 59, .12); border-color: rgba(255, 90, 79, .35); }
.qc-box .l { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink2); }
.qc-box .v { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.qc-box.good .v { color: var(--good-ink); }
.qc-box.bad .v { color: var(--crit-ink); }
.ring { width: 70px; height: 70px; }
.ring text { font-family: var(--font); }
.ql-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ql-mini div { background: rgba(255, 255, 255, .03); border-radius: 8px; padding: 6px 8px; }
.ql-mini b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.ql-mini span { font-size: 10.5px; color: var(--muted); }
.dbar { display: grid; grid-template-columns: 112px 1fr 40px; gap: 8px; align-items: center; font-size: 11.5px; margin-bottom: 2px; }
.dbar .t { color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dbar .track { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.dbar .fill { height: 100%; border-radius: 4px; background: #d03b3b; }
.dbar .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.ql-sub { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px; }
.ql-rejects { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); overflow-x: auto; min-height: 92px; align-items: center; }
.ql-rejects .empty { color: var(--muted); font-size: 12px; }
.rj { flex: 0 0 auto; width: 118px; font-size: 10.5px; color: var(--ink2); animation: slidein .35s ease; }
.rj img, .rj .noimg { width: 118px; height: 66px; object-fit: cover; border-radius: 6px; border: 1px solid rgba(255, 90, 79, .5); display: block; background: #1a0f10; }
.rj .noimg { display: flex; align-items: center; justify-content: center; color: var(--crit-ink); font-weight: 800; }
.rj b { color: #ffb3ad; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.qsplit { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }
.qsplit .bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 2px; }
.qsplit .bar div { height: 100%; }
.qsplit .row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink2); }
.qsplit .big { font-size: 28px; font-weight: 800; }
.qsplit .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.mixbar { display: flex; height: 12px; border-radius: 4px; overflow: hidden; gap: 1px; min-width: 220px; }
.mixbar div { height: 100%; }
.mixlegend { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: normal; max-width: 420px; }
.reject-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.reject-gallery .empty { color: var(--muted); padding: 20px; grid-column: 1 / -1; }
.rg { background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; animation: slidein .35s ease; cursor: zoom-in; }
.rg img, .rg .noimg { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #1a0f10; }
.rg .noimg { display: flex; align-items: center; justify-content: center; color: var(--crit-ink); font-weight: 800; font-size: 13px; }
.rg .meta { padding: 8px 10px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.rg .meta b { color: #ffb3ad; font-size: 12.5px; display: block; }

/* ------------------------------- modal ------------------------------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(3, 5, 8, .82); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 18px; animation: fade .2s; }
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-inner { width: min(1680px, 100%); max-height: 100%; display: flex; flex-direction: column; background: #0b1016; border: 1px solid var(--line2); border-radius: 16px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: zoomin .22s ease; }
@keyframes zoomin { from { transform: scale(.96); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.mh-left { display: flex; align-items: center; gap: 10px; }
.mh-title { font-weight: 800; font-size: 16px; }
.mh-right { display: flex; gap: 6px; }
.icon-btn.close:hover { background: var(--critical); }
.modal-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; flex: 1; }
.modal-video { position: relative; background: #000; align-self: start; aspect-ratio: 16 / 9; cursor: grab; }
.modal-video.dragging { cursor: grabbing; }
.modal-video canvas { width: 100%; height: 100%; display: block; }
.ptz { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 4px; align-items: center; background: rgba(8, 12, 16, .7); padding: 6px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .15); backdrop-filter: blur(6px); }
.ptz button { width: 34px; height: 34px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, .08); color: #fff; font-size: 17px; cursor: pointer; }
.ptz button:hover { background: rgba(58, 209, 255, .35); }
.ptz #zLevel { font-family: var(--mono); font-size: 11px; color: var(--ink2); padding: 2px 0; }
.ptz-hint { position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%); font-size: 11.5px; color: rgba(255, 255, 255, .7); background: rgba(0, 0, 0, .45); padding: 4px 10px; border-radius: 999px; pointer-events: none; }
.modal-side { border-left: 1px solid var(--line); padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 110px); }
.side-block { background: rgba(255, 255, 255, .02); border: 1px solid var(--line); border-radius: 11px; padding: 10px; }
.side-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.mstats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mstat { background: rgba(255, 255, 255, .03); border-radius: 8px; padding: 7px 9px; }
.mstat .v { font-size: 18px; font-weight: 800; }
.mstat .l { font-size: 11px; color: var(--muted); }
.tracks { font-size: 12px; max-height: 210px; overflow-y: auto; }
.trk { display: grid; grid-template-columns: 46px 1fr auto; gap: 8px; padding: 5px 4px; border-bottom: 1px solid var(--line); align-items: center; }
.trk .id { font-family: var(--mono); color: var(--ink2); }
.trk .st { font-size: 11px; font-weight: 700; }
.trk .st.ok { color: var(--good-ink); }
.trk .st.warn { color: var(--warning); }
.trk .st.crit { color: var(--crit-ink); }
.malerts { max-height: 260px; overflow-y: auto; }
.malert { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.malert img { width: 74px; height: 42px; object-fit: cover; border-radius: 5px; }

/* ------------------------------- toasts ------------------------------- */
.toasts { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; min-width: 360px; max-width: 520px; padding: 10px 14px; border-radius: 12px; background: rgba(40, 10, 10, .92); border: 1px solid rgba(255, 90, 80, .6); box-shadow: 0 12px 40px rgba(0, 0, 0, .5); animation: slidein .3s ease; cursor: pointer; }
.toast img { width: 92px; height: 52px; border-radius: 6px; object-fit: cover; }
.toast .t-title { font-weight: 800; font-size: 13.5px; }
.toast .t-sub { font-size: 12px; color: #ffcfca; }

/* ---------------------------- responsive ---------------------------- */
@media (max-width: 1600px) {
  .uc-txt { display: none; }
  .user-chip { padding-right: 4px; }
}
@media (max-width: 1500px) {
  .ov-zones { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1250px) {
  .live-grid { grid-template-columns: minmax(0, 1fr); }
  .alerts-panel { position: static; max-height: 520px; }
  .chart-grid { grid-template-columns: 1fr 1fr; }
  .plant-head { grid-template-columns: 1fr; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-side { border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .ac-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero-banner { grid-template-columns: 1fr; }
}
/* sidebar becomes a slide-in drawer */
@media (max-width: 1000px) {
  body.app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: 272px; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 20px 0 60px rgba(0, 0, 0, .5); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .side-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .55); }
  .icon-btn.menu-btn { display: inline-flex; }
}
@media (max-width: 900px) {
  .qlines { grid-template-columns: 1fr; }
  .ql-body { grid-template-columns: 1fr; }
  .ql-stats { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  main { padding: 14px 16px 30px; }
  .cam-grid { grid-template-columns: 1fr; }
  .chart-grid, .settings-grid, .ov-zones { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .ac-stats { grid-template-columns: 1fr 1fr; }
  .alert-center { grid-template-columns: minmax(0, 1fr); }
  .alert-center .alert { grid-template-columns: 118px 1fr; }
  .alert-center .alert img { width: 118px; height: 66px; }
  .heatmap .hm-row { grid-template-columns: 90px repeat(24, minmax(0, 1fr)); }
  .live-pill, .seg#intensitySeg, .clock, .user-chip { display: none; }
  .hero-banner { padding: 20px; }
  .hb-right { flex-wrap: wrap; }
  .hb-ring svg { width: 120px; height: 120px; }
  .section-head h2 + .muted { margin-left: 0; }
  .crumb-sub { display: none; }
}

/* print the Reports page as a clean PDF */
@media print {
  body.app { display: block; background: #0b0f14; }
  .sidebar, .topbar, .foot, .modal, .toasts, .side-scrim, #repExport, #repPrint { display: none !important; }
  .page { display: none !important; }
  .page[data-page="reports"] { display: block !important; }
  .chart-card { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
