:root {
  --bg: #f4f5fa;
  --panel: #ffffff;
  --ink: #1d1b2e;
  --muted: #6b6880;
  --faint: #9a97ad;
  --line: #e6e5ef;
  --line-strong: #d3d1e2;
  --brand: #5b3fd1;
  --brand-ink: #4128b0;
  --brand-soft: #efebff;
  --danger: #c0262d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 27, 46, .05), 0 4px 16px rgba(29, 27, 46, .05);

  --waiting: #a86b00;   --waiting-bg: #fdf1d6;
  --confirmed: #2557d6; --confirmed-bg: #e2ebff;
  --arrived: #0b877c;   --arrived-bg: #d6f3ee;
  --inside: #7a35e0;    --inside-bg: #efe4ff;
  --done: #1b7a3c;      --done-bg: #daf3e2;
  --cancelled: #8b8f99; --cancelled-bg: #eff0f2;
  --noshow: #b4232a;    --noshow-bg: #fde3e3;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, "Noto Sans Arabic", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
/* Arabic names keep their reading direction but line up with the rest of the layout */
b[dir="auto"], span[dir="auto"], h1[dir="auto"], td[dir="auto"], .p-notes { text-align: left; }
[dir="rtl"] b[dir="auto"], [dir="rtl"] span[dir="auto"], [dir="rtl"] h1[dir="auto"], [dir="rtl"] td[dir="auto"], [dir="rtl"] .p-notes { text-align: right; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: #221a4a;
  color: #e9e5ff;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 26px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand .logo { width: 38px; height: 38px; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: #b5addb; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px;
  color: #cfc8f3; text-decoration: none; font-weight: 500;
  background: none; border: 0; cursor: pointer; text-align: start;
}
.nav a:hover, .nav button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .nav-settings { margin-top: auto; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px;
  background: rgba(244, 245, 250, .9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.search {
  flex: 1; max-width: 460px;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 11px; padding: 0 12px; color: var(--faint);
}
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search input { border: 0; outline: 0; background: none; padding: 10px 0; width: 100%; color: var(--ink); }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin-inline-start: auto; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live.on i { background: #1fb36b; box-shadow: 0 0 0 4px rgba(31, 179, 107, .18); }
.live.off { color: var(--danger); }
.live.off i { background: var(--danger); }
.view { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }

/* ---------- common ---------- */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); }
.spacer { flex: 1; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 16px; margin: 0; }
.panel-head .count { color: var(--muted); font-size: 14px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--panel);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); color: #fff; }
.btn.ghost { background: none; border-color: transparent; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: #fdecec; color: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #f0eff6; color: var(--muted); white-space: nowrap; }
.tag.consultation { background: #e9f0ff; color: #2c4fa8; }
.tag.followup { background: #e5f6ea; color: #1f6b3a; }

.s-waiting   { --c: var(--waiting);   --cb: var(--waiting-bg); }
.s-confirmed { --c: var(--confirmed); --cb: var(--confirmed-bg); }
.s-arrived   { --c: var(--arrived);   --cb: var(--arrived-bg); }
.s-inside    { --c: var(--inside);    --cb: var(--inside-bg); }
.s-done      { --c: var(--done);      --cb: var(--done-bg); }
.s-cancelled { --c: var(--cancelled); --cb: var(--cancelled-bg); }
.s-noshow    { --c: var(--noshow);    --cb: var(--noshow-bg); }
.pill[class*="s-"] { color: var(--c); background: var(--cb); }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; border-inline-start: 4px solid var(--c, var(--brand)); }
.stat .n { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13.5px; }
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 82px minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
  padding: 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: #faf9ff; }
.row .time { font-weight: 700; font-variant-numeric: tabular-nums; }
.row .time small { display: block; font-weight: 500; color: var(--faint); font-size: 12px; }
.row .who { min-width: 0; }
.row .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .who small { color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row .acts { display: flex; gap: 6px; }
.row.is-cancelled .who b, .row.is-noshow .who b { text-decoration: line-through; color: var(--muted); }

.wl-item { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.wl-item:last-child { border-bottom: 0; }
.wl-item:hover { background: #faf9ff; }
.wl-item .who { flex: 1; min-width: 0; }
.wl-item .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-item .who small { color: var(--muted); }

/* ---------- calendar ---------- */
.cal-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.navgroup { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--panel); }
.navgroup button { border: 0; background: none; padding: 8px 12px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; }
.navgroup button + button { border-inline-start: 1px solid var(--line); }
.navgroup button:hover { background: var(--brand-soft); color: var(--brand); }
.navgroup button.on { background: var(--brand); color: #fff; }
.date-jump { border: 1px solid var(--line-strong); border-radius: 10px; padding: 7px 10px; background: var(--panel); }
.select { border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 10px; background: var(--panel); }
.cal-title { font-size: 20px; font-weight: 700; margin: 0; }
.cal-title small { display: block; font-size: 13.5px; font-weight: 500; color: var(--muted); }

.day { overflow: hidden; }
.slot { display: grid; grid-template-columns: 92px 1fr; border-top: 1px solid var(--line); min-height: 50px; }
.slot:first-child { border-top: 0; }
.slot.hour { border-top-color: var(--line-strong); }
.slot.now { background: linear-gradient(90deg, #fff7e6, transparent 40%); }
.slot.now .slot-time { color: #b46b00; font-weight: 700; }
.slot-time { white-space: nowrap; padding-block: 12px 0; padding-inline: 18px 12px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; border-inline-end: 1px solid var(--line); }
.slot.hour .slot-time { color: var(--ink); font-weight: 600; }
.slot-body { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 10px; align-items: center; cursor: pointer; }
.slot-body:hover { background: #fbfaff; }
.slot-add { color: transparent; font-size: 13px; font-weight: 600; padding: 4px 8px; border-radius: 8px; }
.slot-body:hover .slot-add { color: var(--brand); }
.slot.notime .slot-time { color: var(--waiting); font-weight: 600; }

.card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  min-width: 220px; max-width: 380px; text-align: start;
  padding-block: 7px; padding-inline: 11px 12px; border-radius: 10px; cursor: pointer;
  background: var(--cb); border: 1px solid transparent; border-inline-start: 4px solid var(--c);
}
.card:hover { border-color: var(--c); }
.card b { font-size: 14.5px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card small { color: var(--muted); font-size: 12.5px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card .st { color: var(--c); font-weight: 700; }
.card.s-cancelled b, .card.s-noshow b { text-decoration: line-through; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.wday { display: flex; flex-direction: column; min-height: 320px; }
.wday-head { padding: 12px 12px 10px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: var(--radius) var(--radius) 0 0; }
.wday-head:hover { background: var(--brand-soft); }
.wday-head b { display: block; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wday-head span { font-size: 20px; font-weight: 700; }
.wday-head small { float: inline-end; margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.wday.today .wday-head { background: var(--brand); color: #fff; }
.wday.today .wday-head b, .wday.today .wday-head small { color: #e2dbff; }
.wday-body { padding: 8px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.witem {
  display: block; width: 100%; text-align: start; cursor: pointer;
  border: 0; border-inline-start: 3px solid var(--c); background: var(--cb);
  border-radius: 7px; padding: 5px 8px; font-size: 13px;
}
.witem b { display: block; font-weight: 700; font-size: 12px; color: var(--c); font-variant-numeric: tabular-nums; }
.witem span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wday-add { margin-top: auto; border: 1px dashed var(--line-strong); background: none; border-radius: 8px; padding: 6px; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 13px; }
.wday-add:hover { border-color: var(--brand); color: var(--brand); }

.legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- patients ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.table td { padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #faf9ff; }
.table .name { font-weight: 600; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; flex: none;
}
.namecell { display: flex; align-items: center; gap: 12px; }

.profile { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.p-head { display: flex; align-items: center; gap: 16px; padding: 20px; flex-wrap: wrap; }
.p-head .avatar { width: 56px; height: 56px; font-size: 22px; }
.p-head h1 { margin: 0; font-size: 22px; }
.p-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.p-facts div { background: var(--panel); padding: 12px 20px; }
.p-facts small { display: block; color: var(--muted); font-size: 12.5px; }
.p-facts b { font-weight: 600; word-break: break-word; }
.p-notes { padding: 14px 20px; border-top: 1px solid var(--line); white-space: pre-wrap; }
.p-notes small { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 2px; }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; padding: 14px; }
.file { position: relative; }
.file a { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); }
.file img, .file-icon {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: #f7f6fb;
}
.file-icon { display: grid; place-items: center; font-weight: 800; color: var(--brand); font-size: 18px; }
.file-name { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file small { color: var(--muted); font-size: 11.5px; margin-top: -4px; }
.file-del {
  position: absolute; top: 5px; inset-inline-end: 5px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: rgba(29, 27, 46, .65); color: #fff; cursor: pointer; display: none; place-items: center; font-size: 15px; line-height: 1;
}
.file:hover .file-del { display: grid; }
@media (hover: none) { .file-del { display: grid; } }
.upload-btn { position: relative; overflow: hidden; }
.upload-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- modal ---------- */
dialog {
  border: 0; padding: 0; border-radius: 18px; width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 32px); box-shadow: 0 24px 60px rgba(20, 14, 50, .3); color: var(--ink);
}
dialog::backdrop { background: rgba(24, 18, 52, .45); backdrop-filter: blur(2px); }
.modal { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 19px; flex: 1; }
.modal-body { padding: 6px 22px 18px; overflow-y: auto; }
.modal-body section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.modal-body section:last-child { border-bottom: 0; }
.modal-body h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: #fbfbfe; border-radius: 0 0 18px 18px; }

.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); position: relative; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px;
  background: #fff; color: var(--ink); font-weight: 500; font-size: 15px; width: 100%;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.req { color: var(--danger); }

.suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 10; margin-top: 4px; background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.suggest:empty { display: none; }
.suggest button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 9px 12px; border: 0; background: none; cursor: pointer; text-align: start; color: var(--ink); }
.suggest button:hover { background: var(--brand-soft); }
.suggest button small { color: var(--muted); font-weight: 500; }
.suggest .hint { padding: 6px 12px; font-size: 12px; color: var(--muted); background: #fafafe; font-weight: 500; }

.chip { display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 600; color: var(--brand); background: var(--brand-soft); padding: 3px 4px 3px 10px; border-radius: 999px; }
.chip button { border: 0; background: #fff; color: var(--brand); border-radius: 999px; padding: 1px 8px; cursor: pointer; font-size: 12px; font-weight: 600; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 9px 15px; border-radius: 11px; border: 1.5px solid var(--line-strong);
  font-weight: 600; font-size: 14px; background: #fff; color: var(--ink); user-select: none;
}
.choice span:hover { border-color: var(--c, var(--brand)); }
.choice input:checked + span { border-color: var(--c, var(--brand)); background: var(--cb, var(--brand-soft)); color: var(--c, var(--brand)); }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-soft); }
.choice.big span { padding: 12px 22px; font-size: 15px; }
.choice[class*="s-"] span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

.mini-files { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.mini-files:empty { display: none; }
.mini-files .file { width: 92px; }
.pending { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pending:empty { display: none; }
.pending span { background: var(--brand-soft); color: var(--brand); border-radius: 8px; padding: 4px 9px; font-size: 13px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.contact { display: inline-flex; gap: 6px; flex-wrap: wrap; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: #221a4a; color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 100; box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .dash, .profile { grid-template-columns: 1fr; }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 20;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .brand { display: none; }
  .nav { flex-direction: row; justify-content: space-around; }
  .nav a, .nav button { flex-direction: column; gap: 2px; font-size: 11.5px; padding: 6px 10px; flex: 1; align-items: center; }
  .nav .nav-settings { margin-top: 0; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .live span { display: none; }
  .hide-sm { display: none; }
  .view { padding: 16px 16px 96px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .row { grid-template-columns: 64px minmax(0, 1fr); }
  .row .pill, .row .acts { grid-column: 2; justify-self: start; }
  .week { grid-template-columns: 1fr; }
  .wday { min-height: 0; }
  .slot { grid-template-columns: 70px 1fr; }
  .slot-time { padding-inline-start: 10px; }
  .card { min-width: 0; max-width: 100%; flex: 1 1 100%; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .c2, .c3 { grid-column: span 1; } .c4, .c6 { grid-column: span 2; }
  .p-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table .hide-sm-cell { display: none; }
  .table th, .table td { padding: 11px 12px; }
  dialog { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100%; border-radius: 0; margin: 0; }
  .modal { max-height: 100vh; height: 100%; }
  .modal-foot { border-radius: 0; }
}

/* ---------- doctor room ---------- */
.doc { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
#docMain { display: grid; gap: 18px; min-width: 0; }
.doc-side { display: grid; gap: 18px; position: sticky; top: 84px; }
.doc-card { padding: 20px 22px; }
.doc-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.doc-tabs button { border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.doc-tabs button.on { background: var(--inside-bg); border-color: var(--inside); color: var(--inside); }
.doc-who { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar.big { width: 64px; height: 64px; font-size: 24px; background: var(--inside-bg); color: var(--inside); }
.doc-name { flex: 1; min-width: 200px; }
.doc-name h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.01em; }
.doc-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 14px; }
.doc-meta b { color: var(--ink); }
.doc-meta .first { background: #fff4d6; color: var(--waiting); font-weight: 700; padding: 2px 9px; border-radius: 6px; font-size: 12.5px; }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { background: rgba(255, 255, 255, .25); border-radius: 999px; padding: 0 7px; font-size: 12px; }
.alert { margin-top: 16px; background: #fff4d6; border: 1px solid #f3dd9f; color: #6b4500; padding: 10px 14px; border-radius: 10px; white-space: pre-wrap; }
.alert.soft { background: #f7f7fb; border-color: var(--line); color: var(--muted); }
.link { border: 0; background: none; color: var(--brand); font-weight: 600; cursor: pointer; padding: 0 4px; text-decoration: underline; }
.recep { margin-top: 10px; color: var(--muted); white-space: pre-wrap; }
.recep b { color: var(--ink); font-weight: 600; }
.doc-label { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.doc-label h2 { margin: 0; font-size: 16px; flex: 1; }
.save-state { font-size: 13px; color: var(--muted); }
#docNotes {
  width: 100%; min-height: 150px; resize: vertical;
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 14px 16px;
  font-size: 16px; line-height: 1.55; background: #fffef8;
}
#docNotes:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip-btn { border: 1px dashed var(--line-strong); background: none; border-radius: 999px; padding: 4px 11px; font-size: 13px; cursor: pointer; color: var(--muted); font-weight: 600; }
.chip-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.doc-attach { display: flex; gap: 8px; flex-wrap: wrap; }
.visit { border-inline-start: 3px solid var(--line-strong); padding-block: 4px 14px; padding-inline: 16px 0; margin-inline-start: 4px; }
.visit + .visit { margin-top: 4px; }
.visit.last { border-inline-start-color: var(--inside); }
.visit header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.visit .dnotes { white-space: pre-wrap; background: #fbfaff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.visit .mini-files { margin: 10px 0 0; }
.wl-item.dim { cursor: default; opacity: .75; }
.doc-empty { padding: 56px 24px; text-align: center; }
.doc-empty h1 { margin: 10px 0 6px; font-size: 24px; }
.doc-empty-icon { width: 72px; height: 72px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.doc-empty-icon svg { width: 34px; height: 34px; }
.btn.big { padding: 14px 24px; font-size: 16px; margin-top: 12px; }
.row-notes { grid-column: 2 / -1; white-space: pre-wrap; font-size: 13.5px; color: var(--ink); background: #fbfaff; border-inline-start: 3px solid var(--inside); padding: 6px 10px; border-radius: 8px; }
.viewer-dialog { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; margin: 0; border-radius: 0; background: rgba(15, 12, 30, .92); }
.viewer { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; border-radius: 8px; background: #fff; }
.viewer-bar { display: flex; gap: 10px; align-items: center; color: #fff; flex-wrap: wrap; justify-content: center; }
@media (max-width: 1180px) {
  .doc { grid-template-columns: 1fr; }
  .doc-side { position: static; }
}
@media (max-width: 820px) {
  .doc-card { padding: 16px; }
  .doc-actions { width: 100%; }
  .doc-actions .btn { flex: 1; }
  .nav a, .nav button { padding: 6px 4px; }
}

/* ---------- doctor room v2 ---------- */
.doc { grid-template-columns: 1fr; max-width: 1040px; }
.doc-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; width: 100%; }
.doc-actions .btn { padding: 14px 16px; font-size: 15.5px; border-radius: 12px; }
.rx-btn { background: var(--brand-soft); border-color: #d8cdfb; color: var(--brand); }
.rx-btn.has { background: #fff; }
.calling-btn { background: #fff4d6; border-color: #f1d48b; color: #8a5a00; }
.calling-btn:hover { background: #fdecc0; color: #8a5a00; border-color: #e3bf62; }
.calling-btn svg, .call-banner .bell { animation: ring 1.2s ease-in-out infinite; transform-origin: 50% 10%; }
@keyframes ring { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20%, 40% { transform: rotate(-14deg); } }
.recep-note { margin-top: 16px; background: #eef4ff; border: 1px solid #d3e0fb; color: #1f3c7a; padding: 10px 14px; border-radius: 10px; white-space: pre-wrap; }
.recep-note b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #4a67a8; margin-bottom: 2px; }

.rx-day { padding: 14px 0 16px; border-top: 1px solid var(--line); }
.rx-day:first-of-type { border-top: 0; padding-top: 4px; }
.rx-day header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.rx-day header b { font-size: 15.5px; }
.rx-day.today header b { color: var(--inside); }
.rx-day .dnotes { margin-top: 10px; white-space: pre-wrap; background: #fbfaff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.rx-photos { display: flex; gap: 12px; flex-wrap: wrap; }
.rx-photo { padding: 0; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; background: #f7f6fb; cursor: zoom-in; width: 220px; height: 280px; display: block; }
.rx-photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.rx-photo:hover img { transform: scale(1.03); }
.rx-photo.doc-file { display: grid; place-content: center; text-align: center; gap: 6px; font-weight: 800; font-size: 22px; color: var(--brand); text-decoration: none; cursor: pointer; }
.rx-photo.doc-file small { font-size: 12px; font-weight: 500; color: var(--muted); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rx-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.rx-pick .btn.big { margin-top: 0; flex: 1; min-width: 180px; }

.wait { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.wait:last-child { border-bottom: 0; }
.wait .who { flex: 1; min-width: 0; }
.wait .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wait .who small { color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.wait-time { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; background: var(--arrived-bg); color: var(--arrived); padding: 5px 11px; border-radius: 999px; font-size: 13.5px; }
.wait-time.mid { background: #fff1d6; color: #9a6200; }
.wait-time.long { background: var(--noshow-bg); color: var(--noshow); }

.calling { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; font-weight: 600; color: #8a5a00; background: #fff4d6; padding: 10px 16px; border-radius: 999px; }
.calling .dot { width: 9px; height: 9px; border-radius: 50%; background: #e0a100; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.call-banner {
  margin: 16px 28px 0; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: #fff4d6; border: 1px solid #f1d48b; border-radius: 14px; padding: 12px 16px;
  box-shadow: 0 6px 20px rgba(160, 110, 0, .12);
}
.call-banner .bell { font-size: 24px; display: inline-block; }
.call-text { flex: 1; min-width: 180px; }
.call-text b { display: block; color: #6b4500; }
.call-text small { color: #8a6a2a; }
.call-none { color: #8a6a2a; font-weight: 600; }
@media (max-width: 820px) {
  .doc-actions { grid-template-columns: 1fr; }
  .rx-photo { width: calc(50% - 6px); height: 220px; }
  .call-banner { margin: 12px 16px 0; }
}

/* ---------- doctor preview (called / peeking) ---------- */
.coming { display: flex; gap: 12px; align-items: center; margin: -4px 0 16px; padding: 10px 14px; border-radius: 12px; background: #f3f1fa; border: 1px solid var(--line); font-size: 20px; }
.coming div { font-size: 14px; }
.coming b { display: block; }
.coming small { color: var(--muted); }
.coming.called { background: #fff4d6; border-color: #f1d48b; }
.coming.called b { color: #6b4500; }
.coming .bell { display: inline-block; animation: ring 1.2s ease-in-out infinite; transform-origin: 50% 10%; }
.doc-card.is-called { border-color: #f1d48b; box-shadow: 0 0 0 3px #fff4d6, var(--shadow); }
.doc-card.is-preview { border-style: dashed; }
.doc-card.is-called .doc-actions, .doc-card.is-preview .doc-actions { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.wait.click { cursor: pointer; }
.wait.click:hover { background: #faf9ff; }
.wait.shown { background: var(--brand-soft); }
.called-tag { color: #9a6200; }

/* ---------- Arabic / right-to-left ---------- */
[dir="rtl"] body { font-size: 15.5px; }
[dir="rtl"] *, [dir="rtl"] *::before { letter-spacing: 0 !important; } /* spacing breaks Arabic letters apart */
[dir="rtl"] .slot.now { background: linear-gradient(270deg, #fff7e6, transparent 40%); }
[dir="rtl"] .phone-cell, .phone-cell { text-align: start; }
[dir="rtl"] .phone-cell { text-align: right; }
.nav .nav-lang { margin-top: auto; }
.nav .nav-lang + .nav-settings { margin-top: 0; }
.hint-inline { font-weight: 500; color: var(--brand); font-size: 12px; background: var(--brand-soft); padding: 1px 7px; border-radius: 999px; }
.opt { text-transform: none; font-weight: 500; }

/* suggestions in the booking form (phone-first) */
.suggest-inline:empty { display: none; }
.suggest-inline { border: 1.5px solid #d8cdfb; background: #faf8ff; border-radius: 12px; overflow: hidden; }
.suggest-inline .hint { padding: 8px 12px; font-size: 13px; color: var(--brand-ink); font-weight: 600; border-bottom: 1px solid #e6defc; }
.suggest-inline button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 9px 12px; border: 0; border-bottom: 1px solid #efeafd; background: none; cursor: pointer; text-align: start; color: var(--ink); }
.suggest-inline button:last-child { border-bottom: 0; }
.suggest-inline button:hover { background: var(--brand-soft); }
.sg-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sg-text small { color: var(--muted); }
[dir="rtl"] .sg-text small { text-align: right; }
.sg-age { color: var(--muted); }
.sg-use { font-weight: 700; color: #fff; background: var(--brand); border-radius: 8px; padding: 4px 12px; font-size: 13px; }

/* ---------- today board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; margin-bottom: 18px; }
.col { background: #eceaf5; border-radius: 16px; padding: 10px; min-height: 220px; }
.col > header { display: flex; align-items: center; gap: 8px; padding: 6px 6px 12px; }
.col > header h2 { margin: 0; font-size: 16px; }
.col > header .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.col > header .count { margin-inline-start: auto; background: #fff; color: var(--c); font-weight: 700; border-radius: 999px; min-width: 28px; text-align: center; padding: 1px 8px; font-size: 14px; }
.col-body { display: flex; flex-direction: column; gap: 8px; }
.col-empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 26px 8px; border: 1.5px dashed var(--line-strong); border-radius: 12px; }
.bcard {
  background: #fff; border-radius: 12px; padding: 11px 12px; cursor: pointer;
  border: 1px solid var(--line); border-inline-start: 4px solid var(--c);
  box-shadow: 0 1px 2px rgba(29, 27, 46, .05); display: flex; flex-direction: column; gap: 6px;
  transition: transform .12s, box-shadow .12s;
}
.bcard:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(29, 27, 46, .08); }
.bc-top { display: flex; align-items: baseline; gap: 8px; }
.bc-top b { flex: 1; min-width: 0; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-time { font-weight: 700; font-size: 13px; color: var(--c); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bc-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 13px; }
.bc-wait { font-size: 13px; font-weight: 600; color: var(--arrived); }
.bc-wait.mid { color: #9a6200; }
.bc-wait.long { color: var(--noshow); }
.bc-late { font-size: 12.5px; font-weight: 700; color: var(--noshow); }
.bc-btn { align-self: stretch; padding: 8px; font-size: 14px; }
.col.s-done .bcard { opacity: .8; }
details.off { margin-bottom: 18px; }
details.off summary { cursor: pointer; padding: 14px 18px; font-weight: 600; color: var(--muted); display: flex; gap: 8px; align-items: center; list-style: none; }
details.off summary::-webkit-details-marker { display: none; }
details.off summary::before { content: "▸"; color: var(--faint); }
details.off[open] summary::before { content: "▾"; }
[dir="rtl"] details.off summary::before { content: "◂"; }
[dir="rtl"] details.off[open] summary::before { content: "▾"; }
@media (max-width: 1180px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .board { grid-template-columns: 1fr; }
  .col { min-height: 0; }
  .nav .nav-lang { margin-top: 0; }
}

/* ---------- accounts ---------- */
[hidden] { display: none !important; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 50% -10%, #3a2a85 0%, #221a4a 55%, #191335 100%); }
.auth-card { width: min(440px, 100%); background: var(--panel); border-radius: 20px; padding: 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); display: grid; gap: 18px; }
.auth-top { display: flex; align-items: center; gap: 12px; }
.auth-top img { width: 44px; height: 44px; border-radius: 12px; }
.auth-top div { flex: 1; display: flex; flex-direction: column; }
.auth-top b { font-size: 18px; }
.auth-top small { color: var(--muted); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: #f1effa; border-radius: 12px; padding: 4px; }
.auth-tabs button { border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--muted); }
.auth-tabs button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
#authForm { display: grid; gap: 14px; }
.auth-go { width: 100%; margin-top: 4px; }
.auth-error { color: var(--danger); font-weight: 600; font-size: 14px; min-height: 1px; }
.auth-error:empty { display: none; }
.pending-box { text-align: center; display: grid; gap: 12px; justify-items: center; padding: 10px 0; }
.pending-box h2 { margin: 0; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.me { display: flex; align-items: center; gap: 10px; padding: 12px 10px 4px; border-top: 1px solid rgba(255, 255, 255, .1); margin-top: 6px; }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.me-text b { color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: #b5addb; font-size: 12px; }
.me-out { border: 0; background: rgba(255, 255, 255, .08); color: #e9e5ff; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.me-out:hover { background: rgba(255, 255, 255, .16); }
.nav-badge { margin-inline-start: auto; background: #f5b400; color: #2a1d00; border-radius: 999px; font-size: 12px; padding: 0 7px; min-width: 20px; text-align: center; }
body.role-doctor .topbar [data-action="new-appt"] { display: none; }

.pid { display: inline-block; font-size: 12px; font-weight: 600; color: var(--muted); background: #f0eff6; border-radius: 6px; padding: 1px 6px; direction: ltr; unicode-bidi: isolate; }
.pid.big { font-size: 14px; vertical-align: middle; }
.more-hint { padding: 14px 18px; color: var(--muted); border-top: 1px solid var(--line); text-align: center; font-size: 14px; }
.notice { background: #fff4d6; border: 1px solid #f1d48b; color: #6b4500; border-radius: 12px; padding: 12px 16px; font-weight: 600; margin-bottom: 14px; }
.call-stack { display: grid; gap: 8px; }
.table.staff tr.is-pending { background: #fffbef; }
.table.staff select { max-width: 280px; }
.staff-acts { white-space: nowrap; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; inset-inline-start: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + span::before { transform: translateX(-18px); }
@media (max-width: 820px) {
  .me { display: none; }
  .table.staff th:nth-child(2), .table.staff td:nth-child(2) { display: none; }
  .staff-acts { white-space: normal; }
}
.topbar-out { display: none; }
@media (max-width: 820px) { .topbar-out { display: inline-grid; } }
