/* AmpleGuard — Amplefy design system.
   Tokens taken from amplefy.sa: navy #0D0C33, teal #00AA89, mint #00DBB1,
   violet #694EEF; IBM Plex Sans Arabic / IBM Plex Sans; pill buttons,
   near-square cards, navy hero areas with soft glows.
   Mobile first. Logical properties only (inline-start/end), so one sheet
   serves Arabic (RTL) and English (LTR). */

@import url('/css/fonts.css');

:root {
  --navy: #0d0c33;
  --navy-950: #08071f;
  --navy-800: #1b1a4a;
  --navy-700: #2a2963;
  --teal: #00aa89;
  --teal-400: #33cba8;
  --teal-700: #00745d;
  --teal-50: #e8faf6;
  --mint: #00dbb1;
  --violet: #694eef;
  --violet-50: #f0edfe;

  --bg: #f7f7fb;
  --bg-2: #f1f1f7;
  --surface: #ffffff;
  --ink: #0d0c33;
  --ink-2: #3c3b5e;
  --muted: #6f6fa0;
  --line: rgba(13, 12, 51, 0.09);
  --line-2: rgba(13, 12, 51, 0.16);

  --danger: #d9363e;
  --danger-50: #fdeeee;
  --warn: #b7791f;
  --warn-50: #fdf6e7;

  --shadow-card: 0 1px 2px rgba(13, 12, 51, 0.04), 0 12px 32px -12px rgba(13, 12, 51, 0.12);
  --shadow-lift: 0 2px 4px rgba(13, 12, 51, 0.06), 0 24px 48px -16px rgba(13, 12, 51, 0.18);
  --glow-mint: 0 0 40px rgba(0, 219, 177, 0.35);

  --radius: 2px;          /* Amplefy cards and fields are near-square */
  --pill: 999px;
  --tap: 44px;            /* minimum touch target */

  --header-h: 56px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font: 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
:root[lang='en'] { --font: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img, video, canvas { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ */
/* App shell: header + bottom tab bar                                  */
/* ------------------------------------------------------------------ */
.app-header {
  position: sticky; top: 0; z-index: 40;
  padding-top: var(--safe-top);
  background: rgba(13, 12, 51, 0.92);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.app-header .bar {
  height: var(--header-h);
  max-width: 1200px; margin: 0 auto;
  padding-inline: 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: var(--tap); }
.brand .mark { width: 30px; height: 30px; flex: none; }
.brand .name { font-weight: 700; font-size: 18px; letter-spacing: 0; white-space: nowrap; }
.brand .name em { font-style: normal; color: var(--mint); }
.app-header .spacer { flex: 1; }
.app-header .topnav { display: none; gap: 4px; }
.app-header .topnav a {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding-inline: 14px;
  border-radius: var(--pill); color: rgba(255, 255, 255, 0.75); font-weight: 500; font-size: 15px;
}
.app-header .topnav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.app-header .topnav a[aria-current='page'] { color: var(--navy); background: var(--mint); }

.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar nav { height: var(--tabbar-h); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; max-width: 640px; margin: 0 auto; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 12px; font-weight: 500; min-height: var(--tap);
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current='page'] { color: var(--teal-700); }
.tabbar a[aria-current='page'] svg { color: var(--teal); }
.tabbar .dot { position: relative; }
.tabbar .dot::after {
  content: ''; position: absolute; top: -2px; inset-inline-end: -4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--danger); border: 2px solid #fff;
}

.page {
  max-width: 1200px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 16px; }
.page-title { font-size: 26px; line-height: 1.3; font-weight: 700; margin: 0; }
.page-sub { color: var(--muted); margin: 2px 0 0; font-size: 15px; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; color: var(--teal-700); font-weight: 600; font-size: 13px; }
.eyebrow::before { content: ''; width: 22px; height: 2px; background: var(--teal); }

@media (min-width: 900px) {
  .app-header .topnav { display: flex; }
  .tabbar { display: none; }
  .page { padding-bottom: 48px; padding-top: 24px; }
  .page-title { font-size: 32px; }
}

/* ------------------------------------------------------------------ */
/* Navy hero with glows (login, dashboard top)                         */
/* ------------------------------------------------------------------ */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--navy); color: #fff;
  padding: 22px 18px;
  border-radius: var(--radius);
}
.hero::before, .hero::after {
  content: ''; position: absolute; z-index: -1; border-radius: 50%; filter: blur(64px); pointer-events: none;
}
.hero::before { width: 320px; height: 320px; top: -160px; inset-inline-start: -90px; background: rgba(0, 170, 137, 0.45); }
.hero::after { width: 380px; height: 380px; bottom: -220px; inset-inline-end: -140px; background: rgba(105, 78, 239, 0.40); }
.hero h1 { margin: 6px 0 4px; font-size: 24px; line-height: 1.35; font-weight: 700; }
.hero p { margin: 0; color: rgba(255, 255, 255, 0.72); }
.hero .eyebrow { color: var(--mint); }
.hero .eyebrow::before { background: var(--mint); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.stat { background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.10); padding: 10px 12px; border-radius: var(--radius); }
.stat b { display: block; font-size: 24px; line-height: 1.2; font-weight: 700; }
.stat span { font-size: 12.5px; color: rgba(255, 255, 255, 0.7); }
.stat.alert b { color: #ff9b9f; }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 22px;
  border: 0; border-radius: var(--pill);
  background: var(--teal-400); color: var(--navy);
  font-weight: 600; font-size: 15px; line-height: 1.2; white-space: nowrap;
  cursor: pointer; transition: background 0.2s, box-shadow 0.2s, transform 0.08s;
}
.btn:hover { background: var(--mint); box-shadow: var(--glow-mint); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.55; cursor: default; box-shadow: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--bg-2); color: var(--ink); }
.btn-ghost:hover { background: #e7e7f1; box-shadow: none; }
.btn-outline { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-outline:hover { background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-dark { background: var(--navy); color: #fff; }
.btn-dark:hover { background: var(--navy-800); box-shadow: none; }
.btn-danger { background: var(--danger-50); color: var(--danger); }
.btn-danger:hover { background: #fbdcdc; box-shadow: none; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.on-dark .btn-ghost, .btn-ghost.on-dark { background: rgba(255, 255, 255, 0.10); color: #fff; }
.on-dark .btn-ghost:hover, .btn-ghost.on-dark:hover { background: rgba(255, 255, 255, 0.16); }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none;
  border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(13, 12, 51, 0.06); }
.app-header .icon-btn:hover, .on-dark .icon-btn:hover { background: rgba(255, 255, 255, 0.10); }
.icon-btn svg { width: 22px; height: 22px; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding-inline: 12px;
  border-radius: var(--pill); border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.10); color: #fff; font-weight: 600; font-size: 13.5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.lang-btn svg { width: 16px; height: 16px; }
.lang-btn.on-light { background: var(--bg-2); color: var(--ink); box-shadow: none; }

/* ------------------------------------------------------------------ */
/* Chips, badges, status                                               */
/* ------------------------------------------------------------------ */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding-inline: 10px;
  border-radius: var(--pill); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--bg-2); color: var(--ink-2);
}
.chip.teal { background: var(--teal-50); color: var(--teal-700); }
.chip.violet { background: var(--violet-50); color: var(--violet); }
.chip.danger { background: var(--danger-50); color: var(--danger); }
.chip.warn { background: var(--warn-50); color: var(--warn); }
.chip.dark { background: rgba(8, 7, 31, 0.72); color: #fff; backdrop-filter: blur(6px); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.live .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(0, 219, 177, 0.6); } 70% { box-shadow: 0 0 0 7px rgba(0, 219, 177, 0); } 100% { box-shadow: 0 0 0 0 rgba(0, 219, 177, 0); } }

/* ------------------------------------------------------------------ */
/* Cards and camera grid                                               */
/* ------------------------------------------------------------------ */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.card-pad { padding: 16px; }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-title { margin: 0; font-size: 19px; font-weight: 700; line-height: 1.35; }
.section-title small { display: block; font-size: 13px; color: var(--muted); font-weight: 500; }

.cam-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 620px) { .cam-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .cam-grid { grid-template-columns: repeat(3, 1fr); } }
.cam-card { display: block; overflow: hidden; transition: box-shadow 0.2s, transform 0.2s; }
.cam-card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.cam-card .media { position: relative; aspect-ratio: 16 / 9; background: var(--navy-950); overflow: hidden; }
.cam-card .media img { width: 100%; height: 100%; object-fit: cover; }
.cam-card .media .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255, 255, 255, 0.35); }
.cam-card .media .placeholder svg { width: 40px; height: 40px; }
.cam-card .media .tl { position: absolute; top: 10px; inset-inline-start: 10px; display: flex; gap: 6px; }
.cam-card .media .br { position: absolute; bottom: 10px; inset-inline-end: 10px; }
.cam-card .meta { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.cam-card .meta .t { flex: 1; min-width: 0; }
.cam-card .meta b { display: block; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-card .meta span { font-size: 13px; color: var(--muted); }
.cam-card .meta .go { color: var(--muted); }
.cam-card .meta .go svg { width: 20px; height: 20px; }
[dir='rtl'] .flip-rtl { transform: scaleX(-1); }

/* ------------------------------------------------------------------ */
/* Lists (reports, alerts, admin rows)                                 */
/* ------------------------------------------------------------------ */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); width: 100%; text-align: start; background: none; border-inline: 0; border-top: 0;
}
.list-row:last-child { border-bottom: 0; }
button.list-row, a.list-row { cursor: pointer; }
button.list-row:hover, a.list-row:hover { background: var(--bg); }
.list-row .ic {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: var(--radius);
  background: var(--teal-50); color: var(--teal-700);
}
.list-row .ic svg { width: 22px; height: 22px; }
.list-row .ic.violet { background: var(--violet-50); color: var(--violet); }
.list-row .ic.danger { background: var(--danger-50); color: var(--danger); }
.list-row .ic.muted { background: var(--bg-2); color: var(--muted); }
.list-row .thumb { width: 72px; height: 48px; flex: none; object-fit: cover; border-radius: var(--radius); background: var(--navy-950); }
.list-row .body { flex: 1; min-width: 0; }
.list-row .body b { display: block; font-weight: 600; line-height: 1.4; }
.list-row .body > span { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.list-row .body .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list-row .end { display: flex; align-items: center; gap: 6px; flex: none; color: var(--muted); }
.list-row .end svg { width: 20px; height: 20px; }
.list-group-title { margin: 22px 4px 8px; font-size: 13.5px; font-weight: 600; color: var(--muted); }

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 13px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  font-size: 16px; /* 16px keeps iOS from zooming in */
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 170, 137, 0.18); }
.input[aria-invalid='true'] { border-color: var(--danger); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-inline-end: 38px; }
[dir='rtl'] .select { background-position: 15px 21px, 20px 21px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--teal); flex: none; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: var(--pill); background: #d8d8e6; transition: background 0.2s; }
.switch span::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform 0.2s; }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::after { transform: translateX(20px); }
[dir='rtl'] .switch input:checked + span::after { transform: translateX(-20px); }
.form-error { color: var(--danger); font-size: 14px; min-height: 20px; }
.secret {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; background: var(--teal-50); border: 1px dashed var(--teal); border-radius: var(--radius);
  font-family: 'IBM Plex Sans', monospace; font-size: 18px; font-weight: 600; letter-spacing: 0.04em; direction: ltr;
}

/* Segmented tabs */
.seg { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 16px; padding-bottom: 2px; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: none; height: 40px; padding-inline: 16px; border-radius: var(--pill); border: 0; cursor: pointer;
  background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 14.5px; box-shadow: inset 0 0 0 1px var(--line);
}
.seg button[aria-selected='true'] { background: var(--navy); color: #fff; box-shadow: none; }

/* ------------------------------------------------------------------ */
/* Sheet (bottom sheet on phones, dialog on desktop)                   */
/* ------------------------------------------------------------------ */
dialog.sheet {
  border: 0; padding: 0; margin: 0; max-width: none; max-height: none; width: 100%;
  background: transparent; color: var(--ink);
}
dialog.sheet::backdrop { background: rgba(8, 7, 31, 0.55); backdrop-filter: blur(2px); }
dialog.sheet[open] { position: fixed; inset: auto 0 0 0; display: flex; justify-content: center; }
dialog.sheet .sheet-box {
  width: 100%; max-width: 560px; max-height: calc(100dvh - 40px - var(--safe-top));
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 14px 14px 0 0; box-shadow: var(--shadow-lift);
  animation: sheet-up 0.22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
dialog.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: #d8d8e6; margin: 10px auto 2px; }
dialog.sheet header { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 20px; }
[dir='rtl'] dialog.sheet header { padding: 6px 20px 6px 12px; }
dialog.sheet header h2 { flex: 1; margin: 0; font-size: 19px; font-weight: 700; }
dialog.sheet .sheet-body { padding: 8px 20px 16px; overflow-y: auto; }
dialog.sheet footer { display: flex; gap: 10px; padding: 12px 20px calc(16px + var(--safe-bottom)); border-top: 1px solid var(--line); }
dialog.sheet footer .btn { flex: 1; }
@media (min-width: 700px) {
  dialog.sheet[open] { inset: 0; align-items: center; }
  dialog.sheet .sheet-box { border-radius: var(--radius); }
  dialog.sheet .grabber { display: none; }
  dialog.sheet footer { padding-bottom: 16px; }
}

/* Image viewer sheet */
dialog.sheet.photo .sheet-box { max-width: 980px; background: var(--navy-950); color: #fff; }
dialog.sheet.photo .sheet-body img { width: 100%; border-radius: var(--radius); }

/* ------------------------------------------------------------------ */
/* Toast, empty states, skeletons                                      */
/* ------------------------------------------------------------------ */
.toast-wrap { position: fixed; z-index: 60; inset-inline: 16px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px); display: grid; justify-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 900px) { .toast-wrap { bottom: 24px; } }
.toast {
  pointer-events: auto; max-width: 480px; padding: 12px 18px; border-radius: var(--pill);
  background: var(--navy); color: #fff; font-weight: 500; font-size: 15px; box-shadow: var(--shadow-lift);
  animation: sheet-up 0.2s ease-out;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--teal-700); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; margin: 0 auto 10px; color: #c5c5dc; }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, #ececf4 25%, #f6f6fb 37%, #ececf4 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--mint); animation: spin 0.8s linear infinite; }
.spinner.dark { border-color: var(--line-2); border-top-color: var(--teal); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ */
/* Login                                                               */
/* ------------------------------------------------------------------ */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
  background: var(--navy); color: #fff; position: relative; overflow: hidden; isolation: isolate;
}
.auth::before, .auth::after { content: ''; position: absolute; z-index: -1; border-radius: 50%; filter: blur(80px); }
.auth::before { width: 460px; height: 460px; top: -220px; inset-inline-start: -160px; background: rgba(0, 170, 137, 0.40); }
.auth::after { width: 520px; height: 520px; bottom: -280px; inset-inline-end: -200px; background: rgba(105, 78, 239, 0.38); }
.auth-box { width: 100%; max-width: 400px; }
.auth-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 36px; }
.auth h1 { font-size: 30px; line-height: 1.3; margin: 14px 0 6px; font-weight: 700; }
.auth .lead { color: rgba(255, 255, 255, 0.72); margin: 0 0 26px; }
.auth .badge-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--pill); background: rgba(255,255,255,.10); color: var(--mint); font-size: 13.5px; font-weight: 500; box-shadow: inset 0 0 0 1px rgba(255,255,255,.10); }
.auth .input { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.16); color: #fff; }
.auth .input::placeholder { color: rgba(255, 255, 255, 0.4); }
.auth .input:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(0, 219, 177, 0.18); }
.auth .field > label { color: rgba(255, 255, 255, 0.8); }
.auth .form-error { color: #ff9b9f; }
.auth .foot { margin-top: 28px; color: rgba(255, 255, 255, 0.45); font-size: 13px; text-align: center; }

/* ------------------------------------------------------------------ */
/* Live viewer                                                         */
/* ------------------------------------------------------------------ */
.viewer { position: fixed; inset: 0; background: #000; color: #fff; display: flex; flex-direction: column; }
.viewer .vbar {
  position: absolute; z-index: 5; inset-inline: 0; top: 0;
  padding: calc(8px + var(--safe-top)) 8px 28px;
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(to bottom, rgba(0,0,0,.65), transparent);
}
.viewer .vbar .title { flex: 1; min-width: 0; }
.viewer .vbar .title b { display: block; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer .vbar .title span { font-size: 12.5px; color: rgba(255,255,255,.7); }
.viewer .stage { flex: 1; position: relative; display: grid; place-items: center; overflow: hidden; }
.viewer .stage video-stream, .viewer .stage video, .viewer .stage .player-box { width: 100%; height: 100%; }
.viewer .stage video { object-fit: contain; background: #000; }
.viewer .overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; background: rgba(0,0,0,.45); z-index: 3; }
.viewer .overlay.hidden { display: none; }
.viewer .overlay .msg { margin-top: 12px; color: rgba(255,255,255,.85); }
.viewer .controls {
  position: absolute; z-index: 5; inset-inline: 0; bottom: 0;
  padding: 26px 12px calc(12px + var(--safe-bottom));
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
}
.viewer .controls .icon-btn { background: rgba(255,255,255,.12); width: 48px; height: 48px; }
.viewer .controls .icon-btn:hover { background: rgba(255,255,255,.2); }
.viewer .controls .btn { min-height: 48px; }
.viewer .nav-prev, .viewer .nav-next {
  position: absolute; z-index: 4; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(0,0,0,.35); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.viewer .nav-prev { inset-inline-start: 10px; }
.viewer .nav-next { inset-inline-end: 10px; }
.viewer .nav-prev svg, .viewer .nav-next svg { width: 26px; height: 26px; }
.viewer .ptz { position: absolute; z-index: 5; inset-inline-end: 14px; bottom: calc(96px + var(--safe-bottom)); }
.ptz-pad { display: grid; grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 48px); gap: 4px; }
.ptz-btn { border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 18px; cursor: pointer; }
.ptz-btn:active { background: var(--teal); }
.ptz-btn.up { grid-column: 2; grid-row: 1; } .ptz-btn.left { grid-column: 1; grid-row: 2; } .ptz-btn.home { grid-column: 2; grid-row: 2; }
.ptz-btn.right { grid-column: 3; grid-row: 2; } .ptz-btn.down { grid-column: 2; grid-row: 3; }
/* Bars fade only while video is playing; an error or spinner keeps them visible. */
.viewer.playing.idle .vbar, .viewer.playing.idle .controls, .viewer.playing.idle .nav-prev, .viewer.playing.idle .nav-next { opacity: 0; pointer-events: none; transition: opacity .3s; }

/* Wall (several cameras) */
.wall { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 700px) { .wall { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1300px) { .wall { grid-template-columns: repeat(3, 1fr); } }
.wall-tile { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.wall-tile video-stream, .wall-tile video { width: 100%; height: 100%; object-fit: cover; }
.wall-tile .label { position: absolute; top: 8px; inset-inline-start: 8px; z-index: 2; }
.wall-tile .expand { position: absolute; bottom: 8px; inset-inline-end: 8px; z-index: 2; }

/* Playback (recordings and NVR history). Time runs left to right in both languages. */
.pb-player { position: relative; background: #000; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; }
.pb-player video, .pb-player video-stream { width: 100%; height: 100%; object-fit: contain; }
.pb-player .pb-overlay { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; color: #fff; background: rgba(0,0,0,.45); text-align: center; padding: 16px; }
.pb-player .pb-overlay.hidden { display: none; }
.timeline { margin-top: 12px; padding: 12px 14px 14px; user-select: none; direction: ltr; }
.tl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.tl-controls { display: flex; align-items: center; gap: 10px; }
.tl-btn { width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; background: var(--navy); color: #fff; cursor: pointer; font-size: 15px; }
.tl-btn:hover { background: var(--navy-800); }
.tl-now { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tl-range { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-track { position: relative; height: 48px; background: var(--bg-2); border-radius: var(--radius); cursor: pointer; overflow: hidden; touch-action: none; }
.tl-seg { position: absolute; top: 8px; bottom: 8px; background: linear-gradient(180deg, var(--teal-400), var(--teal)); border-radius: 1px; }
.tl-hover { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--muted); opacity: .6; pointer-events: none; z-index: 2; }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); left: 0; z-index: 3; pointer-events: none; }
.tl-playhead::before { content: ''; position: absolute; top: -2px; left: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px #fff; }
.tl-ticks { position: relative; height: 18px; margin-top: 6px; }
.tl-tick { position: absolute; top: 0; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-tick::before { content: ''; position: absolute; top: -6px; left: 50%; width: 1px; height: 5px; background: var(--line-2); }
.tl-tip { position: fixed; transform: translate(-50%, -140%); background: var(--navy); color: #fff; padding: 4px 9px; border-radius: var(--radius); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; pointer-events: none; z-index: 20; white-space: nowrap; }
.nvr-jump { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nvr-jump .tl-btn { width: auto; height: 36px; padding: 0 12px; border-radius: var(--pill); font-size: 13px; font-weight: 600; }

/* Admin helpers */
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kv { grid-template-columns: repeat(4, 1fr); } }
.kv .card { padding: 14px 16px; }
.kv b { display: block; font-size: 26px; line-height: 1.2; font-weight: 700; }
.kv span { font-size: 13px; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick .btn { white-space: normal; text-align: center; padding-inline: 12px; }
@media (min-width: 700px) { .quick { display: flex; flex-wrap: wrap; } }
.pick-list { display: grid; gap: 8px; }
.pick-list .list-row { border: 1px solid var(--line); border-radius: var(--radius); min-height: 56px; }
.pick-list .list-row[aria-checked='true'] { border-color: var(--teal); background: var(--teal-50); }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.stack { display: grid; gap: 12px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.qr { width: 200px; height: 200px; margin: 0 auto; background: #fff; padding: 8px; }
