:root {
  color-scheme: dark;
  --bg: #090d14;
  --panel: #101722;
  --panel-soft: #151e2c;
  --line: #273244;
  --text: #f1f5f9;
  --muted: #93a4b8;
  --accent: #37dda0;
  --danger: #f45b66;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 75% 0%, #142333 0, var(--bg) 34rem); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }
.topbar { height: 4.5rem; padding: 0 clamp(1rem, 4vw, 3rem); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(147, 164, 184, .14); }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--text); text-decoration: none; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 1.35rem; height: 1.35rem; border: 2px solid var(--accent); border-radius: 50%; box-shadow: inset 0 0 0 4px var(--bg); background: var(--accent); }
.connection { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .875rem; }
.topbar-actions, .account { display: flex; align-items: center; gap: .75rem; }
.account { padding-left: .75rem; border-left: 1px solid var(--line); font-size: .82rem; }
.role-badge { padding: .25rem .45rem; border-radius: .35rem; color: var(--accent); background: rgba(55, 221, 160, .1); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.logout-button { padding: .35rem .55rem; border: 1px solid var(--line); border-radius: .4rem; color: var(--muted); background: transparent; cursor: pointer; }
.dot { width: .55rem; height: .55rem; border-radius: 50%; background: #667085; box-shadow: 0 0 0 4px rgba(102, 112, 133, .12); }
.dot.online { background: var(--accent); box-shadow: 0 0 0 4px rgba(55, 221, 160, .12); }
main { width: min(1440px, 100%); margin: 0 auto; padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 4vw, 3rem) 4rem; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 2rem; }
.eyebrow, .panel-label { margin: 0 0 .45rem; color: var(--accent); text-transform: uppercase; letter-spacing: .11em; font-size: .75rem; font-weight: 800; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 4rem); line-height: .98; letter-spacing: -.055em; }
.lede { max-width: 42rem; margin: .9rem 0 0; color: var(--muted); font-size: 1rem; line-height: 1.6; }
.arm-button { min-height: 3rem; padding: .75rem 1rem; border: 1px solid rgba(55, 221, 160, .35); border-radius: .75rem; background: rgba(55, 221, 160, .1); display: flex; align-items: center; gap: .65rem; cursor: pointer; font-weight: 700; white-space: nowrap; }
.arm-button[aria-pressed="false"] { border-color: var(--line); background: var(--panel); color: var(--muted); }
.arm-button:disabled { opacity: .6; cursor: not-allowed; }
.arm-icon { width: .65rem; height: .65rem; border-radius: 50%; background: var(--accent); }
.arm-button[aria-pressed="false"] .arm-icon { background: #667085; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(19rem, 24rem); gap: 1rem; align-items: start; }
.workspace-column { min-width: 0; display: grid; gap: 1rem; }
.cameras-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.panel { border: 1px solid var(--line); border-radius: 1rem; background: rgba(16, 23, 34, .92); overflow: hidden; box-shadow: 0 1.2rem 4rem rgba(0, 0, 0, .16); }
.camera-loading { min-height: 20rem; grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; color: var(--muted); }
.panel-heading { min-height: 5rem; padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-heading h2 { margin: 0; font-size: 1.15rem; letter-spacing: -.025em; }
.camera-title { max-width: 18rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-label { color: var(--muted); margin-bottom: .25rem; }
.live-pill { padding: .35rem .55rem; border: 1px solid var(--line); border-radius: .4rem; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; }
.live-pill.online { color: var(--accent); border-color: rgba(55, 221, 160, .35); background: rgba(55, 221, 160, .08); }
.video-wrap { position: relative; aspect-ratio: 16 / 9; background: #05080d; overflow: hidden; }
.view-selector { padding: .45rem 1.25rem; display: flex; justify-content: flex-end; gap: .25rem; border-top: 1px solid var(--line); background: rgba(5, 8, 13, .28); }
.view-button { padding: .32rem .65rem; border: 1px solid transparent; border-radius: .4rem; color: var(--muted); background: transparent; cursor: pointer; font-size: .75rem; font-weight: 700; }
.view-button:hover { color: var(--text); }
.view-button.active { border-color: rgba(55, 221, 160, .35); color: var(--accent); background: rgba(55, 221, 160, .09); }
.video-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; }
.video-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .65rem; color: var(--muted); text-align: center; padding: 2rem; background: #080d14; }
.video-placeholder.hidden { display: none; }
.video-placeholder strong { color: var(--text); }
.loader { width: 1.6rem; height: 1.6rem; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.metrics div { padding: 1rem 1.25rem; border-right: 1px solid var(--line); }
.metrics div:last-child { border: 0; }
.metrics span, .metrics strong { display: block; }
.metrics span { color: var(--muted); font-size: .8rem; margin-bottom: .35rem; }
.metrics strong { font-size: .95rem; }
.icon-button { width: 2.5rem; height: 2.5rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--panel-soft); cursor: pointer; font-size: 1.25rem; }
.events-list { max-height: 42rem; overflow-y: auto; border-top: 1px solid var(--line); }
.event { display: grid; grid-template-columns: 5rem 1fr; gap: .9rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .15s ease; }
.event:hover, .event:focus-visible { background: rgba(55, 221, 160, .06); outline: 0; }
.event:last-child { border-bottom: 0; }
.event img { width: 5rem; height: 3.5rem; object-fit: cover; border-radius: .45rem; background: #080d14; }
.event-title { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.event-title strong { font-size: .9rem; }
.event-title span { color: var(--accent); font-size: .8rem; font-variant-numeric: tabular-nums; }
.event time { display: block; margin-top: .45rem; color: var(--muted); font-size: .8rem; }
.event-kind { display: block; margin-top: .25rem; color: var(--muted); font-size: .75rem; }
.empty { margin: 0; padding: 3rem 1.25rem; color: var(--muted); text-align: center; line-height: 1.6; }
.controls-body { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.controls-loading { grid-column: 1 / -1; min-height: 8rem; display: flex; align-items: center; justify-content: center; gap: .75rem; color: var(--muted); }
.control-group { min-width: 0; padding: 1rem 1.25rem; border-right: 1px solid var(--line); }
.control-group:last-child { border-right: 0; }
.control-group h3 { margin: 0 0 .55rem; color: var(--muted); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; }
.control-row { min-height: 2.65rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; border-bottom: 1px solid rgba(39, 50, 68, .65); font-size: .86rem; }
.control-row:last-child { border-bottom: 0; }
.control-label { line-height: 1.25; }
.control-row select { max-width: 8.5rem; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: .45rem; color: var(--text); background: var(--panel-soft); }
.switch { position: relative; flex: 0 0 auto; width: 2.35rem; height: 1.35rem; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-track { position: absolute; inset: 0; border: 1px solid var(--line); border-radius: 2rem; background: #283342; cursor: pointer; transition: .15s ease; }
.switch-track::after { content: ""; position: absolute; top: .18rem; left: .2rem; width: .86rem; height: .86rem; border-radius: 50%; background: #a9b5c4; transition: .15s ease; }
.switch input:checked + .switch-track { border-color: rgba(55, 221, 160, .5); background: rgba(55, 221, 160, .22); }
.switch input:checked + .switch-track::after { transform: translateX(1rem); background: var(--accent); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; cursor: wait; }
.range-control { display: flex; align-items: center; gap: .5rem; }
.range-control input { width: 5.5rem; accent-color: var(--accent); }
.range-control output { min-width: 1.8rem; color: var(--accent); text-align: right; font-variant-numeric: tabular-nums; }
.ptz-section { min-height: 5.5rem; padding: .9rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); background: rgba(5, 8, 13, .25); }
.ptz-copy { display: grid; gap: .3rem; }
.ptz-copy span { color: var(--muted); font-size: .8rem; }
.ptz-pad { display: grid; grid-template-columns: repeat(3, 2.25rem); gap: .3rem; }
.ptz-pad button { width: 2.25rem; height: 2.25rem; border: 1px solid var(--line); border-radius: .45rem; background: var(--panel-soft); }
.ptz-pad button:nth-child(1) { grid-column: 2; grid-row: 1; }
.ptz-pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.ptz-pad button:nth-child(3) { grid-column: 2; grid-row: 2; }
.ptz-pad button:nth-child(4) { grid-column: 3; grid-row: 2; }
.ptz-pad button:nth-child(5) { grid-column: 2; grid-row: 3; }
.ptz-pad button:disabled { color: #647184; opacity: .55; }
.controls-message { min-height: 2.2rem; margin: 0; padding: .55rem 1.25rem; border-top: 1px solid var(--line); color: var(--accent); font-size: .8rem; }
.controls-message.error { color: var(--danger); }
.auth-screen { min-height: calc(100vh - 4.5rem); padding: 2rem 1rem; display: grid; place-items: center; }
.auth-card { width: min(28rem, 100%); padding: clamp(1.5rem, 5vw, 2.5rem); }
.auth-card h1 { margin-bottom: .75rem; font-size: clamp(2rem, 8vw, 3rem); }
.auth-description { margin: 0 0 1.6rem; color: var(--muted); line-height: 1.55; }
.auth-field, .guest-form label { display: grid; gap: .45rem; margin-bottom: 1rem; color: var(--muted); font-size: .8rem; font-weight: 700; }
.auth-field input, .guest-form input, .guest-form select { width: 100%; min-height: 2.75rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: .55rem; color: var(--text); background: #0a111b; outline: 0; }
.auth-field input:focus, .guest-form input:focus, .guest-form select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(55, 221, 160, .1); }
.auth-field small { color: var(--muted); font-weight: 500; }
.auth-field code { color: var(--text); }
.primary-button, .secondary-button { min-height: 2.5rem; padding: .6rem .85rem; border: 1px solid rgba(55, 221, 160, .4); border-radius: .55rem; background: rgba(55, 221, 160, .12); color: var(--accent); cursor: pointer; font-weight: 750; }
.primary-button { width: 100%; }
.primary-button:disabled, .secondary-button:disabled { opacity: .5; cursor: wait; }
.auth-error { min-height: 1.2rem; margin: .8rem 0 0; color: var(--danger); font-size: .8rem; }
.access-layout { display: grid; grid-template-columns: minmax(16rem, 22rem) 1fr; border-top: 1px solid var(--line); }
.guest-form, .guest-list-wrap { padding: 1.25rem; }
.guest-form { border-right: 1px solid var(--line); }
.guest-form h3, .guest-list-wrap h3 { margin: 0 0 1rem; font-size: .95rem; }
.guest-list { border: 1px solid var(--line); border-radius: .65rem; overflow: hidden; }
.guest-list .empty { padding: 2rem 1rem; }
.guest-row { min-height: 4rem; padding: .75rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); }
.guest-row:last-child { border-bottom: 0; }
.guest-row div { min-width: 0; display: grid; gap: .3rem; }
.guest-row strong { overflow: hidden; text-overflow: ellipsis; }
.guest-row small { color: var(--muted); }
.guest-row .guest-expired { color: var(--danger); }
.danger-button { border-color: rgba(244, 91, 102, .35); color: var(--danger); background: rgba(244, 91, 102, .08); }
.guest-credentials { margin-bottom: 1rem; padding: .85rem; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem; border: 1px solid rgba(55, 221, 160, .35); border-radius: .65rem; background: rgba(55, 221, 160, .06); }
.guest-credentials strong, .guest-credentials small { grid-column: 1 / -1; }
.guest-credentials code { min-width: 0; overflow-wrap: anywhere; color: var(--text); }
.guest-credentials small { color: var(--muted); }
.event-dialog { width: min(76rem, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 1px solid var(--line); border-radius: 1rem; color: var(--text); background: var(--panel); box-shadow: 0 2rem 8rem rgba(0, 0, 0, .6); }
.event-dialog::backdrop { background: rgba(3, 7, 12, .78); backdrop-filter: blur(5px); }
.event-dialog-shell { display: grid; max-height: calc(100vh - 2rem); grid-template-rows: auto minmax(0, 1fr); }
.event-dialog-header { min-height: 5rem; padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.event-dialog-header h2 { margin: 0; }
.event-dialog-body { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 19rem; }
.evidence-viewer { min-width: 0; display: grid; grid-template-rows: auto minmax(18rem, 1fr) auto; background: #05080d; }
.evidence-selector { min-height: 3.25rem; padding: .55rem 1rem; display: flex; align-items: center; gap: .4rem; border-bottom: 1px solid var(--line); }
.evidence-button { padding: .45rem .8rem; border: 1px solid var(--line); border-radius: .45rem; color: var(--muted); background: var(--panel-soft); cursor: pointer; }
.evidence-button.active { border-color: rgba(55, 221, 160, .45); color: var(--accent); background: rgba(55, 221, 160, .09); }
.evidence-viewport { min-height: 0; overflow: auto; display: flex; align-items: flex-start; }
.evidence-stage { flex: 0 0 auto; width: 100%; min-width: 100%; transition: width .12s ease; }
.evidence-stage img { display: block; width: 100%; height: auto; min-height: 12rem; object-fit: contain; background: #05080d; }
.zoom-control { min-height: 3.4rem; padding: .7rem 1rem; display: flex; align-items: center; gap: .75rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.zoom-control input { flex: 1; accent-color: var(--accent); }
.zoom-control output { min-width: 3.2rem; color: var(--accent); text-align: right; font-variant-numeric: tabular-nums; }
.event-details { overflow-y: auto; padding: 1.25rem; border-left: 1px solid var(--line); }
.event-summary { margin: 0; display: grid; grid-template-columns: 6rem 1fr; gap: .7rem .8rem; }
.event-summary dt { color: var(--muted); font-size: .8rem; }
.event-summary dd { margin: 0; overflow-wrap: anywhere; font-size: .86rem; }
.event-metadata { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.event-metadata summary { color: var(--muted); cursor: pointer; font-size: .82rem; }
.event-metadata pre { max-width: 100%; overflow: auto; padding: .8rem; border-radius: .5rem; color: #bac7d7; background: #080d14; font-size: .72rem; white-space: pre-wrap; }
@media (max-width: 1120px) { .layout { grid-template-columns: 1fr; } .events-list { max-height: none; } }
@media (max-width: 920px) { .controls-body { grid-template-columns: repeat(2, minmax(0, 1fr)); } .control-group:nth-child(2) { border-right: 0; } .control-group:nth-child(-n+2) { border-bottom: 1px solid var(--line); } }
@media (max-width: 760px) { .access-layout { grid-template-columns: 1fr; } .guest-form { border-right: 0; border-bottom: 1px solid var(--line); } .connection { display: none; } }
@media (max-width: 720px) { .cameras-grid { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .hero { align-items: stretch; flex-direction: column; } .arm-button { justify-content: center; } .metrics { grid-template-columns: 1fr; } .metrics div { border-right: 0; border-bottom: 1px solid var(--line); } .topbar { padding-inline: 1rem; } .controls-body { grid-template-columns: 1fr; } .control-group { border-right: 0; border-bottom: 1px solid var(--line); } .ptz-section { align-items: flex-start; flex-direction: column; } #account-name { display: none; } .role-badge { display: none; } }
@media (max-width: 780px) { .event-dialog-body { grid-template-columns: 1fr; overflow-y: auto; } .evidence-viewer { min-height: 28rem; } .event-details { overflow: visible; border-left: 0; border-top: 1px solid var(--line); } }
@media (prefers-reduced-motion: reduce) { .loader { animation: none; } }
