/* نظام بسمة — نظام التصميم: أبيض وأسود، زجاج، كروت داكنة، حواف دائرية كبيرة */
@font-face { font-family: Plex; font-weight: 300; font-display: swap; src: url(/fonts/plex-arabic-300.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Plex; font-weight: 400; font-display: swap; src: url(/fonts/plex-arabic-400.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Plex; font-weight: 500; font-display: swap; src: url(/fonts/plex-arabic-500.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Plex; font-weight: 600; font-display: swap; src: url(/fonts/plex-arabic-600.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Plex; font-weight: 700; font-display: swap; src: url(/fonts/plex-arabic-700.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: Plex; font-weight: 300; font-display: swap; src: url(/fonts/plex-latin-300.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: Plex; font-weight: 400; font-display: swap; src: url(/fonts/plex-latin-400.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: Plex; font-weight: 500; font-display: swap; src: url(/fonts/plex-latin-500.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: Plex; font-weight: 600; font-display: swap; src: url(/fonts/plex-latin-600.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: Plex; font-weight: 700; font-display: swap; src: url(/fonts/plex-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }

:root {
  --ink: #161618; --ink-2: #55555c; --ink-3: #85858c; --ink-4: #b4b4ba;
  --line: rgba(22, 22, 24, .09); --line-2: rgba(22, 22, 24, .16);
  --surface: #ffffff; --surface-2: #f4f4f5; --surface-3: #eaeaec;
  --glass: rgba(255, 255, 255, .5); --glass-line: rgba(255, 255, 255, .7);
  --dark: #242426; --dark-2: #343437; --dark-3: #4a4a4e; --on-dark: #ffffff; --on-dark-2: #b5b5ba;
  --critical: #a4262c; --critical-bg: #f9eced;
  --r-s: 10px; --r-m: 14px; --r-l: 22px; --r-xl: 28px;
  --shadow-s: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .04);
  --shadow-m: 0 8px 30px rgba(0, 0, 0, .1);
  --shadow-l: 0 24px 70px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: Plex, 'Segoe UI', Tahoma, sans-serif; font-size: 14px; line-height: 1.55; color: var(--ink);
  background: #cfcfd3; -webkit-font-smoothing: antialiased; overflow: hidden;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg.ic { display: inline-block; flex: none; vertical-align: middle; stroke-width: 1.7; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.card.dark :focus-visible, .dark-focus :focus-visible { outline-color: #fff; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); } .small { font-size: 12px; } .tiny { font-size: 11px; }
.bold { font-weight: 600; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .row.top { align-items: flex-start; }
.between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; } .stack-s { display: flex; flex-direction: column; gap: 6px; }
.stack > .chip { align-self: flex-start; }
.critical { color: var(--critical); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[hidden] { display: none !important; }

.bg { position: fixed; inset: -8%; z-index: -1; filter: blur(26px); background:
  radial-gradient(40% 34% at 60% 2%, rgba(255,255,255,.95), transparent 70%),
  radial-gradient(34% 44% at 96% 72%, rgba(255,255,255,.75), transparent 70%),
  radial-gradient(30% 30% at 8% 88%, rgba(255,255,255,.65), transparent 70%),
  linear-gradient(118deg, #e6e6e8 0%, #bcbcc1 24%, #f1f1f2 40%, #a8a8ae 58%, #ebebed 74%, #c2c2c7 100%); }

/* —— الهيكل —— */
.shell { position: fixed; inset: 14px; display: grid; grid-template-columns: 228px minmax(0, 1fr); gap: 6px; padding: 12px;
  border-radius: 32px; background: rgba(255, 255, 255, .26); border: 1px solid rgba(255, 255, 255, .6);
  backdrop-filter: blur(22px) saturate(1.05); -webkit-backdrop-filter: blur(22px) saturate(1.05); box-shadow: var(--shadow-m); }
.sidebar { display: flex; flex-direction: column; min-height: 0; padding: 22px 14px 14px; background: var(--surface); border-radius: 26px; box-shadow: var(--shadow-s); overflow-y: auto; scrollbar-width: none; }
.logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; font-size: 21px; font-weight: 700; letter-spacing: -.2px; }
.logo svg { width: 30px; height: 30px; flex: none; }
.nav-label { padding: 14px 10px 6px; font-size: 11px; font-weight: 500; color: var(--ink-3); }
.nav-link { display: flex; width: 100%; align-items: center; gap: 10px; min-height: 37px; padding: 7px 11px; border-radius: 12px; font-size: 13px; color: var(--ink-2); transition: background .15s, color .15s; text-align: start; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 6px 16px rgba(0,0,0,.2); }
.nav-link .badge { margin-inline-start: auto; }
.nav-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink-4); flex: none; margin-inline: 3px; }
.nav-link.selected .nav-dot { background: var(--ink); border-color: var(--ink); }
.nav-link.selected { color: var(--ink); font-weight: 500; }
.sidebar-foot { margin-top: auto; padding-top: 14px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ink); color: #fff; font-size: 10.5px; font-weight: 600; }

.main { min-width: 0; min-height: 0; overflow-y: auto; padding: 10px 20px 28px; scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.2) transparent; }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 56px; margin-bottom: 14px; }
.topbar h1 { font-size: 25px; font-weight: 600; letter-spacing: -.2px; line-height: 1.25; }
.topbar .sub { font-size: 12px; color: var(--ink-2); }
.icon-btn.menu-btn { display: none; }

/* —— الأزرار —— */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; transition: transform .12s, background .15s, box-shadow .15s, border-color .15s; border: 1px solid transparent; }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-dark { background: var(--ink); color: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.btn-dark:hover { background: #2d2d30; }
.btn-line { border-color: var(--ink); background: transparent; }
.btn-line:hover { background: rgba(0,0,0,.05); }
.btn-soft { background: var(--surface-2); }
.btn-soft:hover { background: var(--surface-3); }
.btn-white { background: var(--surface); box-shadow: var(--shadow-s); }
.btn-white:hover { background: var(--surface-2); }
.btn-danger { background: var(--critical); color: #fff; }
.btn-danger-line { border-color: var(--critical); color: var(--critical); }
.btn-danger-line:hover { background: var(--critical-bg); }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 12px; }
.btn-lg { min-height: 46px; padding: 10px 24px; font-size: 14px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-s); position: relative; transition: background .15s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.plain { background: transparent; box-shadow: none; width: 32px; height: 32px; }
.icon-btn.plain:hover { background: rgba(0,0,0,.06); }
.card.dark .icon-btn.plain:hover, .icon-btn.on-dark:hover { background: rgba(255,255,255,.12); }
.icon-btn.dark { background: var(--ink); color: #fff; }
.icon-btn.dark:hover { background: #2d2d30; }
.icon-btn .badge { position: absolute; top: -3px; inset-inline-end: -3px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(145deg, #4b4b50, #1f1f21); color: #fff; font-size: 13px; font-weight: 500; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.avatar.lg { width: 58px; height: 58px; font-size: 19px; }
.avatar.light { background: var(--surface-3); color: var(--ink); }

/* —— الكروت —— */
.card { background: var(--surface); border-radius: var(--r-l); padding: 18px; box-shadow: var(--shadow-s); min-width: 0; }
.card.glass { background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: none; }
.card.dark { background: var(--dark); color: var(--on-dark); box-shadow: 0 14px 34px rgba(0,0,0,.22); }
.card.dark .muted { color: var(--on-dark-2); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; min-height: 30px; }
.card-title { font-size: 16px; font-weight: 600; letter-spacing: -.1px; }
.section-title { font-size: 17px; font-weight: 600; }
.grid { display: grid; gap: 14px; }
.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)); }
.span-2 { grid-column: span 2; }

/* لوحة التحكم */
.dash-top { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(0, 1.04fr) minmax(0, .92fr); gap: 14px; }
.dash-mid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 2.2fr); gap: 14px; margin-top: 16px; align-items: stretch; }
.dash-bottom { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); gap: 14px; margin-top: 16px; align-items: start; }
.big-stats { display: flex; align-items: center; gap: 16px; margin: 4px 0 8px; }
.big-stat { display: flex; align-items: center; gap: 9px; }
.big-stat b { font-size: 50px; line-height: 1; font-weight: 500; letter-spacing: -1px; }
.big-stat span { font-size: 11px; line-height: 1.35; color: var(--on-dark-2); max-width: 74px; }
.big-sep { width: 1px; height: 38px; background: var(--dark-3); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 12px 4px; border-radius: 16px; background: var(--surface); color: var(--ink); text-align: center; transition: transform .15s; min-height: 100px; }
.tile:hover { transform: translateY(-2px); }
.tile.alt { background: #c9c9cc; }
.tile b { font-size: 25px; font-weight: 500; line-height: 1.25; }
.tile span { font-size: 11px; color: var(--ink-2); }
.bar-line { height: 4px; width: 56px; border-radius: 4px; background: var(--on-dark); margin: 6px 0 2px; }

.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { display: block; width: 100%; overflow: visible; direction: ltr; }
.chart-tip { position: absolute; z-index: 5; transform: translate(-50%, -100%); pointer-events: none; padding: 6px 10px; border-radius: 9px; background: var(--ink); color: #fff; font-size: 11px; line-height: 1.5; white-space: nowrap; box-shadow: var(--shadow-m); opacity: 0; transition: opacity .1s; direction: rtl; }
.chart-tip.on { opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; background: var(--ink); }
.legend i.dash { width: 14px; height: 0; border-radius: 0; background: none; border-top: 2px dashed #8c8c92; vertical-align: middle; }
.legend i.g1 { background: #6f6f75; } .legend i.g2 { background: #a8a8ae; }
.ring-wrap { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.ring-svg { position: relative; flex: none; }
.ring-svg .ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; text-align: center; }
.ring-center b { font-size: 21px; font-weight: 600; }
.ring-center span { font-size: 9.5px; color: var(--ink-3); margin-top: 2px; }
.ring-legend { display: flex; flex-direction: column; gap: 10px; font-size: 12px; }
.ring-legend div { display: flex; align-items: center; gap: 7px; }
.ring-legend i { width: 7px; height: 7px; border-radius: 50%; }
.ring-mini { display: inline-flex; position: relative; }
.ring-mini span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 8.5px; font-weight: 500; }

/* كروت المهام المائلة — توقيع التصميم */
.task-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 4px 2px 8px; }
.task-card { position: relative; display: flex; flex-direction: column; min-height: 164px; padding: 15px 15px 42px; background: var(--surface); border-radius: 22px; box-shadow: 0 10px 26px rgba(0,0,0,.09); transition: transform .2s; }
.task-card:nth-child(3n+1) { transform: rotate(-2.4deg); }
.task-card:nth-child(3n+2) { transform: rotate(1.6deg); }
.task-card:hover { transform: rotate(0) translateY(-3px); z-index: 2; }
.task-card.done { opacity: .6; } .task-card.done .task-title { text-decoration: line-through; }
.task-title { font-size: 15px; font-weight: 500; line-height: 1.4; margin: 8px 0 6px; }
.task-foot { position: absolute; bottom: 12px; inset-inline-start: 15px; inset-inline-end: 56px; font-size: 11px; color: var(--ink-3); }
.task-notch { position: absolute; bottom: 0; inset-inline-end: 0; width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; background: var(--ink); color: #fff; border-start-start-radius: 16px; border-end-end-radius: 22px; box-shadow: 0 0 0 5px rgba(255,255,255,.8); transition: background .15s; }
.task-notch:hover { background: #333; }
.task-notch.light { background: var(--surface-3); color: var(--ink); }
.add-card { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 164px; border: 1.5px dashed rgba(0,0,0,.42); border-radius: 22px; font-size: 14px; font-weight: 500; transition: background .15s; width: 100%; }
.add-card:hover { background: rgba(255,255,255,.4); }

.dark-card-title { font-size: 15px; font-weight: 500; }
.bullet { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--on-dark-2); }
.bullet::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.goal { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 0; font-size: 13px; text-align: start; }
.goal .box { flex: none; width: 17px; height: 17px; border-radius: 5px; border: 1.5px solid var(--ink-4); display: flex; align-items: center; justify-content: center; color: #fff; }
.goal.on .box { background: var(--ink); border-color: var(--ink); }
.goal:not(.on) span { color: var(--ink-3); }
.goal.on span { color: var(--ink); }

/* —— الجداول —— */
.table-wrap { overflow-x: auto; margin-inline: -4px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 8px 10px; font-size: 11.5px; font-weight: 500; color: var(--ink-3); text-align: start; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover td { background: var(--surface-2); }
.table td.actions { text-align: end; white-space: nowrap; }
.empty { padding: 34px 16px; text-align: center; color: var(--ink-3); font-size: 13px; }
.empty svg { display: block; margin: 0 auto 8px; opacity: .55; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person b { display: block; font-weight: 500; }
.person small { display: block; font-size: 11.5px; color: var(--ink-3); }

/* حالات */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.chip.solid { background: var(--ink); color: #fff; }
.chip.mid { background: #d9d9dc; color: var(--ink); }
.chip.line { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-2); }
.chip.faint { background: var(--surface-2); color: var(--ink-3); }
.chip.bad { background: var(--critical-bg); color: var(--critical); }

/* —— أدوات —— */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: rgba(255,255,255,.55); border: 1px solid var(--glass-line); border-radius: 999px; }
.tab { min-height: 32px; padding: 4px 14px; border-radius: 999px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; transition: background .15s; }
.tab:hover { background: rgba(0,0,0,.05); }
.tab.active { background: var(--ink); color: #fff; font-weight: 500; }
.tabs-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; margin-bottom: 14px; }
.tabs-scroll .tabs { flex-wrap: nowrap; }
.input, select.input, textarea.input { width: 100%; min-height: 38px; padding: 7px 12px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; font-size: 13px; transition: border-color .15s; }
.input:focus { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.input[type=date], .input[type=time], .input[type=datetime-local], .input[type=month], .input[type=number], .input[type=tel] { direction: ltr; text-align: right; }
textarea.input { resize: vertical; min-height: 76px; }
.search { position: relative; flex: 1 1 200px; min-width: 0; max-width: 320px; }
.search svg { position: absolute; inset-inline-start: 12px; top: 11px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-inline-start: 36px; border-radius: 999px; }
.input.pill { border-radius: 999px; width: auto; }
.date-nav { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-s); }
.date-nav b { min-width: 158px; text-align: center; font-size: 13px; font-weight: 500; }

/* —— النوافذ —— */
dialog.modal { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 28px); padding: 0; border: 0; border-radius: 26px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-l); overflow: hidden; }
dialog.modal[open] { display: flex; flex-direction: column; animation: pop .16s ease-out; }
dialog.modal.wide { width: min(820px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(22,22,24,.35); backdrop-filter: blur(4px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 10px; flex: none; }
.modal-head h3 { font-size: 17px; font-weight: 600; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); flex: none; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .field-label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.field .req { color: var(--critical); }
.field small { font-size: 11px; color: var(--ink-3); }
.form-section { grid-column: 1 / -1; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; font-weight: 600; }
.form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); margin: 0; flex: none; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 0; }
.alert { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; background: var(--surface-2); }
.alert.bad { background: var(--critical-bg); color: var(--critical); }
.alert.dark { background: var(--ink); color: #fff; }
.combo { position: relative; }
.combo-list { position: absolute; z-index: 30; inset-inline: 0; top: calc(100% + 4px); max-height: 220px; overflow-y: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-m); border: 1px solid var(--line); padding: 4px; }
.combo-item { display: block; width: 100%; padding: 8px 10px; border-radius: 10px; text-align: start; font-size: 13px; }
.combo-item:hover, .combo-item.active { background: var(--surface-2); }
.combo-item small { display: block; color: var(--ink-3); font-size: 11px; }

/* قائمة منبثقة داكنة كما في التصميم */
.menu { position: fixed; z-index: 1000; min-width: 158px; padding: 5px; background: var(--ink); color: #fff; border-radius: 12px; box-shadow: var(--shadow-m); animation: pop .12s ease-out; max-height: 70vh; overflow-y: auto; }
.menu button, .menu a { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%; padding: 7px 9px; border-radius: 8px; font-size: 12px; text-align: start; }
.menu button:hover, .menu a:hover { background: rgba(255,255,255,.13); }
.menu hr { border: 0; border-top: 1px solid rgba(255,255,255,.16); margin: 4px 0; }
.menu .danger { color: #ff9c9c; }
.pop-panel { position: fixed; z-index: 1000; width: min(360px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-l); padding: 8px; animation: pop .14s ease-out; }
.notif { display: flex; gap: 10px; padding: 10px; border-radius: 12px; width: 100%; text-align: start; }
.notif:hover { background: var(--surface-2); }
.notif .nic { flex: none; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface-2); }
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100vw - 24px)); }
.toast { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 13px; box-shadow: var(--shadow-m); animation: pop .16s ease-out; }
.toast.bad { background: var(--critical); }

/* —— لوحة المواعيد —— */
.board { display: grid; background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-s); overflow: auto; max-height: calc(100dvh - 210px); position: relative; }
.board-head { position: sticky; top: 0; z-index: 3; background: var(--surface); padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 500; text-align: center; min-width: 150px; }
.board-corner { position: sticky; top: 0; inset-inline-start: 0; z-index: 4; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 58px; }
.board-times { position: sticky; inset-inline-start: 0; z-index: 2; background: var(--surface); min-width: 58px; }
.board-time { display: flex; align-items: flex-start; justify-content: center; font-size: 10.5px; color: var(--ink-3); padding-top: 3px; border-top: 1px solid var(--line); box-sizing: border-box; }
.board-col { position: relative; border-inline-start: 1px solid var(--line); min-width: 150px; background-image: linear-gradient(var(--line) 1px, transparent 1px); }
.board-now { position: absolute; inset-inline: 0; height: 0; border-top: 2px solid var(--ink); z-index: 2; pointer-events: none; }
.board-now::before { content: ''; position: absolute; inset-inline-start: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
.slot { position: absolute; inset-inline: 0; cursor: copy; }
.slot:hover { background: rgba(0,0,0,.035); }
.appt { position: absolute; inset-inline: 4px; z-index: 1; padding: 5px 8px; border-radius: 10px; overflow: hidden; font-size: 11.5px; line-height: 1.35; text-align: start; background: var(--surface-2); border-inline-start: 3px solid var(--ink-4); transition: box-shadow .12s, transform .12s; }
.appt:hover { box-shadow: var(--shadow-m); z-index: 3; }
.appt b { display: block; font-weight: 500; font-size: 12px; }
.appt.s-confirmed { background: #e4e4e6; border-color: var(--ink-2); }
.appt.s-arrived { background: #fff; box-shadow: inset 0 0 0 1.5px var(--ink); border-color: var(--ink); }
.appt.s-in_chair { background: var(--ink); color: #fff; border-color: #fff; }
.appt.s-done { background: var(--surface-2); color: var(--ink-3); border-color: var(--surface-3); }
.appt.s-cancelled, .appt.s-no_show { background: repeating-linear-gradient(135deg, var(--surface-2), var(--surface-2) 5px, #fff 5px, #fff 10px); color: var(--ink-3); text-decoration: line-through; border-color: var(--surface-3); }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(148px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.week-col { background: rgba(255,255,255,.55); border: 1px solid var(--glass-line); border-radius: 18px; padding: 8px; min-height: 240px; }
.week-col.today { background: var(--surface); }
.week-col h4 { font-size: 12.5px; font-weight: 500; padding: 4px 4px 8px; display: flex; justify-content: space-between; }
.week-item { display: block; width: 100%; text-align: start; padding: 7px 9px; border-radius: 11px; background: var(--surface-2); margin-bottom: 5px; font-size: 11.5px; line-height: 1.35; }
.week-item b { display: block; font-weight: 500; }
.week-item:hover { background: var(--surface-3); }
.week-item.s-in_chair { background: var(--ink); color: #fff; }
.week-item.s-cancelled, .week-item.s-no_show { opacity: .5; text-decoration: line-through; }
.queue { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.queue-item { flex: 0 0 auto; min-width: 200px; text-align: start; padding: 11px 13px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-s); }
.queue-item.chair { background: var(--dark); color: #fff; }
.queue-item small { display: block; font-size: 11px; opacity: .65; }

/* —— مخطط الأسنان —— */
.dental { direction: ltr; overflow-x: auto; padding: 4px 0 10px; }
.dental-inner { min-width: 660px; }
.arch { display: flex; justify-content: center; gap: 3px; }
.arch .mid { width: 1px; margin: 4px 7px; background: var(--line-2); }
.arch-sep { height: 1px; margin: 12px 0; background: var(--line-2); }
.tooth { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 39px; padding: 4px 0; border-radius: 10px; transition: background .12s; }
.tooth:hover, .tooth.sel { background: var(--surface-2); }
.tooth span { font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tooth svg { display: block; }
.tooth.has span { color: var(--ink); font-weight: 600; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; }
.status-opt { display: flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 10px; font-size: 12px; background: var(--surface-2); text-align: start; }
.status-opt.on { background: var(--ink); color: #fff; }

.pt-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.pt-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--on-dark-2); margin-top: 4px; }
.pt-meta span { display: inline-flex; align-items: center; gap: 5px; }
.kv { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 7px 10px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-size: 12px; } .kv dd { margin: 0; }
.timeline-item { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.timeline-item:last-child { border-bottom: 0; }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumb { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface-2); display: block; }
.thumb img { display: block; width: 100%; height: 108px; object-fit: cover; }
.thumb .pdf { height: 108px; display: flex; align-items: center; justify-content: center; }
.thumb .cap { padding: 6px 9px; font-size: 11.5px; }

/* إحصاءات */
.stat { padding: 16px; }
.stat .label { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stat .value { font-size: 25px; font-weight: 500; letter-spacing: -.3px; margin-top: 3px; line-height: 1.3; }
.stat .value small { font-size: 12px; font-weight: 400; color: var(--ink-3); letter-spacing: 0; }
.stat .foot { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.card.dark.stat .label, .card.dark.stat .foot, .card.dark.stat .value small { color: var(--on-dark-2); }
.hbar { display: grid; grid-template-columns: minmax(84px, 130px) minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 5px 0; font-size: 12.5px; }
.hbar .track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; background: var(--ink); min-width: 2px; }
.meter { height: 6px; width: 100%; min-width: 74px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.meter.low i { background: var(--critical); }

/* صلاحيات */
.perm-table { border-collapse: separate; border-spacing: 0; font-size: 12.5px; width: 100%; }
.perm-table th, .perm-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.perm-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; font-size: 11.5px; font-weight: 600; min-width: 84px; }
.perm-table td:first-child, .perm-table th:first-child { position: sticky; inset-inline-start: 0; background: var(--surface); text-align: start; min-width: 240px; z-index: 1; }
.perm-table thead th:first-child { z-index: 3; }
.perm-table .group td { background: var(--surface-2); font-weight: 600; font-size: 12px; }
.perm-table td { text-align: center; }
.perm-table input { width: 16px; height: 16px; accent-color: var(--ink); }

/* الحضور بالموقع */
.geo-card { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: center; }
.radar { position: relative; width: 240px; height: 240px; margin: 0 auto; }
.radar > svg { display: block; width: 100%; height: 100%; }
.punch { position: absolute; inset: 58px; border-radius: 50%; background: var(--surface); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.35); transition: transform .15s; text-align: center; }
.punch:hover:not(:disabled) { transform: scale(1.04); }
.punch:disabled { opacity: .55; cursor: not-allowed; }
.pulse { animation: pulse 1.6s ease-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes pulse { 0% { opacity: .55; transform: scale(.55); } 100% { opacity: 0; transform: scale(1.05); } }
.geo-status { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* الدخول */
.login { position: fixed; inset: 0; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: min(920px, 100%); display: grid; grid-template-columns: 1.05fr 1fr; gap: 10px; padding: 12px; border-radius: 34px; background: rgba(255,255,255,.3); border: 1px solid rgba(255,255,255,.65); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: var(--shadow-m); }
.login-form { background: var(--surface); border-radius: 26px; padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.login-side { background: var(--dark); color: #fff; border-radius: 26px; padding: 32px; display: flex; flex-direction: column; justify-content: space-between; gap: 28px; min-height: 420px; }
.login-side h2 { font-size: 27px; font-weight: 500; line-height: 1.35; }
.demo-accounts { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-chip { padding: 5px 11px; border-radius: 999px; font-size: 11.5px; background: var(--dark-2); color: #fff; }
.demo-chip:hover { background: var(--dark-3); }

/* نسخة العرض */
.demo-page { position: fixed; inset: 0; overflow-y: auto; }
.demo-wrap { width: min(1180px, 100%); margin: 0 auto; padding: 20px 16px 48px; display: flex; flex-direction: column; gap: 26px; }
.demo-hero { display: flex; flex-direction: column; gap: 12px; padding: 30px 32px; border-radius: 28px; background: var(--dark); color: #fff; box-shadow: 0 14px 34px rgba(0,0,0,.22); }
.demo-hero h1 { font-size: 30px; font-weight: 500; line-height: 1.3; }
.demo-hero p { color: var(--on-dark-2); max-width: 620px; }
.demo-title { font-size: 19px; font-weight: 600; margin-bottom: 12px; padding-inline: 4px; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 14px; align-items: start; }
.role-card { display: flex; flex-direction: column; gap: 10px; }
.role-card h3 { font-size: 18px; font-weight: 600; }
.role-blurb { font-size: 13px; color: var(--ink-2); min-height: 60px; }
.role-card.dark .role-blurb, .role-card.dark .person small { color: var(--on-dark-2); }
.role-icon { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 50%; background: var(--surface-2); }
.role-card.dark .role-icon { background: var(--dark-2); }
.role-details summary { display: flex; align-items: center; justify-content: space-between; min-height: 32px; font-size: 12.5px; font-weight: 500; cursor: pointer; list-style: none; }
.role-details summary::-webkit-details-marker { display: none; }
.role-details[open] summary svg { transform: rotate(180deg); }
.role-group { padding: 8px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.role-card.dark .role-group { border-color: var(--dark-3); }
.role-group ul { margin: 4px 0 0; padding: 0; list-style: none; }
.role-group li { display: flex; align-items: flex-start; gap: 6px; padding: 2px 0; }
.role-group li svg { margin-top: 3px; }
.role-group.off p { color: var(--ink-3); margin-top: 2px; }
.role-card.dark .role-group.off p { color: var(--on-dark-2); }
.role-enter { width: 100%; margin-top: 4px; }
.mark { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle; }
.mark.full { background: var(--ink); }
.mark.part { background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); box-shadow: inset 0 0 0 1.5px var(--ink); }
.mark.none { width: 12px; height: 2px; border-radius: 2px; background: var(--ink-4); }
.demo-matrix { padding: 0; overflow: auto; }
.demo-matrix .perm-table td:first-child, .demo-matrix .perm-table th:first-child { min-width: 136px; }
.demo-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 7px 8px 7px 14px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 12.5px; }
@media (max-width: 620px) { .demo-hero { padding: 22px; } .demo-hero h1 { font-size: 23px; } .role-blurb { min-height: 0; } }

.loading { padding: 40px; text-align: center; color: var(--ink-3); }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 16px; min-height: 160px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* الطباعة */
.print-doc { font-size: 13px; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); margin-bottom: 14px; }
.print-totals { width: 240px; margin-inline-start: auto; margin-top: 10px; }
.print-totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.print-totals .total { border-top: 1.5px solid var(--ink); font-weight: 700; margin-top: 3px; padding-top: 6px; }
#print-root { display: none; }
@media print {
  @page { margin: 14mm; }
  html, body { overflow: visible; height: auto; background: #fff; }
  .bg, #app, dialog, .toast-host { display: none !important; }
  #print-root { display: block !important; }
  .card, .stat { box-shadow: none !important; border: 1px solid #ddd; }
}
body.print-page .shell { position: static; display: block; border: 0; background: none; box-shadow: none; padding: 0; backdrop-filter: none; }
@media print {
  body.print-page #app { display: block !important; }
  body.print-page .sidebar, body.print-page .topbar, body.print-page .toolbar, body.print-page .no-print { display: none !important; }
  body.print-page .main { overflow: visible; padding: 0; }
  body.print-page .shell { position: static; display: block; border: 0; background: none; box-shadow: none; padding: 0; backdrop-filter: none; }
  .chart-wrap, .card { break-inside: avoid; }
}

/* —— الشاشات الأصغر —— */
@media (max-width: 1240px) {
  .dash-top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-top > :first-child { grid-column: 1 / -1; }
  .dash-mid, .dash-bottom { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  body { overflow: auto; }
  .shell { position: static; display: block; min-height: 100dvh; padding: 0; border: 0; border-radius: 0; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
  .sidebar { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; z-index: 50; width: 268px; border-radius: 0; transform: translateX(105%); transition: transform .22s ease; box-shadow: var(--shadow-l); }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); }
  .main { overflow: visible; padding: 8px 16px 40px; }
  .icon-btn.menu-btn { display: inline-flex; }
  .topbar h1 { font-size: 19px; }
  .topbar .sub { font-size: 11px; }
  .topbar .hide-sm { display: none; }
  .icon-btn { width: 38px; height: 38px; }
  .avatar { width: 38px; height: 38px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .board { max-height: none; }
  .geo-card { grid-template-columns: minmax(0, 1fr); }
  .login-card { grid-template-columns: minmax(0, 1fr); }
  .login-side { min-height: 0; order: 2; }
}
@media (max-width: 620px) {
  .dash-top { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .task-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .big-stat b { font-size: 42px; }
  .search { max-width: none; flex-basis: 100%; }
  .pt-head { grid-template-columns: minmax(0, 1fr); }
  .stat .value { font-size: 21px; }
  .date-nav b { min-width: 120px; font-size: 12px; }
  .login-form, .login-side { padding: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
