/* DOREK — original visual identity: deep teal + saffron call accent on warm paper. */
:root {
  --paper: #f6f3ee;
  --card: #ffffff;
  --ink: #142423;
  --muted: #5e6b69;
  --line: #e3ded5;
  --brand: #0e5e5b;
  --brand-ink: #ffffff;
  --brand-soft: #dcebe9;
  --call: #e9a23b;
  --call-ink: #1c1406;
  --call-soft: #fbebd2;
  --ok: #2f7a4f;
  --ok-soft: #ddefe3;
  --bad: #b23a2e;
  --bad-soft: #f6deda;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 36, 35, 0.06), 0 10px 28px rgba(20, 36, 35, 0.07);
  --font: 'SF Arabic', 'Segoe UI', 'Noto Sans Arabic', Tahoma, system-ui, -apple-system, sans-serif;
  --num: ui-rounded, 'SF Pro Rounded', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1716;
    --card: #17221f;
    --ink: #eef3f1;
    --muted: #9fb0ad;
    --line: #26332f;
    --brand: #39a39b;
    --brand-ink: #071413;
    --brand-soft: #173733;
    --call-soft: #3a2a10;
    --ok: #63c08a;
    --ok-soft: #173325;
    --bad: #f08a7e;
    --bad-soft: #3a1c18;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
p { margin: 0 0 0.5rem; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--brand); text-decoration: none; }
.logo-mark {
  width: 22px; height: 22px; border-radius: 50%;
  border: 4px solid var(--brand); position: relative;
}
.logo-mark::after {
  content: ''; position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: var(--call); top: -6px; inset-inline-end: -6px;
}
.bar-actions { display: flex; gap: 8px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 14px;
  font: inherit; font-weight: 700; padding: 12px 18px; cursor: pointer;
  background: var(--card); color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; transition: transform 0.06s ease, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-call { background: var(--call); color: var(--call-ink); }
.btn-dark { background: var(--ink); color: var(--paper); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-quiet { background: transparent; color: var(--muted); border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; min-height: 38px; font-size: 0.92rem; border-radius: 12px; }
.btn-lg { padding: 14px 22px; font-size: 1.1rem; }
.link { background: none; border: 0; color: var(--brand); font: inherit; font-size: 0.85rem; cursor: pointer; padding: 4px 0; }

/* ---------- customer ticket ---------- */
.page-ticket .wrap { max-width: 480px; margin: 0 auto; padding: 0 16px 32px; }
.venue { text-align: center; color: var(--muted); margin: 4px 0 14px; }
.venue strong { color: var(--ink); }
.ticket {
  background: var(--card); border-radius: 26px; box-shadow: var(--shadow);
  padding: 22px 20px 20px; text-align: center; position: relative; overflow: hidden;
}
.ticket::before {
  /* ticket notches */
  content: ''; position: absolute; top: 50%; inset-inline: -12px; height: 24px; margin-top: -12px;
  background: radial-gradient(circle at 12px 12px, var(--paper) 11px, transparent 12px) left / 50% 100% no-repeat,
              radial-gradient(circle at calc(100% - 12px) 12px, var(--paper) 11px, transparent 12px) right / 50% 100% no-repeat;
  pointer-events: none;
}
.ticket .label { color: var(--muted); font-weight: 600; margin: 0; }
.ticket .num {
  font-family: var(--num); font-weight: 800; font-size: clamp(4.5rem, 26vw, 7rem);
  line-height: 1; margin: 6px 0 12px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.pill {
  display: inline-block; padding: 6px 14px; border-radius: 999px; font-weight: 700;
  background: var(--brand-soft); color: var(--brand); margin: 0 0 10px;
}
.st-called .pill { background: var(--call); color: var(--call-ink); }
.st-serving .pill, .st-completed .pill { background: var(--ok-soft); color: var(--ok); }
.st-cancelled .pill, .st-no_show .pill, .st-expired .pill { background: var(--bad-soft); color: var(--bad); }
.ref { color: var(--muted); font-size: 0.92rem; }
.meta { display: flex; gap: 10px; justify-content: center; margin: 12px 0 4px; flex-wrap: wrap; }
.meta-item { background: var(--paper); border-radius: 14px; padding: 8px 14px; display: grid; }
.meta-label { font-size: 0.8rem; color: var(--muted); }
.meta-value { font-weight: 800; font-size: 1.05rem; }
.hint { color: var(--muted); margin: 10px 0 0; }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-top: 14px; }
.panel h2 { font-size: 1.1rem; }
.caps { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.cap { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 12px; background: var(--paper); font-size: 0.95rem; }
.cap-state { font-weight: 700; }
.cap-on .cap-state { color: var(--ok); }
.cap-denied .cap-state, .cap-error .cap-state { color: var(--bad); }
.cap-needs_homescreen .cap-state, .cap-off .cap-state, .cap-unsupported .cap-state { color: var(--muted); }
.note { font-size: 0.9rem; color: var(--muted); margin-top: 10px; }
.note.warn { color: var(--bad); }
.howto { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--brand-soft); font-size: 0.92rem; }
.howto p { margin: 6px 0 0; }
.ended { text-align: center; }
.conn { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 18px; font-size: 0.85rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot-live { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot-offline { background: var(--bad); }
.skeleton { height: 280px; border-radius: 26px; background: var(--card); opacity: 0.6; margin-top: 30px; }

/* called takeover */
.takeover {
  position: fixed; inset: 0; z-index: 50; background: var(--call); color: var(--call-ink);
  display: grid; place-items: center; padding: 24px;
  animation: pulse 1.4s ease-in-out infinite;
}
.takeover-inner { width: min(440px, 100%); text-align: center; }
.takeover-title { font-size: 1.6rem; font-weight: 800; }
.takeover-num { font-family: var(--num); font-size: clamp(6rem, 38vw, 10rem); font-weight: 900; line-height: 1; margin: 8px 0 14px; }
.takeover-place { font-size: 1.15rem; font-weight: 600; margin-bottom: 24px; }
.badge { display: inline-block; background: var(--call-ink); color: var(--call); padding: 4px 12px; border-radius: 999px; font-weight: 800; }
@keyframes pulse { 0%, 100% { background: var(--call); } 50% { background: #f3bf6e; } }
@media (prefers-reduced-motion: reduce) { .takeover { animation: none; } }

/* ---------- staff console ---------- */
.page-staff .wrap { max-width: 1400px; margin: 0 auto; padding: 0 16px 40px; }
.login { max-width: 380px; margin: 40px auto; display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 0.92rem; }
input, select {
  font: inherit; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); min-height: 44px;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.create { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.create input { width: 200px; }
.next { display: flex; gap: 8px; margin-inline-start: auto; }
.board { display: grid; gap: 14px; }
.board-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.board-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .board-3, .board-4 { grid-template-columns: 1fr; } }
.col { background: rgba(127, 127, 127, 0.06); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col h3 { font-size: 0.95rem; display: flex; justify-content: space-between; padding: 4px 6px 8px; }
.count { background: var(--card); border-radius: 999px; padding: 0 10px; font-size: 0.85rem; }
.col-body { display: grid; gap: 10px; }
.tcard { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 12px; border-inline-start: 5px solid var(--line); }
.tcard.st-waiting { border-inline-start-color: var(--brand); }
.tcard.st-called { border-inline-start-color: var(--call); }
.tcard.st-serving { border-inline-start-color: var(--ok); }
.tcard header { display: flex; align-items: center; gap: 8px; }
.tnum { font-family: var(--num); font-weight: 800; font-size: 2rem; line-height: 1; }
.tage { margin-inline-start: auto; color: var(--muted); font-size: 0.85rem; }
.tref { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.chip { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--paper); color: var(--muted); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--call-soft); color: #8a5a10; }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.tactions { display: flex; flex-wrap: wrap; gap: 6px; }
.tcard footer { display: flex; gap: 14px; margin-top: 8px; }

.modal { position: fixed; inset: 0; z-index: 40; background: rgba(10, 20, 19, 0.55); display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--card); border-radius: 22px; padding: 22px; width: min(520px, 100%); max-height: 90vh; overflow: auto; display: grid; gap: 12px; justify-items: center; text-align: center; }
.qr { width: 280px; height: 280px; background: #fff; border-radius: 12px; }
.qr-num { font-family: var(--num); font-weight: 900; font-size: 3rem; line-height: 1; margin: 0; }
.qr-hint { color: var(--muted); }
.row { display: flex; gap: 8px; }
.history { width: 100%; border-collapse: collapse; font-size: 0.85rem; text-align: start; }
.history td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: start; }
.toast { position: fixed; bottom: 20px; inset-inline: 0; margin: auto; width: fit-content; max-width: 90vw; z-index: 60; padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--paper); font-weight: 700; }
.toast-error { background: var(--bad); color: #fff; }

/* ---------- waiting-room display ---------- */
.page-display { background: #0b1312; color: #eef3f1; min-height: 100vh; }
.page-display .wrap { padding: 3vh 4vw; }
.d-head { display: flex; align-items: baseline; gap: 2vw; margin-bottom: 3vh; }
.d-head h1 { font-size: 4vh; margin: 0; }
.d-head p { color: #9fb0ad; font-size: 2.6vh; margin: 0; }
.d-called h2, .d-prep h2 { color: #e9a23b; font-size: 3vh; }
.d-called ol { list-style: none; padding: 0; margin: 0 0 4vh; display: grid; grid-template-columns: repeat(auto-fill, minmax(28vw, 1fr)); gap: 2vh 2vw; }
.d-called li { background: #17221f; border-radius: 2vh; padding: 2vh 2vw; display: flex; justify-content: space-between; align-items: center; }
.d-called li.latest { background: #e9a23b; color: #1c1406; }
.d-num { font-family: var(--num); font-weight: 900; font-size: 9vh; line-height: 1; }
.d-place { font-size: 3vh; font-weight: 700; }
.d-prep p { font-family: var(--num); font-size: 5vh; font-weight: 800; color: #9fb0ad; word-spacing: 0.4em; }
.d-sound { position: fixed; bottom: 2vh; inset-inline-end: 2vw; color: #eef3f1; }
.d-error { font-size: 4vh; text-align: center; margin-top: 30vh; }

/* ---------- landing ---------- */

/* experimental lock-screen card toggle */
.lab { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.lab .caps { margin-bottom: 6px; }
.qr-status { font-weight: 700; color: var(--muted); }
.qr-status-ok { color: var(--ok); }
.summary { font-weight: 700; margin: 0 0 8px; }
.summary.ok { color: var(--ok); }
.summary.warn { color: var(--bad); }
.details { margin-top: 10px; }

/* ---------- counter code page (take a number) ---------- */
.counter { padding-top: 26px; }
.counter-title { font-family: var(--num); font-size: clamp(2rem, 9vw, 2.8rem); margin: 6px 0 4px; }
.btn-xl { padding: 20px 28px; font-size: 1.45rem; border-radius: 22px; margin-top: 18px; }

/* ---------- staff: pager base station ---------- */
.pager { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 16px; }
.pager-row { display: flex; gap: 10px; align-items: stretch; }
.pager-row input { flex: 1; min-width: 0; font-family: var(--num); font-weight: 800; font-size: 1.7rem; text-align: center; min-height: 56px; }
.tiles-title { margin: 12px 0 6px; font-size: 0.9rem; }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; min-height: 40px; align-items: center; }
.tile {
  font-family: var(--num); font-weight: 800; font-size: 1.6rem; min-width: 88px; min-height: 64px; padding: 0 14px;
  border-radius: 16px; border: 2px solid var(--brand); background: var(--brand-soft); color: var(--brand); cursor: pointer;
}
.tile:active { transform: scale(0.97); }
.tile:disabled { opacity: 0.5; }
.panel.demo { border: 1px dashed var(--call); }

/* ---------- privacy / support pages ---------- */
.legal { max-width: 720px; margin: 0 auto; padding: 8px 16px 48px; line-height: 1.75; }
.legal h1 { font-size: 1.6rem; margin-top: 18px; }
.legal h2 { font-size: 1.15rem; margin-top: 22px; }
.legal hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }

/* ---------- owner console (/admin) ---------- */
.page-admin .wrap.adm { max-width: 920px; margin: 0 auto; padding: 20px 16px 64px; display: grid; gap: 18px; }
.adm h1 { font-size: 1.7rem; margin: 0; }
.adm-org, .adm-new { display: grid; gap: 14px; }
.adm-org-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.adm-org-head h2 { margin: 0; font-size: 1.35rem; }
.adm-branch { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 10px; }
.adm-branch h3 { margin: 0; font-size: 1.05rem; }
.adm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.adm-svc { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
.adm-sub { font-size: 0.86rem; }
.adm-off { opacity: 0.6; }
.adm-add > summary { cursor: pointer; color: var(--brand); font-weight: 700; padding: 4px 0; width: fit-content; }
.adm-add[open] > summary { margin-bottom: 10px; }
.adm-form { display: grid; gap: 10px; }
.adm-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.adm-inline { grid-template-columns: 1fr auto; align-items: end; }
.adm-points { display: grid; gap: 6px; font-size: 0.95rem; }
.adm-secret .adm-cred { display: grid; gap: 6px; background: var(--paper); border: 1px dashed var(--line); border-radius: 14px; padding: 14px 18px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.adm-cred strong { font-size: 1.5rem; letter-spacing: 0.04em; }
@media (max-width: 640px) { .adm-pair, .adm-inline { grid-template-columns: 1fr; } }
