/* كشفة — هوية بصرية: أخضر النيل + أصفر الكهرمان للتنبيه، حروف ريدكس للعناوين وبلكس عربي للنص */
:root {
  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #e8eeeb;
  --ink: #12302b;
  --ink-2: #4d625d;
  --ink-3: #62736d;
  --line: #d6e0dc;
  --brand: #0d6b5a;
  --brand-ink: #ffffff;
  --brand-soft: #dcefe9;
  --urgent: #c8432b;
  --urgent-soft: #fbe6e1;
  --amber: #b97a12;
  --amber-soft: #fbf0d9;
  --ok: #1f7a43;
  --ok-soft: #def2e5;
  --bubble-me: #0d6b5a;
  --bubble-me-ink: #ffffff;
  --bubble-them: #ffffff;
  --shadow: 0 1px 2px rgba(18, 48, 43, .06), 0 6px 18px rgba(18, 48, 43, .06);
  --f-display: "Readex Pro", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --f-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --r: 14px;
  --r-sm: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1614; --surface: #15211e; --surface-2: #1d2b28; --ink: #e5efec; --ink-2: #a9bbb6; --ink-3: #7f938e;
    --line: #283a36; --brand: #3fb79d; --brand-ink: #062621; --brand-soft: #173a33; --urgent: #f07a62; --urgent-soft: #3a1f1a;
    --amber: #e5ad4c; --amber-soft: #352a15; --ok: #5cc98a; --ok-soft: #173326; --bubble-me: #1f6f5f; --bubble-me-ink: #f2fbf8;
    --bubble-them: #1d2b28; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1614; --surface: #15211e; --surface-2: #1d2b28; --ink: #e5efec; --ink-2: #a9bbb6; --ink-3: #7f938e;
  --line: #283a36; --brand: #3fb79d; --brand-ink: #062621; --brand-soft: #173a33; --urgent: #f07a62; --urgent-soft: #3a1f1a;
  --amber: #e5ad4c; --amber-soft: #352a15; --ok: #5cc98a; --ok-soft: #173326; --bubble-me: #1f6f5f; --bubble-me-ink: #f2fbf8;
  --bubble-them: #1d2b28; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
a { color: var(--brand); }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; line-height: 1.3; margin: 0; text-wrap: balance; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- الهيكل ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }
.shell { width: 100%; max-width: 560px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
.page {
  flex: 1; display: flex; flex-direction: column; gap: 18px;
  padding-block: 16px 104px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.page.no-nav { padding-bottom: 32px; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--bg);
  display: flex; align-items: center; gap: 10px; min-height: 58px;
  padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid transparent;
}
.topbar.lined { border-bottom-color: var(--line); background: var(--surface); }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title h2 { font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title small { display: block; color: var(--ink-2); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn {
  width: 44px; height: 44px; flex: none; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center;
  cursor: pointer; color: var(--ink);
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn svg { width: 24px; height: 24px; }

.bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px));
}
.bottomnav .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.bottomnav button {
  border: 0; background: none; padding: 8px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .78rem; color: var(--ink-3); cursor: pointer; position: relative;
}
.bottomnav button svg { width: 24px; height: 24px; }
.bottomnav button.on { color: var(--brand); font-weight: 600; }
.bottomnav .dot { position: absolute; top: 6px; inset-inline-start: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--urgent); color: #fff; font-size: .7rem; display: grid; place-items: center; padding: 0 5px; font-weight: 700; }

/* ---------- عناصر عامة ---------- */
.card { background: var(--surface); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: .86rem; }
.small { font-size: .86rem; }
.center { text-align: center; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sec-h h3 { font-size: 1rem; }
.sec-h .faint { white-space: nowrap; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px;
  border-radius: 14px; border: 0; background: var(--brand); color: var(--brand-ink); font-family: var(--f-display); font-weight: 600;
  font-size: 1.02rem; cursor: pointer; text-decoration: none; transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.06); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.line { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--brand); }
.btn.danger { background: var(--urgent); color: #fff; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: .92rem; border-radius: 11px; }
.btn.xs { min-height: 34px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }
.btn svg { width: 20px; height: 20px; }
.linkbtn { background: none; border: 0; color: var(--brand); font-weight: 600; cursor: pointer; padding: 6px 2px; font-size: .95rem; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.wait { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--urgent-soft); color: var(--urgent); }
.pill.neutral { background: var(--surface-2); color: var(--ink-2); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.offline { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); display: inline-block; }

/* ---------- النماذج ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: .92rem; }
.field .hint { font-size: .82rem; color: var(--ink-3); }
.input, select.input, textarea.input {
  width: 100%; min-height: 52px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); padding: 12px 14px;
  font-size: 1rem; outline: none; transition: border-color .15s;
}
textarea.input { min-height: 110px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--brand); }
.input[dir="ltr"] { text-align: right; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: .95rem; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 99px; padding: 8px 14px; cursor: pointer; font-size: .92rem;
  min-height: 42px;
}
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; min-height: 44px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.err { background: var(--urgent-soft); color: var(--urgent); border-radius: 10px; padding: 10px 12px; font-size: .92rem; }
.note { background: var(--amber-soft); color: var(--ink); border-radius: 12px; padding: 12px 14px; font-size: .92rem; }
.note.ok { background: var(--ok-soft); }
.note.brand { background: var(--brand-soft); }

/* ---------- الدخول ---------- */
.auth-hero { padding: 28px 4px 8px; display: flex; flex-direction: column; gap: 10px; }
.brandmark { display: flex; align-items: center; gap: 10px; }
.brandmark .logo { width: 44px; height: 44px; border-radius: 13px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; }
.brandmark .logo svg { width: 28px; height: 28px; }
.brandmark b { font-family: var(--f-display); font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
.auth-hero h1 { font-size: 1.9rem; margin-top: 12px; }
.promises { display: grid; gap: 10px; margin-top: 4px; }
.promise { display: flex; gap: 12px; align-items: flex-start; }
.promise .ic { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.promise .ic svg { width: 20px; height: 20px; }
.promise p { font-size: .93rem; color: var(--ink-2); }
.promise b { color: var(--ink); display: block; font-size: .97rem; }

/* ---------- الرئيسية ---------- */
.hello { display: flex; align-items: center; gap: 12px; }
.hello h1 { font-size: 1.35rem; }
.wallet-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 12px; font-weight: 600; cursor: pointer; font-size: .9rem; white-space: nowrap; }
.wallet-chip svg { width: 18px; height: 18px; color: var(--brand); }
.urgent-card {
  border-radius: 20px; padding: 20px; background: var(--urgent); color: #fff; display: flex; flex-direction: column; gap: 14px;
  position: relative; overflow: hidden;
}
.urgent-card::after {
  content: ""; position: absolute; inset-inline-end: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  border: 22px solid rgba(255,255,255,.1);
}
.urgent-card h2 { font-size: 1.35rem; color: #fff; }
.urgent-card p { opacity: .92; font-size: .95rem; max-width: 34ch; }
.urgent-card .meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: .88rem; font-weight: 600; }
.urgent-card .meta span { display: inline-flex; align-items: center; gap: 6px; }
.urgent-card .btn { background: #fff; color: var(--urgent); }
:root[data-theme="dark"] .urgent-card .btn { color: #8e2a17; }
.search { position: relative; }
.search svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ink-3); }
.search .input { padding-inline-start: 44px; }
.spec-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 480px) { .spec-grid { grid-template-columns: repeat(4, 1fr); } }
.spec {
  background: var(--surface); border-radius: var(--r); padding: 14px 8px 12px; border: 0; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 6px; text-align: center; box-shadow: var(--shadow); min-height: 112px;
}
.spec .ic { width: 46px; height: 46px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.spec .ic svg { width: 26px; height: 26px; }
.spec b { font-size: .86rem; font-weight: 600; line-height: 1.35; }
.spec small { font-size: .74rem; color: var(--ink-3); }
.spec small.on { color: var(--ok); font-weight: 600; }
.trust { display: grid; gap: 8px; }
.trust div { display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--ink-2); }
.trust svg { width: 18px; height: 18px; color: var(--brand); flex: none; }
.banner {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow);
  cursor: pointer; border: 0; width: 100%; text-align: start; border-inline-start: 4px solid var(--brand);
}
.banner.wait { border-inline-start-color: var(--amber); }

/* ---------- الأطباء ---------- */
.avatar {
  width: 52px; height: 52px; border-radius: 16px; flex: none; display: grid; place-items: center; font-family: var(--f-display); font-weight: 600;
  font-size: 1.15rem; background: var(--brand-soft); color: var(--brand); position: relative;
}
.avatar.lg { width: 76px; height: 76px; border-radius: 22px; font-size: 1.6rem; }
.avatar.f { background: var(--amber-soft); color: var(--amber); }
.avatar .st { position: absolute; bottom: -2px; inset-inline-end: -2px; width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--surface); background: var(--ink-3); }
.avatar .st.on { background: var(--ok); }
.doc-card { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); cursor: pointer; border: 0; text-align: start; width: 100%; }
.doc-card h3 { font-size: 1rem; }
.doc-card .sub { font-size: .85rem; color: var(--ink-2); }
.doc-card .facts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .82rem; color: var(--ink-2); margin-top: 4px; }
.doc-card .facts span { display: inline-flex; align-items: center; gap: 4px; }
.doc-card .facts svg { width: 14px; height: 14px; }
.doc-card .price { text-align: end; flex: none; }
.doc-card .price b { font-family: var(--f-display); font-size: 1.1rem; display: block; }
.star { color: #d89a1c; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { font-family: var(--f-display); font-size: 1.15rem; display: block; }
.stat span { font-size: .78rem; color: var(--ink-2); }

/* ---------- خطوات الحجز ---------- */
.steps { display: flex; gap: 6px; }
.steps i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--brand); }
.who { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r); border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; width: 100%; text-align: start; }
.who.on { border-color: var(--brand); background: var(--brand-soft); }
.who .avatar { width: 44px; height: 44px; border-radius: 13px; font-size: 1rem; }
.flag { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); cursor: pointer; }
.flag input { width: 22px; height: 22px; accent-color: var(--urgent); flex: none; }
.flag.on { border-color: var(--urgent); background: var(--urgent-soft); }
.range { width: 100%; accent-color: var(--brand); height: 32px; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos .ph { width: 76px; height: 76px; border-radius: 12px; background-size: cover; background-position: center; position: relative; border: 1px solid var(--line); }
.photos .ph button { position: absolute; top: -8px; inset-inline-start: -8px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); cursor: pointer; font-size: .9rem; line-height: 1; }
.photos label.add { width: 76px; height: 76px; border-radius: 12px; border: 1.5px dashed var(--line); display: grid; place-items: center; color: var(--ink-3); cursor: pointer; }
.photos label.add svg { width: 26px; height: 26px; }
.bill { display: grid; gap: 8px; }
.bill div { display: flex; justify-content: space-between; gap: 12px; }
.bill .tot { font-weight: 700; font-family: var(--f-display); font-size: 1.1rem; border-top: 1px dashed var(--line); padding-top: 8px; }
.emergency { background: var(--urgent); color: #fff; border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.emergency h2 { color: #fff; font-size: 1.4rem; }
.emergency .big { font-family: var(--f-display); font-size: 3.4rem; font-weight: 700; line-height: 1; letter-spacing: .02em; }
.emergency .btn { background: #fff; color: var(--urgent); }

/* ---------- المحادثة ---------- */
.chat-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chatpage {
  display: flex; flex-direction: column; position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  top: calc(var(--top-off, 0px) + env(safe-area-inset-top, 0px)); background: var(--bg);
}
@media (min-width: 600px) { .chatpage { border-inline: 1px solid var(--line); } }
.statusbar { padding: 10px 14px; font-size: .88rem; display: flex; align-items: center; gap: 10px; background: var(--amber-soft); }
.statusbar.ok { background: var(--ok-soft); }
.statusbar.end { background: var(--surface-2); }
.statusbar .grow { line-height: 1.45; }
.msgs { flex: 1; overflow-y: auto; padding: 16px max(14px, env(safe-area-inset-right, 0px)) 16px max(14px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 82%; padding: 9px 13px; border-radius: 16px; font-size: .97rem; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; box-shadow: var(--shadow); }
.msg.me { align-self: flex-start; background: var(--bubble-me); color: var(--bubble-me-ink); border-start-start-radius: 4px; }
.msg.them { align-self: flex-end; background: var(--bubble-them); border-start-end-radius: 4px; }
.msg time { display: block; font-size: .7rem; opacity: .7; margin-top: 2px; text-align: end; }
.msg img { border-radius: 10px; display: block; max-height: 260px; cursor: zoom-in; margin-bottom: 4px; }
.msg.sys { align-self: center; max-width: 92%; background: var(--surface-2); color: var(--ink-2); font-size: .85rem; text-align: center; box-shadow: none; border-radius: 12px; }
.msg.sys.ok { background: var(--ok-soft); color: var(--ok); }
.msg.sys.warn { background: var(--amber-soft); color: var(--ink); }
.msg.sys .btn { margin-top: 8px; }
.intake-box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: .9rem; display: grid; gap: 4px; }
.intake-box b { font-family: var(--f-display); }
.composer { border-top: 1px solid var(--line); background: var(--surface); padding: 8px max(10px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 8px; }
.composer .in { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 46px; max-height: 140px; resize: none; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg); padding: 11px 14px; outline: none; }
.composer textarea:focus { border-color: var(--brand); }
.sendbtn { width: 46px; height: 46px; border-radius: 14px; border: 0; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.sendbtn svg { width: 22px; height: 22px; transform: scaleX(-1); }
.quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.quick button { flex: none; border: 1px solid var(--line); background: var(--bg); border-radius: 99px; padding: 6px 12px; font-size: .82rem; cursor: pointer; max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-actions { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.doc-actions .btn { flex: none; }

/* ---------- القوائم ---------- */
.list { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 14px; border: 0; background: none; text-align: start; width: 100%; cursor: pointer; border-bottom: 1px solid var(--line); color: inherit; }
.item:last-child { border-bottom: 0; }
.item:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.item .ic { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center; flex: none; }
.item .ic svg { width: 22px; height: 22px; }
.item .t { font-weight: 600; }
.item .s { font-size: .85rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .end { text-align: end; flex: none; font-size: .82rem; color: var(--ink-3); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.badge { min-width: 22px; height: 22px; border-radius: 11px; background: var(--brand); color: var(--brand-ink); font-size: .75rem; font-weight: 700; display: inline-grid; place-items: center; padding: 0 6px; }
.empty { text-align: center; padding: 36px 16px; color: var(--ink-2); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty svg { width: 52px; height: 52px; color: var(--ink-3); }
.tx-amt { font-family: var(--f-display); font-weight: 600; font-variant-numeric: tabular-nums; }
.tx-amt.plus { color: var(--ok); }
.tx-amt.minus { color: var(--ink); }

/* ---------- المحفظة ---------- */
.balance { background: var(--brand); color: var(--brand-ink); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.balance b { font-family: var(--f-display); font-size: 2.2rem; line-height: 1.2; }
.copyline { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.copyline code { flex: 1; font-size: 1rem; direction: ltr; text-align: right; user-select: all; font-family: var(--f-body); font-weight: 600; }

/* ---------- الطبيب ---------- */
.online-toggle { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); cursor: pointer; border: 0; width: 100%; text-align: start; }
.online-toggle.on { background: var(--ok-soft); }
.switch { width: 54px; height: 32px; border-radius: 16px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 4px; inset-inline-start: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: inset-inline-start .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.on > .switch, .switch.on { background: var(--ok); }
.on > .switch::after, .switch.on::after { inset-inline-start: 26px; }
.req { background: var(--surface); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; border-inline-start: 4px solid var(--amber); }
.req.urgent { border-inline-start-color: var(--urgent); }
.req .q { font-size: .95rem; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }

/* ---------- الروشتة ---------- */
.rx { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.rx-head { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--brand); padding-bottom: 12px; }
.rx-head .sym { font-family: var(--f-display); font-size: 2.2rem; color: var(--brand); line-height: 1; font-weight: 700; direction: ltr; }
.rx-item { display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.rx-item:last-child { border-bottom: 0; }
.rx-item .n { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.rx-code { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 14px; padding: 14px; }
.rx-code b { font-family: var(--f-display); font-size: 1.7rem; letter-spacing: .18em; direction: ltr; }
.rx-edit-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); position: relative; }
.rx-edit-row .full { grid-column: 1 / -1; }
.rx-edit-row .input { min-height: 46px; padding: 10px 12px; }
.rx-edit-row .rm { position: absolute; top: 6px; inset-inline-start: 6px; }
@media print {
  .topbar, .bottomnav, .no-print, .demo-bar { display: none !important; }
  body { background: #fff; }
  .rx { box-shadow: none; }
}

/* ---------- النوافذ ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(8, 22, 19, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 14px; animation: up .2s ease; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 4px; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.toast { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: .92rem; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: up .2s ease; }
.toast.bad { background: var(--urgent); color: #fff; }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.88); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-height: 92dvh; border-radius: 8px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: 12px; }
@keyframes sk { to { background-position: -200% 0; } }
.stars { display: flex; gap: 6px; justify-content: center; direction: ltr; }
.stars button { border: 0; background: none; cursor: pointer; padding: 2px; color: var(--line); }
.stars button svg { width: 40px; height: 40px; }
.stars button.on { color: #e0a21f; }

/* ---------- الإدارة ---------- */
.admin { display: grid; grid-template-columns: 240px 1fr; min-height: 100dvh; }
.admin aside { background: var(--surface); border-inline-end: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; overflow-y: auto; }
.admin aside .brandmark { padding: 4px 8px 16px; }
.admin aside button { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: start; font-size: .95rem; color: var(--ink-2); }
.admin aside button svg { width: 20px; height: 20px; }
.admin aside button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.admin aside button .badge { margin-inline-start: auto; background: var(--urgent); color: #fff; }
.admin main { padding-block: 22px 60px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.admin main > * { max-width: 1100px; width: 100%; }
.admin-tabs { display: none; }
@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .admin aside { display: none; }
  .admin-tabs { display: flex; gap: 6px; overflow-x: auto; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); padding: 10px max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .admin-tabs button { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 14px; cursor: pointer; font-size: .88rem; }
  .admin-tabs button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
}
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.kpi span { font-size: .84rem; color: var(--ink-2); }
.kpi b { font-family: var(--f-display); font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi.alert { box-shadow: inset 0 0 0 2px var(--urgent); cursor: pointer; }
.kpi.alert b { color: var(--urgent); }
.tablewrap { overflow-x: auto; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 11px 14px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-weight: 600; color: var(--ink-2); font-size: .8rem; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 220px; }
.chart svg { width: 100%; height: auto; display: block; }
.license { width: 100%; max-width: 360px; aspect-ratio: 1.6; border-radius: 12px; background: var(--surface-2); object-fit: cover; display: grid; place-items: center; color: var(--ink-3); font-size: .85rem; text-align: center; padding: 10px; }

/* ---------- شريط التجربة ---------- */
.demo-bar { background: var(--ink); color: var(--bg); font-size: .82rem; padding: 6px max(12px, env(safe-area-inset-right, 0px)) 6px max(12px, env(safe-area-inset-left, 0px)); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.demo-bar button { border: 1px solid color-mix(in srgb, var(--bg) 35%, transparent); background: transparent; color: var(--bg); border-radius: 99px; padding: 3px 10px; cursor: pointer; font-size: .8rem; }
.demo-bar button.on { background: var(--bg); color: var(--ink); }
.demo-flag { font-size: .7rem; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--ink-3); font-weight: 600; }

/* ---------- تصحيحات ---------- */
[hidden] { display: none !important; }
.urgent-card .meta svg { width: 16px; height: 16px; }
.who > svg { width: 22px; height: 22px; color: var(--brand); flex: none; }
.banner > svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.item > svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.doc-card > svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.toast { bottom: auto; top: calc(var(--top-off, 0px) + env(safe-area-inset-top, 0px) + 12px); }
.urgent-card { background: var(--urgent-card); }
.urgent-card .btn { color: var(--urgent-card); }
:root { --urgent-card: #c8432b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --urgent-card: #a5361f; } }
:root[data-theme="dark"] { --urgent-card: #a5361f; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 360px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.seg button small { display: block; line-height: 1.2; color: var(--ink-3); }
.seg button { padding-block: 6px; }
