/* دفتر — هوية: ورق مايل للأخضر + أخضر الخزنة. الكروت بس بحواف 12px، والباقي 8px أو أقل. */
:root {
  --bg: #F4F6F2;          /* ورق */
  --surface: #FFFFFF;     /* الكروت */
  --surface-2: #EEF2EE;   /* رؤوس الجداول والخانات الهادية */
  --ink: #1A2622;         /* الحبر */
  --muted: #5E6B66;       /* الرمادي الثانوي */
  --brand: #1F5F4F;       /* أخضر الخزنة */
  --brand-hover: #184C3F;
  --brand-soft: #E3EEE9;
  --on-brand: #FFFFFF;
  --in: #1E8E5A;  --in-soft: #E3F3EA;     /* فلوس دخلت */
  --out: #C2412D; --out-soft: #FBE8E4;    /* فلوس طلعت */
  --warn: #B7791F; --warn-soft: #FAF0DD;  /* تنبيه */
  --line: #DDE3DE;
  --c-ops: #4E6A85; --c-ads: #6B5BA8; --c-sup: #8A6A3B; --c-tr: #6E7975; --c-cust: #2F7A8C;
  --logo: #1F5F4F;
  --hero-bg: #1F5F4F; --hero-ink: #FFFFFF; --hero-muted: #BFD8CF; --hero-line: rgba(255, 255, 255, .16);
  --scrim: rgba(15, 22, 20, .45);
  --shadow: 0 1px 2px rgba(26, 38, 34, .06), 0 2px 6px rgba(26, 38, 34, .04);
  --fab-shadow: 0 6px 18px rgba(31, 95, 79, .35);
  --toast-bg: #1A2622; --toast-ink: #FFFFFF;
  --r-card: 12px; --r-ctl: 8px; --r-chip: 6px;
  --f-body: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --f-display: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --nav-w: 252px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1614; --surface: #16201D; --surface-2: #1B2824; --ink: #E6EEEA; --muted: #93A39C;
    --brand: #5BB89A; --brand-hover: #74C9AC; --brand-soft: #18302A; --on-brand: #0B1F19;
    --in: #4FD18E; --in-soft: #16301F; --out: #F0806B; --out-soft: #3A211C; --warn: #E5B04A; --warn-soft: #362B14;
    --line: #26332E;
    --c-ops: #8FA9C4; --c-ads: #A99BE0; --c-sup: #CFA872; --c-tr: #9AA5A0; --c-cust: #7CC6D6;
    --hero-bg: #133A30; --hero-ink: #E6EEEA; --hero-muted: #9CC4B6; --hero-line: rgba(230, 238, 234, .12);
    --scrim: rgba(0, 0, 0, .6);
    --shadow: none; --fab-shadow: 0 6px 18px rgba(0, 0, 0, .5);
    --toast-bg: #E6EEEA; --toast-ink: #0F1614;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1614; --surface: #16201D; --surface-2: #1B2824; --ink: #E6EEEA; --muted: #93A39C;
  --brand: #5BB89A; --brand-hover: #74C9AC; --brand-soft: #18302A; --on-brand: #0B1F19;
  --in: #4FD18E; --in-soft: #16301F; --out: #F0806B; --out-soft: #3A211C; --warn: #E5B04A; --warn-soft: #362B14;
  --line: #26332E;
  --c-ops: #8FA9C4; --c-ads: #A99BE0; --c-sup: #CFA872; --c-tr: #9AA5A0; --c-cust: #7CC6D6;
  --hero-bg: #133A30; --hero-ink: #E6EEEA; --hero-muted: #9CC4B6; --hero-line: rgba(230, 238, 234, .12);
  --scrim: rgba(0, 0, 0, .6);
  --shadow: none; --fab-shadow: 0 6px 18px rgba(0, 0, 0, .5);
  --toast-bg: #E6EEEA; --toast-ink: #0F1614;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.65 var(--f-body); }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-family: var(--f-display); font-weight: 600; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); }
.small, small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.num.in { color: var(--in); }
.num.out { color: var(--out); }
.num.zero { color: var(--muted); }
.neg { color: var(--out); }
.pos { color: var(--in); }

/* ---------- اللوجو ---------- */
.logo { display: inline-grid; flex: none; line-height: 0; }
.logo svg { display: block; }
.brand-name { font-family: var(--f-display); font-weight: 700; letter-spacing: 0; }
.brand-tag { color: var(--muted); font-size: 12px; }

/* ---------- الدخول ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 28px 22px; display: grid; gap: 14px; text-align: center; box-shadow: var(--shadow); }
.login-box .logo { margin: 0 auto; }
.login-box h1 { font-size: 30px; font-weight: 700; }
.login-box .brand-tag { margin-top: -10px; font-size: 14px; }
.login-box .field { text-align: start; }

/* ---------- الهيكل ---------- */
.nav { position: fixed; inset: 0 0 0 auto; width: var(--nav-w); background: var(--surface); border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px calc(14px + env(safe-area-inset-bottom, 0px)); padding-top: calc(14px + env(safe-area-inset-top, 0px)); gap: 2px; z-index: 30; overflow-y: auto; transform: translateX(100%); transition: transform .2s; }
.nav-head { display: flex; gap: 10px; align-items: center; padding: 4px 6px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.nav-head .brand-name { display: block; font-size: 20px; line-height: 1.2; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: var(--r-ctl); color: var(--ink); font-weight: 500; }
.nav a i { font-style: normal; width: 22px; text-align: center; color: var(--muted); }
.nav a .chip { margin-inline-start: auto; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav a.on i { color: var(--brand); }
.nav-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.nav-foot .who { font-size: 13px; color: var(--muted); }
.nav-foot .who b { color: var(--ink); font-weight: 600; }
.scrim { display: none; }
body.nav-open .nav { transform: none; }
body.nav-open .scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 25; }
.main { min-height: 100vh; padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 21; background: var(--bg); }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 8px; padding-block: 8px; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top h1 { flex: 1; font-size: 18px; }
#view { padding-block: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); max-width: 1200px; margin: 0 auto; display: grid; gap: 14px; }
#view > * { min-width: 0; }
.bottom-nav { position: fixed; bottom: 0; inset-inline: 0; z-index: 20; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.bottom-nav a { flex: 1; display: grid; justify-items: center; padding: 7px 2px 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.bottom-nav a i { font-style: normal; font-size: 18px; line-height: 1.2; }
.bottom-nav a.on { color: var(--brand); font-weight: 600; }
.fab { position: fixed; z-index: 22; left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(66px + env(safe-area-inset-bottom, 0px)); display: inline-flex; align-items: center; gap: 6px; min-height: 50px; padding: 0 20px; border-radius: 999px; background: var(--brand); color: var(--on-brand); font-family: var(--f-display); font-weight: 600; font-size: 16px; box-shadow: var(--fab-shadow); }
.fab:hover { background: var(--brand-hover); }
.fab b { font-size: 22px; line-height: 1; font-weight: 600; }
.desk-only { display: none !important; }
@media (min-width: 960px) {
  .nav { transform: none; }
  .main { margin-inline-start: var(--nav-w); padding-bottom: 24px; }
  .bottom-nav, .fab, .top .icon-btn.menu { display: none; }
  .desk-only { display: inline-flex !important; }
  body.nav-open .scrim { display: none; }
  #view { padding-block: 22px; padding-left: 24px; padding-right: 24px; }
}
body.demo .top::after { content: "تجربة"; font-size: 12px; background: var(--warn-soft); color: var(--warn); padding: 1px 8px; border-radius: var(--r-chip); font-weight: 600; }

/* ---------- عناصر ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; box-shadow: var(--shadow); display: grid; gap: 12px; min-width: 0; }
.card > h2, .card-head h2 { font-size: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head .sub { color: var(--muted); font-size: 13px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.danger { color: var(--out); border-color: color-mix(in srgb, var(--out) 40%, var(--line)); }
.btn.big { min-height: 48px; font-size: 16px; width: 100%; }
.btn.block { width: 100%; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: var(--r-ctl); font-size: 18px; cursor: pointer; color: var(--ink); flex: none; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.sm { width: 34px; height: 34px; font-size: 15px; }
.icon-btn.danger { color: var(--out); }
.acts { display: flex; gap: 2px; justify-content: flex-end; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: var(--r-chip); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.more { font-weight: 600; font-size: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }

/* الشارات (chips): لون كل مجموعة */
.chip, .tag { --cc: var(--c-tr); display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; line-height: 1.6; padding: 0 8px; border-radius: var(--r-chip); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
  color: var(--cc); background: color-mix(in srgb, var(--cc) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--cc) 28%, transparent); }
.chip.g-sales, .chip.g-other_in, .tag.pos, .chip.st-ok { --cc: var(--in); }
.chip.g-opex, .chip.g-staff { --cc: var(--c-ops); }
.chip.g-ads { --cc: var(--c-ads); }
.chip.g-supplier, .chip.g-goods { --cc: var(--c-sup); }
.chip.g-outside, .chip.st-over { --cc: var(--warn); }
.chip.g-transfer, .chip.st-none { --cc: var(--c-tr); }
.tag.neg, .chip.st-short { --cc: var(--out); }
.chip.st-ok, .chip.st-short, .chip.st-over, .chip.st-none { font-weight: 600; }

/* ---------- الإحصائيات ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--r-ctl); padding: 10px 12px; min-width: 0; }
.stat-l { color: var(--muted); font-size: 13px; }
.stat-v { font-family: var(--f-display); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; text-align: end; }
.stat-s { font-size: 12px; color: var(--muted); }
.stat.hl { background: var(--brand-soft); }
.stat.hl .stat-v { color: var(--brand); }
.stat .stat-v.neg, .stat.is-out .stat-v { color: var(--out); }
.stat.is-in .stat-v { color: var(--in); }
.drawer-strip { background: var(--brand-soft); color: var(--brand); border-radius: var(--r-card); padding: 10px 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.drawer-strip .num { font-family: var(--f-display); font-size: 18px; }
.drawer-strip a { margin-inline-start: auto; }

/* ---------- الرئيسية ---------- */
.dash { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.dash > * { min-width: 0; }
.hero { grid-column: 1 / -1; background: var(--hero-bg); color: var(--hero-ink); border-radius: var(--r-card); padding: 18px 18px 8px; display: grid; gap: 4px; }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hero .eyebrow { color: var(--hero-muted); font-size: 14px; font-weight: 500; }
.hero .btn.primary { background: var(--hero-ink); color: var(--hero-bg); border-color: transparent; }
.hero-num { display: flex; align-items: baseline; gap: 8px; justify-content: flex-start; flex-wrap: wrap; }
.hero-num .num { font-family: var(--f-display); font-weight: 700; font-size: clamp(38px, 11vw, 60px); line-height: 1.1; color: var(--hero-ink); }
.hero-num .cur { color: var(--hero-muted); font-size: 16px; font-weight: 500; }
.acc-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); column-gap: 24px; }
.acc-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--hero-line); min-width: 0; }
.acc-list li[role="link"] { cursor: pointer; }
.acc-list .acc-n { display: flex; align-items: center; gap: 8px; color: var(--hero-muted); min-width: 0; flex-wrap: wrap; }
.acc-list .num { color: var(--hero-ink); font-weight: 600; font-size: 16px; }
.acc-list .num.out { color: var(--hero-ink); }
.hero .chip { background: var(--surface); }

dl.ledger { display: grid; grid-template-columns: 1fr auto; margin: 0; }
dl.ledger dt, dl.ledger dd { padding: 6px 0; border-bottom: 1px dashed var(--line); margin: 0; }
dl.ledger dd { text-align: end; }
dl.ledger .tot { font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--line); }
dl.ledger .grand { font-family: var(--f-display); font-size: 18px; font-weight: 600; border-bottom: 0; padding-top: 10px; }
dl.ledger dt { color: var(--muted); }
dl.ledger dt.tot, dl.ledger dt.grand { color: var(--ink); }
.big-figure { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.big-figure > .num { font-family: var(--f-display); font-size: 34px; font-weight: 700; }
.dash > .wide { grid-column: 1 / -1; }
.meters { display: grid; gap: 10px; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 13px; }
.meter .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter .bar i { display: block; height: 100%; border-radius: 3px; }
.meter .bar i.ads { background: var(--c-ads); }
.meter .bar i.sup { background: var(--c-sup); }
.link-rows { display: grid; }
.link-rows a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.link-rows a:last-child { border: 0; }

/* كشف الربح: أقسام (عنوان كبير + تفاصيل أصغر) */
.statement2 { display: grid; }
.st-sec { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.st-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-family: var(--f-display); font-size: 16px; font-weight: 600; color: var(--ink); }
.st-head small { font-family: var(--f-body); font-size: 12px; font-weight: 400; color: var(--muted); margin-inline-start: 6px; }
.st-head .num { font-size: 17px; }
.st-rows { display: grid; gap: 2px; padding-inline-start: 14px; border-inline-start: 2px solid var(--line); margin-inline-start: 2px; }
.st-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--muted); }
.st-row small { margin-inline-start: 6px; color: var(--warn); }
.st-sec.grand { border-bottom: 0; padding-top: 14px; }
.st-sec.grand .st-head { font-size: 20px; }
.st-sec.grand .st-head .num { font-size: 26px; font-weight: 700; }
.member-list { list-style: none; margin: 0; padding: 0; display: grid; }
.member-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.member-list .m-name { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; font-weight: 500; }
.member-list .m-pct { font-weight: 600; }
.file-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dt-more { display: flex; justify-content: center; }
.dt-more:empty { display: none; }

/* ---------- قوايم ---------- */
dl.kv { display: grid; grid-template-columns: 1fr auto; row-gap: 6px; margin: 0; }
dl.kv dd { padding-inline-start: 12px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: end; font-weight: 600; }
dl.kv .big { font-family: var(--f-display); font-size: 18px; font-weight: 600; color: var(--ink); border-top: 1px solid var(--line); padding-top: 8px; }
dl.statement .sub { color: var(--muted); font-weight: 400; font-size: 14px; padding-inline-start: 12px; }
dl.statement dd.sub { padding: 0; }
dl.statement .sum { font-weight: 600; color: var(--ink); border-top: 1px dashed var(--line); padding-top: 6px; }
dl.statement .sum.big { font-family: var(--f-display); font-size: 20px; }
dl.statement dt small { color: var(--muted); font-weight: 400; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border: 0; }
.feed .feed-l { display: grid; gap: 2px; min-width: 0; }
.feed .feed-l span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.feed-r { text-align: end; display: grid; }
.feed-r .num { font-weight: 600; }
.feed-r small { color: var(--muted); }

/* ---------- النماذج ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field[hidden] { display: none; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.field.check { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
.field.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
.field small { color: var(--muted); font-size: 12px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); font-size: 16px; }
textarea { min-height: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 0; border-color: var(--brand); }
input[type="date"], input[type="datetime-local"] { direction: ltr; text-align: end; }
.hint-num { color: var(--brand); font-weight: 600; direction: ltr; text-align: end; display: block; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.hint-date { color: var(--muted); font-size: 12px; text-align: end; display: block; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.calc { min-height: 44px; display: flex; align-items: center; justify-content: flex-end; padding: 0 10px; background: var(--surface-2); border-radius: var(--r-ctl); font-weight: 600; direction: ltr; font-variant-numeric: tabular-nums; }
.txn-form { display: grid; gap: 12px; }
/* قايمة العمليات المخصوصة */
.op-picker { position: relative; }
.op-btn { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); cursor: pointer; text-align: start; font-size: 16px; }
.op-picker.open .op-btn, .op-btn:focus-visible { border-color: var(--brand); outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 0; }
.op-cur { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.op-caret { color: var(--muted); font-size: 14px; }
.op-list { position: absolute; z-index: 15; top: calc(100% + 4px); inset-inline: 0; max-height: min(60vh, 460px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 4px 0 8px; box-shadow: 0 10px 28px rgba(15, 22, 20, .18); }
.op-group { font-family: var(--f-display); font-size: 17px; font-weight: 700; color: var(--ink); padding: 14px 14px 4px; border-top: 1px solid var(--line); margin-top: 6px; }
.op-group:first-child { border-top: 0; margin-top: 0; padding-top: 8px; }
.op-opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 14px 6px 14px; padding-inline-start: 26px; border: 0; background: transparent; cursor: pointer; text-align: start; font-size: 14px; font-weight: 400; color: var(--muted); }
.op-opt:hover, .op-opt:focus-visible { background: var(--surface-2); color: var(--ink); outline: none; }
.op-opt.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.dot { --cc: var(--c-tr); width: 8px; height: 8px; border-radius: 50%; background: var(--cc); flex: none; display: inline-block; }
.dot.g-sales, .dot.g-other_in { --cc: var(--in); }
.dot.g-opex, .dot.g-staff { --cc: var(--c-ops); }
.dot.g-ads { --cc: var(--c-ads); }
.dot.g-supplier, .dot.g-goods { --cc: var(--c-sup); }
.dot.g-outside { --cc: var(--warn); }
.review { border-radius: var(--r-ctl); padding: 10px 12px; background: var(--surface-2); font-size: 14px; }
.review ul { margin: 4px 0 0; padding-inline-start: 18px; }
.review.ok { background: var(--in-soft); color: var(--in); }
.review.bad { background: var(--out-soft); color: var(--out); }
.review.warn { background: var(--warn-soft); color: var(--warn); }
.form-err { color: var(--out); font-weight: 600; min-height: 1.2em; }
.stack { display: grid; gap: 10px; }
.month-sel { min-width: 160px; }
.f { display: grid; gap: 2px; min-width: 0; }
.f > span { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ---------- التابات ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 3px; background: var(--surface-2); border-radius: var(--r-ctl); scrollbar-width: none; width: fit-content; max-width: 100%; }
.tab { border: 0; background: transparent; border-radius: 6px; padding: 6px 14px; font-weight: 500; white-space: nowrap; cursor: pointer; min-height: 36px; color: var(--muted); }
.tab.on { background: var(--surface); color: var(--brand); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }

/* ---------- الجداول (من غير ظل) ---------- */
.dt { display: grid; gap: 10px; min-width: 0; }
.dt-title { font-size: 16px; }
.dt-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.dt-bar .f { flex: 1 1 130px; max-width: 220px; }
.dt-bar .f.grow { flex: 2 1 180px; max-width: none; }
.dt-bar input, .dt-bar select { min-height: 38px; font-size: 14px; padding: 4px 8px; }
.dt-tools { display: flex; gap: 8px; align-items: center; margin-inline-start: auto; }
.dt-info { color: var(--muted); font-size: 13px; }
.dt-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-ctl); -webkit-overflow-scrolling: touch; max-height: 70vh; box-shadow: none; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; vertical-align: middle; }
.tbl thead th { position: sticky; top: 0; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); z-index: 1; }
.tbl th.n, .tbl td.n { text-align: end; }
.tbl td.n .num { font-weight: 500; }
.tbl td.wrap { white-space: normal; min-width: 160px; max-width: 320px; }
.tbl td.hl { background: color-mix(in srgb, var(--brand-soft) 55%, transparent); font-weight: 600; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tbl tr.warn td:first-child { box-shadow: inset -3px 0 0 var(--warn); }
.tbl tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--line); }
.tbl td.empty { text-align: center; color: var(--muted); padding: 24px; }
.tbl td.act { width: 1%; padding: 2px 4px; }
.dt [onclick] { cursor: pointer; }

/* جدول تحصيل الشركات */
.grid-wrap { max-height: 75vh; }
.tbl.grid th, .tbl.grid td { padding: 6px 8px; border-inline-start: 1px solid var(--line); }
.tbl.grid .sticky { position: sticky; right: 0; background: var(--surface); z-index: 2; min-width: 120px; }
.tbl.grid thead .sticky { z-index: 3; background: var(--surface-2); }
.tbl.grid th.day { text-align: center; min-width: 64px; line-height: 1.2; }
.tbl.grid th.day small { display: block; font-weight: 400; font-size: 11px; }
.tbl.grid th.cday { color: var(--brand); }
.tbl.grid td.paid { background: var(--in-soft); color: var(--in); font-weight: 600; }
.tbl.grid td.tot { font-weight: 600; background: var(--surface-2); }
.tbl.grid tfoot .sticky { background: var(--surface-2); }

/* ---------- النوافذ والرسايل ---------- */
.modal-wrap { position: fixed; inset: 0; background: var(--scrim); z-index: 50; display: grid; place-items: end center; }
.modal { background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: var(--r-card) var(--r-card) 0 0; display: grid; grid-template-rows: auto 1fr auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 14px; white-space: pre-line; }
.modal-body .form-grid { grid-template-columns: 1fr; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.modal-foot:empty { display: none; }
@media (min-width: 700px) { .modal-wrap { place-items: center; padding: 20px; } .modal { border-radius: var(--r-card); } .modal-body .form-grid { grid-template-columns: 1fr 1fr; } }
#toasts { position: fixed; bottom: calc(128px + env(safe-area-inset-bottom, 0px)); inset-inline: 0; display: grid; justify-items: center; gap: 6px; z-index: 60; pointer-events: none; }
@media (min-width: 960px) { #toasts { bottom: 24px; } }
.toast { background: var(--toast-bg); color: var(--toast-ink); padding: 10px 16px; border-radius: var(--r-ctl); font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); transition: opacity .4s; }
.toast.err { background: var(--out); color: #fff; }
.toast.hide { opacity: 0; }
pre { white-space: pre-wrap; font-size: 12px; direction: ltr; }
@media (prefers-reduced-motion: reduce) { .nav, .toast { transition: none; } }

/* ---------- الجداول على الموبايل: كل سطر كارت ---------- */
@media (max-width: 640px) {
  .dt-scroll:has(.resp) { max-height: none; overflow: visible; border: 0; }
  .tbl.resp, .tbl.resp tbody, .tbl.resp tfoot { display: block; }
  .tbl.resp thead { display: none; }
  .tbl.resp tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); }
  .tbl.resp tr.warn { border-inline-start: 3px solid var(--warn); }
  .tbl.resp tr.warn td:first-child { box-shadow: none; }
  .tbl.resp td { display: grid; gap: 0; padding: 0; border: 0; white-space: normal; text-align: start; min-width: 0; justify-items: start; }
  .tbl.resp td.n { text-align: start; }
  .tbl.resp td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500; }
  .tbl.resp td.e, .tbl.resp tbody td.z { display: none; }
  .tbl.resp td.ttl { grid-column: 1 / -1; font-size: 15px; font-weight: 600; color: var(--ink); padding-bottom: 2px; }
  .tbl.resp td.ttl::before { content: none; }
  .tbl.resp td.keyamt .num { font-family: var(--f-display); font-size: 17px; font-weight: 600; }
  .tbl.resp td.hl { background: none; }
  .tbl.resp td.wrap, .tbl.resp td.act { grid-column: 1 / -1; max-width: none; min-width: 0; }
  .tbl.resp td.act { width: auto; border-top: 1px dashed var(--line); padding-top: 4px; justify-items: stretch; }
  .tbl.resp td.act::before, .tbl.resp td.ft::before, .tbl.resp td.empty::before { content: none; }
  .tbl.resp td.act .acts { justify-content: flex-start; }
  .tbl.resp td.empty { grid-column: 1 / -1; justify-items: center; }
  .tbl.resp tbody tr:hover { background: var(--surface); }
  .tbl.resp tfoot tr { background: var(--brand-soft); border-color: transparent; }
  .tbl.resp tfoot td { position: static; background: none; border: 0; }
  .tbl.resp tfoot td.ft { grid-column: 1 / -1; font-weight: 600; }
}
@media (min-width: 700px) {
  .op-list { inset-inline-end: auto; width: min(100%, 420px); }
  .op-btn { max-width: 100%; }
}

/* ---------- المرحلة 1: الشركا والعهدة والتنبيهات ---------- */
.chip.g-partner { --cc: var(--brand); }
.chip.g-custody { --cc: var(--c-cust); }
.dot.g-partner { --cc: var(--brand); }
.dot.g-custody { --cc: var(--c-cust); }
.alerts { gap: 10px; border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.alert-row { display: grid; gap: 6px; }
.alert-row b { font-weight: 600; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.prod-list { list-style: none; margin: 0; padding: 0; display: grid; }
.prod-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.prod-list li:last-child { border: 0; }
.prod-list .pl-n { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.person-hero .toolbar .btn { background: var(--hero-ink); color: var(--hero-bg); border-color: transparent; }
.person-hero .toolbar .btn:not(.primary) { background: transparent; color: var(--hero-ink); border-color: var(--hero-line); }
.review.ok ul { margin-top: 4px; }

/* ---------- المرحلة 2: المنتجات وتفصيل الرصيد ---------- */
.prod-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 10px; }
.prod-card { display: grid; gap: 8px; text-align: start; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); cursor: pointer; color: var(--ink); min-width: 0; }
.prod-card:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); background: color-mix(in srgb, var(--brand-soft) 35%, var(--surface)); }
.prod-card.off { opacity: .6; }
.pc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pc-head b { font-family: var(--f-display); font-size: 16px; font-weight: 600; }
.pc-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.pc-nums div { display: grid; }
.pc-nums small { color: var(--muted); font-size: 12px; }
.pc-nums .num { font-family: var(--f-display); font-size: 17px; font-weight: 600; }
.hero .num.in, .hero .num.out, .hero .num.zero { color: var(--hero-ink); }
.hero-sub { display: flex; gap: 6px; align-items: baseline; color: var(--hero-muted); }
.hero-sub .num { color: var(--hero-ink); font-weight: 600; }
.hero .chips .chip { background: var(--surface); }
.prod-hero .toolbar .btn, .person-hero .toolbar .btn { background: transparent; color: var(--hero-ink); border-color: var(--hero-line); }
.prod-hero .toolbar .btn.primary, .person-hero .toolbar .btn.primary { background: var(--hero-ink); color: var(--hero-bg); border-color: transparent; }
.meter .bar i.prof { background: var(--in); }
.meter .bar i.del { background: var(--brand); }
.bd-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.bd-sum > div { display: grid; gap: 2px; background: var(--surface-2); border-radius: var(--r-ctl); padding: 8px 12px; }
.bd-sum > div span:first-child { color: var(--muted); font-size: 12px; }
.bd-sum .num { font-family: var(--f-display); font-size: 18px; font-weight: 600; }
.bd-sum .tot { background: var(--brand-soft); }
.bd-list { display: grid; border-top: 1px solid var(--line); }
.bd-group { border-bottom: 1px solid var(--line); }
.bd-group summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 2px; cursor: pointer; list-style: none; }
.bd-group summary::-webkit-details-marker { display: none; }
.bd-group summary::before { content: "‹"; color: var(--muted); transition: transform .15s; display: inline-block; }
.bd-group[open] summary::before { transform: rotate(-90deg); }
.bd-group summary .num { font-family: var(--f-display); font-weight: 600; font-size: 16px; }
.bd-l { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; flex: 1; min-width: 0; }
.bd-l small { color: var(--muted); }
.bd-items { list-style: none; margin: 0 0 10px; padding: 0 0 0 0; padding-inline-start: 16px; display: grid; border-inline-start: 2px solid var(--line); }
.bd-items li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; }
.bd-items .muted { font-size: 12.5px; }
@media (prefers-reduced-motion: reduce) { .bd-group summary::before { transition: none; } }

/* ---------- مزامنة الإعلانات ---------- */
.sync-list { display: grid; gap: 10px; }
.sync-src { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 10px 12px; display: grid; gap: 8px; min-width: 0; }
.sync-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.sync-head b { font-family: var(--f-display); font-weight: 600; }
.sync-head .acts { margin-inline-start: auto; }
.sync-tabs { list-style: none; margin: 0; padding: 0; display: grid; }
.sync-tabs li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 6px 0; border-top: 1px dashed var(--line); align-items: center; }
.sync-tabs li > small { grid-column: 1; font-size: 12px; overflow-wrap: anywhere; }
.sync-tabs li > .acts { grid-column: 2; grid-row: 1 / span 2; }
.st-l { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.sa-email { font-size: 12px; direction: ltr; user-select: all; overflow-wrap: anywhere; }
.cell-flag { display: inline-flex; align-items: center; gap: 4px; }
.flag { color: var(--warn); font-size: 12px; }
.alert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }

/* ---------- المرحلة 3: ثروتي والصلاحيات ---------- */
.wealth-list { list-style: none; margin: 0; padding: 0; display: grid; }
.wealth-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.wealth-list li[role="link"] { cursor: pointer; }
.wealth-list li[role="link"]:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.wealth-list .wl-l { display: grid; gap: 2px; min-width: 0; }
.wealth-list .wl-l b { font-weight: 600; }
.wealth-list .wl-l small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.wealth-list .num { font-family: var(--f-display); font-size: 17px; font-weight: 600; }
.wealth-list li.tot { border-bottom: 0; border-top: 2px solid var(--line); margin-top: 4px; }
.wealth-list li.tot .num { font-size: 24px; font-weight: 700; color: var(--brand); }
.gold-prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; align-items: end; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 6px 12px; }
.perm { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-ctl); cursor: pointer; min-width: 0; }
.perm input { width: 20px; height: 20px; min-height: 0; flex: none; accent-color: var(--brand); }
.inline-sel { min-height: 34px; padding: 2px 8px; font-size: 14px; width: auto; max-width: 100%; }
.hero p.hero-sub { margin: 0; font-size: 13px; }

/* ---------- المرحلة 4: الأملاك ورسم الثروة ---------- */
.wchart-wrap { position: relative; }
.wchart { width: 100%; height: auto; display: block; direction: ltr; }
.wchart .grid { stroke: var(--line); stroke-width: 1; }
.wchart .axis { stroke: color-mix(in srgb, var(--muted) 55%, var(--line)); stroke-width: 1; }
.wchart .tick { fill: var(--muted); font-size: 11px; font-family: var(--f-body); }
.wchart .vlabel { fill: var(--ink); font-size: 12px; font-weight: 600; font-family: var(--f-display); }
.wchart .bar { fill: color-mix(in srgb, var(--brand) 55%, var(--surface)); }
.wchart .bar.last { fill: var(--brand); }
.wchart .hit { fill: transparent; cursor: pointer; outline: none; }
.wchart .hit:hover + .bar, .wchart .hit:focus-visible { stroke: var(--brand); stroke-width: 1; }
.wtip { position: absolute; top: 4px; width: 140px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 6px 10px; font-size: 13px; box-shadow: 0 6px 16px rgba(0, 0, 0, .12); pointer-events: none; display: grid; gap: 2px; }
.wtip .num { font-family: var(--f-display); font-weight: 600; font-size: 15px; }

/* ---------- المرحلة 5: قفل الشهر والقبض ---------- */
.close-box { display: grid; gap: 10px; }
.close-box h4, .card h4 { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--text-2, inherit); }
.mini-tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.mini-tbl th { text-align: start; font-weight: 500; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.mini-tbl td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.mini-tbl td:not(:first-child), .mini-tbl th:not(:first-child) { text-align: end; white-space: nowrap; }
.close-status { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.close-status li { line-height: 1.6; }
.hist-list, .pay-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.hist-list li { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.pay-list li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
tr.dim td { opacity: .55; }
@media (max-width: 640px) { .mini-tbl { font-size: 13px; } .mini-tbl th, .mini-tbl td { padding: 6px 2px; } }
