/* =========================================================================
   VALID — نظام الإدارة
   هوية: Charcoal Ink (القايمة) + Alabaster (المحتوى) + لمسة شامبين خفيفة.
   أسلوب: Minimal / Swiss — مساحات واضحة، تباين عالي، حركة هادية.
   ========================================================================= */
/* خط Almarai (Boutros Fonts — رخصة OFL، الملف في fonts/OFL.txt) متخزن محليًا */
@font-face { font-family: "Almarai"; src: url("fonts/Almarai-Light.ttf") format("truetype"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Almarai"; src: url("fonts/Almarai-Regular.ttf") format("truetype"); font-weight: 400 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Almarai"; src: url("fonts/Almarai-Bold.ttf") format("truetype"); font-weight: 600 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Almarai"; src: url("fonts/Almarai-ExtraBold.ttf") format("truetype"); font-weight: 800 900; font-style: normal; font-display: swap; }

:root {
  /* الأسطح */
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f3f1ed;
  --surface-3: #ece9e3;
  /* الحبر */
  --ink: #141414;
  --ink-2: #44403c;
  --muted: #78716c;
  --line: #e7e4de;
  --line-strong: #d6d2ca;
  /* القايمة الجانبية */
  --side: #0f0f11;
  --side-2: #18181b;
  --side-ink: #e7e5e4;
  --side-muted: #8a8a91;
  --silver: #c9ccd1;
  /* لمسة البراند */
  --accent: #9a7b4f;          /* شامبين/برونز هادي */
  --accent-soft: #f5efe5;
  /* الحالات (ألوان هادية مش صارخة) */
  --good: #2f6b4f;  --good-bg: #edf5f0;  --good-line: #cfe3d7;
  --warn: #8a5a12;  --warn-bg: #fbf3e4;  --warn-line: #efdcb5;
  --bad: #a23b32;   --bad-bg: #fbeeec;   --bad-line: #f0cdc8;
  --info: #3b5b7a;  --info-bg: #eef3f8;  --info-line: #d0dde9;
  /* المقاسات */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 20, .04);
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 6px 24px -8px rgba(20, 20, 20, .08);
  --shadow-lg: 0 12px 40px -12px rgba(20, 20, 20, .18);
  --ring: 0 0 0 3px rgba(20, 20, 20, .14);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t: 180ms;
  --font: "Almarai", "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
  /* ألوان إضافية (بتتغير مع الوضع الداكن) */
  --on-ink: #ffffff;          /* الكلام فوق خلفية الحبر (الزراير الأساسية) */
  --ink-hover: #2a2a2e;
  --field: #ffffff;
  --field-hover: #bfb9ae;
  --placeholder: #b3ada3;
  --row-hover: #faf9f7;
  --glass: rgba(255, 255, 255, .7);
  --hero: #141416;            /* الكروت الغامقة (المبلغ الكبير) */
  --hero-ink: #ffffff;
  --hero-muted: #b8b5ae;
  --chart-bar: #2a2a2f;
  --logo-filter: none;
  color-scheme: light;
}

/* ============================================================ الوضع الداكن */
:root[data-theme="dark"] {
  --bg: #111113;
  --surface: #1a1a1d;
  --surface-2: #232327;
  --surface-3: #2c2c31;
  --ink: #ecebe8;
  --ink-2: #c9c6c0;
  --muted: #9a958e;
  --line: #2e2e33;
  --line-strong: #3d3d43;
  --accent: #c8a675;
  --accent-soft: #2a241b;
  --good: #6fbf95;  --good-bg: #16261e;  --good-line: #24432f;
  --warn: #e0b265;  --warn-bg: #2a2214;  --warn-line: #4a3a1c;
  --bad: #ef8a80;   --bad-bg: #2c1817;   --bad-line: #4d2522;
  --info: #8fb3d9;  --info-bg: #17212c;  --info-line: #26394d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px -8px rgba(0, 0, 0, .5);
  --shadow-lg: 0 12px 40px -12px rgba(0, 0, 0, .7);
  --ring: 0 0 0 3px rgba(236, 235, 232, .22);
  --on-ink: #141414;
  --ink-hover: #ffffff;
  --field: #141416;
  --field-hover: #55555c;
  --placeholder: #6b6760;
  --row-hover: #202024;
  --glass: rgba(255, 255, 255, .06);
  --hero: #26262b;
  --hero-ink: #f4f4f5;
  --hero-muted: #a8a49c;
  --chart-bar: #d6d3cd;
  color-scheme: dark;
}
:root[data-theme="dark"] .amount-hero.out { background: #3a2422; }
:root[data-theme="dark"] .amount-hero.back { background: #26303d; }
:root[data-theme="dark"] .kpi.hero { border-color: #34343a; }
.logo-on-dark { display: none !important; }
/* الخطوة الجاية للمنتج */
.next-step { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--accent); border-radius: var(--r-lg); padding: 14px 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.next-step.tone-good { border-inline-start-color: var(--good); } .next-step.tone-bad { border-inline-start-color: var(--bad); } .next-step.tone-warn { border-inline-start-color: var(--warn); }
.ns-track { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.ns-track span { font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.ns-track span.done { background: var(--good-bg); color: var(--good); }
.ns-track span.cur { background: var(--ink); color: var(--on-ink); }
.ns-body { display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.ns-tx { flex: 1 1 320px; min-width: 0; }
.ns-tx h3 { font-size: 1.12rem; margin: 2px 0 4px; }
.ns-tx p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.ns-links { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: .84rem; }
.ns-links a { color: var(--muted); }
.ns-act form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ns-act select, .ns-act input[type=date] { width: auto; min-width: 140px; }
.ns-act small { flex-basis: 100%; text-align: end; }
.danger-zone { border-color: var(--bad-line); margin-top: 22px; }
.danger-zone h2 { color: var(--bad); }
/* تسجيل الدخول والمستخدمين */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-box { width: 100%; max-width: 400px; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 18px; font-size: 1.6rem; }
.auth-brand img { height: 56px; width: auto; }
.auth-h { font-size: 1.25rem; display: flex; align-items: center; gap: 8px; margin: 0 0 16px; }
.icon-btn.user-btn { width: auto; padding: 0 10px; gap: 6px; display: inline-flex; align-items: center; font-size: .84rem; font-weight: 700; text-decoration: none; }
.bar-end form.inline { display: contents; }
button.icon-btn { background: none; cursor: pointer; }
.perm-table th.c, .perm-table td.c { text-align: center; width: 13%; }
.perm-table tr.perm-grp td { background: var(--surface-2); font-weight: 800; font-size: .8rem; color: var(--ink-2); padding-top: 8px; padding-bottom: 8px; }
.perm-pick { display: inline-grid; place-items: center; cursor: pointer; margin: 0; }
.perm-pick input { width: 18px; height: 18px; min-height: 0; accent-color: var(--ink); cursor: pointer; }
.perm-pick span { display: none; }
.perm-special { align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin: 0; }
.perm-special input { margin-top: 3px; }
.perm-special span { display: flex; flex-direction: column; gap: 2px; }
.cancel-list { margin: 0; padding-inline-start: 20px; line-height: 1.9; }
.cancel-list li + li { margin-top: 2px; }
/* دليل الاستخدام */
.guide-progress { min-width: 180px; text-align: center; }
.guide-progress b { font-size: 1.4rem; display: block; } .guide-progress small { color: var(--muted); }
.guide-progress .bar { height: 6px; background: var(--surface-3); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.guide-progress .bar i { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.guide-sec h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.guide-sec h2 small { font-weight: 400; font-size: .82rem; }
.g-num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--on-ink); font-size: .85rem; }
.guide-steps { list-style: none; margin: 0; padding: 0; }
.guide-steps > li { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.guide-steps > li:first-child { border-top: 0; }
.guide-steps > li.done .g-head b { color: var(--muted); }
.g-tx { min-width: 0; flex: 1; }
.g-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.g-where { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.g-tx ul { margin: 6px 0 0; padding-inline-start: 18px; color: var(--ink-2); font-size: .9rem; }
.g-act { flex: none; }
@media (max-width: 640px) { .guide-steps > li { flex-direction: column; gap: 8px; } }
:root[data-theme="dark"] .logo-on-light { display: none !important; }
:root[data-theme="dark"] .logo-on-dark { display: block !important; }
.theme-btn .ico-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ico-sun { display: inline; }
:root[data-theme="dark"] .theme-btn .ico-moon { display: none; }

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 3px; transition: color var(--t) var(--ease); }
a:hover { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.3; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .98rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .85em; }
.ico { flex: none; vertical-align: middle; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: plaintext; text-align: right; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* ============================================================ التخطيط: شريط علوي + 6 أقسام */
.app-top { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); }
.app-bar { display: flex; align-items: center; gap: 18px; height: 62px; padding: 0 28px; max-width: 1480px; margin: 0 auto; }
.brand { display: flex; align-items: center; flex: none; text-decoration: none; }
.brand img { height: 40px; width: auto; display: block; }
.brand span { font-weight: 800; letter-spacing: .35em; font-size: 1.1rem; }
.sections { display: flex; gap: 2px; background: var(--surface-2); padding: 4px; border-radius: 12px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.sections::-webkit-scrollbar { display: none; }
.sections a { display: flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 9px; text-decoration: none; font-weight: 700; font-size: .88rem; color: var(--ink-2); white-space: nowrap; transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.sections a .ico { color: var(--muted); }
.sections a:hover { color: var(--ink); background: var(--glass); }
.sections a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.sections a.on .ico { color: var(--ink); }
.bar-end { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.cmdk-btn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font: inherit; font-size: .84rem; cursor: pointer; transition: border-color var(--t) var(--ease); }
.cmdk-btn:hover { border-color: var(--line-strong); color: var(--ink-2); }
kbd { font-family: inherit; font-size: .7rem; background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--ink-2); direction: ltr; white-space: nowrap; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--ink-2); border: 1px solid transparent; }
.icon-btn:hover, .icon-btn.on { background: var(--surface-2); color: var(--ink); }
.subnav { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 70%, var(--bg)); }
.subnav .in { display: flex; gap: 4px; max-width: 1480px; margin: 0 auto; padding: 0 28px; overflow-x: auto; scrollbar-width: none; }
.subnav .in::-webkit-scrollbar { display: none; }
.subnav a { display: flex; align-items: center; gap: 6px; padding: 10px 12px; font-size: .86rem; font-weight: 700; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.subnav a:hover { color: var(--ink); }
.subnav a.on { color: var(--ink); border-color: var(--ink); }

main.page { max-width: 1320px; margin: 0 auto; padding: 26px 28px 64px; }
main.page.page-wide { max-width: 1480px; padding-top: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.eyebrow { display: block; font-size: .72rem; letter-spacing: .1em; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ============================================================ البطاقات */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: 14px; }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
.card .page-head { margin-bottom: 12px; align-items: center; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.grid.g2 + .grid, .grid + .card, .card + .grid { margin-top: 0; }
.grid { margin-bottom: 20px; }

/* مؤشرات KPI */
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px 16px; box-shadow: var(--shadow);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.kpi .l { color: var(--muted); font-size: .8rem; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi .l .ico { color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 7px; width: 32px; height: 32px; }
.kpi .v { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 6px; line-height: 1.2; }
.kpi .h { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.kpi .h a { color: var(--ink-2); }
.kpi.good .v { color: var(--good); }
.kpi.bad .v { color: var(--bad); }
.kpi.hero { background: linear-gradient(135deg, #141416 0%, #26262b 100%); border-color: #26262b; color: #f4f4f5; }
:root[data-theme="dark"] .kpi.hero { background: linear-gradient(135deg, #222227 0%, #2e2e34 100%); }
.kpi.hero .l { color: #a1a1aa; }
.kpi.hero .l .ico { background: rgba(255, 255, 255, .08); color: #e4e4e7; }
.kpi.hero .h { color: #a1a1aa; }
.kpi.hero .v { color: #fff; }
.kpi.hero::after {
  content: ""; position: absolute; inset-inline-end: -40px; top: -40px; width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(201, 204, 209, .16), transparent 70%);
}

/* ============================================================ التوصية */
.rec {
  display: flex; gap: 14px; align-items: flex-start;
  border-radius: var(--r-lg); padding: 16px 20px; margin-bottom: 20px;
  border: 1px solid; border-inline-start-width: 4px;
  font-size: 1.05rem; font-weight: 700;
}
.rec small { display: block; font-weight: 700; font-size: .72rem; letter-spacing: .08em; opacity: .75; margin-bottom: 2px; }
.rec .ico { margin-top: 3px; }
.rec.good { background: var(--good-bg); color: var(--good); border-color: var(--good-line); border-inline-start-color: var(--good); }
.rec.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); border-inline-start-color: var(--warn); }
.rec.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); border-inline-start-color: var(--bad); }
.rec.info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); border-inline-start-color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; margin-top: 10px; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent); }

/* ============================================================ الجداول */
.tbl-wrap { overflow-x: auto; }
.card.tbl-wrap { padding-top: 16px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
th {
  font-weight: 700; color: var(--muted); background: transparent; font-size: .75rem;
  letter-spacing: .03em; white-space: nowrap; border-bottom: 1px solid var(--line-strong);
}
thead th:first-child { border-start-start-radius: 8px; }
tbody tr { transition: background var(--t) var(--ease); }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: none; }
tfoot td { border-bottom: none; border-top: 1px solid var(--line-strong); }
tr.sec td { background: var(--surface-2); font-weight: 800; color: var(--ink-2); font-size: .78rem; letter-spacing: .04em; padding-top: 8px; padding-bottom: 8px; }
tr.total td, td.total, th.total { font-weight: 800; background: var(--accent-soft); color: var(--ink); }
th.total { color: var(--accent); }
td.lbl { color: var(--ink-2); white-space: nowrap; }
td.nw { white-space: nowrap; }
td a { font-weight: 700; text-decoration: none; }
td a:hover { text-decoration: underline; }
.kv { width: 100%; }
.kv td { padding: 9px 4px; }
.kv td:first-child { color: var(--ink-2); width: 58%; }
.kv td:last-child { font-weight: 700; text-align: left; font-variant-numeric: tabular-nums; direction: ltr; }
.kv tr:hover { background: transparent; }
.kv tr.strong td { font-weight: 800; font-size: 1.02rem; border-top: 1.5px solid var(--ink); border-bottom: none; padding-top: 11px; }
.empty { color: var(--muted); text-align: center; padding: 36px 12px !important; }

/* ============================================================ الشارات */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; line-height: 1.6;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.b-good { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.b-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.b-bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.b-info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.b-mute { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.badge.soft { background: transparent; border-style: dashed; }
.badge.soft::before { display: none; }

/* ============================================================ التسعير والإعلانات */
table.sens { font-variant-numeric: tabular-nums; }
table.sens td, table.sens th { text-align: center; padding: 7px 8px; }
table.sens td.lbl { background: var(--surface-2); }
table.sens td.sens-pos { background: var(--good-bg); color: var(--good); }
table.sens td.sens-neg { background: var(--bad-bg); color: var(--bad); }
table.sens td.sens-now { outline: 2px solid var(--ink); outline-offset: -2px; font-weight: 800; }
.ads-table td, .ads-table th { padding-inline: 7px; font-size: .84rem; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }

/* ============================================================ النماذج */
form.inline { display: inline; }
label { display: block; font-size: .8rem; color: var(--ink-2); margin-bottom: 6px; font-weight: 700; }
input, select, textarea {
  font: inherit; font-size: .92rem; width: 100%; min-height: 42px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--field); color: var(--ink);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--field-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: var(--ring); }
input[type=number] { direction: ltr; text-align: right; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; margin: 0 0 0 8px; accent-color: var(--ink); vertical-align: middle; }
input[type=file] { padding: 7px; background: var(--surface-2); }
input::placeholder { color: var(--placeholder); }
select { appearance: none; -webkit-appearance: none; padding-left: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 10px center; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--muted); font-size: .74rem; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 2px; font-size: .88rem; color: var(--ink); font-weight: 500; margin: 6px 0; cursor: pointer; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px 8px; margin: 0 0 20px; background: var(--surface); box-shadow: var(--shadow); min-width: 0; }
/* العنوان جوه البطاقة بدل ما يقعد على الحدود */
legend { float: right; width: 100%; padding: 0 0 12px; margin: 0 0 14px; font-weight: 800; font-size: 1.02rem; color: var(--ink); border-bottom: 1px solid var(--line); }
legend ~ * { clear: both; }
.grid > fieldset { margin-bottom: 0; }

/* ============================================================ الأزرار */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--on-ink); font: inherit; font-size: .88rem; font-weight: 700;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 2px 6px -2px rgba(20, 20, 20, .35);
}
.btn:hover { background: var(--ink-hover); color: var(--on-ink); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--field-hover); color: var(--ink); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad-line); box-shadow: none; }
.btn.danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn.good { background: var(--good); border-color: var(--good); }
.btn.good:hover { background: #255a42; }
.btn.sm { min-height: 32px; padding: 4px 11px; font-size: .8rem; border-radius: 8px; gap: 5px; }
.btn.sm .ico { width: 15px; height: 15px; }

/* ============================================================ الرسائل */
.flash {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--r); margin-bottom: 16px; white-space: pre-line; border: 1px solid;
  font-size: .92rem; animation: flash-in 260ms var(--ease);
}
.flash .ico { margin-top: 2px; }
.toast { position: fixed; inset-inline: 0; bottom: 20px; margin: 0 auto; width: max-content; max-width: min(560px, calc(100% - 32px));
  z-index: 60; box-shadow: var(--shadow-lg); animation: toastIn .25s var(--ease); transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translateY(12px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.flash.ok { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); font-weight: 700; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ============================================================ التبويبات */
.tabs { display: inline-flex; gap: 2px; flex-wrap: wrap; margin-bottom: 16px; padding: 4px; background: var(--surface-3); border-radius: 12px; }
.tabs a { padding: 6px 14px; border-radius: 9px; text-decoration: none; font-size: .84rem; font-weight: 700; color: var(--ink-2); transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.tabs a:hover { color: var(--ink); background: var(--glass); }
.tabs a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ============================================================ الرسوم */
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar-pos { fill: var(--chart-bar); transition: fill var(--t) var(--ease); }
.chart .bar-pos:hover { fill: var(--accent); }
.chart .bar-neg { fill: var(--bad); }
.chart .axis { stroke: var(--line-strong); }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 11px; }

/* قائمة منسدلة مع بحث */
.combo { position: relative; }
.combo-list {
  position: absolute; top: calc(100% + 4px); inset-inline: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; padding: 4px;
}
.combo-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: .9rem; }
.combo-item small { color: var(--muted); font-size: .76rem; direction: ltr; unicode-bidi: plaintext; }
.combo-item:hover, .combo-item.on { background: var(--surface-2); }
.combo-item.on { box-shadow: inset 3px 0 0 var(--ink); }
.combo-empty { padding: 10px; color: var(--muted); font-size: .84rem; text-align: center; }
.combo-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 11px center; padding-left: 34px;
}

/* اختيار مقسّم (زي الراديو) */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 11px; }
.seg-opt { flex: 1; margin: 0; cursor: pointer; position: relative; }
.seg-opt input { position: absolute; inset: 0; width: 1px; height: 1px; min-height: 0; opacity: 0; pointer-events: none; }
.seg-opt span { display: flex; align-items: center; justify-content: center; min-height: 34px; padding: 4px 8px; border-radius: 8px;
  font-size: .84rem; font-weight: 700; color: var(--ink-2); transition: background var(--t) var(--ease), color var(--t) var(--ease); text-align: center; }
.seg-opt input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg-opt input:focus-visible + span { box-shadow: var(--ring); }
th a.sort { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
th a.sort:hover { color: var(--ink); }
th a.sort .mk { font-size: .62rem; color: var(--accent); }
.stmt-head { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.lines-table input, .lines-table select { min-height: 38px; padding: 6px 10px; }
.lines-table select { padding-left: 30px; }
.lines-table td { padding: 6px 4px; border-bottom: none; }
.lines-table tbody tr:hover { background: transparent; }

.logo-preview { display: flex; gap: 10px; margin-bottom: 10px; }
.logo-preview div { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; background: #fff; }   /* معاينة اللوجو على الورق الأبيض (في الوضعين) */
.logo-preview img { height: 64px; width: auto; }
.logo-preview .on-dark { background: var(--side); border-color: var(--side); }

/* ============================================================ الشاشات الصغيرة */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .app-bar { padding: 0 16px; gap: 10px; height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .sections { order: 3; width: 100%; }
  .cmdk-btn span, .cmdk-btn kbd { display: none; }
  .subnav .in { padding: 0 16px; }
  main.page, main.page.page-wide { padding: 18px 16px 40px; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head .actions select { max-width: 100%; }
}
@media (max-width: 600px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .bar-end .btn span { display: none; }
  .sections a { padding: 7px 10px; }
  h1 { font-size: 1.3rem; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .app-top, .actions, .no-print, .cmdk, .pnl-acts, .split-list { display: none !important; }
  main.page { padding: 0; max-width: none; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; }
}
.ads-table td:first-child b, .ads-table td.small, .ads-table .badge { white-space: nowrap; }

/* ============================================================ الرئيسية: مركز المهام */
.home { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.hello h1 { font-size: 1.75rem; margin: 0; }
.hello .sub { color: var(--muted); font-size: .9rem; }
.cmd-box { width: 100%; margin: 16px 0 16px; display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--surface); border: 2px solid var(--ink); border-radius: 14px; font: inherit; font-size: .95rem; color: var(--muted); cursor: text; text-align: start; transition: box-shadow var(--t) var(--ease); }
.cmd-box:hover { box-shadow: 0 6px 22px -10px rgba(20, 20, 20, .35); }
.cmd-box span { flex: 1; }
.acts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.act { display: flex; flex-direction: column; gap: 10px; padding: 14px 12px; min-height: 104px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; font-weight: 700; font-size: .88rem; color: var(--ink); transition: transform var(--t) var(--ease), border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.act:hover { border-color: var(--ink); transform: translateY(-2px); color: var(--ink); box-shadow: var(--shadow); }
.act .ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); }
.act.pri { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.act.pri:hover { color: var(--on-ink); }
.act.pri .ic { background: rgba(255, 255, 255, .14); }
.sec-h { display: flex; justify-content: space-between; align-items: baseline; margin: 26px 0 10px; }
.sec-h h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.sec-h.small-h { margin: 22px 0 6px; } .sec-h.small-h h3 { margin: 0; font-size: .9rem; }
.todo { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.todo-row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.todo-row:last-child { border-bottom: 0; }
.todo-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--ink-2); }
.lv-bad .todo-ic { background: var(--bad-bg); color: var(--bad); }
.lv-warn .todo-ic { background: var(--warn-bg); color: var(--warn); }
.lv-info .todo-ic { background: var(--info-bg); color: var(--info); }
.lv-good .todo-ic { background: var(--good-bg); color: var(--good); }
.todo-tx { flex: 1; min-width: 0; }
.todo-tx b { display: block; font-size: .93rem; }
.todo-tx small { color: var(--muted); font-size: .8rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-act { display: flex; gap: 6px; flex: none; }
.todo-empty { display: flex; align-items: center; gap: 14px; padding: 22px 18px; color: var(--good); }
.todo-empty b { display: block; color: var(--ink); } .todo-empty small { color: var(--muted); }
.batch-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.bcard { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--ink); transition: border-color var(--t) var(--ease); }
.bcard:hover { border-color: var(--ink); color: var(--ink); }
.bcard .bh { display: flex; justify-content: space-between; align-items: baseline; }
.bcard .bn { font-size: 1.5rem; font-weight: 800; display: flex; align-items: baseline; gap: 8px; }
.bcard .bn small { font-size: .76rem; color: var(--muted); font-weight: 400; }
.bcard .bf { display: flex; gap: 12px; font-size: .78rem; color: var(--ink-2); }
.rec-line { display: flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.rec-line .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.rec-line.good { color: var(--good); } .rec-line.warn { color: var(--warn); } .rec-line.bad { color: var(--bad); } .rec-line.info { color: var(--info); }
.home-side { position: sticky; top: 130px; }
.stat { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 10px; text-decoration: none; color: var(--ink); transition: border-color var(--t) var(--ease); }
.stat:hover { border-color: var(--line-strong); color: var(--ink); }
.stat small { display: block; color: var(--muted); font-size: .8rem; }
.stat b { display: block; font-size: 1.75rem; font-weight: 800; line-height: 1.35; }
.stat b span { font-size: .95rem; font-weight: 400; }
.stat.dark { background: var(--hero); border-color: var(--hero); color: var(--hero-ink); }
.stat.dark:hover { color: var(--hero-ink); } .stat.dark small { color: var(--hero-muted); }
.stat.link { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: .88rem; }
.stat.link span { flex: 1; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.feed li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 2px; font-size: .82rem; border-bottom: 1px dashed var(--line); }
.feed li a { text-decoration: none; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed li a:hover { color: var(--ink); }
.feed small { color: var(--muted); flex: none; }
.rec.mute { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }

/* ============================================================ البحث السريع (Ctrl+K) */
.cmdk { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.cmdk[hidden] { display: none; }
.cmdk-back { position: absolute; inset: 0; background: rgba(15, 15, 17, .42); backdrop-filter: blur(3px); }
.cmdk-box { position: relative; width: min(640px, 100%); background: var(--surface); border-radius: 16px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); overflow: hidden; animation: cmdkIn .16s var(--ease); }
@keyframes cmdkIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.cmdk-in { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.cmdk-in input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 1.02rem; background: transparent; color: var(--ink); padding: 4px 0; box-shadow: none; min-height: 0; }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.cmdk-grp { font-size: .72rem; font-weight: 700; color: var(--muted); padding: 10px 12px 4px; }
.cmdk-it { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.cmdk-it.on { background: var(--surface-2); }
.cmdk-it .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); flex: none; color: var(--ink-2); }
.cmdk-it.on .ic { background: var(--ink); color: var(--on-ink); }
.cmdk-it .tx { min-width: 0; } .cmdk-it b { display: block; font-size: .9rem; } .cmdk-it small { color: var(--muted); font-size: .78rem; }
.cmdk-empty { padding: 26px; text-align: center; color: var(--muted); }
.cmdk-foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--line); font-size: .74rem; color: var(--muted); background: var(--surface-2); }

/* ============================================================ الفواتير: قائمة وتفاصيل */
.split { display: grid; grid-template-columns: 380px minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); height: calc(100vh - 168px); min-height: 520px; overflow: hidden; }
.split-list { display: flex; flex-direction: column; border-inline-end: 1px solid var(--line); min-height: 0; }
.sl-head { padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.sl-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sl-title h1 { margin: 0; font-size: 1.3rem; }
.sl-search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 10px; color: var(--muted); background: var(--surface); }
.sl-search input { border: 0; outline: 0; box-shadow: none; padding: 8px 0; min-height: 0; background: transparent; flex: 1; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.chips a { font-size: .76rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); }
.chips a b { font-weight: 400; color: var(--muted); }
.chips a.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); } .chips a.on b { color: var(--on-ink); opacity: .7; }
.sl-sort { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }
.sl-sort select { width: auto; min-height: 30px; padding: 2px 8px; font-size: .78rem; }
.pick-hint { display: flex; gap: 8px; align-items: center; margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: var(--info-bg); color: var(--info); font-size: .82rem; font-weight: 700; }
.sl-items { overflow-y: auto; flex: 1; min-height: 0; }
.inv-it { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 11px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); border-inline-start: 3px solid transparent; transition: background var(--t) var(--ease); }
.inv-it:hover { background: var(--surface-2); color: var(--ink); }
.inv-it.on { background: var(--accent-soft); border-inline-start-color: var(--ink); }
.inv-it b { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-it .amt { font-weight: 800; font-size: .9rem; }
.inv-it small { color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-it .st { font-size: .74rem; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; justify-self: end; white-space: nowrap; }
.inv-it .st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.inv-it .st em { font-style: normal; font-weight: 400; color: var(--bad); margin-inline-start: 4px; }
.s-draft { color: var(--muted); } .s-ship { color: var(--info); } .s-done { color: var(--good); } .s-ret { color: var(--bad); } .s-cancel { color: var(--muted); }
.split-detail { overflow-y: auto; min-height: 0; padding: 20px 26px; transition: opacity .12s; }
.split-detail.loading { opacity: .45; }
.pnl-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); text-align: center; }
.pnl-empty b { color: var(--ink); }
.pnl-back { display: none; align-items: center; gap: 6px; font-size: .85rem; font-weight: 700; margin-bottom: 10px; text-decoration: none; }
.pnl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.pnl-head h2 { font-size: 1.45rem; font-weight: 800; margin: 2px 0 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pnl-acts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.more { position: relative; }
.more summary { list-style: none; cursor: pointer; font-weight: 800; letter-spacing: .1em; }
.more summary::-webkit-details-marker { display: none; }
.more-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 10; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; }
.more-menu a, .more-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: .85rem; text-decoration: none; color: var(--ink); background: none; border: 0; cursor: pointer; text-align: start; }
.more-menu a:hover, .more-menu button:hover { background: var(--surface-2); }
.more-menu form { margin: 0; }
.danger-txt { color: var(--bad) !important; }
.steps { list-style: none; display: flex; margin: 18px 0; padding: 14px 10px; background: var(--surface-2); border-radius: 12px; }
.steps li { flex: 1; text-align: center; position: relative; font-size: .8rem; color: var(--muted); }
.steps li i { position: relative; z-index: 1; display: grid; place-items: center; width: 28px; height: 28px; margin: 0 auto 4px; border-radius: 50%; background: var(--surface-3); font-style: normal; font-weight: 800; font-size: .78rem; }
.steps li + li::before { content: ""; position: absolute; top: 14px; inset-inline-end: 50%; width: 100%; height: 2px; background: var(--surface-3); }
.steps li span { display: block; font-weight: 700; }
.steps li small { display: block; font-size: .72rem; }
.steps li.done { color: var(--good); } .steps li.done i { background: var(--good); color: var(--surface); } .steps li.done::before { background: var(--good); }
.steps li.cur { color: var(--ink); } .steps li.cur i { background: var(--ink); color: var(--on-ink); box-shadow: var(--ring); }
.steps li.bad { color: var(--bad); } .steps li.bad i { background: var(--bad); color: var(--surface); } .steps li.bad::before { background: var(--bad); }
.pnl-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.pc { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.pc-wide { grid-column: 1 / -1; }
.pc h4 { margin: 0 0 8px; font-size: .86rem; color: var(--ink-2); }
.pc table { margin: 0; }

@media (max-width: 1180px) {
  .home { grid-template-columns: minmax(0, 1fr); }
  .home-side { position: static; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .home-side .stat { margin: 0; }
  .home-side .stat.link, .home-side .sec-h, .home-side .feed { grid-column: 1 / -1; }
  .acts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { grid-template-columns: 320px minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .split { display: block; height: auto; min-height: 0; }
  .split .split-detail { display: none; padding: 16px; }
  .split.has-sel .split-list { display: none; }
  .split.has-sel .split-detail { display: block; }
  .split-list { border: 0; }
  .sl-items { max-height: none; }
  .pnl-back { display: inline-flex; }
}
@media (max-width: 600px) {
  .acts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .act { min-height: 0; flex-direction: row; align-items: center; }
  .home-side { grid-template-columns: minmax(0, 1fr); }
  .todo-row { flex-wrap: wrap; }
  .todo-act { width: 100%; justify-content: flex-end; }
  .pnl-grid { grid-template-columns: minmax(0, 1fr); }
  .cmd-box span { font-size: .85rem; }
  .cmd-box kbd { display: none; }
}

/* سند القبض في التفاصيل */
.amount-hero { margin: 16px 0 12px; padding: 18px 20px; border-radius: 14px; background: var(--hero); color: var(--hero-ink); }
.amount-hero small { color: var(--hero-muted); font-size: .8rem; }
.amount-hero b { display: block; font-size: 2rem; font-weight: 800; line-height: 1.3; }
.amount-hero b span { font-size: 1rem; font-weight: 400; }
.amount-hero .words { color: #dedbd4; font-size: .9rem; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.mini-stats > div { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-width: 0; }
.mini-stats small { display: block; color: var(--muted); font-size: .76rem; }
.mini-stats b { font-size: 1.05rem; }
.mini-stats .warn { background: var(--warn-bg); border-color: var(--warn-line); } .mini-stats .warn b { color: var(--warn); }
.amount-hero.out { background: #3a2422; }
.amount-hero.out small, .amount-hero.out .words { color: #e2cfcb; }
.mini-stats .ok { background: var(--good-bg); border-color: var(--good-line); } .mini-stats .ok b { color: var(--good); }
.amount-hero.back { background: #2d3440; }
.amount-hero.back small, .amount-hero.back .words { color: #cfd5de; }
.seg-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin-bottom: 10px; background: var(--surface-2); border-radius: 10px; }
.seg-switch a { text-align: center; padding: 6px 8px; border-radius: 8px; font-size: .8rem; font-weight: 700; color: var(--ink-2); text-decoration: none; }
.seg-switch a b { font-weight: 400; color: var(--muted); }
.seg-switch a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ============================================================ الموقف المالي التفاعلي */
.ptabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.ptab { text-align: start; font: inherit; cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; color: var(--ink); box-shadow: var(--shadow-sm); transition: border-color var(--t) var(--ease), transform var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.ptab:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.ptab .l { display: flex; align-items: center; gap: 7px; font-size: .84rem; font-weight: 700; color: var(--ink-2); }
.ptab b { font-size: 1.6rem; font-weight: 800; line-height: 1.35; }
.ptab small { font-size: .76rem; color: var(--muted); }
.ptab.in b { color: var(--good); } .ptab.out b { color: var(--bad); }
.ptab.on { border: 2px solid var(--ink); padding: 15px 17px; box-shadow: var(--shadow); }
.decide { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 24px; align-items: center; padding: 12px 18px; margin-bottom: 16px; background: var(--surface-2); border-radius: 14px; }
.decide small { display: block; font-size: .76rem; color: var(--muted); }
.decide b { font-size: 1.1rem; }
.meter { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; border-radius: 6px; }
.meter i.ok { background: var(--good); } .meter i.bad { background: var(--bad); }
.ppanel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 20px; }
.ppanel-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.ppanel-h h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
details.party { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--surface); transition: border-color var(--t) var(--ease); }
details.party[open] { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
details.party > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto auto auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; }
details.party > summary::-webkit-details-marker { display: none; }
details.party > summary:hover { background: var(--surface-2); }
.p-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.p-tx { min-width: 0; } .p-tx b { display: block; font-size: .95rem; }
.p-tx small { display: block; color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-bar { width: 120px; height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.p-bar i { display: block; height: 100%; background: var(--good); border-radius: 4px; }
.p-bar.out i { background: var(--bad); }
.p-amt { font-weight: 800; font-size: 1.05rem; min-width: 90px; text-align: left; }
.chev { color: var(--muted); transform: rotate(90deg); transition: transform var(--t) var(--ease); }
details.party[open] .chev { transform: rotate(-90deg); }
.p-body { padding: 4px 16px 16px; border-top: 1px dashed var(--line); }
.p-body h4 { margin: 14px 0 6px; font-size: .84rem; color: var(--ink-2); }
.p-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.party-note { display: flex; gap: 8px; align-items: center; font-size: .84rem; color: var(--ink-2); padding: 10px 14px; background: var(--info-bg); border-radius: 10px; margin-top: 10px; flex-wrap: wrap; }
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.acc { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); transition: border-color var(--t) var(--ease); }
.acc:hover { border-color: var(--ink); color: var(--ink); }
.acc small { color: var(--muted); font-size: .76rem; } .acc span { font-size: 1.3rem; font-weight: 800; }
@media (max-width: 960px) {
  .ptabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .decide { grid-template-columns: 1fr 1fr; } .decide .meter-wrap { grid-column: 1 / -1; }
  details.party > summary { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  details.party > summary .p-bar, details.party > summary .badge { display: none; }
}
@media print { .ppanel[hidden] { display: block !important; } details.party > .p-body { display: block; } }

/* خطوات الدفعة */
.plan-steps { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px 14px 12px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.plan-steps .steps { background: none; margin: 8px 0 4px; padding: 6px 0; }
.next-step { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .9rem; padding: 8px 12px; background: var(--info-bg); color: var(--info); border-radius: 10px; }
.next-step b { color: var(--ink); }
.next-step .btn { margin-inline-start: auto; }
/* قائمة المكونات */
.bom-table .cell { display: flex; flex-direction: column; gap: 4px; }
.bom-table .cell .mode { font-size: .72rem; color: var(--muted); cursor: pointer; text-decoration: underline dotted; align-self: flex-start; background: none; border: 0; padding: 0; font-family: inherit; }
.quick-mat { display: none; gap: 8px; align-items: end; flex-wrap: wrap; margin-top: 10px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.quick-mat.on { display: flex; }
.quick-mat .field { margin: 0; }
.demo-bar { background: #8a5a12; color: #fff; text-align: center; font-size: .82rem; font-weight: 700; padding: 5px 12px; }
.demo-bar a { color: #fff; text-decoration: underline; margin-inline-start: 6px; }
