/* =========================================================================
   نظام تصميم مندوب — المصدر الوحيد للرموز ومظهر المكوّنات المشتركة (RTL)
   يُحمَّل بعد app.css. القواعد:
   • هوية داكنة كحلية افتراضياً، مع وضع فاتح يعمل بالرموز نفسها.
   • --brand يأتي من الشركة (layout) وتُشتق منه التدرجات، فتبقى هوية كل شركة.
   • التدرجات للمؤشرات الرئيسية والأزرار الأساسية فقط؛ بقية الأسطح هادئة.
   • نصوص بلون الهوية عبر --brand-text (مقروءة في الوضعين).
   ترتيب الملف: الرموز → الأساسيات → الهيكل → المكوّنات → أنماط الصفحات → الاستجابة.
   ========================================================================= */

:root {
  --brand: #7463db;
  --brand-dark: color-mix(in srgb, var(--brand) 82%, #000);
  --brand-bright: color-mix(in srgb, var(--brand) 72%, #fff);
  --brand-text: var(--brand);
  --brand-soft: color-mix(in srgb, var(--brand) 10%, var(--surface));
  --brand-light: color-mix(in srgb, var(--brand) 20%, var(--surface));
  --brand-ring: color-mix(in srgb, var(--brand) 26%, transparent);
  --magenta: color-mix(in srgb, var(--brand) 45%, #f15bd8);
  --cyan: #19d9d3;
  --grad-a: linear-gradient(120deg, var(--magenta), var(--brand-bright) 55%, var(--brand));
  --grad-b: linear-gradient(120deg, var(--cyan), #3f8ff0);
  --grad-nav: linear-gradient(270deg, color-mix(in srgb, var(--brand) 52%, transparent), color-mix(in srgb, var(--brand) 14%, transparent));
  --chart-1: color-mix(in srgb, var(--brand) 55%, #f15bd8);
  --chart-2: #19c9d9;
  --chart-3: #3f8ff0;
  --chart-4: #9b6cf5;
  --chart-5: #f0b429;
  --chart-grid: #e6e8f0;

  --bg: #f3f4f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef0f6;
  --surface-input: #ffffff;
  --border: #e3e6ef;
  --border-strong: #cfd4e1;
  --text: #151a2e;
  --text-2: #3d4560;
  --muted: #5f6880;
  --muted-2: #767f96;

  --green: #0d8a5e;  --green-bg: color-mix(in srgb, var(--green) 11%, var(--surface));
  --red: #d0343f;    --red-bg: color-mix(in srgb, var(--red) 10%, var(--surface));
  --amber: #b06f04;  --amber-bg: color-mix(in srgb, var(--amber) 12%, var(--surface));
  --blue: #2563d8;   --blue-bg: color-mix(in srgb, var(--blue) 10%, var(--surface));
  --olive: #66791d;  --olive-bg: color-mix(in srgb, var(--olive) 12%, var(--surface));
  --gray: #4b5567;   --gray-bg: color-mix(in srgb, var(--gray) 9%, var(--surface));
  --teal: var(--brand); --teal-bg: var(--brand-soft);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 46, .05);
  --shadow: 0 6px 20px rgba(20, 24, 46, .08);
  --shadow-lg: 0 20px 56px rgba(10, 13, 30, .32);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --control-h: 38px;

  /* الشريط الجانبي داكن في الوضعين */
  --sb-bg: #151a31;
  --sb-bg-2: #1a2039;
  --sb-line: rgba(255, 255, 255, .07);
  --sb-text: #c3c8dd;
  --sb-strong: #ffffff;
  --sb-muted: #7f87a6;
  --sb-accent: color-mix(in srgb, var(--brand) 40%, #f07ee4);

  --sidebar-w: 268px;
  --topbar-h: 62px;
  --ink: #0e1224;
  --ink-2: #171c33;
  --font: "IBM Plex Sans Arabic", "SF Arabic", "Segoe UI Variable Text", "Segoe UI", "Noto Sans Arabic", "Noto Kufi Arabic", Tahoma, system-ui, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #10142a; --surface: #181d37; --surface-2: #1d2340; --surface-3: #252c4d; --surface-input: #141932;
  --border: #272e4f; --border-strong: #38406a;
  --text: #edeffa; --text-2: #c3c8dd; --muted: #98a0bd; --muted-2: #7f87a6;
  --green: #34d9a0; --red: #ff7d92; --amber: #fbc24a; --blue: #6fa8ff; --olive: #b4c85a; --gray: #aab4cc;
  --brand-text: color-mix(in srgb, var(--brand) 62%, #fff);
  --brand-soft: color-mix(in srgb, var(--brand) 20%, var(--surface));
  --brand-light: color-mix(in srgb, var(--brand) 34%, var(--surface));
  --chart-grid: rgba(255, 255, 255, .08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow: 0 8px 26px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
  --ink: #0a0d1c; --ink-2: #141932;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10142a; --surface: #181d37; --surface-2: #1d2340; --surface-3: #252c4d; --surface-input: #141932;
    --border: #272e4f; --border-strong: #38406a;
    --text: #edeffa; --text-2: #c3c8dd; --muted: #98a0bd; --muted-2: #7f87a6;
    --green: #34d9a0; --red: #ff7d92; --amber: #fbc24a; --blue: #6fa8ff; --olive: #b4c85a; --gray: #aab4cc;
    --brand-text: color-mix(in srgb, var(--brand) 62%, #fff);
    --brand-soft: color-mix(in srgb, var(--brand) 20%, var(--surface));
    --brand-light: color-mix(in srgb, var(--brand) 34%, var(--surface));
    --chart-grid: rgba(255, 255, 255, .08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow: 0 8px 26px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
    --ink: #0a0d1c; --ink-2: #141932;
    color-scheme: dark;
  }
}

/* ---------------- الأساسيات ---------------- */
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.65; letter-spacing: 0; text-rendering: optimizeLegibility; }
::selection { background: var(--brand-ring); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }
.num, .val, .kpi-value, .stat-value, td, .pos-total { font-variant-numeric: tabular-nums; }
h1, h2, h3, h4 { letter-spacing: -.01em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-red { color: var(--red) !important; } .text-muted { color: var(--muted) !important; } .text-sm { font-size: .82rem; }
.text-green { color: var(--green) !important; } .text-amber { color: var(--amber) !important; }

.skip-link { position: fixed; top: -60px; inset-inline-start: 1rem; z-index: 400; background: var(--brand); color: #fff; padding: .55rem 1rem; border-radius: 0 0 8px 8px; font-weight: 700; transition: top .2s; }
.skip-link:focus { top: 0; }

#nav-progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 300; pointer-events: none; opacity: 0; transition: opacity .25s; }
#nav-progress i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .4s var(--ease); margin-inline-start: auto; }
#nav-progress.on { opacity: 1; }

/* ---------------- الشريط الجانبي ---------------- */
.sidebar { background: linear-gradient(180deg, var(--sb-bg-2), var(--sb-bg)); border-left: 0; border-inline-end: 1px solid var(--sb-line); box-shadow: none; transition: width .2s var(--ease), transform .24s var(--ease); }
.sidebar-head { padding: 1rem 1.15rem; min-height: var(--topbar-h); border-bottom: 1px solid var(--sb-line); }
.sidebar-logo { width: 38px; height: 38px; border-radius: 11px; background: var(--grad-a); color: #fff; box-shadow: none; }
.sidebar-title { color: var(--sb-strong); font-size: .98rem; font-weight: 700; }
.sidebar-sub { color: var(--sb-muted); font-size: .72rem; }
.sidebar-nav { padding: .4rem 0 1rem; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .14) transparent; }
.nav-group { margin-top: 0; padding: .7rem 0 .55rem; border-bottom: 1px solid var(--sb-line); }
.nav-group:last-child { border-bottom: 0; }
/* عنوان القسم: أيقونة ولون مميزان، والعناصر تحته نصوص هادئة */
.nav-label { display: flex; align-items: center; gap: .55rem; color: var(--sb-accent); font-size: .82rem; font-weight: 700; letter-spacing: 0; padding: .1rem 1.15rem .4rem; }
.nav-label svg { width: 17px; height: 17px; flex: none; }
.nav-link { position: relative; color: var(--sb-text); padding: .44rem 1.15rem .44rem .9rem; padding-inline-start: 2.55rem; border-radius: 0; font-size: .85rem; font-weight: 500; margin: 0; transition: background .14s, color .14s; }
.nav-link .nav-icon { display: none; }
.nav-group:not(:has(.nav-label)) .nav-link { padding-inline-start: 1.15rem; font-weight: 700; color: var(--sb-strong); }
.nav-group:not(:has(.nav-label)) .nav-link .nav-icon { display: block; width: 17px; height: 17px; color: var(--sb-accent); opacity: 1; }
.nav-link:hover { background: rgba(255, 255, 255, .05); color: var(--sb-strong); }
/* العنصر النشط: شريط بتدرج الهوية وسهم عند الحافة */
.nav-link.is-active, .nav-group:not(:has(.nav-label)) .nav-link.is-active { background: var(--grad-nav); color: #fff; font-weight: 650; box-shadow: none; }
.nav-link.is-active::after { display: none; }
.nav-link.is-active::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 11px; background: var(--grad-a); clip-path: polygon(100% 0, 0 50%, 100% 100%); }
.nav-badge { margin-inline-start: auto; min-width: 20px; padding: 0 .42rem; border-radius: 999px; background: var(--magenta); color: #fff; font-size: .68rem; font-weight: 700; text-align: center; line-height: 20px; }
.nav-link-erp { background: none; color: var(--sb-strong) !important; font-weight: 700; }
.nav-link-erp .nav-icon { color: var(--sb-accent) !important; }

/* بطاقة التقارير أسفل الشريط */
.nav-card { margin: .7rem .8rem .25rem; padding: .7rem .8rem; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid var(--sb-line); }
.nav-card b { display: block; color: var(--sb-strong); font-size: .82rem; font-weight: 700; }
.nav-card small { display: block; margin: .05rem 0 .55rem; color: var(--sb-muted); font-size: .72rem; }
.nav-card a { display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 .8rem; border-radius: 999px; background: var(--grad-a); color: #fff; font-size: .78rem; font-weight: 700; }
.nav-card a svg { width: 15px; height: 15px; }
.nav-card a:hover { filter: brightness(1.08); color: #fff; }
.sidebar-foot { border-top: 1px solid var(--sb-line); padding: .6rem .8rem; }
.user-chip { background: none; border: 0; padding: .1rem; }
.user-chip > div:nth-child(2) > div:first-child, .user-chip .truncate { color: var(--sb-strong) !important; }
.user-chip > div:nth-child(2) > div:last-child { color: var(--sb-muted) !important; }
.user-chip .btn { color: var(--sb-muted) !important; }
.user-chip .btn:hover { background: rgba(255, 255, 255, .08); color: #fff !important; }
.avatar { background: var(--grad-a); color: #fff; box-shadow: none; }

@media (min-width: 901px) {
  html[data-rail="1"] { --sidebar-w: 70px; }
  html[data-rail="1"] .sidebar-head { justify-content: center; padding-inline: .5rem; }
  html[data-rail="1"] .sidebar-head > div:not(.sidebar-logo),
  html[data-rail="1"] .nav-label,
  html[data-rail="1"] .nav-card,
  html[data-rail="1"] .user-chip > div:not(.avatar),
  html[data-rail="1"] .user-chip form { display: none; }
  html[data-rail="1"] .nav-link { font-size: 0; justify-content: center; padding: .6rem 0; }
  html[data-rail="1"] .nav-link .nav-icon { display: block; width: 20px; height: 20px; color: var(--sb-text); }
  html[data-rail="1"] .nav-link.is-active .nav-icon { color: #fff; }
  html[data-rail="1"] .nav-badge { position: absolute; top: 3px; inset-inline-start: 8px; margin: 0; font-size: .6rem; line-height: 16px; min-width: 16px; padding: 0 .25rem; }
  html[data-rail="1"] .user-chip { justify-content: center; padding: .4rem 0; }
  html[data-rail="1"] .nav-link:hover::before { content: attr(data-tip); position: absolute; inset-block: auto; clip-path: none; width: auto; right: calc(100% + 10px); top: 50%; transform: translateY(-50%); background: var(--ink); color: #fff; font-size: .78rem; padding: .25rem .55rem; border-radius: 6px; white-space: nowrap; z-index: 80; }
}
.main { transition: margin-right .2s var(--ease); }

/* ---------------- الشريط العلوي ---------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: none; height: var(--topbar-h); padding: 0 1.25rem; gap: .75rem; }
.topbar h1 { font-size: 1.05rem; font-weight: 700; }
.topbar-actions { gap: .4rem; }
.menu-toggle { display: none; background: var(--surface-3); border: 0; border-radius: var(--radius-sm); padding: .45rem; color: var(--text-2); }
.tb-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; transition: background .12s, border-color .12s; font-family: inherit; }
.tb-btn:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.tb-btn svg { width: 18px; height: 18px; }
.tb-search { display: inline-flex; align-items: center; gap: .5rem; height: 36px; padding: 0 .7rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: .82rem; cursor: pointer; font-family: inherit; transition: border-color .12s; min-width: 190px; }
.tb-search:hover { border-color: var(--border-strong); color: var(--text); }
.tb-search svg { width: 16px; height: 16px; }
.tb-search kbd { margin-inline-start: auto; font: 600 .66rem var(--font); padding: .08rem .35rem; border-radius: 5px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.tb-page-actions, .tb-tools { display: flex; align-items: center; gap: .4rem; }
.content { padding: 1.25rem; max-width: 1560px; }
.tabs, .table-wrap, .sidebar-nav { scrollbar-width: thin; }
.rail-toggle { display: inline-grid; }

/* ---------------- البطاقات والمؤشرات ---------------- */
.card { background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); background: transparent; }
.card-head svg { width: 18px; height: 18px; flex: none; }
.card-head h2, .card-head h3 { font-size: .95rem; font-weight: 700; }
.card-body { padding: 1.1rem; }
.card-foot { background: var(--surface-2); border-top: 1px solid var(--border); padding: .75rem 1.1rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; border-radius: 0 0 var(--radius) var(--radius); }
.card + .card { margin-top: 1rem; }

.stat, .kpi-card, .sb-kpi, .erp-tile, .dash-chart-card, .erp-step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat, .kpi-card, .erp-kpi { --kpi: var(--brand); --kpi-bg: var(--brand-soft); }
.stat.red, .kpi-card.debts, .erp-kpi.tone-red { --kpi: var(--red); --kpi-bg: var(--red-bg); }
.stat.amber, .kpi-card.visits, .erp-kpi.tone-amber { --kpi: var(--amber); --kpi-bg: var(--amber-bg); }
.erp-kpi[class] { --tone: var(--kpi); --tone-bg: var(--kpi-bg); }
.stat { padding: .95rem 1.05rem; }
.stat:hover, .kpi-card:hover, .region-card:hover, .erp-tile:hover { transform: none; box-shadow: var(--shadow-sm); }
.stat[class] .stat-icon, .kpi-card[class] .kpi-icon-box, .erp-kpi .erp-kpi-ico { width: 40px; height: 40px; border-radius: 50%; background: var(--grad-a); color: #fff; box-shadow: none; }
.stat.teal .stat-icon, .stat.olive .stat-icon, .stat.green .stat-icon, .erp-kpi:nth-child(even) .erp-kpi-ico { background: var(--grad-b) !important; }
.stat.red .stat-icon, .erp-kpi.tone-red .erp-kpi-ico { background: linear-gradient(120deg, #ff7d92, #d0343f) !important; }
.stat.amber .stat-icon, .erp-kpi.tone-amber .erp-kpi-ico { background: linear-gradient(120deg, #fbc24a, #e8892b) !important; }
.stat-value, .kpi-value { font-weight: 700; letter-spacing: -.02em; }
.kpi-card { border-top-width: 1px !important; position: relative; overflow: hidden; }
.kpi-card::before { display: none; }
.kpi-label, .stat-label, .sb-kpi .lbl { color: var(--muted); font-weight: 600; }
.sb-kpi { padding: .95rem 1.05rem; }
.sb-kpi .val { font-weight: 700; letter-spacing: -.02em; }
.sb-kpi.red { border-color: color-mix(in srgb, var(--red) 28%, var(--border)); }
.sb-kpi.amber { border-color: color-mix(in srgb, var(--amber) 30%, var(--border)); }
.sb-kpi.green { border-color: color-mix(in srgb, var(--green) 28%, var(--border)); }

/* رأس لوحة القيادة: شريط ترحيب هادئ بنفس سطح البطاقات */
.dash-hero, .sb-hero { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.dash-hero::before, .dash-hero::after, .sb-hero::before, .sb-hero::after { display: none; }
.dash-hero-title h1, .sb-hero h2 { color: var(--text); }
.dash-hero-title p, .sb-hero p, .sb-hero .eyebrow { color: var(--muted); opacity: 1; }
.dash-hero-actions .btn { color: var(--text); background: var(--surface); border-color: var(--border-strong); box-shadow: none; }
.dash-hero-actions .btn:hover { background: var(--surface-2); color: var(--text); transform: none; box-shadow: none; }
.dash-hero-actions .btn.btn-hero-primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.dash-hero-actions .btn.btn-hero-primary:hover { background: var(--brand-dark); color: #fff; }
.sb-hero .sb-tag { color: var(--text-2); background: var(--surface-3); border-color: var(--border); }
.sb-hero .sb-countdown { color: var(--brand-text); background: var(--brand-soft); }
.sb-hero .sb-countdown b { color: var(--brand-text); }
.sb-hero .sb-countdown span { color: var(--muted); }

.dash-alert-item { border-radius: var(--radius-sm); }
.dash-alert-item.warn { background: var(--amber-bg); border-color: color-mix(in srgb, var(--amber) 30%, transparent); color: var(--amber); }
.dash-alert-item.danger { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 30%, transparent); color: var(--red); }
.dash-alert-item.info { background: var(--blue-bg); border-color: color-mix(in srgb, var(--blue) 30%, transparent); color: var(--blue); }
.chart-bar { background: var(--brand); border-radius: 5px 5px 2px 2px; }
.legend-dot.sales { background: var(--green); } .legend-dot.payments { background: var(--blue); }
.progress { background: var(--surface-3); height: 7px; }
.side-item-row:hover { background: var(--surface-2); }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 176px), 1fr)); gap: .85rem; }
.dash-cols { gap: 1rem; }
.kpi-pill { background: var(--surface-3); color: var(--text-2); border-radius: 999px; }
/* أدوات استوديو الفاتورة لها أنماط مضمّنة بألوان ثابتة: تتبع الثيم، وورقة المعاينة تبقى بيضاء */
.studio-header, .card-tool, .head-icon, .dropzone-box, .dz-icon, .slider-group { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; box-shadow: none !important; }
.head-icon, .dz-icon, .dropzone-box, .slider-group { background: var(--surface-2) !important; }
.card-tool :is(h1, h2, h3, h4, label, p, small, span):not(.palette-btn *):not(.btn *), .studio-header :is(h1, h2, h3, p, span, small):not(.btn *), .dropzone-box * { color: inherit !important; }
.studio-header .btn:not(.btn-primary), .card-tool .btn:not(.btn-primary) { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--border-strong) !important; }
.studio-header .btn-primary { background: var(--grad-a) !important; color: #fff !important; border-color: transparent !important; }
.preview-top-toolbar, .preview-stage { background: var(--surface-2) !important; color: var(--text-2) !important; border-color: var(--border) !important; }
.preview-top-toolbar * { color: inherit; }

/* ---------------- الأزرار ---------------- */
.btn { min-height: var(--control-h); border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: .84rem; padding: .4rem .9rem; box-shadow: none; transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { background: var(--surface-3); }
.btn-primary { background: var(--grad-a); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--grad-a); border-color: transparent; color: #fff; filter: brightness(1.08); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: color-mix(in srgb, var(--green) 85%, #000); border-color: transparent; color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--red) 85%, #000); border-color: transparent; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn-soft { background: var(--brand-soft); color: var(--brand-text); border-color: transparent; }
.btn-soft:hover { background: var(--brand-light); border-color: transparent; }
.btn-sm { min-height: 32px; border-radius: 7px; padding: .22rem .65rem; font-size: .78rem; }
.btn-lg { min-height: 46px; border-radius: 10px; padding: .6rem 1.3rem; font-size: .95rem; }
.btn-icon { padding: 0; width: var(--control-h); justify-content: center; }
.btn-sm.btn-icon { width: 32px; }
.btn-icon svg { width: 16px; height: 16px; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--red); }
.btn-danger-ghost:hover { background: var(--red-bg); border-color: transparent; color: var(--red); }
.btn:disabled, .btn[data-busy] { opacity: .6; pointer-events: none; }
.btn[data-busy]::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- النماذج ---------------- */
label { color: var(--text-2); font-weight: 600; font-size: .82rem; }
.form-control, select, textarea, input:not([type]), input[type=text], input[type=number], input[type=date], input[type=time], input[type=datetime-local],
input[type=password], input[type=email], input[type=tel], input[type=search], input[type=url], input[type=month] {
  background-color: var(--surface-input); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .4rem .7rem; min-height: var(--control-h); font-size: .86rem;
  transition: border-color .12s, box-shadow .12s;
}
.form-control::placeholder, input::placeholder, textarea::placeholder { color: var(--muted-2); }
.form-control:hover, select:hover, textarea:hover, input:hover { border-color: var(--muted-2); }
.form-control:focus, select:focus, textarea:focus, input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); outline: none; }
input[readonly] { background-color: var(--surface-2); color: var(--muted); }
input[type=checkbox], input[type=radio] { min-height: 0; padding: 0; box-shadow: none !important; accent-color: var(--brand); }
input[type=color] { width: 100%; min-height: var(--control-h); padding: .2rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-input); cursor: pointer; }
input[type=file] { width: 100%; font: inherit; font-size: .8rem; color: var(--muted); }
input[type=file]::file-selector-button { height: 32px; margin-inline-end: .6rem; padding: 0 .7rem; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); color: var(--text); font: 600 .78rem var(--font); cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--surface-3); }
select { background-repeat: no-repeat; background-position: left .55rem center; background-size: 16px; padding-inline-end: 1.9rem; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23747d8e'%3E%3Cpath d='M5.2 7.5 10 12.3l4.8-4.8z'/%3E%3C/svg%3E"); }
.help { color: var(--muted); font-size: .74rem; }
.req { color: var(--red); }
.switch { position: relative; }
.switch input { display: block; position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch span.lbl { color: var(--text-2); font-weight: 500; }
.switch .track { width: 36px; height: 20px; background: var(--border-strong); }
.switch .track::after { width: 16px; height: 16px; top: 2px; }
.switch input:checked + .track::after { inset-inline-end: 18px; }
.switch input:checked + .track { background: var(--brand); }
.upload-box { background: var(--surface-2); border-color: var(--border-strong); border-radius: var(--radius); }
.upload-box:hover { border-color: var(--brand); background: var(--brand-soft); }
.search-box svg { color: var(--muted-2); }
.search-box input { padding-inline-start: 2.2rem; }
.filters { padding: 0; gap: .5rem; }
.chip { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); border-radius: 999px; padding: .22rem .7rem; transition: border-color .12s, color .12s; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand-text); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------------- الجداول ---------------- */
.table-wrap { position: relative; scrollbar-width: thin; }
table.table { font-size: .85rem; }
table.table thead th { background: var(--surface-2); color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: 0; border-bottom: 1px solid var(--border); padding: .6rem .85rem; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
table.table tbody td { padding: .6rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr { transition: background .1s; }
table.table tbody tr:hover { background: var(--surface-2); }
table.table tfoot td { background: var(--surface-2); border-top: 1px solid var(--border-strong); }
table.table td.num, table.table th.num { text-align: end; }
table.table .actions, table.table td > .actions { justify-content: flex-end; }
.actions { display: flex; align-items: center; gap: .25rem; }
.cell-title { color: var(--text); font-weight: 600; }
td > a.cell-title { white-space: nowrap; }
a.cell-title:hover, .cell-title a:hover { color: var(--brand-text); }
.cell-sub { color: var(--muted); font-size: .74rem; }
.thumb { border-radius: var(--radius-sm); border: 1px solid var(--border); }
.empty { padding: 2.75rem 1rem; }
.empty > svg { width: 42px; height: 42px; padding: 10px; border-radius: 10px; background: var(--surface-3); color: var(--muted); }
.empty .btn svg { width: 16px; height: 16px; margin: 0; padding: 0; background: none; color: currentColor; }
.empty h4 { color: var(--text); font-weight: 700; font-size: .95rem; }
.empty p { color: var(--muted); }

/* ---------------- الشارات والتنبيهات ---------------- */
.badge { border-radius: 6px; font-weight: 600; font-size: .72rem; padding: .1rem .5rem; letter-spacing: 0; white-space: nowrap; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-olive { background: var(--olive-bg); color: var(--olive); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }
.badge-teal { background: var(--brand-soft); color: var(--brand-text); }

.alert { border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 500; }
.alert-success { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 26%, transparent); }
.alert-danger { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 26%, transparent); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 28%, transparent); }
.alert-info { background: var(--blue-bg); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 26%, transparent); }
.alert.toast { animation: toastIn .25s var(--ease); transition: opacity .3s, transform .3s; }
.alert.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

.impersonate-bar { background: var(--ink); }
.sb-notice { border-bottom: 0; }
.ads-bar { background: var(--brand); }

/* ---------------- التبويبات والصفحات ---------------- */
.tabs { gap: .1rem; border-bottom: 1px solid var(--border); }
.tab { border-radius: 7px 7px 0 0; padding: .55rem .9rem; font-weight: 600; color: var(--muted); transition: color .12s, background .12s; position: relative; }
.tab:hover { color: var(--text); background: var(--surface-3); }
.tab.is-active { color: var(--brand-text); border-bottom: 0; }
.tab.is-active::after { content: ""; position: absolute; inset: auto .5rem -1px; height: 2px; background: var(--brand); }
.pagination a, .pagination span { background: var(--surface); border-color: var(--border); color: var(--text-2); border-radius: 7px; }
.pagination a:hover { border-color: var(--brand); color: var(--brand-text); }
.pagination .active span, .pagination span[aria-current] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------------- النوافذ المنبثقة ---------------- */
.modal-backdrop { background: rgba(14, 17, 23, .5); }
.modal { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: modalIn .16s var(--ease); }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } }
.modal-head { border-bottom: 1px solid var(--border); padding: .85rem 1.15rem; }
.modal-head h3 { font-weight: 700; }
.modal-head .close { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; transition: background .12s; }
.modal-head .close:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 1.15rem; }
.modal-foot { background: var(--surface-2); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------------- مكوّنات صفحات الإدارة ---------------- */
/* شريط أدوات القائمة: بحث وفلاتر وإجراء رئيسي في صف واحد */
.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .7rem 1.1rem; border-bottom: 1px solid var(--border); }
.toolbar .search-box { flex: 1 1 240px; min-width: 200px; max-width: 420px; }
.toolbar select { width: auto; flex: 0 1 170px; min-width: 130px; }
.toolbar-count { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.toolbar-spacer { flex: 1 1 0; }

/* تبديل مقسّم (شبكة/جدول) */
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-sm); background: var(--surface-3); flex: none; }
.seg a { display: inline-flex; align-items: center; gap: .3rem; height: 32px; padding: 0 .65rem; border-radius: 6px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.seg a svg { width: 15px; height: 15px; }
.seg a:hover { color: var(--text); }
.seg a.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* خلية عنصر: صورة + اسم + سطر فرعي */
.item-cell { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.item-cell > span:last-child, .item-cell > div:last-child { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.item-cell b, .item-cell .name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-cell a.name:hover { color: var(--brand-text); }
.item-cell small { font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-thumb { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-3); border: 1px solid var(--border); color: var(--muted-2); }
.item-thumb svg { width: 18px; height: 18px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--dot, var(--muted-2)); margin-inline-end: .35rem; }
.drag-handle { color: var(--muted-2); cursor: grab; display: inline-grid; }

/* نموذج الإدخال: عمود رئيسي وعمود جانبي وشريط حفظ ثابت */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.form-layout > * { min-width: 0; }
.form-layout .card { margin: 0 0 1rem; }
.form-narrow { max-width: 760px; margin-inline: auto; }
.section-head { padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); }
.section-head h2 { margin: 0; font-size: .95rem; font-weight: 700; }
.section-head p { margin: .1rem 0 0; font-size: .77rem; color: var(--muted); }
.switch-list { display: flex; flex-direction: column; gap: .7rem; }
.savebar { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .25rem -1.25rem -1.25rem; padding: .7rem 1.25rem; background: var(--surface); border-top: 1px solid var(--border); }
.savebar-hint { color: var(--muted); font-size: .78rem; margin-inline-start: auto; }

/* رفع صورة بمعاينة داخلية */
.upload-drop { position: relative; display: grid; place-items: center; gap: .3rem; min-height: 150px; padding: 1rem; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); color: var(--muted); cursor: pointer; overflow: hidden; transition: border-color .12s, background .12s; font-weight: 500; }
.upload-drop:hover { border-color: var(--brand); background: var(--brand-soft); }
.upload-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-drop svg { width: 24px; height: 24px; color: var(--muted-2); }
.upload-drop img { width: 100%; max-height: 190px; object-fit: contain; border-radius: var(--radius-sm); }
.upload-drop img.hidden { display: none; }
.upload-drop img:not(.hidden) ~ .upload-empty { display: none; }
.upload-empty { display: grid; justify-items: center; gap: .25rem; font-size: .8rem; }

/* معرض الصور */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: .6rem; }
.gallery-item { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.gallery-item img { display: block; width: 100%; height: 92px; object-fit: cover; }
.gallery-item .actions { padding: .25rem; justify-content: space-between; }

/* شبكة المنتجات */
.product-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.product-card:hover { box-shadow: var(--shadow-sm); transform: none; border-color: var(--border-strong); }
.product-img { height: 132px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.product-img .no-img { color: var(--muted-2); width: 34px; height: 34px; }
.product-body { padding: .65rem .8rem; }
.product-name { font-weight: 600; }
.product-cat { color: var(--muted); font-size: .74rem; }
.product-price { color: var(--text); font-weight: 700; font-size: .95rem; }
.product-foot { padding: .35rem .5rem; }
.offer-flag { background: var(--red); border-radius: 5px; }
.flag-off { background: var(--gray); inset-inline-start: auto; inset-inline-end: .5rem; }

/* رقائق قابلة للحذف (الباركود) */
.erp-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.erp-x { background: none; border: 0; padding: 0 .15rem; color: var(--muted); cursor: pointer; font: inherit; font-size: 1rem; line-height: 1; }
.erp-x:hover { color: var(--red); }

/* قائمة مفتاح/قيمة */
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .45rem 1rem; margin: 0; font-size: .85rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: end; font-weight: 600; }

/* ---------------- القوائم الكبيرة ---------------- */
.toolbar-date { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--muted); font-weight: 500; }
.toolbar-date input { width: 142px; }
.col-menu { position: relative; }
.col-menu > summary { list-style: none; }
.col-menu > summary::-webkit-details-marker { display: none; }
.col-option { display: flex; align-items: center; gap: .5rem; padding: .35rem .6rem; border-radius: 6px; font-size: .82rem; font-weight: 500; cursor: pointer; white-space: nowrap; }
.col-option:hover { background: var(--surface-3); }

.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .55rem 1.1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filter-chips[hidden] { display: none; }
.filter-chip { display: inline-flex; align-items: center; gap: .35rem; height: 26px; padding: 0 .55rem; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text); font: 600 .75rem var(--font); cursor: pointer; animation: chipIn .14s var(--ease); }
.filter-chip small { color: var(--muted); font-weight: 500; font-size: .7rem; }
.filter-chip i { font-style: normal; color: var(--muted); font-size: .95rem; line-height: 1; }
.filter-chip:hover { border-color: var(--red); }
.filter-chip:hover i { color: var(--red); }
.filter-clear { background: none; border: 0; padding: 0 .3rem; color: var(--brand-text); font: 600 .75rem var(--font); cursor: pointer; }
@keyframes chipIn { from { opacity: 0; transform: scale(.94); } }

.th-sort { display: inline-flex; align-items: center; gap: .3rem; color: inherit; }
.th-sort:hover { color: var(--text); }
.th-sort i { width: 0; height: 0; border-inline: 4px solid transparent; border-bottom: 5px solid currentColor; opacity: .25; transition: transform .14s var(--ease), opacity .14s; }
.th-sort:hover i { opacity: .55; }
.th-sort.is-on { color: var(--text); }
.th-sort.is-on i { opacity: 1; color: var(--brand-text); }
.th-sort.is-desc i { transform: rotate(180deg); }
table.table th.num .th-sort { flex-direction: row-reverse; }

.pager { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; padding: .6rem 1.1rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-foot .pager { padding: 0; border: 0; background: none; flex: 1; }
.pager .pagination { padding: 0; margin-inline-start: auto; justify-content: flex-end; }
.pager-info { color: var(--muted); font-size: .79rem; }
.pager-info b { color: var(--text); font-weight: 600; }
.pager-note { margin-inline-start: .5rem; color: var(--amber); }
.pager-size { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 500; color: var(--muted); }
.pager-size select { width: 70px; min-height: 30px; padding-block: 0; font-size: .78rem; }
.pagination a, .pagination span { min-width: 30px; height: 30px; display: inline-grid; place-items: center; padding: 0 .4rem; font-size: .78rem; font-variant-numeric: tabular-nums; }

/* حالة التحميل: تعتيم خفيف وشريط متحرك بلا إعادة رسم الجدول */
#main-content { position: relative; }
#main-content[aria-busy] .table-wrap, #main-content[aria-busy] .grid-cards { opacity: .55; transition: opacity .12s; }
#main-content[aria-busy]::before { content: ""; position: absolute; inset: 0 0 auto; z-index: 30; height: 2px; background: var(--brand); transform-origin: right; animation: listLoad 1s var(--ease) infinite; }
@keyframes listLoad { 0% { transform: scaleX(0); } 60% { transform: scaleX(.8); } 100% { transform: scaleX(1); opacity: 0; } }

/* الكثافة والتحديد */
:root[data-density="compact"] table.table tbody td { padding-block: .28rem; font-size: .8rem; }
:root[data-density="compact"] table.table thead th { padding-block: .4rem; }
:root[data-density="compact"] .item-thumb { width: 28px; height: 28px; }
:root[data-density="compact"] .item-cell small { display: none; }
:root[data-density="compact"] .btn-sm.btn-icon { min-height: 26px; width: 26px; }
table.table tbody tr.is-selected { background: var(--brand-soft); }
table.table tbody tr.is-cursor { box-shadow: inset 2px 0 0 var(--brand), inset -2px 0 0 var(--brand); background: var(--surface-2); }
.th-check, .td-check { width: 34px; padding-inline-end: 0 !important; }
.table mark, .palette mark { background: color-mix(in srgb, var(--amber) 26%, transparent); color: inherit; border-radius: 3px; padding-inline: 1px; }

.meter { display: inline-block; width: 56px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; vertical-align: middle; }
.meter i { display: block; width: var(--v, 0); height: 100%; background: var(--brand); margin-inline-start: 0; transition: width .3s var(--ease); }
.meter.is-low i { background: var(--red); }
.meter-wide { display: block; width: 100%; height: 6px; border-radius: 3px; }

/* شريط الإجراء الجماعي */
.bulkbar { position: sticky; bottom: 0; z-index: 25; display: none; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .55rem 1.1rem; background: var(--ink-2); color: #fff; border-radius: 0 0 var(--radius) var(--radius); }
.bulkbar.is-open { display: flex; animation: barIn .16s var(--ease); }
.bulkbar select { width: auto; min-width: 150px; color: var(--text); }
.bulkbar .bulk-count { font-weight: 700; font-size: .85rem; margin-inline-end: .4rem; }
.bulkbar .btn-ghost { color: #d9dde6; }
.bulkbar .btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }
@keyframes barIn { from { opacity: 0; transform: translateY(8px); } }

/* فهرس أقسام النماذج */
.section-nav { position: sticky; top: calc(var(--topbar-h) + .75rem); z-index: 5; display: flex; flex-direction: column; padding: .4rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.section-nav a { padding: .3rem .6rem; border-radius: 6px; color: var(--muted); font-size: .8rem; font-weight: 500; border-inline-start: 2px solid transparent; transition: color .12s, background .12s; }
.section-nav a:hover { color: var(--text); background: var(--surface-3); }
.section-nav a.is-on { color: var(--brand-text); background: var(--brand-soft); font-weight: 650; }
html { scroll-padding-top: calc(var(--topbar-h) + 1rem); }

/* قائمة بحث عن بُعد */
.remote-select { position: relative; }
.remote-select > input { width: 100%; }
.remote-native { position: absolute; inset-inline-start: 0; bottom: 0; width: 1px !important; height: 1px; min-height: 0 !important; padding: 0 !important; opacity: 0; pointer-events: none; }
.remote-list { position: absolute; inset: calc(100% + 4px) 0 auto; z-index: 60; max-height: 280px; overflow-y: auto; padding: .25rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-lg); }
.remote-list button { display: flex; flex-direction: column; width: 100%; padding: .4rem .55rem; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; text-align: start; cursor: pointer; line-height: 1.35; }
.remote-list button b { font-weight: 600; font-size: .85rem; }
.remote-list button small { color: var(--muted); font-size: .73rem; }
.remote-list button.is-on, .remote-list button:hover { background: var(--brand-soft); }
.remote-empty { padding: .7rem; text-align: center; color: var(--muted); font-size: .8rem; }

/* البحث الشامل */
.palette-backdrop { align-items: flex-start; padding-top: 11vh; }
.palette { max-width: 620px; width: 100%; padding: 0; overflow: hidden; }
.palette-head { display: flex; align-items: center; gap: .6rem; padding: .35rem 1rem; border-bottom: 1px solid var(--border); }
.palette-head svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.palette-head input { flex: 1; min-width: 0; border: 0 !important; box-shadow: none !important; background: transparent; font-size: .98rem; min-height: 46px; padding-inline: 0; }
.palette-status { color: var(--muted); font-size: .74rem; white-space: nowrap; }
.palette-list { max-height: 54vh; overflow-y: auto; padding: .3rem .4rem .5rem; scrollbar-width: thin; }
.palette-group { padding: .55rem .6rem .25rem; color: var(--muted); font-size: .72rem; font-weight: 700; }
.palette-list a { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .42rem .6rem; border-radius: 7px; color: var(--text); }
.palette-list a.is-on { background: var(--brand-soft); }
.palette-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.palette-text b { font-weight: 600; font-size: .87rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-text small { color: var(--muted); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-badge { color: var(--muted); font-size: .78rem; flex: none; }
.palette-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: .85rem; }
.palette-foot { display: flex; gap: 1rem; padding: .45rem 1rem; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: .72rem; }
.palette-foot kbd { font: 600 .66rem var(--font); padding: .02rem .3rem; margin-inline-end: .15rem; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); }

/* شارات الحالة بنقطة دلالية */
.badge-green::before, .badge-red::before, .badge-amber::before, .badge-blue::before, .badge-gray::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-inline-end: .3rem; border-radius: 50%; background: currentColor; vertical-align: middle; }

/* ---------------- الحركة: تحويل وشفافية فقط (لا تعيد تخطيط الصفحة) ---------------- */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: app-sidebar; }
.topbar { view-transition-name: app-topbar; }
.content { view-transition-name: app-content; }
::view-transition-group(app-sidebar), ::view-transition-group(app-topbar) { animation: none; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(app-content) { animation: pageOut .09s linear both; }
::view-transition-new(app-content) { animation: pageIn .16s var(--ease) both; }
@keyframes pageOut { to { opacity: 0; } }
@keyframes pageIn { from { opacity: 0; transform: translateY(4px); } }
.btn:active, .tb-btn:active { transform: scale(.98); }
.nav-link { transition: background .12s, color .12s, transform .12s var(--ease); }
.modal-backdrop.open { animation: fadeIn .12s linear; }
@keyframes fadeIn { from { opacity: 0; } }
.erp-menu[open] > .erp-menu-pop { transform-origin: top; }
.card, .stat, .erp-kpi { transition: border-color .12s; }
.alert { animation: alertIn .18s var(--ease); }
@keyframes alertIn { from { opacity: 0; transform: translateY(-4px); } }
/* لا يُرسم ما هو خارج الشاشة حتى يقترب منها */
.erp-space, .product-card { content-visibility: auto; contain-intrinsic-size: auto 260px; }

/* أجهزة ضعيفة (lists.js): بلا حركات إطلاقاً */
html[data-lite] *, html[data-lite] *::before, html[data-lite] *::after { animation: none !important; transition: none !important; }
html[data-lite] ::view-transition-group(*), html[data-lite] ::view-transition-old(*), html[data-lite] ::view-transition-new(*) { animation: none !important; }

/* ---------------- لوحات القيادة ---------------- */
.dash-greet { display: flex; align-items: center; justify-content: space-between; gap: .8rem 1.2rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dash-greet h2 { margin: 0; font-size: 1.2rem; font-weight: 700; }
.dash-greet p { margin: .1rem 0 0; color: var(--muted); font-size: .82rem; }
.dash-greet-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

/* شبكة اللوحة: عمود رئيسي وعمود جانبي للرسوم */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 1rem; align-items: start; margin-bottom: 1rem; }
.dash-main, .dash-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.dash-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.dash-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.dash-minis { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.dash-main .card, .dash-side .card { margin: 0; }

.hero-kpi { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 148px; padding: 1.05rem 1.2rem; border-radius: var(--radius); overflow: hidden; color: #fff; isolation: isolate; transition: transform .18s var(--ease); }
a.hero-kpi:hover { transform: translateY(-2px); color: #fff; }
.hero-kpi.tone-a { background: var(--grad-a); }
.hero-kpi.tone-b { background: var(--grad-b); }
.hero-kpi::before, .hero-kpi::after { content: ""; position: absolute; z-index: -1; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.hero-kpi::before { width: 130px; height: 130px; inset-inline-end: -44px; bottom: -52px; }
.hero-kpi::after { width: 76px; height: 76px; inset-inline-start: 22%; top: -40px; }
.hero-kpi-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.hero-kpi-label { font-size: .88rem; font-weight: 600; opacity: .95; }
.hero-kpi-ico { width: 20px; height: 20px; opacity: .85; flex: none; }
.hero-kpi-val { margin-top: .5rem; font-size: clamp(1.55rem, 2.3vw, 2.15rem); font-weight: 700; line-height: 1.15; letter-spacing: -.01em; overflow-wrap: anywhere; }
.hero-kpi-val small { margin-inline-start: .35rem; font-size: .82rem; font-weight: 500; opacity: .85; letter-spacing: 0; }
.hero-kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .45rem; font-size: .76rem; opacity: .95; }
.hero-delta { padding: .02rem .5rem; border-radius: 999px; background: rgba(255, 255, 255, .22); font-weight: 700; font-size: .72rem; }

.mini-stat { display: flex; align-items: center; gap: .7rem; flex: 1; min-height: 66px; padding: .55rem .85rem; border-radius: var(--radius); background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .14s; }
a.mini-stat:hover { border-color: var(--border-strong); color: var(--text); }
.mini-stat-ico { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; color: #fff; }
.mini-stat-ico.tone-a { background: var(--grad-a); }
.mini-stat-ico.tone-b { background: var(--grad-b); }
.mini-stat-ico.tone-c { background: linear-gradient(120deg, #fbc24a, #e8892b); }
.mini-stat-ico.tone-d { background: linear-gradient(120deg, #ff7d92, #d0343f); }
.mini-stat-ico svg { width: 18px; height: 18px; }
.mini-stat-body { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.mini-stat-body small { color: var(--muted); font-size: .76rem; }
.mini-stat-body b { font-size: 1.02rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-pill { flex: none; padding: .05rem .5rem; border-radius: 7px; font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-pill.is-up, .mini-pill.is-green { background: var(--green-bg); color: var(--green); }
.mini-pill.is-down, .mini-pill.is-red { background: var(--red-bg); color: var(--red); }
.mini-pill.is-amber { background: var(--amber-bg); color: var(--amber); }
.mini-pill.is-gray { background: var(--surface-3); color: var(--text-2); }

.chart-card { padding: 1rem 1.15rem 1.05rem; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: .55rem; }
.chart-head h3 { margin: 0; font-size: .95rem; font-weight: 700; }
.chart-head p { margin: .05rem 0 0; color: var(--muted); font-size: .75rem; }
.chart-keys { display: flex; align-items: center; flex-wrap: wrap; gap: .85rem; color: var(--muted); font-size: .76rem; }
.chart-keys span { display: inline-flex; align-items: center; gap: .4rem; }
.chart-keys i { width: 22px; height: 0; border-top: 2px solid var(--chart-1); }
.chart-keys i.k2 { border-top: 2px dotted var(--chart-2); }
.chart-host { position: relative; min-width: 0; direction: ltr; }
.chart-host svg { display: block; max-width: 100%; }
.chart-axis { fill: var(--muted); font-size: 10.5px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-pct { fill: #fff; font-size: 11px; font-weight: 700; font-family: var(--font); }
.chart-center-label { fill: var(--muted); font-size: 11.5px; font-family: var(--font); direction: rtl; }
.chart-center-value { fill: var(--text); font-size: 15px; font-weight: 700; font-family: var(--font); }
.chart-tip { position: absolute; z-index: 5; display: flex; flex-direction: column; gap: .05rem; padding: .3rem .55rem; border-radius: 7px; background: var(--grad-a); color: #fff; font-size: .72rem; white-space: nowrap; pointer-events: none; direction: rtl; transition: left .1s linear, top .1s linear; }
.chart-tip[hidden] { display: none; }
.chart-tip b { font-weight: 700; }
.chart-tip span { display: flex; align-items: center; gap: .3rem; }
.chart-tip i { width: 7px; height: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, .6); }
.chart-tip em { font-style: normal; font-weight: 700; margin-inline-start: auto; padding-inline-start: .6rem; }
.chart-bar-rect { transform-box: fill-box; transform-origin: bottom; animation: barGrow .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes barGrow { from { transform: scaleY(0); } }
.chart-fill { animation: fadeIn .6s linear both; }
.chart-round { display: flex; align-items: center; justify-content: space-around; gap: 1rem; flex-wrap: wrap; }
.chart-round .chart-host { flex: none; }
.chart-legend { display: flex; flex-direction: column; gap: .6rem; min-width: 110px; }
.chart-legend-row { display: flex; align-items: center; gap: .55rem; }
.chart-legend-row i { width: 15px; height: 15px; flex: none; border: 3px solid; border-radius: 50%; }
.chart-legend-row span { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.chart-legend-row b { font-size: .8rem; font-weight: 600; }
.chart-legend-row small { color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; }
.chart-link { display: flex; align-items: center; justify-content: space-between; margin-top: .7rem; padding: .55rem .8rem; border-radius: 9px; background: var(--surface-2); color: var(--text-2); font-size: .8rem; font-weight: 600; }
.chart-link:hover { background: var(--surface-3); color: var(--text); }
.chart-link svg { width: 15px; height: 15px; color: var(--brand-text); }
.pipe-chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.pipe-chips span { padding: .08rem .5rem; border-radius: 7px; font-size: .72rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.pipe-chips b { font-weight: 700; }

/* مركز التقارير */
.report-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.report-group { margin: 0 !important; padding-bottom: .4rem; }
.report-group[hidden], .report-link[hidden] { display: none; }
.report-group-head { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem .6rem; }
.report-group-head h3 { margin: 0; flex: 1; font-size: .95rem; font-weight: 700; }
.report-group-head small { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.report-link { display: flex; align-items: flex-start; gap: .6rem; padding: .5rem 1rem; color: var(--text); transition: background .12s; }
.report-link:hover { background: var(--surface-2); color: var(--text); }
.report-link svg { width: 17px; height: 17px; margin-top: .15rem; color: var(--brand-text); flex: none; }
.report-link span { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.report-link b { font-size: .86rem; font-weight: 600; }
.report-link small { color: var(--muted); font-size: .74rem; }

/* سجل المتابعة */
.timeline { padding: .6rem 1.1rem 1rem; }
.timeline-item { position: relative; display: flex; gap: .7rem; padding-bottom: 1rem; }
.timeline-item:not(:last-child)::before { content: ""; position: absolute; inset-inline-start: 5px; top: 14px; bottom: 0; width: 1px; background: var(--border-strong); }
.timeline-dot { width: 11px; height: 11px; margin-top: .3rem; flex: none; border-radius: 50%; background: var(--muted-2); }
.timeline-dot.is-green { background: var(--green); } .timeline-dot.is-amber { background: var(--amber); } .timeline-dot.is-red { background: var(--red); }
.timeline-body { flex: 1; min-width: 0; }
.timeline-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .86rem; }
.tab-count { margin-inline-start: .35rem; padding: 0 .4rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: .68rem; font-variant-numeric: tabular-nums; }

/* حقول الأرقام الحسابية */
.calc-input { direction: ltr; text-align: end; font-variant-numeric: tabular-nums; }
html[dir="rtl"] .calc-input { text-align: right; }
input.calc-error, input.calc-error:focus { border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 22%, transparent); }
.calc-shake { animation: calcShake .22s var(--ease); }
@keyframes calcShake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.calc-chip { position: fixed; z-index: 600; display: inline-flex; align-items: center; gap: .4rem; padding: .22rem .6rem; border-radius: 8px; background: var(--grad-a); color: #fff; font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; pointer-events: none; box-shadow: var(--shadow); }
.calc-chip[hidden] { display: none; }
.calc-chip.is-error { background: var(--red); color: #fff; direction: rtl; font-weight: 600; }
.calc-chip-text:empty { display: none; }
.calc-keys { display: inline-flex; gap: .2rem; pointer-events: auto; }
.calc-keys button { min-width: 34px; height: 34px; border: 0; border-radius: 7px; background: rgba(255, 255, 255, .2); color: #fff; font: 700 1rem var(--font); }
.calc-keys button.is-eq { background: #fff; color: var(--ink); }

/* منتقي اللوحات الرسمية في إعدادات الهوية */
.palette-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem; margin-top: .5rem; }
.palette-swatch { display: flex; align-items: center; gap: .5rem; padding: .4rem .55rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 600 .78rem var(--font); cursor: pointer; transition: border-color .12s; }
.palette-swatch i { width: 20px; height: 20px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.palette-swatch:hover { border-color: var(--brand); }
.palette-swatch.is-on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }

/* ---------------- ERP ونقطة البيع ---------------- */
.erp-tile { padding: 1rem; }
.erp-tile .ico { background: var(--brand-soft); color: var(--brand-text); border-radius: 9px; }
.erp-tile:hover { border-color: var(--border-strong); }
.erp-step .ico { border-radius: 8px; }

.pos-left, .pos-right { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.pos-search { padding: .8rem 1rem; background: var(--surface-2); }
.pos-search input { font-size: 1.05rem; min-height: 0; border: 0; box-shadow: none !important; background: transparent; }
.pos-kbd { background: var(--surface-3); border-color: var(--border-strong); }
.pos-grid { gap: .6rem; padding: .85rem; }
.pos-item { min-height: 92px; padding: .75rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); box-shadow: none; transition: border-color .1s, background .1s; touch-action: manipulation; }
.pos-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.pos-item:active { background: var(--brand-light); }
.pos-item b { font-size: .86rem; color: var(--text); }
.pos-item span { font-size: 1rem; }
.pos-line { border-bottom-color: var(--border); }
.pos-line .qty button { min-width: 34px; height: 36px; border-radius: 7px; background: var(--surface-3); border-color: var(--border); color: var(--text); transition: background .1s; touch-action: manipulation; }
.pos-line .qty button:active { background: var(--brand-soft); }
.pos-totals { background: var(--surface-2); border-top: 1px solid var(--border); }
.pos-totals .grand b { color: var(--brand-text); letter-spacing: -.02em; }
.pos-actions .btn-lg { min-height: 52px; border-radius: 10px; font-size: 1.05rem; }

/* ---------------- صفحة الدخول ---------------- */
.auth-shell { background: var(--surface); }
.auth-brand { background: var(--ink-2); }
.auth-brand::before, .auth-brand::after { display: none; }
.auth-panel { background: var(--bg); }
.auth-title { letter-spacing: -.01em; }
.auth-submit { background: var(--brand); border-radius: var(--radius-sm); box-shadow: none; }
.auth-submit:hover { background: var(--brand-dark); }
.auth-feature .ico { background: rgba(255, 255, 255, .1); border-radius: 9px; }
.auth-field .auth-input input { height: 46px; padding-inline-start: 2.7rem; padding-inline-end: .95rem; border-radius: var(--radius-sm); background-color: var(--surface-input); }
.auth-field .auth-input.has-toggle input { padding-inline-end: 3rem; }
.auth-field .auth-input input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); background-color: var(--surface-input); }
.auth-field > label { color: var(--text-2); }
.auth-demo, .auth-demo-item { background: var(--surface); border-color: var(--border); }

/* ---------------- أقسام لوحتي الإدارة ---------------- */
.erp-dashboard-hero { margin-bottom: 1rem; padding: 1.2rem 1.4rem; }
.admin-dashboard-hero { margin-bottom: 1rem; padding: 1rem 1.25rem; }
.admin-dashboard-hero .dash-hero-content { gap: .75rem 1.25rem; }
.admin-dashboard-hero .dash-hero-title { min-width: 0; }
.admin-dashboard-hero .dash-hero-title h1 { gap: .55rem; font-size: 1.2rem; }
.admin-dashboard-hero .dash-hero-title h1 > svg { width: 22px; height: 22px; flex: 0 0 22px; }
.admin-dashboard-hero .dash-hero-title p { font-size: .8rem; }
.erp-dashboard-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1.4rem; }
.erp-dashboard-stats .stat { display: flex; align-items: center; gap: .8rem; min-width: 0; }
.erp-dashboard-stats .stat-body { min-width: 0; }
.erp-dashboard-stats .stat-value { font-size: 1.45rem; line-height: 1.25; }
.erp-dashboard-section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: .25rem 0 .85rem; }
.erp-dashboard-section-head h2 { margin: 0; font-size: 1rem; }
.erp-dashboard-section-head p { margin: .15rem 0 0; color: var(--muted); font-size: .82rem; }

/* حاويات الشبكات: لا تتمدد بمحتوى أعرض منها */
.studio-layout > *, .invoice-builder > *, .dash-cols > *, .pos > * { min-width: 0; }

/* ---------------- الاستجابة ---------------- */
@media (max-width: 1280px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .dash-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dash-minis { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .dash-minis .mini-stat { flex: 1 1 200px; }
  .form-layout { grid-template-columns: minmax(0, 1fr); }
  .section-nav { display: none; }
}
@media (max-width: 900px) {
  .menu-toggle { display: inline-grid; }
  .rail-toggle, .tb-search kbd, .tb-search span { display: none; }
  .tb-search { min-width: 0; width: 36px; padding: 0; justify-content: center; }
  .content { padding: 1rem; }
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; row-gap: .4rem; padding: .55rem .9rem; gap: .5rem; }
  .topbar h1 { min-width: 0; flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { display: contents; }
  .tb-tools { margin-inline-start: auto; order: 2; }
  .tb-page-actions { order: 3; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .tb-page-actions .btn { flex: none; white-space: nowrap; }
  .sidebar.open { box-shadow: var(--shadow-lg); }
  .backdrop { background: rgba(14, 17, 23, .45); }
  .card-head, .section-head, .toolbar { padding: .75rem .95rem; }
  .card-body { padding: .95rem; }
  :root { --control-h: 42px; }
  .btn-sm { min-height: 36px; }
  .btn-sm.btn-icon { width: 36px; }
  .tb-btn { min-height: 40px; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; width: 100%; max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; animation: sheetIn .22s var(--ease); }
  @keyframes sheetIn { from { transform: translateY(100%); } }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .savebar { margin: .25rem -1rem -1rem; padding: .65rem 1rem; }
  .savebar .btn-primary { flex: 1; }
  .savebar-hint { display: none; }
  .grid > * { min-width: 0; }
  .grid > .span-2, .grid > .span-3, .grid > [style*="grid-column:span"] { grid-column: 1 / -1 !important; }
  .grid-3, .grid-4, .grid-5 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
  .invoice-builder { grid-template-columns: 1fr; }
  .pos { min-height: 0; }
  .pos-left { max-height: 52vh; }
  .pos-totals { position: sticky; bottom: 0; z-index: 5; }
  .erp-dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .erp-dashboard-section-head { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
  .topbar-actions { display: contents; overflow: visible; flex: none; }
  .topbar h1 { flex: 1 1 0; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .pager { gap: .5rem; }
  .pager .pagination { margin-inline-start: 0; width: 100%; justify-content: center; }
  .pager-note, .toolbar-count { display: none; }
  .grid-3:has(> .stat), .grid-4:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .stat { padding: .7rem; gap: .55rem; }
  .stat .stat-icon { display: none; }
  .stat .stat-value { font-size: 1.1rem; overflow-wrap: anywhere; }
  table.table td:has(> .cell-media), table.table td:has(> .item-cell) { min-width: 11rem; }
  .toolbar-date { flex: 1 1 calc(50% - .25rem); }
  .toolbar-date input { flex: 1; width: 100%; min-width: 0; }
  .dash-side, .dash-pair { grid-template-columns: minmax(0, 1fr); }
  .hero-kpi { min-height: 120px; padding: .85rem .95rem; }
  .toolbar .search-box { flex: 1 1 100%; max-width: none; }
  .toolbar select { flex: 1 1 calc(50% - .25rem); min-width: 0; }
  .erp-dashboard-stats { gap: .55rem; }
  .erp-dashboard-stats .stat { padding: .75rem; gap: .55rem; }
  .erp-dashboard-stats .stat-icon { width: 34px; height: 34px; }
  .erp-dashboard-stats .stat-value { font-size: 1.2rem; }
  .erp-dashboard-hero, .admin-dashboard-hero { padding: 1rem; }
  .admin-dashboard-hero .dash-hero-title h1 { font-size: 1.08rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
@media print { body { background: #fff !important; } .sidebar, .topbar, #nav-progress, .backdrop { display: none !important; } .main { margin: 0 !important; } }

/* >>> fallback-begin (مُولَّد: لا تعدّل يدوياً) */
@supports not (color: color-mix(in srgb, red, blue)) {
  :root { --green-rgb:15,154,104; --red-rgb:220,60,70; --amber-rgb:194,122,5; --blue-rgb:42,109,240; --olive-rgb:111,132,32; --gray-rgb:75,85,103; }
  :root {
  --brand: #7463db;
  --brand-dark: var(--brand-dark-fb);
  --brand-bright: var(--brand-bright-fb);
  --brand-text: var(--brand);
  --brand-soft: rgba(var(--brand-rgb),0.1);
  --brand-light: rgba(var(--brand-rgb),0.2);
  --brand-ring: rgba(var(--brand-rgb),0.26);
  --magenta: var(--brand);
  --cyan: #19d9d3;
  --grad-a: linear-gradient(120deg, var(--magenta), var(--brand-bright) 55%, var(--brand));
  --grad-b: linear-gradient(120deg, var(--cyan), #3f8ff0);
  --grad-nav: linear-gradient(270deg, rgba(var(--brand-rgb),0.52), rgba(var(--brand-rgb),0.14));
  --chart-1: var(--brand);
  --chart-2: #19c9d9;
  --chart-3: #3f8ff0;
  --chart-4: #9b6cf5;
  --chart-5: #f0b429;
  --chart-grid: #e6e8f0;

  --bg: #f3f4f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef0f6;
  --surface-input: #ffffff;
  --border: #e3e6ef;
  --border-strong: #cfd4e1;
  --text: #151a2e;
  --text-2: #3d4560;
  --muted: #5f6880;
  --muted-2: #767f96;

  --green: #0d8a5e;  --green-bg: rgba(var(--green-rgb),0.11);
  --red: #d0343f;    --red-bg: rgba(var(--red-rgb),0.1);
  --amber: #b06f04;  --amber-bg: rgba(var(--amber-rgb),0.12);
  --blue: #2563d8;   --blue-bg: rgba(var(--blue-rgb),0.1);
  --olive: #66791d;  --olive-bg: rgba(var(--olive-rgb),0.12);
  --gray: #4b5567;   --gray-bg: rgba(var(--gray-rgb),0.09);
  --teal: var(--brand); --teal-bg: var(--brand-soft);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 46, .05);
  --shadow: 0 6px 20px rgba(20, 24, 46, .08);
  --shadow-lg: 0 20px 56px rgba(10, 13, 30, .32);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --control-h: 38px;

  
  --sb-bg: #151a31;
  --sb-bg-2: #1a2039;
  --sb-line: rgba(255, 255, 255, .07);
  --sb-text: #c3c8dd;
  --sb-strong: #ffffff;
  --sb-muted: #7f87a6;
  --sb-accent: var(--brand);

  --sidebar-w: 268px;
  --topbar-h: 62px;
  --ink: #0e1224;
  --ink-2: #171c33;
  --font: "IBM Plex Sans Arabic", "SF Arabic", "Segoe UI Variable Text", "Segoe UI", "Noto Sans Arabic", "Noto Kufi Arabic", Tahoma, system-ui, sans-serif;
  color-scheme: light;
}
  :root[data-theme="dark"] {
  --bg: #10142a; --surface: #181d37; --surface-2: #1d2340; --surface-3: #252c4d; --surface-input: #141932;
  --border: #272e4f; --border-strong: #38406a;
  --text: #edeffa; --text-2: #c3c8dd; --muted: #98a0bd; --muted-2: #7f87a6;
  --green: #34d9a0; --red: #ff7d92; --amber: #fbc24a; --blue: #6fa8ff; --olive: #b4c85a; --gray: #aab4cc;
  --brand-text: var(--brand-bright-fb);
  --brand-soft: rgba(var(--brand-rgb),0.2);
  --brand-light: rgba(var(--brand-rgb),0.34);
  --chart-grid: rgba(255, 255, 255, .08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow: 0 8px 26px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
  --ink: #0a0d1c; --ink-2: #141932;
  color-scheme: dark;
}
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
    --bg: #10142a; --surface: #181d37; --surface-2: #1d2340; --surface-3: #252c4d; --surface-input: #141932;
    --border: #272e4f; --border-strong: #38406a;
    --text: #edeffa; --text-2: #c3c8dd; --muted: #98a0bd; --muted-2: #7f87a6;
    --green: #34d9a0; --red: #ff7d92; --amber: #fbc24a; --blue: #6fa8ff; --olive: #b4c85a; --gray: #aab4cc;
    --brand-text: var(--brand-bright-fb);
    --brand-soft: rgba(var(--brand-rgb),0.2);
    --brand-light: rgba(var(--brand-rgb),0.34);
    --chart-grid: rgba(255, 255, 255, .08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow: 0 8px 26px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
    --ink: #0a0d1c; --ink-2: #141932;
    color-scheme: dark;
  } }
  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
  .sb-kpi.red { border-color: var(--red); }
  .sb-kpi.amber { border-color: var(--amber); }
  .sb-kpi.green { border-color: var(--green); }
  .dash-alert-item.warn { background: var(--amber-bg); border-color: rgba(var(--amber-rgb),0.3); color: var(--amber); }
  .dash-alert-item.danger { background: var(--red-bg); border-color: rgba(var(--red-rgb),0.3); color: var(--red); }
  .dash-alert-item.info { background: var(--blue-bg); border-color: rgba(var(--blue-rgb),0.3); color: var(--blue); }
  .btn-success:hover { background: var(--green); border-color: transparent; color: #fff; }
  .btn-danger:hover { background: var(--red); border-color: transparent; color: #fff; }
  .alert-success { background: var(--green-bg); color: var(--green); border-color: rgba(var(--green-rgb),0.26); }
  .alert-danger { background: var(--red-bg); color: var(--red); border-color: rgba(var(--red-rgb),0.26); }
  .alert-warning { background: var(--amber-bg); color: var(--amber); border-color: rgba(var(--amber-rgb),0.28); }
  .alert-info { background: var(--blue-bg); color: var(--blue); border-color: rgba(var(--blue-rgb),0.26); }
  .table mark, .palette mark { background: rgba(var(--amber-rgb),0.26); color: inherit; border-radius: 3px; padding-inline: 1px; }
  .mini-stat { display: flex; align-items: center; gap: .7rem; flex: 1; min-height: 66px; padding: .55rem .85rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .14s; }
  input.calc-error, input.calc-error:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(var(--red-rgb),0.22); }
}
/* <<< fallback-end */
