/* ===== سكينة: نظام التصميم =====
   زجاج شفاف فوق منظر طبيعي ضبابي، بألوان الميرمية والوردي والأزرق الهادئ. */

:root {
  --brand-sage: #5E8B7E;
  --brand-sky: #A7C7E7;
  --brand-slate: #2F3E46;
  --brand-mist: #F1F5F4;
  --brand-rose: #E8AEB7;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --font-display: 'Amiri', 'Traditional Arabic', serif;
  --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-xl: 26px; --r-pill: 999px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --side-w: 256px;
}

:root[data-theme='light'] {
  color-scheme: light;
  --ink: #22323A;
  --ink-2: #47595F;
  --ink-3: #5F7278;
  --glass: rgba(255, 255, 255, .62);
  --glass-2: rgba(255, 255, 255, .5);
  --glass-strong: rgba(250, 252, 251, .9);
  --glass-line: rgba(255, 255, 255, .78);
  --line: rgba(47, 62, 70, .13);
  --line-2: rgba(47, 62, 70, .22);
  --hover: rgba(47, 62, 70, .06);
  --field: rgba(255, 255, 255, .62);
  --field-focus: rgba(255, 255, 255, .92);
  --shadow: 0 10px 34px rgba(47, 76, 80, .13);
  --shadow-lg: 0 24px 70px rgba(32, 56, 62, .28);
  --primary: #4B7A6D;
  --primary-2: #3F6B5F;
  --primary-top: #5E8B7E;
  --primary-ink: #fff;
  --primary-soft: rgba(94, 139, 126, .17);
  --primary-text: #2F6556;
  --pressed: #2F3E46;
  --rose: #E8AEB7;
  --rose-2: #DC98A4;
  --rose-ink: #4F2530;
  --rose-soft: rgba(232, 174, 183, .3);
  --sky-soft: rgba(167, 199, 231, .34);
  --ok: #24725D; --ok-soft: rgba(36, 114, 93, .13);
  --warn: #8E5D0C; --warn-soft: rgba(201, 145, 40, .18);
  --danger: #A83247; --danger-soft: rgba(200, 62, 86, .12);
  --info: #2A6398; --info-soft: rgba(79, 134, 189, .15);
  --violet: #5C4AA8; --violet-soft: rgba(122, 111, 176, .16);
  --muted-soft: rgba(47, 62, 70, .08);
  --c1: #128A6C; --c2: #3B78C4; --c3: #C08312; --c4: #D14F6C; --c5: #7657C8; --c-other: #8A9AA0;
  --surface-gap: rgba(255, 255, 255, .85);
  --scroll: rgba(47, 62, 70, .25);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --ink: #EDF3F1;
  --ink-2: #BFCDCB;
  --ink-3: #9DB0B0;
  --glass: rgba(20, 34, 41, .64);
  --glass-2: rgba(26, 42, 49, .52);
  --glass-strong: rgba(22, 36, 43, .94);
  --glass-line: rgba(255, 255, 255, .11);
  --line: rgba(255, 255, 255, .1);
  --line-2: rgba(255, 255, 255, .2);
  --hover: rgba(255, 255, 255, .07);
  --field: rgba(255, 255, 255, .07);
  --field-focus: rgba(255, 255, 255, .13);
  --shadow: 0 12px 38px rgba(0, 0, 0, .34);
  --shadow-lg: 0 26px 80px rgba(0, 0, 0, .58);
  --primary: #5E8B7E;
  --primary-2: #4B7A6D;
  --primary-top: #6F9F91;
  --primary-ink: #fff;
  --primary-soft: rgba(111, 159, 145, .22);
  --primary-text: #9BD3C1;
  --pressed: #0E1B21;
  --rose: #E8AEB7;
  --rose-2: #F0BEC6;
  --rose-ink: #43202A;
  --rose-soft: rgba(232, 174, 183, .2);
  --sky-soft: rgba(167, 199, 231, .18);
  --ok: #8AD6BE; --ok-soft: rgba(138, 214, 190, .15);
  --warn: #EBC67A; --warn-soft: rgba(235, 198, 122, .15);
  --danger: #F4A1AF; --danger-soft: rgba(244, 161, 175, .15);
  --info: #A7C7E7; --info-soft: rgba(167, 199, 231, .16);
  --violet: #C2B8EE; --violet-soft: rgba(194, 184, 238, .16);
  --muted-soft: rgba(255, 255, 255, .08);
  --c1: #14A07C; --c2: #4A8FDA; --c3: #BC8C1E; --c4: #DE5C7C; --c5: #8A70E0; --c-other: #7E9196;
  --surface-gap: rgba(20, 34, 41, .9);
  --scroll: rgba(255, 255, 255, .22);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--ink);
  background: var(--brand-slate); min-height: 100dvh; font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
svg { display: block; }
[hidden] { display: none !important; }
::selection { background: var(--primary-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
:focus-visible { outline: 2px solid var(--primary-text); outline-offset: 2px; }

/* ===== الخلفية ===== */
.backdrop { position: fixed; inset: 0; z-index: -1; }
.bd { position: absolute; inset: 0; background-size: cover; background-position: center; transition: opacity .6s var(--ease); }
.bd-light { background-image: url('../assets/backdrop-light.svg'); opacity: 1; }
.bd-dark { background-image: url('../assets/backdrop-dark.svg'); opacity: 0; }
[data-theme='dark'] .bd-dark { opacity: 1; }
[data-theme='dark'] .bd-light { opacity: 0; }

/* ===== الزجاج ===== */
.glass, .panel {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  backdrop-filter: blur(22px) saturate(1.15);
}
.panel { padding: 18px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.panel-sub { font-size: 12.5px; color: var(--ink-3); }
.flush { padding: 0; overflow: hidden; }
.flush > .panel-head { padding: 16px 18px 0; }

/* ===== الهيكل ===== */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100dvh; gap: 0; }
.side {
  position: sticky; top: 12px; height: calc(100dvh - 24px); margin: 12px 12px 12px 0; padding: 16px 12px; display: flex; flex-direction: column; gap: 8px;
  border-radius: var(--r-xl); overflow: hidden; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 10px; }
.brand img { width: 38px; height: 38px; border-radius: 12px; flex: none; object-fit: cover; }
.brand-name { font-family: var(--font-display); font-size: 25px; line-height: 1.1; color: var(--ink); }
.brand-sub { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.nav { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nav-group { font-size: 11.5px; color: var(--ink-3); padding: 12px 10px 4px; font-weight: 500; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8.5px 10px; border-radius: 12px; color: var(--ink-2); font-weight: 500;
  transition: background .15s, color .15s; position: relative;
}
.nav-item svg { flex: none; }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { background: linear-gradient(180deg, var(--primary-top), var(--primary-2)); color: var(--primary-ink); box-shadow: 0 6px 16px rgba(63, 107, 95, .3); }
.nav-count { margin-inline-start: auto; background: var(--rose-soft); color: var(--ink); font-size: 11.5px; padding: 0 7px; border-radius: var(--r-pill); font-weight: 600; }
.nav-item.active .nav-count { background: rgba(255, 255, 255, .22); color: #fff; }
.side-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; align-items: center; gap: 10px; }
.side-foot .who { min-width: 0; flex: 1; }
.who-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-role { font-size: 11.5px; color: var(--ink-3); }

.main { min-width: 0; padding: 12px 16px 28px; display: flex; flex-direction: column; gap: 14px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-lg); position: sticky; top: 12px; z-index: 20; }
.top-search { position: relative; flex: 1; max-width: 460px; }
.top-actions { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.menu-btn { display: none; }

.page { display: flex; flex-direction: column; gap: 14px; min-width: 0; animation: rise .32s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 2px 4px; }
.page-title { font-size: 25px; font-weight: 600; letter-spacing: 0; }
.page-title.display { font-family: var(--font-display); font-size: 32px; font-weight: 700; line-height: 1.25; }
.page-sub { color: var(--ink-2); font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* العناوين تجلس فوق صورة الخلفية مباشرة، لذلك تأخذ لوحة خفيفة تضمن وضوحها */
.page-head { background: var(--glass-2); border: 1px solid var(--glass-line); border-radius: var(--r-lg); padding: 12px 16px; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }

.grid { display: grid; gap: 14px; min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.row.nowrap { flex-wrap: nowrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-danger { color: var(--danger); } .text-ok { color: var(--ok); } .text-warn { color: var(--warn); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* ===== الأزرار ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 7px 15px; border-radius: 12px;
  border: 1px solid transparent; background: transparent; cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: transform .12s var(--ease), background .15s, box-shadow .15s, color .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--primary-top), var(--primary-2)); color: var(--primary-ink); border-color: rgba(255,255,255,.28); box-shadow: 0 6px 16px rgba(63, 107, 95, .26), inset 0 1px 0 rgba(255,255,255,.22); }
.btn-primary:hover:not([disabled]) { filter: brightness(1.07); box-shadow: 0 9px 22px rgba(63, 107, 95, .34), inset 0 1px 0 rgba(255,255,255,.22); }
.btn-primary:active:not([disabled]) { background: var(--pressed); filter: none; }
.btn-rose { background: linear-gradient(180deg, var(--rose), var(--rose-2)); color: var(--rose-ink); border-color: rgba(255,255,255,.4); box-shadow: 0 6px 14px rgba(200, 120, 135, .22); }
.btn-rose:hover:not([disabled]) { filter: brightness(1.04); }
.btn-soft { background: var(--field); border-color: var(--glass-line); color: var(--ink); }
.btn-soft:hover:not([disabled]) { background: var(--field-focus); }
.btn-ghost { color: var(--primary-text); padding-inline: 10px; }
.btn-ghost:hover:not([disabled]) { background: var(--primary-soft); }
.btn-danger { color: var(--danger); background: var(--danger-soft); }
.btn-danger:hover:not([disabled]) { filter: brightness(1.05); box-shadow: 0 0 0 1px var(--danger) inset; }
.btn-sm { min-height: 32px; padding: 4px 11px; font-size: 13px; border-radius: 10px; }
.btn-lg { min-height: 46px; padding: 10px 22px; font-size: 15px; border-radius: 14px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; position: relative;
  transition: background .15s, color .15s, transform .12s;
}
.icon-btn:hover:not([disabled]) { background: var(--hover); color: var(--ink); }
.icon-btn:active:not([disabled]) { transform: scale(.95); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.solid { background: linear-gradient(180deg, var(--primary-top), var(--primary-2)); color: #fff; box-shadow: 0 6px 14px rgba(63,107,95,.3); }
.icon-btn.solid:hover:not([disabled]) { background: linear-gradient(180deg, var(--primary-top), var(--primary-2)); filter: brightness(1.08); color: #fff; }
.icon-btn[disabled] { opacity: .4; cursor: not-allowed; }
.dot-badge { position: absolute; top: 3px; inset-inline-end: 3px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10.5px; line-height: 16px; text-align: center; border-radius: 8px; background: var(--rose); color: var(--rose-ink); font-weight: 700; }

/* ===== حقول الإدخال ===== */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.field .req { color: var(--danger); margin-inline-start: 2px; }
.field-hint { font-size: 11.5px; color: var(--ink-3); }
.field-error { font-size: 12px; color: var(--danger); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg { position: absolute; inset-inline-start: 12px; color: var(--ink-3); pointer-events: none; }
.input-wrap > svg ~ .input { padding-inline-start: 36px; }
.input-wrap .input-end { position: absolute; inset-inline-end: 6px; }
.input {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--field); outline: 0;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
textarea.input { resize: vertical; min-height: 76px; line-height: 1.6; }
select.input { appearance: none; padding-inline-end: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23889A9D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 10px center; }
select.input option { background: #fff; color: #22323A; }
[data-theme='dark'] select.input option { background: #1C2C33; color: #EDF3F1; }
.input::placeholder { color: var(--ink-3); opacity: .85; }
.input:hover { border-color: var(--line-2); }
.input:focus { border-color: var(--primary-top); background: var(--field-focus); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.invalid, .invalid .input { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.input:disabled { opacity: .55; }
.input.sm { min-height: 32px; padding: 3px 9px; font-size: 13px; border-radius: 10px; }
input[type='date'].input, input[type='time'].input, input[type='month'].input, input[type='tel'].input, input[type='number'].input { direction: rtl; text-align: right; }
input[type='number'].input { -moz-appearance: textfield; }

/* مفتاح */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 44px; height: 25px; border-radius: 13px; background: var(--muted-soft); border: 1px solid var(--line-2); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 5px rgba(0,0,0,.28); transition: inset-inline-start .2s var(--ease); }
.switch input:checked + .track { background: var(--primary-top); border-color: transparent; }
.switch input:checked + .track::after { inset-inline-start: 21px; }
.switch input:focus-visible + .track { outline: 2px solid var(--primary-text); outline-offset: 2px; }

/* مربع اختيار وزر راديو */
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.check input { appearance: none; width: 19px; height: 19px; margin: 0; border-radius: 6px; border: 1.5px solid var(--line-2); background: var(--field); cursor: pointer; display: grid; place-items: center; flex: none; transition: background .15s, border-color .15s; }
.check input:checked { background: var(--primary-top); border-color: var(--primary-top); }
.check input:checked::after { content: ''; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-inline-end: 0; transform: rotate(-45deg) translate(0, -1px); }
.check input[type='radio'] { border-radius: 50%; }
.check input[type='radio']:checked::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: #fff; transform: none; }

/* منزلق */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: var(--line-2); outline-offset: 6px; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgba(0,0,0,.28), 0 0 0 5px var(--primary-soft); cursor: pointer; }
.range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgba(0,0,0,.28), 0 0 0 5px var(--primary-soft); cursor: pointer; }

/* شرائح */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 3px 13px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--field); cursor: pointer; font-size: 13px; color: var(--ink-2); white-space: nowrap; transition: background .15s, color .15s; }
.chip:hover { background: var(--field-focus); color: var(--ink); }
.chip.on, .chip[aria-pressed='true'] { background: linear-gradient(180deg, var(--primary-top), var(--primary-2)); color: #fff; border-color: transparent; }
.chip .swatch { width: 9px; height: 9px; border-radius: 50%; }

/* شارات */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--muted-soft); color: var(--ink-2); }
.badge svg { flex: none; }
.tone-primary { background: var(--primary-soft); color: var(--primary-text); }
.tone-ok { background: var(--ok-soft); color: var(--ok); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }
.tone-muted { background: var(--muted-soft); color: var(--ink-3); }
.tone-rose { background: var(--rose-soft); color: var(--ink); }

/* تبويبات */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 9px 13px; border: 0; background: none; cursor: pointer; color: var(--ink-2); font-weight: 500; white-space: nowrap; position: relative; border-radius: 10px 10px 0 0; display: inline-flex; gap: 7px; align-items: center; }
.tab:hover { color: var(--ink); background: var(--hover); }
.tab.active { color: var(--primary-text); font-weight: 600; }
.tab.active::after { content: ''; position: absolute; inset-inline: 8px; bottom: -1px; height: 2.5px; border-radius: 2px; background: var(--primary-top); }
.page-tabs { background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--r); padding: 4px 8px 0; -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); box-shadow: var(--shadow); }
.page-tabs .tabs { border-bottom: 0; }

.seg { display: inline-flex; padding: 3px; background: var(--muted-soft); border-radius: 12px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; min-height: 30px; border-radius: 9px; cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg button.on { background: var(--glass-strong); color: var(--ink); box-shadow: 0 1px 5px rgba(0,0,0,.12); }

/* خطوات */
.steps { display: flex; align-items: flex-start; gap: 0; }
.step { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; position: relative; font-size: 12px; color: var(--ink-3); text-align: center; }
.step i { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 600; border: 1.5px solid var(--line-2); background: var(--glass-strong); z-index: 1; }
.step::before { content: ''; position: absolute; top: 15px; inset-inline-start: -50%; width: 100%; height: 2px; background: var(--line-2); }
.step:first-child::before { display: none; }
.step.done i, .step.now i { background: linear-gradient(180deg, var(--primary-top), var(--primary-2)); color: #fff; border-color: transparent; }
.step.done::before, .step.now::before { background: var(--primary-top); }
.step.now { color: var(--ink); font-weight: 600; }

/* ===== الجدول ===== */
.tbl-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 16px 10px; }
.tbl-tools .search { flex: 1; min-width: 180px; max-width: 340px; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: start; font-weight: 500; font-size: 12.5px; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--hover); }
.tbl .end { text-align: end; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: 0; }
.tbl-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; font-size: 12.5px; color: var(--ink-3); border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 4px; }

.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-text { min-width: 0; }
.person-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; flex: none; color: #fff; font-size: 14px; background: var(--primary-top); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 68px; height: 68px; font-size: 26px; }

/* ===== البطاقات الإحصائية ===== */
.stat { display: flex; flex-direction: column; gap: 3px; padding: 15px 16px; min-width: 0; position: relative; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 12.5px; color: var(--ink-2); }
.stat-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); flex: none; }
.stat-ic.rose { background: var(--rose-soft); color: var(--ink); }
.stat-ic.sky { background: var(--sky-soft); color: var(--ink); }
.stat-ic.warn { background: var(--warn-soft); color: var(--warn); }
.stat-value { font-size: 25px; font-weight: 600; line-height: 1.25; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-inline-start: 3px; }
.stat-delta { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 4px; }
.stat-delta.up { color: var(--ok); } .stat-delta.down { color: var(--danger); }

/* قوائم صغيرة */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; border-radius: 10px; }
.list-item.clickable:hover { background: var(--hover); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 16px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; font-weight: 500; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); font-size: 13px; }
.alert svg { flex: none; margin-top: 2px; }

/* حالة فارغة */
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; text-align: center; color: var(--ink-3); }
.empty .empty-art { width: 108px; opacity: .95; }
.empty-title { font-weight: 600; color: var(--ink-2); }

/* ===== النوافذ ===== */
dialog.modal {
  border: 1px solid var(--glass-line); padding: 0; border-radius: var(--r-xl); background: var(--glass-strong); color: var(--ink);
  box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow: hidden;
  -webkit-backdrop-filter: blur(30px) saturate(1.2); backdrop-filter: blur(30px) saturate(1.2);
}
dialog.modal[open] { display: flex; flex-direction: column; animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
dialog.modal::backdrop { background: rgba(20, 34, 40, .42); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog.modal.lg { width: min(800px, calc(100vw - 24px)); }
dialog.modal.xl { width: min(1080px, calc(100vw - 24px)); }
dialog.modal.sm { width: min(400px, calc(100vw - 24px)); }
.modal-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 16.5px; font-weight: 600; }
.modal-sub { font-size: 12.5px; color: var(--ink-3); }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.modal-foot .start { margin-inline-end: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-size: 12.5px; font-weight: 600; color: var(--primary-text); padding-top: 6px; border-top: 1px solid var(--line); margin-top: 2px; }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.confirm-art { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; margin: 6px auto 12px; background: var(--primary-soft); color: var(--primary-text); }
.confirm-art.danger { background: var(--danger-soft); color: var(--danger); }

/* قائمة منسدلة باحثة */
.combo { position: relative; }
.combo-list { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 30; max-height: 230px; overflow-y: auto; background: var(--glass-strong); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 4px; }
.combo-opt { padding: 7px 10px; border-radius: 9px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.combo-opt:hover, .combo-opt.hl { background: var(--primary-soft); }
.combo-opt .sub { font-size: 12px; color: var(--ink-3); }
.combo-new { color: var(--primary-text); font-weight: 500; border-top: 1px solid var(--line); border-radius: 0 0 9px 9px; }
.pop { position: absolute; z-index: 40; background: var(--glass-strong); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); }
.search-pop { inset-inline: 0; top: calc(100% + 6px); max-height: 60vh; overflow: auto; }
.search-group { font-size: 11.5px; color: var(--ink-3); padding: 7px 8px 3px; }
.notif-pop { inset-inline-end: 0; top: calc(100% + 8px); width: min(360px, calc(100vw - 24px)); max-height: 70vh; overflow: auto; }

/* رسائل */
.toasts { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(50%); display: flex; flex-direction: column; gap: 8px; z-index: 2000; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; padding: 10px 16px; border-radius: var(--r); background: var(--brand-slate); color: #fff; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .22s var(--ease); max-width: min(480px, 92vw); pointer-events: auto; }
.toast.err { background: #8E2B3D; }
.toast.ok { background: #2F6556; }

/* تلميح */
#tip { position: fixed; z-index: 3000; pointer-events: none; background: var(--brand-slate); color: #fff; padding: 6px 10px; border-radius: 9px; font-size: 12px; line-height: 1.5; white-space: pre-line; box-shadow: 0 8px 22px rgba(0,0,0,.3); max-width: 260px; }
[data-theme='dark'] #tip { background: #F1F5F4; color: #22323A; }

/* ===== الرسوم ===== */
.chart { width: 100%; min-height: 40px; position: relative; }
.chart svg { width: 100%; overflow: visible; }
.axis-text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.grid-line { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .col .cross { opacity: 0; stroke: var(--line-2); stroke-width: 1; }
.chart .col .dot { opacity: 0; }
.chart .col:hover .cross, .chart .col:hover .dot { opacity: 1; }
.chart .bar { transition: opacity .12s; }
.chart .barcol:hover .bar { opacity: .75; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 3px; }
.hbar-track { height: 8px; border-radius: 4px; background: var(--muted-soft); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; background: var(--c1); }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.donut-legend { display: flex; flex-direction: column; gap: 7px; font-size: 13px; flex: 1; min-width: 150px; }
.donut-legend > div { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; margin-inline-end: 7px; }
.heat { display: grid; gap: 3px; font-size: 11px; color: var(--ink-3); }
.heat .cell { height: 26px; border-radius: 4px; background: var(--c1); }
.heat .lbl { display: flex; align-items: center; justify-content: center; white-space: nowrap; }
.meter { height: 8px; border-radius: 4px; background: var(--muted-soft); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--primary-top); border-radius: 4px; }
.meter.warn > i { background: var(--c3); } .meter.danger > i { background: var(--c4); }

/* ===== التقويم ===== */
.cal-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-date { font-weight: 600; font-size: 15px; min-width: 150px; text-align: center; }
.cal { --min: 1.25px; position: relative; overflow: auto; max-height: calc(100dvh - 230px); border-radius: var(--r); }
.cal-grid { display: grid; min-width: 100%; position: relative; }
.cal-head { position: sticky; top: 0; z-index: 6; display: contents; }
.cal-th { position: sticky; top: 0; z-index: 6; background: var(--glass-strong); padding: 8px 8px; border-bottom: 1px solid var(--line-2); border-inline-start: 1px solid var(--line); min-width: 0; }
.cal-th.corner { inset-inline-start: 0; z-index: 7; border-inline-start: 0; }
.cal-times { position: sticky; inset-inline-start: 0; z-index: 5; background: var(--glass-strong); }
.cal-time { position: absolute; inset-inline: 0; text-align: center; font-size: 11px; color: var(--ink-3); transform: translateY(-50%); }
.cal-col { position: relative; border-inline-start: 1px solid var(--line); cursor: copy; }
.cal-hour { position: absolute; inset-inline: 0; border-top: 1px solid var(--line); pointer-events: none; }
.cal-hour.half { border-top-style: dotted; opacity: .6; }
.cal-off { position: absolute; inset-inline: 0; background: repeating-linear-gradient(135deg, var(--muted-soft) 0 6px, transparent 6px 12px); pointer-events: none; }
.cal-now { position: absolute; inset-inline: 0; height: 0; border-top: 2px solid var(--c4); z-index: 4; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; inset-inline-start: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--c4); }
.appt {
  position: absolute; inset-inline: 3px; border-radius: 10px; padding: 4px 8px; font-size: 12px; overflow: hidden; cursor: grab; z-index: 2; line-height: 1.35;
  background: color-mix(in srgb, var(--appt) 22%, var(--glass-strong)); border-inline-start: 3px solid var(--appt); box-shadow: 0 2px 8px rgba(0,0,0,.08);
  transition: box-shadow .12s, transform .12s; touch-action: none; color: var(--ink);
}
.appt:hover { box-shadow: 0 6px 18px rgba(0,0,0,.18); z-index: 3; }
.appt.ghost { opacity: .85; box-shadow: var(--shadow-lg); z-index: 8; cursor: grabbing; }
.appt.dim { opacity: .55; } .appt.dim .appt-name { text-decoration: line-through; }
.appt-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-meta { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
.appt .st { position: absolute; top: 5px; inset-inline-end: 5px; width: 8px; height: 8px; border-radius: 50%; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.month-dow { text-align: center; font-size: 12px; color: var(--ink-3); padding: 2px; }
.month-cell { min-height: 92px; border-radius: 12px; border: 1px solid var(--line); padding: 6px 8px; background: var(--field); cursor: pointer; text-align: start; display: flex; flex-direction: column; gap: 3px; min-width: 0; transition: background .12s; }
.month-cell:hover { background: var(--field-focus); }
.month-cell.other { opacity: .42; } .month-cell.today { border-color: var(--primary-top); box-shadow: 0 0 0 1px var(--primary-top) inset; }
.month-cell .d { font-weight: 600; }
.mini-line { font-size: 11px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* لوحة الاستقبال */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.lane { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 240px; }
.lane-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 13.5px; padding: 0 2px 4px; }
.card-mini { background: var(--field-focus); border: 1px solid var(--glass-line); border-radius: var(--r); padding: 10px 11px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.queue-no { font-weight: 700; background: var(--primary-soft); color: var(--primary-text); padding: 0 8px; border-radius: 8px; font-size: 13px; }
.wait-long { color: var(--danger); font-weight: 600; }

/* ملف المريض */
.hero { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.tag-alert { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 12.5px; font-weight: 500; }
.timeline { position: relative; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 12px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 5px; top: 6px; bottom: 6px; width: 1.5px; background: var(--line-2); }
.tl-item { position: relative; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: -18px; top: 7px; width: 11px; height: 11px; border-radius: 50%; background: var(--primary-top); box-shadow: 0 0 0 3px var(--glass-strong); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo { position: relative; border-radius: var(--r); overflow: hidden; aspect-ratio: 4/5; background: var(--muted-soft); cursor: pointer; border: 2px solid transparent; }
.photo.sel { border-color: var(--primary-top); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .cap { position: absolute; inset-inline: 0; bottom: 0; padding: 14px 8px 6px; background: linear-gradient(transparent, rgba(0,0,0,.62)); color: #fff; font-size: 11.5px; }
.compare { position: relative; aspect-ratio: 4/5; max-height: 60vh; margin: auto; overflow: hidden; border-radius: var(--r); background: #000; direction: ltr; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.compare .top { clip-path: inset(0 calc(100% - var(--x, 50%)) 0 0); }
.compare .divider { position: absolute; top: 0; bottom: 0; left: var(--x, 50%); width: 2px; background: #fff; box-shadow: 0 0 8px rgba(0,0,0,.5); }

/* خريطة الوجه */
.face-map { position: relative; width: 100%; max-width: 280px; margin: auto; cursor: crosshair; }
.face-map svg { width: 100%; height: auto; }
.face-pin { position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%; background: var(--c4); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0,0,0,.3); cursor: pointer; }

/* تقييم المزاج */
.mood { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.mood button { border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); padding: 2px; }
.mood .face { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; transition: transform .15s var(--ease), box-shadow .15s; color: #2F3E46; }
.mood button:hover .face { transform: scale(1.08); }
.mood button.on .face { box-shadow: 0 0 0 3px var(--primary-top); transform: scale(1.08); }
.m5 { background: #A7C7E7; } .m4 { background: #A9D3C3; } .m3 { background: #CBD5D4; } .m2 { background: #DDBFC4; } .m1 { background: #E8AEB7; }

/* نقطة البيع */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 14px; align-items: start; }
.pos-summary { position: sticky; top: 78px; }
.line-row { display: grid; grid-template-columns: minmax(130px, 1.6fr) 60px 92px 86px minmax(110px, 1fr) 32px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.line-head { font-size: 12px; color: var(--ink-3); padding-top: 0; }
.sum-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 13.5px; }
.sum-row.total { font-size: 19px; font-weight: 700; border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 9px; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 260px; overflow: auto; }
.quick-card { border: 1px solid var(--line); background: var(--field); border-radius: 12px; padding: 8px 10px; text-align: start; cursor: pointer; transition: background .12s, transform .12s; }
.quick-card:hover { background: var(--primary-soft); }
.pay-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 92px 30px; gap: 6px; align-items: center; margin-bottom: 6px; }

/* مصفوفة الصلاحيات وجداول الورديات */
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: start; }
.shift-cell { font-size: 11.5px; padding: 3px 6px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-text); white-space: nowrap; display: inline-block; cursor: pointer; border: 0; }
.shift-cell.off { background: var(--muted-soft); color: var(--ink-3); }
.shift-cell.leave { background: var(--rose-soft); color: var(--ink); }

/* شاشة انتظار */
.tv { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; padding: 28px; }
.tv-panel { padding: 26px; display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: hidden; }
.tv-now { font-size: clamp(60px, 11vw, 150px); font-weight: 700; line-height: 1; color: var(--primary-text); }
.tv-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r); background: var(--field); font-size: clamp(16px, 1.8vw, 24px); }

/* تسجيل الدخول والإعداد */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 18px; }
.auth-card { width: min(440px, 100%); padding: 26px; border-radius: var(--r-xl); display: flex; flex-direction: column; gap: 14px; animation: rise .4s var(--ease); }
.auth-card.wide { width: min(600px, 100%); }
.auth-brand { text-align: center; }
.auth-brand img { width: 58px; height: 58px; margin: 0 auto 6px; border-radius: 18px; }
.auth-name { font-family: var(--font-display); font-size: 42px; line-height: 1.15; }
.offline-bar { background: var(--danger-soft); color: var(--danger); border-radius: var(--r); padding: 7px 12px; font-size: 13px; display: flex; gap: 8px; align-items: center; border: 1px solid var(--danger); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }

/* طلب أونلاين على التقويم */
.appt.pending { background: color-mix(in srgb, var(--appt) 8%, transparent); border: 1.5px dashed var(--appt); border-inline-start: 3px dashed var(--appt); cursor: pointer; box-shadow: none; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.code-box { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--muted-soft); font-family: Consolas, 'Courier New', monospace; font-size: 12.5px; overflow-x: auto; text-align: left; }

/* صفحة الحجز العامة */
.book { min-height: 100dvh; display: flex; justify-content: center; align-items: flex-start; padding: clamp(12px, 4vh, 40px) 12px; }
.book-card { width: min(620px, 100%); padding: 22px; border-radius: var(--r-xl); display: flex; flex-direction: column; gap: 16px; }
.book-head { display: flex; align-items: center; gap: 12px; }
.book-head img { width: 46px; height: 46px; border-radius: 14px; object-fit: cover; flex: none; }
.book-name { font-family: var(--font-display); font-size: 26px; line-height: 1.2; }
.book-steps { list-style: none; margin: 0; padding: 0; }
.book-steps .step i svg { color: #fff; }
.book-list { display: flex; flex-direction: column; gap: 8px; }
.book-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; min-height: 58px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--field); cursor: pointer; text-align: start; color: var(--ink); transition: background .15s, border-color .15s; }
.book-option:hover { background: var(--field-focus); border-color: var(--primary-top); }
.book-option > svg { color: var(--ink-3); flex: none; }
.book-summary { display: flex; flex-direction: column; gap: 2px; padding: 11px 14px; border-radius: var(--r); background: var(--primary-soft); }
.book-wait { text-align: center; padding: 22px; }
.day-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.day-btn { display: flex; flex-direction: column; align-items: center; gap: 1px; flex: none; min-width: 78px; padding: 8px 10px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--field); cursor: pointer; color: var(--ink); font-size: 13px; }
.day-btn:hover { background: var(--field-focus); }
.day-btn.on { background: linear-gradient(180deg, var(--primary-top), var(--primary-2)); color: #fff; border-color: transparent; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.slot-btn { min-height: 42px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--field); cursor: pointer; color: var(--ink); font-weight: 500; transition: background .12s, border-color .12s; }
.slot-btn:hover { background: var(--primary-soft); border-color: var(--primary-top); }
.bk-trap { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.bottom-nav { display: none; }
.side-scrim { display: none; }

/* ===== الشاشات الصغيرة ===== */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-3-2 { grid-template-columns: minmax(0, 1fr); }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos { grid-template-columns: minmax(0, 1fr); }
  .pos-summary { position: static; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; height: 100dvh; margin: 0; width: 280px; border-radius: 0; background: var(--glass-strong); transform: translateX(100%); transition: transform .25s var(--ease); z-index: 60; }
  .side.open { transform: none; }
  .side-scrim.open { display: block; position: fixed; inset: 0; background: rgba(15, 28, 33, .45); z-index: 55; }
  .menu-btn { display: inline-grid; }
  .main { padding: 8px 10px 92px; }
  .topbar { top: 8px; }
  .bottom-nav {
    display: flex; position: fixed; inset-inline: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 40; padding: 5px; border-radius: 20px; justify-content: space-around;
    background: var(--glass-strong);
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px; font-size: 11px; color: var(--ink-3); flex: 1; border-radius: 14px; min-width: 0; }
  .bottom-nav a.active { color: var(--primary-text); background: var(--primary-soft); font-weight: 600; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .board { grid-template-columns: minmax(0, 1fr); }
  .lane { min-height: 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > * { grid-column: 1 / -1; }
  .page-title { font-size: 21px; }
  .page-title.display { font-size: 26px; }
  .panel { padding: 14px; }
  .flush { padding: 0; }
  .month-cell { min-height: 58px; padding: 4px 5px; }
  .month-cell .mini-line:nth-child(n+3) { display: none; }
  .line-row { grid-template-columns: repeat(3, minmax(0, 1fr)) 30px; }
  .line-row .ln-name { grid-column: 1 / -1; }
  .line-row .ln-staff { grid-column: 1 / 4; }
  .line-head { display: none; }
  .tv { grid-template-columns: 1fr; overflow: auto; position: absolute; }
  dialog.modal, dialog.modal.lg, dialog.modal.xl, dialog.modal.sm { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  /* الجداول تتحول إلى بطاقات */
  table.tbl.stacked thead { display: none; }
  table.tbl.stacked, table.tbl.stacked tbody, table.tbl.stacked tfoot { display: block; }
  table.tbl.stacked tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.tbl.stacked td { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; border: 0; text-align: end; align-items: center; min-width: 0; }
  table.tbl.stacked td::before { content: attr(data-label); color: var(--ink-3); font-size: 12px; flex: none; }
  table.tbl.stacked td.lead { display: block; text-align: start; padding-bottom: 6px; }
  table.tbl.stacked td.lead::before { display: none; }
  table.tbl.stacked td:empty { display: none; }
  .topbar { flex-wrap: wrap; position: static; }
  .top-search { order: 3; flex: 1 1 100%; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (forced-colors: active) {
  .btn, .chip, .input { border: 1px solid CanvasText; }
}
@media print {
  .backdrop, .side, .topbar, .bottom-nav, .page-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .panel, .glass { background: #fff !important; box-shadow: none; backdrop-filter: none; border: 1px solid #ccc; }
}
