/* ═══ نظام إدارة عيادات الأسنان — الطبقة المشتركة ═══
   RTL هو الأصل، لا ترجمة لواجهة إنجليزية. */

:root {
  color-scheme: light;
  --bg: #f4f6f6;
  --surface: #ffffff;
  --surface-2: #fafbfb;
  --line: #dfe4e4;
  --line-soft: #ecefef;
  --text: #16211f;
  --muted: #586866;   /* كان #6b7b78 — 4.09 على --bg، ساقط */
  --faint: #697270;   /* كان #9aa8a5 — 2.27 على --bg، غير مقروء */

  --brand: #14716a;
  --brand-soft: #e6f2f0;
  --brand-ink: #0d504b;

  --ok: #287c47;
  --ok-soft: #e6f4ea;
  --warn: #99640f;
  --warn-soft: #fdf3e0;
  --danger: #c0392f;
  --danger-soft: #fdecea;
  --info: #2b6cb0;
  --info-soft: #e8f0fa;

  /* حدّ أقوى للعناصر التفاعلية — --line زخرفي (1.28:1) ولا يصلح لحدود الحقول */
  --line-strong: #828a88;
  --hatch: #3d3d3d;              /* تظليل السن المخلوع */
  --scrim: rgba(10,20,18,.5);    /* ستارة الحوار */
  /* حبر فوق الخلفيات الملوّنة — الأبيض الثابت كان يسقط في الغامق */
  --on-brand: #fff; --on-ok: #fff; --on-warn: #fff; --on-danger: #fff;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16,33,31,.06), 0 4px 14px rgba(16,33,31,.05);
  --shadow-lg: 0 8px 40px rgba(16,33,31,.16);
  --sans: "SF Arabic", "Geeza Pro", "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", "Tajawal", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;            /* يصلح select والتاريخ وأشرطة التمرير والملء التلقائي */
  --bg: #0f1614;
  --surface: #16201e;
  --surface-2: #1b2624;
  --line: #263331;
  --line-soft: #1f2c2a;
  --text: #e6ecea;
  --muted: #93a5a1;
  --faint: #7d8f8b;   /* كان #6c7e7a — 3.63 على --surface، ساقط */
  --brand: #35a89e;
  --brand-soft: #16302e;
  --brand-ink: #7fd8ce;
  --ok: #4caf6e; --ok-soft: #16301f;
  --warn: #d9a13c; --warn-soft: #302713;
  --danger: #e06a5e; --danger-soft: #341c19;
  --info: #6ba3e0; --info-soft: #16232f;
  --line-strong: #5e706d;
  --hatch: #9fb0ac;
  --scrim: rgba(0,0,0,.72);
  --on-brand: #0f1614; --on-ok: #0f1614; --on-warn: #0f1614; --on-danger: #0f1614;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;              /* لا تمرير أفقي للصفحة أبداً */
}

/* لا رقم ولا تاريخ ولا مُعرّف يُكسر أبداً */
.num, .date, .mono, .slug, td .num, .money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .9em; }

h1,h2,h3,h4 { margin: 0; font-weight: 700; line-height: 1.35; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.12rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .6em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── الأزرار ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s;
}
/* ⚠️ border-color هنا كانت بلا قيد، فكل صنف لا يعيد تعريفها في hover كان
   يفقد إطاره: «إيقاف» الأحمر يصير رماديًا، و«ghost» يكتسب إطارًا من العدم. */
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:not(.btn-primary):not(.btn-ok):not(.btn-ok-soft):not(.btn-danger):not(.btn-ghost):hover:not(:disabled) {
  border-color: var(--muted);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
/* a.btn كان يرث underline من a:hover ولا يطابق :disabled أبداً */
.btn, .btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover:not(:disabled) { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: var(--on-ok); }
.btn-ok:hover:not(:disabled) { filter: brightness(.92); background: var(--ok); border-color: var(--ok); }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 11px 22px; font-size: .95rem; }
.btn-block { width: 100%; }

/* ⚠️ عرض واحد لكل أزرار الصف — لا الزر ولا الشارة ولا القائمة تأخذ عرضها من نصها.
   المسار الثابت (لا min-width) هو ما يجعل الخانات تتراصّ في أعمدة مستقيمة
   **عبر الصفوف** لا داخل الصف الواحد فقط.
   القياس: أعرض نص مستخدم «تشغيل مؤقت» = 67.3px بخط SF Arabic و70.0px بـ
   system-ui عند .8rem/600، + 16px حشو + 2px حد = 88px ⇒ المسار 96px بهامش 8px.
   أي نص أطول من 78px يُختصر، ولا يُوسَّع المسار له. */
:root {
  --act-w: 96px;        /* مسار الزر النصّي */
  --act-icon-w: 34px;   /* مسار زر الأيقونة */
  --act-gap: 6px;
}

.row-actions {
  display: flex; gap: var(--act-gap);
  justify-content: flex-end; align-items: center;
}
/* كل ساكن في الشريط يأخذ نفس المسار — زرًا كان أو شارة أو قائمة أو خانة محجوزة */
.row-actions > .btn,
.row-actions > .badge,
.row-actions > select,
.row-actions > .act-slot {
  flex: 0 0 var(--act-w);
  min-width: 0;
}
.row-actions > .btn   { padding-inline: 8px; }
.row-actions > .badge { justify-content: center; }
.row-actions > select { width: auto; padding: 5px 8px; font-size: .8rem; }
/* خانة محجوزة مكان زر مخفي — تحفظ رقم العمود ولا تَظهر */
.row-actions > .act-slot { align-self: stretch; }
/* زر أيقونة: مسار ضيّق ثابت، يبقى محاذيًا لأنه في نفس الترتيب بكل صف */
.row-actions > .btn-icon { flex-basis: var(--act-icon-w); padding-inline: 0; font-size: 1rem; }

/* مفتاح الحالة: إيقاف أحمر مفرّغ · تشغيل أخضر مفرّغ — يُقرآن كمفتاح واحد بحالتين */
.btn-ok-soft { background: var(--surface); border-color: var(--ok); color: var(--ok); }
.btn-ok-soft:hover:not(:disabled) { background: var(--ok-soft); border-color: var(--ok); }

/* حالات الزر — كانت ناقصة على كل الأصناف */
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:active:not(:disabled) { transform: translateY(1px); }

/* ── الحقول ──────────────────────────────────────────────────────────── */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: .9rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); transition: border-color .12s, box-shadow .12s;
}
/* الحقل المعطَّل كان مطابقًا تمامًا للمفعَّل */
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2); color: var(--muted); border-color: var(--line); cursor: not-allowed;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
input[type="checkbox"] { width: auto; accent-color: var(--brand); }
textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
.hint { font-size: .78rem; color: var(--faint); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 680px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── البطاقات ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
}
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

/* ── الجداول ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.data th {
  text-align: right; padding: 10px 12px; font-size: .75rem; font-weight: 700;
  color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.actions { width: 1%; }

/* 🔴 عمود الأفعال آخر عمود، وفي RTL هو أقصى اليسار — أول ما يخرج عن الشاشة
   عند التمرير الأفقي. قِسنا على 1024px: ثلاثة أزرار من أربعة عند left سالب،
   أي غير قابلة للوصول أصلاً. التثبيت يُبقيها في مكانها والأعمدة تتزحلق تحتها،
   بلا إخفاء زر ولا تغيير نقطة التحوّل. */
table.data td.actions,
table.data:has(td.actions) thead th:last-child {
  position: sticky; inset-inline-end: 0; z-index: 1;
  background: var(--surface);
  border-inline-start: 1px solid var(--line-soft);
}
table.data:has(td.actions) thead th:last-child { background: var(--surface-2); }
table.data tbody tr:hover td.actions { background: var(--surface-2); }

/* ── الشارات ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
  border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-soft);
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }

/* الشارة داخل شريط الأفعال تأخذ مسارًا (انظر .row-actions > .badge) — أما شارات
   أعمدة الجدول فتُترك بحجم محتواها عمدًا: توحيد عرضها يضيف ~103px لعرض الجدول
   فيدفعه للفيضان على 1280 ويجعل العمود المثبّت يغطّي عمودًا كاملًا. قِسناه. */
.day-item > .badge { min-width: 92px; justify-content: center; }

/* ── الحوارات ─── لا prompt ولا confirm ولا alert في منتج تسلّمه ────── */
.overlay {
  position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
  animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0 } }
.modal {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column;
  animation: rise .16s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { transform: translateY(10px); opacity: 0 } }
.modal.wide { max-width: 860px; }
.modal-head {
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  padding: 13px 18px; border-top: 1px solid var(--line-soft);
  display: flex; gap: 8px; justify-content: flex-start;
}
.x-btn {
  border: none; background: transparent; color: var(--faint); cursor: pointer;
  font-size: 1.3rem; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.x-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── التنبيهات ───────────────────────────────────────────────────────── */
.alert {
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: .87rem;
  border: 1px solid transparent; margin-bottom: 12px;
}
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-info { background: var(--info-soft); color: var(--info); }

/* شريط التنبيه الطبي — طبيب يحقن مخدراً لمريض حساسية = كارثة */
.medical-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--danger); color: var(--on-danger); padding: 9px 15px;
  font-weight: 700; font-size: .87rem; border-radius: var(--radius-sm); margin-bottom: 14px;
}
.medical-bar .chip {
  background: var(--surface); color: var(--danger);
  padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700;
}

/* ── التبويبات ───────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  border: none; background: transparent; padding: 10px 15px; cursor: pointer;
  font: inherit; font-size: .875rem; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .count {
  margin-inline-start: 5px; font-size: .72rem; background: var(--surface-2);
  padding: 1px 7px; border-radius: 999px; color: var(--muted);
}
.tabs button.on .count { background: var(--brand-soft); color: var(--brand-ink); }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills button {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  padding: 5px 13px; border-radius: 999px; cursor: pointer; font: inherit;
  font-size: .8rem; font-weight: 600;
}
.pills button.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* ── أدوات ───────────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .82rem; }
.tiny { font-size: .75rem; }
.bold { font-weight: 700; }
.center { text-align: center; }
.empty { padding: 42px 20px; text-align: center; color: var(--faint); }
.empty .big { font-size: 2rem; margin-bottom: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .label { font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.stat .value { font-size: 1.5rem; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .75rem; color: var(--faint); margin-top: 2px; }
.stat.accent { border-inline-start: 3px solid var(--brand); }
.stat.ok .value { color: var(--ok); }
.stat.danger .value { color: var(--danger); }
.stat.warn .value { color: var(--warn); }

.spinner {
  width: 18px; height: 18px; border: 2px solid var(--line-strong);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.toast-host {
  position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: .87rem; font-weight: 600; max-width: 400px;
  animation: rise .18s ease;
}
.toast.err { background: var(--danger); color: var(--on-danger); }
.toast.ok { background: var(--ok); color: var(--on-ok); }


/* ── قوائم مفتاح/قيمة · أعمدة · بيانات الدخول (مشتركة بين التطبيقين) ─── */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; font-size: .875rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

.cred-box {
  background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius-sm);
  padding: 14px; display: grid; grid-template-columns: max-content 1fr max-content;
  gap: 8px 12px; align-items: center; font-size: .9rem;
}
.cred-box .k { color: var(--muted); font-weight: 600; }
.cred-box .v { font-family: var(--mono); font-weight: 700; word-break: break-all; }

/* ── الموبايل: الصف يصير بطاقة، وكل حد أدنى يُلغى ────────────────────
   ⚠️ جدول يتزحلق أفقياً على الموبايل = أزرار خارج الشاشة. البطاقة تُلغي
   الحاجة للتمرير الأفقي أصلاً، والأزرار تتقاسم العرض بالتساوي. */
/* ══ تجاوب: بنية ══════════════════════════════════════════════════════ */
/* عمود الشبكة حدّه الأدنى auto — بدون هذا تُثبَّت صفحة العيادة على 1562px */
.two-col > * { min-width: 0; }
/* بلا media query: الفيض قائم من 1001 إلى 1561 لا على الموبايل وحده */
.audit-row { flex-wrap: wrap; }
.audit-row > * { min-width: 0; overflow-wrap: anywhere; }
.content { margin-inline: auto; }
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.modal.wide { max-width: min(1100px, 92vw); }

/* الحوار يبقى في الوسط حين يتّسع، ويتمرّر حين لا يتّسع */
.overlay { overflow-y: auto; align-items: flex-start; }
.modal { margin-block: auto; max-height: 90vh; max-height: 90dvh; }

table.data td.detail {
  max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 1100px) { .tabs { flex-wrap: wrap; overflow-x: visible; } }

/* ── زر المظهر والدليل فوق شاشات الدخول ──────────────────────────────── */
.theme-btn { display: inline-flex; align-items: center; gap: 5px; }
.login-page { position: relative; }
.login-topbar {
  position: absolute; top: 14px; inset-inline-end: 16px;
  display: flex; gap: 6px; z-index: 3;
}

@media (max-width: 1024px) {
  /* البطاقة فقط للجداول ذات عمود أزرار — جداول الأرقام تحتاج عناوين أعمدتها
     فتظل جدولاً يتزحلق أفقياً، وهذا مقبول لأن لا أزرار فيها تخرج عن الشاشة. */
  .table-wrap:has(td.actions) { overflow-x: visible; }
  table.data:has(td.actions) thead { display: none; }
  table.data:has(td.actions),
  table.data:has(td.actions) tbody,
  table.data:has(td.actions) tr,
  table.data:has(td.actions) td { display: block; width: auto; }
  table.data:has(td.actions) tr {
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); padding: 11px 13px; margin-bottom: 9px;
  }
  table.data:has(td.actions) tbody tr:hover { background: var(--surface); }
  table.data:has(td.actions) td { border: none; padding: 3px 0; }
  table.data:has(td.actions) td:empty { display: none; }
  table.data:has(td.actions) td.actions {
    width: auto; margin-top: 9px; padding-top: 9px;
    border-top: 1px solid var(--line-soft);
  }
  /* داخل البطاقة: شبكة تلتفّ بأعمدة متساوية بدل flex الذي يمطّ آخر سطر.
     (flex-basis:0 كان يقصّ «تشغيل مؤقت» بـ 16px على 320px؛ والالتفاف بـ flex
     كان يترك زرًا بعرض 244px وآخر يتيمًا في سطره.) */
  .row-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--act-w), 1fr));
    gap: var(--act-gap);
  }
  .row-actions > .btn,
  .row-actions > .badge,
  .row-actions > select,
  .row-actions > .btn-icon { flex: none; width: auto; }
  .row-actions > .act-slot { display: none; }  /* كل بطاقة مستقلة — لا محاذاة عبر الصفوف */
  table.data td.actions { position: static; border-inline-start: none; }
}

/* ── الطباعة ─────────────────────────────────────────────────────────── */
@media print {
  /* الطباعة من الوضع الغامق كانت تُخرج نصًا فاتحًا على ورق أبيض (1.20:1).
     نفرض اللوحة الورقية على الجذر مهما كان الثيم. */
  :root, [data-theme="dark"] {
    color-scheme: light;
    --bg: #fff; --surface: #fff; --surface-2: #fff;
    --text: #16211f; --muted: #586866; --faint: #697270;
    --line: #ccc; --line-soft: #ddd; --line-strong: #888; --hatch: #3d3d3d;
    --brand: #14716a; --ok: #287c47; --warn: #99640f; --danger: #c0392f; --info: #2b6cb0;
    --on-brand: #fff; --on-ok: #fff; --on-warn: #fff; --on-danger: #fff;
  }
  html, body { background: #fff !important; color: var(--text) !important; }
  .no-print, .sidebar, .topbar, .tabs, .row-actions, .login-topbar { display: none !important; }
  .card { box-shadow: none; border-color: #ccc; }
  .print-only { display: block !important; }

  /* الخلفيات الحاملة للمعنى لا تُطبع افتراضيًا — خريطة الأسنان والرسم البياني
     كانا يخرجان فارغين تمامًا. */
  .surf, .tooth-box.whole::after, .tooth-box.missing::after,
  .bar-chart .bar, .badge, .appt, .legend-swatch, .cond-dot {
    print-color-adjust: exact; -webkit-print-color-adjust: exact;
  }
  .bar-chart .bar { outline: 1px solid #16211f; outline-offset: -1px; }
  .medical-bar, .impersonate-bar {
    background: #fff !important; color: #c0392f !important; border: 2px solid #c0392f;
  }
  .medical-bar .chip { background: #fff; border: 1px solid #c0392f; color: #c0392f; }
}
.print-only { display: none; }

/* ══ الموبايل الضيّق ══════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .tabs {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 26px), transparent);
            mask-image: linear-gradient(to left, #000 calc(100% - 26px), transparent);
  }
  .tabs button { scroll-snap-align: start; }
  .audit-row .when { margin-inline-start: 0; }
  table.data td.detail { max-width: none; white-space: normal; overflow-wrap: anywhere; }
}

@media (max-width: 430px) {
  /* ١٦px بالضبط: أقل منها يكبّر iOS الصفحة تلقائيًا ولا يرتدّ */
  input, select, textarea { font-size: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 1.2rem; }
  .cred-box { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .cred-box .k { grid-column: 1 / -1; margin-bottom: -6px; }
  .row-actions { --act-gap: 10px; }
  /* الشريط كان يتراكب مع البطاقة حين يظهر زر «جرّب».
     و static وحدها لا تكفي: .login-page صفّ flex، فيقف الشريط **بجوار**
     البطاقة ويفيض 25px. قلب المحور يضعه فوقها. */
  .login-page { flex-direction: column; align-items: stretch; justify-content: flex-start; }
  .login-topbar { position: static; justify-content: flex-end; padding: 10px 16px 0; }
  .login-card { margin-inline: auto; }
}

/* ══ أهداف اللمس — بنوع المؤشّر لا بالعرض ═════════════════════════════
   الآيباد العرضي 1024px وهو لمسي، ونافذة لابتوب ضيّقة 900px وهي بمؤشّر دقيق.
   الربط بالعرض يعطي أزرارًا صغيرة على الأول وضخمة على الثاني. */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 44px; min-width: 44px; padding: 10px 12px; }
  .x-btn { min-width: 44px; min-height: 44px; padding: 0;
           display: inline-flex; align-items: center; justify-content: center; }
  .tabs button { min-height: 44px; }
  .pills button { min-height: 44px; padding: 10px 14px; }
  select { min-height: 44px; }
  input[type="checkbox"] { width: 22px; height: 22px; }
  label.field:has(> input[type="checkbox"]),
  label:has(> input[type="checkbox"]) { min-height: 44px; display: flex; align-items: center; gap: 8px; }
  table.data td a { display: inline-flex; align-items: center; justify-content: center;
                    min-width: 44px; min-height: 44px; margin-block: -6px; }
}

/* اللمس لا يملك :hover — بديل واضح عند الضغط */
.surf:active, .tooth-box:active, .cond-btn:active, .nav-item:active,
.result-item:active, .day-item.clickable:active, .appt:active,
.tabs button:active, .pills button:active, .x-btn:active {
  background: var(--surface-2); outline: 2px solid var(--brand); outline-offset: -2px;
}
