:root {
  --bg: #050a13;
  --bg-soft: #08111f;
  --panel: #0b1424;
  --panel-raised: #0f1a2e;
  --panel-soft: #0a1220;
  --border: rgba(148, 163, 184, 0.13);
  --border-strong: rgba(148, 163, 184, 0.24);
  --text: #e9effb;
  --muted: #8999b2;
  --faint: #5b6b83;
  --blue: #4f8cff;
  --blue-soft: rgba(79, 140, 255, 0.14);
  --cyan: #22c7de;
  --cyan-soft: rgba(34, 199, 222, 0.13);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.14);
  --green: #35d49a;
  --green-soft: rgba(53, 212, 154, 0.13);
  --amber: #f5b942;
  --amber-soft: rgba(245, 185, 66, 0.13);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.13);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  --ease: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input { font: inherit; }
button { color: inherit; }
a { color: var(--blue); }
svg { display: block; }

.ambient {
  position: fixed;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}
.ambient-one { top: -260px; left: -160px; background: #1f5cff; }
.ambient-two { bottom: -320px; right: -200px; background: #7c3aed; }

/* ============================== LOGIN ============================== */
.login-view {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(420px, 0.88fr);
  background:
    linear-gradient(rgba(5, 10, 19, 0.82), rgba(5, 10, 19, 0.94)),
    repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.045) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(148, 163, 184, 0.045) 0 1px, transparent 1px 72px),
    radial-gradient(circle at 18% 20%, #122b55 0%, #050a13 56%);
}
.login-story {
  padding: clamp(32px, 6vw, 84px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--border);
}
.story-brand { display: flex; align-items: center; gap: 18px; margin-bottom: 36px; }
.story-brand img {
  width: 74px; height: 74px; object-fit: contain; border-radius: 18px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.4);
}
.eyebrow {
  display: inline-block;
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.story-brand h1 {
  margin: 4px 0 0;
  font-size: clamp(30px, 3.2vw, 44px);
  letter-spacing: -0.045em;
  line-height: 1.02;
  background: linear-gradient(100deg, #f8fbff, #8ab7ff 72%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.story-lead { max-width: 560px; margin: 0 0 36px; color: var(--muted); font-size: 15px; line-height: 1.75; }
.story-features { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.story-features article {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(12, 21, 37, 0.55);
  backdrop-filter: blur(8px);
}
.story-features strong { display: block; font-size: 13.5px; margin-bottom: 3px; }
.story-features small { display: block; color: var(--faint); font-size: 12px; line-height: 1.55; }
.feature-mark {
  flex: 0 0 38px; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
}
.feature-mark svg { width: 19px; height: 19px; }
.feature-mark.blue { background: var(--blue-soft); color: var(--blue); }
.feature-mark.cyan { background: var(--cyan-soft); color: var(--cyan); }
.feature-mark.violet { background: var(--violet-soft); color: var(--violet); }
.story-foot { margin-top: 36px; color: var(--faint); font-size: 11.5px; display: flex; align-items: center; gap: 8px; }
.led { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(53, 212, 154, 0.8); }
.login-panel {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: clamp(24px, 5vw, 68px);
}
.login-card {
  width: 100%; max-width: 390px;
  padding: 36px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(16, 26, 46, 0.96), rgba(9, 16, 29, 0.98));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.login-heading { margin-bottom: 26px; }
.login-heading h2 { margin: 6px 0 6px; font-size: 26px; letter-spacing: -0.035em; }
.login-heading p { margin: 0; color: var(--muted); font-size: 12.5px; }
.field { display: block; margin-bottom: 15px; }
.field > span:first-child { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.field input {
  width: 100%; height: 46px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: rgba(4, 9, 17, 0.72);
  color: var(--text);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field input:focus { border-color: rgba(79, 140, 255, 0.7); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.14); }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 48px; }
.ghost-icon {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--faint); cursor: pointer;
}
.ghost-icon:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.ghost-icon svg { width: 17px; height: 17px; }
.form-error {
  margin: 4px 0 14px; padding: 10px 12px;
  border-radius: 10px; border: 1px solid rgba(248, 113, 113, 0.3);
  background: var(--red-soft); color: #fecaca; font-size: 12px; line-height: 1.5;
}
.btn-primary {
  width: 100%; height: 48px; margin-top: 6px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  border: 0; border-radius: 12px;
  background: linear-gradient(120deg, #2f6ef0, #2ea8d8);
  color: #fff; font-weight: 700; font-size: 13px; cursor: pointer;
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.3);
  transition: transform var(--ease), box-shadow var(--ease), opacity var(--ease);
}
.btn-primary svg { width: 17px; height: 17px; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 18px 42px rgba(37, 99, 235, 0.42); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; transform: none; }
.login-hint { margin: 16px 0 0; text-align: center; color: var(--faint); font-size: 11px; line-height: 1.6; }
.login-copyright { margin: 22px 0 0; color: var(--faint); font-size: 10.5px; letter-spacing: 0.04em; }

/* ============================== APP SHELL ============================== */
.app-shell {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 85% -20%, rgba(47, 110, 240, 0.12), transparent 42%), var(--bg);
}
.topbar {
  flex: 0 0 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  background: rgba(8, 15, 27, 0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
  z-index: 30;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  border: 0; background: transparent; padding: 0; cursor: pointer; text-align: left;
}
.brand img {
  width: 38px; height: 38px; object-fit: contain; border-radius: 10px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
}
.brand-copy strong {
  display: block; font-size: 15px; font-weight: 800; letter-spacing: 0.1em;
  background: linear-gradient(90deg, #f4f8ff, #8ab7ff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brand-copy small { display: block; margin-top: 1px; color: var(--faint); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; }
.topbar-center { display: flex; align-items: center; gap: 14px; }
.live-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 20px;
  border: 1px solid rgba(53, 212, 154, 0.22);
  background: rgba(53, 212, 154, 0.07);
  color: #a7f3d0; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(53, 212, 154, 0.5); } 50% { box-shadow: 0 0 0 5px rgba(53, 212, 154, 0); } }
#clock { color: var(--muted); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.mini-metrics { display: flex; gap: 12px; padding-right: 12px; border-right: 1px solid var(--border); }
.mini-metrics span { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.mini-metrics small { color: var(--faint); font-size: 8.5px; font-weight: 700; letter-spacing: 0.1em; }
.mini-metrics b { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.operator-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel-soft);
  color: var(--muted); font-size: 11.5px; font-weight: 600;
}
.operator-chip svg { width: 14px; height: 14px; }
.icon-button {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--panel-soft); color: var(--muted); cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.icon-button:hover { background: var(--red-soft); color: #fca5a5; border-color: rgba(248, 113, 113, 0.25); }
.icon-button svg { width: 16px; height: 16px; }

/* Tabs */
.tabs {
  flex: 0 0 52px;
  display: flex; align-items: stretch; gap: 2px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 15, 27, 0.82);
  backdrop-filter: blur(16px);
  z-index: 25;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 16px;
  border: 0; background: transparent;
  color: var(--faint); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  cursor: pointer;
  transition: color var(--ease), background var(--ease);
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--muted); background: rgba(255, 255, 255, 0.025); }
.tab.active { color: var(--text); }
.tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px;
  border-radius: 2px; background: linear-gradient(90deg, var(--blue), var(--cyan));
  box-shadow: 0 0 14px rgba(79, 140, 255, 0.55);
}
.tab-state { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.tab-state.online { background: var(--green); box-shadow: 0 0 7px rgba(53, 212, 154, 0.7); }
.tab-state.degraded { background: var(--amber); }
.tab-state.offline { background: var(--red); }
.tabs-spacer { flex: 1; }
.tabs-meta { display: flex; align-items: center; color: var(--faint); font-size: 10.5px; white-space: nowrap; padding-left: 18px; }

.workspace { position: relative; flex: 1; min-height: 0; }
.panel { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity 220ms ease; }
.panel.active { opacity: 1; pointer-events: auto; }
#panel-overview { overflow: hidden; }
.overview-scroll { height: 100%; overflow-y: auto; padding: 26px 28px 34px; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; max-width: 1720px; margin: 0 auto; }
.overview-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.overview-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* Hero */
.hero-card {
  display: flex; justify-content: space-between; gap: 26px;
  padding: 26px 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 90% 15%, rgba(79, 140, 255, 0.16), transparent 40%),
    linear-gradient(130deg, rgba(16, 28, 49, 0.95), rgba(8, 15, 27, 0.95));
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}
.hero-copy { min-width: 0; }
.hero-copy h2 { margin: 8px 0 7px; font-size: clamp(22px, 2.3vw, 31px); letter-spacing: -0.045em; line-height: 1.12; }
.hero-copy p { margin: 0; max-width: 620px; color: var(--muted); font-size: 12.5px; line-height: 1.65; }
.hero-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.hero-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(4, 9, 17, 0.4);
  color: var(--muted); font-size: 10.5px; font-weight: 600;
}
.hero-pill b { color: var(--text); font-weight: 700; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.dot.online { background: var(--green); }
.dot.degraded { background: var(--amber); }
.dot.offline { background: var(--red); }
.hero-device {
  flex: 0 0 238px;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(4, 9, 17, 0.42);
  display: flex; flex-direction: column;
}
.device-label { color: var(--faint); font-size: 9px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.hero-device strong { margin-top: 7px; font-size: 15px; letter-spacing: -0.02em; }
.hero-device > span:nth-of-type(2) { margin-top: 3px; color: var(--faint); font-size: 10.5px; line-height: 1.45; }
.device-meta { display: flex; gap: 18px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.device-meta span { display: flex; flex-direction: column; gap: 3px; }
.device-meta small { color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; }
.device-meta b { font-size: 13px; font-variant-numeric: tabular-nums; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi-card {
  position: relative;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: linear-gradient(170deg, rgba(15, 26, 46, 0.9), rgba(9, 16, 29, 0.95));
  overflow: hidden;
  transition: transform var(--ease), border-color var(--ease);
}
.kpi-card::before { content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 2px; opacity: 0.8; }
.kpi-cctv::before { background: linear-gradient(90deg, var(--blue), transparent 70%); }
.kpi-noc::before { background: linear-gradient(90deg, var(--cyan), transparent 70%); }
.kpi-sensor::before { background: linear-gradient(90deg, var(--violet), transparent 70%); }
.kpi-alert::before { background: linear-gradient(90deg, var(--amber), transparent 70%); }
.kpi-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.kpi-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: rgba(255, 255, 255, 0.04); }
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-cctv .kpi-icon { color: var(--blue); background: var(--blue-soft); }
.kpi-noc .kpi-icon { color: var(--cyan); background: var(--cyan-soft); }
.kpi-sensor .kpi-icon { color: var(--violet); background: var(--violet-soft); }
.kpi-alert .kpi-icon { color: var(--amber); background: var(--amber-soft); }
.kpi-trend { color: var(--faint); font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.kpi-label { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
.kpi-value { display: block; margin: 4px 0 3px; font-size: 27px; font-weight: 800; letter-spacing: -0.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-sub { display: block; color: var(--faint); font-size: 10.5px; line-height: 1.5; }

/* Module cards */
.modules-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.module-card {
  position: relative;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: linear-gradient(170deg, rgba(15, 26, 46, 0.92), rgba(8, 15, 27, 0.96));
  cursor: pointer;
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
  outline: none;
}
.module-card:hover, .module-card:focus-visible { transform: translateY(-3px); box-shadow: 0 20px 42px rgba(0, 0, 0, 0.32); }
.module-cctv:hover, .module-cctv:focus-visible { border-color: rgba(79, 140, 255, 0.4); }
.module-noc:hover, .module-noc:focus-visible { border-color: rgba(34, 199, 222, 0.4); }
.module-sensor:hover, .module-sensor:focus-visible { border-color: rgba(167, 139, 250, 0.4); }
.module-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.module-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; }
.module-icon svg { width: 19px; height: 19px; }
.module-cctv .module-icon { color: var(--blue); background: var(--blue-soft); }
.module-noc .module-icon { color: var(--cyan); background: var(--cyan-soft); }
.module-sensor .module-icon { color: var(--violet); background: var(--violet-soft); }
.status-badge {
  padding: 4px 8px; border-radius: 20px; font-size: 9px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  background: rgba(148, 163, 184, 0.1); color: var(--muted);
}
.status-badge.online { background: var(--green-soft); color: #8ee9c4; }
.status-badge.degraded { background: var(--amber-soft); color: #fbd38d; }
.status-badge.offline { background: var(--red-soft); color: #fca5a5; }
.module-card h3 { margin: 0 0 5px; font-size: 14.5px; letter-spacing: -0.02em; }
.module-card p { margin: 0 0 16px; min-height: 34px; color: var(--faint); font-size: 11px; line-height: 1.6; }
.module-stats { display: flex; gap: 16px; padding: 12px 0; margin-bottom: 12px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.module-stats span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.module-stats small { color: var(--faint); font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase; }
.module-stats b { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.module-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10.5px; font-weight: 650; }
.module-link svg { width: 13px; height: 13px; transition: transform var(--ease); }
.module-card:hover .module-link { color: var(--text); }
.module-card:hover .module-link svg { transform: translateX(3px); }

/* Side cards */
.side-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(175deg, rgba(14, 24, 42, 0.94), rgba(8, 15, 27, 0.98));
}
.side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.side-head h3 { margin: 4px 0 0; font-size: 15px; letter-spacing: -0.02em; }
.text-button {
  border: 0; background: transparent; color: var(--faint); font-size: 10.5px; font-weight: 650; cursor: pointer; padding: 4px 0;
}
.text-button:hover { color: var(--blue); }
.alert-feed { display: flex; flex-direction: column; gap: 8px; max-height: 430px; overflow-y: auto; padding-right: 3px; }
.alert-item {
  position: relative;
  padding: 11px 12px 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(4, 9, 17, 0.36);
}
.alert-item::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--faint); }
.alert-item.info::before { background: var(--blue); }
.alert-item.warning::before { background: var(--amber); }
.alert-item.critical::before { background: var(--red); }
.alert-top { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.alert-module {
  padding: 2px 6px; border-radius: 5px; font-size: 8px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  background: rgba(148, 163, 184, 0.1); color: var(--muted);
}
.alert-module.cctv { background: var(--blue-soft); color: #a9c7ff; }
.alert-module.noc { background: var(--cyan-soft); color: #8ce7f3; }
.alert-module.sensor { background: var(--violet-soft); color: #cdbdfd; }
.alert-time { margin-left: auto; color: var(--faint); font-size: 9px; white-space: nowrap; }
.alert-title { margin: 0; color: var(--text); font-size: 11.5px; font-weight: 650; line-height: 1.35; }
.alert-detail { margin: 3px 0 0; color: var(--faint); font-size: 10px; line-height: 1.45; }
.alert-snap { display: inline-block; margin-top: 6px; font-size: 9.5px; font-weight: 650; color: var(--blue); text-decoration: none; }
.alert-snap:hover { text-decoration: underline; }
.empty-state { padding: 26px 10px; text-align: center; color: var(--faint); font-size: 11px; line-height: 1.6; }

.meter-list { display: flex; flex-direction: column; gap: 12px; }
.meter { display: grid; grid-template-columns: 58px 1fr 40px; align-items: center; gap: 10px; }
.meter > span { color: var(--muted); font-size: 10px; font-weight: 600; }
.meter-track { height: 5px; border-radius: 4px; background: rgba(148, 163, 184, 0.12); overflow: hidden; }
.meter-track i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width 400ms ease, background 200ms ease; }
.meter.warn .meter-track i { background: linear-gradient(90deg, var(--amber), #f97316); }
.meter.danger .meter-track i { background: linear-gradient(90deg, #f97316, var(--red)); }
.meter > b { text-align: right; font-size: 10px; font-variant-numeric: tabular-nums; color: var(--muted); }
.system-list { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 9px; }
.system-list div { display: flex; justify-content: space-between; gap: 15px; }
.system-list dt { color: var(--faint); font-size: 10px; }
.system-list dd { margin: 0; color: var(--muted); font-size: 10px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }

/* Module frames */
.module-panel { display: flex; flex-direction: column; background: var(--bg); }
.frame-toolbar {
  flex: 0 0 42px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 15, 27, 0.94);
}
.frame-title { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.03em; }
.frame-dot { width: 6px; height: 6px; border-radius: 50%; }
.frame-dot.cctv { background: var(--blue); }
.frame-dot.noc { background: var(--cyan); }
.frame-dot.sensor { background: var(--violet); }
.frame-actions { display: flex; gap: 7px; }
.frame-button {
  padding: 6px 10px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--panel-soft);
  color: var(--muted); font-size: 10px; font-weight: 650; text-decoration: none; cursor: pointer;
}
.frame-button:hover { color: var(--text); border-color: var(--border-strong); }
.frame-shell { position: relative; flex: 1; min-height: 0; }
.frame-shell iframe { width: 100%; height: 100%; border: 0; background: #050a13; display: block; }
.frame-loader {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); transition: opacity 260ms ease;
}
.frame-loader.hidden { opacity: 0; pointer-events: none; }
.frame-loader p { margin: 0; color: var(--faint); font-size: 11px; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(148, 163, 184, 0.15); border-top-color: var(--blue); animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.statusbar {
  flex: 0 0 28px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 22px;
  border-top: 1px solid var(--border);
  background: rgba(6, 11, 21, 0.95);
  color: var(--faint); font-size: 9.5px;
}
.statusbar span { display: inline-flex; align-items: center; gap: 6px; }
.statusbar-spacer { flex: 1; }

/* Toast */
.toast {
  position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%);
  z-index: 100; padding: 11px 16px;
  border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--panel-raised); color: var(--text); font-size: 11.5px;
  box-shadow: var(--shadow);
}

/* Scrollbars */
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.22); border-radius: 6px; }
*::-webkit-scrollbar-track { background: transparent; }

/* Responsive */
@media (max-width: 1240px) {
  .overview-grid { grid-template-columns: 1fr; }
  .overview-side { display: grid; grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .modules-grid { grid-template-columns: 1fr; }
  .module-card p { min-height: 0; }
}
@media (max-width: 1000px) {
  .login-view { grid-template-columns: 1fr; }
  .login-story { display: none; }
  .login-panel { min-height: 100%; }
  .topbar-center { display: none; }
  .mini-metrics { display: none; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 14px; }
  .brand-copy small { display: none; }
  .operator-chip span:last-child { display: none; }
  .overview-scroll { padding: 16px 14px 26px; }
  .hero-card { flex-direction: column; padding: 22px; }
  .hero-device { flex-basis: auto; }
  .overview-side { grid-template-columns: 1fr; }
  .kpi-grid { gap: 10px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 23px; }
  .tabs { padding: 0 8px; }
  .tab { padding: 0 11px; font-size: 11.5px; }
  .tabs-meta { display: none; }
  .statusbar { gap: 10px; }
  .statusbar span:last-child { display: none; }
  .login-card { padding: 26px; border-radius: 18px; }
}

/* Diagnostics */
.alert-module.system { background: var(--amber-soft); color: #fbd38d; }
.diagnostics-layer {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  background: rgba(2, 6, 14, 0.72);
  backdrop-filter: blur(8px);
}
.diagnostics-panel {
  width: min(860px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 22px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(175deg, #0d1729, #080f1c);
  box-shadow: var(--shadow);
}
.diagnostics-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--border);
}
.diagnostics-head h2 { margin: 4px 0 4px; font-size: 22px; letter-spacing: -0.03em; }
.diagnostics-head p { margin: 0; color: var(--muted); font-size: 11.5px; }
.diagnostics-body { padding: 20px 26px 26px; }
.diagnostics-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.btn-primary.compact { width: auto; height: 34px; margin: 0; padding: 0 14px; font-size: 11px; border-radius: 8px; }
.diag-spacer { flex: 1; }
.diag-summary {
  padding: 12px 14px; margin-bottom: 14px;
  border-radius: 10px; border: 1px solid var(--border);
  background: rgba(4, 9, 17, 0.45);
  color: var(--muted); font-size: 11.5px; line-height: 1.5;
}
.diag-summary.pass { border-color: rgba(53, 212, 154, 0.3); background: var(--green-soft); color: #b7f7db; }
.diag-summary.warn { border-color: rgba(245, 185, 66, 0.3); background: var(--amber-soft); color: #fde6b0; }
.diag-summary.fail { border-color: rgba(248, 113, 113, 0.3); background: var(--red-soft); color: #fecaca; }
.diag-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.diag-check {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: rgba(4, 9, 17, 0.34);
}
.diag-badge {
  flex: 0 0 auto; margin-top: 1px;
  padding: 2px 6px; border-radius: 5px;
  font-size: 8px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
}
.diag-badge.pass { background: var(--green-soft); color: #8ee9c4; }
.diag-badge.warn { background: var(--amber-soft); color: #fbd38d; }
.diag-badge.fail { background: var(--red-soft); color: #fca5a5; }
.diag-check strong { display: block; font-size: 10.5px; font-weight: 650; }
.diag-check small { display: block; margin-top: 2px; color: var(--faint); font-size: 9.5px; line-height: 1.45; word-break: break-word; }
.diag-cameras { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.diag-cameras-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.diag-cameras-head h3 { margin: 0; font-size: 12px; }
.diag-camera {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(4, 9, 17, 0.3);
  font-size: 10.5px;
}
.diag-camera .diag-camera-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diag-camera .diag-result { color: var(--muted); font-size: 9.5px; text-align: right; max-width: 55%; }
.diag-camera .diag-result.pass { color: #8ee9c4; }
.diag-camera .diag-result.fail { color: #fca5a5; }
.diag-camera button { flex: 0 0 auto; }
.diag-output {
  margin: 0; padding: 12px 14px; max-height: 220px; overflow: auto;
  border-radius: 9px; border: 1px solid var(--border);
  background: #040911; color: #b8c7e0;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 10px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
@media (max-width: 720px) {
  .diag-checks { grid-template-columns: 1fr; }
  .diagnostics-layer { padding: 10px; }
  .diagnostics-head, .diagnostics-body { padding-left: 16px; padding-right: 16px; }
  .diag-spacer { display: none; }
}
