:root {
  --bg: #080b0f;
  --panel: #10151b;
  --panel-2: #151b22;
  --line: #242c35;
  --text: #f4f7f9;
  --muted: #8f9ba7;
  --faint: #596570;
  --green: #51e39a;
  --green-dark: #173c2d;
  --red: #ff6f76;
  --amber: #f4c56a;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 70% -20%, #18231f 0, transparent 36%), var(--bg); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 17px; font-weight: 750; letter-spacing: -.03em; }
.brand--large { justify-content: center; font-size: 20px; }
.brand-mark { position: relative; display: grid; width: 27px; height: 27px; place-items: center; border: 2px solid var(--green); border-radius: 9px; transform: rotate(45deg); box-shadow: 0 0 24px #51e39a22; }
.brand-mark span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.brand--large .brand-mark { width: 32px; height: 32px; }

/* Authentication and setup */
.auth-shell { display: grid; min-height: 100vh; padding: 28px 18px; place-items: center; background: radial-gradient(circle at 50% 15%, #14221c 0, #090d11 40%, #06080b 100%); }
.auth-shell::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .18; background-image: linear-gradient(#ffffff07 1px, transparent 1px), linear-gradient(90deg, #ffffff07 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, black, transparent 75%); }
.login-card, .setup-card, .message-card { position: relative; width: min(100%, 430px); padding: 38px; border: 1px solid var(--line); border-radius: 24px; background: #0e1318e8; box-shadow: 0 28px 90px #0009; backdrop-filter: blur(18px); }
.setup-card { width: min(100%, 760px); }
.message-card { text-align: center; }
.message-card h1 { margin: 30px 0 10px; font-size: 28px; }
.message-card p { color: var(--muted); line-height: 1.6; }
.login-heading, .setup-heading { margin: 40px 0 26px; }
.login-heading h1, .setup-heading h1 { margin: 0; font-size: clamp(30px, 5vw, 40px); letter-spacing: -.045em; }
.login-heading p:last-child, .setup-heading p:last-child { margin: 12px 0 0; color: var(--muted); line-height: 1.6; }
.login-form, .setup-form { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; }
.field > span, .compact-field > span { color: #c7d0d7; font-size: 12px; font-weight: 700; }
.field input, .field select, .compact-field select { width: 100%; height: 48px; padding: 0 14px; color: var(--text); border: 1px solid #2a333d; border-radius: 11px; outline: none; background: #0a0e12; transition: border .2s, box-shadow .2s; }
.field input:focus, .field select:focus, .compact-field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px #51e39a16; }
.button { display: inline-flex; min-height: 45px; padding: 0 18px; align-items: center; justify-content: center; gap: 12px; border: 0; border-radius: 11px; font-weight: 750; text-decoration: none; cursor: pointer; }
.button--primary { color: #07130d; background: var(--green); box-shadow: 0 9px 30px #51e39a20; }
.button--primary:hover { background: #72eaaa; }
.button--primary:disabled { opacity: .45; cursor: not-allowed; }
.button--secondary { color: var(--text); border: 1px solid var(--line); background: var(--panel-2); }
.button--wide { width: 100%; margin-top: 3px; }
.alert { padding: 13px 15px; margin: 0 0 20px; border-radius: 11px; font-size: 13px; line-height: 1.5; }
.alert--error { color: #ffc2c5; border: 1px solid #ff6f7644; background: #3b171a; }
.alert--warning { color: #ffe4ab; border: 1px solid #f4c56a44; background: #382b14; }
.alert--success { color: #b9f5d6; border: 1px solid #51e39a44; background: #123526; }
.alert code { display: inline-block; padding: 1px 5px; color: inherit; border-radius: 4px; background: #0004; }
.privacy-note { margin-top: 24px; color: var(--faint); font-size: 11px; text-align: center; }
.setup-form fieldset { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 15px; }
.setup-form legend { padding: 0 10px 0 0; font-size: 14px; font-weight: 800; }
.setup-form legend span { display: inline-grid; width: 25px; height: 25px; margin-right: 8px; place-items: center; color: var(--green); border: 1px solid #51e39a55; border-radius: 8px; background: #51e39a10; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-hint { align-self: center; color: var(--faint); font-size: 12px; line-height: 1.5; }
.field-hint--wide { grid-column: 1 / -1; }
.error-code { margin: 30px 0 0 !important; color: var(--green) !important; font-size: 60px; font-weight: 800; letter-spacing: -.07em; }

/* Application shell */
.app-shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; padding: 25px 18px 18px; flex-direction: column; border-right: 1px solid #1c232b; background: #0a0e12e8; backdrop-filter: blur(18px); }
.sidebar .brand { padding: 0 10px 29px; border-bottom: 1px solid #1c232b; }
.primary-nav { display: grid; gap: 6px; margin-top: 22px; }
.nav-item { display: flex; width: 100%; height: 45px; padding: 0 13px; align-items: center; gap: 12px; color: var(--muted); border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: left; }
.nav-item:hover { color: var(--text); background: #ffffff07; }
.nav-item.is-active { color: var(--text); background: #17221d; }
.nav-item.is-active .nav-icon { color: var(--green); }
.nav-icon { width: 20px; text-align: center; }
.sidebar-foot { display: grid; gap: 14px; margin-top: auto; }
.private-badge { display: flex; padding: 12px; align-items: center; gap: 10px; border: 1px solid #203229; border-radius: 11px; background: #101b16; }
.private-badge > span { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.private-badge div, .user-button > span:nth-child(2) { display: grid; gap: 2px; }
.private-badge strong, .user-button strong { font-size: 11px; }
.private-badge small, .user-button small { color: var(--faint); font-size: 9px; }
.user-button { display: grid; padding: 9px 7px; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: left; }
.user-button:hover { background: #ffffff08; }
.avatar { display: grid; width: 34px; height: 34px; place-items: center; color: #0a1510; border-radius: 10px; background: #a9e7c7; font-weight: 800; }
.main-content { min-width: 0; padding: 0 38px 48px; }
.topbar { display: flex; min-height: 112px; align-items: center; justify-content: space-between; border-bottom: 1px solid #1c232b; }
.topbar h1 { margin: 0; font-size: 27px; letter-spacing: -.04em; }
.topbar-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.status-dot.is-online { background: var(--green); box-shadow: 0 0 10px #51e39a88; }
.status-dot.is-error { background: var(--red); }
.topbar-time { padding-left: 12px; margin-left: 8px; border-left: 1px solid var(--line); color: #d3dae0; font-variant-numeric: tabular-nums; }
.view { display: none; padding-top: 28px; }
.view.is-active { display: block; animation: appear .25s ease; }
@keyframes appear { from { opacity: 0; transform: translateY(3px); } }
.section-intro { display: flex; margin-bottom: 20px; align-items: center; justify-content: space-between; }
.section-intro p { margin: 0; color: var(--muted); font-size: 13px; }
.icon-button { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; }
.camera-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 18px; }
.loading-card { display: grid; min-height: 360px; place-items: center; align-content: center; gap: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.spinner { width: 25px; height: 25px; border: 2px solid #ffffff18; border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.camera-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 18px 60px #0003; }
.video-frame { position: relative; overflow: hidden; aspect-ratio: 16 / 9; background: #020304; }
.video-frame video { display: block; width: 100%; height: 100%; object-fit: contain; background: #020304; }
.camera-overlay { position: absolute; inset: 0; display: flex; padding: 15px; align-items: flex-start; justify-content: space-between; pointer-events: none; background: linear-gradient(to bottom, #0007, transparent 25%); }
.live-pill, .recorded-pill { display: inline-flex; padding: 6px 9px; align-items: center; gap: 6px; color: #e7fff3; border: 1px solid #51e39a55; border-radius: 7px; background: #123627d9; font-size: 9px; font-weight: 900; letter-spacing: .09em; }
.live-pill i, .recorded-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.quality-pill { padding: 6px 8px; border-radius: 7px; background: #05080bba; color: #cbd3da; font-size: 10px; }
.stream-message { position: absolute; inset: 0; display: none; padding: 20px; place-items: center; align-content: center; gap: 8px; color: var(--muted); text-align: center; background: #080b0f; }
.stream-message.is-visible { display: grid; }
.stream-message strong { color: var(--text); }
.camera-footer { display: flex; padding: 17px 18px; align-items: center; justify-content: space-between; }
.camera-title { display: grid; gap: 4px; }
.camera-title strong { font-size: 15px; }
.camera-title span { color: var(--muted); font-size: 10px; }
.online-label { display: inline-flex; align-items: center; gap: 7px; color: var(--green); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.online-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.online-label.is-error { color: var(--red); }
.dashboard-strip { display: grid; margin-top: 18px; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-card { display: flex; min-width: 0; padding: 18px; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 14px; background: #0e1318; }
.stat-icon { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; color: var(--green); border: 1px solid #263a31; border-radius: 10px; background: #122019; }
.stat-card div { display: grid; min-width: 0; gap: 3px; }
.stat-card small { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.stat-card strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.stat-card span:last-child { overflow: hidden; color: var(--faint); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

/* Recordings */
.recording-toolbar { display: flex; margin-bottom: 18px; align-items: end; gap: 12px; }
.compact-field { display: grid; min-width: 180px; gap: 7px; }
.compact-field select { height: 43px; }
.playback-layout { display: grid; grid-template-columns: minmax(0, 1fr) 235px; gap: 16px; }
.playback-card, .recording-summary, .timeline-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.video-frame--playback { aspect-ratio: 16 / 9; }
.video-empty { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); text-align: center; background: #080b0f; }
.video-empty > span { color: var(--green); font-size: 28px; }
.video-empty strong { color: #dce2e6; }
.video-empty small { font-size: 11px; }
.playback-meta { display: flex; min-height: 64px; padding: 12px 16px; align-items: center; justify-content: space-between; }
.playback-meta > div { display: flex; align-items: center; gap: 12px; }
.playback-meta > span { color: var(--muted); font-size: 11px; }
.recorded-pill { color: #ffe8e9; border-color: #ff6f7655; background: #451c20; }
.recorded-pill i { background: var(--red); }
.recording-summary { padding: 23px; }
.recording-summary > strong { display: block; margin-top: 18px; font-size: 25px; letter-spacing: -.04em; }
.recording-summary > p:not(.eyebrow), .recording-summary small { color: var(--muted); font-size: 11px; line-height: 1.6; }
.summary-rule { height: 1px; margin: 24px 0; background: var(--line); }
.timeline-card { padding: 20px 22px; margin-top: 16px; }
.timeline-head { display: flex; margin-bottom: 19px; align-items: center; justify-content: space-between; }
.timeline-head strong { font-size: 14px; }
.timeline-actions { display: flex; gap: 7px; }
.timeline-actions button { width: 34px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); cursor: pointer; }
.timeline-range { width: 100%; height: 7px; appearance: none; border-radius: 10px; outline: none; background: linear-gradient(90deg, #24543e, var(--green)); }
.timeline-range::-webkit-slider-thumb { width: 17px; height: 17px; appearance: none; border: 3px solid #0b0f13; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 1px var(--green); cursor: pointer; }
.timeline-range:disabled { opacity: .25; }
.timeline-scale { display: flex; margin-top: 10px; justify-content: space-between; color: var(--faint); font-size: 9px; }
.mobile-nav { display: none; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: min(360px, calc(100vw - 32px)); padding: 12px 16px; color: #e8fff3; border: 1px solid #51e39a44; border-radius: 11px; background: #153527ee; box-shadow: 0 12px 40px #0008; font-size: 12px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { padding: 0 20px 92px; }
  .topbar { min-height: 92px; }
  .topbar-time { display: none; }
  .dashboard-strip { grid-template-columns: 1fr; }
  .playback-layout { grid-template-columns: 1fr; }
  .recording-summary { display: none; }
  .mobile-nav { position: fixed; right: 16px; bottom: 14px; left: 16px; z-index: 5; display: grid; height: 64px; padding: 6px; grid-template-columns: 1fr 1fr; border: 1px solid #293139; border-radius: 17px; background: #11171ded; box-shadow: 0 15px 40px #0009; backdrop-filter: blur(18px); }
  .mobile-nav button { display: grid; place-items: center; align-content: center; gap: 3px; color: var(--muted); border: 0; border-radius: 12px; background: transparent; font-size: 10px; }
  .mobile-nav button span { font-size: 16px; }
  .mobile-nav button.is-active { color: var(--green); background: #19261f; }
}
@media (max-width: 600px) {
  .auth-shell { padding: 0; place-items: stretch; }
  .login-card, .setup-card, .message-card { width: 100%; min-height: 100vh; padding: 30px 22px; border: 0; border-radius: 0; }
  .field-grid { grid-template-columns: 1fr; }
  .field-hint--wide { grid-column: auto; }
  .topbar-status #system-label { display: none; }
  .main-content { padding-inline: 14px; }
  .topbar { min-height: 82px; }
  .topbar h1 { font-size: 23px; }
  .section-intro p { max-width: 82%; font-size: 11px; line-height: 1.5; }
  .camera-grid { grid-template-columns: 1fr; }
  .camera-footer { padding: 14px; }
  .recording-toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .recording-toolbar .button { grid-column: 1 / -1; }
  .compact-field { min-width: 0; }
  .playback-meta > div { gap: 7px; }
  .recorded-pill { display: none; }
  .timeline-card { padding: 16px; }
}

