/* CCTV Cloud dashboard. Plain CSS, no framework. Mobile first-ish; tables
   turn into cards under 760px. */

:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5d6877;
  --border: #dce1e8;
  --border-strong: #c3cad4;
  --primary: #1f63d6;
  --primary-dark: #174ea9;
  --primary-soft: #e8f0fd;
  --green: #18a058;
  --green-soft: #e6f6ed;
  --red: #d63a3a;
  --red-soft: #fdecec;
  --amber: #d98a00;
  --amber-soft: #fff5e0;
  --blue: #2f80d1;
  --blue-soft: #e8f2fc;
  --grey: #9aa3af;
  --topbar: #17324d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.45;
}
body.modal-open { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: 1.1rem 0 .5rem; }
h4 { font-size: .95rem; margin: .9rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ok-text { color: var(--green); }
.err-text { color: var(--red); }
.warn-text { color: #9a5b00; }
.break { word-break: break-all; overflow-wrap: anywhere; }
.nowrap { flex-wrap: nowrap !important; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- layout */
.boot { display: flex; gap: .6rem; align-items: center; justify-content: center; min-height: 60vh; color: var(--muted); }
.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }
.container.wide { max-width: 1500px; }
.container.narrow { max-width: 820px; }

.topbar { background: var(--topbar); color: #fff; position: sticky; top: 0; z-index: 30; }
.topbar-inner { max-width: 1500px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 56px; }
.brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a { color: #d6e2ef; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.mainnav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; color: #fff; }
.mainnav a.active { background: rgba(255, 255, 255, .16); color: #fff; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; padding: 6px 8px; cursor: pointer; }
.user-menu { position: relative; margin-left: auto; }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #fff; cursor: pointer; font: inherit; padding: 6px; border-radius: 8px; }
.user-btn:hover { background: rgba(255, 255, 255, .08); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #2c5a85; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.user-dropdown { min-width: 240px; color: var(--text); }
.menu-info { padding: 10px 14px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-header-text p { margin: .3rem 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 6px; font-size: .9rem; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 { margin-bottom: 16px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.actions-row.center { justify-content: center; }
.tab-body { margin-top: 16px; }

/* ---------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; color: var(--text); }
.stat-link:hover { border-color: var(--primary); text-decoration: none; }
.stat-label { color: var(--muted); font-size: .9rem; font-weight: 600; }
.stat-value { font-size: 2.2rem; font-weight: 700; line-height: 1.2; margin: 4px 0; }
.stat-value-sm { font-size: 1.6rem; }
.stat-of { font-size: 1rem; color: var(--muted); font-weight: 500; }
.stat-sub { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.all-good { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; color: var(--green); font-weight: 600; }
.big-check { display: inline-flex; width: 32px; height: 32px; border-radius: 50%; background: var(--green); color: #fff; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.problem-list, .simple-list, .events { list-style: none; margin: 0; padding: 0; }
.problem-list li { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); align-items: baseline; }
.problem-list li:first-child { border-top: 0; }
.simple-list li { padding: 8px 0; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.simple-list li:first-child { border-top: 0; }
.steps-list { margin: 0; padding-left: 1.3rem; }
.steps-list li { margin: .4rem 0; }

/* ---------------------------------------------------------------- status */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--grey); flex: none; vertical-align: middle; }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }
.dot-amber { background: var(--amber); }
.dot-blue { background: var(--blue); }
.dot-grey { background: var(--grey); }
.dot-pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.status { display: inline-flex; align-items: center; gap: 6px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef0f3; color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge-green { background: var(--green-soft); color: #0f7a41; }
.badge-red { background: var(--red-soft); color: #a92525; }
.badge-amber { background: var(--amber-soft); color: #8f5b00; }
.badge-blue { background: var(--blue-soft); color: #1d5f9f; }

.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(31, 99, 214, .2); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; flex: none; }
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 14px 0; }

.alert { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 14px; border-radius: 8px; margin: 10px 0; border: 1px solid; }
.alert-error { background: var(--red-soft); border-color: #f4c2c2; color: #7d1d1d; }
.alert-warn { background: var(--amber-soft); border-color: #f1d49a; color: #6b4300; }
.alert-info { background: var(--blue-soft); border-color: #c4dcf4; color: #1c4c7c; }
.alert-success { background: var(--green-soft); border-color: #b7e3c9; color: #0f5f34; }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-body p { max-width: 520px; margin: 0 auto 12px; }
.tech-detail { font-size: .85rem; color: var(--muted); margin-top: 8px; overflow-wrap: anywhere; }
.tech-detail code { background: #f1f3f6; padding: 1px 4px; border-radius: 4px; }

/* ---------------------------------------------------------------- buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: #f5f7fa; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b92d2d; }
.btn-danger-outline { color: var(--red); border-color: #efb4b4; }
.btn-danger-outline:hover { background: var(--red-soft); }
.btn-small { min-height: 32px; padding: 4px 10px; font-size: .88rem; }
.btn-big { min-height: 48px; padding: 10px 22px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; }
.btn-icon { background: none; border: 0; font-size: 1.1rem; cursor: pointer; padding: 6px 8px; color: var(--muted); border-radius: 6px; }
.btn-icon:hover { background: #f1f3f6; }

.field { margin-bottom: 14px; }
.field label, .label-like { display: block; font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea, .search {
  width: 100%; min-height: 42px; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px;
  font: inherit; font-size: 16px; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus, .search:focus { outline: 2px solid rgba(31, 99, 214, .35); border-color: var(--primary); }
.field input:disabled, .field select:disabled { background: #f3f5f8; color: var(--muted); }
.field-error input, .field-error select { border-color: var(--red); }
.field-msg { color: var(--red); font-size: .88rem; margin-top: 4px; }
.hint { color: var(--muted); font-size: .86rem; margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.field-row.three { grid-template-columns: 110px 1fr 1fr; }
.static-value { padding: 6px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.input-with-btn { display: flex; gap: 6px; }
.input-with-btn input { flex: 1; }
.check-line { display: flex; gap: 8px; align-items: baseline; margin: 6px 0; font-weight: 400 !important; cursor: pointer; }
.check-line input { width: auto; min-height: 0; }
.pick-list { max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
.subform { border: 1px solid var(--border); background: #fafbfc; border-radius: var(--radius); padding: 14px 16px; margin: 6px 0 16px; }
.subform h3 { margin-top: 0; }

.choices { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 12px; cursor: pointer; background: #fff; }
.choice.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary) inset; }
.choice.disabled { opacity: .55; cursor: not-allowed; }
.choice input { margin-top: 4px; }
.choice-body { display: flex; flex-direction: column; gap: 2px; }
.choice-label { font-weight: 600; }
.choice-help { color: var(--muted); font-size: .9rem; }
.choice-extra { font-size: .84rem; color: #3a4a5e; }
.opt-title { margin-top: .4rem; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { background: none; border: 0; padding: 6px 12px; font: inherit; font-size: .9rem; cursor: pointer; color: var(--text); min-height: 34px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--primary); color: #fff; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { max-width: 320px; }
.refresh-note { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.scope-bar { display: flex; gap: 10px; align-items: center; background: var(--blue-soft); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------------------------------------------------------------- tables */
.table-scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .82rem; text-transform: none; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: #fafbfc; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f8fafc; }
.table tr.is-revoked td { color: var(--muted); }
.table tr.status-offline .cell-name strong { color: #a92525; }
.cell-name { min-width: 150px; }
.cell-error { max-width: 220px; color: #8a2a2a; font-size: .85rem; overflow-wrap: anywhere; }
.cell-actions { text-align: right; white-space: nowrap; }
.cams-table .cell-actions { position: sticky; right: 0; background: #fff; box-shadow: -6px 0 8px -6px rgba(16, 24, 40, .15); }
.cams-table th.cell-actions { background: #fafbfc; }
.cell-video { white-space: nowrap; }
.bar-col { width: 30%; min-width: 120px; }
.bar { height: 8px; background: #eef1f5; border-radius: 4px; overflow: hidden; margin: 3px 0; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-in, .bar-fill.bar-in { background: var(--blue); }
.bar-out, .bar-fill.bar-out { background: #8e6bd8; }
.legend { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 12px 6px 0; vertical-align: top; width: 40%; font-size: .92rem; }
.kv td { padding: 6px 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- menus & modals */
.menu { position: relative; display: inline-block; }
.menu-items { position: absolute; top: calc(100% + 4px); z-index: 40; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(16, 24, 40, .16); min-width: 200px; padding: 6px 0; text-align: left; }
.menu-right { right: 0; }
.menu-fixed { top: auto; max-height: 70vh; overflow-y: auto; }
.menu-left { left: 0; }
.menu-items button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 14px; font: inherit; cursor: pointer; color: var(--text); }
.menu-items button:hover { background: #f3f6fa; }
.menu-items button.danger { color: var(--red); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 33, .5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 480px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal-wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 18px 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.dialog-message { margin-bottom: 12px; }
.dialog-message p:first-child { margin-top: 0; }

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; width: min(560px, calc(100vw - 32px)); }
.toast { background: #23303f; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); cursor: pointer; overflow-wrap: anywhere; }
.toast-success { background: #11603a; }
.toast-error { background: #9b2424; }

/* ---------------------------------------------------------------- copy & secrets */
.copy-field { display: flex; gap: 6px; align-items: stretch; }
.copy-field input, .copy-field textarea { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: #f8fafc; font-size: .88rem; }
.copy-field textarea { min-height: 150px; resize: vertical; }
.copy-field.is-muted { opacity: .6; }
.secret-once { display: flex; flex-direction: column; gap: 6px; }
.secret-title { font-weight: 700; }
.usage { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 6px; }
.usage ol { padding-left: 1.2rem; }
.usage li { margin: .4rem 0; }
.usage .mono { background: #f3f5f8; padding: 6px 8px; border-radius: 6px; display: block; margin: 4px 0; }

/* ---------------------------------------------------------------- camera pieces */
.step-no { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-size: .9rem; align-items: center; justify-content: center; margin-right: 6px; }
.advanced { border: 1px dashed var(--border-strong); border-radius: 8px; padding: 8px 12px; margin: 6px 0 4px; }
.advanced summary, .steps-details summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: 4px 0; }
.steps-details { margin: 10px 0; }
.conn-status { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; padding: 12px 14px; border-radius: 10px; font-size: 1.05rem; }
.conn-status .status { font-weight: 700; }
.conn-ok { background: var(--green-soft); }
.conn-fail { background: var(--red-soft); flex-direction: column; }
.conn-reason { font-size: 1rem; }
.fix-tips ul { padding-left: 1.2rem; }
.checklist { list-style: none; padding: 0; margin: 8px 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; }
.check { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; flex: none; background: #e9edf2; color: var(--muted); }
.check-ok { background: var(--green); color: #fff; }
.check-fail { background: var(--red); color: #fff; }
.check-working { background: none; }
.check-unknown { background: #eef0f3; color: var(--muted); }
.probe-details .kv { margin-bottom: 10px; }
.stream-table { margin: 8px 0; }

.ladder-summary { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-weight: 600; }
.ladder-message { font-weight: 400; color: var(--text); }
.ladder { list-style: none; margin: 0; padding: 0; position: relative; }
.ladder-step { display: flex; gap: 12px; padding: 8px 0; position: relative; }
.ladder-step:not(:last-child)::after { content: ""; position: absolute; left: 10px; top: 32px; bottom: -6px; width: 2px; background: var(--border); }
.ladder-step.is-ok:not(:last-child)::after { background: #9bd8b5; }
.ladder-label { font-weight: 600; }
.ladder-state { font-weight: 500; font-size: .8rem; color: var(--muted); margin-left: 6px; }
.ladder-step.is-fail .ladder-state { color: var(--red); }
.ladder-step.is-ok .ladder-state { color: var(--green); }
.ladder-step.is-waiting .ladder-label, .ladder-step.is-off .ladder-label { color: var(--muted); }
.success-box { display: flex; gap: 12px; align-items: center; background: var(--green-soft); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }

.endpoints { list-style: none; margin: 0; padding: 0; }
.endpoint { padding: 10px 0; border-top: 1px solid var(--border); }
.endpoint:first-child { border-top: 0; }
.endpoint-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.endpoint-label { font-weight: 700; }
.endpoint-url { display: flex; gap: 8px; align-items: center; }
.endpoint-url code { flex: 1; min-width: 0; background: #f3f5f8; padding: 6px 8px; border-radius: 6px; overflow-wrap: anywhere; font-size: .86rem; }
.endpoint.unverified .endpoint-url code { color: #8a94a2; background: #f6f7f9; border: 1px dashed #cfd5dd; }
.endpoint-reason { font-size: .85rem; color: #8f5b00; margin-top: 4px; }
.temp-links .seg { margin-bottom: 4px; }
.temp-result { margin-top: 10px; }

.events li { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.events li:first-child { border-top: 0; }

/* ---------------------------------------------------------------- player */
.player { position: relative; background: #000; border-radius: 10px; overflow: hidden; width: 100%; color: #fff; }
.player-stage { position: relative; aspect-ratio: 16 / 9; width: 100%; }
.player-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.player.is-fs, .player-full { display: flex; flex-direction: column; border-radius: 0; height: 100%; }
.player.is-fs .player-stage, .player-full .player-stage { flex: 1; aspect-ratio: auto; min-height: 0; }
.player-overlay { position: absolute; inset: 0 0 48px 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .55); text-align: center; }
.ov { display: flex; flex-direction: column; gap: 8px; align-items: center; max-width: 520px; }
.ov-wide { max-width: 640px; }
.ov-title { font-weight: 700; font-size: 1.1rem; }
.ov-sub { color: #d5dce5; font-size: .92rem; }
.ov .spinner { border-color: rgba(255, 255, 255, .25); border-top-color: #fff; width: 32px; height: 32px; }
.ov-error .ov-title { color: #ffb4b4; }
.ov-warn .ov-title { color: #ffd88a; }
.ov .btn { color: var(--text); }
.ov .btn-primary { color: #fff; }
.player-badge { position: absolute; top: 10px; left: 10px; background: rgba(0, 0, 0, .55); padding: 3px 9px; border-radius: 6px; font-size: .78rem; font-weight: 700; display: flex; gap: 6px; align-items: center; letter-spacing: .03em; }
.player-tech { font-weight: 500; color: #c8d2de; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff3b3b; animation: pulse 1.6s infinite; }
.player-note { position: absolute; top: 10px; right: 10px; left: 140px; text-align: right; font-size: .8rem; color: #ffe3a3; text-shadow: 0 1px 2px #000; pointer-events: none; }
.player-controls { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; align-items: center; padding: 6px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); flex-wrap: wrap; }
.seg-dark { background: rgba(0, 0, 0, .45); border-color: rgba(255, 255, 255, .3); }
.seg-dark button { color: #fff; font-size: .82rem; min-height: 30px; padding: 4px 10px; }
.seg-dark button + button { border-left-color: rgba(255, 255, 255, .3); }
.pbtn { background: rgba(0, 0, 0, .45); color: #fff; border: 1px solid rgba(255, 255, 255, .3); border-radius: 8px; padding: 4px 10px; min-height: 30px; font: inherit; font-size: .82rem; cursor: pointer; }
.pbtn:hover { background: rgba(255, 255, 255, .15); }
.player-placeholder { background: #1d2733; color: #d5dce5; border-radius: 10px; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; }

.watch-page { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; color: #fff; }
.watch-bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: #0d1620; min-height: 46px; flex-wrap: wrap; }
.watch-back { color: #b9cde3; }
.watch-title { font-weight: 700; }
.watch-shared { margin-left: auto; font-size: .8rem; color: #9fb0c3; }
.watch-body { flex: 1; min-height: 0; }
.watch-empty { margin: auto; color: #ccc; }

/* ---------------------------------------------------------------- pairing */
.pair-code { text-align: center; padding: 14px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pair-code-value { font-family: var(--mono); font-size: clamp(1.7rem, 7vw, 2.8rem); font-weight: 700; letter-spacing: .08em; background: #f3f6fb; border: 2px dashed var(--primary); border-radius: 12px; padding: 10px 20px; user-select: all; }
.pair-code.is-expired .pair-code-value { opacity: .4; text-decoration: line-through; border-color: var(--grey); }
.big-steps { counter-reset: s; list-style: none; padding: 0; margin: 22px 0 6px; }
.big-steps > li { counter-increment: s; position: relative; padding: 0 0 18px 48px; }
.big-steps > li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 1.05rem; }
.step-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 2px; }
.install-block { margin-top: 12px; }
.install-title { font-weight: 600; }
.cmd { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.cmd code { flex: 1; min-width: 0; background: #0f1720; color: #d6f5e3; padding: 10px 12px; border-radius: 8px; overflow-wrap: anywhere; font-size: .85rem; }
.waiting { display: flex; gap: 8px; align-items: center; }
.celebrate-inner { text-align: center; padding: 18px 6px; }
.celebrate-inner h2 { font-size: 1.6rem; margin: 4px 0 8px; }
.big-tick { width: 76px; height: 76px; border-radius: 50%; background: var(--green); color: #fff; font-size: 2.6rem; display: inline-flex; align-items: center; justify-content: center; animation: pop .5s ease-out; margin-bottom: 8px; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; padding: 26px; }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.role-help { margin: 0 0 12px; padding-left: 1.2rem; color: var(--muted); font-size: .9rem; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .detail-grid, .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > .card { margin-bottom: 0; }
}

@media (max-width: 760px) {
  :root { font-size: 15px; }
  h1 { font-size: 1.35rem; }
  .container { padding: 14px 12px 40px; }
  .card { padding: 14px; }
  .nav-toggle { display: block; }
  .mainnav { display: none; position: absolute; top: 56px; left: 0; right: 0; background: var(--topbar); flex-direction: column; padding: 8px 12px 12px; box-shadow: 0 8px 18px rgba(0, 0, 0, .25); }
  .mainnav.open { display: flex; }
  .mainnav a { padding: 12px; }
  .user-name { display: none; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
  .search { max-width: none; flex: 1 1 100%; }
  .refresh-note { margin-left: 0; }
  .page-actions .btn { flex: 1 1 auto; }

  /* Tables become cards */
  .table-scroll { overflow: visible; background: none; border: 0; box-shadow: none; }
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; padding: 8px 12px; }
  .card .table.responsive tr { box-shadow: none; }
  .table.responsive td { border: 0; padding: 5px 0 5px 42%; display: block; position: relative; text-align: right; min-height: 30px; }
  .table.responsive td::before { content: attr(data-label); position: absolute; left: 0; top: 6px; width: 40%; color: var(--muted); font-family: var(--sans); font-weight: 600; font-size: .82rem; text-align: left; }
  .table.responsive td > .status { justify-content: flex-end; }
  .cams-table .cell-actions { position: static; box-shadow: none; background: none; }
  .table.responsive td:not([data-label])::before { content: none; }
  .table.responsive td.cell-name { display: block; text-align: left; font-size: 1.05rem; border-bottom: 1px solid var(--border); padding: 4px 0 8px; margin-bottom: 4px; }
  .table.responsive td.cell-name::before { content: none; }
  .table.responsive td.cell-actions { padding: 8px 0 2px; border-top: 1px solid var(--border); margin-top: 6px; }
  .table.responsive td.bar-col { padding-left: 0; }
  .cell-video { white-space: normal; }
  .table.responsive .num { text-align: right; }
  .cell-error { max-width: none; }
  .bar-col { width: auto; min-width: 0; }
  .events li { grid-template-columns: 1fr; gap: 2px; }
  .kv th { width: 45%; }
  .player-note { left: 10px; top: 40px; text-align: left; }
  .player-overlay { inset: 0; }
  .player:not(.is-fs) .player-controls { position: static; background: #111; }
  .player-full:not(.is-fs) .player-controls { position: static; }
  .ov-sub { font-size: .85rem; }
  .copy-field { flex-direction: column; }
  .endpoint-url, .cmd { flex-direction: column; align-items: stretch; }
  .modal-backdrop { padding-top: 12px; }
}

/* quick start (Overview): connect this PC, then IP + login -> stream link */
.quickstart { margin-bottom: 16px; }
.quick-camera .btn-big { margin-top: 4px; }
.stream-links { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.stream-links h3 { margin: 0 0 10px; color: var(--green, #0f7a43); }
.stream-links .cmd code { word-break: break-all; }
