/* ==========================================================================
   ClinicCore — نظام التصميم (RTL، فاتح/غامق)
   كل الألوان والمسافات من المتغيرات أدناه؛ لا ألوان مكتوبة داخل الصفحات.
   ========================================================================== */

@font-face { font-family: "Cairo"; font-weight: 400; font-display: swap; src: url("fonts/cairo-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Cairo"; font-weight: 500; font-display: swap; src: url("fonts/cairo-arabic-500-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Cairo"; font-weight: 600; font-display: swap; src: url("fonts/cairo-arabic-600-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Cairo"; font-weight: 700; font-display: swap; src: url("fonts/cairo-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Cairo"; font-weight: 800; font-display: swap; src: url("fonts/cairo-arabic-800-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Cairo"; font-weight: 400; font-display: swap; src: url("fonts/cairo-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cairo"; font-weight: 500; font-display: swap; src: url("fonts/cairo-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cairo"; font-weight: 600; font-display: swap; src: url("fonts/cairo-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cairo"; font-weight: 700; font-display: swap; src: url("fonts/cairo-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cairo"; font-weight: 800; font-display: swap; src: url("fonts/cairo-latin-800-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- المتغيرات ---------- */
:root {
    --font: "Cairo", "Segoe UI", Tahoma, system-ui, sans-serif;

    --brand-50: #ecf8f8; --brand-100: #d0eeee; --brand-200: #a3dcdd; --brand-500: #14868f; --brand-600: #0f6f77; --brand-700: #0c5a61;

    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f8fafb;
    --surface-sunken: #eef2f5;
    --border: #e1e6eb;
    --border-strong: #c9d1d9;
    --text: #17212b;
    --text-2: #4b5966;
    --text-3: #7a8794;
    --primary: var(--brand-600);
    --primary-hover: var(--brand-700);
    --primary-soft: var(--brand-50);
    --primary-ring: rgba(20, 134, 143, .28);
    --on-primary: #ffffff;

    --success: #15803d; --success-soft: #e8f6ed;
    --warning: #b45309; --warning-soft: #fdf3e2;
    --danger: #c0262d;  --danger-soft: #fdecec;
    --info: #1d5fbf;    --info-soft: #e9f1fc;

    --sidebar-bg: #0f2a33;
    --sidebar-text: #c4d3d9;
    --sidebar-muted: #7f98a2;
    --sidebar-active: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, .09);
    --sidebar-accent: #5fd3d9;

    --radius-sm: 6px; --radius: 10px; --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
    --sidebar-w: 256px; --topbar-h: 60px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0e151b;
    --surface: #151f27;
    --surface-2: #1a252e;
    --surface-sunken: #111a21;
    --border: #26333d;
    --border-strong: #34434f;
    --text: #e6edf2;
    --text-2: #a9b6c1;
    --text-3: #7d8b97;
    --primary: #2bb0b8;
    --primary-hover: #49c3ca;
    --primary-soft: rgba(43, 176, 184, .12);
    --primary-ring: rgba(43, 176, 184, .35);
    --on-primary: #06262a;
    --success: #4ade80; --success-soft: rgba(74, 222, 128, .12);
    --warning: #fbbf24; --warning-soft: rgba(251, 191, 36, .12);
    --danger: #f87171;  --danger-soft: rgba(248, 113, 113, .12);
    --info: #7cb1ff;    --info-soft: rgba(124, 177, 255, .12);
    --sidebar-bg: #0a1116;
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

/* ---------- الأساس ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* ---------- الإطار العام ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.shell.collapsed { --sidebar-w: 72px; }

.sidebar { position: sticky; top: 0; height: 100vh; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; overflow: hidden; transition: width .2s var(--ease); width: var(--sidebar-w); z-index: 30; }
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 0 1.1rem; height: var(--topbar-h); color: #fff; font-weight: 800; font-size: 1.1rem; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #1aa3ac, #0c5a61); color: #fff; flex: none; }
.brand-mark .icon { width: 20px; height: 20px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem .6rem 1rem; scrollbar-width: thin; scrollbar-color: #2a4350 transparent; }
.nav-group { margin-top: 1rem; }
.nav-group-title { font-size: .72rem; font-weight: 700; color: var(--sidebar-muted); padding: 0 .75rem .35rem; letter-spacing: .02em; white-space: nowrap; }
.nav-link { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; margin: 1px 0; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; font-size: .93rem; white-space: nowrap; position: relative; transition: background .15s, color .15s; }
.nav-link:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }
.nav-link.active::before { content: ""; position: absolute; inset-inline-start: -.6rem; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--sidebar-accent); }
.nav-link .icon { width: 19px; height: 19px; opacity: .9; }
.nav-soon { margin-inline-start: auto; font-size: .66rem; padding: 0 .4rem; border-radius: 99px; background: rgba(255, 255, 255, .08); color: var(--sidebar-muted); }
.shell.collapsed .nav-group-title, .shell.collapsed .nav-link span, .shell.collapsed .nav-soon, .shell.collapsed .sidebar-brand span { display: none; }
.shell.collapsed .nav-link { justify-content: center; }
.sidebar-foot { padding: .75rem 1rem; border-top: 1px solid rgba(255, 255, 255, .06); font-size: .75rem; color: var(--sidebar-muted); white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-spacer { flex: 1; }
.content { padding: 1.5rem; max-width: 1480px; width: 100%; margin: 0 auto; flex: 1; }
.workdate-banner { display: flex; align-items: center; gap: .6rem; padding: .55rem 1.25rem; background: var(--warning-soft); color: var(--warning); border-bottom: 1px solid color-mix(in srgb, var(--warning) 25%, transparent); font-weight: 600; font-size: .9rem; }
.workdate-banner .btn { margin-inline-start: auto; }

.backdrop { display: none; }
@media (max-width: 960px) {
    .shell, .shell.collapsed { grid-template-columns: 1fr; --sidebar-w: 268px; }
    .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(100%); transition: transform .22s var(--ease); box-shadow: var(--shadow-lg); }
    .shell.mobile-open .sidebar { transform: none; }
    .shell.mobile-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 25; }
    .shell.collapsed .nav-group-title, .shell.collapsed .nav-link span, .shell.collapsed .nav-soon, .shell.collapsed .sidebar-brand span { display: revert; }
    .content { padding: 1rem; }
    .hide-sm { display: none !important; }
}

/* ---------- عناوين الصفحات ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header .crumbs { font-size: .82rem; color: var(--text-3); margin-bottom: .2rem; display: flex; gap: .35rem; align-items: center; }
.page-header .crumbs a { color: var(--text-3); }
.page-header .crumbs a:hover { color: var(--primary); }
.page-header p { margin: .25rem 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- الأزرار ---------- */
.btn { --b-bg: var(--surface); --b-fg: var(--text); --b-bd: var(--border-strong); display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 38px; padding: 0 1rem; border-radius: 8px; border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; user-select: none; }
.btn:hover { --b-bg: var(--surface-2); color: var(--b-fg); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.btn-primary { --b-bg: var(--primary); --b-fg: var(--on-primary); --b-bd: var(--primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover { --b-bg: var(--primary-hover); --b-bd: var(--primary-hover); }
.btn-danger { --b-bg: var(--danger); --b-fg: #fff; --b-bd: var(--danger); }
.btn-danger:hover { --b-bg: color-mix(in srgb, var(--danger) 88%, #000); }
.btn-soft { --b-bg: var(--primary-soft); --b-fg: var(--primary); --b-bd: transparent; }
.btn-soft:hover { --b-bg: color-mix(in srgb, var(--primary) 16%, transparent); }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; --b-fg: var(--text-2); }
.btn-ghost:hover { --b-bg: var(--surface-sunken); }
.btn-sm { height: 32px; padding: 0 .7rem; font-size: .85rem; border-radius: 7px; }
.btn-lg { height: 46px; padding: 0 1.4rem; font-size: 1rem; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }

/* ---------- البطاقات ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.15rem; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { font-size: 1rem; }
.card-body { padding: 1.15rem; }
.card-footer { padding: .8rem 1.15rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; gap: .9rem; align-items: flex-start; padding: 1.05rem 1.15rem; }
.stat-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.stat-icon .icon { width: 21px; height: 21px; }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-label { color: var(--text-2); font-size: .85rem; font-weight: 500; }
.stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1.25; margin-top: .1rem; }
.stat-sub { font-size: .8rem; color: var(--text-3); margin-top: .15rem; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- الشارات ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-sunken); color: var(--text-2); white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- النماذج ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem 1.1rem; }
.form-grid .span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: .88rem; color: var(--text); }
.field .req { color: var(--danger); margin-inline-start: .15rem; }
.field .hint { font-size: .8rem; color: var(--text-3); }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
    width: 100%; height: 40px; padding: 0 .8rem; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .95rem; transition: border-color .15s, box-shadow .15s; }
.field textarea { height: auto; min-height: 88px; padding: .6rem .8rem; resize: vertical; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--text-3); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.field input[disabled], .field select[disabled] { background: var(--surface-sunken); color: var(--text-3); }
.field .invalid, .field input.invalid, .field select.invalid { border-color: var(--danger); }
.field .invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
.validation-message { color: var(--danger); font-size: .8rem; font-weight: 500; }
.validation-errors { margin: 0 0 1rem; padding: .75rem 1rem .75rem 2rem; background: var(--danger-soft); color: var(--danger); border-radius: var(--radius); list-style: disc inside; }
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 500; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; inset-inline-start: .7rem; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
/* الأيقونة داخل الحقل: نفس المسافة حتى داخل .field (قاعدة .field input أعلى أولوية من .input-icon .input) */
.input-icon .input, .field .input-icon input:not([type=checkbox]):not([type=radio]) { padding-inline-start: 2.4rem; }
.input-icon input[type=search]::-webkit-search-cancel-button { margin-inline: .25rem 0; cursor: pointer; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ---------- التنبيهات داخل الصفحة ---------- */
.alert { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius); font-size: .92rem; border: 1px solid transparent; margin-bottom: 1rem; }
.alert .icon { margin-top: .15rem; }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- جدول البيانات ---------- */
.dg { display: flex; flex-direction: column; }
.dg-toolbar { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.dg-search { flex: 1 1 240px; max-width: 360px; }
.dg-scroll { overflow: auto; position: relative; }
.dg table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.dg thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-2); font-weight: 700; font-size: .82rem; text-align: start; padding: .65rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dg thead th.sortable { cursor: pointer; user-select: none; }
.dg thead th.sortable:hover { color: var(--text); }
.dg thead th .sort { display: inline-flex; vertical-align: middle; margin-inline-start: .25rem; opacity: .35; }
.dg thead th.sorted .sort { opacity: 1; color: var(--primary); }
.dg tbody td { padding: .62rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dg tbody tr { transition: background .1s; }
.dg tbody tr:hover { background: var(--surface-2); }
.dg tbody tr.clickable { cursor: pointer; }
.dg tbody tr.selected { background: var(--primary-soft); }
.dg tbody tr:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.dg tbody tr:last-child td { border-bottom: none; }
.dg tfoot td { padding: .65rem .9rem; font-weight: 800; background: var(--surface-2); border-top: 2px solid var(--border); position: sticky; bottom: 0; }
.dg .end, .dg thead th.end { text-align: end; } .dg .center, .dg thead th.center { text-align: center; }
.dg .tnum { font-variant-numeric: tabular-nums; }
/* عناصر داخل الخلية عليها direction:ltr (مثل .num) تفهم «end» يميناً؛ في الواجهة العربية نهاية العمود = الشمال */
[dir=rtl] .dg .end, [dir=rtl] .dg .end :is(div, b, span, small, a) { text-align: left; }
.dg .actions { white-space: nowrap; text-align: end; width: 1%; }
.dg-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem 1rem; border-top: 1px solid var(--border); font-size: .85rem; color: var(--text-2); flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: .25rem; }
.pager .btn { min-width: 32px; }
.pager .current { --b-bg: var(--primary); --b-fg: var(--on-primary); --b-bd: var(--primary); }
.pager select { height: 32px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; padding: 0 .4rem; margin-inline-end: .5rem; }
.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-sunken), var(--surface-2), var(--surface-sunken)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2.5rem 1rem; color: var(--text-3); gap: .35rem; }
.empty .empty-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-3); margin-bottom: .4rem; }
.empty .empty-icon .icon { width: 24px; height: 24px; }
.empty strong { color: var(--text); font-size: 1rem; }

/* ---------- النوافذ ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(9, 18, 24, .45); z-index: 100; display: grid; place-items: center; padding: 1rem; animation: fade .15s ease-out; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; animation: pop .18s var(--ease); }
.modal.sm { max-width: 420px; } .modal.lg { max-width: 820px; } .modal.xl { max-width: 1100px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1.08rem; }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.confirm-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: .75rem; }
.confirm-icon.danger { background: var(--danger-soft); color: var(--danger); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- الإشعارات ---------- */
.toasts { position: fixed; bottom: 1.25rem; inset-inline-start: 1.25rem; z-index: 200; display: flex; flex-direction: column; gap: .6rem; width: min(380px, calc(100vw - 2.5rem)); }
.toast { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--info); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: pop .2s var(--ease); }
.toast.success { border-inline-start-color: var(--success); } .toast.success .icon:first-child { color: var(--success); }
.toast.warning { border-inline-start-color: var(--warning); } .toast.warning .icon:first-child { color: var(--warning); }
.toast.error { border-inline-start-color: var(--danger); } .toast.error .icon:first-child { color: var(--danger); }
.toast.info .icon:first-child { color: var(--info); }
.toast-body { flex: 1; font-size: .9rem; } .toast-body strong { display: block; }

/* ---------- القوائم المنسدلة ---------- */
.menu { position: relative; }
.menu-panel { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .35rem; z-index: 50; animation: pop .14s var(--ease); }
.menu-item { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .7rem; border: 0; background: none; border-radius: 7px; color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; text-align: start; }
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: .3rem 0; }
.menu-head { padding: .5rem .7rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.menu-head small { color: var(--text-3); display: block; }

.chip-select { display: inline-flex; align-items: center; gap: .45rem; height: 36px; padding: 0 .75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; font-weight: 600; }
.chip-select input, .chip-select select { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; outline: none; }
.chip-select.warn { border-color: color-mix(in srgb, var(--warning) 50%, transparent); background: var(--warning-soft); color: var(--warning); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: .9rem; flex: none; }

/* ---------- مصفوفة الصلاحيات ---------- */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: start; }
.matrix .group-row td { background: var(--surface-sunken); font-weight: 800; color: var(--text-2); font-size: .82rem; }
.matrix input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.matrix .na { color: var(--border-strong); }
.matrix .override td:first-child::after { content: "خاص"; margin-inline-start: .4rem; font-size: .7rem; padding: 0 .4rem; border-radius: 99px; background: var(--warning-soft); color: var(--warning); }

/* ---------- صفحات الحساب ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(1200px 600px at 100% 0%, #1a9aa3 0%, transparent 60%), linear-gradient(160deg, #0c4a52, #0f2a33 70%); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .08); bottom: -180px; left: -160px; box-shadow: 0 0 0 60px rgba(255, 255, 255, .025), 0 0 0 130px rgba(255, 255, 255, .02); }
.auth-art h1 { font-size: 2.1rem; font-weight: 800; margin-top: 2.5rem; max-width: 420px; }
.auth-art p { color: rgba(255, 255, 255, .78); max-width: 420px; font-size: 1.02rem; }
.auth-features { display: grid; gap: .8rem; margin-top: 2rem; color: rgba(255, 255, 255, .88); }
.auth-features div { display: flex; gap: .6rem; align-items: center; }
.auth-panel { display: grid; place-items: center; padding: 2rem; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: .3rem; }
.auth-card .sub { color: var(--text-2); margin-bottom: 1.75rem; }
.auth-card .field { margin-bottom: 1rem; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 2.6rem !important; }
.pw-toggle { position: absolute; inset-inline-end: .35rem; top: 50%; transform: translateY(-50%); }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-art { display: none; } }

/* ---------- متفرقات ---------- */
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mb-2 { margin-bottom: 1rem; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.timeline-item { display: flex; gap: .8rem; padding: .7rem 0; border-bottom: 1px dashed var(--border); }
.timeline-item:last-child { border-bottom: 0; }
.time-pill { font-weight: 700; color: var(--primary); background: var(--primary-soft); border-radius: 7px; padding: .1rem .5rem; font-size: .82rem; height: fit-content; }

#blazor-error-ui { background: var(--danger); color: #fff; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); display: none; left: 0; padding: .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; left: .75rem; top: .5rem; }
#blazor-error-ui a { color: #fff; text-decoration: underline; }

/* ==========================================================================
   مرحلة 3 — التعريفات: تبويبات، مفتاح تشغيل، ألوان، لوحة الأسبوع، محرر العروض
   ========================================================================== */

/* تبويبات */
.tabs { display: flex; gap: .25rem; padding: .35rem; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.tab { display: inline-flex; align-items: center; gap: .45rem; height: 36px; padding: 0 .9rem; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.tab:hover { background: var(--surface-sunken); color: var(--text); }
.tab[aria-selected="true"] { background: var(--primary-soft); color: var(--primary); }
.tab .badge { font-size: .72rem; }
.tab:focus-visible { outline: 2px solid var(--primary-ring); outline-offset: 1px; }

/* مفتاح تشغيل/إيقاف */
.switch { position: relative; display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; user-select: none; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .15s var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: inset-inline-start .15s var(--ease); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { inset-inline-start: 19px; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--primary-ring); }
.switch input:disabled + .track { opacity: .5; }

/* ألوان الأطباء */
.swatches { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); cursor: pointer; padding: 0; position: relative; }
.swatch[aria-pressed="true"] { outline: 2px solid var(--text); outline-offset: 2px; }
.swatch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.swatch-custom { width: 32px; height: 32px; border: 1px dashed var(--border-strong); border-radius: 50%; padding: 0; background: var(--surface); cursor: pointer; overflow: hidden; }
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }

/* لوحة الأسبوع (جداول عمل الأطباء) */
.week { display: grid; grid-template-columns: minmax(170px, 210px) repeat(7, minmax(110px, 1fr)); min-width: 980px; }
.week-head { position: sticky; top: 0; z-index: 2; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: .6rem .7rem; font-weight: 700; font-size: .82rem; color: var(--text-2); }
.week-head.today { color: var(--primary); }
.week-doc { display: flex; align-items: center; gap: .55rem; padding: .7rem; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; inset-inline-start: 0; z-index: 1; }
.week-doc b { display: block; line-height: 1.3; }
.week-doc small { color: var(--text-3); }
.week-cell { border-bottom: 1px solid var(--border); border-inline-start: 1px solid var(--border); padding: .4rem; display: flex; flex-direction: column; gap: .3rem; min-height: 64px; }
.week-cell.off { background: repeating-linear-gradient(-45deg, transparent 0 6px, var(--surface-sunken) 6px 7px); }
.period { display: flex; flex-direction: column; gap: .05rem; padding: .3rem .5rem; border-radius: 7px; font-size: .78rem; line-height: 1.35; background: color-mix(in srgb, var(--c, var(--primary)) 13%, var(--surface)); border-inline-start: 3px solid var(--c, var(--primary)); color: var(--text); }
.period b { font-weight: 700; direction: ltr; unicode-bidi: isolate; text-align: right; }
.period span { color: var(--text-2); font-size: .74rem; }
.period.inactive { opacity: .45; text-decoration: line-through; }

/* محرر فترات الطبيب */
.periods { display: flex; flex-direction: column; gap: .6rem; }
.period-day { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.period-day > header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem .75rem; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.period-day > header b { font-size: .92rem; }
.period-day.empty > header { border-bottom: 0; }
.period-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 1fr 1fr auto auto; gap: .5rem; align-items: center; padding: .5rem .75rem; }
.period-row + .period-row { border-top: 1px dashed var(--border); }
.period-row .input, .period-row select { height: 36px; }
.period-row .dur { font-size: .8rem; color: var(--text-3); white-space: nowrap; min-width: 60px; text-align: center; }
@media (max-width: 640px) { .period-row { grid-template-columns: 1fr 1fr; } .period-row .dur { text-align: start; } }

/* سطور العرض (الخدمات داخل الباقة) */
.lines { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.lines th { text-align: start; font-size: .8rem; color: var(--text-2); font-weight: 700; padding: .45rem .5rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.lines td { padding: .4rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.lines td .input, .lines td select { height: 36px; width: 100%; }
.lines tfoot td { font-weight: 700; background: var(--surface-2); }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.summary > div { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; background: var(--surface-2); }
.summary small { display: block; color: var(--text-3); font-size: .78rem; }
.summary b { font-size: 1.15rem; }
.summary .good b { color: var(--success); }
.summary .bad b { color: var(--danger); }

/* شرائح تصفية فوق الجداول */
.filter-chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: .7rem 1rem 0; }
.fchip { display: inline-flex; align-items: center; gap: .35rem; height: 30px; padding: 0 .75rem; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; }
.fchip:hover { border-color: var(--border-strong); color: var(--text); }
.fchip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.fchip .n { font-size: .74rem; opacity: .8; }

/* إدخال الأرقام والمبالغ */
.money { display: flex; align-items: stretch; }
.money .input { border-start-end-radius: 0; border-end-end-radius: 0; text-align: end; direction: ltr; }
.money .unit { display: inline-flex; align-items: center; padding: 0 .7rem; border: 1px solid var(--border-strong); border-inline-start: 0; border-start-end-radius: 8px; border-end-end-radius: 8px; background: var(--surface-sunken); color: var(--text-2); font-size: .82rem; font-weight: 600; white-space: nowrap; }
.input.num, input.num { direction: ltr; text-align: end; font-variant-numeric: tabular-nums; }
.row-muted { opacity: .55; }
.row-muted td:first-child { text-decoration: none; }
.sort-btns { display: inline-flex; flex-direction: column; }
.sort-btns .btn { height: 18px; width: 26px; padding: 0; }

/* ==========================================================================
   مرحلة 4 — المرضى: بحث سريع، ملف المريض، التكرار
   ========================================================================== */
.combo { position: relative; flex: 1 1 260px; max-width: 420px; }
.combo .input, .field .combo input:not([type=checkbox]):not([type=radio]) { padding-inline-end: 3.6rem; }
.combo kbd { position: absolute; inset-inline-end: .6rem; top: 50%; transform: translateY(-50%); font: inherit; font-size: .7rem; color: var(--text-3); border: 1px solid var(--border); border-radius: 5px; padding: 0 .3rem; background: var(--surface-2); unicode-bidi: isolate; }
.combo-list { position: absolute; top: calc(100% + 6px); inset-inline: 0; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; padding: .3rem; }
.combo-item { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .5rem .6rem; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.combo-item:hover, .combo-item.active { background: var(--primary-soft); }
.combo-item .meta { color: var(--text-3); font-size: .8rem; }
.combo-item mark { background: color-mix(in srgb, var(--warning) 25%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.combo-empty { padding: .9rem; color: var(--text-3); font-size: .88rem; text-align: center; }
.combo-foot { border-top: 1px solid var(--border); margin-top: .3rem; padding-top: .3rem; }
.topbar .combo { max-width: 380px; }
@media (max-width: 960px) { .topbar .combo kbd { display: none; } }

/* رأس ملف المريض */
.profile-head { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem 1.25rem; align-items: center; padding: 1.1rem 1.25rem; }
.profile-head .avatar { width: 64px; height: 64px; font-size: 1.3rem; }
.profile-head h1 { margin: 0; font-size: 1.35rem; line-height: 1.3; }
.profile-meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin-top: .35rem; color: var(--text-2); font-size: .88rem; }
.profile-meta > span { display: inline-flex; align-items: center; gap: .3rem; }
.profile-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
@media (max-width: 900px) { .profile-head { grid-template-columns: auto 1fr; } .profile-actions { grid-column: 1 / -1; justify-content: flex-start; } }

.balance-pill { display: inline-flex; flex-direction: column; align-items: flex-start; padding: .35rem .8rem; border-radius: 10px; background: var(--surface-sunken); font-size: .78rem; color: var(--text-2); line-height: 1.25; }
.balance-pill b { font-size: 1.05rem; color: var(--text); }
.balance-pill.due { background: var(--danger-soft); color: var(--danger); }
.balance-pill.due b { color: var(--danger); }
.balance-pill.credit { background: var(--success-soft); color: var(--success); }
.balance-pill.credit b { color: var(--success); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem 1.5rem; }
.kv > div { min-width: 0; }
.kv dt { font-size: .78rem; color: var(--text-3); margin-bottom: .15rem; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.kv dd.kv-empty { color: var(--text-3); font-weight: 400; }

.money-pos { color: var(--success); }
.money-neg { color: var(--danger); }

.note-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; background: var(--surface); }
.note-card header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.note-card p { margin: 0; white-space: pre-wrap; line-height: 1.7; }
.note-list { display: flex; flex-direction: column; gap: .7rem; padding: 1rem; }

.dup-box { border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent); background: var(--warning-soft); border-radius: var(--radius); padding: .7rem .85rem; }
.dup-box.strong { border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); }
.dup-box h4 { margin: 0 0 .4rem; font-size: .9rem; display: flex; align-items: center; gap: .4rem; }
.dup-row { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; border-top: 1px dashed color-mix(in srgb, var(--warning) 35%, transparent); font-size: .88rem; }
.dup-row:first-of-type { border-top: 0; }
.dup-row .grow { flex: 1; min-width: 0; }

.form-section { grid-column: 1 / -1; display: flex; align-items: center; gap: .5rem; margin-top: .4rem; font-size: .82rem; font-weight: 700; color: var(--text-3); }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.field .ok-hint { color: var(--success); font-size: .8rem; }
.field .warn-hint { color: var(--warning); font-size: .8rem; }
.tab-body { padding: 1rem; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.mini-stat { border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; background: var(--surface); }
.mini-stat small { display: block; color: var(--text-3); font-size: .78rem; }
.mini-stat b { font-size: 1.2rem; }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* ==========================================================================
   مرحلة 5 — الحجوزات: تقويم بالأعمدة، مواعيد، سحب وإفلات
   ========================================================================== */
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.cal-toolbar .date-title { font-weight: 800; font-size: 1.05rem; min-width: 200px; }
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--surface-sunken); gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 600; font-size: .86rem; height: 30px; padding: 0 .8rem; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.doc-chips { display: flex; flex-wrap: wrap; gap: .35rem; padding: .6rem 1rem; border-bottom: 1px solid var(--border); }
.doc-chip { display: inline-flex; align-items: center; gap: .4rem; height: 30px; padding: 0 .7rem; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; color: var(--text); }
.doc-chip .color-dot { width: 10px; height: 10px; }
.doc-chip[aria-pressed="false"] { opacity: .45; }
.doc-chip .n { font-size: .74rem; color: var(--text-3); }

.cal-scroll { overflow: auto; max-height: calc(100vh - 290px); min-height: 360px; position: relative; }
.cal { display: grid; position: relative; min-width: max-content; }
.cal-head { position: sticky; top: 0; z-index: 5; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: .5rem .6rem; min-height: 52px; display: flex; align-items: center; gap: .5rem; border-inline-start: 1px solid var(--border); }
.cal-head .color-dot { width: 10px; height: 28px; border-radius: 4px; }
.cal-head b { display: block; font-size: .88rem; line-height: 1.25; }
.cal-head small { color: var(--text-3); font-size: .74rem; }
.cal-head.today { background: var(--primary-soft); }
.cal-corner { position: sticky; top: 0; inset-inline-start: 0; z-index: 6; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-gutter { position: sticky; inset-inline-start: 0; z-index: 4; background: var(--surface); border-inline-end: 1px solid var(--border); }
.cal-hour { position: absolute; inset-inline: 0; padding-inline: .4rem; font-size: .72rem; color: var(--text-3); transform: translateY(-50%); text-align: center; direction: ltr; }
.cal-col { position: relative; border-inline-start: 1px solid var(--border); background: repeating-linear-gradient(-45deg, var(--surface-2) 0 6px, var(--surface-sunken) 6px 7px); }
.cal-work { position: absolute; inset-inline: 0; background: var(--surface); }
.cal-line { position: absolute; inset-inline: 0; border-top: 1px solid var(--border); pointer-events: none; }
.cal-line.half { border-top-style: dashed; opacity: .55; }
.cal-cell { position: absolute; inset-inline: 0; cursor: pointer; z-index: 1; }
.cal-cell:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.cal-cell:hover::after { content: "+ " attr(data-time); position: absolute; inset-inline-start: .4rem; top: 1px; font-size: .7rem; color: var(--primary); font-weight: 700; unicode-bidi: isolate; }
.cal-cell.drop { background: color-mix(in srgb, var(--primary) 20%, transparent); outline: 2px dashed var(--primary); outline-offset: -2px; }
.cal-cell.readonly { cursor: default; }
.cal-cell.readonly:hover { background: transparent; }
.cal-cell.readonly:hover::after { content: none; }
.cal-now { position: absolute; inset-inline: 0; border-top: 2px solid var(--danger); z-index: 3; pointer-events: none; }
.cal-now::before { content: ""; position: absolute; inset-inline-start: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

.appt { position: absolute; inset-inline: 3px; z-index: 2; border-radius: 7px; padding: .2rem .45rem; overflow: hidden; cursor: pointer; font-size: .76rem; line-height: 1.3;
        background: color-mix(in srgb, var(--c) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); border-inline-start: 4px solid var(--c); color: var(--text);
        box-shadow: var(--shadow-sm); transition: box-shadow .12s, transform .12s; }
.appt:hover { box-shadow: var(--shadow); z-index: 3; }
.appt:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.appt .t { font-weight: 700; direction: ltr; unicode-bidi: isolate; font-size: .72rem; color: var(--text-2); }
.appt .p { font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt .s { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.appt .icons { position: absolute; top: 3px; inset-inline-end: 4px; display: flex; gap: 2px; }
.appt .icons .icon { width: 13px; height: 13px; }
.appt.st-2 { border-inline-start-color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, var(--surface)); }
.appt.st-3 { border-inline-start-color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--surface)); opacity: .8; }
.appt.st-4 { opacity: .45; text-decoration: line-through; background: var(--surface-sunken); border-inline-start-color: var(--text-3); z-index: 1; }
.appt.dragging { opacity: .4; }
.appt.compact { display: flex; align-items: center; gap: .35rem; padding-block: 0; }
.appt.compact .s { display: none; }
.appt.compact .p { display: inline; flex: 1; min-width: 0; }
.appt.compact .icons { position: static; order: 3; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.st-bg-1 { background: var(--info); } .st-bg-2 { background: var(--warning); } .st-bg-3 { background: var(--success); } .st-bg-4 { background: var(--text-3); }
.legend { display: flex; flex-wrap: wrap; gap: .9rem; padding: .5rem 1rem; font-size: .78rem; color: var(--text-2); border-top: 1px solid var(--border); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .35rem; max-height: 220px; overflow: auto; padding: .2rem; }
.slot-btn { height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-weight: 700; font-size: .84rem; cursor: pointer; direction: ltr; color: var(--text); }
.slot-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.slot-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.slot-btn:disabled { background: var(--surface-sunken); color: var(--text-3); text-decoration: line-through; cursor: not-allowed; }
.slot-sep { grid-column: 1 / -1; font-size: .76rem; color: var(--text-3); font-weight: 700; margin-top: .3rem; }

.picked-patient { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.picked-patient .grow { flex: 1; min-width: 0; }
.detail-head { display: flex; gap: .8rem; align-items: center; padding-bottom: .8rem; border-bottom: 1px solid var(--border); margin-bottom: .8rem; }
.status-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .45rem; }
.status-actions .btn[aria-pressed="true"] { outline: 2px solid currentColor; outline-offset: 1px; }
@media print { .sidebar, .topbar, .cal-toolbar, .doc-chips, .legend, .page-actions { display: none !important; } .cal-scroll { max-height: none; overflow: visible; } }
.field .combo, .modal .combo { flex: none; max-width: none; width: 100%; }
bdi.ltr, .ltr-iso { direction: ltr; unicode-bidi: isolate; }

/* ==========================================================================
   مرحلة 6 — خدمات العملاء (الكاشير) والإيصال
   ========================================================================== */
.cashier { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
@media (max-width: 1150px) { .cashier { grid-template-columns: 1fr; } }
.cashier-side { display: flex; flex-direction: column; gap: 1.25rem; position: sticky; top: calc(var(--topbar-h) + 1rem); }
@media (max-width: 1150px) { .cashier-side { position: static; } }
.add-line { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .6rem; align-items: end; padding: 1rem; }
.add-line .what { grid-column: span 3; }
.add-line .sel { grid-column: span 3; display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.add-line .nums { grid-column: span 6; display: grid; grid-template-columns: 90px 1fr 1fr auto auto; gap: .6rem; align-items: end; }
.add-line .line-total { font-weight: 800; font-size: 1.05rem; padding-bottom: .45rem; min-width: 90px; text-align: end; }
.add-line .field > label { font-size: .78rem; color: var(--text-3); }
@media (max-width: 900px) { .add-line .what, .add-line .sel { grid-column: span 6; } .add-line .nums { grid-template-columns: 1fr 1fr; } }
.pkg-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; padding: 1rem; }
.pkg-card { display: flex; align-items: center; gap: .6rem; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: start; font: inherit; color: var(--text); }
.pkg-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.pkg-card .n { margin-inline-start: auto; font-weight: 800; font-size: 1.1rem; color: var(--primary); }
.pay-box { padding: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.pay-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .92rem; }
.pay-row b { font-variant-numeric: tabular-nums; }
.pay-row.big { font-size: 1.15rem; font-weight: 800; padding-top: .55rem; border-top: 1px dashed var(--border-strong); }
.pay-row.due b { color: var(--danger); }
.pay-row.credit b { color: var(--success); }
.pay-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.quick-pay { display: flex; gap: .4rem; flex-wrap: wrap; }
.line-kind { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-sunken); color: var(--text-2); }
.line-kind.k1 { background: var(--primary-soft); color: var(--primary); }
.line-kind.k2 { background: var(--info-soft); color: var(--info); }
.line-kind.k3 { background: var(--warning-soft); color: var(--warning); }
.lines tr.draft td { background: color-mix(in srgb, var(--primary) 4%, var(--surface)); }
.today-q { display: flex; flex-direction: column; }
.today-q button { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; border: 0; border-bottom: 1px solid var(--border); background: transparent; font: inherit; color: var(--text); text-align: start; cursor: pointer; }
.today-q button:hover { background: var(--surface-2); }

/* الإيصال المطبوع */
.receipt { max-width: 420px; margin: 1.5rem auto; background: #fff; color: #111; padding: 1.25rem 1.4rem; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.receipt h1 { font-size: 18px; margin: 0; text-align: center; }
.receipt .center { text-align: center; }
.receipt .muted { color: #555; }
.receipt hr { border: 0; border-top: 1px dashed #999; margin: .6rem 0; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td, .receipt th { padding: 3px 0; text-align: start; vertical-align: top; }
.receipt .amt { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.receipt .tot td { font-weight: 800; font-size: 14px; border-top: 1px solid #333; padding-top: 5px; }
.receipt-actions { display: flex; justify-content: center; gap: .5rem; margin-top: 1rem; }
@media print {
    body { background: #fff !important; }
    .receipt { border: 0; margin: 0 auto; padding: 0; max-width: 80mm; font-size: 12px; }
    .receipt-actions, .toasts { display: none !important; }
    @page { margin: 4mm; }
}
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem; padding: 1rem; }
.photo { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.photo .img { aspect-ratio: 4 / 3; background: var(--surface-sunken); display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.photo .img img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.photo .meta { padding: .5rem .65rem; font-size: .82rem; display: flex; gap: .4rem; align-items: flex-start; }
.photo .meta div { flex: 1; min-width: 0; }
.lightbox img { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: 8px; }
.drop-zone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 1.2rem; text-align: center; color: var(--text-2); position: relative; }
.drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-zone.has { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- أشرطة التوزيع (المصروفات حسب النوع، المستهلكات حسب الطبيب) ---------- */
.bars { display: grid; gap: .35rem; }
.bar-row { display: grid; grid-template-columns: minmax(0, 38%) minmax(50px, 1fr) auto; align-items: center; gap: .75rem; padding: .3rem .5rem; border: 0; background: none; border-radius: var(--radius); text-align: start; font: inherit; color: inherit; cursor: pointer; }
.bar-row:hover { background: var(--surface-2); }
.bar-row[aria-pressed="true"] { background: var(--primary-soft); }
.bar-label { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; border-radius: 99px; background: var(--surface-sunken); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; background: var(--primary); min-width: 2px; }
.bar-value { font-weight: 700; text-align: end; font-size: .9rem; }
@media (max-width: 640px) { .bar-row { grid-template-columns: 1fr auto; } .bar-track { grid-column: 1 / -1; grid-row: 2; } }

/* ==========================================================================
   مرحلة 9 — التقارير
   ========================================================================== */
.report-hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.report-card { display: flex; gap: .9rem; padding: 1.1rem; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.report-card:hover, .report-card:focus-visible { border-color: var(--primary); box-shadow: var(--shadow-md, var(--shadow-sm)); }
.report-card h3 { font-size: 1rem; margin-bottom: .2rem; }
.report-card p { color: var(--text-2); font-size: .85rem; margin: 0; }
.report-filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; padding: .9rem 1.15rem; }
.report-filters .spacer { margin-inline-start: auto; }
.report-print-head { display: none; }
.colchart { margin: 0; direction: ltr; }
.colchart-plot { display: grid; grid-template-columns: auto 1fr; gap: .5rem; height: 220px; }
.colchart-axis { display: grid; font-size: .72rem; color: var(--text-3); text-align: end; }
.colchart-axis-pos, .colchart-axis-neg { display: flex; flex-direction: column; justify-content: space-between; min-height: 0; }
.colchart-cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; border-bottom: 1px solid var(--border); }
.colchart-col { position: relative; display: grid; height: 100%; outline: none; border-radius: 4px; }
.colchart-col:focus-visible { box-shadow: 0 0 0 2px var(--primary); }
.colchart-up { display: flex; align-items: flex-end; justify-content: center; min-height: 0; border-bottom: 1px solid var(--text-3); }
.colchart-down { display: flex; align-items: flex-start; justify-content: center; min-height: 0; }
.colchart-bar { display: block; width: min(100%, 36px); background: var(--primary); border-radius: 4px 4px 0 0; transition: opacity .15s; }
.colchart-bar.neg { background: var(--danger); border-radius: 0 0 4px 4px; }
.colchart-cols:hover .colchart-bar { opacity: .55; }
.colchart-col:hover .colchart-bar, .colchart-col:focus-visible .colchart-bar { opacity: 1; }
.colchart-tip { position: absolute; top: 0; left: 50%; transform: translateX(-50%); display: none; flex-direction: column; gap: .1rem; white-space: nowrap;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); border-radius: 8px; padding: .35rem .55rem; font-size: .78rem; z-index: 5; pointer-events: none; }
.colchart-col:hover .colchart-tip, .colchart-col:focus-visible .colchart-tip { display: flex; }
.colchart-tip small { color: var(--text-3); }
.colchart-labels { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; margin-inline-start: 3.6rem; font-size: .7rem; color: var(--text-3); text-align: center; margin-top: .25rem; white-space: nowrap; }
.kpi-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.kpi-table td { padding: .45rem .2rem; border-bottom: 1px dashed var(--border); }
.kpi-table td:last-child { text-align: end; font-weight: 700; }
.kpi-table tr.total td { border-bottom: 0; border-top: 2px solid var(--text); font-size: 1.05rem; }
.kpi-table tr.minus td:last-child { color: var(--danger); }
@media print {
    .report-filters, .dg-toolbar, .dg-footer, .page-header .page-actions, .no-print { display: none !important; }
    .report-print-head { display: block; margin-bottom: .5rem; }
    .content { padding: 0 !important; }
    .card { box-shadow: none !important; break-inside: avoid; }
    .dg-scroll { max-height: none !important; overflow: visible !important; }
}
.dg tbody tr.row-warn { background: var(--danger-soft); }

/* ---------- عدم تواجد الطبيب ---------- */
.cal-leave { position: absolute; inset-inline: 0; z-index: 2; cursor: not-allowed; border-block: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
    background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--danger) 10%, var(--surface)) 0 8px, var(--surface-2) 8px 16px); }
.cal-leave span { position: sticky; top: 56px; display: inline-flex; align-items: center; gap: .3rem; margin: .3rem; padding: .1rem .45rem; border-radius: 6px;
    background: var(--surface); color: var(--danger); font-size: .74rem; font-weight: 700; box-shadow: var(--shadow-sm); }
.cal-leave .icon { width: 14px; height: 14px; }
.leave-list { display: grid; gap: .5rem; }
.leave-item { display: flex; gap: .75rem; align-items: center; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.leave-item .who { flex: 1; min-width: 0; }
.leave-item .who small { display: block; color: var(--text-3); }
.msg-preview { white-space: pre-line; background: color-mix(in srgb, var(--success) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
    border-radius: 12px 12px 4px 12px; padding: .6rem .8rem; font-size: .88rem; line-height: 1.6; }
.chips-inline { display: flex; flex-wrap: wrap; gap: .3rem; }
.chips-inline button { border: 1px dashed var(--border-strong); background: var(--surface); border-radius: 6px; padding: .05rem .4rem; font: inherit; font-size: .78rem; cursor: pointer; color: var(--text-2); }
.chips-inline button:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- فلتر الاختيار المتعدد ---------- */
.mf { position: relative; }
.mf-btn { display: inline-flex; align-items: center; gap: .35rem; height: 36px; padding: 0 .7rem; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
    font: inherit; font-size: .86rem; color: var(--text-2); cursor: pointer; max-width: 260px; white-space: nowrap; }
.mf-btn b { overflow: hidden; text-overflow: ellipsis; font-weight: 700; color: var(--text); }
.mf-btn.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.mf-btn .icon { width: 15px; height: 15px; flex: none; }
.mf-backdrop { position: fixed; inset: 0; z-index: 59; }
.mf-panel { position: absolute; top: calc(100% + 4px); inset-inline-start: 0; z-index: 60; width: 280px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .5rem; }
.mf-actions { display: flex; justify-content: space-between; margin-bottom: .25rem; }
.mf-list { max-height: 300px; overflow: auto; }
.mf-item { display: flex; align-items: center; gap: .5rem; padding: .35rem .4rem; border-radius: 6px; cursor: pointer; font-size: .88rem; }
.mf-item:hover { background: var(--surface-2); }
.mf-item .mf-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-clear { font-size: .82rem; }

/* ===== نظام الدور (صفحة الغرف والإعدادات) ===== */
.q-rooms { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: 1rem; scrollbar-width: thin; }
.q-room-tab { display: flex; align-items: center; gap: .65rem; min-width: 11rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.q-room-tab b { display: block; font-size: .92rem; }
.q-room-tab small { color: var(--text-3); font-size: .78rem; }
.q-room-tab.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.q-room-tab:focus-visible { outline: 2px solid var(--primary-ring); outline-offset: 2px; }
.q-letter { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 1.05rem; }
.q-grid { display: grid; grid-template-columns: minmax(300px, 1fr) 1.3fr; gap: 1.25rem; align-items: start; }
.q-current { --vip: var(--primary); text-align: center; padding: 1.2rem 1rem; border-radius: var(--radius-lg); background: var(--surface-sunken); margin-bottom: 1rem; border: 2px solid transparent; }
.q-current.vip { border-color: var(--vip); background: color-mix(in srgb, var(--vip) 10%, var(--surface)); }
.q-current-label { color: var(--text-3); font-size: .85rem; font-weight: 600; }
.q-current-code { font-size: 4.2rem; font-weight: 800; line-height: 1.1; color: var(--primary); letter-spacing: .02em; }
.q-current.vip .q-current-code { color: var(--vip); }
.q-current-name { font-size: 1.1rem; font-weight: 700; }
.q-next { width: 100%; height: 56px; font-size: 1.15rem; justify-content: center; }
.q-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .6rem; }
.q-actions .btn { justify-content: center; }
.q-list li { display: flex; align-items: center; gap: .65rem; padding: .6rem 1.15rem; border-bottom: 1px solid var(--border); }
.q-list li:last-child { border-bottom: 0; }
.q-who { flex: 1; min-width: 0; }
.q-who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-who small { color: var(--text-3); font-size: .8rem; }
.q-chip { --vip: var(--warning); display: inline-flex; align-items: center; justify-content: center; min-width: 3.4rem; height: 30px; padding: 0 .55rem; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.q-chip.vip { background: color-mix(in srgb, var(--vip) 14%, transparent); color: var(--vip); }
.q-sub { padding: .6rem 1.15rem .2rem; font-size: .8rem; font-weight: 700; color: var(--text-3); border-top: 1px solid var(--border); }
.muted-list li { opacity: .8; }
.q-overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.q-ov { padding: 1rem; display: flex; flex-direction: column; gap: .7rem; }
.q-ov-head { display: flex; align-items: center; gap: .65rem; }
.q-ov-head b { display: block; }
.q-ov-head small { color: var(--text-3); font-size: .8rem; }
.q-ov-cur { --vip: var(--warning); text-align: center; font-size: 2.6rem; font-weight: 800; color: var(--primary); background: var(--surface-sunken); border-radius: var(--radius); padding: .3rem; }
.q-ov-cur.vip { color: var(--vip); }
.q-ov-next { display: flex; flex-wrap: wrap; gap: .35rem; min-height: 30px; align-items: center; }
.q-issued { --vip: var(--primary); text-align: center; padding: 1rem; border-radius: var(--radius-lg); border: 2px dashed var(--vip); }
.q-issued small { display: block; color: var(--text-3); }
.q-issued b { display: block; font-size: 3rem; font-weight: 800; color: var(--vip); line-height: 1.15; }
.q-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.q-checks { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; }
.q-screens { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 1rem; }
.q-screen { display: flex; gap: 1rem; padding: 1rem; align-items: flex-start; }
.q-screen-qr { flex: none; width: 112px; height: 112px; border-radius: 8px; overflow: hidden; background: #fff; }
.q-screen-qr svg { width: 100%; height: 100%; display: block; }
.q-screen-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .45rem; }
.q-url { font-size: .8rem; color: var(--text-2); background: var(--surface-sunken); border-radius: 6px; padding: .25rem .5rem; overflow-wrap: anywhere; text-align: left; }
.q-help { margin-top: 1.25rem; padding: 1rem 1.15rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-sunken); }
.q-help h3 { font-size: .98rem; margin-bottom: .6rem; display: flex; align-items: center; gap: .4rem; }
.q-help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.q-help ul { margin: .35rem 0 0; padding-inline-start: 1.1rem; font-size: .88rem; display: grid; gap: .25rem; }
.q-cmd { margin: .5rem 0 0; padding: .6rem .7rem; border-radius: 8px; background: #0b1418; color: #ccfbf1; font-size: .74rem; white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; }
.q-add { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; padding: 1rem; border: 1px dashed var(--border); border-radius: var(--radius-lg); margin-bottom: 1rem; }
.q-add .field { flex: 1 1 14rem; margin: 0; }
.q-media li { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.q-thumb { flex: none; width: 88px; height: 56px; border-radius: 8px; background: var(--surface-sunken); display: grid; place-items: center; overflow: hidden; color: var(--text-3); }
.q-thumb img { width: 100%; height: 100%; object-fit: cover; }
.q-media-main { flex: 1 1 16rem; min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
@media (max-width: 900px) {
    .q-grid, .q-help-grid { grid-template-columns: 1fr; }
    .q-screens { grid-template-columns: 1fr; }
    .q-screen { flex-direction: column; align-items: center; }
}
