/* خُطّة — هيكل مساحة العمل ولوحة التحكم ومكونات مشتركة.
 * القيم مطابقة لأصناف Tailwind في AppShell.tsx و NavLinks.tsx و BottomNav.tsx و dashboard/page.tsx.
 * نقاط التجاوب كما في tailwind.config.ts: xs 360 · sm 640 · lg 1025.
 */

/* ── أدوات عامة ── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.text-overline { font-size: 11px; line-height: 1.6; font-weight: 600; }
.text-brass { color: var(--kh-brass-text); }
.text-action { color: var(--kh-action); }
.text-faint { color: var(--kh-ink-faint); }
.shrink-0 { flex-shrink: 0; }
.icon-xs { width: 14px; height: 14px; }
.icon-nav { width: 18px; height: 18px; flex-shrink: 0; }

/* ── طبقة «Premium» من globals.css ── */
.khutah-premium-shell { background: var(--kh-paper-100); }
.khutah-premium-sidebar { background: var(--kh-paper-0); box-shadow: inset -1px 0 0 var(--kh-brass-rule-soft); }
.khutah-premium-brand {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  border-radius: 8px; background: var(--kh-action); color: var(--kh-action-on);
  box-shadow: inset 0 0 0 1px var(--kh-brass); font-family: var(--kh-font-display); line-height: 1;
}
.khutah-premium-main :is(button, a, input, select, textarea) { transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease; }
.brand-lg { width: 44px; height: 44px; font-size: 24px; }
.brand-sm { width: 36px; height: 36px; font-size: 18px; }

/* ── الهيكل ── */
.shell { margin: 0 auto; display: flex; min-height: 100dvh; max-width: 1440px; }
.skip-link { position: absolute; inset-inline-start: 8px; top: -100px; z-index: 50; border-radius: 8px; background: var(--kh-paper-0); padding: 8px; }
.skip-link:focus { top: 8px; }

.sidebar {
  position: sticky; top: 0; z-index: 40; display: none; height: 100dvh; width: 256px; flex-shrink: 0;
  flex-direction: column; border-inline-end: 1px solid var(--kh-rule);
}
@media (min-width: 1025px) { .sidebar { display: flex; } }
.sidebar-head { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--kh-rule); padding: 20px 16px; }
.sidebar-titles { min-width: 0; flex: 1; }
.brand-sub { font-weight: 400; color: var(--kh-ink-muted); }
.ws-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; line-height: 1.5; font-weight: 600; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px; }
.sidebar-foot { border-top: 1px solid var(--kh-rule); padding: 12px; }

.nav-list { display: flex; flex-direction: column; gap: 6px; }
.nav-link {
  display: flex; min-height: var(--kh-tap-min); align-items: center; gap: 12px; border-radius: 8px;
  border-inline-start: 3px solid transparent; padding-inline: 11px 14px;
  font-size: 14px; font-weight: 500; color: var(--kh-ink-2); transition: background-color 150ms, color 150ms;
}
.nav-link:hover { background: var(--kh-paper-100); color: var(--kh-action); }
.nav-link.is-active { border-inline-start-color: var(--kh-brass); background: var(--kh-action-tint); color: var(--kh-action); }

.user-footer { display: flex; flex-direction: column; gap: 8px; }
.user-id { padding: 0 4px; }
.user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; text-align: end; }
.footer-link {
  display: flex; width: 100%; min-height: var(--kh-tap-min); align-items: center; gap: 8px;
  border-radius: 8px; padding: 0 8px; color: var(--kh-ink-muted);
}
.footer-link:hover { background: var(--kh-paper-100); color: var(--kh-ink); }

.shell-body { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--kh-rule); padding: max(0.25rem, env(safe-area-inset-top, 0px)) 8px 4px;
}
@media (min-width: 1025px) { .topbar { display: none; } }
.topbar-title { min-width: 0; flex: 1; }
.icon-btn {
  position: relative; display: inline-flex; width: 48px; height: 48px; flex-shrink: 0;
  align-items: center; justify-content: center; border-radius: 8px; color: var(--kh-ink);
}
.icon-btn:hover { background: var(--kh-paper-100); }
.bell-badge {
  position: absolute; inset-inline-end: -2px; top: -2px; display: inline-flex; min-width: 20px;
  align-items: center; justify-content: center; border-radius: 999px; background: var(--kh-danger);
  padding: 0 4px; font-size: 11px; font-weight: 700; line-height: 20px; color: var(--kh-action-on);
}

.shell-main { margin: 0 auto; width: 100%; max-width: 1200px; flex: 1; padding: 20px 16px; }
@media (min-width: 640px) { .shell-main { padding: 28px 24px; } }
@media (min-width: 1025px) { .shell-main { padding-inline: 32px; } }
.bottomnav-spacer { height: var(--kh-bottomnav-total); flex-shrink: 0; }
@media (min-width: 1025px) { .bottomnav-spacer { display: none; } }

/* ── درج الجوال (popover أصلي) ── */
.drawer {
  margin: 0; inset-block: 0; inset-inline-start: 0; inset-inline-end: auto;
  height: 100dvh; max-height: 100dvh; width: 85vw; max-width: 320px; padding: 0; border: 0;
  border-inline-start: 1px solid var(--kh-brass-rule-soft); color: var(--kh-ink);
}
.drawer::backdrop { background: color-mix(in srgb, var(--kh-ink) 40%, transparent); }
.drawer-inner { display: flex; height: 100%; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--kh-rule); background: var(--kh-paper-50); padding: 16px; }
.drawer-brand { display: flex; min-width: 0; align-items: center; gap: 12px; }
.drawer-titles { display: flex; min-width: 0; flex-direction: column; }
.drawer-app { font-weight: 700; color: var(--kh-ink); }
.drawer-ws { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.drawer-foot { padding-bottom: calc(var(--kh-safe-bottom) + 0.75rem); }

/* ── الشريط السفلي (الجوال فقط) ── */
.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40; border-top: 1px solid var(--kh-brass-rule-soft);
  padding-bottom: var(--kh-safe-bottom); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
@media (min-width: 1025px) { .bottomnav { display: none; } }
.bottomnav ul { margin: 0 auto; display: flex; max-width: 1200px; }
.bottomnav li { min-width: 0; flex: 1; }
.bottomnav li.slot-fifth { display: none; }
@media (min-width: 360px) { .bottomnav li.slot-fifth { display: block; } }
.slot {
  display: flex; height: var(--kh-bottomnav-h); min-height: var(--kh-tap-min); flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; padding: 6px 2px 4px;
  border-top: 3px solid transparent; color: var(--kh-ink-2); transition: color 150ms;
}
.slot.is-active { border-top-color: var(--kh-brass); background: var(--kh-action-tint); font-weight: 600; color: var(--kh-action); }
.slot-label { width: 100%; text-align: center; font-size: 11px; line-height: 1.2; font-weight: 600; }

/* ── صفحة عامة ── */
.page { display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.page-title { font-size: 22px; line-height: 32px; font-weight: 700; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; border: 1px solid var(--kh-rule);
  border-radius: 8px; background: var(--kh-paper-0); padding: 48px 24px; text-align: center;
}
.empty-title { margin-top: 16px; font-size: 20px; line-height: 1.5; font-weight: 600; color: var(--kh-ink); }
.empty-desc { margin-top: 8px; max-width: var(--kh-reading-measure); color: var(--kh-ink-2); }
.empty-action { margin-top: 24px; }

.chip { display: inline-flex; align-items: center; border: 1px solid var(--kh-rule); border-radius: 4px; background: var(--kh-paper-100); padding: 2px 8px; font-size: 12.5px; line-height: 1.6; color: var(--kh-ink-2); }

.breadcrumb { font-size: 12.5px; line-height: 1.6; color: var(--kh-ink-2); }
.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.crumb-sep { padding: 0 2px; }
.crumb-link, .crumb-current { display: inline-block; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 14px 8px; margin: 0 -8px; vertical-align: middle; }
.crumb-link:hover { color: var(--kh-ink); text-decoration: underline; }
.crumb-current { color: var(--kh-ink); }

/* ── شارة الحالة: نص + أيقونة + مسطرة لونية ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border-radius: 4px;
  border-inline-start: 3px solid; padding: 2px 8px; font-size: 12px; line-height: 18px; font-weight: 500;
}
.badge-unknown { border: 1px dashed; }
.st-stone { border-color: var(--kh-st-stone-rule); background: var(--kh-st-stone-tint); color: var(--kh-st-stone); }
.st-indigo { border-color: var(--kh-st-indigo-rule); background: var(--kh-st-indigo-tint); color: var(--kh-st-indigo); }
.st-violet { border-color: var(--kh-st-violet-rule); background: var(--kh-st-violet-tint); color: var(--kh-st-violet); }
.st-teal { border-color: var(--kh-st-teal-rule); background: var(--kh-st-teal-tint); color: var(--kh-st-teal); }
.st-slate { border-color: var(--kh-st-slate-rule); background: var(--kh-st-slate-tint); color: var(--kh-st-slate); }
.st-moss { border-color: var(--kh-st-moss-rule); background: var(--kh-st-moss-tint); color: var(--kh-st-moss); }
.st-brass { border-color: var(--kh-st-brass-rule); background: var(--kh-st-brass-tint); color: var(--kh-st-brass); }
.st-crimson { border-color: var(--kh-st-crimson-rule); background: var(--kh-st-crimson-tint); color: var(--kh-st-crimson); }
.st-ink { border-color: var(--kh-st-ink-rule); background: var(--kh-st-ink-tint); color: var(--kh-st-ink); }

/* ── اللوحات ── */
.panel { overflow: hidden; border: 1px solid var(--kh-rule); border-radius: 12px; background: var(--kh-paper-0); }
.panel-title { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--kh-rule); padding: 14px 16px; font-size: 18px; line-height: 28px; font-weight: 600; color: var(--kh-ink); }
.panel-empty { padding: 20px 16px; font-size: 12.5px; line-height: 1.6; color: var(--kh-ink-2); }
@media (min-width: 640px) { .panel-title, .panel-empty { padding-inline: 20px; } }
.row-list > li { border-bottom: 1px solid var(--kh-rule); }
.row-list > li:last-child { border-bottom: 0; }

/* ── لوحة التحكم ── */
.dash { display: flex; flex-direction: column; gap: 24px; padding-bottom: 40px; }
.dash-head { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 640px) { .dash-head { flex-direction: row; align-items: flex-end; justify-content: space-between; } }
.dash-head-text { min-width: 0; }
.dash-kicker { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; line-height: 1.6; font-weight: 600; color: var(--kh-brass-text); }
.dash-title { margin-top: 4px; font-family: var(--kh-font-display); font-size: 31px; line-height: 1.15; font-weight: 700; color: var(--kh-ink); }
.dash-rule { margin-top: 10px; display: block; height: 2px; width: 56px; border-radius: 999px; background: var(--kh-brass); }
.dash-summary { margin-top: 12px; color: var(--kh-ink-2); }
.dash-head-side { display: flex; flex-shrink: 0; flex-direction: column; align-items: stretch; gap: 12px; }
@media (min-width: 640px) { .dash-head-side { align-items: flex-end; } .dash-date { text-align: end; } }
.dash-date { font-size: 12.5px; line-height: 1.6; color: var(--kh-ink-2); }
.dash-head-side .btn { padding-inline: 20px; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 12px; }
@media (min-width: 640px) { .stats { gap: 16px; } }
@media (min-width: 1025px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.span-2 { grid-column: span 2 / span 2; }
@media (min-width: 1025px) { .span-2 { grid-column: span 1 / span 1; } }
.stat-card {
  position: relative; display: flex; min-height: 7.5rem; flex-direction: column; justify-content: space-between; gap: 12px;
  overflow: hidden; border: 1px solid var(--kh-rule); border-radius: 12px; background: var(--kh-paper-0); padding: 16px;
}
@media (min-width: 640px) { .stat-card { padding: 20px; } }
.stat-ring { pointer-events: none; position: absolute; inset-inline-end: -40px; top: -48px; width: 144px; height: 144px; border-radius: 999px; border: 1px solid var(--kh-rule-strong); }
.stat-top { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stat-label { min-width: 0; font-size: 14.5px; line-height: 1.5; font-weight: 600; color: var(--kh-ink-2); }
.stat-chip { display: flex; width: 40px; height: 40px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 8px; }
.stat-value { position: relative; font-family: var(--kh-font-display); font-size: 27px; line-height: 1; font-weight: 700; color: var(--kh-ink); }
.chip-brass { background: var(--kh-brass-tint); color: var(--kh-brass-text); }
.chip-action { background: var(--kh-action-tint); color: var(--kh-action); }
.chip-indigo { background: var(--kh-st-indigo-tint); color: var(--kh-st-indigo); }

.dash-cols { display: grid; align-items: start; gap: 20px; }
@media (min-width: 1025px) { .dash-cols { grid-template-columns: repeat(5, minmax(0, 1fr)); } .dash-main { grid-column: span 3 / span 3; } .dash-side { grid-column: span 2 / span 2; } }
.dash-side { display: flex; flex-direction: column; gap: 20px; }

.upcoming-row { display: flex; min-height: var(--kh-tap-min); align-items: center; gap: 12px; padding: 12px 16px; }
.upcoming-row:hover { background: var(--kh-paper-50); }
@media (min-width: 640px) { .upcoming-row { padding-inline: 20px; } }
.date-box { display: flex; width: 48px; height: 48px; flex-shrink: 0; flex-direction: column; align-items: center; justify-content: center; border-radius: 8px; background: var(--kh-action-tint); color: var(--kh-action); }
.date-day { font-size: 14.5px; line-height: 1; font-weight: 600; }
.date-month { margin-top: 4px; font-size: 11px; line-height: 1; font-weight: 600; }
.upcoming-text { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 2px; }
.upcoming-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; line-height: 1.5; font-weight: 600; color: var(--kh-ink); }

.status-list { display: flex; flex-direction: column; padding: 4px 8px; }
@media (min-width: 640px) { .status-list { padding-inline: 12px; } }
.status-row { display: flex; min-height: var(--kh-tap-min); flex-direction: column; justify-content: center; gap: 8px; border-radius: 8px; padding: 8px; }
.status-row:hover { background: var(--kh-paper-50); }
.status-row-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status-count { display: flex; flex-shrink: 0; align-items: center; gap: 6px; font-size: 14.5px; font-weight: 600; color: var(--kh-ink); }
.bar { display: block; height: 6px; overflow: hidden; border-radius: 999px; background: var(--kh-paper-200); }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--kh-action); }

.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px; }
@media (min-width: 640px) { .quick-grid { padding: 20px; } }
.quick-link { display: flex; min-height: 5.5rem; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); padding: 12px 8px; text-align: center; }
.quick-link:hover { border-color: var(--kh-action); background: var(--kh-action-tint); }
.quick-label { font-size: 12.5px; line-height: 1.375; font-weight: 600; color: var(--kh-ink); }

/* ── الإشعارات: نافذة منبثقة من الجرس ── */
.bell-wrap { position: relative; flex-shrink: 0; }
.bell-badge[hidden] { display: none; }
.notif-panel {
  z-index: 50; display: flex; max-height: 70dvh; flex-direction: column; overflow: hidden;
  border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); color: var(--kh-ink);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.28);
}
.notif-panel[hidden] { display: none; }
/* الحاسوب: تحت الجرس وتمتد نحو المحتوى */
.notif-panel-sidebar { position: absolute; inset-inline-start: 0; top: 52px; width: 384px; }
/* الجوال: بعرض الشاشة تحت الشريط العلوي (مع الحافة الآمنة) */
.notif-panel-header { position: fixed; inset-inline: 8px; top: calc(3.5rem + env(safe-area-inset-top, 0px)); }
.notif-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--kh-rule); padding: 8px 16px; }
.notif-panel-title { font-weight: 600; }
.notif-readall { display: inline-flex; min-height: 44px; align-items: center; gap: 4px; border-radius: 8px; padding: 0 8px; font-size: 12.5px; font-weight: 500; color: var(--kh-action); }
.notif-readall:hover:not(:disabled) { background: var(--kh-paper-100); }
.notif-readall:disabled { opacity: 0.4; cursor: default; }
.notif-panel-body { overflow-y: auto; }
.notif-empty { display: flex; align-items: center; gap: 8px; padding: 16px; color: var(--kh-ink-muted); }
.notif-list > li + li { border-top: 1px solid var(--kh-rule); }
.notif-item { display: flex; width: 100%; gap: 12px; border-inline-start: 3px solid transparent; padding: 12px 16px; text-align: start; }
.notif-item:hover { background: var(--kh-paper-100); }
.notif-item.is-unread { border-inline-start-color: var(--kh-brass); background: var(--kh-action-tint); }
.notif-dot { margin-top: 8px; width: 8px; height: 8px; flex-shrink: 0; border-radius: 999px; }
.is-unread .notif-dot { background: var(--kh-action); }
.notif-text { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.is-unread .notif-title { font-weight: 600; }
.notif-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--kh-ink); }

/* ═════════ المرحلة 2ب: صفحات التخطيط ═════════ */
.page-tight { display: flex; flex-direction: column; }
.page-tight > .page-title { margin-top: 8px; }
.strong { font-weight: 600; }
.strong-md { font-weight: 500; }
.grow { min-width: 0; flex: 1; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.py-2 { padding-block: 8px; }
.text-end { text-align: end; }
.handle { margin-inline-end: 8px; }

.box { border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); padding: 16px; }
.box-title { font-size: 20px; line-height: 1.5; font-weight: 600; }
.box > .box-title + form, .box > .box-title + .form-stack-sm { margin-top: 12px; }
.box-section { margin-top: 16px; border-top: 1px solid var(--kh-rule); padding-top: 16px; }
.box-section-sm { margin-top: 12px; border-top: 1px solid var(--kh-rule); padding-top: 12px; }
.form-stack-sm { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; gap: 12px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .col-span-2 { grid-column: span 2 / span 2; } }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form .field { flex: 1; }
.alert-link { margin-top: 4px; display: inline-block; font-weight: 600; text-decoration: underline; }

.ok-banner {
  margin-top: 16px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--kh-st-moss-rule);
  border-radius: 8px; background: var(--kh-success-tint); padding: 12px; color: var(--kh-success-text);
}

.detail-head { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--kh-rule); padding-bottom: 16px; }
.toggle-form { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.two-col { display: grid; gap: 16px; }
@media (min-width: 1025px) { .two-col { grid-template-columns: minmax(0, 1fr) 320px; } }
.side-col { display: flex; flex-direction: column; gap: 16px; }

.divided > li + li { border-top: 1px solid var(--kh-rule); }
.plan-row { display: flex; align-items: center; gap: 8px; padding: 12px 0; }
.plan-row:hover { text-decoration: underline; }
.domain-row { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.account-list { display: flex; flex-direction: column; gap: 4px; }

.pill { display: inline-flex; border-radius: 4px; padding: 2px 8px; font-size: 12px; line-height: 18px; font-weight: 500; }
.pill-ok { background: var(--kh-success-tint); color: var(--kh-success-text); }
.pill-off { border: 1px solid var(--kh-rule); background: var(--kh-paper-100); color: var(--kh-ink-muted); }

.desktop-only { display: none; }
@media (min-width: 1025px) { .desktop-only { display: table; } .mobile-only { display: none; } }
.data-table { width: 100%; overflow: hidden; border-collapse: separate; border-spacing: 0; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); text-align: start; }
.data-table thead { background: var(--kh-paper-100); font-size: 12.5px; color: var(--kh-ink-2); }
.data-table th { padding: 8px 16px; text-align: start; font-weight: 500; }
.data-table td { padding: 12px 16px; border-top: 1px solid var(--kh-rule); }
.data-table td.cell-end { padding-block: 4px; text-align: end; }
.link-action { display: inline-flex; min-height: var(--kh-tap-min); align-items: center; border-radius: 8px; padding: 0 12px; font-weight: 500; color: var(--kh-action); }
.link-action:hover { background: var(--kh-paper-100); text-decoration: underline; }
.card-list { display: flex; flex-direction: column; gap: 8px; }
.card-link { display: flex; align-items: center; gap: 12px; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); padding: 16px; }
.meta-row { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--kh-ink-2); }

.segmented { display: inline-flex; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); padding: 2px; }
.seg { display: inline-flex; min-height: var(--kh-tap-min); align-items: center; border-radius: 4px; padding: 0 12px; font-weight: 500; }
.seg:hover { background: var(--kh-paper-100); }
.seg.is-on { background: var(--kh-action); color: var(--kh-action-on); }

.item-list { overflow: hidden; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); }
.item-list > li + li { border-top: 1px solid var(--kh-rule); }
.item-list > li.is-new { background: var(--kh-st-indigo-tint); }
.item-link { display: flex; flex-direction: column; gap: 4px; padding: 16px; }
.item-link:hover { background: var(--kh-paper-100); }
.item-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--kh-ink-2); }
.page-tight > .alert-danger { margin-top: 16px; }

/* ═════════ المرحلة 2ج: عناصر المحتوى ═════════ */
.narrow { margin-inline: auto; max-width: 48rem; width: 100%; }
.block { display: block; }
.textarea { min-height: 8rem; padding-block: 10px; line-height: 1.9; resize: vertical; }
.legend { padding: 0 4px; font-size: 20px; line-height: 1.5; font-weight: 600; }
fieldset.box { margin: 0; min-width: 0; }
.check-box { display: block; cursor: pointer; }
.check-row { display: flex; align-items: center; gap: 8px; border-radius: 8px; background: var(--kh-paper-100); padding: 12px; font-weight: 500; cursor: pointer; }
.check-row input, .check-box input { width: 16px; height: 16px; }
select.field:disabled, input.field:disabled { opacity: .55; cursor: not-allowed; }

.item-head { margin-top: 12px; border-bottom: 1px solid var(--kh-rule); padding-bottom: 16px; }
.item-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stage-track { padding: 12px; }
.stage-track ol { display: flex; flex-direction: column; gap: 6px; }
@media (min-width: 1025px) { .stage-track ol { flex-direction: row; gap: 8px; } .stage-track li { flex: 1; min-width: 0; } }
.stage { display: flex; min-height: var(--kh-tap-min); align-items: center; gap: 8px; border-radius: 4px; border-inline-start: 3px solid transparent; padding: 0 8px; font-size: 12.5px; color: var(--kh-ink-muted); }
@media (min-width: 1025px) {
  .stage { min-height: 0; flex-direction: column; align-items: flex-start; gap: 4px; border-inline-start: 0; border-top: 3px solid var(--kh-rule); padding: 8px 8px 4px; }
  .stage.is-active { border-top-color: var(--kh-brass); }
}
.stage.is-active { border-inline-start-color: var(--kh-brass); background: var(--kh-action-tint); font-weight: 600; color: var(--kh-action); }
.stage-none { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid var(--kh-rule); padding-top: 8px; font-size: 12.5px; color: var(--kh-ink-2); }

.main-col { display: flex; min-width: 0; flex-direction: column; gap: 12px; }
.item-section { padding: 0; }
.section-summary { display: flex; min-height: var(--kh-tap-min); cursor: pointer; list-style: none; align-items: center; justify-content: space-between; gap: 8px; padding: 0 16px; }
.section-summary::-webkit-details-marker { display: none; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 20px; line-height: 1.5; font-weight: 600; }
.count { border: 1px solid var(--kh-rule); border-radius: 4px; background: var(--kh-paper-100); padding: 0 6px; font-size: 12.5px; font-weight: 500; color: var(--kh-ink-2); }
.summary-chevron { transition: transform .15s; }
details[open] > summary .summary-chevron { transform: rotate(-90deg); }
.section-body { border-top: 1px solid var(--kh-rule); padding: 16px; }
.icon-line { display: flex; align-items: center; gap: 4px; }
.script-body { margin-top: 12px; white-space: pre-wrap; line-height: 1.75rem; }
.link-inline { word-break: break-all; color: var(--kh-action); text-decoration: underline; text-underline-offset: 2px; }
.version-list { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.version { border: 1px solid var(--kh-rule); border-radius: 8px; }
.version-summary { display: flex; min-height: var(--kh-tap-min); cursor: pointer; list-style: none; align-items: center; gap: 12px; padding: 0 12px; }
.version-summary::-webkit-details-marker { display: none; }
.version-body { border-top: 1px solid var(--kh-rule); padding: 12px; }
.tag-new { border-radius: 4px; background: var(--kh-st-indigo-tint); padding: 0 6px; font-size: 11.5px; color: var(--kh-action); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.push-end { margin-inline-start: auto; flex-shrink: 0; }
.mt-5 { margin-top: 20px; }
.file-row { padding: 10px 0; }
.revision { border: 1px solid var(--kh-rule); border-radius: 8px; padding: 12px; }

.dl > .dl-row + .dl-row { border-top: 1px solid var(--kh-rule); }
.dl-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 8px 0; }
.dl-row dt { flex-shrink: 0; }
.dl-row dd { margin: 0; min-width: 0; text-align: end; }
.activity-summary { display: flex; min-height: var(--kh-tap-min); cursor: pointer; align-items: center; font-weight: 600; color: var(--kh-action); }
.activity-list { margin-top: 8px; display: flex; flex-direction: column; gap: 16px; border-inline-start: 2px solid var(--kh-rule); padding-inline-start: 16px; }
.comment { border-radius: 8px; background: var(--kh-paper-100); padding: 12px; }
.comment-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--kh-ink-2); }
.tag { border: 1px solid var(--kh-rule); border-radius: 4px; background: var(--kh-paper-0); padding: 0 6px; }
.text-ink { color: var(--kh-ink); }

/* ═════════ المرحلة 3أ: قوائم المهام والكتابة والمراجعة ═════════ */
.queue { overflow: hidden; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); }
.queue-head { display: none; }
.queue-row { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.queue-title { font-weight: 600; color: var(--kh-ink); }
.queue-title:hover { text-decoration: underline; }
.queue-title::after { content: ""; position: absolute; inset: 0; }
.queue-version { display: flex; align-items: center; gap: 8px; }
.queue-cta { position: relative; z-index: 1; display: none; min-height: var(--kh-tap-min); width: 7rem; align-items: center; justify-content: center; border: 1px solid var(--kh-st-indigo-rule); border-radius: 8px; padding: 0 12px; font-weight: 600; color: var(--kh-action); }
.queue-cta:hover { background: var(--kh-st-indigo-tint); }
.mobile-label { display: inline; }
@media (min-width: 1025px) {
  .queue-head, .queue-row { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr) minmax(0, 0.9fr) auto; align-items: center; gap: 16px; }
  .queue-head { border-bottom: 1px solid var(--kh-rule); background: var(--kh-paper-100); padding: 8px 16px; font-size: 12.5px; color: var(--kh-ink-2); }
  .queue-head span:last-child { width: 7rem; }
  .queue-row { padding-block: 4px; }
  .queue-title { display: inline-block; padding-block: 12px; }
  .queue-title::after { content: none; }
  .queue-cta { display: inline-flex; }
  .mobile-label, .mobile-inline { display: none; }
  .queue-row .text-muted { color: var(--kh-ink); }
}
.returned { display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; background: var(--kh-warning-tint); padding: 2px 8px; font-size: 12px; color: var(--kh-warning-text); }

.action-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.revision-alert { margin-bottom: 16px; border: 1px solid var(--kh-st-brass-rule); border-radius: 8px; background: var(--kh-warning-tint); padding: 12px; color: var(--kh-warning-text); }
.revision-alert .script-body-tight { white-space: pre-wrap; color: var(--kh-ink); }
.decision-grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .decision-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
.decision-option > summary { list-style: none; width: 100%; cursor: pointer; }
.decision-option > summary::-webkit-details-marker { display: none; }
.decision-option[open] { border: 1px solid var(--kh-rule); border-radius: 8px; padding: 12px; }

/* ═════════ المرحلة 3ب: الإنتاج والرفع ومدير المشروع ═════════ */
.mt-8 { margin-top: 32px; }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: 13px; }
.file-pick { cursor: pointer; }
.upload-zone { margin-bottom: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; border: 1px dashed var(--kh-field-border); border-radius: 8px; padding: 16px; }
.upload-jobs { display: flex; width: 100%; flex-direction: column; gap: 6px; }
.upload-job { display: grid; grid-template-columns: minmax(0, 1fr) 120px; align-items: center; gap: 4px 12px; font-size: 12.5px; }
.upload-job .upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.upload-job .upload-status { grid-column: 1 / -1; color: var(--kh-ink-2); }
.upload-job.is-error .upload-status { color: var(--kh-danger-text); }
.upload-job progress { width: 120px; accent-color: var(--kh-action); }
.file-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.file-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.file-actions form { margin: 0; }
.file-preview { margin-top: 10px; max-height: 320px; max-width: 100%; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-100); }
.file-versions { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--kh-ink-2); }
.file-versions .link-inline { margin-inline-start: 8px; }
.snapshot-list { display: flex; flex-direction: column; gap: 4px; padding-inline-start: 4px; font-size: 13px; }
.snapshot-list li::before { content: "• "; color: var(--kh-ink-muted); }
.awaiting { border-color: var(--kh-st-moss-rule); }
.awaiting-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; }
.desktop-inline { display: none; }
@media (min-width: 1025px) { .desktop-inline { display: inline-flex; } }

/* ═════════ المرحلة 3ج: النشر ودورة الحياة ═════════ */
.filters { overflow-x: auto; }
.filters ul { display: flex; gap: 8px; }
.filter { display: inline-flex; min-height: var(--kh-tap-min); align-items: center; gap: 8px; white-space: nowrap; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); padding: 0 12px; font-weight: 500; }
.filter:hover { background: var(--kh-paper-100); }
.filter.is-on { border-color: var(--kh-action); background: var(--kh-action); color: var(--kh-action-on); }
.filter-count { border-radius: 4px; background: var(--kh-paper-100); padding: 0 6px; font-size: 11.5px; color: var(--kh-ink-muted); }
.filter.is-on .filter-count { background: color-mix(in srgb, var(--kh-paper-0) 20%, transparent); color: inherit; }
.pub-row { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
@media (min-width: 1025px) { .pub-row { flex-direction: row; align-items: center; } }
.pub-title { display: inline-block; padding-block: 12px; }
.pub-title:hover { text-decoration: underline; }
.pub-actions { flex-shrink: 0; }
.pub-form { display: flex; flex-direction: column; gap: 6px; min-width: 240px; }
.muted-box { background: var(--kh-paper-100); }
.lifecycle { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.lifecycle .decision-option[open] { flex-basis: 100%; }

/* ═════════ المرحلة 3ج-2: بوابة المؤثر ═════════ */
.lib-levels { display: inline-flex; align-self: flex-start; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); padding: 2px; }
.lib-head { margin-top: 16px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.day-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.field-sm { min-height: 40px; width: auto; }
.lib-cards { display: grid; gap: 12px; }
@media (min-width: 640px) { .lib-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1025px) { .lib-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.lib-card { display: flex; flex-direction: column; }
.lib-card .btn { align-self: flex-start; margin-top: auto; }
.lib-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; }
.month-grid { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 4px; }
.month-grid th { padding: 4px; font-size: 12px; font-weight: 500; color: var(--kh-ink-2); }
.month-cell { display: flex; min-height: 64px; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); }
.month-cell:hover { border-color: var(--kh-field-border); }
.month-cell.has-items { border-color: var(--kh-action); }
.month-cell.is-today { box-shadow: inset 0 0 0 2px var(--kh-brass); }
.month-day { font-weight: 600; }
.month-count { border-radius: 999px; background: var(--kh-action); padding: 0 8px; font-size: 11.5px; font-weight: 600; color: var(--kh-action-on); }
.year-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .year-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.year-cell { display: flex; min-height: 72px; flex-direction: column; justify-content: center; gap: 4px; border: 1px solid var(--kh-rule); border-radius: 8px; background: var(--kh-paper-0); padding: 12px; }
.year-cell.has-items { border-color: var(--kh-action); }
.year-cell:hover { background: var(--kh-paper-100); }
.portal-file .file-preview { margin-top: 0; }

/* ═════════ الفريق ═════════ */
.role-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; border: 0; padding: 0; }
.role-checks legend { margin-bottom: 4px; }
.role-check { display: inline-flex; min-height: 40px; align-items: center; gap: 6px; cursor: pointer; }
.role-check input { width: 16px; height: 16px; }
.danger-zone { border-color: var(--kh-st-crimson-rule); }

/* ═════════ التقويم ═════════ */
.cal-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 12px; }
.cal-filter { display: flex; flex-direction: column; min-width: 140px; }
.cal-filter .field-label { font-size: 12.5px; }
.cal-filter-actions { display: flex; gap: 6px; }
.cal-grid { width: 100%; table-layout: fixed; border-collapse: collapse; background: var(--kh-paper-0); border: 1px solid var(--kh-rule); }
.cal-grid th { padding: 6px; border-bottom: 1px solid var(--kh-rule); font-size: 12px; font-weight: 500; color: var(--kh-ink-2); }
.cal-grid td { height: 110px; vertical-align: top; padding: 4px; border: 1px solid var(--kh-rule); }
.cal-grid td.is-out { background: var(--kh-paper-100); }
.cal-grid td.is-today { box-shadow: inset 0 0 0 2px var(--kh-brass); }
.cal-day { display: block; font-size: 12px; font-weight: 600; color: var(--kh-ink-2); }
.cal-item { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--kh-rule); border-radius: 6px; background: var(--kh-paper-50); padding: 4px 6px; font-size: 12px; }
.cal-item:hover { border-color: var(--kh-field-border); }
.cal-item.is-target { border-style: dashed; }
.cal-item .badge { align-self: flex-start; font-size: 11px; padding: 0 6px; }
.cal-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--kh-ink); }
.cal-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--kh-ink-2); }
.cal-mday { border-bottom: 1px solid var(--kh-rule); padding: 12px 0; }

/* ═════════ صورة المؤثر ═════════ */
.avatar-row { display: flex; align-items: flex-start; gap: 12px; }
.avatar { width: 64px; height: 64px; flex-shrink: 0; border-radius: 999px; object-fit: cover; }
.avatar-empty { display: grid; place-items: center; border: 2px dashed var(--kh-rule); font-size: 11px; color: var(--kh-ink-2); text-align: center; }
.avatar-gold { box-shadow: 0 0 0 2px var(--kh-brass); }
.portal-hello { display: flex; align-items: center; gap: 12px; }
.file-input { font-size: 12.5px; }

/* مشاركة ملف من البوابة */
.share-msg[hidden] { display: none; }
.link-strong { font-weight: 500; color: var(--kh-action); text-decoration: underline; }
