/* هوية Control Circutis: العنابي والأزرق */
:root {
  --m: #872835; --m-2: #a33545; --m-soft: #f6e7ea;
  --b: #386fb3; --b-2: #2b5a96; --b-soft: #e8f0fa;
  --ink: #0f1b2d;
  --bg: #f2f5f9; --surface: #ffffff; --surface-2: #f7f9fc;
  --line: #e2e8f0; --line-2: #cfd9e5;
  --text: #142033; --muted: #5c6b7e; --faint: #8a97a8;
  --ok: #1f8a57; --ok-soft: #e3f4ea; --warn: #a76a00; --warn-soft: #fdf2d9; --danger: #c0392b; --danger-soft: #fbe9e6;
  --focus: #386fb3;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .05);
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 8px 24px rgba(15, 27, 45, .06);
  --shadow-lg: 0 24px 60px rgba(15, 27, 45, .18);
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #0b1320; --surface: #121d2e; --surface-2: #17243a; --line: #22324b; --line-2: #2d4060;
  --text: #e5ecf5; --muted: #98a8bd; --faint: #6f8099; --b-soft: #1a2c48; --m-soft: #3a1a22;
  --ok-soft: #12301f; --warn-soft: #362a10; --danger-soft: #3a1c19; --ok: #5fcf95; --warn: #efc25a; --danger: #ef7d6d; --b: #6c9de0; --m: #d76a7a;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 24px 60px rgba(0,0,0,.5); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1320; --surface: #121d2e; --surface-2: #17243a; --line: #22324b; --line-2: #2d4060;
    --text: #e5ecf5; --muted: #98a8bd; --faint: #6f8099; --b-soft: #1a2c48; --m-soft: #3a1a22;
    --ok-soft: #12301f; --warn-soft: #362a10; --danger-soft: #3a1c19; --ok: #5fcf95; --warn: #efc25a; --danger: #ef7d6d; --b: #6c9de0; --m: #d76a7a;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 24px 60px rgba(0,0,0,.5); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--b); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ic { width: 20px; height: 20px; flex: none; }

/* ========== الهيكل ========== */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; transition: grid-template-columns .2s ease; }
.app.collapsed { grid-template-columns: 84px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 12px; padding-inline-end: 0;
}
.side-panel {
  height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; min-height: 72px; }
.side-head img.full { height: 44px; width: auto; max-width: 100%; }
.side-head img.mark { height: 40px; width: auto; display: none; }
.app.collapsed .side-head img.full { display: none; }
.app.collapsed .side-head img.mark { display: block; margin: 0 auto; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11.5px; color: var(--faint); padding: 14px 10px 4px; font-weight: 600; }
.app.collapsed .nav-group { visibility: hidden; height: 10px; padding: 0; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14.5px; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--b-soft); color: var(--b-2); font-weight: 600; }
:root[data-theme='dark'] .nav a.active { color: #a9c6ee; }
.nav a.active::before { content: ''; position: absolute; inset-inline-start: -10px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--m); }
[dir='rtl'] .nav a.active::before { border-radius: 4px 0 0 4px; }
.nav a .ic { width: 20px; height: 20px; }
.nav .count { margin-inline-start: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--m); color: #fff; font-size: 11.5px; display: grid; place-items: center; font-weight: 700; }
.app.collapsed .nav a { justify-content: center; padding: 10px; }
.app.collapsed .nav a span.lbl, .app.collapsed .nav .count { display: none; }
.app.collapsed .nav a .dot-count { display: block; }
.dot-count { display: none; position: absolute; top: 6px; inset-inline-end: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--m); }
.side-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; gap: 6px; }
.side-foot button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--muted); font-size: 13px; }
.side-foot button:hover { color: var(--text); border-color: var(--line-2); }
.app.collapsed .side-foot { flex-direction: column; }
.app.collapsed .side-foot .lbl { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); }
.search-trigger {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--faint); cursor: pointer; text-align: start; box-shadow: var(--shadow-sm);
}
.search-trigger kbd { margin-inline-start: auto; font-family: inherit; font-size: 11.5px; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--muted); direction: ltr; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.icon-btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); }
.icon-btn .badge-dot { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--m); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 4px; padding-inline-end: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text); }
.me-chip small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.me-chip b { font-size: 13.5px; line-height: 1.2; display: block; }
.mobile-logo { display: none; }
.content { padding: 8px 24px 48px; max-width: 1440px; width: 100%; }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); margin-bottom: 16px; font-size: 14px; }
.banner .btn { margin-inline-start: auto; }

/* ========== الرأس ========== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 0 20px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--text); }
[dir='rtl'] .back .ic { transform: scaleX(-1); }

/* ========== الأزرار والحقول ========== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--b); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--b); border-color: var(--b); color: #fff; }
.btn-primary:hover { background: var(--b-2); border-color: var(--b-2); }
.btn-accent { background: var(--m); border-color: var(--m); color: #fff; }
.btn-accent:hover { background: var(--m-2); border-color: var(--m-2); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-xs { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .req { color: var(--danger); }
.input, select.input, textarea.input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 11px; background: var(--surface); color: var(--text); }
textarea.input { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input:focus { outline: none; border-color: var(--b); box-shadow: 0 0 0 4px color-mix(in srgb, var(--b) 18%, transparent); }
.hint { font-size: 12px; color: var(--faint); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-weight: 700; font-size: 14px; color: var(--b-2); padding-top: 8px; border-top: 1px solid var(--line); margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-opt { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: 13.5px; }
.tag-opt[aria-pressed='true'] { background: var(--b); color: #fff; border-color: var(--b); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--b); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 13.5px; display: inline-flex; gap: 6px; align-items: center; }
.seg button[aria-pressed='true'] { background: var(--b-soft); color: var(--b-2); font-weight: 600; }

/* ========== البطاقات والجداول ========== */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.panel-head h2 .ic { color: var(--b); }
.panel-body { padding: 18px 20px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.search { position: relative; }
.search .ic { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); }
.search .input { padding-inline-start: 38px; width: 260px; height: 38px; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table td.money, .table th.money { text-align: end; }
.table tr:last-child td { border-bottom: 0; }
.cell-strong { font-weight: 600; }
.cell-person { display: flex; align-items: center; gap: 10px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--b-soft); color: var(--b-2); }
:root[data-theme='dark'] .badge { color: #a9c6ee; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.plain { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.maroon { background: var(--m-soft); color: var(--m); }
.badge .ic { width: 14px; height: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatars { display: flex; }
.avatars .avatar { border: 2px solid var(--surface); margin-inline-start: -8px; width: 30px; height: 30px; font-size: 11.5px; }
.avatars .avatar:first-child { margin-inline-start: 0; }
.progress { display: flex; align-items: center; gap: 10px; min-width: 120px; }
.progress .bar { flex: 1; height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--b), #5b8fd1); border-radius: 6px; }
.progress .bar i.done { background: var(--ok); }
.progress span { font-size: 12.5px; width: 42px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .ill { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px; background: var(--b-soft); color: var(--b); display: grid; place-items: center; }
.empty .ill .ic { width: 30px; height: 30px; }
.empty h3 { margin: 0 0 4px; color: var(--text); font-size: 16px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-page { display: grid; gap: 14px; }
.sk-page .skeleton:nth-child(1) { height: 34px; width: 40%; }
.sk-page .skeleton:nth-child(2) { height: 120px; }
.sk-page .skeleton:nth-child(3) { height: 320px; }

/* ========== البنتو واللوحات ========== */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .kpi-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--b-soft); color: var(--b); margin-bottom: 12px; }
.kpi.m .kpi-ic { background: var(--m-soft); color: var(--m); }
.kpi.ok .kpi-ic { background: var(--ok-soft); color: var(--ok); }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 28px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.kpi .value small { font-size: 13px; color: var(--muted); font-weight: 500; margin-inline-start: 4px; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.hero-kpi { background: linear-gradient(135deg, var(--ink), #1d3557); color: #fff; border: 0; }
.hero-kpi .label, .hero-kpi .sub { color: #b9c7da; }
.hero-kpi .kpi-ic { background: rgba(255,255,255,.1); color: #9cc0ee; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: center; font-size: 13.5px; }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 6px; background: var(--b); }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); cursor: pointer; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list li:hover { background: var(--surface-2); }
.alert-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--warn-soft); color: var(--warn); }
.alert-ic.expired { background: var(--danger-soft); color: var(--danger); }
.alert-ic.urgent { background: var(--m-soft); color: var(--m); }
.alert-ic .ic { width: 18px; height: 18px; }
.a-main { flex: 1; min-width: 0; }
.a-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-kind { font-size: 12.5px; color: var(--muted); }
.a-when { font-size: 12.5px; text-align: end; white-space: nowrap; }
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring-wrap .ring-text b { display: block; font-size: 15px; }
.ring-wrap .ring-text span { font-size: 13px; color: var(--muted); }

/* ========== المشروع ========== */
.proj-hero { padding: 22px; display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; background: linear-gradient(135deg, var(--surface), var(--b-soft)); }
.proj-hero h1 { margin: 0 0 6px; font-size: 24px; line-height: 1.3; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.chip .ic { width: 15px; height: 15px; color: var(--b); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.tabs button .ic { width: 17px; height: 17px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--m); font-weight: 700; }
.tabs button .n { font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }
.timeline-bar { position: relative; height: 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); overflow: visible; }
.timeline-bar .done { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 8px; background: linear-gradient(90deg, var(--b), #6c9de0); }
.timeline-bar .today { position: absolute; top: -6px; bottom: -6px; width: 3px; border-radius: 2px; background: var(--m); }
.timeline-labels { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.money-flow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.money-flow > div { padding: 16px 18px; border-inline-start: 1px solid var(--line); }
.money-flow > div:first-child { border-inline-start: 0; }
.money-flow .label { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.money-flow .label i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.money-flow .value { font-size: 20px; font-weight: 700; }
.flow-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); margin: 0 18px 16px; }
.flow-bar i { display: block; height: 100%; }
.unit-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 4px; }
.unit-cell { aspect-ratio: 1; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); }
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.legend-row i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -2px; }
.photo-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-strip a, .photo-grid a, .photo-grid .ph { display: block; aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; background: var(--surface-2); position: relative; }
.photo-strip img, .photo-grid img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-grid .x { position: absolute; top: 6px; inset-inline-end: 6px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 8px; width: 28px; height: 28px; display: grid; place-items: center; cursor: pointer; }
.photo-grid .cap { position: absolute; bottom: 0; inset-inline: 0; padding: 6px 8px; background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #fff; font-size: 12px; }
.member-list { display: grid; gap: 10px; }
.member { display: flex; align-items: center; gap: 12px; }
.member b { display: block; font-size: 14px; }
.member span { font-size: 12.5px; color: var(--muted); }
.stat-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-pair > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat-pair .label { font-size: 12.5px; color: var(--muted); }
.stat-pair .value { font-size: 19px; font-weight: 700; }

/* شبكة الوحدات والمراحل */
.grid-scroll { overflow: auto; max-height: 68vh; }
table.ugrid { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.ugrid th, .ugrid td { border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); padding: 0; text-align: center; background: var(--surface); }
.ugrid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); padding: 8px 10px; font-weight: 600; font-size: 12.5px; min-width: 110px; }
.ugrid tbody th { position: sticky; inset-inline-start: 0; z-index: 1; padding: 6px 12px; text-align: start; font-weight: 600; white-space: nowrap; background: var(--surface); min-width: 120px; }
.ugrid thead th:first-child { inset-inline-start: 0; z-index: 3; }
.ugrid td button { width: 100%; height: 34px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.ugrid td.done button { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.ugrid td.claimed button { background: color-mix(in srgb, var(--b) 16%, transparent); color: var(--b-2); cursor: default; }
.ugrid td.sel button { outline: 2px solid var(--m); outline-offset: -2px; }
.ugrid .colhead { display: grid; gap: 2px; }
.ugrid .colhead small { color: var(--muted); font-weight: 500; }

/* ========== النوافذ ========== */
.overlay { position: fixed; inset: 0; background: rgba(9, 17, 29, .5); z-index: 60; display: flex; justify-content: flex-start; animation: fade .15s ease; backdrop-filter: blur(2px); }
.drawer { width: min(680px, 100%); height: 100%; background: var(--surface); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide .2s ease; }
.drawer.wide { width: min(1000px, 100%); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 12px; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-foot { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.drawer-foot .spacer { flex: 1; }
.modal-wrap { position: fixed; inset: 0; background: rgba(9, 17, 29, .5); z-index: 70; display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: min(460px, 100%); padding: 24px; box-shadow: var(--shadow-lg); }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 18px; color: var(--muted); }
.modal .actions { display: flex; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(-24px); opacity: .6; } }
[dir='ltr'] .drawer { animation-name: slide-ltr; }
@keyframes slide-ltr { from { transform: translateX(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .overlay, .drawer, .modal-wrap, .skeleton { animation: none; } }
.palette { position: fixed; inset: 0; z-index: 80; background: rgba(9, 17, 29, .45); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; animation: fade .12s; }
.palette-box { width: min(620px, 100%); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--line); }
.palette-box .pin { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.palette-box input { flex: 1; border: 0; outline: none; background: none; font-size: 16px; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.palette-item.on, .palette-item:hover { background: var(--b-soft); }
.palette-item .ib { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--b); flex: none; }
.palette-item small { display: block; color: var(--muted); font-size: 12px; }
.toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-lg); max-width: 380px; display: flex; gap: 10px; align-items: center; }
.toast.error { background: var(--danger); }
.dropzone { display: block; border: 1.5px dashed var(--line-2); border-radius: var(--r); padding: 20px; text-align: center; background: var(--surface-2); cursor: pointer; margin-bottom: 16px; }
.dropzone:hover, .dropzone.drag { border-color: var(--b); background: var(--b-soft); }
.dropzone strong { display: block; font-size: 15px; margin-top: 6px; }
.dropzone .hint { display: block; }
.dropzone .ic { width: 30px; height: 30px; color: var(--b); }
.result-box { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; }
.result-box.ok { background: var(--ok-soft); color: var(--ok); }
.result-box.warn { background: var(--warn-soft); color: var(--warn); }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13px; text-decoration: none; }
.file-chip .ic { width: 16px; height: 16px; }
.file-thumb { width: 64px; height: 48px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }
.perm-grid { display: grid; gap: 12px; }
.perm-group { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.perm-group h4 { margin: 0; padding: 10px 14px; background: var(--surface-2); font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.perm-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; padding: 10px 14px; }
.perm-items label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 4px 0; cursor: pointer; }
.perm-items input { width: 17px; height: 17px; accent-color: var(--b); }
.perm-items .from-role { color: var(--faint); }
.perm-items .ov-grant { color: var(--ok); font-weight: 600; }
.perm-items .ov-deny { color: var(--danger); text-decoration: line-through; }
.storage-meter { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; display: flex; border: 1px solid var(--line); }
.storage-meter i { height: 100%; display: block; }
.sig-pad { width: 100%; height: 200px; border: 1.5px dashed var(--line-2); border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; display: block; }
.charter-text { max-height: 46vh; overflow-y: auto; padding: 18px 20px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line); line-height: 1.9; }
.charter-text h3 { font-size: 16px; margin: 18px 0 6px; color: var(--b-2); }
.charter-text h3:first-child { margin-top: 0; }
.charter-text ol { margin: 0; padding-inline-start: 22px; }
.charter-text p { margin: 0 0 8px; }

/* ========== الدخول ========== */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth-art { position: relative; overflow: hidden; background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art::before { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 48px 48px; mask-image: radial-gradient(ellipse at 30% 60%, #000 10%, transparent 70%); }
.auth-art > * { position: relative; }
.auth-logo { background: #fff; border-radius: 16px; padding: 12px 18px; display: inline-block; }
.auth-logo img { height: 52px; width: auto; display: block; }
.auth-art h2 { font-size: 34px; line-height: 1.3; margin: 0 0 12px; font-weight: 700; }
.auth-art .lead { color: #b9c7da; font-size: 16px; max-width: 460px; margin: 0; }
.auth-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; max-width: 520px; }
.auth-feats div { display: flex; gap: 10px; align-items: center; color: #d5e0ee; font-size: 14px; }
.auth-feats .ic { color: #9cc0ee; }
.auth-feats div:nth-child(even) .ic { color: #e98a97; }
.auth-art .foot { color: #7f92ab; font-size: 13px; }
.auth-form-side { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(400px, 100%); }
.auth-card h1 { font-size: 26px; margin: 0 0 6px; }
.auth-card > p { color: var(--muted); margin: 0 0 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn { height: 46px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.form-ok { background: var(--ok-soft); color: var(--ok); padding: 14px; border-radius: 12px; font-size: 14.5px; }
.loading { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--b); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== شريط الجوال ========== */
.tabbar { display: none; }

@media (max-width: 1180px) {
  .span-3 { grid-column: span 6; } .span-4 { grid-column: span 6; } .span-5, .span-7, .span-8 { grid-column: span 12; } .span-6 { grid-column: span 12; }
  .money-flow { grid-template-columns: repeat(2, 1fr); }
  .money-flow > div:nth-child(3) { border-inline-start: 0; }
  .money-flow > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 290px; z-index: 50; padding: 0; transform: translateX(110%); transition: transform .22s ease; }
  [dir='ltr'] .sidebar { transform: translateX(-110%); }
  .app.nav-open .sidebar { transform: none; }
  .side-panel { border-radius: 0; }
  .app.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45; }
  .app.collapsed .side-head img.full { display: block; } .app.collapsed .side-head img.mark { display: none; }
  .app.collapsed .nav a span.lbl, .app.collapsed .nav .count { display: initial; }
  .topbar { padding: 10px 14px; }
  .mobile-logo { display: block; height: 34px; width: auto; }
  .search-trigger { display: none; }
  .me-chip .who { display: none; }
  .content { padding: 4px 14px 96px; }
  .page-head h1 { font-size: 22px; }
  .search .input { width: 100%; }
  .search { flex: 1; min-width: 160px; }
  .form-grid { grid-template-columns: 1fr; }
  .proj-hero { grid-template-columns: 1fr; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(15,27,45,.06); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; background: none; border: 0; padding: 4px; position: relative; cursor: pointer; }
  .tabbar .active { color: var(--b); font-weight: 600; }
  .tabbar .fab-tab span.ib { width: 44px; height: 44px; border-radius: 14px; background: var(--m); color: #fff; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 8px 18px rgba(135,40,53,.35); }
  .tabbar .count { position: absolute; top: 0; inset-inline-end: 22%; min-width: 16px; height: 16px; border-radius: 8px; background: var(--m); color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 4px; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-art { padding: 24px 20px; }
  .auth-art h2 { font-size: 22px; }
  .auth-feats, .auth-art .foot { display: none; }
  .hide-sm { display: none; }
  .toasts { bottom: 86px; }
  .photo-strip { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 540px) {
  .span-3, .span-4 { grid-column: span 12; }
  .bento { gap: 12px; }
  .kpi .value { font-size: 23px; }
  .stat-pair { grid-template-columns: 1fr; }
}

/* ========== الطباعة ========== */
.print-page { background: #fff; color: #111; max-width: 900px; margin: 0 auto; padding: 32px; font-size: 13.5px; }
.print-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 3px solid var(--m); padding-bottom: 14px; margin-bottom: 18px; }
.print-head img { height: 58px; width: auto; }
.print-head .co { text-align: end; font-size: 12.5px; color: #444; }
.print-title { text-align: center; font-size: 20px; font-weight: 700; margin: 6px 0 16px; color: var(--b-2); }
.print-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 24px; margin-bottom: 16px; }
.print-meta div { display: flex; gap: 8px; border-bottom: 1px dotted #ccc; padding: 4px 0; }
.print-meta b { min-width: 120px; color: #555; font-weight: 600; }
.print-page table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.print-page th, .print-page td { border: 1px solid #cfd6df; padding: 7px 9px; text-align: start; }
.print-page th { background: #eef3f9; font-weight: 700; }
.print-page .tot td { font-weight: 700; background: #f7f9fc; }
.print-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 40px; text-align: center; }
.print-sign div { border-top: 1px solid #999; padding-top: 6px; color: #555; }
.print-actions { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.print-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.print-photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; border: 1px solid #ddd; }
@media print {
  .sidebar, .topbar, .tabbar, .head-actions, .drawer-foot, .toasts, .print-actions, .banner, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .panel { box-shadow: none; border-color: #ddd; break-inside: avoid; }
  body { background: #fff; color: #000; }
  .print-page { padding: 0; }
  @page { margin: 14mm; }
}
.settings-logo { height: 64px; width: auto; display: block; }
.cms .btn-ghost { font-weight: 500; }
@media (max-width: 900px) { .cms { grid-template-columns: 1fr !important; } .cms > .panel:first-child { position: static !important; display: flex; flex-wrap: wrap; } .cms > .panel:first-child .btn { width: auto !important; } }
.show-mobile, .show-mobile-inline { display: none !important; }
@media (max-width: 900px) {
  .show-mobile { display: grid !important; }
  .show-mobile-inline { display: inline-flex !important; }
  .hide-mobile { display: none !important; }
}
