/* ألوان النظام نفسها — لوحتا الفاتح والليلي من ui/theme.py بلا تغيير */
@font-face { font-family: Plex; src: url(../fonts/IBMPlexSansArabic-Regular.ttf); font-weight: 400; }
@font-face { font-family: Plex; src: url(../fonts/IBMPlexSansArabic-SemiBold.ttf); font-weight: 600; }
@font-face { font-family: Plex; src: url(../fonts/IBMPlexSansArabic-Bold.ttf); font-weight: 700; }

:root {
  --ink: #0B0907; --muted: #4A443A; --bg: #F7F5F0; --surface: #FFFFFF; --surface2: #FAF8F3;
  --hover: #FBF7EC; --line: #E3DDD0; --line2: #D6CFC0; --line3: #C0B79F;
  --gold: #9A7B22; --goldHi: #B08E2A; --goldDim: #5E4A0C; --goldSoft: #F3E9CE; --goldSoft2: #F7EFD9;
  --goldRing: #E4C665; --green: #0F5A24; --red: #A33131; --redSoft: #E2C3C3; --redText: #9A1414;
  --disBg: #DED8CB; --disFg: #7C7566; --hdrBg: #F1ECE0; --hdrFg: #1E1A14;
  --sumBg: #FDF3E2; --sumEdge: #E6C68A; --sumInk: #5A3806; --totBg: #1C1A17; --totFg: #FFFFFF;
  --barBg: #2B2723; --barFg: #F3EEE2; --onGold: #FFFFFF;
  --r-card: 12px; --r-ctl: 8px;
}
:root[data-theme="dark"] {
  --ink: #FAF6EE; --muted: #C6BDAB; --bg: #15130F; --surface: #1E1C17; --surface2: #232019;
  --hover: #2A261D; --line: #332E25; --line2: #3E382C; --line3: #554D3C;
  --gold: #C9A227; --goldHi: #E0B93E; --goldDim: #D2AF46; --goldSoft: #3A3120; --goldSoft2: #332B1C;
  --goldRing: #E4C665; --green: #72DE91; --red: #B24A4A; --redSoft: #5E3030; --redText: #FFB3B3;
  --disBg: #2A2721; --disFg: #8C8573; --hdrBg: #272218; --hdrFg: #F1E9D7;
  --sumBg: #302716; --sumEdge: #6E5626; --sumInk: #FFD68C; --totBg: #050504; --totFg: #FFFFFF;
  --barBg: #0F0E0B; --barFg: #F3EEE2; --onGold: #1A1305;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #FAF6EE; --muted: #C6BDAB; --bg: #15130F; --surface: #1E1C17; --surface2: #232019;
    --hover: #2A261D; --line: #332E25; --line2: #3E382C; --line3: #554D3C;
    --gold: #C9A227; --goldHi: #E0B93E; --goldDim: #D2AF46; --goldSoft: #3A3120; --goldSoft2: #332B1C;
    --goldRing: #E4C665; --green: #72DE91; --red: #B24A4A; --redSoft: #5E3030; --redText: #FFB3B3;
    --disBg: #2A2721; --disFg: #8C8573; --hdrBg: #272218; --hdrFg: #F1E9D7;
    --sumBg: #302716; --sumEdge: #6E5626; --sumInk: #FFD68C; --totBg: #050504; --totFg: #FFFFFF;
    --barBg: #0F0E0B; --barFg: #F3EEE2; --onGold: #1A1305;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Plex, "Segoe UI", sans-serif; font-size: 16px; color: var(--ink);
  background: var(--bg); min-height: 100vh; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
.num, input.n { font-variant-numeric: tabular-nums; }
/* الرقم سطرٌ لاتينيّ معزول: «−500.00» لا «500.00−» في السطر العربي */
.num { direction: ltr; unicode-bidi: isolate; }
.line .vals b.num { text-align: right; }
[dir="ltr"] { unicode-bidi: isolate; }

/* ══ الشريط العلوي ══ */
#bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  min-height: 56px;
}
#bar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
#bar .sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.icon-btn {
  min-width: 40px; height: 40px; border-radius: var(--r-ctl); border: 1px solid var(--line2);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; padding: 0 10px; cursor: pointer;
}
.icon-btn:active { background: var(--hover); }

main#view { padding: 12px 12px 96px; max-width: 760px; margin: 0 auto; }

/* ══ الشريط السفلي ══ */
#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button {
  flex: 1; border: 0; background: transparent; padding: 8px 2px 10px; font-size: 12px;
  color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#tabs button .i { font-size: 20px; line-height: 1.2; }
#tabs button.on { color: var(--goldDim); font-weight: 700; }
#tabs button.plus .i {
  background: var(--gold); color: var(--onGold); width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin-top: -18px;
  box-shadow: 0 2px 6px rgba(0,0,0,.25); font-size: 26px;
}
body.no-tabs #tabs { display: none; }
body.no-tabs main#view { padding-bottom: 110px; }

/* ══ البطاقات ══ */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 12px; margin-bottom: 12px;
}
.card > h2, .card .spread > h2, .sec-title {
  margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--goldDim);
  display: flex; align-items: center; gap: 6px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.span2 { grid-column: span 2; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

/* ══ الحقول ══ */
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); min-width: 0; }
label.f > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
input.in, select.in, textarea.in {
  width: 100%; min-height: 44px; border: 1px solid var(--line2); border-radius: var(--r-ctl);
  background: var(--surface); padding: 8px 10px; font-size: 16px; color: var(--ink); outline: none;
}
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--gold); box-shadow: 0 0 0 2px var(--goldRing); }
input.in.n { text-align: center; direction: ltr; }
input.in.hl { background: var(--goldSoft2); font-weight: 700; }
input.in[readonly] { background: var(--surface2); color: var(--muted); }
.pick {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  min-height: 48px; border: 1px solid var(--line2); border-radius: var(--r-ctl);
  background: var(--surface); padding: 6px 12px; text-align: start; cursor: pointer;
}
.pick .ph { color: var(--muted); }

/* ══ الأزرار ══ */
.btn {
  min-height: 46px; border-radius: var(--r-ctl); border: 0; padding: 8px 16px; font-weight: 700;
  background: var(--gold); color: var(--onGold); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; font-size: 16px;
}
.btn:active { background: var(--goldHi); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line2); }
.btn.ghost:active { background: var(--hover); }
.btn.danger { background: var(--red); color: #FFFFFF; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.btn[disabled] { background: var(--disBg); color: var(--disFg); }
.seg { display: flex; border: 1px solid var(--line2); border-radius: var(--r-ctl); overflow: hidden; }
.seg button { flex: 1; min-height: 42px; border: 0; background: var(--surface); font-weight: 600; }
.seg button.on { background: var(--gold); color: var(--onGold); }
.seg button[disabled] { opacity: .55; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip {
  border: 1px solid var(--line2); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; white-space: nowrap; font-size: 14px;
}
.chip.on { background: var(--goldSoft); border-color: var(--gold); color: var(--goldDim); font-weight: 700; }
.switch { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.switch input { width: 22px; height: 22px; accent-color: var(--gold); }

/* ══ الأرقام والأرصدة ══ */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi {
  background: var(--sumBg); border: 1px solid var(--sumEdge); border-radius: var(--r-card);
  padding: 10px 12px; color: var(--sumInk);
}
.kpi b { display: block; font-size: 13px; font-weight: 600; }
.kpi .v { font-size: 20px; font-weight: 700; color: var(--ink); }
.kpi .u { font-size: 12px; color: var(--muted); }
.bal-on { color: var(--red); font-weight: 700; }
.bal-for { color: var(--green); font-weight: 700; }
.badge {
  display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700;
  background: var(--goldSoft); color: var(--goldDim);
}
.badge.ret { background: var(--redSoft); color: var(--redText); }

/* ══ القوائم ══ */
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-card); margin-bottom: 8px; cursor: pointer;
}
.list-item:active { background: var(--hover); }
.list-item .t { font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ══ بنود الفاتورة ══ */
.line {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px;
  background: var(--surface2);
}
.line .top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.line .wo { font-weight: 700; direction: ltr; }
.line .vals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 6px; font-size: 13px; }
.line .vals b { display: block; font-size: 15px; color: var(--ink); }
.act { display: flex; gap: 6px; }
.act button {
  border: 1px solid var(--line2); background: var(--surface); border-radius: 6px;
  min-width: 38px; height: 34px; font-size: 15px;
}
.act button.del { color: var(--redText); border-color: var(--redSoft); }
.note-bar { border-radius: 8px; padding: 8px 10px; font-size: 14px; margin-top: 8px; }
.note-bar.info { background: var(--goldSoft2); border: 1px solid var(--line3); }
.note-bar.warn { background: var(--redSoft); color: var(--redText); border: 1px solid var(--red); }

.totals { background: var(--sumBg); border: 1px solid var(--sumEdge); border-radius: var(--r-card); padding: 10px 12px; }
.totals .spread { padding: 3px 0; }
.totals .grand { border-top: 1px solid var(--sumEdge); margin-top: 4px; padding-top: 6px; font-weight: 700; font-size: 17px; }

/* ══ الشريط السفلي الثابت للحفظ ══ */
.footer-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; background: var(--surface);
  border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 8px;
}
.footer-bar .btn { flex: 1; }
.footer-bar .btn.ghost { flex: 0 0 auto; }

/* ══ الجداول (كشف الحساب) ══ */
.st-row { border-bottom: 1px solid var(--line); padding: 8px 2px; cursor: pointer; }
.st-row:last-child { border-bottom: 0; }
.st-row .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; margin-top: 4px; }
.st-row .cols b { font-size: 14px; }

/* ══ النوافذ السفلية ══ */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; }
.sheet {
  background: var(--surface); width: 100%; max-height: 88vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto;
}
.sheet h3 { margin: 0 0 10px; font-size: 17px; }
.sheet .actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet .actions .btn { flex: 1; }
#toast {
  position: fixed; bottom: 86px; left: 16px; right: 16px; z-index: 60; display: none;
  background: var(--barBg); color: var(--barFg); border-radius: 10px; padding: 12px 14px;
  font-size: 15px; box-shadow: 0 4px 14px rgba(0,0,0,.3); white-space: pre-line;
}
#toast.err { background: var(--red); color: #FFFFFF; }

.preview { border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; background: #FFFFFF; }
.preview iframe { border: 0; transform-origin: top right; display: block; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.quick button {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 14px;
}
.quick button .i { font-size: 22px; }
.quick button:active { background: var(--hover); }

/* ══════════ أيقونات، الممتلكات، الحسابات، التحديث (الألوان نفسها) ══════════ */
.ic { display: inline-flex; align-items: center; justify-content: center; line-height: 0; flex: 0 0 auto; }
.ic svg { display: block; }
.btn .ic, .note-bar .ic, h2 .ic, h3 .ic, summary .ic { vertical-align: -4px; }
.note-bar .ic { display: inline-flex; margin-inline-end: 2px; }
.icon-btn { gap: 4px; font-size: 14px; font-weight: 600; transition: background .15s ease, transform .1s ease; }
.icon-btn:active { transform: scale(.96); }
.bar-logo { width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto; }
.icon-btn.upd { position: relative; }
.icon-btn.upd.dot { border-color: var(--gold); color: var(--goldDim); }
.icon-btn.upd.dot::after {
  content: ""; position: absolute; top: 6px; inset-inline-end: 6px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--surface);
}
.tap { cursor: pointer; }
.link {
  border: 0; background: transparent; color: var(--goldDim); font-weight: 700; font-size: 14px;
  padding: 6px 4px; cursor: pointer;
}
.sec-title.spread { justify-content: space-between; margin-top: 4px; }

/* الشريط السفلي بأيقونات */
#tabs button { transition: color .15s ease; }
#tabs button .i { display: flex; align-items: center; justify-content: center; height: 28px; width: 52px;
  border-radius: 14px; transition: background .2s ease; }
#tabs button.on .i { background: var(--goldSoft); }
#tabs button .l { white-space: nowrap; }
#tabs button.plus .i { width: 50px; height: 50px; border-radius: 50%; margin-top: -20px; background: var(--gold);
  box-shadow: 0 3px 10px rgba(0,0,0,.25); transition: transform .12s ease; }
#tabs button.plus:active .i { transform: scale(.94); }

/* صورة رمزية دائرية في القوائم */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto; display: inline-flex;
  align-items: center; justify-content: center; background: var(--goldSoft); color: var(--goldDim);
  font-weight: 700; font-size: 17px;
}
.avatar.ret { background: var(--redSoft); color: var(--redText); }
.list-item { transition: background .15s ease, transform .1s ease; }
.list-item:active { transform: scale(.99); }
.list-item .ic.muted { color: var(--line3); }
.list-item.col { flex-direction: column; align-items: stretch; gap: 6px; }
.list-item.col .grid3 b { display: block; text-align: right; }
.card .spread > h2 { margin-bottom: 6px; }
.quick button { transition: background .15s ease, transform .1s ease; }
.quick button:active { transform: scale(.97); }
.quick button .i { color: var(--goldDim); height: 26px; display: flex; align-items: center; }
.act button { display: inline-flex; align-items: center; justify-content: center; }
.kpi { transition: transform .1s ease; }
.kpi.tap:active { transform: scale(.98); }
.seg.sm button { min-height: 36px; font-size: 14px; }

/* بلاطات الأرقام */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.stats.in-card { margin-bottom: 0; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.stats.in-card .stat { background: var(--surface2); }
.stat .l { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 700; color: var(--ink); text-align: right; }
.stat .u { font-size: 12px; color: var(--muted); }
.stats > .stat:first-child:nth-last-child(odd) { grid-column: span 2; }
.delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.delta.up { color: var(--green); }
.delta.down { color: var(--redText); }
.badge.grade { background: var(--surface2); border: 1px solid var(--line2); }
.badge.grade.good { color: var(--green); }
.badge.grade.mid { color: var(--goldDim); }
.badge.grade.fair { color: var(--goldHi); }
.badge.grade.bad { color: var(--redText); }
.badge.grade.none { color: var(--muted); }
.meter { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 4px; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--gold); transition: width .5s ease; }
.row-link { padding: 9px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row-link:last-child { border-bottom: 0; }
.row-link:active { background: var(--hover); }

/* الممتلكات: صناديق تُلمس فتُفصَّل */
.boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.box-tile {
  text-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 12px; display: flex; flex-direction: column; gap: 3px; cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.box-tile:active { background: var(--hover); transform: scale(.98); }
.box-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--goldSoft); color: var(--goldDim);
  display: inline-flex; align-items: center; justify-content: center; }
.box-t { font-weight: 700; font-size: 14px; margin-top: 4px; }
.box-v { font-size: 22px; font-weight: 700; color: var(--ink); direction: rtl; }
.box-v .u { font-size: 13px; font-weight: 400; color: var(--muted); }
.box-v.bal-on, .box-v.bal-on .num { color: var(--red); }
.boxes > .box-tile:last-child:nth-child(odd) { grid-column: span 2; }
.avatar.fac { background: var(--hdrBg); color: var(--hdrFg); }
.wages-row { margin-top: 8px; padding: 8px 10px; border-radius: var(--r-ctl); background: var(--sumBg); color: var(--sumInk); }
.wages-row b { font-size: 16px; }
.sheet h3 .ic { vertical-align: -4px; }
.sheet .sec-title { margin-top: 6px; }
/* التحديثات */
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .25s ease; }
.update-card {
  background: var(--goldSoft2); border: 1px solid var(--goldRing); border-radius: var(--r-card);
  padding: 12px; margin: 10px 0;
}
.update-card .ic { color: var(--goldDim); }
.ok-line { display: flex; align-items: center; gap: 6px; color: var(--green); font-weight: 700; margin: 10px 0 4px; }
.publish-card { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.publish-card > b { display: flex; align-items: center; gap: 6px; color: var(--goldDim); }
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { margin-bottom: 4px; }
.steps { margin: 8px 0 10px; padding-inline-start: 22px; line-height: 1.9; }
.steps a { color: var(--goldDim); word-break: break-all; }

/* الترحيب */
.welcome { text-align: center; padding: 28px 8px 8px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.welcome-logo { width: 96px; height: 96px; border-radius: 24px; margin: 0 auto 4px; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.welcome h2 { margin: 0; font-size: 21px; }
.welcome p { margin: 0 0 8px; line-height: 1.8; }

/* حركةٌ ناعمة: دخول الشاشة، ونافذةٌ سفلية تنزلق */
main#view.enter { animation: view-in .22s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sheet-wrap { animation: fade-in .18s ease-out; }
.sheet { animation: sheet-up .24s cubic-bezier(.2,.8,.2,1); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
#toast { animation: fade-in .18s ease-out; }
.btn { transition: background .15s ease, transform .1s ease; }
.btn:active { transform: scale(.98); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* صور الأطقم */
.thumb { object-fit: cover; border-radius: 8px; border: 1px solid var(--line2); background: var(--surface2);
  flex: 0 0 auto; cursor: zoom-in; display: block; }
.thumb.sm { width: 40px; height: 40px; }
.thumb.md { width: 48px; height: 48px; }
.thumb.lg { width: 76px; height: 76px; border-radius: 10px; }
.photo-full { width: 100%; height: auto; border-radius: 12px; display: block; }
.fld { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); min-width: 0; }
.photo-pick { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.photo-btn { min-height: 44px; }
.photo-acts { display: flex; flex-direction: column; align-items: flex-start; }
.line .top { gap: 8px; }
/* المعاينة المرنة (كشف الحساب): الصفحة بعرض الشاشة كما هي */
.preview.fluid iframe { width: 100%; transform: none; }
.preview.fluid { margin-bottom: 12px; }
.kpi .small-v { font-size: 16px; }

/* ══ الرئيسية: لوحات العمليات (بألوان النظام) ══ */
.op-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.op-tile, .wide-tile { font: inherit; color: var(--ink); cursor: pointer; text-align: start;
  transition: transform .1s ease, box-shadow .15s ease; }
.op-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 116px; padding: 14px 12px 12px;
  border-radius: 16px; border: 1px solid var(--sumEdge);
  background: linear-gradient(170deg, var(--goldSoft2), var(--surface) 70%);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.op-tile.fac { border-color: var(--line2); background: linear-gradient(170deg, var(--hdrBg), var(--surface) 70%); }
.op-tile:active, .wide-tile:active { transform: scale(.97); box-shadow: none; }
.op-ic { width: 48px; height: 48px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--gold); color: var(--onGold); flex: 0 0 auto; box-shadow: 0 3px 8px rgba(0,0,0,.15); }
.op-tile.fac .op-ic { background: var(--goldDim); }
.op-t { font-size: 16px; font-weight: 700; display: block; }
.op-h { font-size: 12px; color: var(--muted); display: block; }
.wide-tile {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 12px; margin-bottom: 10px;
  border-radius: 16px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.wide-tile .op-ic { width: 44px; height: 44px; background: var(--goldSoft); color: var(--goldDim); box-shadow: none; }
.wide-tile.today .op-ic { background: var(--sumBg); color: var(--sumInk); }
.op-row .prev-btn { flex: 0 0 auto; margin-inline-start: 4px; }

/* ══ رأس المستند: الحساب والتاريخ بدل الخانات ══ */
.bar-chips { display: flex !important; gap: 6px; margin-top: 3px; align-items: center; }
.chip-btn {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; max-width: 62%;
  border: 1px solid var(--line2); background: var(--surface2); border-radius: 999px; padding: 2px 10px; min-height: 26px;
}
.chip-btn .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-btn .car { color: var(--muted); font-size: 11px; }
.chip-btn.empty { border-color: var(--gold); background: var(--goldSoft2); color: var(--goldDim); }
.chip-btn.date { color: var(--muted); flex: 0 0 auto; }
.date-hidden { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; border: 0; pointer-events: none; }
details.opts { margin-top: 10px; border-top: 1px dashed var(--line2); padding-top: 6px; }
details.opts > summary { cursor: pointer; color: var(--goldDim); font-weight: 600; font-size: 14px; padding: 6px 0; }
details.opts .in { margin-top: 6px; }

/* ══ الممتلكات: ذهب المصانع عندي · ذهبي عند العملاء ══ */
.wide-tile.big { align-items: flex-start; padding: 16px 12px; }
.wide-tile.big .big-v { display: block; font-size: 24px; font-weight: 700; margin: 2px 0; }
.wide-tile.big .big-v .u { font-size: 13px; font-weight: 400; color: var(--muted); }
.wide-tile.big.fac .op-ic { background: var(--goldDim); color: var(--onGold); }
.wide-tile.big.cus .op-ic { background: var(--gold); color: var(--onGold); }

/* ══ بطاقة الراعي: هادئة، تُغلق بلمسة ══ */
.sponsor {
  border: 1px dashed var(--line3); border-radius: 16px; padding: 12px; margin-top: 6px; margin-bottom: 12px;
  background: var(--surface2);
}
.sp-tag { font-size: 11px; font-weight: 700; color: var(--goldDim); background: var(--goldSoft); border-radius: 6px; padding: 1px 8px; }
.sp-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; display: inline-flex; }
.sp-t { font-size: 16px; font-weight: 700; margin-top: 6px; }
.sp-d { font-size: 14px; color: var(--muted); margin-top: 2px; line-height: 1.7; }
.sp-acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.amts { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; justify-content: flex-end; }
.amts .amt { white-space: nowrap; }

/* ══ صور الطقم: أكثر من صورة في الخانة نفسها ══ */
.photo-add { min-height: 44px; display: flex; align-items: center; }
.photo-pick { flex-wrap: wrap; gap: 8px; margin-top: 8px; min-height: 0; }
.ph-item { position: relative; display: inline-block; }
.ph-x {
  position: absolute; top: -6px; inset-inline-start: -6px; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line2); background: var(--surface); color: var(--redText); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.thumb-wrap { position: relative; display: inline-block; flex: 0 0 auto; cursor: zoom-in; }
.thumb-n {
  position: absolute; bottom: -4px; inset-inline-end: -4px; font-size: 11px; font-weight: 700; line-height: 1;
  background: var(--gold); color: var(--onGold); border-radius: 999px; padding: 3px 5px;
}
.photo-fig { margin: 10px 0 0; cursor: zoom-in; }
.photo-fig figcaption { margin-top: 4px; text-align: center; }
.pc-prev { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.no-ph { flex: 0 0 auto; }
.sheet .actions.doc-acts { margin: 4px 0 10px; gap: 6px; }
.sheet .actions.doc-acts .btn { padding: 8px 6px; gap: 4px; white-space: nowrap; min-width: 0; font-size: 15px; }
.wide-tile.big.sets .op-ic { background: var(--goldSoft); color: var(--goldDim); }

/* ══ كشف الحساب: جدولٌ واحد بسيط ══ */
.st-filters { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.st-filters .seg { flex: 0 0 auto; }
.st-filters .seg button { padding: 0 14px; }
.st-period { display: inline-flex; align-items: center; gap: 5px; flex: 1 1 auto; min-width: 0; font: inherit; font-size: 14px; }
.st-period span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.st-bal {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 10px 12px; margin-bottom: 10px;
  border-radius: var(--r-card); background: var(--sumBg); border: 1px solid var(--sumEdge); font-size: 15px;
}
.st-table {
  width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden;
}
.st-table th {
  background: var(--hdrBg); color: var(--hdrFg); font-size: 12px; font-weight: 700; padding: 8px 4px; text-align: start;
}
.st-table td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; font-size: 13px; }
.st-table th:first-child, .st-table td.d { width: 46px; }
.st-table td.d { white-space: nowrap; color: var(--muted); font-size: 12px; }
.st-table td.d small, .st-table td.op small { display: block; font-size: 11px; color: var(--muted); }
.st-table td.op { overflow-wrap: anywhere; }
.st-table td.op small.no { color: var(--goldDim); }
.st-table td.m { white-space: nowrap; }
.st-table td.m .mv { display: block; font-size: 12px; color: var(--muted); }
.st-table td.m b { font-size: 14px; }
.st-table td.m .w { font-size: 11px; color: var(--muted); margin-inline-start: 3px; }
.st-table.dia th:last-child { width: 34%; }
.st-table tr.tap { cursor: pointer; }
.st-table tr.tap:active td { background: var(--hover); }
.st-hint { text-align: center; margin: 8px 0 4px; }
.nowrap { white-space: nowrap; }

/* نافذة «يوجد تحديث جديد» في وسط الشاشة */
.sheet-wrap.center { align-items: center; justify-content: center; padding: 20px; }
.sheet.pop { max-width: 360px; border-radius: var(--r-card); text-align: center; padding: 22px 18px 16px;
  animation: pop-in .26s cubic-bezier(.2,.8,.2,1); }
.sheet.pop h3 { font-size: 20px; margin: 12px 0 4px; }
.pop-logo { width: 84px; height: 84px; border-radius: 22px; display: block; margin: 0 auto; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.pop-notes { margin: 12px 0 14px; line-height: 1.7; white-space: pre-line; text-align: start;
  background: var(--goldSoft2); border: 1px solid var(--goldRing); border-radius: var(--r-card); padding: 10px 12px; }
.sheet.pop .btn.big { font-size: 18px; padding: 14px; margin-top: 4px; }
.sheet.pop .btn.ghost { margin-top: 8px; }
.pop-note { min-height: 1.4em; margin-top: 6px; }
@keyframes pop-in { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }

/* ══ نسخة الويب (الآيفون عبر الرابط) ══ */
/* إعلان AdSense: شريطٌ أسفل الشاشة تحت الشريط السفلي — مرسومٌ خارج الشاشة حتى يصل إعلان */
#webad { position: fixed; left: 0; right: 0; bottom: 0; z-index: 19; background: var(--surface);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); min-height: 50px;
  transform: translateY(110%); visibility: hidden; }
body.web-ad #webad { transform: none; visibility: visible; }
body.web-ad #tabs { bottom: var(--webad-h, 60px); padding-bottom: 0; }
body.web-ad main#view { padding-bottom: calc(96px + var(--webad-h, 60px)); }
/* «احفظ نسخة» — يظهر بعد كل تغييرٍ بثوانٍ وعند الفتح: لمسةٌ تحفظ الملف في «الملفات» (iCloud) */
.web-bk { position: fixed; left: 12px; right: 12px; z-index: 25; max-width: 736px; margin: 0 auto;
  bottom: calc(72px + env(safe-area-inset-bottom) + var(--webad-h, 0px));
  display: flex; align-items: center; gap: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.18);
  animation: sheet-up .24s cubic-bezier(.2,.8,.2,1); }
.web-bk .grow { flex: 1; line-height: 1.5; }
.web-bk .x { border: 0; background: transparent; color: var(--muted); padding: 4px 6px; }
body.no-tabs .web-bk { bottom: calc(16px + env(safe-area-inset-bottom)); }
/* بطاقة «ثبّت ÀUR على الآيفون» */
.install-card ol { margin: 6px 0 0; padding-inline-start: 20px; line-height: 1.9; }

/* ══ الممتلكات 1.9: «صافي ما لي» — بطاقةٌ واحدة تجمع الموقف كلّه ══ */
.net-card { background: var(--sumBg); border: 1px solid var(--sumEdge); border-radius: var(--r-card);
  padding: 14px 14px 10px; margin-bottom: 12px; color: var(--sumInk); }
.net-card .net-t { font-weight: 700; font-size: 15px; }
.net-card .net-v { font-size: 30px; font-weight: 700; margin-top: 4px; color: var(--ink); }
.net-card .net-c { font-size: 18px; font-weight: 700; color: var(--ink); }
.net-card .neg .num { color: var(--red); }
.net-card .u { font-size: 13px; font-weight: 400; color: var(--muted); }
.net-card .seg.net-k button { min-width: 34px; padding: 4px 6px; }
.net-rows { margin: 10px 0 6px; border-top: 1px solid var(--sumEdge); padding-top: 6px; }
.net-row { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 14px; padding: 3px 0; font-size: 14px; color: var(--ink); }
.net-row b { text-align: left; min-width: 72px; }
.net-row.head { font-size: 12px; color: var(--muted); }
.net-row.head span { text-align: left; }
.net-row.head span:first-child { text-align: start; }
.open-cta { display: flex; align-items: center; gap: 8px; width: 100%; text-align: start; font: inherit; color: var(--ink);
  cursor: pointer; margin-bottom: 12px; }
