/* Baby CCTV — dashboard styles
   Design: dark navy sidebar, calm white surface, no gradients, no glass. */

:root {
  --navy: #1a2b40;
  --navy-hover: #22374f;
  --navy-active: #2c70d0;
  --accent: #2c70d0;
  --accent-hover: #245ea9;
  --accent-soft: #eaf1fb;
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #222222;
  --text-2: #666666;
  --text-3: #8a949f;
  --line: #e5eaf1;
  --line-strong: #d3dbe6;
  --ok: #2ecc71;
  --warn: #f39c12;
  --bad: #e74c3c;
  --ok-soft: #eafaf1;
  --warn-soft: #fdf4e3;
  --bad-soft: #fdecea;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(26, 43, 64, .06), 0 4px 12px rgba(26, 43, 64, .05);
  --shadow-lg: 0 8px 28px rgba(26, 43, 64, .14);
  --sans: "Inter", "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.skip-link:focus { left: 8px; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--navy);
  color: #c8d4e2;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 0;
  color: #fff;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--navy-active);
  display: grid; place-items: center;
  color: #fff;
  flex: 0 0 34px;
}
.brand-name { font-size: 15px; font-weight: 600; color: #fff; line-height: 1.2; }
.brand-tag { font-size: 11.5px; color: #8ea3ba; line-height: 1.3; margin-top: 2px; }

.nav { margin-top: 24px; display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #6e8299;
  padding: 8px;
  margin-top: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #c8d4e2;
  font-size: 14px;
  font-weight: 500;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.nav-item:hover { background: var(--navy-hover); color: #fff; text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--navy-active); color: #fff; }
.nav-item svg { flex: 0 0 18px; opacity: .95; }
.nav-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.nav-item[aria-current="page"] .nav-badge { background: rgba(255, 255, 255, .22); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .09);
  font-size: 12px;
  color: #8ea3ba;
  padding-left: 8px;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 60px;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar-sub { font-size: 12.5px; color: var(--text-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.menu-btn { display: none; }

.content { padding: 24px 28px 56px; max-width: 1240px; width: 100%; }

/* ---------- primitives ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head .spacer { margin-left: auto; }

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head .spacer { margin-left: auto; }
.page-head p.lede { color: var(--text-2); font-size: 13.5px; margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  min-height: 40px;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  white-space: nowrap;
}
.btn:hover { background: #f3f6fa; border-color: #c3cede; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { flex: 0 0 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: #fff; border-color: #f0c4bf; color: #c0392b; }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef2f7; }
.btn-sm { padding: 7px 11px; font-size: 13px; min-height: 32px; }
.btn-icon {
  padding: 0;
  width: 36px;
  min-height: 36px;
  border-radius: var(--radius-sm);
}
.btn-block { width: 100%; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.status-online { background: var(--ok-soft); color: #1e874b; border-color: #c9f0da; }
.status-online .dot { background: var(--ok); }
.status-connecting { background: var(--warn-soft); color: #9a6408; border-color: #f7e2b8; }
.status-connecting .dot { background: var(--warn); }
.status-offline { background: var(--bad-soft); color: #b03a2e; border-color: #f6cbc6; }
.status-offline .dot { background: var(--bad); }
.status-neutral { background: #f0f3f7; color: #5b6b7c; border-color: var(--line); }
.status-neutral .dot { background: #97a5b5; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  background: #f1f4f9;
  border-radius: 999px;
  padding: 2px 9px;
}

.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; color: var(--text-3); }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .06em; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label, .field-label {
  font-size: 13px;
  font-weight: 600;
  color: #3a4652;
}
.field .hint { font-size: 12px; color: var(--text-2); }
.field .err { font-size: 12px; color: #c0392b; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: 40px;
  width: 100%;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
input:focus, select:focus { outline: 2px solid rgba(44, 112, 208, .35); outline-offset: 0; border-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--bad); }
input::placeholder { color: #9aa6b4; }

.input-row { display: flex; gap: 8px; align-items: center; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 44px; }
.input-wrap .reveal {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.input-wrap .reveal:hover { background: #eef2f7; color: var(--text); }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 0;
}
.check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  margin: 2px 0 0;
  flex: 0 0 18px;
}
.check-text strong { display: block; font-size: 13.5px; font-weight: 600; }
.check-text span { font-size: 12px; color: var(--text-2); }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 24px;
}
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row output { font-size: 13px; color: var(--text-2); min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.cfg-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 14px 0 4px;
  margin-top: 4px;
}
.cfg-actions .tiny { margin-left: auto; }

/* ---------- notices ---------- */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.5px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #f4f7fb;
  color: #33414f;
  margin-bottom: 16px;
}
.notice svg { flex: 0 0 18px; margin-top: 1px; }
.notice-error { background: var(--bad-soft); border-color: #f6cbc6; color: #a33327; }
.notice-ok { background: var(--ok-soft); border-color: #c9f0da; color: #1e874b; }
.notice-warn { background: var(--warn-soft); border-color: #f7e2b8; color: #8a5a06; }
.notice:empty { display: none; }
.notice .close { margin-left: auto; }

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-2);
}
.empty .icon-lg { color: #b7c4d3; margin-bottom: 12px; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 15px; }
.empty p { font-size: 13.5px; margin-bottom: 16px; }

/* ---------- dashboard ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.stat-top { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.stat-top .stat-ic {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: #eef3fa; color: var(--accent);
}
.stat-top .stat-ic.warn { background: var(--warn-soft); color: #b5730a; }
.stat-top .stat-ic.bad { background: var(--bad-soft); color: #c0392b; }
.stat-value { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12px; color: var(--text-3); }

.cam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 16px;
}
.cam-card { overflow: hidden; display: flex; flex-direction: column; }
.cam-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #101c2b;
  display: grid;
  place-items: center;
  color: #52657c;
  overflow: hidden;
}
.cam-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-thumb .thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; color: #8ea3ba; text-align: center; padding: 8px;
}
.cam-thumb .thumb-status { position: absolute; top: 10px; left: 10px; }
.cam-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.cam-title { display: flex; align-items: flex-start; gap: 8px; }
.cam-title h3 { font-size: 15px; line-height: 1.3; word-break: break-word; }
.cam-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; color: var(--text-2); }
.cam-meta .item { display: inline-flex; align-items: center; gap: 4px; }
.cam-actions { margin-top: auto; display: flex; gap: 8px; padding-top: 6px; }
.cam-actions .btn-primary { flex: 1; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item .ev-ic {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 32px;
  display: grid; place-items: center;
  background: #eef3fa; color: var(--accent);
}
.list-item .ev-ic.cry { background: #eaf1fb; color: #2c70d0; }
.list-item .ev-ic.motion { background: var(--warn-soft); color: #b5730a; }
.list-item .ev-ic.offline, .list-item .ev-ic.storage, .list-item .ev-ic.permission { background: var(--bad-soft); color: #c0392b; }
.list-item .ev-main { min-width: 0; flex: 1; }
.list-item .ev-title { font-size: 13.5px; font-weight: 600; }
.list-item .ev-sub { font-size: 12.5px; color: var(--text-2); }
.list-item .ev-time { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }

/* ---------- live ---------- */
.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.player {
  background: #0d1622;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  color: #8ea3ba;
  border: 1px solid #16233a;
}
.player img { width: 100%; height: 100%; object-fit: contain; display: block; background: #0d1622; }
.player .player-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
  font-size: 13.5px;
  color: #a9bccf;
}
.player .player-msg strong { color: #fff; font-size: 15px; display: block; }
.player-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(13, 22, 34, .82);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 4px 10px;
}
.player-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.player-badge.off .dot { background: var(--bad); }

.controls { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); align-items: center; }
.controls .spacer { margin-left: auto; }
.brightness-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--line); background: #fbfcfe;
  flex-wrap: wrap;
}
.brightness-bar label { font-size: 12.5px; font-weight: 600; color: #3a4652; }
.brightness-bar input[type="range"] { flex: 1 1 140px; min-width: 120px; }
.brightness-bar output { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }

.info-list { display: flex; flex-direction: column; }
.info-row {
  display: flex; align-items: baseline; gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.info-row:last-child { border-bottom: 0; }
.info-row .k { color: var(--text-2); flex: 0 0 118px; font-size: 12.5px; }
.info-row .v { font-weight: 500; min-width: 0; word-break: break-word; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  white-space: nowrap;
}
table.data td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fafcff; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn { margin-left: 6px; }
td .dev-name { font-weight: 600; display: block; }
td .dev-sub { font-size: 12px; color: var(--text-3); }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.toolbar .search { position: relative; flex: 1 1 220px; max-width: 320px; }
.toolbar .search input { padding-left: 36px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.toolbar select { width: auto; min-width: 140px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 28, 43, .55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 80;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; }
.modal-head .close-btn { margin-left: auto; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--line); background: #fbfcfe; }

.code-display {
  text-align: center;
  padding: 20px 16px;
  background: #f4f8fe;
  border: 1px dashed #b9d1f0;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.code-display .code {
  font-size: 36px;
  font-weight: 600;
  letter-spacing: .22em;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  line-height: 1.2;
}
.code-display .code-meta { font-size: 12.5px; color: var(--text-2); }

/* ---------- auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: 32px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-brand .brand-mark { background: var(--navy); }
.auth-brand .brand-name { color: var(--navy); font-size: 16px; }
.auth-brand .brand-tag { color: var(--text-2); }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-sub { color: var(--text-2); font-size: 13.5px; margin-bottom: 24px; }
.auth-foot { text-align: center; font-size: 13px; color: var(--text-2); margin-top: 8px; }
.auth-tabs {
  display: flex;
  gap: 4px;
  background: #eef2f7;
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}
.auth-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
}
.auth-tabs button[aria-selected="true"] { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(26, 43, 64, .08); }
.auth-links { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; font-size: 12.5px; }
.disabled-link { color: var(--text-3); cursor: not-allowed; display: inline-flex; gap: 6px; align-items: center; }
.disabled-link span.tag { font-size: 10.5px; background: #eef2f7; border-radius: 4px; padding: 1px 5px; color: #6b7a8b; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skel {
  background: #eef2f7;
  border-radius: 6px;
  height: 12px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
.toast {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--text);
}
.toast.error { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .live-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: var(--shadow-lg);
    width: 268px;
    flex-basis: 268px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(16, 28, 43, .5);
    z-index: 35;
  }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 48px; }
  .stats { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .cam-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .page-head { align-items: flex-start; }
  .page-head .spacer { margin-left: 0; width: 100%; }
  .page-head .spacer .btn { width: 100%; }
  .stat-value { font-size: 26px; }
  .auth-card { padding: 24px; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  table.data td.actions { white-space: normal; }
  table.data td.actions .btn { margin: 2px 0 2px 4px; }
}

/* Atribut `hidden` HARUS menang atas display:flex/grid milik kelas.
   Tanpa ini, panel login (.auth-wrap display:flex) tetap tampil di bawah
   SETIAP halaman setelah masuk — pengguna melihat form login di tab mana pun. */
[hidden] { display: none !important; }
/* Panel perbaikan alamat stream (konten campuran https/http) */
.stream-fix { padding: 22px; }
.stream-fix h3 { font-size: 16px; margin: 0 0 8px; }
.stream-fix p { font-size: 13px; color: var(--text-2, #5b6878); margin: 0 0 4px; line-height: 1.5; }
.stream-fix code { background: #f1f4f8; padding: 1px 5px; border-radius: 4px; font-size: 12px; word-break: break-all; }
.stream-fix .fix-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* --- Rekaman: thumbnail bingkai klip --- */
.rec-thumb {
  width: 112px; height: 63px; object-fit: cover; border-radius: 8px;
  background: #0f172a; border: 1px solid var(--line); display: block;
}
.rec-thumb[data-play] { cursor: pointer; }
.rec-thumb-na {
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 10px; line-height: 1.2; color: var(--muted); padding: 4px;
}
.rec-thumb[data-play]:hover { border-color: var(--accent); }
@media (max-width: 700px) {
  .rec-thumb { width: 84px; height: 47px; }
}

@media (max-width: 560px) {
  .topbar h1 { font-size: 15px; }
  .topbar-sub { display: none; }
  .code-display .code { font-size: 30px; letter-spacing: .18em; }
  .info-row { flex-direction: column; gap: 2px; }
  .info-row .k { flex-basis: auto; }
  .controls .btn { flex: 1 1 calc(50% - 8px); }
  .controls .spacer { display: none; }
}

/* ---------- Tabel jadi kartu di layar kecil (tanpa geser ke kanan) ---------- */
@media (max-width: 700px) {
  .table-wrap { overflow-x: visible; }
  table.data { font-size: 13.5px; }
  table.data thead { display: none; }
  table.data, table.data tbody { display: block; width: 100%; }
  table.data tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 2px 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
  }
  table.data tr:last-child { border-bottom: 0; }
  table.data tr:hover td { background: transparent; }
  table.data td { display: block; padding: 0; border: 0; min-width: 0; }
  table.data td.actions {
    grid-column: 1 / -1;
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 10px; text-align: left; white-space: normal;
  }
  table.data td.actions .btn { margin: 0; flex: 1 1 auto; min-width: 96px; text-align: center; }

  /* Perangkat: label kecil di depan tiap nilai supaya jelas tanpa header tabel */
  #dev-table table.data td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px; letter-spacing: .02em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 2px;
  }
  #dev-table table.data td[data-label="Nama"] { grid-column: 1 / -1; }
  #dev-table table.data td[data-label="Nama"]::before { display: none; }
  #dev-table table.data td[data-label="Nama"] .dev-name { font-size: 15px; }

  /* Rekaman: thumbnail di kiri, waktu/ukuran/status menumpuk di kanan */
  #rec-list table.data tr { grid-template-columns: 84px minmax(0, 1fr); }
  #rec-list table.data td[data-label="Pratinjau"] { grid-column: 1; grid-row: 1 / span 3; }
  #rec-list table.data td[data-label="Mulai"] { grid-column: 2; }
  #rec-list table.data td[data-label="Ukuran"] { grid-column: 2; color: var(--text-2, #5b6878); }
  #rec-list table.data td[data-label="Status"] { grid-column: 2; margin-top: 2px; }
  #rec-list table.data td[data-label="Mulai"] .tiny { overflow-wrap: anywhere; }
  #rec-list table.data td.actions { grid-column: 1 / -1; }
}

/* Pemilih lensa kamera (Depan / Belakang / USB) di halaman Live */
.seg { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg .btn { border: 0; border-radius: 0; }
.seg .btn + .btn { border-left: 1px solid var(--line); }
@media (max-width: 560px) { .seg { flex: 1 1 100%; } .seg .btn { flex: 1 1 0; } }

/* ==================== LANDING (halaman awal) ==================== */
.landing{max-width:1080px;margin:0 auto;padding:20px 20px 56px;}
.landing-head{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:8px 0 24px;}
.landing-hero{max-width:720px;margin:8px 0 32px;}
.landing-hero h1{font-size:30px;line-height:1.2;letter-spacing:-.02em;margin:0 0 12px;}
.landing-lead{font-size:15px;line-height:1.65;color:var(--text-2,#5A6779);margin:0;}
.landing-sub{font-size:13px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-2,#5A6779);margin:0 0 14px;font-weight:600;}
.role-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:16px;}
.role-card{background:var(--surface,#fff);border:1px solid var(--line,#E4E8EE);border-radius:14px;padding:20px;display:flex;flex-direction:column;gap:10px;}
.role-icon{width:40px;height:40px;border-radius:10px;display:flex;align-items:center;justify-content:center;background:rgba(44,112,208,.10);color:#2C70D0;}
.role-card h3{margin:0;font-size:16px;}
.role-desc{margin:0;font-size:13.5px;line-height:1.6;color:var(--text-2,#5A6779);}
.role-points{margin:0;padding-left:18px;font-size:12.5px;line-height:1.75;color:var(--text-2,#5A6779);}
.role-card .btn{margin-top:auto;}
.dl-ver{font-size:11.5px;opacity:.75;margin-left:8px;font-weight:400;}
.landing-guide{margin-top:40px;border-top:1px solid var(--line,#E4E8EE);padding-top:24px;}
.landing-guide h2{font-size:18px;margin:0 0 12px;}
.guide-list{margin:0 0 14px;padding-left:20px;font-size:14px;line-height:1.9;color:var(--text-2,#5A6779);}
.landing-foot{margin-top:28px;text-align:center;}
@media (max-width:640px){
  .landing{padding:16px 14px 44px;}
  .landing-hero h1{font-size:23px;}
  .landing-lead{font-size:14px;}
  .role-grid{grid-template-columns:1fr;gap:12px;}
  .role-card{padding:16px;}
}

/* ==================== GRID SEMUA KAMERA ==================== */
.cam-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:16px;}
.cam-tile{background:var(--surface,#fff);border:1px solid var(--line,#E4E8EE);border-radius:14px;overflow:hidden;display:flex;flex-direction:column;}
.cam-thumb{position:relative;aspect-ratio:4/3;background:#0E1725;display:flex;align-items:center;justify-content:center;}
.cam-thumb img{width:100%;height:100%;object-fit:cover;display:block;}
.cam-thumb .cam-off{color:#8fa1b6;font-size:12.5px;text-align:center;padding:12px;}
.cam-thumb .cam-badge{position:absolute;left:10px;top:10px;}
.cam-body{padding:12px 14px;display:flex;flex-direction:column;gap:6px;}
.cam-body h3{margin:0;font-size:14.5px;}
.cam-meta{font-size:12px;color:var(--text-2,#5A6779);}
.cam-actions{display:flex;gap:8px;flex-wrap:wrap;padding:0 14px 14px;}
@media (max-width:640px){.cam-grid{grid-template-columns:1fr;}}

/* ==================== RIWAYAT AKUN DI HALAMAN MASUK ==================== */
.acct-history{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-top:8px;}
.acct-hint{font-size:11.5px;color:var(--text-2,#5A6779);}
.acct-chip{display:inline-flex;align-items:center;border:1px solid var(--line,#E4E8EE);border-radius:999px;background:var(--surface,#fff);overflow:hidden;}
.acct-pick{display:inline-flex;align-items:center;gap:6px;border:0;background:transparent;padding:5px 8px;font-size:12px;color:var(--text,#1A2B40);cursor:pointer;max-width:230px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.acct-pick:hover{background:rgba(44,112,208,.08);}
.acct-x{border:0;background:transparent;color:#8fa1b6;cursor:pointer;font-size:14px;line-height:1;padding:4px 7px;}
.acct-x:hover{color:#B3261E;background:#FDECEA;}
@media (max-width:420px){.acct-pick{max-width:170px;}}
