/* سقف — واجهة عربية RTL، موبايل أولًا */
:root {
  --bg: #f3f1ea; --card: #ffffff; --ink: #13241f; --muted: #68776f; --line: #e8e4d9; --chip: #ecefe9;
  --g1: #08342c; --g2: #12705d; --gold: #c9a24a; --pos: #16895f; --neg: #c4452f; --warn: #d98a1d;
  --shadow: 0 1px 2px rgba(19,36,31,.05), 0 8px 24px -12px rgba(19,36,31,.14);
  --r: 20px; --nav-h: 68px;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1310; --card: #121e19; --ink: #edf3ef; --muted: #8aa196; --line: #213229; --chip: #1a2a23;
    --g1: #0b3d33; --g2: #15806a; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55;
  font-variant-numeric: tabular-nums; min-height: 100vh; min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; }
.num { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.ic { width: 22px; height: 22px; flex: none; }
.ic.sm { width: 18px; height: 18px; } .ic.xs { width: 15px; height: 15px; }

#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
.boot { display: grid; place-items: center; height: 80vh; }
.mark { width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(145deg, var(--g1), var(--g2)); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.88); opacity: .6; } }

/* ---------- رأس الصفحة ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 2px 14px; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -.2px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(145deg, var(--g1), var(--g2)); display: grid; place-items: center; color: var(--gold); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-size: 13.5px; font-weight: 500; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow); }
.iconbtn:active, .pill:active { transform: scale(.96); }
.row { display: flex; align-items: center; gap: 8px; }
.row.sb { justify-content: space-between; }

/* ---------- البطاقة الرئيسية ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 28px; padding: 22px 22px 20px; color: #f2f7f4;
  background: radial-gradient(120% 90% at 0% 0%, var(--g2) 0%, transparent 60%), linear-gradient(160deg, var(--g1), #062a23 110%);
  box-shadow: 0 18px 40px -18px rgba(8,52,44,.7);
}
.hero::before, .hero::after { content: ""; position: absolute; border: 1.5px solid rgba(201,162,74,.28); border-radius: 50%; pointer-events: none; }
.hero::before { width: 260px; height: 260px; left: -90px; top: -140px; }
.hero::after  { width: 170px; height: 170px; left: -45px; top: -95px; border-color: rgba(201,162,74,.38); }
.hero .lbl { font-size: 13.5px; opacity: .78; display: flex; align-items: center; gap: 6px; }
.hero .big { font-size: 46px; font-weight: 700; letter-spacing: -1.2px; line-height: 1.15; margin: 6px 0 2px; }
.hero .big small { font-size: 17px; font-weight: 500; opacity: .75; margin-inline-start: 6px; letter-spacing: 0; }
.hero .big.neg { color: #ffb4a6; }
.hero .split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.hero .stat { background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.1); border-radius: 16px; padding: 10px 12px; }
.hero .stat > span { font-size: 12.5px; opacity: .75; display: flex; align-items: center; gap: 5px; }
.hero .stat b { font-size: 19px; font-weight: 600; display: block; margin-top: 2px; }
.ceil { margin-top: 16px; }
.ceil .meta { display: flex; justify-content: space-between; font-size: 12.5px; opacity: .85; margin-bottom: 7px; }
.bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.14); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #8fe0bf, var(--gold)); transition: width .8s cubic-bezier(.2,.7,.2,1); }
.bar.warn i { background: linear-gradient(90deg, #ffd27a, #ff9a52); }
.bar.over i { background: #ff7a63; }
.hero .foot { margin-top: 14px; font-size: 13px; opacity: .8; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- أقسام ---------- */
.sec { margin-top: 26px; }
.sec h3 { margin: 0 2px 10px; font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.sec h3 a, .link { font-size: 13px; font-weight: 500; color: var(--g2); text-decoration: none; cursor: pointer; }
.panel { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px 16px; }
.panel.pad { padding: 16px; }
.chips { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 14px -16px 0; padding: 2px 16px 6px; }
.chips::-webkit-scrollbar { display: none; }
.bank { flex: none; background: var(--card); border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow); min-width: 150px; }
.bank > span { font-size: 12.5px; color: var(--muted); display: block; }
.bank b { font-size: 17px; font-weight: 600; }
.bank small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }

/* ---------- العمليات ---------- */
.tx { display: flex; align-items: center; gap: 12px; padding: 13px 0; width: 100%; text-align: start; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: 0; }
.tx:active { opacity: .6; }
.cico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.tx .mid { flex: 1; min-width: 0; }
.tx .mid b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .mid small { color: var(--muted); font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .amt { font-weight: 600; font-size: 15.5px; white-space: nowrap; text-align: end; }
.tx .amt.in { color: var(--pos); }
.tx .amt small { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.day { font-size: 12.5px; color: var(--muted); font-weight: 500; margin: 20px 4px 6px; display: flex; justify-content: space-between; }
.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty .ic { width: 38px; height: 38px; opacity: .5; margin-bottom: 8px; }
.empty b { color: var(--ink); display: block; margin-bottom: 4px; font-size: 16px; }

.catrow { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.catrow .cico { width: 38px; height: 38px; border-radius: 12px; }
.catrow .mid { flex: 1; }
.catrow .mid .t { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; font-weight: 500; }
.catrow .mid .t span { color: var(--muted); font-weight: 400; }
.mini { height: 6px; border-radius: 9px; background: var(--chip); overflow: hidden; }
.mini i { display: block; height: 100%; border-radius: 9px; }

/* ---------- عناصر التحكم ---------- */
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 14px; padding: 0 14px; box-shadow: var(--shadow); height: 46px; }
.search input { border: 0; outline: 0; background: none; flex: 1; height: 100%; min-width: 0; }
.seg { display: flex; background: var(--chip); border-radius: 13px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 8px 6px; border-radius: 10px; font-size: 13.5px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); font-weight: 600; }
.fchips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 12px -16px 0; padding: 2px 16px; }
.fchips::-webkit-scrollbar { display: none; }
.fchip { flex: none; padding: 7px 13px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-size: 13.5px; color: var(--muted); }
.fchip.on { background: var(--g1); color: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 20px; border-radius: 14px; font-weight: 600; background: linear-gradient(145deg, var(--g1), var(--g2)); color: #fff; box-shadow: 0 8px 18px -8px rgba(8,52,44,.7); }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--chip); color: var(--ink); box-shadow: none; }
.btn.danger { background: #fbe9e5; color: var(--neg); box-shadow: none; }
.btn.sm { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.field { display: block; margin-top: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.inp, select.inp, textarea.inp { width: 100%; height: 48px; padding: 0 14px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--card); outline: 0; transition: border-color .15s; }
textarea.inp { height: auto; padding: 12px 14px; min-height: 110px; resize: vertical; line-height: 1.6; }
.inp:focus { border-color: var(--g2); }
.inp.ltr { direction: ltr; text-align: left; font-size: 13px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.switch small { display: block; color: var(--muted); font-size: 12.5px; }
.tog { width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.tog::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.tog.on { background: var(--g2); }
.tog.on::after { transform: translateX(-20px); }
.copyrow { display: flex; gap: 8px; align-items: stretch; }
.copyrow .inp { flex: 1; min-width: 0; height: 44px; }
.copyrow .iconbtn { height: 44px; width: 44px; box-shadow: none; background: var(--chip); }

/* ---------- التنقل السفلي ---------- */
.nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  padding: 0 12px calc(10px + env(safe-area-inset-bottom)); pointer-events: none;
}
.nav .in {
  pointer-events: auto; width: 100%; max-width: 520px; height: var(--nav-h); display: grid; grid-template-columns: 1fr 1fr 74px 1fr 1fr; align-items: center;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-radius: 24px; box-shadow: 0 10px 34px -10px rgba(8,52,44,.35), 0 0 0 1px var(--line);
}
.nav button.t { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11.5px; color: var(--muted); height: 100%; justify-content: center; font-weight: 500; }
.nav button.t.on { color: var(--g2); font-weight: 600; }
.nav button.t.on .ic { stroke-width: 2.2; }
.fab { width: 56px; height: 56px; border-radius: 20px; margin: 0 auto; background: linear-gradient(145deg, var(--g1), var(--g2)); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 22px -8px rgba(8,52,44,.8); transform: translateY(-14px); }
.fab:active { transform: translateY(-14px) scale(.94); }

/* ---------- نافذة سفلية ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(6,20,16,.5); z-index: 40; animation: fade .2s; backdrop-filter: blur(2px); }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 41; max-width: 560px; margin: 0 auto; max-height: 92dvh; overflow: auto;
  background: var(--bg); border-radius: 26px 26px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .28s cubic-bezier(.2,.8,.2,1);
}
.sheet .grab { width: 42px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 19px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 4px; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 2px; border-radius: 14px; font-size: 11.5px; text-align: center; background: var(--card); border: 1.5px solid transparent; line-height: 1.25; }
.cat .cico { width: 34px; height: 34px; border-radius: 11px; }
.cat.on { border-color: var(--g2); background: color-mix(in srgb, var(--g2) 8%, var(--card)); }

#toast { position: fixed; bottom: calc(var(--nav-h) + 34px + env(safe-area-inset-bottom)); left: 50%; transform: translate(-50%, 20px); background: #0d1f1a; color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 90vw; text-align: center; white-space: pre-line; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- التقارير ---------- */
.pnav { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 14px; }
.pnav .t { text-align: center; font-weight: 700; font-size: 19px; }
.pnav .t small { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { background: var(--card); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); }
.kpi > span { font-size: 12px; color: var(--muted); display: block; }
.kpi b { font-size: 17px; font-weight: 700; display: block; margin-top: 2px; }
.kpi small { font-size: 11.5px; display: block; margin-top: 2px; }
.up { color: var(--neg); } .down { color: var(--pos); }
.donutwrap { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; padding: 14px 4px; }
.donut { position: relative; width: 150px; height: 150px; }
.donut svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.donut .c { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.3; }
.donut .c b { display: block; color: var(--ink); font-size: 18px; }
.legend { display: grid; gap: 7px; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 4px; flex: none; }
.legend > div > span { margin-inline-start: auto; color: var(--muted); }
.archive .tx { cursor: pointer; }
.note { font-size: 12.5px; color: var(--muted); line-height: 1.7; }

/* ---------- الدخول ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 4px; }
.auth .card { width: 100%; background: var(--card); border-radius: 28px; padding: 30px 24px; box-shadow: var(--shadow); text-align: center; }
.auth .logo { width: 68px; height: 68px; margin: 0 auto 14px; border-radius: 22px; background: linear-gradient(145deg, var(--g1), var(--g2)); display: grid; place-items: center; color: var(--gold); }
.auth h1 { margin: 0 0 4px; font-size: 26px; }
.auth p { margin: 0 0 18px; color: var(--muted); }
.auth .inp { text-align: center; }
.err { color: var(--neg); font-size: 13.5px; margin-top: 10px; min-height: 20px; }

/* ---------- الإعدادات ---------- */
.steps { counter-reset: s; margin: 10px 0 0; padding: 0; list-style: none; }
.steps li { counter-increment: s; position: relative; padding: 4px 38px 12px 0; font-size: 14px; line-height: 1.7; }
.steps li::before { content: counter(s); position: absolute; inset-inline-start: auto; right: 0; top: 2px; width: 26px; height: 26px; border-radius: 50%; background: var(--chip); color: var(--g2); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.steps code, code.k { background: var(--chip); padding: 1px 7px; border-radius: 7px; font-size: 12.5px; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.result { margin-top: 12px; background: var(--chip); border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.result dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.result dt { color: var(--muted); } .result dd { margin: 0; font-weight: 500; }

.print-only { display: none; }
@media (min-width: 700px) { body { background: radial-gradient(1000px 500px at 50% -10%, color-mix(in srgb, var(--g2) 14%, transparent), transparent), var(--bg); } }
@media print {
  :root { --bg: #fff; --card: #fff; --ink: #111; --muted: #555; --line: #ddd; --chip: #f1f1f1; --shadow: none; }
  body { background: #fff; padding: 0; }
  .nav, .top, .iconbtn, .pnav .iconbtn, .no-print, #toast, .fab { display: none !important; }
  .print-only { display: block; }
  #app { max-width: none; padding: 0; }
  .panel, .kpi { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .hero { color: #111; background: #f4f4f4 !important; box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sec { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.kpi b small { display: inline; font-size: 12px; font-weight: 400; color: var(--muted); }
.panel .tx .amt .num + small, .tx .amt > small:first-of-type { display: inline; }
.cp { display: inline-flex; align-items: center; gap: 5px; background: color-mix(in srgb, var(--g2) 12%, transparent); color: var(--g2); padding: 2px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; margin: 2px 2px; direction: ltr; unicode-bidi: isolate; }
.cp:active { transform: scale(.96); }
.stephead { margin: 20px 0 2px; font-weight: 700; font-size: 15px; }
