/* «مصاريف» بشكل جرام فلو: رماديات Tailwind + أخضر الهوية. الخط Cairo محلي (CSP = 'self'). فاتح/غامق حسب الجهاز. */
@font-face { font-family: 'Cairo'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('/fonts/cairo-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Cairo'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('/fonts/cairo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f9fafb; --surface: #fff; --surface-2: #f3f4f6; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb; --line-strong: #d1d5db;
  --brand: #0b6b5a; --brand-hover: #095647; --brand-ink: #fff; --brand-text: #0b6b5a; --brand-soft: #e7f5f1; --brand-soft-line: #b9e3d8;
  --up: #007930; --down: #c10007; --warn-bg: #fffbeb; --warn-fg: #b45309; --red-bg: #fef2f2; --green-bg: #dcfce7;
  --radius: 12px; --radius-sm: 8px; --font: 'Cairo', system-ui, sans-serif; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111827; --surface: #1f2937; --surface-2: #374151; --text: #f3f4f6; --muted: #9ca3af; --line: #374151; --line-strong: #4b5563;
    --brand: #14a38a; --brand-hover: #10896f; --brand-ink: #04211c; --brand-text: #4cd1b8; --brand-soft: #0f2f2a; --brand-soft-line: #14534a;
    --up: #4ade80; --down: #f87171; --warn-bg: #3b2f12; --warn-fg: #fbbf24; --red-bg: #3b1519; --green-bg: #12331f; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html[data-fs="1"] { zoom: 1.1; } html[data-fs="2"] { zoom: 1.2; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.6; padding-bottom: calc(64px + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent; }
a { color: var(--brand-text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; inset-inline-start: -999px; } .skip:focus { inset-inline-start: 8px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 99; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* البار العلوي */
.topbar { position: sticky; top: 0; z-index: var(--ds-z-topbar, 30); background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: var(--ds-page-2xl, 42rem); margin: 0 auto; display: flex; align-items: center; gap: 4px; padding: 6px 8px; min-height: 42px; }
.brand { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--brand-text); font-weight: 700; }
.slot-nav, .bar-actions { display: flex; gap: 4px; min-width: 28px; }
.bar-btn { width: 28px; height: 28px; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 0; }
.bar-btn:hover { background: var(--surface-2); } .bar-btn svg { width: 16px; height: 16px; }
.sysbar { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 12px; font-size: 12px; color: #fff; background: var(--brand); }
.sysbar.update { background: #059669; } .sysbar button { background: rgba(255,255,255,.2); color: #fff; border: 0; border-radius: 8px; padding: 2px 10px; }

.page { max-width: var(--ds-page-2xl, 42rem); margin: 0 auto; padding: 12px var(--ds-page-pad-x, 14px); }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }
.spinner { display: inline-block; width: 16px; height: 16px; margin-inline-end: 8px; border: 2px solid var(--line-strong); border-top-color: var(--brand); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* المكوّنات */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.card h2, .page h2 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1 1 auto; min-width: 0; }
.btn { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: var(--radius-sm); min-height: 44px; padding: 0 16px; font-weight: 600; }
.btn:hover { background: var(--brand-hover); } .btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); }
.btn.danger { background: var(--down); color: #fff; } .btn.sm { min-height: 34px; padding: 0 10px; font-size: 13px; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: 16px; }
.field { display: block; margin-bottom: 10px; } .field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; } .chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: 999px; padding: 3px 12px; font-size: 13px; min-height: 32px; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.tag { display: inline-block; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 0 9px; font-size: 12px; color: var(--text); min-height: 24px; line-height: 22px; }
button.tag { cursor: pointer; } .tag.ent { background: var(--brand-soft); border-color: var(--brand-soft-line); color: var(--brand-text); }
.tag.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; } .tag.pri-ضروري { background: var(--green-bg); } .tag.pri-تحسيني { background: var(--warn-bg); }

/* الإدخال السريع */
.quick { position: relative; }
.quick form { display: flex; gap: 8px; }
.quick .input { font-size: 18px; min-height: 52px; }
.quick .btn { min-height: 52px; }
.prev { min-height: 28px; margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.prev .amt { font-weight: 700; font-size: 16px; }
.err { color: var(--down); }

/* الحركات */
.list { list-style: none; margin: 0; padding: 0; }
.item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; text-align: start; width: 100%; background: none; border: 0; padding: 0; }
.item .desc { font-weight: 600; overflow-wrap: anywhere; } .item .amt { font-weight: 700; white-space: nowrap; }
.item .amt.in { color: var(--up); } .item .amt.out { color: var(--text); }
.item .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; align-items: center; }
.day { font-size: 12px; color: var(--muted); margin: 14px 0 2px; font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.kpi b { display: block; font-size: 18px; } .kpi.in b { color: var(--up); } .kpi.neg b { color: var(--down); }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; } .bar > i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 99px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; } .tbl th, .tbl td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: start; } .tbl td.n, .tbl th.n { text-align: end; }
details > summary { cursor: pointer; padding: 6px 0; list-style: revert; }

/* الشريط السفلي */
.tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 35; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; text-align: center; padding: 8px 0 6px; text-decoration: none; color: var(--muted); font-size: 12px; min-height: 52px; }
.tabbar a svg { display: block; margin: 0 auto 2px; width: 20px; height: 20px; } .tabbar a.on { color: var(--brand-text); font-weight: 700; }

/* شيت سفلي */
.sheet { position: fixed; inset: 0; z-index: var(--ds-z-modal, 60); background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-in { background: var(--surface); width: 100%; max-width: 42rem; max-height: 90vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); }
.sheet-in h3 { margin: 0 0 10px; font-size: 16px; }
.opts { display: grid; gap: 6px; } .opt { text-align: start; background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-sm); min-height: 44px; padding: 6px 12px; } .opt.on { border-color: var(--brand); background: var(--brand-soft); }
.alloc { display: grid; grid-template-columns: 1fr 110px 36px; gap: 6px; margin-bottom: 6px; align-items: center; }
.toast { position: fixed; inset-inline: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 80; background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; text-align: center; max-width: 30rem; margin-inline: auto; }
.login { max-width: 22rem; margin: 40px auto 0; }
.w100 { width: 100%; } .w110 { width: 110px; } .m0 { margin: 0; } .center0 { text-align: center; margin: 0; }
.mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; } .mt10 { margin-top: 10px; } .mb8 { margin-bottom: 8px; } .my8 { margin: 8px 0; }
