@font-face { font-family: 'Cairo'; src: url('../assets/fonts/Cairo-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('../assets/fonts/Cairo-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('../assets/fonts/Cairo-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('../assets/fonts/Cairo-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('../assets/fonts/Cairo-ExtraBold.ttf') format('truetype'); font-weight: 800; font-display: swap; }

:root {
  /* أسماء المكونات تقرأ من ألوان المنصة الموحدة (tokens.css)، فيتبدل الوضع وهوية الشركة تلقائياً */
  --navy: var(--one-brand);
  --navy-2: var(--one-brand-2);
  --navy-3: var(--one-brand-3);
  --blue: var(--one-accent);
  --blue-deep: var(--one-primary);
  --blue-soft: var(--one-primary-soft);
  --bg: var(--one-bg);
  --surface: var(--one-surface);
  --surface-soft: var(--one-surface-2);
  --border: var(--one-border);
  --border-strong: var(--one-border-strong);
  --ink: var(--one-text);
  --ink-2: var(--one-text-2);
  --ink-3: var(--one-text-3);
  --heading: var(--one-heading);
  --ok-bg: var(--one-ok-soft); --ok-fg: var(--one-ok);
  --warn-bg: var(--one-warn-soft); --warn-fg: var(--one-warn);
  --bad-bg: var(--one-bad-soft); --bad-fg: var(--one-bad);
  --info-bg: var(--one-info-soft); --info-fg: var(--one-info);
  --muted-bg: var(--one-muted-soft); --muted-fg: var(--one-muted);
  --r-sm: var(--one-radius-sm);
  --r-md: var(--one-radius-md);
  --r-lg: var(--one-radius-lg);
  --shadow-sm: var(--one-shadow-sm);
  --shadow-lg: var(--one-shadow-lg);
  --side-w: 288px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14.5px/1.7 'Cairo', system-ui, 'Segoe UI', Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue-deep); text-decoration: none; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
svg.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- الأزرار والحقول ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-soft); border-color: var(--border-strong); }
.btn.primary { background: var(--one-primary); border-color: var(--one-primary); color: var(--one-on-primary); }
.btn.primary:hover { background: var(--one-primary-hover); border-color: var(--one-primary-hover); }
.btn.danger { color: var(--bad-fg); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--muted-bg); color: var(--ink); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, select.input {
  width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px var(--one-focus); }
.input[readonly] { background: var(--surface-soft); color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-error { padding: 10px 12px; border-radius: var(--r-sm); background: var(--bad-bg); color: var(--bad-fg); font-weight: 600; font-size: 13.5px; }

/* ---------- شاشة الدخول ---------- */
.auth {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 85% -10%, color-mix(in srgb, var(--one-accent) 22%, transparent), transparent 60%), var(--one-hero);
}
.auth-card { width: min(420px, 100%); padding: 32px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-lg); display: grid; gap: 18px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand img { width: 54px; height: 54px; flex: none; padding: 6px; border-radius: 14px; background: #fff; border: 1px solid var(--border); object-fit: contain; }
.auth-brand h1 { font-size: 20px; font-weight: 800; line-height: 1.3; color: var(--heading); }
.auth-brand p { font-size: 13px; color: var(--ink-2); }

/* ---------- الهيكل ---------- */
.shell { min-height: 100%; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px;
  background: var(--one-sidebar); color: var(--one-on-brand-2); display: flex; flex-direction: column; gap: 6px;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; color: #fff; }
.side-brand img { width: 44px; height: 44px; flex: none; padding: 5px; border-radius: 12px; background: #fff; object-fit: contain; box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .6); }
.side-brand b { display: block; font-size: 15px; font-weight: 800; line-height: 1.3; }
.side-brand small { font-size: 11.5px; color: var(--one-on-brand-3); }
/* مجموعات القائمة منسدلة */
.nav-fold { margin-top: 4px; }
.nav-fold > summary { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; cursor: pointer; list-style: none; font-size: 12.5px; font-weight: 700; color: var(--one-on-brand-3); }
.nav-fold > summary::-webkit-details-marker { display: none; }
.nav-fold > summary:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-fold > summary > span:first-child:not(.nav-tile) { flex: 1; }
.nav-fold > summary > svg { width: 16px; height: 16px; transition: transform .15s; }
.nav-fold[open] > summary > svg { transform: rotate(180deg); }
.nav-fold[open] > summary { color: #fff; }
.nav-fold > .nav-link { margin-inline-start: 8px; padding: 8px 12px; font-size: 13.5px; }
.nav-group { margin: 14px 10px 4px; font-size: 11.5px; font-weight: 700; color: var(--one-on-brand-3); letter-spacing: .02em; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: inherit; font-weight: 600; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link span:first-of-type { flex: 1; min-width: 0; }
.nav-count { padding: 0 7px; border-radius: 999px; background: var(--one-fill); color: var(--one-on-fill); font-size: 11.5px; font-weight: 700; line-height: 1.7; }
.nav-link.on { background: color-mix(in srgb, var(--one-accent) 20%, transparent); color: #fff; box-shadow: inset -3px 0 0 var(--blue); }
.search-btn { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 8px; padding: 9px 12px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; background: rgba(255, 255, 255, .05); color: var(--one-on-brand-3); text-align: start; }
.search-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.search-btn svg { width: 18px; height: 18px; }
.results { display: grid; gap: 4px; }
.results h3 { margin: 10px 0 2px; font-size: 12.5px; font-weight: 800; color: var(--ink-3); }
.result { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; text-align: start; }
.result:hover, .result:focus-visible { background: var(--surface-soft); }
.result b { display: block; line-height: 1.5; }
.result small { color: var(--ink-2); }
.result .grow { flex: 1; min-width: 0; }
.ai-btn { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 8px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--one-accent) 45%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--one-accent) 14%, transparent); color: #fff; font-weight: 700; text-align: start; }
.ai-btn:hover { background: color-mix(in srgb, var(--one-accent) 26%, transparent); }
.ai-btn svg { color: var(--blue); }
.side-user { margin-top: auto; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, .06); display: grid; gap: 8px; }
.side-user b { color: #fff; font-size: 14px; line-height: 1.4; }
.side-user small { color: var(--one-on-brand-3); font-size: 12px; }
.side-user .row { display: flex; gap: 6px; }
.side-user .btn { flex: 1; min-height: 32px; padding: 0 8px; font-size: 12.5px; background: transparent; border-color: rgba(255, 255, 255, .18); color: var(--one-on-brand-2); }
.side-user .btn:hover { background: rgba(255, 255, 255, .1); }

.main { min-width: 0; padding: 24px 28px 48px; }
/* بوابة الموظفين تملأ مساحة العمل كلها وتمرّر محتواها داخلياً */
.shell.portal-active .main { padding: 0; }
.portal-host iframe { display: block; width: 100%; height: 100vh; height: 100dvh; border: 0; background: var(--bg); }
/* التنقل بين البوابتين لا يغيّر تخطيط الصفحة: البوابة غير المعروضة تبقى في مكانها مخفية فقط بدل إزالتها من التخطيط.
   إزالتها (display: none) كانت تعيد بناء الصفحة كلها مع كل تنقل، فيبقى الشريط الجانبي أحياناً أبيض فارغاً في سفاري وغيره،
   وتُعيد البوابة حساب عرضها من الصفر. */
.portal-host { position: relative; overflow: hidden; }
.portal-host iframe[hidden] { display: block !important; visibility: hidden; position: absolute; top: 0; inset-inline: 0; pointer-events: none; }
.topbar { display: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 800; line-height: 1.3; color: var(--heading); }
.page-head p { color: var(--ink-2); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-head h2 { font-size: 16px; font-weight: 700; color: var(--heading); }
.card-head small { color: var(--ink-3); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: 1.4fr 1fr 1fr; }
.empty { padding: 36px 20px; text-align: center; color: var(--ink-2); }

/* ---------- مؤشرات اللوحة ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; display: grid; gap: 2px; }
.kpi .label { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.kpi .label svg { width: 18px; height: 18px; color: var(--blue-deep); }
.kpi .value { font-size: 28px; font-weight: 800; line-height: 1.35; }
.kpi .value small { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.kpi .hint { font-size: 12.5px; color: var(--ink-3); }
a.kpi { color: inherit; transition: border-color .15s, transform .15s; }
a.kpi:hover { border-color: var(--blue); transform: translateY(-1px); }

/* أعمدة: لون واحد للمقدار، قيمة فوق كل عمود، وتفاصيل عند المرور */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 220px; padding: 26px 20px 0; }
.bar-col { position: relative; flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; min-width: 0; }
/* ارتفاع العمود من المساحة الباقية بعد سطر القيمة، حتى تبقى النسب صحيحة */
.bar-col .bar { flex: none; height: calc((100% - 30px) * var(--h)); width: min(46px, 70%); min-height: 2px; border-radius: 4px 4px 0 0; background: var(--blue-deep); transition: background .15s; }
.bar-col:hover .bar, .bar-col:focus-visible .bar { background: var(--navy-3); }
.bar-col .v { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.bars-x { display: flex; gap: 10px; padding: 8px 20px 18px; border-top: 1px solid var(--border); margin-top: -1px; }
.bars-x span { flex: 1; text-align: center; font-size: 12.5px; color: var(--ink-2); }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 5;
  padding: 6px 10px; border-radius: 8px; background: var(--one-brand); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow-sm);
}

.hbars { display: grid; gap: 12px; padding: 16px 20px 20px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; font-size: 13.5px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .n { font-weight: 700; }
.hbar .track { grid-column: 1 / -1; height: 6px; border-radius: 4px; background: var(--muted-bg); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; background: var(--blue-deep); }

/* ---------- الشارات ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; background: var(--muted-bg); color: var(--muted-fg); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.new { background: var(--info-bg); color: var(--info-fg); }
.badge.pending { background: var(--warn-bg); color: var(--warn-fg); }
.badge.done, .badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.cancel, .badge.bad { background: var(--bad-bg); color: var(--bad-fg); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- شريط التصفية والجداول ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .search { position: relative; flex: 1 1 240px; }
.toolbar .search svg { position: absolute; top: 10px; right: 12px; color: var(--ink-3); }
.toolbar .search .input { padding-right: 40px; }
.toolbar select.input { width: auto; max-width: 180px; }
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-sm); background: var(--muted-bg); }
.seg button { border: 0; background: transparent; padding: 5px 14px; border-radius: 8px; font-weight: 600; color: var(--ink-2); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; padding: 8px 10px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--blue-soft); color: var(--info-fg); font-weight: 600; font-size: 13px; }
.filter-chip button { border: 0; background: transparent; padding: 0; display: grid; color: inherit; }
.filter-chip svg { width: 16px; height: 16px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { padding: 10px 16px; text-align: start; font-size: 12.5px; font-weight: 700; color: var(--ink-2); background: var(--surface-soft); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.click { cursor: pointer; }
table.data tbody tr.click:hover { background: var(--surface-soft); }
table.data td.end, table.data th.end { text-align: end; }
table.data .sub { display: block; font-size: 12.5px; color: var(--ink-3); }
table.data .code { font-weight: 700; color: var(--heading); }
table.data td.nowrap { white-space: nowrap; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--ink-2); font-size: 13.5px; }
.pager .row { display: flex; align-items: center; gap: 8px; }

.meter { display: grid; gap: 4px; min-width: 110px; }
.meter .track { height: 6px; border-radius: 4px; background: var(--muted-bg); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 4px; background: var(--blue-deep); }
.meter .fill.over { background: var(--bad-fg); }
.meter small { font-size: 12px; color: var(--ink-2); }

/* ---------- النوافذ ---------- */
dialog.dlg { width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); color: var(--ink); background: var(--surface); overflow: hidden; }
dialog.dlg[open] { display: flex; flex-direction: column; }
dialog.dlg::backdrop { background: var(--one-overlay); backdrop-filter: blur(2px); }
dialog.dlg.narrow { width: min(460px, calc(100vw - 24px)); }
dialog.dlg.drawer { margin: 0 auto 0 0; width: min(640px, 100vw); height: 100vh; max-height: 100vh; border-radius: 0; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { font-size: 17px; font-weight: 800; color: var(--heading); }
/* max-content حتى لا تنضغط الأقسام ذات overflow:hidden عند امتلاء النافذة */
.dlg-body { padding: 20px; overflow-y: auto; display: grid; grid-auto-rows: max-content; gap: 16px; align-content: start; flex: 1; }
.dlg-foot { display: flex; justify-content: flex-start; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-soft); }

.section-title { font-size: 13px; font-weight: 800; color: var(--ink-2); margin-bottom: -6px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
/* الفواصل من حدود الخلايا نفسها، فلا تظهر خلية فارغة ملوّنة عند العدد الفردي */
.kv > div { padding: 9px 12px; min-width: 0; border-block-end: 1px solid var(--border); border-inline-end: 1px solid var(--border); margin-block-end: -1px; margin-inline-end: -1px; }
.kv > div.wide { grid-column: 1 / -1; }
.kv dt { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.kv dd.text { font-weight: 400; line-height: 1.9; }
.steps { display: grid; gap: 10px; }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--muted-bg); color: var(--muted-fg); flex: none; }
.step.done .dot { background: var(--ok-bg); color: var(--ok-fg); }
.step .dot svg { width: 16px; height: 16px; }
.step b { display: block; line-height: 1.5; }
.step small { color: var(--ink-2); }

.secret { display: flex; gap: 8px; align-items: center; padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--r-sm); background: var(--surface-soft); }
.secret code { flex: 1; font: 700 18px/1.4 ui-monospace, Menlo, monospace; direction: ltr; text-align: center; letter-spacing: .04em; }

.role-list { display: grid; gap: 4px; padding: 10px; }
.role-list .group { margin: 10px 8px 2px; font-size: 12px; font-weight: 700; color: var(--ink-3); }
.role-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 0; border-radius: 10px; background: transparent; text-align: start; font-weight: 600; }
.role-item:hover { background: var(--surface-soft); }
.role-item.on { background: var(--blue-soft); color: var(--info-fg); }
.perm-group { padding: 14px 20px; border-top: 1px solid var(--border); }
.perm-group h3 { font-size: 13.5px; font-weight: 800; margin-bottom: 8px; }
.perm-group ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; }
.perm-group li { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--ink-3); }
.perm-group li svg { width: 16px; height: 16px; margin-top: 4px; }
.perm-group li.on { color: var(--ink); }
.perm-group li.on svg { color: var(--ok-fg); }
.perm-group label { color: var(--ink); display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.perm-group label input { margin-top: 6px; }
.perm-group .hint { color: var(--ink-2); font-size: 13px; margin-bottom: 10px; }
.role-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-soft); border-radius: 0 0 var(--r-md) var(--r-md); position: sticky; bottom: 0; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.checks label { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.checks .group { grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: var(--ink-3); margin-top: 6px; }

.alerts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; padding: 14px 20px 18px; }
.alert { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-sm); background: var(--info-bg); color: var(--ink); font-weight: 600; }
.alert svg { color: var(--info-fg); }
.alert.warn { background: var(--warn-bg); }
.alert.warn svg { color: var(--warn-fg); }
.alert:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.chat { display: grid; gap: 10px; align-content: start; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.9; }
.bubble.user { justify-self: start; background: var(--one-primary); color: var(--one-on-primary); border-start-start-radius: 4px; }
.bubble.model { justify-self: end; background: var(--muted-bg); border-start-end-radius: 4px; }
.bubble.error { background: var(--bad-bg); color: var(--bad-fg); }
#toasts { position: fixed; bottom: 20px; left: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { padding: 10px 16px; border-radius: 12px; background: var(--one-brand-2); color: #fff; font-weight: 600; box-shadow: var(--shadow-lg); max-width: 360px; border: 1px solid rgba(255, 255, 255, .12); }
.toast.bad { background: var(--bad-fg); }

/* ---------- الحساب والأمان ---------- */
.side-me { display: flex; align-items: center; gap: 10px; color: inherit; border-radius: 10px; padding: 2px; }
.side-me:hover b { text-decoration: underline; }
.side-me > span:last-child { display: grid; min-width: 0; }
.side-me b, .side-me small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--one-accent) 28%, transparent); color: #fff; font-weight: 800; font-size: 13px; }
.side-user .row .btn:first-child { flex: 0 0 38px; padding: 0; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12.5px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.otp { font-size: 22px; letter-spacing: .35em; text-align: center; font-weight: 700; }
.qr-box { display: grid; place-items: center; padding: 12px; border-radius: var(--r-md); background: #fff; border: 1px solid var(--border); }
.qr-box svg { width: 200px; height: 200px; }
.steps-list { margin: 0; padding-inline-start: 20px; display: grid; gap: 4px; color: var(--ink-2); }
.sec-card { display: grid; gap: 14px; align-content: start; }
.sec-title { display: flex; align-items: flex-start; gap: 12px; }
.sec-title > svg { width: 38px; height: 38px; padding: 8px; border-radius: 12px; background: var(--blue-soft); color: var(--blue-deep); }
.sec-title > div { flex: 1; min-width: 0; }
.sec-title h2 { font-size: 16px; font-weight: 800; color: var(--heading); }
.sec-title p { font-size: 13px; color: var(--ink-2); }
table.data.compact td { padding: 8px 12px; }
.enroll { align-items: start; padding-top: 6vh; }
.enroll-card { width: min(980px, 100%); padding: 28px; border-radius: var(--r-lg); background: var(--bg); box-shadow: var(--shadow-lg); }
.enroll-foot { display: flex; justify-content: flex-start; margin-top: 18px; }
.kpi.warn { border-color: color-mix(in srgb, var(--warn-fg) 40%, var(--border)); }
.kpi.warn .value { color: var(--warn-fg); }
.kpi.good .value { color: var(--ok-fg); }
.kpi.bad { border-color: var(--bad-fg); }
.kpi.bad .value { color: var(--bad-fg); }

.badge.info { background: var(--info-bg); color: var(--info-fg); }
.badge svg { width: 14px; height: 14px; }
.hint { font-size: 13px; color: var(--ink-2); }
details.ov { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0 14px; }
details.ov > summary { padding: 12px 0; font-weight: 700; cursor: pointer; color: var(--heading); }
details.ov[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.ov-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; max-height: 360px; overflow-y: auto; padding-bottom: 12px; }
.ov-list .group { grid-column: 1 / -1; margin-top: 8px; font-size: 12px; font-weight: 800; color: var(--ink-3); }
.ov-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.ov-row select.input { width: 104px; min-height: 32px; flex: none; padding: 0 8px; }

/* صندوق اعتماداتي */
.inbox { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; padding: 14px 20px 18px; }
.inbox h3 { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 800; color: var(--heading); margin-bottom: 8px; }
.inbox h3 svg { width: 18px; height: 18px; color: var(--blue-deep); }
.inbox h3 .num { margin-inline-start: auto; padding: 0 8px; border-radius: 999px; background: var(--one-fill); color: var(--one-on-fill); font-size: 12px; }
.inbox-item { display: grid; width: 100%; padding: 9px 12px; margin-bottom: 6px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-soft); text-align: start; }
.inbox-item:hover { border-color: var(--blue); background: var(--blue-soft); }
.inbox-item b { font-weight: 700; line-height: 1.5; color: var(--ink); }
.inbox-item small { color: var(--ink-2); }
.inbox-more { font-size: 13px; font-weight: 700; }

/* ---------- أيقونات مجموعات القائمة ---------- */
.nav-fold > summary > .nav-tile, .nav-tile { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--tone); box-shadow: 0 4px 12px -4px var(--tone), inset 0 1px 0 rgba(255, 255, 255, .25); }
.nav-tile svg.ic { width: 16px; height: 16px; stroke-width: 2; }
.nav-fold > summary > .nav-title { flex: 1; min-width: 0; line-height: 1.45; }
.nav-fold > summary { font-size: 13px; padding: 7px 10px; }
.g-blue { --tone: linear-gradient(135deg, #2f9fe0, #1662b8); }
.g-teal { --tone: linear-gradient(135deg, #1fbfa6, #0b7f78); }
.g-violet { --tone: linear-gradient(135deg, #9b7bff, #5b3fd1); }
.g-amber { --tone: linear-gradient(135deg, #f6b73c, #d07a0c); }
.g-pink { --tone: linear-gradient(135deg, #f472b6, #c02672); }
.g-green { --tone: linear-gradient(135deg, #3ccf7f, #138a4a); }
.g-slate { --tone: linear-gradient(135deg, #8a9bb8, #4c5d7c); }
.g-orange { --tone: linear-gradient(135deg, #ff9a5a, #e0541f); }
.g-indigo { --tone: linear-gradient(135deg, #6f86ff, #2f45c9); }
.g-red { --tone: linear-gradient(135deg, #ff7b85, #c62f3b); }
.g-cyan { --tone: linear-gradient(135deg, #38c9e8, #0a7fa8); }
.nav-fold > .nav-link svg.ic { width: 18px; height: 18px; opacity: .85; }
.nav-link.on svg.ic { opacity: 1; color: var(--blue); }

/* ---------- رأس شاشات الوحدات ---------- */
.hero { position: relative; overflow: hidden; display: flex; flex-wrap: wrap; align-items: center; gap: 18px; padding: 22px 24px; margin-bottom: 18px; border-radius: var(--r-lg); color: #fff;
  background: radial-gradient(600px 220px at 10% 0%, color-mix(in srgb, var(--one-accent) 45%, transparent), transparent 70%), var(--one-hero); box-shadow: var(--shadow-sm); }
.hero::after { content: ''; position: absolute; inset: auto -60px -80px auto; width: 240px; height: 240px; border-radius: 50%; border: 36px solid rgba(255, 255, 255, .05); pointer-events: none; }
.hero-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); }
.hero-icon svg.ic { width: 28px; height: 28px; stroke-width: 1.6; }
.hero-text { flex: 1; min-width: 220px; }
.hero h1 { font-size: 23px; font-weight: 800; line-height: 1.35; color: #fff; }
.hero p { color: rgba(255, 255, 255, .78); font-size: 13.5px; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 8px; position: relative; z-index: 1; }
.hero .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22); color: #fff; }
.hero .btn:hover { background: rgba(255, 255, 255, .18); }
.hero .btn.primary { background: #fff; border-color: #fff; color: var(--one-brand); }
.hero .btn.primary:hover { background: #eef4fb; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; position: relative; z-index: 1; }
.hero-stat { flex: 1 1 140px; padding: 10px 14px; border-radius: 14px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); }
.hero-stat b { display: block; font-size: 22px; font-weight: 800; line-height: 1.3; }
.hero-stat small { color: rgba(255, 255, 255, .72); font-size: 12px; }
.hero-stat.warn b { color: #ffd27a; }
.hero-stat.bad b { color: #ffadb3; }
.hero-stat.ok b { color: #8ff0c4; }

/* ---------- شبكة البطاقات ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.tile-card { position: relative; min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-sm); transition: border-color .15s, transform .15s, box-shadow .15s; text-align: start; width: 100%; color: inherit; }
button.tile-card { cursor: pointer; }
.tile-card:hover { border-color: color-mix(in srgb, var(--blue) 55%, var(--border)); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tile-head { display: flex; align-items: flex-start; gap: 12px; }
.tile-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 13px; color: #fff; background: var(--tone, linear-gradient(135deg, #2f9fe0, #1662b8)); box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .5); }
.tile-ico svg.ic { width: 22px; height: 22px; stroke-width: 1.8; }
.tile-head > div { flex: 1; min-width: 0; }
.tile-head h3 { font-size: 15.5px; font-weight: 800; line-height: 1.45; color: var(--heading); overflow-wrap: anywhere; }
.tile-head h3.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* الحالة والرقم في سطر مستقل: الأرقام الطويلة (الآيبان) تُقص داخل البطاقة ولا تدفعها */
.tile-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.tile-num { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1px 10px; border-radius: 999px; background: var(--muted-bg); color: var(--ink-2); font-size: 12px; font-weight: 700; }
.tile-head small { color: var(--ink-3); font-size: 12.5px; }
.tile-head > div small { display: block; overflow-wrap: anywhere; }
.tile-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; font-size: 12.5px; }
.tile-meta dt { color: var(--ink-3); }
.tile-meta { margin: 0; }
.tile-meta > div { min-width: 0; }
.tile-meta dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.tile-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--border); }
.tile-foot .btn { flex: 0 1 auto; }
.tile-foot .grow { flex: 1; }
.life { display: grid; gap: 5px; }
.life .track { height: 7px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; }
.life .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--one-ok), color-mix(in srgb, var(--one-ok) 70%, #fff)); }
.life.soon .fill { background: linear-gradient(90deg, var(--one-warn), #f6c25b); }
.life.expired .fill { background: var(--one-bad); }
.life small { display: flex; justify-content: space-between; color: var(--ink-2); font-size: 12px; }
.ribbon { position: absolute; top: 14px; inset-inline-end: 14px; }
.badge.soon { background: var(--warn-bg); color: var(--warn-fg); }
.badge.expired { background: var(--bad-bg); color: var(--bad-fg); }
.badge.valid { background: var(--ok-bg); color: var(--ok-fg); }
.badge.none { background: var(--muted-bg); color: var(--muted-fg); }
.cat-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 6px; scrollbar-width: thin; }
.cat-pill { display: inline-flex; align-items: center; gap: 7px; flex: none; padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-weight: 700; font-size: 13px; color: var(--ink-2); }
.cat-pill .num { padding: 0 7px; border-radius: 99px; background: var(--muted-bg); font-size: 11.5px; }
.cat-pill.on { background: var(--one-primary); border-color: var(--one-primary); color: var(--one-on-primary); }
.cat-pill.on .num { background: rgba(255, 255, 255, .22); color: inherit; }
.cat-pill svg.ic { width: 16px; height: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters .search { position: relative; flex: 1 1 260px; }
.filters .search svg { position: absolute; top: 10px; right: 12px; color: var(--ink-3); }
.filters .search .input { padding-right: 40px; }
.filters select.input { width: auto; }

/* ---------- رفع الملفات ---------- */
.drop { display: grid; place-items: center; gap: 6px; padding: 22px; border: 2px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface-soft); text-align: center; color: var(--ink-2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--blue); background: var(--blue-soft); }
.drop svg.ic { width: 30px; height: 30px; color: var(--blue-deep); }
.drop b { color: var(--ink); }
.drop .file-name { font-weight: 700; color: var(--one-primary); }
.progress { height: 6px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--one-primary); transition: width .2s; }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--r-sm); background: #fff; }
.preview-img { max-width: 100%; max-height: 70vh; display: block; margin: auto; border-radius: var(--r-sm); }
dialog.dlg.wide { width: min(1040px, calc(100vw - 24px)); }
.versions { display: grid; gap: 6px; }
.version { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-soft); font-size: 13px; }
.version.current { border-color: color-mix(in srgb, var(--one-ok) 50%, var(--border)); background: var(--ok-bg); }
.version .grow { flex: 1; min-width: 0; }
.version b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- من يطلع ---------- */
.access { display: grid; gap: 8px; }
.access-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-soft); font-size: 13.5px; }
.access-row .grow { flex: 1; min-width: 0; font-weight: 600; }
.access-row select.input { width: 150px; min-height: 32px; }
.access-row .who { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: var(--blue-soft); color: var(--blue-deep); flex: none; }
.access-row .who svg.ic { width: 15px; height: 15px; }
.access-add { display: flex; gap: 8px; }
.access-add select.input { flex: 1; }

/* ---------- سجل البوابات ---------- */
.cred { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: var(--r-sm); background: var(--surface-soft); border: 1px solid var(--border); font-size: 13px; }
.cred > span:first-child { color: var(--ink-3); min-width: 74px; font-size: 12px; }
.cred code { flex: 1; min-width: 0; font: 600 13.5px/1.6 ui-monospace, Menlo, monospace; direction: ltr; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cred .icon-btn { width: 30px; height: 30px; }
.cred .icon-btn svg.ic { width: 17px; height: 17px; }
.pw-strength { height: 5px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; }
.pw-strength > div { height: 100%; transition: width .2s, background .2s; }
.extra-row { display: grid; grid-template-columns: 1fr 1.4fr auto auto; gap: 8px; align-items: center; }
.events { display: grid; gap: 4px; font-size: 12.5px; }
.events div { display: flex; gap: 8px; color: var(--ink-2); }
.events b { color: var(--ink); }

/* ---------- CRM ---------- */
.crm-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(158px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kan-col { display: grid; gap: 8px; align-content: start; padding: 10px; border-radius: var(--r-md); background: var(--one-surface-3, var(--surface-soft)); border: 1px solid var(--border); min-height: 220px; transition: background .15s, border-color .15s; }
.kan-col.over { border-color: var(--blue); background: var(--blue-soft); }
.kan-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 6px; }
.kan-head b { flex: 1; font-size: 13.5px; color: var(--heading); }
.kan-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--blue)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--blue)) 25%, transparent); }
.kan-head small { color: var(--ink-3); font-size: 12px; }
.opp { display: grid; gap: 6px; padding: 11px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); cursor: grab; text-align: start; width: 100%; color: inherit; }
.opp:hover { border-color: var(--blue); }
.opp.dragging { opacity: .5; }
.opp b { font-size: 13.5px; line-height: 1.5; }
.opp small { color: var(--ink-2); font-size: 12px; }
.opp .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.opp .val { font-weight: 800; color: var(--heading); }
.prob { height: 4px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; }
.prob > div { height: 100%; background: var(--c, var(--blue-deep)); }
.contact-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.big-avatar { width: 56px; height: 56px; flex: none; display: grid; place-items: center; border-radius: 18px; font-size: 20px; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--one-accent), var(--one-primary)); }
.contact-head h2 { font-size: 19px; font-weight: 800; color: var(--heading); line-height: 1.35; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick .btn svg.ic { width: 18px; height: 18px; }
.btn.wa { color: #14814a; border-color: color-mix(in srgb, #25d366 45%, var(--border-strong)); }
:root[data-theme="dark"] .btn.wa { color: #5fe39b; }
.timeline { position: relative; display: grid; gap: 12px; padding-inline-start: 26px; }
.timeline::before { content: ''; position: absolute; inset-block: 6px; inset-inline-start: 11px; width: 2px; background: var(--border); }
.tl { position: relative; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.tl .ico { position: absolute; inset-inline-start: -27px; top: 10px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--tone, var(--one-primary)); color: #fff; box-shadow: 0 0 0 4px var(--bg); }
.tl .ico svg.ic { width: 13px; height: 13px; stroke-width: 2.2; }
.tl b { display: block; font-size: 13.5px; }
.tl p { white-space: pre-wrap; color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.tl small { color: var(--ink-3); font-size: 12px; }
.tl.due { border-color: color-mix(in srgb, var(--one-warn) 55%, var(--border)); background: var(--warn-bg); }
.tl.late { border-color: color-mix(in srgb, var(--one-bad) 55%, var(--border)); background: var(--bad-bg); }
.funnel { display: grid; gap: 8px; padding: 16px 20px 20px; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.funnel-row .bar { height: 26px; border-radius: 8px; background: var(--c); min-width: 4px; display: flex; align-items: center; padding: 0 10px; color: #fff; font-weight: 700; font-size: 12px; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.task-row .grow { flex: 1; min-width: 0; }
.task-row b { display: block; line-height: 1.5; }
.task-row small { color: var(--ink-2); }
.task-row.late { border-color: color-mix(in srgb, var(--one-bad) 45%, var(--border)); }
.tag-chip { display: inline-flex; padding: 1px 9px; border-radius: 99px; background: var(--blue-soft); color: var(--info-fg); font-size: 12px; font-weight: 700; }
.merge-help { display: flex; flex-wrap: wrap; gap: 6px; }
.merge-help button { border: 1px dashed var(--border-strong); background: var(--surface-soft); border-radius: 8px; padding: 2px 10px; font-size: 12.5px; }
.phone-mock { max-width: 340px; padding: 14px; border-radius: 22px; background: #e8ded2; }
.phone-mock .msg { padding: 8px 12px; border-radius: 12px 12px 4px 12px; background: #dcf8c6; color: #111; white-space: pre-wrap; font-size: 13.5px; line-height: 1.8; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.mail-mock { border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.mail-mock .bar { padding: 10px 14px; background: var(--one-brand); color: #fff; font-weight: 700; }
.mail-mock .body { padding: 14px; white-space: pre-wrap; line-height: 1.9; font-size: 13.5px; background: var(--surface); }
.stat-ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--one-primary) calc(var(--p) * 1%), var(--muted-bg) 0); }
.stat-ring span { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-weight: 800; font-size: 14px; }

/* ---------- الموردون ---------- */
.stars { color: #e0a020; font-size: 13px; letter-spacing: 1px; line-height: 1; white-space: nowrap; }
.stars > span { color: var(--border-strong); }
.sup-services { color: var(--ink-2); font-size: 13px; line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.sup-decision { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.tile-num svg.ic { width: 13px; height: 13px; vertical-align: -2px; }
.tile-foot .badge svg.ic { width: 13px; height: 13px; }

.home-hero { padding: 26px 26px 20px; }
.home-hero h1 { font-size: 26px; }
.launch { position: relative; z-index: 1; width: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 4px; }
.launch-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); color: #fff; transition: background .15s, transform .15s, border-color .15s; }
.launch-item:hover { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .3); transform: translateY(-2px); }
.launch-item b { display: block; font-size: 14px; line-height: 1.4; }
.launch-item small { color: rgba(255, 255, 255, .72); font-size: 12px; }
.launch-item .tile-ico { width: 40px; height: 40px; border-radius: 12px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.cards > *, .kpis > *, .hero { animation: rise .35s ease both; }
.cards > *:nth-child(2) { animation-delay: .03s; } .cards > *:nth-child(3) { animation-delay: .06s; } .cards > *:nth-child(4) { animation-delay: .09s; }

/* ---------- الجوال ---------- */
@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* 100vh في Safari الجوال أطول من الظاهر فيختفي أسفل القائمة (الحساب والخروج) تحت شريط المتصفح؛ القائمة تمتد بين حافتي الشاشة الفعليتين.
     المخفية غير مرئية حتى لا يصلها التنقل بلوحة المفاتيح ولا تُمرَّر خارج الشاشة. */
  .side { position: fixed; inset: 0 0 0 auto; height: auto; width: min(var(--side-w), 86vw); z-index: 40; transform: translateX(100%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .shell.nav-open .side { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; z-index: 30; background: var(--one-overlay); }
  /* الصفحة خلف القائمة لا تتحرك أثناء فتحها */
  html:has(.shell.nav-open) { overflow: hidden; }
  /* زر القائمة ثابت أعلى الشاشة، فلا يلزم الرجوع لأول الصفحة لفتحها */
  .topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; margin: -16px -16px 14px; padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px; height: calc(48px + env(safe-area-inset-top, 0px));
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
  .shell.portal-active .topbar { margin: 0; background: var(--surface); }
  .portal-host iframe { height: calc(100vh - 48px - env(safe-area-inset-top, 0px)); height: calc(100dvh - 48px - env(safe-area-inset-top, 0px)); }
  .topbar b { font-weight: 800; }
  .main { padding: 16px 16px 40px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 20px; }
  /* الجدول يحتفظ بعرض مقروء ويُمرَّر أفقياً داخل بطاقته فقط */
  .table-wrap table.data { min-width: 720px; }
  .hero { padding: 18px; }
  .hero h1 { font-size: 20px; }
  .hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .hero-stat { padding: 8px 10px; border-radius: 12px; }
  .hero-stat b { font-size: 18px; }
  .hero-stat small { display: block; font-size: 11px; line-height: 1.5; }
  .extra-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .form-grid, .kv, .perm-group ul, .checks, .ov-list { grid-template-columns: minmax(0, 1fr); }
  .toolbar select.input { flex: 1 1 140px; max-width: none; }
  /* الموبايل: النافذة ورقة سفلية بارتفاع محدد، فلا ينهار جسمها على Safari iOS (flex:1 داخل ارتفاع غير محدد). */
  dialog.dlg, dialog.dlg.narrow, dialog.dlg.wide {
    width: 100%; max-width: 100%;
    inset: auto 0 0 0; margin: 0;
    height: 92vh; height: 92dvh; max-height: 92vh; max-height: 92dvh;
    border-radius: 16px 16px 0 0;
  }
  dialog.dlg.drawer { inset: 0; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; border-radius: 0; }
  .dlg-body { flex: 1 1 auto; min-height: 0; -webkit-overflow-scrolling: touch; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* اشتراكات الشركة: أعمدة التجديدات المتوقعة لكل شهر، وبيانات الاشتراك */
.vbars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; padding: 16px 20px 8px; height: 210px; }
.vbar { display: grid; grid-template-rows: auto 1fr auto; gap: 4px; height: 100%; min-width: 0; text-align: center; cursor: default; }
.vbar .v { font-size: 10.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.vbar .col { display: flex; align-items: flex-end; background: var(--muted-bg); border-radius: 6px; overflow: hidden; }
.vbar .fill { width: 100%; min-height: 0; background: var(--one-primary); border-radius: 6px 6px 0 0; }
.vbar:hover .fill { filter: brightness(1.15); }
.vbar .m { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; }
.vbar .m small { display: block; font-size: 10px; }
.sub-info { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; padding: 6px 20px 18px; font-size: 14px; }
.sub-info dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) { .vbars { gap: 3px; padding-inline: 12px; } .vbar .v { font-size: 9px; } .vbar .m { font-size: 9.5px; } }
.sub-cards { display: none; gap: 8px; }
.sub-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: inherit; }
.sub-card .tile-ico { width: 38px; height: 38px; flex: none; }
.sub-card .grow { flex: 1; min-width: 0; display: grid; gap: 3px; }
.sub-card b { line-height: 1.45; }
.sub-card small { color: var(--ink-2); font-size: 12px; }
.sub-card .days { flex: none; text-align: center; display: grid; min-width: 64px; }
.sub-card .days .sub { font-size: 10.5px; color: var(--ink-3); }
@media (max-width: 760px) { .sub-cards { display: grid; } .sub-table { display: none; } }

/* إدارة الأملاك والمحاسبة: على الجوال تبقى خلايا الجداول على سطر واحد ويُمرَّر الجدول أفقياً بدل تكسير الأرقام والأسماء */
@media (max-width: 760px) {
  .ledger-view table.data th, .ledger-view table.data td { white-space: nowrap; }
  .ledger-view table.data td .sub { white-space: nowrap; }
}

/* ===== البرنامج المحاسبي ===== */
.books-tabs { overflow-x: auto; flex-wrap: nowrap !important; scrollbar-width: thin; }
.books-tabs .btn { flex: 0 0 auto; }
.books-lines td { vertical-align: top; }
.books-lines .input { min-width: 0; }
.books-totals { display: flex; justify-content: flex-end; }
table.tot { width: min(380px, 100%); border-collapse: collapse; margin-inline-start: auto; }
table.tot td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.tot td.num { text-align: end; white-space: nowrap; }
table.tot tr.grand td { font-weight: 800; font-size: 15px; background: var(--surface-soft); border-bottom: 0; }
.books-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin: 14px 0 6px; }
.books-bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; }
.books-bars .bb { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.books-bars .bb-cols { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.books-bars .bb-s, .books-bars .bb-e { width: 42%; min-height: 1px; border-radius: 4px 4px 0 0; }
.books-bars .bb-s, .dot-s { background: var(--one-primary); }
.books-bars .bb-e, .dot-e { background: var(--warn-fg); opacity: .75; }
.dot-s, .dot-e { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; margin-inline: 8px 4px; }
.zstep { border-inline-start: 4px solid var(--border); }
.zstep.now { border-inline-start-color: var(--one-primary); }
.zstep.done { border-inline-start-color: var(--ok-fg); }
.zstep .zn { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--muted-bg); font-weight: 800; }
.zstep.done .zn { background: var(--ok-bg); color: var(--ok-fg); }
.zstep.now .zn { background: var(--info-bg); color: var(--info-fg); }
.warn-box { border-color: color-mix(in srgb, var(--warn-fg) 45%, var(--border)); }
@media (max-width: 720px) {
  .books .form-grid { grid-template-columns: 1fr; }
  .books-lines { min-width: 760px; }
  .books-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* شاشة الأدوار: أقسام منسدلة، ولكل صلاحية قائمة مسموح أو ممنوع */
.pm-head { display: grid; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.pm-pick { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(200px, 1fr); gap: 12px; align-items: end; }
.pm-part { border-bottom: 1px solid var(--border); }
.pm-part > summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 20px; cursor: pointer; font-weight: 800; color: var(--heading); }
.pm-part > summary:hover { background: var(--surface-soft); }
.pm-part .pm-name { flex: 1; min-width: 160px; }
.pm-part select.pm-bulk { width: 170px; min-height: 34px; flex: none; padding-block: 0; font-weight: 500; }
.pm-group { padding: 4px 20px 14px; }
.pm-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.pm-group-head h4 { font-size: 13.5px; font-weight: 800; color: var(--ink-3); margin: 0; }
.pm-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; }
.pm-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: 10px; font-size: 13.5px; color: var(--ink); background: var(--surface-soft); }
.pm-row > span:first-child { flex: 1; min-width: 0; }
.pm-row select.pm-sel { width: 118px; min-height: 32px; flex: none; padding-block: 0; font-weight: 700; }
.pm-row select.pm-sel.allow { color: var(--ok-fg); background-color: var(--ok-bg); }
.pm-row select.pm-sel.deny { color: var(--bad-fg); background-color: var(--bad-bg); }
.pm-actions { position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--border); z-index: 2; }
.ov-part { border-top: 1px solid var(--border); }
.ov-part > summary { padding: 10px 0; font-weight: 700; cursor: pointer; color: var(--heading); }
@media (max-width: 900px) { .pm-pick, .pm-rows { grid-template-columns: minmax(0, 1fr); } .pm-part select.pm-bulk { width: 100%; } }

/* CRM: لوحة الزيارة الميدانية (موقع وصور) في محرّر النشاط وسجله */
.visit-box { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; display: grid; gap: 6px; background: var(--surface-soft); }
.visit-meta { margin-top: 8px; display: grid; gap: 8px; }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.ph-grid a { display: block; border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; background: var(--surface-soft); border: 1px solid var(--border); }
.ph-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- زر حذف ذاكرة التخزين المؤقتة ---------- */
.side-brand > div { min-width: 0; flex: 1; }
.cache-btn { flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .06); color: var(--one-on-brand-2); cursor: pointer; }
.cache-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.cache-btn svg.ic, .cache-top svg.ic { width: 17px; height: 17px; }
.topbar .cache-top { margin-inline-start: auto; }
[data-clear-cache].spin svg { animation: att-spin .9s linear infinite; }

/* ---------- نافذة الحضور والانصراف اليومية ---------- */
dialog.att-pop { width: min(400px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 26px; background: transparent; overflow: visible; color: var(--ink); }
dialog.att-pop::backdrop { background: rgba(4, 16, 47, .55); backdrop-filter: blur(5px); animation: att-fade .3s ease both; }
dialog.att-pop[open] .att-card { animation: att-pop .5s cubic-bezier(.2, 1.3, .4, 1) both; }
dialog.att-pop.att-leave .att-card { animation: att-away .26s ease both; }
.att-card { position: relative; overflow: hidden; border-radius: 26px; background: var(--surface); box-shadow: 0 30px 80px -20px rgba(4, 16, 47, .55), 0 0 0 1px rgba(255, 255, 255, .06); }
.att-scene { display: block; width: 100%; height: auto; }
.att-x { position: absolute; top: 10px; inset-inline-end: 10px; z-index: 2; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .78); color: #071949; cursor: pointer; }
.att-x svg.ic { width: 16px; height: 16px; }
.att-body { position: relative; display: grid; justify-items: center; gap: 6px; padding: 4px 22px 20px; text-align: center; }
.att-greet { margin-top: -16px; padding: 5px 14px; border-radius: 999px; background: var(--surface); box-shadow: 0 8px 20px -10px rgba(7, 25, 73, .45); font-size: 13px; font-weight: 700; color: var(--one-primary); }
.att-pop.att-out .att-greet { color: #7a4b8f; }
.att-body h2 { margin: 6px 0 0; font-size: 22px; font-weight: 900; color: var(--one-heading); }
.att-clock { display: flex; align-items: baseline; gap: 8px; }
.att-clock b { font-size: 30px; font-weight: 900; letter-spacing: .5px; background: linear-gradient(135deg, #12709c, #29a9e1); -webkit-background-clip: text; background-clip: text; color: transparent; }
.att-pop.att-out .att-clock b { background-image: linear-gradient(135deg, #5e4a8c, #f29e6b); }
.att-clock small { font-size: 12px; color: var(--ink-3); }
.att-line { margin: 2px 0 6px; font-size: 13.5px; line-height: 1.9; color: var(--ink-2); }
.att-status { width: 100%; min-height: 0; font-size: 13.5px; line-height: 1.8; }
.att-status:empty { display: none; }
.att-status b { display: block; color: var(--one-ok); font-weight: 800; }
.att-err { display: block; padding: 8px 12px; border-radius: 12px; background: var(--one-bad-soft); color: var(--one-bad); font-weight: 600; }
.att-go { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 54px; margin-top: 4px; border: 0; border-radius: 16px; cursor: pointer; font: inherit; font-size: 16px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #12709c 0%, #29a9e1 100%); box-shadow: 0 14px 30px -12px rgba(18, 112, 156, .8); transition: transform .15s ease, box-shadow .15s ease; overflow: hidden; }
.att-pop.att-out .att-go { background: linear-gradient(135deg, #5e4a8c 0%, #e98a5f 100%); box-shadow: 0 14px 30px -12px rgba(122, 75, 143, .8); }
.att-go:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 18px 34px -12px rgba(18, 112, 156, .9); }
.att-go:disabled { cursor: progress; opacity: .95; }
.att-go svg.ic { width: 24px; height: 24px; }
.att-go::after { content: ''; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .35) 50%, transparent 65%); transform: translateX(-120%); animation: att-shine 3.2s ease-in-out 1s infinite; }
.att-busy .att-go::after, .att-ok .att-go::after { display: none; }
.att-pop.att-ok .att-go { background: linear-gradient(135deg, #157a4c, #2fb27a); box-shadow: 0 14px 30px -12px rgba(21, 122, 76, .8); }
.att-radar { position: relative; width: 22px; height: 22px; border-radius: 50%; background: #fff; }
.att-radar::before, .att-radar::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid #fff; animation: att-ping 1.4s ease-out infinite; }
.att-radar::after { animation-delay: .7s; }
.att-more { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.att-more[hidden] { display: none; }
.att-more button { border: 0; background: transparent; padding: 8px 10px; border-radius: 10px; font: inherit; font-size: 13px; color: var(--ink-3); cursor: pointer; }
.att-more button:hover { background: var(--muted-bg); color: var(--ink); }
.att-check { display: inline-block; width: 46px; height: 46px; margin-bottom: 2px; }
.att-check svg { width: 100%; height: 100%; fill: none; stroke: var(--one-ok); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.att-check circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: att-draw .6s ease forwards; }
.att-check path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: att-draw .4s ease .5s forwards; }
.att-rise { animation: att-rise 1.6s cubic-bezier(.2, .8, .3, 1) both; }
.att-rays { transform-origin: 120px 72px; animation: att-spin 18s linear infinite; }
.att-cloud { animation: att-drift 9s ease-in-out infinite alternate; }
.att-stars circle { animation: att-twinkle 2.4s ease-in-out infinite; }
.att-moon { animation: att-float 4s ease-in-out infinite alternate; }
.att-set { animation: att-sink 2s ease-out both; }
@keyframes att-pop { from { opacity: 0; transform: translateY(26px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes att-away { to { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes att-fade { from { opacity: 0; } }
@keyframes att-rise { from { transform: translateY(40px); } to { transform: none; } }
@keyframes att-spin { to { transform: rotate(360deg); } }
@keyframes att-drift { to { transform: translateX(26px); } }
@keyframes att-twinkle { 50% { opacity: .25; } }
@keyframes att-float { to { transform: translateY(-5px); } }
@keyframes att-sink { from { transform: translateY(-26px); } }
@keyframes att-shine { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
@keyframes att-ping { from { transform: scale(1); opacity: .9; } to { transform: scale(2.4); opacity: 0; } }
@keyframes att-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .att-card, .att-rise, .att-rays, .att-cloud, .att-stars circle, .att-moon, .att-set, .att-go::after { animation: none !important; } }

/* الأدوار: ملخص ما يفتحه الدور، وأقسام التقييم حين تكون المنصة مقفلة */
.pm-sum { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pm-sum .badge svg { width: 13px; height: 13px; margin-inline-end: 3px; vertical-align: -2px; }
.pm-part.pm-off .pm-group:not([data-group="الدخول لمنصة التقييم"]) { opacity: .45; }
.pm-off-note { margin: 0 20px 6px; padding: 8px 12px; border-radius: 10px; background: var(--surface-soft); color: var(--ink-3); font-size: 13px; }
.ov-key { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; }
.ov-key .ov-row { font-weight: 700; }
.att-status .att-weather { display: block; margin-top: 8px; padding: 8px 12px; border-radius: 12px; background: var(--surface-soft); color: var(--ink-2, inherit); font-weight: 600; }
