/* MMG CLINIC — تصميم يبدأ من الهاتف ثم يتوسع للحاسبة */
:root {
  color-scheme: light;
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --text: #0e1a29;
  --text-2: #475467;
  --muted: #778397;
  --line: #e3e8ef;
  --line-2: #eef1f5;
  --brand: #0b7a75;
  --brand-strong: #075a57;
  --brand-soft: #e2f3f1;
  --brand-ink: #ffffff;
  --navy: #0b1a2c;
  --danger: #c2410c;
  --danger-soft: #fdede4;
  --ok: #15803d;
  --ok-soft: #e4f5e9;
  --warn-soft: #fdf3dc;
  --shadow-sm: 0 1px 2px rgba(14, 26, 41, .05);
  --shadow: 0 1px 2px rgba(14, 26, 41, .04), 0 6px 20px rgba(14, 26, 41, .06);
  --shadow-lg: 0 20px 50px rgba(8, 20, 35, .22);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  /* ألوان مصادر المرضى (مفحوصة لعمى الألوان) */
  --s-social: #2a78d6;
  --s-doctor: #eb6834;
  --s-followup: #1baf7a;
  --s-other: #eda100;
  --side-w: 268px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1118; --surface: #141c26; --surface-2: #19232f; --text: #e9eef5; --text-2: #b6c1cf; --muted: #8592a4;
    --line: #243241; --line-2: #1d2936; --brand: #2ec4b6; --brand-strong: #6ad8cd; --brand-soft: #0f2d2c; --brand-ink: #04211f;
    --navy: #070e16; --danger: #fb8a4c; --danger-soft: #36200f; --ok: #4ade80; --ok-soft: #10291a; --warn-soft: #2e2510;
    --shadow-sm: none; --shadow: 0 1px 0 rgba(255,255,255,.02); --shadow-lg: 0 20px 50px rgba(0,0,0,.5);
    --s-social: #3987e5; --s-doctor: #d95926; --s-followup: #199e70; --s-other: #c98500;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1118; --surface: #141c26; --surface-2: #19232f; --text: #e9eef5; --text-2: #b6c1cf; --muted: #8592a4;
  --line: #243241; --line-2: #1d2936; --brand: #2ec4b6; --brand-strong: #6ad8cd; --brand-soft: #0f2d2c; --brand-ink: #04211f;
  --navy: #070e16; --danger: #fb8a4c; --danger-soft: #36200f; --ok: #4ade80; --ok-soft: #10291a; --warn-soft: #2e2510;
  --shadow-sm: none; --shadow: 0 1px 0 rgba(255,255,255,.02); --shadow-lg: 0 20px 50px rgba(0,0,0,.5);
  --s-social: #3987e5; --s-doctor: #d95926; --s-followup: #199e70; --s-other: #c98500;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "IBM Plex Sans Arabic", "Tajawal", system-ui, sans-serif;
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
input, select, textarea, button { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ الشعار */
.logo { display: flex; align-items: center; gap: 10px; }
.logo svg { width: 38px; height: 38px; flex: none; filter: drop-shadow(0 4px 10px rgba(11, 122, 117, .35)); }
.wordmark { direction: ltr; display: flex; flex-direction: column; line-height: 1; }
.wordmark b { font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.wordmark b span { font-weight: 400; letter-spacing: 2.5px; opacity: .8; margin-left: 4px; }
.wordmark small { font-size: 10.5px; opacity: .6; margin-top: 4px; direction: rtl; text-align: left; letter-spacing: 0; }

/* ------------------------------------------------------------ الهيكل */
.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.appbar.scrolled { border-color: var(--line); }
.appbar .logo svg { width: 34px; height: 34px; }
.avatar-btn { border: 0; padding: 0; background: none; border-radius: 50%; }

main#app { padding: 8px 16px calc(var(--tabbar-h) + var(--safe-b) + 96px); max-width: 1240px; margin: 0 auto; min-height: 100vh; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a, .tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 500; color: var(--muted); background: none; border: 0; position: relative;
}
.tabbar svg.i { width: 23px; height: 23px; }
.tabbar .on { color: var(--brand); }
.tabbar .on::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }

.side { display: none; }

.fab {
  position: fixed; z-index: 25; left: 16px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  display: inline-flex; align-items: center; gap: 8px; height: 56px; padding: 0 22px 0 20px; border: 0; border-radius: 18px;
  background: linear-gradient(135deg, #14b8a6, #0b6b67); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 10px 24px rgba(11, 122, 117, .4); animation: pop .35s cubic-bezier(.2, 1.4, .4, 1);
}
.fab svg.i { width: 22px; height: 22px; stroke-width: 2.4; }
.fab:active { transform: scale(.96); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@media (min-width: 900px) { .fab { bottom: 28px; left: 28px; } }

/* الحاسبة: قائمة جانبية بدل الشريط السفلي */
@media (min-width: 900px) {
  .appbar, .tabbar, .fab.mob-only { display: none !important; }
  .side {
    display: flex; flex-direction: column; position: fixed; inset: 0 0 0 auto; width: var(--side-w); z-index: 20;
    background: var(--navy); color: #c7d3e2; padding: 22px 14px 16px;
    background-image: radial-gradient(120% 60% at 100% 0%, rgba(20, 184, 166, .16), transparent 60%);
  }
  .side .logo { padding: 0 8px 22px; color: #fff; }
  .side-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
  .side-label { font-size: 11px; letter-spacing: .4px; color: #6f8197; padding: 16px 12px 6px; font-weight: 600; }
  .side-nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px; font-weight: 500; color: #c7d3e2; transition: background .15s, color .15s; }
  .side-nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
  .side-nav a.on { background: rgba(46, 196, 182, .14); color: #fff; box-shadow: inset -3px 0 0 #2ec4b6; }
  .side-nav a.sub { padding: 7px 12px 7px 12px; font-size: 14px; color: #9fb0c4; }
  .side-nav a.sub .dot { background: #3b4d63; }
  .side-nav a.sub.on .dot { background: #2ec4b6; }
  .side-nav a .count { margin-inline-start: auto; font-size: 12px; color: #7d8fa5; }
  .side-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; margin-top: 10px; display: flex; align-items: center; gap: 10px; }
  .side-foot .who { flex: 1; min-width: 0; }
  .side-foot .who b { display: block; color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-foot .who span { font-size: 12px; color: #7d8fa5; }
  .side-foot .icon-btn { color: #9fb0c4; border-color: rgba(255, 255, 255, .1); background: transparent; }
  .side-foot .icon-btn:hover { color: #fff; border-color: rgba(255, 255, 255, .25); }
  main#app { margin-right: var(--side-w); padding: 28px 32px 64px; max-width: none; }
  main#app > * { max-width: 1180px; margin-left: auto; margin-right: auto; }
}

/* ------------------------------------------------------------ عناصر عامة */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 6px 0 18px; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.2px; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--brand); }
.crumbs svg.i { width: 14px; height: 14px; }
.sub { color: var(--muted); font-size: 13.5px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 900px) { .page-head h1 { font-size: 28px; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px; background: var(--brand); color: var(--brand-ink);
  font-weight: 600; white-space: nowrap; transition: filter .15s, transform .1s, background .15s, border-color .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn svg.i { width: 18px; height: 18px; }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 16px; border-radius: 14px; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); filter: none; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn:disabled { opacity: .55; pointer-events: none; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.icon-btn.sm { width: 36px; height: 36px; border-radius: 10px; }
.icon-btn.sm svg.i { width: 17px; height: 17px; }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-head h2 svg.i { color: var(--brand); }
@media (min-width: 900px) { .panel { padding: 20px; } }

.avatar {
  --h: 170; width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 62% 48%), hsl(calc(var(--h) + 35) 58% 34%));
}
.avatar.lg { width: 60px; height: 60px; font-size: 22px; border-radius: 18px; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; white-space: nowrap; }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.badge.r-admin { background: #ece8fd; color: #4b3bb5; }
.badge.r-manager { background: #e3eefc; color: #1f5fae; }
.badge.r-director { background: var(--brand-soft); color: var(--brand-strong); }
.badge.r-secretary { background: var(--warn-soft); color: #8a5a00; }
:root[data-theme="dark"] .badge.r-admin { background: #231d48; color: #b3a8f5; }
:root[data-theme="dark"] .badge.r-manager { background: #132842; color: #8dbdf5; }
:root[data-theme="dark"] .badge.r-secretary { color: #e8b84a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.r-admin { background: #231d48; color: #b3a8f5; }
  :root:not([data-theme="light"]) .badge.r-manager { background: #132842; color: #8dbdf5; }
  :root:not([data-theme="light"]) .badge.r-secretary { color: #e8b84a; }
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-2); white-space: nowrap; color: var(--text-2); }
.note { font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------ مؤشرات */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 14px; }
@media (min-width: 700px) { .kpis { gap: 14px; } }
@media (min-width: 1200px) { .kpis { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 10px; min-width: 0; }
.kpi > div:last-child { min-width: 0; }
@media (min-width: 700px) { .kpi { flex-direction: column; align-items: stretch; padding: 14px; } }
.kpi .k-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.kpi .k-icon svg.i { width: 19px; height: 19px; }
.kpi .k-icon.blue { background: #e5effc; color: #2a6fc4; }
.kpi .k-icon.violet { background: #eeebfd; color: #5a48c9; }
.kpi .k-icon.amber { background: #fdf2dc; color: #a36a00; }
:root[data-theme="dark"] .kpi .k-icon.blue { background: #132842; color: #8dbdf5; }
:root[data-theme="dark"] .kpi .k-icon.violet { background: #231d48; color: #b3a8f5; }
:root[data-theme="dark"] .kpi .k-icon.amber { background: #2e2510; color: #e8b84a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .kpi .k-icon.blue { background: #132842; color: #8dbdf5; }
  :root:not([data-theme="light"]) .kpi .k-icon.violet { background: #231d48; color: #b3a8f5; }
  :root:not([data-theme="light"]) .kpi .k-icon.amber { background: #2e2510; color: #e8b84a; }
}
.kpi span { font-size: 12px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi b small { font-size: 12px; font-weight: 500; color: var(--muted); margin-inline-start: 3px; }
@media (max-width: 699px) { .kpi .cur { display: none; } }
@media (min-width: 700px) { .kpi span { font-size: 12.5px; } .kpi b { font-size: 22px; } }
@media (min-width: 900px) { .kpi { padding: 16px 18px; } .kpi b { font-size: 24px; } .kpi b small { font-size: 11px; } }

/* ------------------------------------------------------------ بطاقات المجمعات والدكاترة */
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; } }
a.tile { display: block; padding: 16px; position: relative; overflow: hidden; transition: border-color .15s, transform .15s, box-shadow .15s; }
a.tile:hover { border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
a.tile:active { transform: scale(.99); }
.tile-top { display: flex; align-items: center; gap: 12px; }
.tile-top .t-text { flex: 1; min-width: 0; }
.tile-top h3 { font-size: 16.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-top .sub { display: flex; align-items: center; gap: 4px; }
.tile-top .sub svg.i { width: 14px; height: 14px; }
.tile-top .go { color: var(--muted); }
.tile .cx-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #14b8a6, #0b4f6c); box-shadow: 0 6px 14px rgba(11, 122, 117, .28); }
.tile .cx-icon svg.i { width: 22px; height: 22px; }
.tile-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.tile-stats div { background: var(--surface-2); border-radius: 12px; padding: 9px 10px; min-width: 0; }
.tile-stats b { display: block; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-stats span { font-size: 11.5px; color: var(--muted); }
.tile-stats .hl { background: var(--brand-soft); }
.tile-stats .hl b { color: var(--brand-strong); }
.tile-edit { position: absolute; top: 12px; left: 12px; }

/* ------------------------------------------------------------ صفحة الدكتور */
.hero {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--r-lg); margin-bottom: 14px; color: #fff;
  background: linear-gradient(135deg, #0d8a83 0%, #0b4f6c 70%, #0b2f4a 100%); position: relative; overflow: hidden;
}
.hero::after { content: ""; position: absolute; inset: auto -40px -60px auto; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .07); }
.hero::before { content: ""; position: absolute; inset: -50px auto auto -30px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255, 255, 255, .05); }
.hero .avatar.lg { background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .25); }
.hero h1 { font-size: 21px; font-weight: 700; }
.hero .h-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.hero .h-meta span { font-size: 12.5px; background: rgba(255, 255, 255, .14); padding: 2px 10px; border-radius: 999px; }
.hero .crumbs, .hero .crumbs a { color: rgba(255, 255, 255, .75); }
.hero-actions { margin-inline-start: auto; position: relative; z-index: 1; display: flex; gap: 6px; }
.hero-actions .icon-btn { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .2); color: #fff; }
@media (min-width: 900px) { .hero { padding: 22px 24px; } .hero h1 { font-size: 26px; } }

.ranges { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 2px 16px; }
.ranges::-webkit-scrollbar { display: none; }
.range {
  flex: none; min-height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 500; font-size: 14px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px;
}
.range.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.range input[type="date"] { border: 0; background: none; padding: 0; width: 128px; font-size: 14px; color: inherit; }
@media (min-width: 900px) { .ranges { margin: 0 0 16px; padding: 2px 0; } }

.doc-layout { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
  .doc-layout.with-form { grid-template-columns: 380px minmax(0, 1fr); align-items: start; }
  .doc-layout .form-col { position: sticky; top: 24px; }
}
.desk-only { display: none; }
@media (min-width: 1100px) { .desk-only { display: block; } .mob-only-1100 { display: none !important; } }

/* ------------------------------------------------------------ نموذج الحجز */
.form { display: grid; gap: 14px; }
.form-2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
label.f, .f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); min-width: 0; }
.f .hint { font-weight: 400; color: var(--muted); }
.f input, .f select, .f textarea {
  width: 100%; min-height: 48px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 13px; font-size: 16px; /* 16px يمنع الزوم التلقائي بالآيفون */ transition: border-color .15s, box-shadow .15s, background .15s;
}
.f textarea { min-height: 84px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.fee-wrap { position: relative; }
.fee-wrap input { padding-left: 52px; font-weight: 600; direction: ltr; text-align: right; }
.fee-wrap .unit { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; font-weight: 500; pointer-events: none; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.quick button { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px dashed var(--line); background: none; font-size: 13px; font-weight: 500; color: var(--text-2); direction: ltr; }
.quick button:hover, .quick button.on { border-style: solid; border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.sources { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.src {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 8px 12px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.src input { position: absolute; opacity: 0; pointer-events: none; }
.src .s-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }
.src .s-ic svg.i { width: 17px; height: 17px; stroke-width: 2; }
.src:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.src:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.err { color: var(--danger); font-size: 13.5px; min-height: 0; }
.err:not(:empty) { background: var(--danger-soft); padding: 9px 12px; border-radius: 10px; }

/* ------------------------------------------------------------ قائمة الحجوزات */
.search { position: relative; }
.search input { width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 40px 0 12px; font-size: 16px; }
.search input:focus { outline: none; border-color: var(--brand); }
.search svg.i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }

.bk-list { display: flex; flex-direction: column; }
.bk {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "av main fee" "av meta act";
  gap: 2px 12px; align-items: center; padding: 13px 2px; border-bottom: 1px solid var(--line-2);
}
.bk:last-child { border-bottom: 0; }
.bk .avatar { grid-area: av; align-self: start; }
.bk .b-main { grid-area: main; min-width: 0; }
.bk .b-main b { font-weight: 600; font-size: 15.5px; }
.case-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%; margin-top: 4px; padding: 3px 10px 3px 9px;
  border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text);
  background: color-mix(in srgb, var(--cc) 14%, var(--surface)); border-inline-start: 3px solid var(--cc);
}
.case-chip svg.i { width: 14px; height: 14px; color: var(--cc); flex: none; }
.case-chip.none { --cc: var(--line); background: none; border: 1px dashed var(--line); color: var(--muted); font-weight: 500; }
.case-chip.none svg.i { color: var(--muted); }
.bk .b-case { color: var(--text-2); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk .b-meta { grid-area: meta; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 4px; }
.bk .b-fee { grid-area: fee; font-weight: 700; font-size: 15px; white-space: nowrap; align-self: start; }
.bk .b-act { grid-area: act; display: flex; gap: 6px; justify-self: end; }
@media (min-width: 900px) {
  .bk { grid-template-columns: auto minmax(0, 1.4fr) minmax(0, 1fr) 110px auto; grid-template-areas: "av main meta fee act"; padding: 12px 4px; }
  .bk .b-meta { margin-top: 0; }
  .bk .b-fee { align-self: center; text-align: left; }
}
.day-head { position: sticky; top: 60px; z-index: 2; display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 2px 6px; background: var(--surface); border-bottom: 1px solid var(--line-2); }
@media (min-width: 900px) { .day-head { top: 0; } }

/* ------------------------------------------------------------ الرسوم */
.chart-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .chart-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }

/* ألوان الحالات (أول 6 حالات، والباقي رمادي) */
:root { --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #008300; --c-rest: #98a2b3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c-rest: #5b6676; } }
:root[data-theme="dark"] { --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c-rest: #5b6676; }
.legend details { border-bottom: 1px solid var(--line-2); }
.legend details:last-child { border-bottom: 0; }
.legend summary { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 10px; align-items: center; padding: 9px 0; font-size: 14px; cursor: pointer; list-style: none; min-height: 44px; }
.legend summary::-webkit-details-marker { display: none; }
.legend summary .chev { width: 16px; height: 16px; color: var(--muted); transition: transform .2s; }
.legend details[open] summary .chev { transform: rotate(-90deg); }
.legend summary .c-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-pts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 19px 12px 0; }
.case-pts .tag { gap: 6px; }
.case-pts .tag .note { font-size: 11.5px; }
.stack { display: flex; gap: 2px; height: 16px; border-radius: 4px; overflow: hidden; background: var(--surface); }
.stack i { display: block; height: 100%; min-width: 4px; transition: opacity .15s; }
.stack i:first-child { border-radius: 0 4px 4px 0; }
.stack i:last-child { border-radius: 4px 0 0 4px; }
.stack:hover i { opacity: .55; }
.stack i:hover { opacity: 1; }
.legend { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; }
.legend li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.legend li:last-child { border-bottom: 0; }
.legend .l-n { font-weight: 700; font-variant-numeric: tabular-nums; }
.legend .l-p { color: var(--muted); font-size: 12.5px; width: 42px; text-align: left; font-variant-numeric: tabular-nums; }

.bars { position: relative; height: 170px; display: flex; align-items: flex-end; gap: 2px; padding: 0 0 0 30px; direction: ltr; }
.bars .grid-l { position: absolute; left: 30px; right: 0; height: 1px; background: var(--line-2); }
.bars .grid-l span { position: absolute; left: -30px; top: -8px; width: 24px; text-align: right; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bars .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; z-index: 1; outline: none; }
.bars .col i { display: block; width: 100%; max-width: 22px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; transition: opacity .15s; }
.bars .col.today i { background: var(--brand-strong); }
.bars:hover .col i { opacity: .5; }
.bars .col:hover i, .bars .col:focus i { opacity: 1; }
.bars .col.zero i { background: var(--line); }
.x-labels { display: flex; gap: 2px; padding-left: 30px; direction: ltr; margin-top: 6px; }
.x-labels span { flex: 1; text-align: center; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.baseline { height: 1px; background: var(--line); margin-left: 30px; }

#tip {
  position: fixed; z-index: 90; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12.5px; line-height: 1.5;
  padding: 7px 11px; border-radius: 9px; white-space: pre-line; box-shadow: var(--shadow-lg); transform: translate(-50%, calc(-100% - 10px));
}

/* ------------------------------------------------------------ المستخدمين */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 2px 16px; }
.tabs::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .tabs { margin: 0 0 14px; padding: 2px 0; } }
.tabs button { flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.tabs button span { font-size: 12px; color: var(--muted); }
.tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.tabs button.on span { color: inherit; opacity: .7; }
.user-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; }
.user-card .u-text { flex: 1; min-width: 0; }
.user-card .u-text b { font-weight: 600; }
.user-card .u-scope { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.user-card.inactive { opacity: .62; }

.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role-opt { position: relative; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.role-opt input { position: absolute; opacity: 0; }
.role-opt b { font-size: 14px; }
.role-opt span { font-size: 12px; color: var(--muted); line-height: 1.4; }
.role-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.perm-group { margin-top: 4px; }
.perm-group h4 { font-size: 12px; color: var(--muted); font-weight: 600; margin: 10px 0 4px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; padding: 4px 0; border-bottom: 1px solid var(--line-2); font-size: 14.5px; cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(-18px); }
.switch input:focus-visible + i { outline: 2px solid var(--brand); outline-offset: 2px; }
.pick-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-size: 14px; background: var(--surface); }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.section-t { font-size: 13px; font-weight: 700; color: var(--text); margin: 18px 0 8px; display: flex; align-items: center; gap: 6px; }
.section-t svg.i { width: 16px; height: 16px; color: var(--brand); }

/* ------------------------------------------------------------ النوافذ: ورقة سفلية بالهاتف */
.sheet-back { position: fixed; inset: 0; z-index: 60; background: rgba(6, 14, 24, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet {
  width: 100%; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; background: var(--surface);
  border-radius: 24px 24px 0 0; padding: 8px 16px calc(20px + var(--safe-b)); animation: up .28s cubic-bezier(.2, .9, .3, 1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; position: sticky; top: -8px; background: var(--surface); padding: 6px 0; z-index: 2; }
.sheet-head h3 { font-size: 18px; font-weight: 700; }
.sheet-foot { position: sticky; bottom: calc(-20px - var(--safe-b)); background: var(--surface); padding: 12px 0 calc(4px + var(--safe-b)); margin-top: 16px; display: flex; gap: 8px; border-top: 1px solid var(--line-2); }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@media (min-width: 700px) {
  .sheet-back { align-items: center; padding: 24px; }
  .sheet { max-width: 600px; border-radius: 22px; padding: 18px 22px 22px; animation: rise .22s ease-out; box-shadow: var(--shadow-lg); }
  .sheet .grab { display: none; }
  .sheet-foot { bottom: -22px; padding-bottom: 6px; }
  @keyframes rise { from { transform: translateY(14px); opacity: 0; } }
}

.toast {
  position: fixed; z-index: 95; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 86px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px;
  font-weight: 500; box-shadow: var(--shadow-lg); animation: rise2 .25s ease-out; white-space: nowrap;
}
.toast svg.i { color: #34d399; }
@keyframes rise2 { from { transform: translate(-50%, 10px); opacity: 0; } }
@media (min-width: 900px) { .toast { bottom: 28px; left: calc(50% - var(--side-w) / 2); } }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .e-ic { width: 60px; height: 60px; border-radius: 20px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty .e-ic svg.i { width: 28px; height: 28px; }
.empty b { display: block; color: var(--text); font-size: 15.5px; margin-bottom: 2px; }

.skel { border-radius: var(--r); background: linear-gradient(90deg, var(--line-2), var(--surface-2), var(--line-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------ الدخول */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; background: var(--bg); }
.login-brand {
  position: relative; overflow: hidden; color: #fff; padding: calc(36px + env(safe-area-inset-top, 0px)) 24px 70px;
  background: linear-gradient(150deg, #0e9a91 0%, #0b5b74 55%, #0a2540 100%);
}
.login-brand::before {
  content: ""; position: absolute; inset: 0; opacity: .5;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .16) 1px, transparent 0); background-size: 22px 22px;
  mask-image: linear-gradient(180deg, #000, transparent 85%); -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%);
}
.login-brand .ring { position: absolute; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .14); }
.login-brand .logo { position: relative; }
.login-brand .logo svg { width: 52px; height: 52px; filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .25)); }
.login-brand .wordmark b { font-size: 26px; }
.login-brand h2 { position: relative; font-size: 22px; font-weight: 700; margin-top: 26px; max-width: 420px; }
.login-brand p { position: relative; color: rgba(255, 255, 255, .78); margin: 8px 0 0; max-width: 420px; font-size: 14.5px; }
.feats { position: relative; list-style: none; padding: 0; margin: 24px 0 0; display: none; gap: 12px; }
.feats li { display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: rgba(255, 255, 255, .9); }
.feats li i { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: rgba(255, 255, 255, .12); }
.login-form-wrap { padding: 0 16px 32px; margin-top: -44px; position: relative; }
.login-card { max-width: 420px; margin: 0 auto; background: var(--surface); border-radius: var(--r-lg); padding: 24px 20px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.login-card h1 { font-size: 21px; font-weight: 700; }
.login-card form { display: grid; gap: 14px; margin-top: 18px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-left: 48px; }
.pw-wrap button { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
@media (min-width: 900px) {
  .login { grid-template-rows: none; grid-template-columns: minmax(0, 1.1fr) minmax(420px, 1fr); }
  .login-brand { display: flex; flex-direction: column; justify-content: center; padding: 56px; }
  .login-brand h2 { font-size: 32px; margin-top: 40px; }
  .feats { display: grid; }
  .login-form-wrap { margin: 0; display: grid; place-items: center; padding: 40px; }
  .login-card { width: 100%; box-shadow: none; border: 0; background: transparent; padding: 0; }
  .login-card h1 { font-size: 26px; }
}

/* ------------------------------------------------------------ قائمة الحساب (هاتف) */
.acct-head { display: flex; align-items: center; gap: 12px; padding: 4px 0 14px; border-bottom: 1px solid var(--line-2); margin-bottom: 8px; }
.menu-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 0 4px; border: 0; background: none; border-bottom: 1px solid var(--line-2); font-size: 15.5px; text-align: right; }
.menu-row:last-child { border-bottom: 0; }
.menu-row svg.i { color: var(--text-2); }
.menu-row.danger, .menu-row.danger svg.i { color: var(--danger); }
.menu-row .r-end { margin-inline-start: auto; color: var(--muted); font-size: 13px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-inline-start: auto; }
.seg button { border: 0; background: none; min-height: 34px; padding: 0 12px; border-radius: 9px; font-size: 13px; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.f input[dir="ltr"] { text-align: left; }
