/* Admin console — shares palette and brand with the viewer (viewer.css). */
:root {
  color-scheme: dark;
  --bg: #0b1018;
  --panel: #141c28;
  --panel2: #1b2534;
  --sunken: #101824;
  --line: #273346;
  --text: #edf3fd;
  --muted: #9baac0;
  --accent: #73a7ff;
  --accent-ink: #07162e;
  --ok: #54d6b1;
  --warn: #e5c687;
  --bad: #ff8f9a;
  --radius: 12px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  font: 15px/1.5 "Segoe UI", "Be Vietnam Pro", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 24px; font-weight: 650; letter-spacing: -.3px; }
h3 { font-size: 15px; font-weight: 600; margin-bottom: var(--s3); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- brand (same mark as viewer) */
.brand { display: flex; align-items: center; gap: var(--s3); font-size: 19px; font-weight: 650; white-space: nowrap; }
.brand span { font-size: 13px; color: var(--muted); font-weight: 400; border-left: 1px solid var(--line); padding-left: var(--s3); }
.brand-icon { width: 24px; height: 24px; border: 6px solid var(--accent); border-radius: 8px; display: inline-block; position: relative; }
.brand-icon::after { content: ""; position: absolute; width: 4px; height: 4px; background: var(--text); border-radius: 50%; top: 3px; left: 3px; }
.eyebrow { display: block; color: var(--accent); font-size: 11px; letter-spacing: 2px; font-weight: 650; margin-bottom: var(--s2); }

/* ---------- shell */
.layout {
  display: grid; min-height: 100vh;
  grid-template-columns: 248px minmax(0, 1fr);
  grid-template-rows: 64px 1fr;
  grid-template-areas: "top top" "nav main";
}
.topbar {
  grid-area: top; display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s5); border-bottom: 1px solid var(--line); background: #101721;
}
.topbar-actions { display: flex; align-items: center; gap: var(--s4); font-size: 13px; }
nav { grid-area: nav; min-width: 0; padding: var(--s4) var(--s3); border-right: 1px solid var(--line); background: #0e151f; }
.nav-group { display: block; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: #6f7f96; padding: var(--s4) var(--s3) var(--s2); }
nav button {
  display: flex; align-items: center; gap: var(--s3); width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 9px var(--s3); border-radius: 8px; cursor: pointer; margin-bottom: 2px;
}
nav button i { font-style: normal; width: 18px; text-align: center; color: #7f93ae; }
nav button:hover { background: var(--panel); color: var(--text); }
nav button.active { background: #192b45; border-color: #2e4c74; color: var(--text); }
nav button.active i { color: var(--accent); }
.nav-badge { margin-left: auto; background: #4a2a1d; color: #ffc29a; font-size: 11px; font-weight: 650; border-radius: 10px; padding: 1px 7px; }
main { grid-area: main; min-width: 0; padding: var(--s6); max-width: 1320px; width: 100%; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s5); margin-bottom: var(--s5); }
.lead { color: var(--muted); margin-top: var(--s2); max-width: 720px; line-height: 1.6; }
.note { color: var(--muted); font-size: 13px; margin-top: var(--s3); line-height: 1.6; }
.link-quiet { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------- surfaces */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s5); margin-top: var(--s4); }
.panel.flush { padding: 0; overflow-x: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.grid-2 .panel { margin-top: var(--s4); }
.kv { color: var(--muted); font-size: 13px; line-height: 1.8; word-break: break-word; }
.kv b { color: var(--text); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: var(--s3); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); display: flex; flex-direction: column; gap: 2px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stat .value.small-value { font-size: 20px; padding: 5px 0 4px; }
.stat .value.ok { color: var(--ok); }
.stat .value.warn { color: var(--warn); }
.stat .hint { color: #73839b; font-size: 11px; }

.alert {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  border: 1px solid #6b5326; background: #2a2215; border-radius: var(--radius);
  padding: var(--s4) var(--s5); margin-bottom: var(--s4);
}
.alert strong { color: var(--warn); }
.alert p { color: #d9ccb0; font-size: 13px; margin-top: 2px; }

/* ---------- controls */
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--sunken);
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
button.primary, button.secondary, button.ghost { border-radius: 8px; padding: 10px 16px; cursor: pointer; font-weight: 550; white-space: nowrap; }
button.primary { background: #6d9fff; color: var(--accent-ink); border: 0; }
button.secondary { background: #23324b; color: #d8e7ff; border: 0; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button:hover:not(:disabled) { filter: brightness(1.12); }
button:disabled { opacity: .5; cursor: wait; }
button.small { padding: 6px 10px; font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: var(--s3); flex: 1; min-width: 150px; }
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); }
.form-row .field { margin-bottom: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.row.checks { margin-bottom: var(--s3); color: var(--muted); }
.row.checks label { display: flex; align-items: center; gap: var(--s2); }
.actions { display: flex; gap: var(--s2); margin-top: var(--s4); }

/* ---------- tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px var(--s4); border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: #8696ad; font-weight: 550; font-size: 12px; background: #111925; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #172131; }
td.empty { color: var(--muted); text-align: center; padding: var(--s6); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap; background: #243145; color: #c3d2e8; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: #183a34; color: var(--ok); }
.badge.bad { background: #3c1e26; color: var(--bad); }
.badge.warn { background: #3a2f18; color: var(--warn); }
.badge.info { background: #1b2f4d; color: var(--accent); }

.meter { width: 96px; height: 6px; background: #263145; border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: var(--s2); }
.meter > i { display: block; height: 100%; background: var(--ok); }
.meter.partial > i { background: var(--warn); }

/* ---------- recovery page */
.flow { list-style: none; padding: 0; margin: 0 0 var(--s5); display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.flow li { display: flex; align-items: center; gap: var(--s3); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: var(--s3) var(--s4); font-size: 13px; color: var(--muted); }
.flow b { display: grid; place-items: center; min-width: 26px; height: 26px; border-radius: 50%; background: #1b2f4d; color: var(--accent); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.chip span { margin-left: 4px; color: #73839b; font-variant-numeric: tabular-nums; }
.chip.active { background: #192b45; border-color: #3d6797; color: var(--text); }
.span-cell strong { display: block; font: 500 13px ui-monospace, Consolas, monospace; white-space: nowrap; }
.span-cell span { color: var(--muted); font-size: 12px; }
.nowrap { white-space: nowrap; }
#recovery-table td:nth-child(4) { min-width: 150px; }
#recovery-table td:nth-child(4) button { margin-top: 6px; display: block; }
.note-cell { color: var(--muted); min-width: 200px; max-width: 320px; overflow-wrap: anywhere; font-size: 12px; line-height: 1.5; }

/* ---------- misc (kept for app.js) */
.login-wrap { max-width: 400px; margin: 12vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: var(--s6); display: flex; flex-direction: column; gap: var(--s2); }
.login-wrap .brand { margin-bottom: var(--s5); }
.login-wrap h1 { font-size: 22px; margin-bottom: var(--s3); }
.login-wrap label { font-size: 13px; color: var(--muted); margin-top: var(--s2); }
.login-wrap .primary { margin-top: var(--s4); }
.steps { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s2); }
.steps span { padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.steps span.on { background: #192b45; border-color: #3d6797; color: var(--text); }
.msg { margin-top: var(--s3); color: var(--muted); white-space: pre-wrap; font-size: 13px; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--ok); }
pre.msg { font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-x: auto; }
video { width: 100%; max-height: 460px; background: #000; border-radius: 10px; margin-top: var(--s4); }
.timeline { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin: var(--s4) 0 0; }
.timeline i { display: block; height: 28px; background: #253043; border-radius: 3px; }
.timeline i.has { background: #6b9fef; }
.label { color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .grid-2, .flow { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(56px, auto) auto 1fr; grid-template-areas: "top" "nav" "main"; }
  .topbar { height: auto; min-height: 56px; flex-wrap: wrap; gap: var(--s2); padding: var(--s2) var(--s3); min-width: 0; }
  .topbar-actions { flex-wrap: wrap; gap: var(--s2); max-width: 100%; min-width: 0; }
  .brand span { display: none; }
  nav { display: flex; gap: var(--s1); overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: var(--s2) var(--s4); }
  .nav-group { display: none; }
  nav button { width: auto; white-space: nowrap; margin: 0; }
  main { padding: var(--s5) var(--s4); }
  .page-head { flex-direction: column; align-items: flex-start; }
  .grid-2, .flow, .row { grid-template-columns: 1fr; }
  .alert { flex-direction: column; align-items: flex-start; }
}

/* ---- Xem trực tiếp ---- */
.live-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s4); }
.live-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.live-card.bad { border-color: #6b2d3a; }
.live-frame { position: relative; aspect-ratio: 16 / 9; background: #05090f; border: 0; padding: 0; cursor: zoom-in; display: flex; align-items: center; justify-content: center; width: 100%; }
.live-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.live-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.live-noimg { color: var(--muted); font-size: 13px; padding: var(--s4); text-align: center; }
.live-rec { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 700; letter-spacing: .5px; color: #fff; background: #c2283ccc; border-radius: 4px; padding: 2px 7px; }
.live-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px 4px; }
.live-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0 14px 12px; color: var(--muted); font-size: 12px; }
.live-hint { color: var(--bad); }
.live-zoom { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: var(--s4); width: min(1280px, 95vw); }
.live-zoom::backdrop { background: #000c; }
.live-zoom header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s3); }
.live-zoom img { width: 100%; max-height: 78vh; object-fit: contain; background: #05090f; border-radius: 6px; }
@media (max-width: 760px) { .live-grid { grid-template-columns: 1fr; } }

/* ---- Đổi mật khẩu ---- */
.pw-dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: var(--s5); width: min(420px, 92vw); }
.pw-dialog::backdrop { background: #000b; }
.pw-dialog h3 { margin-bottom: var(--s2); }
.pw-dialog .field { min-width: 0; }
.pw-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s4); }
.live-frame video { width: 100%; height: 100%; object-fit: contain; display: block; background: #05090f; }
.live-frame [hidden] { display: none; }
.live-vstate { position: absolute; bottom: 8px; left: 8px; right: 8px; font-size: 12px; color: var(--muted); background: #05090fcc; border-radius: 4px; padding: 3px 7px; }
.live-zoom video { width: 100%; max-height: 78vh; background: #05090f; border-radius: 6px; }

/* ---- Chế độ Auto khôi phục ---- */
.recovery-auto {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--s4); margin-top: 0; margin-bottom: var(--s4); padding: var(--s4) var(--s5);
}
.recovery-auto-info { min-width: 240px; flex: 1; }
.recovery-auto-title { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.recovery-auto-title strong { font-size: 15px; font-weight: 600; }
.recovery-auto-info .note { margin-top: 4px; }
.recovery-auto-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.recovery-auto-interval { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.recovery-auto-interval select { width: auto; padding: 6px 10px; font-size: 13px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 550; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative; width: 42px; height: 24px; border-radius: 999px;
  background: #273346; border: 1px solid #35455d; transition: background .18s, border-color .18s;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #c9d7ec; transition: transform .18s, background .18s;
}
.switch input:checked + .switch-track { background: #1c5b4f; border-color: var(--ok); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--ok); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Tự động dò tìm camera (Discovery) ---- */
.discovery-panel { margin-top: var(--s4); padding: var(--s4) var(--s5); }
.discovery-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--s4);
}
.discovery-inputs { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--line); }
.discovery-subhead { margin-top: var(--s5); margin-bottom: var(--s2); font-size: 14px; font-weight: 600; color: var(--text); }

/* ---- Live optimization controls (Task C) ---- */
.live-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.live-quality-label { display: inline-flex; align-items: center; gap: var(--s2); font-size: 12px; color: var(--muted); }
.live-quality-select { width: auto; min-width: 170px; padding: 6px 10px; font-size: 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; }
.live-zoom-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.live-mute-btn { min-width: 96px; }
.live-ptz-pad { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }
.live-ptz-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ptz-btn { min-width: 34px; height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 4px 10px; }
.live-ptz-msg { margin-top: 0; font-size: 12px; color: var(--muted); }
@media (max-width: 760px) {
  .live-toolbar, .live-zoom-actions { width: 100%; justify-content: space-between; }
  .live-quality-select { min-width: 0; flex: 1; }
}

/* ---- Control Center & Drive Storage (Task L / Task F) ---- */
.small { font-size: 12px; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.cc-root { margin-top: var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.cc-filter-bar { margin-top: 0; }
.cc-filter-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.cc-filter-head h3 { margin-bottom: 0; }
.cc-summary-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: 13px; color: var(--muted); }
.cc-total-wrap { color: var(--text); }
.cc-filters { align-items: flex-end; }
.cc-filters .field { min-width: 140px; }

.cc-panels-grid > .panel { margin-top: 0; min-width: 0; overflow-x: auto; }
.cc-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); }
.cc-panel-head h3 { margin-bottom: 0; }

.cc-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: var(--s2); margin-bottom: var(--s3); }
.cc-kpi { background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; padding: var(--s2) var(--s3); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cc-kpi strong { font-size: 14px; overflow-wrap: anywhere; }

.cc-meter { width: 100%; height: 8px; background: #263145; border-radius: 4px; overflow: hidden; margin: var(--s2) 0 var(--s3); }
.cc-meter-fill { height: 100%; background: var(--ok); transition: width .2s ease; }
.cc-meter-fill.warn { background: var(--warn); }

.cc-daily-list { margin: var(--s3) 0; }
.cc-daily-list h4 { margin: 0 0 var(--s2); font-size: 13px; color: var(--muted); font-weight: 600; }
.cc-daily-items { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; font-size: 12px; }
.cc-daily-items li { background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; display: flex; justify-content: space-between; gap: 8px; }

.cc-table { margin-top: var(--s2); }
.cc-table th, .cc-table td { padding: 8px 10px; font-size: 12px; }
.cc-table td { overflow-wrap: anywhere; }

.cc-drive-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s3); }
.cc-drive-card { background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; padding: var(--s3); display: flex; flex-direction: column; gap: var(--s2); min-width: 0; overflow-wrap: anywhere; }
.cc-drive-card.storage-warning { border-color: #6b2d3a; }
.cc-drive-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); }
.cc-drive-card-head h4, .cc-drive-card h4 { margin: 0; font-size: 14px; font-weight: 600; }
.cc-drive-metrics { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.cc-drive-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s1); }
.cc-area-list { list-style: none; padding: 0; margin: var(--s2) 0 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.cc-area-list li { display: flex; justify-content: space-between; gap: 8px; }
.drive-reconnect-status { margin-top: var(--s1); }
.page-head-spaced { margin-top: 1.5rem; }

@media (max-width: 600px) {
  .topbar .brand { font-size: 17px; gap: var(--s2); }
  .topbar-actions button { padding: 6px 10px; font-size: 12px; }
  .cc-drive-grid, .cc-kpi-row, .cc-daily-items { grid-template-columns: 1fr; }
  .cc-filters .field { min-width: 100%; }
}

/* Nút xoá camera trên thẻ live: kín đáo, chỉ rõ khi rê chuột */
.live-head { position: relative; }
.live-del {
  margin-left: auto;
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted, #8a93a6);
  font-size: 13px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.live-card:hover .live-del,
.live-del:focus-visible { opacity: 1; }
.live-del:hover {
  color: #ff6b6b;
  border-color: #ff6b6b;
}
.live-del[disabled] { opacity: 0.25; cursor: progress; }

/* ---- Lưới camera trực tiếp: chọn bố cục, kéo thả, xoay vòng ---- */
.live-layout { display: inline-flex; align-items: center; gap: 4px; margin-left: 12px; }
.live-layout-label { font-size: 12px; color: var(--muted, #8a93a6); margin-right: 2px; }
.live-lay-btn {
  min-width: 30px; padding: 3px 7px; font-size: 12px; line-height: 1.2;
  background: transparent; color: var(--muted, #8a93a6);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 4px; cursor: pointer;
}
.live-lay-btn:hover { color: #e8ecf4; border-color: rgba(255,255,255,0.35); }
.live-lay-btn[aria-pressed="true"] {
  background: #2b6cb0; color: #fff; border-color: #2b6cb0; font-weight: 600;
}
.live-opt { display: inline-flex; align-items: center; gap: 5px; margin-left: 12px; font-size: 12px; color: var(--muted, #8a93a6); cursor: pointer; }
.live-page-info { margin-left: 12px; font-size: 12px; color: var(--muted, #8a93a6); }
.live-page-info.warn { color: #e0a83c; }

/* Bố cục: số cột theo mức đã chọn. 6 và 8 có một ô lớn như phần mềm CMS. */
.live-grid.lay-1 { grid-template-columns: 1fr; }
.live-grid.lay-4 { grid-template-columns: repeat(2, 1fr); }
.live-grid.lay-6 { grid-template-columns: repeat(3, 1fr); }
.live-grid.lay-8 { grid-template-columns: repeat(4, 1fr); }
.live-grid.lay-9 { grid-template-columns: repeat(3, 1fr); }
.live-grid.lay-16 { grid-template-columns: repeat(4, 1fr); }
.live-grid.lay-6 > .live-card:first-child { grid-column: span 2; grid-row: span 2; }
.live-grid.lay-8 > .live-card:first-child { grid-column: span 3; grid-row: span 3; }

/* Kéo thả */
.live-card[draggable="true"] { cursor: grab; }
.live-card.dragging { opacity: 0.4; }
.live-card.drop-target { outline: 2px dashed #2b6cb0; outline-offset: 2px; }

/* Màn hình hẹp: bỏ bố cục nhiều cột cho dễ nhìn */
@media (max-width: 900px) {
  .live-grid.lay-6, .live-grid.lay-8, .live-grid.lay-9, .live-grid.lay-16 { grid-template-columns: repeat(2, 1fr); }
  .live-grid.lay-6 > .live-card:first-child,
  .live-grid.lay-8 > .live-card:first-child { grid-column: span 2; grid-row: span 1; }
}

/* Ô lớn trong bố cục 6/8: cho khung hình giãn hết chiều cao, hết khoảng đen thừa */
.live-grid.lay-6 > .live-card:first-child .live-frame,
.live-grid.lay-8 > .live-card:first-child .live-frame {
  aspect-ratio: auto;
  flex: 1 1 auto;
  min-height: 0;
}

/* Nút xem toàn màn hình, cùng kiểu kín đáo với nút xoá */
.live-fs {
  flex: 0 0 auto;
  margin-left: auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted, #8a93a6);
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity .12s ease, color .12s ease, border-color .12s ease;
}
.live-card:hover .live-fs,
.live-fs:focus-visible { opacity: 1; }
.live-fs:hover { color: #e8ecf4; border-color: rgba(255,255,255,0.35); }
.live-del { margin-left: 0; }

/* Khi một thẻ đang toàn màn hình: hình chiếm trọn, chữ nằm dưới */
.live-card:fullscreen { background: #05090f; border: 0; border-radius: 0; }
.live-card:fullscreen .live-frame { aspect-ratio: auto; flex: 1 1 auto; min-height: 0; }
.live-card:fullscreen .live-frame img,
.live-card:fullscreen .live-frame video { object-fit: contain; }

/* Nút phóng to cả bức tường camera */
.live-wall-btn {
  margin-left: 12px; padding: 4px 10px; font-size: 12px;
  background: transparent; color: var(--muted, #8a93a6);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 4px; cursor: pointer;
}
.live-wall-btn:hover { color: #e8ecf4; border-color: rgba(255,255,255,0.4); }
.live-wall-btn[aria-pressed="true"] { background: #2b6cb0; color: #fff; border-color: #2b6cb0; }

/* Hàng cao bằng nhau và khung hình lấp đầy ô — hết khoảng trống dưới thẻ */
.live-grid[class*="lay-"] { grid-auto-rows: 1fr; }
.live-grid[class*="lay-"] > .live-card .live-frame {
  aspect-ratio: auto;
  flex: 1 1 auto;
  min-height: 140px;
}

/* Toàn màn hình: cả tường camera lấp kín, bỏ phần chữ giới thiệu */
section[data-page="live"]:fullscreen {
  background: #05090f;
  padding: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
section[data-page="live"]:fullscreen .page-head { margin: 0 0 8px; }
section[data-page="live"]:fullscreen .page-head > div:first-child { display: none; }
section[data-page="live"]:fullscreen .live-grid {
  flex: 1 1 auto;
  min-height: 0;
  grid-auto-rows: 1fr;
}
section[data-page="live"]:fullscreen .live-card { overflow: hidden; }
section[data-page="live"]:fullscreen .live-card .live-frame {
  aspect-ratio: auto;
  flex: 1 1 auto;
  min-height: 0;
}
section[data-page="live"]:fullscreen .live-meta { display: none; }
section[data-page="live"]:fullscreen .live-head { padding: 6px 10px 6px; }
