/* QRar · قرار. Arabic, right-to-left, phone first. Logical properties
   (inline-start/end) keep the layout correct in RTL. */

@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 400; font-display: swap;
  src: url("/static/fonts/plex-arabic-arabic-400.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 500; font-display: swap;
  src: url("/static/fonts/plex-arabic-arabic-500.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 700; font-display: swap;
  src: url("/static/fonts/plex-arabic-arabic-700.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 400; font-display: swap;
  src: url("/static/fonts/plex-arabic-latin-400.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 500; font-display: swap;
  src: url("/static/fonts/plex-arabic-latin-500.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 700; font-display: swap;
  src: url("/static/fonts/plex-arabic-latin-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --ink: #1f2a44;
  --ink-soft: #3a4766;
  --gold: #b08d3c;
  --gold-soft: #f3ecdb;
  --paper: #f6f4ef;
  --card: #ffffff;
  --line: #e3dfd5;
  --muted: #6b7280;
  --ok: #2f7a4f;
  --ok-soft: #e5f2ea;
  --blue: #2c5aa0;
  --blue-soft: #e4ecf7;
  --warn: #9a6512;
  --err: #a23b3b;
  --err-soft: #f8e6e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 68, .06), 0 8px 24px rgba(31, 42, 68, .06);
  --font: "IBM Plex Sans Arabic", Tahoma, "Segoe UI", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--paper); color: var(--ink); font: 16px/1.7 var(--font); min-height: 100vh; }
h1, h2, h3 { font-weight: 700; margin: 0 0 .4em; line-height: 1.4; }
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
a { color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* Latin fragments inside Arabic text: references, emails, usernames, codes. */
.ltr, .mono, .ref { direction: ltr; unicode-bidi: isolate; }
.mono, .ref { font-family: var(--mono); font-size: .86em; }
.ref { letter-spacing: .06em; font-weight: 600; display: inline-block; }
input.ltr, textarea.ltr { text-align: left; }

/* top bar */
.topbar { background: var(--ink); color: #fff; border-bottom: 3px solid var(--gold); min-height: 61px; }
.topbar .inner { max-width: 1160px; margin: auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
/* The QRar mark. The element keeps a letter as its text for anything that
   reads the page without images; on screen the logo covers it. */
.seal, .hero-seal { background: url("/static/logo.svg") center / cover no-repeat; color: transparent; font-size: 0; line-height: 0; overflow: hidden; }
.seal { width: 36px; height: 36px; border-radius: 8px; flex: none; }
.brand b { font-size: 17px; font-weight: 700; display: block; line-height: 1.3; }
.brand span { display: block; font-size: 12px; color: #c9cfdc; line-height: 1.3; }
.topbar .spacer { flex: 1; }
.who { font-size: 13.5px; color: #dfe3ec; text-align: end; line-height: 1.4; }
.who b { display: block; }
.who .small { color: #aab3c5; font-size: 12px; }
.topbar nav { display: flex; gap: 4px; flex-basis: 100%; overflow-x: auto; }
.topbar nav a { color: #dfe3ec; text-decoration: none; font-size: 14.5px; padding: 7px 14px; border-radius: 8px; white-space: nowrap; flex: 1; text-align: center; background: rgba(255,255,255,.06); }
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.1); }
.topbar nav a.active { color: var(--ink); background: #fff; font-weight: 500; }
@media (min-width: 760px) {
  .topbar .inner { padding: 10px 20px; }
  .topbar nav { flex-basis: auto; order: 1; }
  .topbar nav a { flex: none; background: none; }
  .topbar nav a.active { color: #fff; background: rgba(255,255,255,.16); }
  .topbar .spacer { order: 2; }
  .who { order: 3; }
  .topbar #logout { order: 4; }
}

.wrap { max-width: 1160px; margin: auto; padding: 18px 14px 70px; }
.mid { max-width: 640px; margin: auto; padding: 18px 14px 70px; }
.narrow { max-width: 440px; margin: auto; padding: 28px 14px 60px; }
@media (min-width: 760px) { .wrap, .mid { padding: 28px 20px 70px; } .narrow { padding-top: 56px; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
@media (min-width: 760px) { .card { padding: 22px; } }
.card + .card { margin-top: 16px; }
.eyebrow { font-size: 13px; color: var(--gold); font-weight: 500; margin-bottom: 4px; }

/* forms: 16px inputs stop phones from zooming in on focus */
label { display: block; font-size: 14px; color: var(--ink-soft); margin: 12px 0 5px; }
input, textarea, select {
  width: 100%; padding: 11px 12px; font: inherit; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 46px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: transparent; }
input[type="file"] { padding: 9px; background: var(--paper); cursor: pointer; font-size: 14px; }
input[type="date"] { direction: ltr; text-align: right; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  padding: 10px 18px; min-height: 46px; border-radius: 10px; border: 1px solid var(--ink);
  background: var(--ink); color: #fff; font: 500 15.5px var(--font); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--ink-soft); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--gold-soft); }
.btn.light { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); padding: 4px 12px; min-height: 36px; font-size: 13.5px; }
.btn.small { padding: 4px 12px; min-height: 36px; font-size: 13.5px; }
.btn.danger { color: var(--err); border-color: #e8caca; background: transparent; }
.btn.danger:hover { background: var(--err-soft); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

.msg { padding: 10px 14px; border-radius: 10px; font-size: 14.5px; margin-top: 12px; }
.msg.err { background: var(--err-soft); color: var(--err); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 11px; border-radius: 999px; font-size: 13.5px; font-weight: 500; white-space: nowrap; background: var(--gold-soft); color: var(--warn); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.gold { background: #f8f0d9; color: var(--warn); }
.chip.plain { background: #ecebe6; color: var(--ink-soft); }
.chip.grey { background: #eef0f3; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* scanner: square on phones, landscape on wider screens */
.scanner { position: relative; border-radius: var(--radius); overflow: hidden; background: #121826; aspect-ratio: 1 / 1; }
@media (min-width: 760px) { .scanner { aspect-ratio: 4 / 3; } }
.scanner #reader, .scanner #reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scanner #reader { border: 0 !important; }
.scanner .frame { position: absolute; inset: 16%; border-radius: 16px; pointer-events: none; box-shadow: 0 0 0 9999px rgba(10, 14, 24, .35); border: 2px solid rgba(255,255,255,.8); }
.scanner .frame::after { content: ""; position: absolute; left: 6%; right: 6%; height: 2px; top: 50%; background: var(--gold); box-shadow: 0 0 12px var(--gold); animation: sweep 2.2s ease-in-out infinite; }
@keyframes sweep { 0%,100% { top: 12%; } 50% { top: 88%; } }
.scanner .overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #e6e9f0; padding: 20px; background: #121826; }
.scanner .overlay .btn { background: var(--gold); border-color: var(--gold); }
.scan-status { margin-top: 10px; font-size: 14px; color: var(--muted); min-height: 22px; text-align: center; }
details.manual { margin-top: 8px; font-size: 14px; }
details.manual summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
details.manual .row { margin-top: 6px; flex-wrap: nowrap; }

/* result panels after a scan */
.result { text-align: center; padding: 30px 18px; }
.result .icon { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; font-size: 32px; font-weight: 700; }
.result.ok .icon { background: var(--ok-soft); color: var(--ok); }
.result.err .icon { background: var(--err-soft); color: var(--err); }
.result.err h2 { color: var(--err); }
.result .ref { font-size: 22px; }

.proc-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.proc-head .ref { font-size: 24px; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 14.5px; margin: 12px 0 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

/* clerk status cards, one tinted block per registry */
.section-title { font-size: 14.5px; font-weight: 500; color: var(--ink-soft); margin: 22px 0 10px; }
.registry { border-radius: 14px; padding: 12px; margin-top: 12px; border: 1px solid transparent; }
.registry h3 { margin: 2px 4px 10px; }
.registry.blue { background: #e8f1fb; border-color: #cfe0f4; }
.registry.gold { background: #f8f0d9; border-color: #ecdcae; }
.registry.plain { background: #f1f1ee; border-color: #e2e1db; }
.options { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 760px) { .registry { padding: 14px 16px 16px; } .options { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; } }
.option { position: relative; margin: 0; display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 1.5px solid rgba(31,42,68,.12); border-radius: 12px; padding: 13px 14px; cursor: pointer; font-size: 15.5px; color: var(--ink); min-height: 56px; line-height: 1.6; }
.option:hover { border-color: var(--ink-soft); }
.option:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink) inset; }
.option input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; min-height: 0; }
.option .num { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 13px; display: grid; place-items: center; margin-top: 2px; }
.option .text { flex: 1; }
.option .opt-date { display: block; margin-top: 8px; max-width: 220px; }
/* On phones the Apply bar stays in reach at the bottom of the screen. */
.apply-bar { position: sticky; bottom: 0; background: var(--card); margin: 16px -18px -18px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: nowrap; z-index: 2; }
.apply-bar .btn { flex: 1; }
.apply-bar #u-apply { flex: 2; }
@media (min-width: 760px) { .apply-bar { position: static; margin: 18px 0 0; padding: 0; border: 0; } .apply-bar .btn, .apply-bar #u-apply { flex: none; } }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; margin-bottom: 16px; }
.filters label { margin-top: 0; }
.filters .btn { grid-column: 1 / -1; }
@media (min-width: 760px) { .filters { grid-template-columns: repeat(4, minmax(140px, 190px)) auto; } .filters .btn { grid-column: auto; } }

/* tables become stacked cards on phones (cells carry data-label) */
table.list { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.list th { text-align: start; font-weight: 500; color: var(--muted); font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-scroll { overflow-x: auto; }
@media (max-width: 759px) {
  table.list.stack tr.head { display: none; }
  table.list.stack, table.list.stack tbody, table.list.stack tr, table.list.stack td { display: block; width: 100%; }
  table.list.stack tr { border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; margin-bottom: 10px; background: #fff; }
  table.list.stack td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 14px; align-items: baseline; text-align: end; }
  table.list.stack td::before { content: attr(data-label); color: var(--muted); font-size: 13px; flex: none; text-align: start; }
  table.list.stack td[data-label=""]::before { display: none; }
  table.list.stack td[data-label=""] { justify-content: flex-end; }
}

.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.empty .big { font-size: 19px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); max-width: 92vw; width: max-content;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow); text-align: center;
  opacity: 0; transition: .25s; pointer-events: none; z-index: 20; border-inline-start: 4px solid var(--gold);
}
.toast.err { border-inline-start-color: #e06666; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* tabs (admin, db viewer) */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--gold); font-weight: 500; }
.tabs .count { font-size: 12.5px; background: #eef0f3; border-radius: 999px; padding: 1px 8px; margin-inline-start: 6px; }

.grid-side { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 900px) { .grid-side { grid-template-columns: 340px 1fr; gap: 20px; } }

.creds { background: var(--ok-soft); border-radius: 10px; padding: 12px 14px; margin-top: 14px; font-size: 14.5px; }
.creds code { font-family: var(--mono); background: #fff; padding: 1px 6px; border-radius: 4px; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.secret { font-family: var(--mono); font-size: 13.5px; direction: ltr; unicode-bidi: isolate; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; width: min(420px, 92vw); color: var(--ink); font-family: var(--font); }
dialog::backdrop { background: rgba(20, 26, 44, .5); }
#verify-code { font-family: var(--mono); font-size: 22px; letter-spacing: .3em; text-align: center; direction: ltr; }

/* auth + client pages */
.hero-seal { width: 64px; height: 64px; border-radius: 15px; margin: 0 auto 12px; }
.wordmark { font-size: 15px; color: var(--muted); }
.wordmark b { color: var(--gold); }
.status-note { background: var(--paper); border-inline-start: 3px solid var(--gold); border-radius: 8px; padding: 12px 14px; margin: 18px 0 6px; font-size: 16.5px; }

/* db viewer (demo tool, raw rows) */
.dbt td, .dbt th { font-size: 12.5px; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; text-align: start; }
.dbt tr.flash td { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: #ffe9a8; } to { background: transparent; } }
.dbt .null { color: #b6bcc7; }

/* outbox (demo tool) */
.mail-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 820px) { .mail-layout { grid-template-columns: 320px 1fr; } }
.mail-list { padding: 0; overflow: hidden; }
.mail-item { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mail-item:hover { background: var(--paper); }
.mail-item.sel { background: var(--gold-soft); }
.mail-item .to { font-size: 13px; color: var(--muted); }
.mail-item .subj { font-weight: 500; }
.mail-view iframe { width: 100%; height: 560px; border: 0; }

/* html5-qrcode injects its own English "Scanner paused" banner; ours replaces it. */
.scanner #reader > div { display: none !important; }

/* process history */
.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px; padding-inline-start: 22px; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 4px; top: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.timeline li::after { content: ""; position: absolute; inset-inline-start: 8px; top: 20px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }

/* clerk: connection state and scans waiting to be sent */
.pending { border: 1px solid #ecdcae; background: #fbf5e3; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 14.5px; }
.pending.offline { border-color: #e8caca; background: var(--err-soft); }
.pending b { display: block; }
.pending ul { margin: 8px 0 0; padding-inline-start: 18px; }
.option.plainopt { border-style: dashed; }

/* paged lists */
.pager { justify-content: center; margin-top: 14px; }
.search { margin-bottom: 12px; }

/* admin: choosing people to email their sign-in details */
.send-bar { margin-bottom: 10px; gap: 8px 12px; }
.pick { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; cursor: pointer; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--ink); cursor: pointer; }
table.list td .ltr { white-space: nowrap; }
.topbar .seal { box-shadow: 0 0 0 1px rgba(255, 255, 255, .22); }
