:root {
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #f8f9fb; --text: #1b2130; --muted: #657085; --line: #e2e5ec;
  --accent: #2557d6; --accent-soft: #e8eefc; --on-accent: #ffffff;
  --good: #1d8a4b; --weak: #b77b00; --bad: #c4372f; --none: #9aa3b2;
  --good-bg: #e5f4eb; --weak-bg: #fdf2d8; --bad-bg: #fbe6e4; --none-bg: #eef0f4;
  --radius: 14px; --gap: 14px; --nav-h: 62px; --side-w: 232px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  font-family: system-ui, "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Sans", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --surface: #181c24; --surface-2: #1e232d; --text: #e8ebf1; --muted: #98a2b3; --line: #2a303c;
    --accent: #7096ff; --accent-soft: #1d2740; --on-accent: #0b1020;
    --good: #4ec685; --weak: #e9b53f; --bad: #f06c63; --none: #6b7484;
    --good-bg: #143022; --weak-bg: #372c10; --bad-bg: #3b1b19; --none-bg: #232935;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; overflow-x: clip; }
.content, .stack, .grid2 > * { min-width: 0; }
body { min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.35rem; margin: 0 0 var(--gap); }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; }
img { display: block; }
[hidden] { display: none !important; }

/* boot */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* frame: mobile first (top bar + bottom bar), side bar from 900px */
.shell { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem;
  padding-top: calc(.55rem + env(safe-area-inset-top)); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.off { background: var(--bad-bg); color: var(--bad); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.iconbtn { border: 0; background: none; padding: .35rem; border-radius: 10px; cursor: pointer; color: var(--muted); display: inline-grid; place-items: center; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.ico { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.bottomnav { position: fixed; inset-inline: 0; bottom: 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .72rem; color: var(--muted); }
.bottomnav a.on { color: var(--accent); font-weight: 600; }
.sidenav { display: none; }
.content { padding: var(--gap); max-width: 1180px; margin: 0 auto; }

@media (min-width: 900px) {
  .shell { padding-bottom: 0; padding-inline-start: var(--side-w); }
  .bottomnav { display: none; }
  .sidenav { display: flex; flex-direction: column; gap: 2px; position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--side-w);
    padding: 1rem .75rem; background: var(--surface); border-inline-end: 1px solid var(--line); z-index: 21; }
  .sidenav .brand { font-weight: 800; font-size: 1.15rem; padding: .3rem .7rem 1rem; display: flex; gap: .5rem; align-items: center; color: var(--text); }
  .sidenav .brand img { width: 28px; height: 28px; border-radius: 8px; }
  .sidenav a.item { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 10px; color: var(--text); }
  .sidenav a.item:hover { background: var(--surface-2); }
  .sidenav a.item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .sidenav .spacer { flex: 1; }
  .content { padding: 1.4rem 1.6rem; }
}

/* blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
.tiles { display: grid; gap: var(--gap); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { display: flex; flex-direction: column; gap: .2rem; }
.tile .label { color: var(--muted); font-size: .82rem; }
.tile .num { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .ltr { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; word-break: break-all; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 42px; padding: .45rem 1rem;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 32px; padding: .2rem .7rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; }
.input, select.input, textarea.input { min-height: 42px; padding: .5rem .75rem; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); width: 100%; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.search { position: relative; flex: 1; min-width: 200px; }
.chips { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip { flex: none; padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: .85rem; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tag { display: inline-block; padding: .05rem .5rem; margin: .1rem .15rem .1rem 0; border-radius: 7px; font-size: .76rem; background: var(--none-bg); color: var(--muted); }

.badge { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700; background: var(--none-bg); color: var(--muted); }
.v-good, .b-match, .s-ok, .w-off { background: var(--good-bg); color: var(--good); }
.v-weak, .b-maybe, .s-running, .w-dry-run { background: var(--weak-bg); color: var(--weak); }
.v-rejected, .s-failed, .w-on { background: var(--bad-bg); color: var(--bad); }
.alert { padding: .7rem .9rem; border-radius: 11px; background: var(--bad-bg); color: var(--bad); }
.note { padding: .7rem .9rem; border-radius: 11px; background: var(--weak-bg); }
.ok { padding: .7rem .9rem; border-radius: 11px; background: var(--good-bg); color: var(--good); }

.bar { height: 10px; border-radius: 6px; background: var(--none-bg); overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }
.bar .good { background: var(--good); } .bar .weak { background: var(--weak); } .bar .rejected { background: var(--bad); } .bar .none { background: var(--none); }
.bar .fill { background: var(--accent); transition: width .4s ease; }
.bar .fill.busy { width: 30%; animation: busy 1.4s ease-in-out infinite; border-radius: 6px; }
@keyframes busy { 0% { margin-inline-start: -30%; } 100% { margin-inline-start: 100%; } }
@media (prefers-reduced-motion: reduce) { .bar .fill.busy { animation: none; width: 100%; opacity: .5; } }
.legend { list-style: none; margin: .7rem 0 0; padding: 0; display: grid; gap: .25rem; font-size: .9rem; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: .45rem; }

/* people */
.people { display: grid; gap: .6rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .people { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .people { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.person { display: flex; gap: .8rem; align-items: center; padding: .6rem; color: var(--text); }
.person:hover { border-color: var(--accent); }
.thumb { width: 52px; height: 64px; flex: none; border-radius: 10px; object-fit: cover; background: var(--none-bg); }
.person .who { min-width: 0; flex: 1; }
.person > :last-child { flex: none; }
.person .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .meta { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sentinel { height: 1px; }
.center { display: grid; place-items: center; padding: 1.4rem; }

.profile { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .profile { grid-template-columns: 280px minmax(0, 1fr); } }
.profile .photo { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; background: var(--none-bg); }
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.history { display: flex; gap: .6rem; overflow-x: auto; }
.history figure { margin: 0; flex: none; width: 96px; font-size: .75rem; text-align: center; }
.history img { width: 96px; height: 120px; object-fit: cover; border-radius: 9px; border: 2px solid transparent; }
.history .current img { border-color: var(--accent); }
.list { display: flex; flex-direction: column; }
.list .item { display: flex; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.list .item:last-child { border-bottom: 0; }
.list .item .grow { flex: 1; min-width: 0; }
details summary { cursor: pointer; color: var(--muted); }

/* camera */
/* contain: nothing inside the camera (the scaled video, the overlay drawn past its edges) may make the page wider — some phone
   browsers count clipped children as page width and then scroll sideways */
.camera { position: relative; width: min(100%, 560px); margin: 0 auto; aspect-ratio: 3/4; border-radius: 16px; overflow: hidden;
  background: #000; contain: layout paint; }
@media (min-width: 760px) { .camera { aspect-ratio: 4/3; } }
.camera video, .camera .overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera .mirror { transform: scaleX(-1); }
.camera .overlay .shade { fill: rgba(0, 0, 0, .45); }
.camera .overlay .guide { fill: none; stroke: #fff; stroke-width: 4; stroke-dasharray: 14 10; transition: stroke .2s; }
.camera .overlay .guide.ready { stroke: #3ddc84; stroke-dasharray: none; stroke-width: 6; }
.camera .overlay .guide.wrong { stroke: #ffb020; }
.camera .overlay .eyes { stroke: rgba(255, 255, 255, .55); stroke-width: 2; stroke-dasharray: 6 8; }
.camera .overlay .face { fill: none; stroke: #3ddc84; stroke-width: 3; }
.camera .overlay .face.bad { stroke: #ffb020; }
.camera .hint { position: absolute; inset-inline: 0; bottom: 0; padding: .7rem 1rem; text-align: center; color: #fff; font-weight: 600;
  background: linear-gradient(transparent, rgba(0, 0, 0, .7)); min-height: 3rem; }
.camera .hint.ready { color: #3ddc84; }
.camera .shutter { position: absolute; bottom: 3.4rem; inset-inline-start: 50%; transform: translateX(-50%); width: 68px; height: 68px;
  border-radius: 50%; border: 4px solid #fff; background: rgba(255, 255, 255, .25); cursor: pointer; }
[dir=rtl] .camera .shutter { transform: translateX(50%); }
.camera .shutter.ready { background: #3ddc84; border-color: #fff; }
.camera .shutter[disabled] { opacity: .4; }
.shot { width: 100%; max-width: 360px; border-radius: 14px; margin: 0 auto; }

.match { display: flex; gap: .8rem; align-items: center; padding: .6rem; border-inline-start: 4px solid var(--line); }
.match.b-match { border-inline-start-color: var(--good); } .match.b-maybe { border-inline-start-color: var(--weak); }
.decision { font-size: 1.1rem; font-weight: 700; padding: .6rem .9rem; border-radius: 12px; }
.d-match { background: var(--good-bg); color: var(--good); } .d-maybe { background: var(--weak-bg); color: var(--weak); }
.d-no_match { background: var(--none-bg); color: var(--muted); } .d-rejected { background: var(--bad-bg); color: var(--bad); }
.steps { display: flex; gap: .4rem; font-size: .8rem; color: var(--muted); }
.steps span { flex: 1; text-align: center; padding-bottom: .3rem; border-bottom: 3px solid var(--line); }
.steps span.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.steps span.done { color: var(--good); border-color: var(--good); }

/* sign in */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.auth .card { width: 100%; max-width: 380px; }
.auth .logo { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto .8rem; }
.qr { display: grid; place-items: center; }
.qr svg { width: 210px; height: 210px; background: #fff; border-radius: 10px; }

/* install offer */
.install { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-bottom: var(--gap); border-color: var(--accent); }
.install img { width: 44px; height: 44px; border-radius: 11px; flex: none; }
.install .grow { flex: 1; min-width: 12rem; }

/* toast, modal, offline */
.toast { position: fixed; inset-inline: 1rem; bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); z-index: 50; margin: 0 auto; max-width: 420px;
  padding: .75rem 1rem; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }
@media (min-width: 900px) { .toast { bottom: 1.5rem; } }
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .45); display: grid; place-items: end center; }
@media (min-width: 640px) { .modal { place-items: center; } }
.modal .sheet { width: 100%; max-width: 440px; background: var(--surface); border-radius: 18px 18px 0 0; padding: 1.2rem; }
@media (min-width: 640px) { .modal .sheet { border-radius: 18px; } }
.offline { position: sticky; top: 0; z-index: 30; background: var(--bad); color: #fff; text-align: center; padding: .3rem; font-size: .85rem; }
.table-scroll { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.t th, table.t td { padding: .5rem .55rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.nowrap { white-space: nowrap; }
.mdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: .45rem; background: var(--none); vertical-align: middle; }
.mdot.m-good { background: var(--good); } .mdot.m-weak { background: var(--weak); } .mdot.m-bad { background: var(--bad); }
table.measures td:first-child { min-width: 9rem; }
.auth-title { text-align: center; font-size: 1.2rem; }
.sidenav .brand { font-size: 1rem; line-height: 1.25; }
/* sign out: a button that looks like the menu items around it, in the danger colour */
button.item.signout { width: 100%; border: 0; background: none; font: inherit; cursor: pointer; text-align: start; color: var(--bad); }
.sidenav button.item.signout { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 10px; }
.sidenav button.item.signout:hover { background: var(--bad-bg); }
.list button.item.signout { display: flex; gap: .7rem; padding: .6rem 0; align-items: center; }
[dir=rtl] .ico.flip, [dir=rtl] button.signout .ico { transform: scaleX(-1); }
/* server status */
.meter { display: flex; flex-direction: column; gap: .35rem; }
.bar .fill.warn { background: var(--weak); } .bar .fill.bad { background: var(--bad); }
/* selecting people and moving them to a department */
button.card.person { width: 100%; text-align: start; font: inherit; cursor: pointer; }
.person.picked { border-color: var(--accent); background: var(--accent-soft); }
.pick { flex: none; width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); display: grid; place-items: center;
  font-weight: 800; font-size: .85rem; color: var(--on-accent); }
.pick.on { background: var(--accent); border-color: var(--accent); }
.selbar { position: sticky; top: 4rem; z-index: 5; }
.orglist { max-height: min(55vh, 460px); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line);
  border-radius: 11px; padding: 4px; }
.org { display: flex; gap: .5rem; align-items: center; text-align: start; padding: .55rem .7rem; border: 0; border-radius: 8px;
  background: none; cursor: pointer; font: inherit; color: var(--text); }
.org:hover { background: var(--surface-2); }
.org.on { background: var(--accent); color: var(--on-accent); }
.org.on .tag { background: rgba(255, 255, 255, .2); color: inherit; }
/* department tree */
.tree { max-height: min(55vh, 460px); overflow-y: auto; border: 1px solid var(--line); border-radius: 11px; padding: 4px; }
.tree .node { display: flex; align-items: center; gap: .25rem; border-radius: 8px; padding-block: 1px; padding-inline-end: .5rem; }
.tree .node:hover { background: var(--surface-2); }
.tree .node.on { background: var(--accent); }
.tree .node.on .label, .tree .node.on .twist, .tree .node.on .muted { color: var(--on-accent); }
.tree .twist { flex: none; width: 30px; height: 34px; border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: .8rem; transition: transform .15s; display: grid; place-items: center; }
.tree .twist.open { transform: rotate(90deg); }
[dir=rtl] .tree .twist:not(.open) { transform: scaleX(-1); }
.tree .twist.leaf { cursor: default; }
.tree .label { flex: 1; text-align: start; border: 0; background: none; cursor: pointer; font: inherit; color: var(--text);
  padding: .45rem .2rem; min-width: 0; overflow-wrap: anywhere; }

/* the outbox: changes waiting for HikCentral */
.o-sent, .o-dry_run { background: var(--good-bg); color: var(--good); }
.o-waiting, .o-sending { background: var(--weak-bg); color: var(--weak); }
.o-failed { background: var(--bad-bg); color: var(--bad); }
.outbox-row { align-items: flex-start; gap: .6rem; flex-wrap: wrap; }
.outbox-row .tight { gap: .2rem; min-width: 0; }
.outbox-row pre { white-space: pre-wrap; word-break: break-all; }
.btn.small { padding: .25rem .7rem; font-size: .8rem; }
.tag.on { background: var(--accent-bg, var(--good-bg)); color: var(--accent, var(--good)); }

/* the trust page (installing the server's root certificate) */
.auth.wide { align-items: flex-start; }
.auth.wide > .trust { width: min(720px, 100%); padding: 1rem 0; }
.trust .fp { word-break: break-all; font-size: .78rem; }
.trust .steps-list { margin: 0; padding-inline-start: 1.3rem; display: grid; gap: .55rem; line-height: 1.6; }
.row.wrap { flex-wrap: wrap; }
.center { text-align: center; }
.auth.wide .card { max-width: none; }

/* API docs: English text, left to right, also in the Arabic app */
.ltr-block { direction: ltr; text-align: left; }
.docs h3 { margin: 0; font-size: 1rem; }
.docs p { margin: 0; line-height: 1.6; }
.docs .stack.tight { gap: .35rem; }
.docs section + section { border-top: 1px solid var(--line, rgba(127,127,127,.2)); padding-top: .8rem; }
.endpoint summary { display: flex; align-items: center; gap: .6rem; cursor: pointer; flex-wrap: wrap; list-style: none; }
.endpoint summary::-webkit-details-marker { display: none; }
.endpoint[open] summary { margin-bottom: .8rem; }
.endpoint .path { font-weight: 700; word-break: break-all; }
.method { font: 700 .72rem/1 ui-monospace, monospace; padding: .3rem .5rem; border-radius: 6px; background: var(--none-bg); }
.m-get { background: var(--good-bg); color: var(--good); }
.m-post { background: var(--accent-soft); color: var(--accent); }
.m-put, .m-patch { background: var(--weak-bg); color: var(--weak); }
.m-delete { background: var(--bad-bg); color: var(--bad); }
.code { position: relative; }
.code pre, .docs pre.answer { margin: 0; padding: .7rem .8rem; border-radius: 8px; background: var(--none-bg); overflow-x: auto;
  white-space: pre; font-size: .78rem; max-height: 22rem; }
.code pre { white-space: pre-wrap; word-break: break-all; padding-right: 4.5rem; }
.code .btn { position: absolute; top: .35rem; right: .35rem; }
.docs table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.docs td, .docs th { padding: .35rem .45rem; border-bottom: 1px solid var(--line, rgba(127,127,127,.18)); vertical-align: top; text-align: left; }
.docs th { color: var(--muted); font-weight: 600; }
.docs td.mono { white-space: nowrap; }
@media (max-width: 640px) { .docs td.mono { white-space: normal; word-break: break-word; } }

/* the camera test before adding a photo */
.cam-checks { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; }
.cam-check { font-size: .78rem; padding: .2rem .6rem; border-radius: 999px; background: var(--none-bg); color: var(--muted); }
.cam-check.ok { background: var(--good-bg); color: var(--good); }
.cam-check.bad { background: var(--bad-bg); color: var(--bad); }
.shutter:disabled { opacity: .45; cursor: not-allowed; }

/* switching between the device's cameras (front / back, or another webcam) */
.camera .switch-cam { position: absolute; top: .7rem; inset-inline-end: .7rem; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .5); color: #fff; display: grid; place-items: center; cursor: pointer; z-index: 2; }
.camera .switch-cam svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* notifications */
.iconbtn.bell { position: relative; }
.iconbtn.bell .count { position: absolute; top: 2px; inset-inline-end: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: .68rem; font-weight: 700; line-height: 17px; text-align: center; }
.note-row { display: flex; align-items: flex-start; gap: .6rem; width: 100%; text-align: start; background: none; border: 0; color: inherit;
  cursor: pointer; font: inherit; }
.note-row .dot-unread { width: 8px; height: 8px; border-radius: 50%; margin-top: .45rem; flex: none; }
.note-row.unread .dot-unread { background: var(--accent); }
.note-row:not(.unread) { opacity: .75; }
.big-code { font-size: 1rem; padding: .3rem .6rem; border-radius: 8px; background: var(--none-bg); user-select: all; }
.rule .chip input { display: none; }

/* person page: name editing, ID card */
.name-row h1 { margin: 0; }
.id-card .qr-box { align-items: center; text-align: center; }
.id-card .qr svg { width: 220px; height: 220px; background: #fff; border-radius: 10px; }
.id-card .link-text { word-break: break-all; max-width: 100%; }
.small-select { width: auto; padding: .25rem .5rem; font-size: .85rem; }

.id-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.id-slot { margin: 0; display: grid; gap: .3rem; }
.id-slot figcaption { display: grid; gap: .1rem; font-size: .85rem; }
.id-thumb { display: block; width: 100%; aspect-ratio: 1.58; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--surface-2); cursor: zoom-in; }
.id-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.id-thumb.missing { display: grid; place-items: center; color: var(--muted); font-size: .85rem; border-style: dashed; cursor: default; }
.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .8); display: grid; place-items: center; padding: 1rem; }
.viewer-box { background: var(--surface); border-radius: 14px; padding: 1rem; width: min(960px, 100%); max-height: 100%; overflow: auto; }
.id-full { width: 100%; height: auto; border-radius: 8px; }

/* MRZ test */
.mrz-table td:first-child { color: var(--muted); white-space: nowrap; padding-inline-end: 1rem; }
.mrz-table td { padding: .25rem 0; vertical-align: top; }
.mrz-lines { margin: 0; padding: .6rem .8rem; border-radius: 8px; background: var(--none-bg); font-size: .82rem; letter-spacing: .06em;
  overflow-x: auto; }
.mrz-band { width: 100%; background: #fff; border-radius: 6px; }

/* gate passages */
.passage { align-items: center; gap: .7rem; }
.pass-pic { width: 52px; height: 52px; flex: none; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: var(--surface-2); cursor: zoom-in; display: grid; place-items: center; }
.pass-pic img { width: 100%; height: 100%; object-fit: cover; }
.pass-pic.none { cursor: default; color: var(--muted); }
.passages .right { align-items: flex-end; text-align: end; }

/* left-to-right values (numbers, ids, codes, dates) inside the Arabic page keep their character order but line up on the right like the
   Arabic around them; typing fields, code blocks and the MRZ lines stay left-aligned */
[dir="rtl"] .ltr { text-align: right; }
[dir="rtl"] .input.ltr, [dir="rtl"] pre.ltr, [dir="rtl"] .ltr-block { text-align: left; }

/* the gate log (all passages, live) */
.live-pill { cursor: pointer; border: 1px solid var(--line); }
.live-pill .dot { background: var(--muted); animation: none; }
.live-pill.on { color: var(--good); }
.live-pill.on .dot { background: var(--good); animation: pulse 1.6s ease-in-out infinite; }
.tile-btn { text-align: start; cursor: pointer; font: inherit; color: inherit; }
.tile-btn.on { outline: 2px solid var(--bad); outline-offset: -2px; }
.bad-num { color: var(--bad); } .in-num { color: var(--good); } .out-num { color: var(--weak); }
.filter-grid { display: grid; gap: .5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
@media (min-width: 900px) { .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.passages .item.passage { transition: background 2s ease; }
.passages .item.passage.fresh { background: var(--good-bg); }
.passages .item.passage.refused { box-shadow: inset 3px 0 0 var(--bad); }
[dir="rtl"] .passages .item.passage.refused { box-shadow: inset -3px 0 0 var(--bad); }
.passages .right { align-items: flex-end; text-align: end; }
.row.tight { gap: .3rem; flex-wrap: nowrap; }
.dir-in { background: var(--good-bg); color: var(--good); }
.dir-out { background: var(--weak-bg); color: var(--weak); }
.door-row { flex-wrap: wrap; gap: .6rem; align-items: center; }
.door-row .door-name { max-width: 260px; }
@media (prefers-reduced-motion: reduce) { .live-pill.on .dot { animation: none; } .passages .item.passage { transition: none; } }

/* registered photo + gate picture, one block */
.pic-pair { display: flex; flex: none; padding: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--none-bg);
  cursor: pointer; }
.pic-pair .half { width: 48px; height: 56px; display: grid; place-items: center; color: var(--muted); }
.pic-pair .half + .half { border-inline-start: 2px solid var(--surface); }
.pic-pair img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pic-pair i { font-style: normal; }
.pair-full { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.pair-full figure { margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.pair-full img { width: 100%; height: auto; max-height: 60vh; object-fit: contain; border-radius: 8px; background: var(--none-bg); }
.pair-none { aspect-ratio: 3 / 4; display: grid; place-items: center; border-radius: 8px; background: var(--none-bg); font-size: 1.5rem; }

/* roles and permissions */
.roles-wrap { overflow-x: auto; padding: 0; }
.roles { width: 100%; border-collapse: collapse; min-width: 560px; }
.roles th, .roles td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: start; }
.roles th.mid, .roles td.mid { text-align: center; }
.roles thead th { position: sticky; top: 0; background: var(--surface); }
.roles td.diff { background: var(--weak-bg); }
.roles .check { display: inline-flex; align-items: center; gap: .2rem; cursor: pointer; }
.roles .check input { width: 20px; height: 20px; }
.roles tfoot td { border-bottom: 0; }

/* IP cameras and sightings */
.cams { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .cams { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cam-ok { background: var(--good-bg); color: var(--good); }
.cam-no_signal { background: var(--bad-bg); color: var(--bad); }
.cam-waiting { background: var(--weak-bg); color: var(--weak); }
.cam-off { background: var(--none-bg); color: var(--muted); }
.test-pic { position: relative; }
.test-pic img { width: 100%; height: auto; display: block; border-radius: 8px; }
.face-box { position: absolute; border: 2px solid var(--good); border-radius: 4px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); }
.whole-frame { margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.whole-frame img { width: 100%; height: auto; max-height: 50vh; object-fit: contain; border-radius: 8px; background: var(--none-bg); }
.passages .item.unknown-row { box-shadow: inset 3px 0 0 var(--weak); }
[dir="rtl"] .passages .item.unknown-row { box-shadow: inset -3px 0 0 var(--weak); }
.test-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.test-steps li { display: flex; align-items: center; gap: .5rem; }
.test-steps .mark { width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: none;
  background: var(--none-bg); color: var(--muted); }
.test-steps .pass .mark { background: var(--good-bg); color: var(--good); }
.test-steps .fail .mark { background: var(--bad-bg); color: var(--bad); }
.test-steps .skip { color: var(--muted); }
.test-box { background: var(--bg, transparent); }

/* live camera pictures */
.live-box { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.live-box img { width: 100%; height: 100%; object-fit: contain; display: block; }
.live-box.off { background: var(--none-bg); color: var(--muted); }
.live-box.big { max-height: 70vh; }
.live-state { position: absolute; inset: auto 0 0 0; padding: .4rem .6rem; font-size: .8rem; color: #fff; background: rgba(0, 0, 0, .55); }
.live-state.no_signal { background: rgba(160, 30, 30, .75); }
.live-dot { position: absolute; top: .5rem; inset-inline-start: .5rem; display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem;
  border-radius: 999px; font-size: .75rem; color: #fff; background: rgba(0, 0, 0, .5); }
.live-dot .dot { width: 7px; height: 7px; border-radius: 50%; background: #e33; animation: pulse 1.2s ease-in-out infinite; }
.live-grid { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .live-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .live-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.live-card { text-align: start; cursor: pointer; font: inherit; color: inherit; }
.cam-info { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .15rem .8rem; margin: 0; font-size: .82rem; }
.cam-info dt { color: var(--muted); }
.cam-info dd { margin: 0; overflow-wrap: anywhere; }
[dir="rtl"] .cam-info dd.ltr { text-align: right; }

/* PTZ control pad */
.ptz-body { display: flex; gap: 1rem; align-items: center; justify-content: center; flex-wrap: wrap; }
.ptz-pad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); gap: 6px; }
.ptz-zoom { display: grid; grid-template-rows: repeat(2, 56px); gap: 6px; }
.ptz-btn { width: 56px; height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 1.4rem; cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none; color: inherit; }
.ptz-btn.on, .ptz-btn:active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.ptz-btn.stop { font-size: 1rem; color: var(--muted); }
.ptz .chip.save { border-style: dashed; }
.ptz input[type="range"] { width: 100%; }
/* PTZ controls on the left of the live picture (physically left, in Arabic too); below it on narrow screens */
.live-ptz { display: flex; gap: var(--gap); align-items: flex-start; }
.live-ptz-pad { flex: none; width: 260px; }
.live-ptz-video { flex: 1; min-width: 0; }
.live-ptz-pad .ptz-body { flex-direction: column; gap: .6rem; }
.live-ptz-pad .ptz-zoom { grid-template-rows: none; grid-template-columns: repeat(2, 56px); }
@media (max-width: 760px) {
  .live-ptz { flex-direction: column-reverse; align-items: stretch; }
  .live-ptz-pad { width: auto; }
}
.live-ptz-pad .chips { flex-wrap: wrap; overflow: visible; }

/* the big live view: controls on the left, the picture, details on the right (physically, in Arabic too) */
.live-main { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
.live-main.with-pad { grid-template-columns: 260px minmax(0, 1fr) 300px; }
.live-video { min-width: 0; }
.live-pad .ptz-body { flex-direction: column; gap: .6rem; }
.live-pad .ptz-zoom { grid-template-rows: none; grid-template-columns: repeat(2, 56px); }
.live-pad .chips { flex-wrap: wrap; overflow: visible; }
@media (max-width: 1100px) {
  .live-main, .live-main.with-pad { grid-template-columns: minmax(0, 1fr); }
  .live-video { order: -1; }
}

/* side bar sections */
@media (min-width: 900px) { .sidenav { overflow-y: auto; scrollbar-width: thin; } }
.nav-head { display: flex; align-items: center; gap: .4rem; margin-top: .7rem; padding: .3rem .7rem; border: 0; background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: .74rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; text-align: start; width: 100%; }
.nav-head:hover { color: var(--text); }
.nav-head .chev { transition: transform .15s ease; }
.nav-head.closed .chev { transform: rotate(-90deg); }
[dir="rtl"] .nav-head.closed .chev { transform: rotate(90deg); }
.more-head { color: var(--muted); font-size: .8rem; font-weight: 700; padding: 0 .3rem; }

/* an admin using face-id as someone else */
.switch-banner { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; padding: .6rem .9rem; margin-bottom: var(--gap);
  border-radius: 12px; background: var(--weak-bg); color: var(--weak); border: 1px solid var(--weak); font-weight: 600; }
.switch-banner .btn { background: var(--surface); }

/* person cards: name link, photo opens large, quick actions */
.card.person { position: relative; }
.card.person a.name { color: var(--text); font-weight: 700; text-decoration: none; }
.card.person a.name:hover { color: var(--accent); text-decoration: underline; }
.thumb-btn { padding: 0; border: 0; background: none; cursor: zoom-in; flex: none; border-radius: 10px; }
.quick-btn { flex: none; align-self: flex-start; font-size: 1.3rem; line-height: 1; }
.quick-menu { position: absolute; top: 2.6rem; inset-inline-end: .5rem; z-index: 30; min-width: 220px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); padding: .3rem; }
.quick-item { text-align: start; padding: .55rem .7rem; border: 0; background: none; border-radius: 8px; cursor: pointer; font: inherit; color: var(--text); }
.quick-item:hover { background: var(--surface-2); }
.quick-item.danger { color: var(--bad); }
.quick-box { max-width: 480px; }
.viewer .id-full { max-height: 72vh; object-fit: contain; background: var(--none-bg); }
.card.person.menu-open { z-index: 40; }

/* People list: sort and date range */
.sort-row { gap: .5rem .8rem; }
.field.inline { flex-direction: row; align-items: center; gap: .4rem; }

/* password boxes: the show / hide eye inside the box (the boxes are left-to-right, so it sits on the right) */
.pw-wrap { position: relative; display: block; }
.pw-wrap > .input { padding-right: 2.6rem; }
.pw-eye { position: absolute; top: 50%; right: .35rem; transform: translateY(-50%); width: 2rem; height: 2rem; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.pw-eye:hover, .pw-eye[aria-pressed="true"] { color: var(--text); background: var(--surface-2); }
