/* داشبورد وقتي للموبايل */
:root {
  /* ألوان لوجو وقتي: الأخضر الداكن والأخضر الفاتح */
  --bg: #F5F7F6; --surface: #FFFFFF; --surface-2: #F2F5F3; --ink: #111916; --ink-2: #3A4540; --muted: #737D78; --line: #E7ECE9;
  --brand: #2F9E72; --brand-2: #23855F; --brand-soft: #E4F3EC; --brand-ink: #1B6E4E; --dark: #16211C; --dark-2: #1F2D27;
  --pos: #23855F; --neg: #D04A35; --neg-soft: #FCEDEA; --warn: #B26A0B; --warn-soft: #FDF3E2; --info: #3466C2; --info-soft: #EAF0FC;
  --violet: #7552CC; --violet-soft: #F1ECFC;
  --radius: 18px; --shadow: 0 1px 2px rgba(17, 25, 22, .04), 0 4px 14px rgba(17, 25, 22, .05);
  --font: 'Cairo', 'Segoe UI', Tahoma, 'Noto Sans Arabic', Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1513; --surface: #161E1B; --surface-2: #1B2521; --ink: #EBF1EE; --ink-2: #C4CEC9; --muted: #8C9893; --line: #24302B;
    --brand: #47B88A; --brand-2: #3AA078; --brand-soft: #18322A; --brand-ink: #93E2C2; --dark: #1A2621; --dark-2: #22322B;
    --pos: #4CC497; --neg: #F08A78; --neg-soft: #3A1F1A; --warn: #E9B35C; --warn-soft: #3A2D16; --info: #8AB4F8; --info-soft: #1B2840;
    --violet: #B49BF2; --violet-soft: #2A2240; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .b { font-weight: 700; } .neg { color: var(--neg); } .pos { color: var(--pos); }
svg { flex-shrink: 0; }

/* ---------- الهيدر ---------- */
header.top {
  position: sticky; top: 0; z-index: 5; color: var(--ink);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line);
}
header.top .logo { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; display: block; }
header.top .ttl { flex: 1; min-width: 0; }
header.top h1 { margin: 0; font-size: 17px; font-weight: 800; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.2px; }
header.top .sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 1px; white-space: nowrap; overflow: hidden; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #A9B3AE; display: inline-block; flex-shrink: 0; }
.dot.on { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.dot.off { background: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.hbtn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.hbtn:active { background: var(--surface-2); }
.hbtn svg { width: 20px; height: 20px; }
.hbtn.spinning { color: var(--brand); border-color: var(--brand); }
.hbtn.spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }

.notice { margin: 12px 16px 0; padding: 10px 12px; border-radius: 12px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice svg { width: 18px; height: 18px; margin-top: 1px; }

main { padding: 14px 16px 8px; max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.section-t { font-size: 13px; font-weight: 700; color: var(--muted); margin: 6px 4px -4px; }

/* ---------- كروت ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.card.hero { border: 0; }
.card-h { padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-h .grow { flex: 1; }
.card-b { padding: 14px 16px; }

.hero { background: var(--dark); color: #fff; border: 0; padding: 20px 20px 18px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; left: -50px; bottom: -70px; width: 200px; height: 200px; border-radius: 50%; border: 18px solid rgba(71, 184, 138, .14); }
.hero .l { font-size: 13px; color: #A9C9B9; }
.hero .v { font-size: clamp(30px, 9.5vw, 38px); font-weight: 800; line-height: 1.2; margin: 4px 0 12px; letter-spacing: -.5px; }
.hero .v small { font-size: .45em; font-weight: 600; color: #A9C9B9; }
.hero .row2 { display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; background: rgba(255, 255, 255, .08); font-size: 12.5px; color: #DCEBE3; }
.pill svg { width: 14px; height: 14px; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
/* لو عدد الكروت فردي: آخر كارت بياخد العرض كله */
.kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 12px; }
.kpis > :last-child:nth-child(odd) > div:nth-child(2) { flex: 1; }
.kpis > :last-child:nth-child(odd) .s { margin: 0; }
@media (min-width: 700px) { .kpis > :last-child:nth-child(odd) { grid-column: auto; } .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi { padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 10px; text-align: right; }
button.kpi { border: 1px solid var(--line); cursor: pointer; font: inherit; color: inherit; }
.kpi .ic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.kpi .ic svg { width: 19px; height: 19px; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi .v { font-size: clamp(17px, 5vw, 21px); font-weight: 800; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.kpi .s { color: var(--muted); font-size: 11.5px; margin-top: -4px; }
.c-green .ic { background: var(--brand-soft); color: var(--brand); }
.c-red .ic { background: var(--neg-soft); color: var(--neg); }
.c-blue .ic { background: var(--info-soft); color: var(--info); }
.c-amber .ic { background: var(--warn-soft); color: var(--warn); }
.c-violet .ic { background: var(--violet-soft); color: var(--violet); }

/* ---------- لستات ---------- */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: right; cursor: pointer; color: inherit; }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .sub { color: var(--muted); font-size: 12.5px; }
.li:active { background: var(--surface-2); }
.li .chev { color: var(--muted); width: 16px; height: 16px; }
.ava { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; background: var(--brand-soft); color: var(--brand-ink); }
.ava.alt { background: var(--info-soft); color: var(--info); }
.ava.red { background: var(--neg-soft); color: var(--neg); }
.ava.amber { background: var(--warn-soft); color: var(--warn); }
.ava svg { width: 19px; height: 19px; }

/* ---------- فورم ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.in { height: 46px; width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--surface); }
.in:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.search { position: relative; }
.search svg { position: absolute; right: 14px; top: 13px; width: 20px; height: 20px; color: var(--muted); }
.search .in { padding-right: 42px; background: var(--surface); box-shadow: var(--shadow); border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn { height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--dark); border-color: var(--dark); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--brand); border-color: var(--brand); color: #08120E; } }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; cursor: pointer; white-space: nowrap; font-weight: 600; }
.chip.on { background: var(--dark); color: #fff; border-color: var(--dark); }
@media (prefers-color-scheme: dark) { .chip.on { background: var(--brand); color: #08120E; border-color: var(--brand); } }
.chk { display: flex; align-items: center; gap: 10px; }
.chk input { width: 20px; height: 20px; accent-color: var(--brand); }

/* ---------- جداول ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { text-align: right; font-weight: 700; color: var(--muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.t td.wrap, .t tr.detail td { white-space: normal; min-width: 170px; }
.t td.n, .t th.n { text-align: left; direction: ltr; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t tr.bold td { font-weight: 700; background: var(--surface-2); }
.t tr.detail td { font-size: 12.5px; color: var(--muted); background: var(--surface-2); padding-top: 4px; padding-bottom: 4px; }
.t tfoot td { font-weight: 800; background: var(--surface-2); }

/* ---------- التنقل ---------- */
nav.bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
nav.bottom button { background: none; border: 0; padding: 6px 2px; font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; border-radius: 12px; font-weight: 600; }
nav.bottom button .ico { width: 52px; height: 30px; border-radius: 99px; display: flex; align-items: center; justify-content: center; transition: background .15s; }
nav.bottom button.on { color: var(--brand); }
nav.bottom button.on .ico { background: var(--brand-soft); }
nav.bottom svg { width: 22px; height: 22px; }

/* ---------- الدخول ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 20px; background: var(--bg); }
.login .brandline { text-align: center; margin-bottom: 22px; }
.login .brandline img { width: 76px; height: 76px; border-radius: 22px; display: block; margin: 0 auto 14px; box-shadow: 0 10px 30px rgba(22, 33, 28, .22); }
.login .brandline h2 { margin: 0; font-size: 24px; font-weight: 800; }
.login .brandline div { color: var(--muted); font-size: 13.5px; }
.login .card { width: 100%; max-width: 400px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.err { color: var(--neg); font-size: 13.5px; background: var(--neg-soft); padding: 9px 12px; border-radius: 10px; }

/* ---------- متفرقات ---------- */
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }
.big { font-size: 28px; font-weight: 800; }
.chart { display: flex; align-items: flex-end; gap: 5px; height: 110px; padding-top: 6px; }
.chart .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.chart .bar { width: 100%; background: var(--brand); opacity: .28; border-radius: 6px 6px 3px 3px; min-height: 3px; }
.chart .b.today .bar { opacity: 1; }
.chart .d { font-size: 9.5px; color: var(--muted); }
.tag { display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; }
.tag.red { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.tag.green { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
#toast { position: fixed; bottom: calc(88px + env(safe-area-inset-bottom)); left: 16px; right: 16px; z-index: 20; display: none; background: var(--ink); color: var(--bg); padding: 13px 16px; border-radius: 14px; text-align: center; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.footer-sig { text-align: center; color: var(--muted); font-size: 11px; padding: 6px 0 10px; }
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: var(--radius); }
@keyframes sh { to { background-position: -200% 0; } }
.spin { padding: 30px; text-align: center; color: var(--muted); }
.amount-in { color: var(--ink); font-weight: 700; }
.amount-out { color: var(--pos); font-weight: 700; }

/* قايمة اختيار فيها بحث */
.in.pick { display: flex; align-items: center; gap: 8px; text-align: right; cursor: pointer; color: var(--ink); font: inherit; }
.in.pick .pick-v { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.in.pick svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.sheet-ov { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .15s; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; max-height: 82vh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.sheet-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; }
.sheet-l { overflow-y: auto; flex: 1; border-top: 1px solid var(--line); }
.sheet-l .li.on { background: var(--surface-2); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 700px) { .sheet-ov { align-items: center; } .sheet { border-radius: 20px; max-height: 70vh; } }
.sheet .search svg { right: 28px; top: 13px; }
