:root {
  color-scheme: dark;
  --bg: #090d14;
  --surface: #101620;
  --surface-2: #151d29;
  --line: #273142;
  --text: #f5f7fa;
  --muted: #8d99aa;
  --cyan: #57d7d2;
  --cyan-soft: #173b3c;
  --red: #fa6464;
  --amber: #f1b85b;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--cyan); text-transform: uppercase; letter-spacing: .15em; font-size: 11px; font-weight: 750; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(25px, 3vw, 38px); line-height: 1.05; letter-spacing: -.035em; }
h2 { margin-bottom: 4px; font-size: 17px; letter-spacing: -.01em; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(400px, .9fr) 1.1fr; }
.login-panel { padding: clamp(34px, 7vw, 110px); display: flex; flex-direction: column; justify-content: center; }
.login-panel h1 { max-width: 580px; margin: 30px 0 16px; font-size: clamp(36px, 5vw, 64px); }
.login-panel > .muted { max-width: 510px; font-size: 17px; line-height: 1.55; }
.login-panel form { max-width: 420px; margin-top: 34px; }
.login-aside { min-height: 100vh; padding: 9vw; background: #0c141e; display: flex; align-items: flex-end; position: relative; overflow: hidden; }
.login-aside::after { content: ""; position: absolute; inset: 12%; border: 1px solid #1d3942; border-radius: 50%; transform: rotate(-18deg); }
.login-aside > div:last-child { max-width: 380px; z-index: 2; }
.login-aside strong { font-size: 22px; }
.login-aside p { color: var(--muted); line-height: 1.6; }
.signal-orbit { position: absolute; width: 420px; height: 420px; left: 50%; top: 42%; transform: translate(-50%, -50%); }
.signal-orbit span { position: absolute; inset: 0; border: 1px solid #20434a; border-radius: 50%; animation: pulse 4s infinite ease-out; }
.signal-orbit span:nth-child(2) { inset: 16%; animation-delay: .5s; }
.signal-orbit span:nth-child(3) { inset: 32%; animation-delay: 1s; }
.signal-orbit i { position: absolute; width: 42px; height: 42px; inset: calc(50% - 21px); background: var(--cyan); border: 12px solid #193b3c; border-radius: 50%; box-shadow: 0 0 45px #57d7d288; }
@keyframes pulse { 50% { border-color: #57d7d266; transform: scale(1.04); } }

.brand { display: flex; align-items: center; gap: 11px; font-weight: 750; letter-spacing: -.02em; }
.brand-large { font-size: 18px; }
.brand-mark { width: 31px; height: 31px; border-radius: 8px; display: grid; place-items: center; color: #061111; background: var(--cyan); font-weight: 900; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); background: #0c111a; padding: 24px 16px; display: flex; flex-direction: column; }
.sidebar .brand { padding: 0 8px 29px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { width: 100%; border: 0; background: transparent; padding: 11px 13px; color: var(--muted); border-radius: 9px; text-align: left; cursor: pointer; display: flex; gap: 12px; align-items: center; }
.nav-item:hover { color: var(--text); background: #151c27; }
.nav-item.active { color: var(--text); background: var(--surface-2); box-shadow: inset 3px 0 var(--cyan); }
.nav-item span { color: var(--cyan); width: 18px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 18px 8px 0; border-top: 1px solid var(--line); }
.system-dot { display: flex; gap: 10px; align-items: center; margin-bottom: 17px; }
.system-dot > span { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px #57d7d288; }
.system-dot strong, .system-dot small { display: block; }
.system-dot strong { font-size: 12px; }
.system-dot small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.text-button { border: 0; padding: 0; background: transparent; color: var(--muted); cursor: pointer; }

main { min-width: 0; }
.topbar { height: 98px; display: flex; justify-content: space-between; align-items: center; padding: 20px 32px; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 28px; }
.top-actions { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 13px; }
.button { border-radius: 8px; border: 1px solid var(--line); padding: 10px 16px; cursor: pointer; font-weight: 700; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--cyan); border-color: var(--cyan); color: #071111; }
.button.secondary { background: var(--surface-2); color: var(--text); }
.page { padding: 26px 32px 38px; }
.stats-line { display: flex; gap: 38px; padding-bottom: 23px; }
.stats-line div { display: flex; align-items: baseline; gap: 8px; }
.stats-line span { font-size: 26px; font-weight: 780; }
.stats-line small { color: var(--muted); }
.live-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); border: 1px solid var(--line); min-height: calc(100vh - 202px); background: var(--surface); }
.camera-rail { border-right: 1px solid var(--line); min-width: 0; }
.section-head { min-height: 65px; padding: 17px 18px; display: flex; justify-content: space-between; align-items: center; }
.section-head p { margin: 5px 0 0; font-size: 12px; }
.section-head > span { color: var(--muted); font-size: 12px; }
.camera-list { border-top: 1px solid var(--line); }
.camera-item { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; padding: 15px 17px; cursor: pointer; display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 10px; }
.camera-item:hover, .camera-item.active { background: #16202c; }
.camera-item.active { box-shadow: inset 3px 0 var(--cyan); }
.camera-item .status { width: 7px; height: 7px; border-radius: 50%; background: #596273; }
.camera-item .status.online { background: var(--cyan); box-shadow: 0 0 9px #57d7d288; }
.camera-item .status.unstable { background: var(--amber); }
.camera-item strong, .camera-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camera-item strong { font-size: 13px; }
.camera-item small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.camera-item em { color: var(--muted); font-style: normal; font-size: 16px; }
.monitor-column { min-width: 0; display: grid; grid-template-rows: minmax(420px, 1fr) auto; }
.video-frame { min-height: 420px; position: relative; background: #05080c; overflow: hidden; }
.video-frame video { width: 100%; height: 100%; object-fit: contain; position: absolute; }
.video-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; color: var(--muted); gap: 10px; }
.video-empty strong { color: var(--text); margin-top: 7px; }
.lens { width: 64px; height: 64px; border: 1px solid #29404b; border-radius: 50%; position: relative; }
.lens::after { content: ""; position: absolute; inset: 18px; border-radius: 50%; background: var(--cyan-soft); border: 1px solid var(--cyan); }
.video-overlay { position: absolute; inset: 0 0 auto; min-height: 64px; padding: 17px; display: flex; align-items: center; gap: 12px; background: linear-gradient(#05080cdd, transparent); pointer-events: none; }
.video-overlay > * { pointer-events: auto; }
.live-badge { color: var(--red); font-weight: 800; font-size: 11px; letter-spacing: .08em; }
#videoName { font-weight: 700; font-size: 13px; }
.overlay-button { margin-left: auto; background: #0e151ed9; border: 1px solid #394759; border-radius: 7px; padding: 8px 12px; cursor: pointer; }
.timeline-panel { border-top: 1px solid var(--line); min-height: 150px; }
.timeline { height: 38px; margin: 0 22px; position: relative; }
.timeline-track { position: absolute; top: 17px; width: 100%; height: 3px; background: #2b3442; }
.timeline-event { position: absolute; top: 12px; height: 13px; min-width: 4px; background: var(--cyan); border-radius: 2px; cursor: pointer; }
.timeline-now { position: absolute; height: 31px; top: 3px; width: 1px; background: var(--red); left: 72%; }
.timeline-now::before { content: ""; position: absolute; width: 7px; height: 7px; left: -3px; border-radius: 50%; background: var(--red); }
.hour-labels { padding: 0 18px 14px; display: flex; justify-content: space-between; color: #707b8b; font-size: 9px; }

label { color: #b7c0cc; font-size: 12px; font-weight: 650; }
input, select { width: 100%; color: var(--text); background: #0d131c; border: 1px solid var(--line); border-radius: 7px; padding: 11px 12px; margin-top: 7px; outline: none; }
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px #57d7d21c; }
.stack { display: grid; gap: 16px; }
.form-error { min-height: 18px; color: var(--red); font-size: 12px; margin: 0; }
.archive-tools { display: grid; grid-template-columns: minmax(200px, 1fr) 170px 170px auto; gap: 12px; align-items: end; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.archive-summary { display: flex; justify-content: space-between; align-items: center; padding: 25px 0 12px; }
.archive-list { border-top: 1px solid var(--line); }
.archive-row { min-height: 72px; display: grid; grid-template-columns: 160px minmax(180px, 1fr) 120px 120px; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.archive-row small { color: var(--muted); display: block; }
.empty-state { padding: 55px 20px; text-align: center; color: var(--muted); }
.data-table { border-top: 1px solid var(--line); margin-top: 15px; }
.camera-row { display: grid; grid-template-columns: minmax(220px, 1.5fr) 1fr 1fr 120px 90px; gap: 16px; align-items: center; min-height: 72px; border-bottom: 1px solid var(--line); }
.camera-row strong, .camera-row small { display: block; }
.camera-row small { color: var(--muted); margin-top: 4px; }
.status-text.online { color: var(--cyan); }
.status-text.unstable { color: var(--amber); }
.status-text.offline { color: #7e8998; }
.link-button { color: var(--cyan); border: 0; background: transparent; cursor: pointer; text-align: left; padding: 0; }
.system-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.system-grid article { min-height: 220px; background: var(--surface); padding: 26px; }
.system-grid h2 { font-size: 18px; word-break: break-word; }
.system-grid article > p:last-child { color: var(--muted); line-height: 1.55; margin-top: 18px; }

dialog { width: min(700px, calc(100vw - 30px)); max-height: 90vh; padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 28px 90px #000b; }
dialog::backdrop { background: #03060aaa; backdrop-filter: blur(4px); }
.dialog-head { padding: 21px 23px 17px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 28px; cursor: pointer; }
.dialog-tabs { padding: 0 23px; display: flex; gap: 23px; border-bottom: 1px solid var(--line); }
.dialog-tabs button { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 14px 0 12px; cursor: pointer; }
.dialog-tabs button.active { color: var(--text); border-bottom-color: var(--cyan); }
.dialog-body { padding: 23px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--cyan); }
.check.inline { align-self: end; padding-bottom: 12px; }
.button-row { display: flex; gap: 10px; }
.dialog-message { min-height: 18px; color: var(--cyan); margin: 0 23px 20px; font-size: 12px; }
.ptz-pad { width: 190px; margin: 25px auto 8px; display: grid; grid-template-columns: repeat(3, 58px); gap: 7px; }
.ptz-pad button { width: 58px; height: 48px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; font-size: 19px; }
.ptz-pad button:first-child { grid-column: 2; }
.ptz-pad button:nth-child(2) { grid-column: 1; }
.ptz-pad button:nth-child(5) { grid-column: 2; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 15px; border: 1px solid #325255; background: #112326; border-radius: 8px; color: var(--text); opacity: 0; transform: translateY(12px); transition: .2s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .sidebar .brand span:last-child, .nav-item:not(.active) { font-size: 0; }
  .nav-item { justify-content: center; }
  .nav-item.active { font-size: 0; }
  .nav-item span { font-size: 17px; }
  .sidebar-foot { display: none; }
  .live-layout { grid-template-columns: 210px minmax(0, 1fr); }
  .system-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 5; height: 64px; width: 100%; top: auto; bottom: 0; border: 0; border-top: 1px solid var(--line); padding: 7px 8px; }
  .sidebar .brand, .sidebar-foot { display: none; }
  .sidebar nav { display: grid; grid-template-columns: repeat(4, 1fr); }
  .nav-item, .nav-item.active, .nav-item:not(.active) { height: 49px; display: grid; justify-items: center; gap: 0; padding: 4px; font-size: 9px; }
  .nav-item span { font-size: 15px; }
  .topbar { height: 78px; padding: 15px 17px; }
  .top-actions #clock { display: none; }
  .page { padding: 18px 14px 88px; }
  .stats-line { gap: 16px; }
  .stats-line span { font-size: 21px; }
  .live-layout { display: block; min-height: 0; }
  .camera-rail { border-right: 0; max-height: 200px; overflow: auto; }
  .monitor-column { grid-template-rows: 330px auto; }
  .video-frame { min-height: 330px; }
  .archive-tools { grid-template-columns: 1fr 1fr; }
  .archive-tools label:first-child { grid-column: 1 / -1; }
  .archive-row, .camera-row { grid-template-columns: 1fr 1fr; padding: 14px 0; }
  .form-row { grid-template-columns: 1fr; }
}
