:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --ink: #14302e;
  --muted: #566b69;
  --line: #dcd8cc;
  --brand: #0f766e;
  --brand-dark: #0a5a54;
  --brand-soft: #d8efec;
  --accent: #c2410c;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --ok: #146c43;
  --ok-soft: #dff3e7;
  --warn: #8a5300;
  --warn-soft: #fdf0d5;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 48 46 / 6%), 0 8px 24px rgb(20 48 46 / 7%);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1b1a; --surface: #152726; --surface-2: #1c3231; --ink: #e8f1ef; --muted: #9db5b2;
    --line: #2b4644; --brand: #2dd4bf; --brand-dark: #5eead4; --brand-soft: #123c38;
    --accent: #fb923c; --danger: #ff8a80; --danger-soft: #3b1d1b; --ok: #6ee7a8; --ok-soft: #153a29;
    --warn: #fbbf24; --warn-soft: #3a2a0b; --shadow: 0 8px 24px rgb(0 0 0 / 35%);
  }
  .btn-primary { color: #04201d; }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.7 var(--font); }
img, svg { max-width: 100%; }
a { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; font-weight: 700; }
h1 { font-size: clamp(2rem, 5.5vw, 3.4rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(760px, 100% - 32px); }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 8px; }

/* header */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.35rem; color: var(--brand); text-decoration: none; }
.nav { margin-inline-start: auto; display: flex; gap: 4px; }
.nav a { padding: 8px 14px; border-radius: 999px; color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
@media (max-width: 640px) { .nav { display: none; } .bar > .btn { margin-inline-start: auto; } }

/* buttons */
.btn { white-space: nowrap; font: 600 1rem/1 var(--font); border: 1.5px solid transparent; border-radius: 12px; padding: 13px 20px; min-height: 46px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s, background .12s, border-color .12s; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.btn-quiet { background: transparent; color: var(--ink); padding: 10px 14px; min-height: 40px; font-weight: 500; }
.btn-quiet:hover { background: var(--surface-2); }
.btn-lg { padding: 16px 26px; font-size: 1.05rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 12px; min-height: 36px; font-size: .875rem; border-radius: 9px; }

/* hero */
.hero { padding: clamp(36px, 7vw, 84px) 0 clamp(28px, 5vw, 56px); background:
  radial-gradient(900px 380px at 85% -10%, var(--brand-soft), transparent 70%), var(--bg); }
[dir="ltr"] .hero { background: radial-gradient(900px 380px at 15% -10%, var(--brand-soft), transparent 70%), var(--bg); }
.hero-grid { display: grid; gap: 40px; align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.25fr .75fr; } }
.eyebrow { color: var(--brand-dark); font-weight: 600; letter-spacing: .02em; margin-bottom: .6em; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 40ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0; }
.points { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--muted); font-size: .95rem; }
.points li::before { content: "✓"; color: var(--brand); font-weight: 700; margin-inline-end: 8px; }

.ticket { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); max-width: 340px; width: 100%; justify-self: center; transform: rotate(-2deg); position: relative; }
.ticket-top { display: flex; justify-content: space-between; align-items: center; color: var(--brand); }
.ticket-chip { background: var(--warn-soft); color: var(--warn); font-size: .8rem; font-weight: 600; padding: 4px 12px; border-radius: 999px; }
.ticket-label { color: var(--muted); font-size: .85rem; margin: 18px 0 0; }
.ticket-code { font: 700 1.9rem/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; margin: 2px 0 14px; direction: ltr; text-align: start; }
.ticket-rule { border-top: 2px dashed var(--line); margin: 6px -22px 14px; }
.ticket-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--muted); }
.ticket-row strong { color: var(--ink); }

/* sections */
.section { padding: clamp(40px, 6vw, 72px) 0; }
.section.alt { background: var(--surface-2); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 3vw, 28px); box-shadow: var(--shadow); margin-top: 16px; }
.alert { background: var(--danger-soft); color: var(--danger); border: 1px solid currentColor; border-radius: 12px; padding: 12px 16px; font-weight: 500; }
.notice { background: var(--brand-soft); border-radius: 12px; padding: 12px 16px; }

/* stepper */
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 20px 0 4px; counter-reset: s; }
.steps li { flex: 1; counter-increment: s; display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; font-size: .9rem; padding-bottom: 10px; border-bottom: 3px solid var(--line); }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); font-size: .8rem; flex: none; }
.steps li[aria-current="step"] { color: var(--ink); border-color: var(--brand); }
.steps li[aria-current="step"]::before { background: var(--brand); color: #fff; }
.steps li.past { border-color: var(--brand); }
.steps li.past::before { content: "✓"; background: var(--brand-soft); color: var(--brand-dark); }
@media (max-width: 560px) { .steps li span { display: none; } .steps li { justify-content: center; } }

/* doctors */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.chip { font: 500 .95rem var(--font); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 16px; min-height: 40px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.doctors { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.doc { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.doc:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.doc-head { display: flex; gap: 14px; align-items: center; }
.avatar { width: 54px; height: 54px; border-radius: 16px; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; flex: none; direction: ltr; }
.doc h4 { margin: 0; font-size: 1.1rem; }
.doc .spec { color: var(--brand-dark); font-weight: 600; font-size: .92rem; }
.doc .meta { color: var(--muted); font-size: .9rem; margin: 0; }
.doc .btn { margin-top: auto; }
.empty { color: var(--muted); padding: 20px; text-align: center; border: 1.5px dashed var(--line); border-radius: 12px; grid-column: 1 / -1; }

.chosen { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.chosen .avatar { width: 40px; height: 40px; border-radius: 12px; font-size: .95rem; }
.field-label { font-weight: 600; margin: 18px 0 8px; }
.days { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; }
.day { flex: none; scroll-snap-align: start; min-width: 74px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px; padding: 10px 8px; cursor: pointer; font: 500 .85rem/1.3 var(--font); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.day strong { font-size: 1.25rem; line-height: 1.1; }
.day[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.day:disabled { opacity: .4; cursor: not-allowed; background: var(--surface-2); text-decoration: line-through; }
.times { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); min-height: 56px; }
.time { font: 600 1rem var(--font); direction: ltr; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 11px 6px; min-height: 46px; cursor: pointer; }
.time:hover { border-color: var(--brand); }
.time[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.times .empty, .times .loading { grid-column: 1 / -1; }
.loading { color: var(--muted); padding: 14px; }
.nav-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* forms */
.grid2 { display: grid; gap: 16px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field small { color: var(--muted); font-weight: 400; }
input:not([type="checkbox"]), select, textarea { width: 100%; font: 400 1rem var(--font); color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; min-height: 48px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 3px solid var(--brand-soft); }
input[aria-invalid="true"] { border-color: var(--danger); }
.err { color: var(--danger); font-size: .9rem; margin: 6px 0 0; font-weight: 500; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.check { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 3px; accent-color: var(--brand); flex: none; }
.summary { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; display: grid; gap: 4px; }
.summary div { display: flex; justify-content: space-between; gap: 12px; }
.summary dt, .summary span.k { color: var(--muted); }
#turnstile-box { margin-top: 16px; }

/* done */
.done { text-align: center; }
.done-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 0 auto 12px; }
.code-box { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 18px 0; }
.code { font: 700 clamp(1.7rem, 6vw, 2.3rem)/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .12em; background: var(--surface-2); padding: 14px 20px; border-radius: 14px; border: 2px dashed var(--brand); }
.done .summary { text-align: start; max-width: 460px; margin-inline: auto; margin-bottom: 14px; }
.done .nav-row { justify-content: center; }

.status { display: inline-block; font-size: .85rem; font-weight: 600; padding: 3px 12px; border-radius: 999px; }
.status.pending { background: var(--warn-soft); color: var(--warn); }
.status.confirmed { background: var(--ok-soft); color: var(--ok); }
.status.completed { background: var(--brand-soft); color: var(--brand-dark); }
.status.cancelled { background: var(--danger-soft); color: var(--danger); }
.result .btn { margin-top: 14px; }

details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 18px; margin-top: 10px; }
summary { cursor: pointer; font-weight: 600; padding: 14px 0; }
details p { color: var(--muted); }

.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; }
.emergency { background: var(--danger-soft); color: var(--danger); font-weight: 600; padding: 12px 16px; border-radius: 12px; }

/* ===== admin ===== */
.bar.flush { padding: 0; }
.end-group { margin-inline-start: auto; display: flex; gap: 6px; }
.h-md { font-size: 1.4rem; }
.block { width: 100%; }
.mt16 { margin-top: 16px; }
.mt12 { margin-top: 12px; }
.row { display: flex; }
.gap8 { gap: 8px; }
fieldset.plain { border: 0; padding: 0; margin: 16px 0 0; }
.admin-wrap { width: min(1180px, 100% - 24px); margin: 24px auto 60px; }
.login-card { max-width: 420px; margin: 12vh auto; }
.tabs { display: flex; gap: 6px; margin: 18px 0; border-bottom: 1px solid var(--line); }
.tab { font: 600 1rem var(--font); background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 18px; cursor: pointer; color: var(--muted); }
.tab[aria-selected="true"] { color: var(--brand-dark); border-color: var(--brand); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.stat b { display: block; font-size: 2rem; line-height: 1.1; color: var(--brand-dark); }
.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; margin-bottom: 14px; }
.filters label { font-size: .85rem; font-weight: 600; display: block; margin-bottom: 4px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 760px) {
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  tr { display: block; border-bottom: 8px solid var(--bg); padding: 6px 0; }
  td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 6px 14px; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; flex: none; }
}
dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(640px, 100% - 24px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 30%); }
dialog::backdrop { background: rgb(8 20 19 / 55%); }
dialog form { padding: 22px; max-height: 88vh; overflow-y: auto; }
.days-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.days-pick label { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 500; margin: 0; }
.days-pick input { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }
.toast { position: fixed; inset-inline: 0; bottom: 20px; margin-inline: auto; width: fit-content; max-width: calc(100% - 32px); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow); z-index: 50; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .ticket { transform: none; }
}
@media print { .site-header, .site-footer, .hero { display: none; } }

#lookup-form .btn { margin-top: 16px; }
#lookup-form .err { margin-top: 12px; }
