/* ═══════════════════════════════════════════════════════════
   نظام الألوان — أزرق أساسي على خلفية رمادية مزرقة هادئة.
   كل الألوان متغيرات عشان الوضع الداكن يبدّلها بدون لمس باقي التنسيق.
   ═══════════════════════════════════════════════════════════ */
:root {
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --primary: #1e5eff; --primary-strong: #1547c9; --primary-soft: #e8efff; --primary-soft-2: #d5e2ff; --on-primary: #fff;
  --bg: #f3f6fb; --surface: #fff; --surface-2: #f8fafd; --border: #e3e9f2; --border-strong: #cbd5e3;
  --text: #0f1b33; --text-2: #4b5b76; --text-3: #8290a8;
  --booked-bg: #1e5eff; --booked-text: #fff; --free-bg: #fff;
  --weekend-bg: #fbf5e8; --weekend-text: #8a5a00;
  --discount: #10b981; --danger: #e5484d; --danger-soft: #fdecec; --warn: #d97706; --warn-soft: #fff4e0;
  --success: #12a06a; --success-soft: #e6f7ef; --info-soft: #e8f4ff;
  --shadow-sm: 0 1px 2px rgba(15,27,51,.06), 0 1px 1px rgba(15,27,51,.04);
  --shadow-md: 0 8px 24px -12px rgba(15,27,51,.18), 0 2px 6px rgba(15,27,51,.05);
  --shadow-lg: 0 24px 60px -24px rgba(15,27,51,.35);
  --radius: 16px; --radius-sm: 10px; --cell-radius: 12px;
  --nav-w: 232px; --topbar-h: 62px;
}
/* الوضع الداكن يُفعّل بسمة data-theme اللي يضبطها theme.js (من اختيار المستخدم أو إعداد الجهاز) */
:root[data-theme="dark"] {
    color-scheme: dark;
    --primary: #5b8cff; --primary-strong: #7aa2ff; --primary-soft: #16244a; --primary-soft-2: #1e3166; --on-primary: #08122b;
    --bg: #0b1220; --surface: #121a2b; --surface-2: #17213a; --border: #22304d; --border-strong: #33456b;
    --text: #e8eefc; --text-2: #a9b6d1; --text-3: #6f7f9f;
    --booked-bg: #3b6fe0; --free-bg: #121a2b; --weekend-bg: #201c12; --weekend-text: #f0c26b;
    --danger-soft: #3a1a1c; --warn-soft: #3a2a10; --success-soft: #0f2f22; --info-soft: #14243d;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 8px 24px -12px rgba(0,0,0,.6); --shadow-lg: 0 24px 60px -24px rgba(0,0,0,.8);
}
:root[data-theme="light"] { color-scheme: light; }
.icon-btn .sun, .icon-btn .moon { display: none; }
:root[data-theme="dark"] .icon-btn .sun { display: block; }
:root[data-theme="light"] .icon-btn .moon { display: block; }

/* ═══ الأساسيات ═══ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg); min-height: 100dvh; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ═══ الأزرار ═══ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 999px; border: 1px solid transparent; font-weight: 600; font-size: 14px; line-height: 1; transition: background .15s, transform .1s, box-shadow .15s, opacity .15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 16px -8px var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-strong); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.btn-ghost[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary-soft-2); color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-success { background: var(--success-soft); color: var(--success); }
.btn-block { width: 100%; padding: 13px 16px; font-size: 15px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn svg { flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); transition: background .15s, color .15s, border-color .15s; flex: none; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn.sm { width: 32px; height: 32px; }

/* ═══ الشعار ═══ */
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 14px; color: #fff; background: linear-gradient(145deg, #3d7bff, #1547c9); box-shadow: 0 8px 18px -8px #1e5eff; }
.brand.compact .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 15px; white-space: nowrap; }
.brand-text .muted { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ═══ صفحة الدخول ═══ */
.login-body { display: grid; place-items: center; padding: 24px; background: radial-gradient(60% 50% at 80% 0%, var(--primary-soft) 0%, transparent 60%), radial-gradient(50% 40% at 0% 100%, var(--primary-soft) 0%, transparent 60%), var(--bg); }
.login-card { width: min(100%, 400px); background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 32px 28px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 24px; }
.login-card h1 { font-size: 20px; }
.login-foot { font-size: 12px; text-align: center; }
#login-form { display: flex; flex-direction: column; gap: 14px; }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; }

/* ═══ الحقول ═══ */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 500; }
.field > span:first-child { color: var(--text-2); }
.field-input { position: relative; display: flex; align-items: center; }
.field-input input, .field-input select, .field-input textarea, .input {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-2); font-size: 15px; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
.field-input textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field-input input:focus, .field-input select:focus, .field-input textarea:focus, .input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); background: var(--surface); }
.field-input .icon-btn { position: absolute; inset-inline-end: 6px; width: 32px; height: 32px; border: none; background: transparent; }
.field-input input[dir="ltr"] { text-align: start; }
.field .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: 400; font-size: 14px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.check .help { display: block; font-size: 12px; color: var(--text-3); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch input { width: 36px; height: 20px; appearance: none; background: var(--border-strong); border-radius: 999px; position: relative; transition: background .15s; flex: none; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(-16px); }

/* ═══ الشريط العلوي ═══ */
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1400px; margin: 0 auto; padding: 10px 20px; display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr); align-items: center; gap: 12px; min-height: var(--topbar-h); }
.topbar-center { display: flex; justify-content: center; }
.topbar-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.mock-flag { background: var(--warn-soft); color: var(--warn); padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 12px; white-space: nowrap; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.user-btn:hover { border-color: var(--border-strong); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; flex: none; }
.user-name { font-size: 13.5px; font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; }
.menu-head { padding: 10px 12px 8px; display: flex; flex-direction: column; border-bottom: 1px solid var(--border); margin-bottom: 6px; font-size: 13px; }
.menu-item { display: block; width: 100%; text-align: start; padding: 9px 12px; border: none; background: transparent; border-radius: 9px; font-size: 14px; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu form { display: contents; }

/* ═══ الهيكل: قائمة جانبية + محتوى ═══ */
.shell { max-width: 1400px; margin: 0 auto; padding: 20px; display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); gap: 24px; align-items: start; }
.sidenav { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 14.5px; transition: background .15s, color .15s; border: 1px solid transparent; }
.nav-item svg { flex: none; opacity: .8; }
.nav-item:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.nav-item.active { background: var(--primary); color: var(--on-primary); box-shadow: 0 8px 18px -10px var(--primary); }
.nav-item.active svg { opacity: 1; }
.nav-sep { height: 1px; background: var(--border); margin: 8px 10px; }
.view { min-width: 0; display: flex; flex-direction: column; gap: 16px; padding-bottom: 40px; }
.tabbar { display: none; }

/* ═══ رؤوس الأقسام والبطاقات ═══ */
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.view-head h1 { font-size: 22px; }
.view-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-sm); }
.kpi .label { font-size: 12.5px; color: var(--text-2); }
.kpi .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-inline-start: 4px; }
.kpi .delta { font-size: 12px; font-weight: 600; }
.kpi .delta.up { color: var(--success); } .kpi .delta.down { color: var(--danger); }
.kpi.primary { background: linear-gradient(145deg, #2f6dff, #1547c9); color: #fff; border-color: transparent; }
.kpi.primary .label, .kpi.primary .value small { color: rgba(255,255,255,.8); }

.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 7px 14px; border-radius: 999px; border: none; background: transparent; color: var(--text-2); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.tab.active { background: var(--primary); color: var(--on-primary); }
.tab .count { margin-inline-start: 5px; font-size: 11px; opacity: .8; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 180px; }
.search { position: relative; }
.search input { padding-inline-start: 38px; border-radius: 999px; }
.search svg { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }

/* ═══ الشارات ═══ */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.booked, .badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.free, .badge.success { background: var(--success-soft); color: var(--success); }
.badge.past, .badge.neutral { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.badge.weekend, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.discount { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--primary); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ═══ القوائم ═══ */
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); text-align: start; width: 100%; transition: border-color .15s, box-shadow .15s, transform .12s; min-width: 0; }
button.row:hover { border-color: var(--primary); box-shadow: 0 6px 14px -8px var(--primary); transform: translateY(-1px); }
.row .row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row .row-title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row .row-sub { font-size: 12.5px; color: var(--text-2); display: flex; gap: 10px; flex-wrap: wrap; }
.row .row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.row .row-end .money { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }
.row .row-end .money small { font-weight: 500; font-size: 11px; color: var(--text-3); }
.row-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; font-weight: 700; }
.row-icon.success { background: var(--success-soft); color: var(--success); }
.row-icon.warn { background: var(--warn-soft); color: var(--warn); }
.row-icon.neutral { background: var(--surface-2); color: var(--text-3); }
.row-icon.danger { background: var(--danger-soft); color: var(--danger); }
.day-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); flex: none; line-height: 1; }
.day-chip b { font-size: 18px; }
.day-chip span { font-size: 10px; margin-top: 3px; font-weight: 600; }
.day-chip.past { background: var(--surface-2); color: var(--text-3); }
.day-chip.today { background: var(--primary); color: var(--on-primary); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--text-2); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
td.num, th.num { font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: var(--surface-2); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; margin: 0; }
.kv dt { color: var(--text-2); margin: 0; }
.kv dd { margin: 0; font-weight: 600; text-align: end; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.kv dd.net, .kv dd.accent { color: var(--primary); font-size: 15px; }
.kv .sep { grid-column: 1 / -1; height: 1px; background: var(--border); }

.empty { text-align: center; padding: 40px 20px; color: var(--text-3); font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty svg { opacity: .5; }
.error-box { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.note { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--border-strong); padding: 8px 12px; border-radius: 10px; }
.note.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.note.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.note.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; min-height: 56px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.msg-box { position: relative; white-space: pre-wrap; font-size: 14px; line-height: 1.7; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; max-height: 320px; overflow: auto; }
.code-big { font-family: var(--mono); font-size: 30px; font-weight: 700; letter-spacing: .12em; color: var(--primary); direction: ltr; text-align: center; padding: 12px; background: var(--primary-soft); border-radius: 12px; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions-grid .btn { padding: 11px 10px; font-size: 13.5px; }
.action-btn { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); text-align: start; font-weight: 600; font-size: 14px; }
.action-btn:hover { border-color: var(--primary); color: var(--primary); }
.action-btn svg { flex: none; color: var(--primary); }
.action-btn.danger svg, .action-btn.danger:hover { color: var(--danger); }
.actions-list { display: flex; flex-direction: column; gap: 8px; }

/* ═══ المحادثات ═══ */
.chat { display: flex; flex-direction: column; gap: 8px; padding: 6px 0; }
.bubble { max-width: 85%; padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .who { display: block; font-size: 11px; font-weight: 600; opacity: .7; margin-bottom: 2px; }
.bubble.guest { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-start-start-radius: 4px; }
.bubble.agent { align-self: flex-end; background: var(--primary-soft); color: var(--text); border-end-end-radius: 4px; }
.bubble.host { align-self: flex-end; background: var(--primary); color: var(--on-primary); border-end-end-radius: 4px; }

/* ═══ التقويم ═══ */
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--text-2); align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border-strong); display: inline-block; }
.swatch.free { background: var(--free-bg); }
.swatch.booked { background: var(--booked-bg); border-color: transparent; }
.swatch.weekend { background: var(--weekend-bg); }
.swatch.discount { background: var(--surface); position: relative; }
.swatch.discount::after { content: ""; position: absolute; inset-inline-start: 3px; top: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--discount); }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-range { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 14px; min-width: 200px; }
.month-range:hover { border-color: var(--border-strong); }
.months { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 900px) { .months { grid-template-columns: 1fr 1fr; } }
.month-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px; }
.month-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.month-title { font-size: 19px; }
.month-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.stat { display: inline-flex; align-items: baseline; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.stat b { color: var(--text); font-size: 13px; }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.weekdays span { text-align: center; font-size: 12px; color: var(--text-3); font-weight: 500; padding-block: 2px; }
.weekdays span.is-weekend { color: var(--weekend-text); }
.cell { position: relative; aspect-ratio: 1 / 1.08; border-radius: var(--cell-radius); border: 1.5px solid var(--border); background: var(--free-bg); display: flex; flex-direction: column; justify-content: space-between; padding: 7px 8px; text-align: start; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; transition: transform .12s, box-shadow .15s, border-color .15s, background .15s; min-width: 0; overflow: hidden; }
.cell.empty { border: none; background: transparent; pointer-events: none; }
.cell:not(.empty):hover { border-color: var(--primary); box-shadow: 0 6px 14px -8px var(--primary); transform: translateY(-1px); }
.cell .d { font-size: 14px; font-weight: 600; line-height: 1; }
.cell .p { font-size: 13px; font-weight: 700; line-height: 1.1; white-space: nowrap; letter-spacing: -.01em; }
.cell .p small { font-size: 10px; font-weight: 500; opacity: .7; margin-inline-start: 2px; }
.cell .g { font-size: 10.5px; line-height: 1.15; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.weekend { background: var(--weekend-bg); border-color: color-mix(in srgb, var(--weekend-text) 22%, var(--border)); }
.cell.weekend .d { color: var(--weekend-text); }
.cell.booked { background: var(--booked-bg); border-color: transparent; color: var(--booked-text); }
.cell.booked .d, .cell.booked .p { color: var(--booked-text); }
.cell.past { opacity: .45; }
.cell.past:hover { transform: none; box-shadow: none; border-color: var(--border); cursor: default; }
.cell.past.booked { background: color-mix(in srgb, var(--booked-bg) 45%, var(--surface)); }
.cell.today { border-color: var(--primary); box-shadow: inset 0 0 0 1.5px var(--primary); }
.cell.today .d::after { content: "اليوم"; font-size: 9px; font-weight: 600; margin-inline-start: 5px; color: var(--primary); }
.cell.booked.today .d::after { color: var(--booked-text); }
.cell.discount::before { content: ""; position: absolute; top: 8px; inset-inline-end: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--discount); box-shadow: 0 0 0 2px var(--surface); }
.cell.booked.discount::before { box-shadow: 0 0 0 2px var(--booked-bg); }
.cell.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-2), 0 8px 18px -10px var(--primary); }
.cell.selected::after { content: ""; position: absolute; bottom: 7px; inset-inline-end: 7px; width: 18px; height: 18px; border-radius: 50%; background: var(--primary) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12l5 5L20 7'/></svg>") center/12px no-repeat; }
.cell.selected.booked::after { background-color: #fff; filter: invert(1) hue-rotate(180deg); }
.cell.selected .p small { visibility: hidden; }
.cell.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-2); }
body.multi-mode .cell:not(.empty):not(.past) { cursor: copy; }
.cell.skeleton { border-color: transparent; min-height: 0; }
.hint { font-size: 13px; text-align: center; padding-block: 4px 40px; }
.price-editor { display: flex; flex-direction: column; gap: 12px; }
.price-editor label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.stepper { display: grid; grid-template-columns: 46px 1fr 46px; gap: 8px; }
.stepper input { min-width: 0; width: 100%; text-align: center; font-size: 26px; font-weight: 700; padding: 8px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2); font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); background: var(--surface); }
.stepper input.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.stepper button { border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); font-size: 20px; font-weight: 600; color: var(--text-2); }
.stepper button:hover { border-color: var(--border-strong); color: var(--text); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary-soft); border-color: var(--primary-soft-2); color: var(--primary); }
.preview { font-size: 13px; color: var(--text-2); display: flex; justify-content: space-between; gap: 10px; padding: 0 4px; }
.preview b { color: var(--text); font-variant-numeric: tabular-nums; }
.validation { font-size: 12.5px; padding: 8px 12px; border-radius: 10px; }
.validation.warn { background: var(--warn-soft); color: var(--warn); }
.validation.danger { background: var(--danger-soft); color: var(--danger); }
.validation.ok { background: var(--success-soft); color: var(--success); }
.limits { font-size: 12px; color: var(--text-3); text-align: center; }
.bulk-list { display: flex; flex-wrap: wrap; gap: 5px; max-height: 96px; overflow: auto; padding: 2px; }
.bulk-list span { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 500; font-variant-numeric: tabular-nums; }
.selection-bar { position: fixed; z-index: 34; inset-inline: 0; bottom: 14px; margin: 0 auto; width: min(calc(100% - 24px), 680px); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 10px 12px 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; animation: rise .22s cubic-bezier(.32,.72,0,1); padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } }
.selection-info { display: flex; align-items: baseline; gap: 6px; }
.selection-info strong { font-size: 22px; color: var(--primary); font-variant-numeric: tabular-nums; }
.selection-actions { display: flex; gap: 6px; }

/* ═══ اللوحة الجانبية (درج) / الشريحة السفلية ═══ */
.panel { position: fixed; z-index: 40; background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; border: 1px solid var(--border); transition: transform .28s cubic-bezier(.32,.72,0,1), opacity .2s; overflow: hidden; inset-inline: 0; bottom: 0; border-radius: 22px 22px 0 0; max-height: 90dvh; transform: translateY(105%); opacity: 0; border-bottom: none; padding-bottom: env(safe-area-inset-bottom); }
.panel.open { transform: translateY(0); opacity: 1; }
.panel-handle { display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 10px auto 0; flex: none; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px 12px; flex: none; }
.panel-titles { min-width: 0; }
.panel-head h2 { font-size: 18px; }
.panel-head .muted { font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.panel-body { padding: 4px 20px 24px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 1100px) {
  .panel { inset: 0 auto 0 0; width: min(440px, 100%); border-radius: 0; max-height: none; transform: translateX(-105%); border: none; border-inline-end: 1px solid var(--border); padding-bottom: 0; }
  .panel.open { transform: translateX(0); }
  .panel-handle { display: none; }
  .panel-head { padding-top: 22px; }
  .panel-body { padding-bottom: 32px; }
}
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(8,15,35,.45); backdrop-filter: blur(2px); }

/* ═══ الحوار ═══ */
.modal-host { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(8,15,35,.5); padding: 20px; }
.modal { width: min(100%, 420px); background: var(--surface); border-radius: 20px; padding: 22px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 10px; animation: pop .18s cubic-bezier(.32,.72,0,1); }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal h3 { font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ═══ التنبيهات ═══ */
.toast-host { position: fixed; z-index: 60; top: 74px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); max-width: 560px; display: flex; gap: 10px; align-items: center; animation: toast-in .25s cubic-bezier(.32,.72,0,1); }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(-12px); opacity: 0; } }

/* ═══ الصلاحيات ═══ */
.perm-groups { display: flex; flex-direction: column; gap: 12px; }
.perm-group { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.perm-group > .pg-head { padding: 8px 12px; background: var(--surface-2); font-size: 12.5px; font-weight: 700; color: var(--text-2); display: flex; justify-content: space-between; }
.perm-group .check { padding: 9px 12px; border-top: 1px solid var(--border); margin: 0; }
.perm-group .check:hover { background: var(--surface-2); }
.perm-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.perm-tags span { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.audit-row { display: grid; grid-template-columns: 90px 110px 1fr; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 12.5px; align-items: baseline; }
.audit-row:last-child { border-bottom: none; }
.audit-row .when { color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-row .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audit-row .what { overflow-wrap: anywhere; }
.audit-row.fail .what { color: var(--danger); }

/* ═══ حالة النظام ═══ */
.health-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.health-item .status { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 4px var(--surface-2); }
.health-item .status.ok { background: var(--success); }
.health-item .status.bad { background: var(--danger); }
.health-item .status.unknown { background: var(--text-3); }

/* ═══ الجوال ═══ */
@media (max-width: 1099px) {
  .shell { grid-template-columns: 1fr; padding: 14px 14px 90px; gap: 14px; }
  .sidenav { display: none; }
  .tabbar { display: flex; position: fixed; z-index: 32; bottom: 0; inset-inline: 0; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .tabbar::-webkit-scrollbar { display: none; }
  .tab-item { flex: 1 0 64px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; border-radius: 12px; color: var(--text-3); text-decoration: none; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
  .tab-item.active { color: var(--primary); background: var(--primary-soft); }
  .selection-bar { bottom: 74px; }
  .hint { padding-bottom: 10px; }
}
@media (max-width: 720px) {
  .topbar-inner { grid-template-columns: 1fr auto; padding: 8px 12px; gap: 8px; }
  .topbar-center { grid-column: 1 / -1; grid-row: 2; justify-content: stretch; }
  .topbar-center:empty { display: none; }
  .month-range { min-width: 0; flex: 1; padding: 8px 10px; font-size: 14px; white-space: nowrap; }
  .month-nav { width: 100%; }
  .user-name { display: none; }
  .user-btn { padding: 3px; }
  .mock-flag { display: none; }
  .view-head h1 { font-size: 19px; }
  .card { padding: 14px; border-radius: 14px; }
  .month-card { padding: 12px; border-radius: 14px; }
  .month-title { font-size: 17px; }
  .weekdays, .grid { gap: 4px; }
  .cell { padding: 5px 6px; border-radius: 10px; aspect-ratio: 1 / 1.15; }
  .cell .d { font-size: 13px; }
  .cell .p { font-size: 11.5px; }
  .cell .p small, .cell .g { display: none; }
  .cell.today .d::after { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); vertical-align: middle; }
  .selection-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .selection-actions .btn { flex: 1; padding-inline: 8px; }
  .form-row { grid-template-columns: 1fr; }
  .actions-grid { grid-template-columns: 1fr; }
  .audit-row { grid-template-columns: 70px 1fr; }
  .audit-row .what { grid-column: 1 / -1; }
  .toast-host { top: auto; bottom: 90px; }
  .kpi .value { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
