/* Red Broadcast — محتوى أولاً، أسطح مسطحة، والأحمر للإجراء الرئيسي والتقدّم والحالات الحيّة فقط.
   Roboto للاتيني والأرقام، وNoto Sans Arabic للعربي (Roboto ما فيه حروف عربية). */
:root {
  color-scheme: light;
  --red: #FF0000;
  --red-hover: #CC0000;
  --link: #065FD4;
  --bg: #FFFFFF;
  --surface: #F2F2F2;
  --surface-hover: #E5E5E5;
  --ink: #0F0F0F;
  --muted: #606060;
  --line: #E5E5E5;
  --success: #2BA640;
  --warning: #FB8C00;
  --on-ink: #FFFFFF;
  --badge-red-bg: #FFE5E5;
  --badge-red-ink: #CC0000;
  --badge-ok-bg: #E6F4EA;
  --badge-ok-ink: #1E7B30;
  --purple: #7C3AED;
  --badge-purple-bg: #F1E8FF;
  --badge-purple-ink: #6D28D9;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .1);
  --shadow-3: 0 8px 40px rgba(0, 0, 0, .2);

  --font: 'Roboto', 'Noto Sans Arabic', system-ui, sans-serif;
  --font-mono: 'Roboto Mono', ui-monospace, monospace;

  --r-badge: 2px;
  --r-menu: 4px;
  --r-modal: 8px;
  --r-large: 12px;
  --r-pill: 9999px;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --top-h: 56px;
  --nav-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --link: #3EA6FF;
    --bg: #0F0F0F;
    --surface: #272727;
    --surface-hover: #3F3F3F;
    --ink: #F1F1F1;
    --muted: #AAAAAA;
    --line: #3F3F3F;
    --on-ink: #0F0F0F;
    --badge-red-bg: rgba(255, 0, 0, .18);
    --badge-red-ink: #FF6B6B;
    --badge-ok-bg: rgba(43, 166, 64, .18);
    --badge-ok-ink: #5FD37A;
    --purple: #A855F7;
    --badge-purple-bg: rgba(168, 85, 247, .2);
    --badge-purple-ink: #D8B4FE;
    /* في الداكن: حدود خفيفة بدل الظلال */
    --shadow-1: 0 0 0 1px rgba(255, 255, 255, .05);
    --shadow-3: 0 0 0 1px rgba(255, 255, 255, .08);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
code { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.link { color: var(--link); }
.sar {
  display: inline-block; width: .82em; height: .92em; vertical-align: -.08em; background: currentColor;
  -webkit-mask: url(../img/saudi_riyal.svg) center / contain no-repeat; mask: url(../img/saudi_riyal.svg) center / contain no-repeat;
}

/* ── الهيكل ─────────────────────────────────────────── */
.app { max-width: 640px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + var(--s5)); }
.topbar {
  position: sticky; top: 0; z-index: 5; height: var(--top-h);
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s4); background: var(--bg);
  transition: box-shadow .15s;
}
.topbar.scrolled { box-shadow: var(--shadow-1); }
.topbar h1 { font-size: 20px; line-height: 28px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tb-title p { margin: 0; font-size: 12px; line-height: 16px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-home {
  width: 40px; height: 40px; flex: none; border-radius: var(--r-large);
  display: grid; place-items: center; background: var(--surface); color: var(--ink);
  margin-inline-end: var(--s1); transition: background .15s;
}
.tb-home:hover { background: var(--surface-hover); }
.tb-actions { display: flex; align-items: center; gap: var(--s1); flex: none; }
/* زر الخروج: نفس مربع زر القائمة (tb-home)، أيقونة بس */
.tb-logout { margin-inline-end: 0; }
.tb-logout svg { transform: scaleX(-1); } /* السهم يطلع لجهة الخروج في RTL */
.tb-home:focus-visible, .tb-logout:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.icon-btn, .topbar .back {
  width: 40px; height: 40px; border-radius: var(--r-pill); border: 0; flex: none;
  background: transparent; color: var(--ink); display: grid; place-items: center;
}
.icon-btn:hover, .topbar .back:hover { background: var(--surface); }
.icon-btn { color: var(--muted); }
.page { padding: var(--s2) var(--s4) 0; display: flex; flex-direction: column; gap: var(--s5); }
.stack { display: flex; flex-direction: column; gap: var(--s3); }

.nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.nav-inner { display: flex; width: 100%; max-width: 640px; height: var(--nav-h); align-items: stretch; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; line-height: 14px; color: var(--ink); }
.nav a.on { font-weight: 700; }
.nav a.on svg { stroke-width: 2.5; }
.nav .fab-slot { flex: 1; display: grid; place-items: center; }
.nav .fab {
  width: 48px; height: 36px; border-radius: var(--r-pill);
  background: var(--red); color: #FFFFFF; display: grid; place-items: center;
}
.nav .fab:hover { background: var(--red-hover); }

/* ── العناوين والنصوص ───────────────────────────────── */
.section-title { font-size: 20px; line-height: 28px; font-weight: 500; margin: 0; }
.section-sub { display: block; font-size: 13px; line-height: 18px; font-weight: 400; color: var(--muted); }
.meta { font-size: 12px; line-height: 16px; color: var(--muted); }
.dots > * + *::before { content: '•'; margin: 0 6px; color: var(--muted); }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── البطاقات: مسطحة، بدون ظل ───────────────────────── */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-large); padding: var(--s4); }
.hero-banner { display: block; width: 100%; height: auto; }
.hero { padding: var(--s5) var(--s4); display: flex; flex-direction: column; gap: var(--s1); background: var(--surface); border: 0; }
.hero .label { color: var(--muted); font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .02em; }
.hero .big { font-size: 36px; line-height: 44px; font-weight: 700; }
.hero .big small { font-size: 14px; font-weight: 400; color: var(--muted); margin-inline-start: var(--s1); }
.hero.clear .big { font-size: 24px; line-height: 32px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
.stat { background: var(--surface); border-radius: var(--r-large); padding: var(--s3) var(--s4); }
.stat .k { font-size: 12px; line-height: 16px; color: var(--muted); }
.stat .v { font-size: 20px; line-height: 28px; font-weight: 500; }
.stat .v.names { font-size: 15px; line-height: 22px; padding-top: 3px; }
.bars { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4); }
.bar-row { display: grid; grid-template-columns: 6.5em 1fr auto; align-items: center; gap: var(--s3); }
.bar-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--surface); border-radius: var(--r-pill); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--red); border-radius: var(--r-pill); }
.bar-val { font-size: 14px; font-weight: 500; min-width: 4.5em; text-align: end; }

.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; min-height: 56px; }
.list > .row + .row { border-top: 1px solid var(--line); }
.card.list { padding: 0 var(--s4); }
.card.row { padding: var(--s3) var(--s4); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-size: 14px; line-height: 20px; font-weight: 500; }
.row .sub { font-size: 12px; line-height: 16px; color: var(--muted); }
.row .amt { font-weight: 500; white-space: nowrap; }

.avatar {
  width: 36px; height: 36px; border-radius: var(--r-pill); flex: none;
  display: grid; place-items: center; font-weight: 500; font-size: 15px;
  background: var(--ink); color: var(--on-ink);
}
.avatar.muted { background: var(--surface); color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: var(--s1); font-size: 12px; line-height: 16px; font-weight: 500; padding: 2px 6px; border-radius: var(--r-badge); white-space: nowrap; letter-spacing: .02em; }
.pill.ok { background: var(--badge-ok-bg); color: var(--badge-ok-ink); }
.pill.due { background: var(--badge-red-bg); color: var(--badge-red-ink); }
.pill.neutral { background: var(--surface); color: var(--muted); }

/* شريط التقدّم — نسبة المسدد من مجموع الجلسة */
.progress { height: 4px; background: var(--surface-hover); border-radius: var(--r-pill); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--red); border-radius: inherit; }
.progress.done > span { background: var(--success); }

/* عنصر جلسة في القائمة: بدون حاوية — أفاتار + عنوان + سطر بيانات + تقدّم */
.session-item { display: flex; gap: var(--s3); padding: var(--s3) 0; align-items: flex-start; }
.session-item + .session-item { border-top: 1px solid var(--line); }
.session-item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.session-item .headline { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); }
.session-item .title { font-size: 14px; line-height: 20px; font-weight: 500; }
.session-item .amount { font-size: 16px; font-weight: 500; white-space: nowrap; }
.session-item .progress { margin-top: var(--s2); }

/* ── الأزرار ─────────────────────────────────────────── */
.btn {
  border: 0; border-radius: var(--r-pill); padding: 0 var(--s4); height: 36px;
  font-size: 14px; line-height: 20px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  background: var(--ink); color: var(--on-ink); white-space: nowrap;
}
.btn.block { width: 100%; height: 44px; }
.btn.ghost { background: var(--surface); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-hover); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--line); }
.btn.sm { height: 32px; padding: 0 var(--s3); font-size: 13px; }
.btn.paid { background: var(--surface); color: var(--ink); }
.btn:disabled { opacity: .4; cursor: default; }

/* ── الحقول ──────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--s2); }
.field > span { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.input {
  height: 44px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: transparent; padding: 0 var(--s1); width: 100%; font-size: 16px; outline: none;
}
.input:focus { border-bottom-color: var(--ink); box-shadow: 0 1px 0 var(--ink); }
.input.big { height: 64px; font-size: 36px; font-weight: 700; text-align: center; }
.input.phone { text-align: center; font-size: 20px; font-weight: 500; letter-spacing: .04em; }
.input.code { letter-spacing: 12px; text-align: center; font-size: 24px; font-weight: 500; font-family: var(--font-mono); }
select.input { appearance: none; background-image: none; }
/* حقل التاريخ يعرض بالإنجليزي: النص ظاهر، والحقل الأصلي شفاف فوقه عشان يفتح منتقي التاريخ */
.date-wrap { position: relative; display: block; }
.date-shown { display: flex; align-items: center; direction: ltr; justify-content: center; }
.date-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }
.date-native::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.date-native:focus + .date-shown, .date-wrap:focus-within .date-shown { border-bottom-color: var(--ink); box-shadow: 0 1px 0 var(--ink); }

/* ── الشرائح ─────────────────────────────────────────── */
.chip-bar { display: flex; gap: var(--s3); overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--s4)); padding: 0 var(--s4); }
.chip-bar::-webkit-scrollbar { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  height: 32px; padding: 0 var(--s3); border-radius: var(--r-pill); border: 0; flex: none;
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { background: var(--surface-hover); }
.chip.on { background: var(--ink); color: var(--on-ink); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-pill); }
.stepper button { width: 36px; height: 32px; border: 0; background: transparent; font-size: 18px; display: grid; place-items: center; color: var(--ink); }
.stepper button:disabled { color: var(--muted); opacity: .5; }
.stepper .n { min-width: 24px; text-align: center; font-weight: 500; border-inline: 1px solid var(--line); line-height: 32px; }

.preview { background: var(--surface); border-radius: var(--r-large); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.preview .line { display: flex; justify-content: space-between; }
.preview .line.total { font-weight: 700; font-size: 16px; padding-top: var(--s2); border-top: 1px solid var(--surface-hover); }

/* ── جلسة جديدة ─────────────────────────────────────── */
.new-session { gap: var(--s4); }
.ns-inputs { background: var(--surface); border-radius: var(--r-large); padding: var(--s5) var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.ns-field { display: flex; flex-direction: column; align-items: center; gap: var(--s2); }
.ns-label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--muted); }
.payer-share { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-radius: var(--r-large); padding: var(--s3) var(--s4); font-size: 14px; }
.payer-share b { font-size: 16px; }
.ns-divider { height: 1px; background: var(--line); margin: 0 var(--s5); }
/* العملة في عمود جانبي عشان الرقم يبقى بالنص بالضبط تحت العنوان */
.amount-wrap { display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline; column-gap: var(--s2); width: 100%; }
.amount-wrap .amount-input { grid-column: 2; }
.amount-wrap .amount-cur { grid-column: 3; justify-self: start; }
.amount-input {
  width: 6ch; min-width: 0; border: 0; background: transparent; outline: none; text-align: center;
  font-size: 44px; line-height: 56px; font-weight: 700; padding: 0;
  border-bottom: 2px solid transparent; transition: border-color .15s;
}
.amount-input:focus { border-bottom-color: var(--ink); }
.amount-input::placeholder { color: var(--surface-hover); }
.amount-cur { font-size: 16px; color: var(--muted); font-weight: 500; }
.counter { display: flex; align-items: center; gap: var(--s4); direction: ltr; }
.counter-btn {
  width: 48px; height: 48px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--bg);
  font-size: 24px; line-height: 1; display: grid; place-items: center; color: var(--ink);
}
.counter-btn:hover:not(:disabled) { background: var(--surface-hover); }
.counter-btn:disabled { opacity: .35; cursor: default; }
.counter-n { width: 3ch; border: 0; background: transparent; outline: none; text-align: center; font-size: 36px; line-height: 44px; font-weight: 700; padding: 0; }

.calc { border: 1px solid var(--line); border-radius: var(--r-large); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.empty-calc { border-style: dashed; text-align: center; color: var(--muted); }
.empty-calc p { margin: var(--s2) 0; font-size: 13px; }
.calc-head { display: flex; align-items: baseline; justify-content: space-between; }
.calc-label { font-size: 14px; font-weight: 500; }
.calc-big { font-size: 32px; line-height: 40px; font-weight: 700; }
.calc-big small { font-size: 14px; font-weight: 400; color: var(--muted); margin-inline-start: var(--s1); }
.calc-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; counter-reset: step; }
.calc-steps li {
  counter-increment: step; display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) 0; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line);
}
.calc-steps li > span:first-child::before {
  content: counter(step); display: inline-grid; place-items: center; width: 18px; height: 18px; margin-inline-end: var(--s2);
  border-radius: var(--r-pill); background: var(--surface); font-size: 11px; font-weight: 700; color: var(--ink);
}
.calc-steps li > .num { color: var(--ink); font-weight: 500; white-space: nowrap; }
.calc-fund {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  background: var(--badge-ok-bg); color: var(--badge-ok-ink); border-radius: var(--r-modal); padding: var(--s3);
}
.calc-fund small { font-size: 12px; opacity: .8; margin-inline-start: var(--s1); }
.calc-fund b { font-size: 18px; }

.ns-details { display: flex; flex-direction: column; gap: var(--s4); }
.ns-guests { display: flex; flex-direction: column; gap: var(--s2); background: var(--surface); border-radius: var(--r-large); padding: var(--s3) var(--s4); }
.ns-guests-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.ns-guests .ns-label { align-self: flex-start; }
.ns-submit {
  position: sticky; bottom: 0; z-index: 4;
  margin: 0 calc(-1 * var(--s4)); padding: var(--s3) var(--s4) calc(var(--s3) + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.btn.lg { height: 52px; font-size: 16px; }

.note { font-size: 12px; line-height: 18px; color: var(--muted); background: var(--surface); padding: var(--s3); border-radius: var(--r-modal); margin: 0; }
.error { color: var(--red); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: var(--s6) var(--s4); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--surface-hover); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; margin: var(--s7) auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── الدخول والتفعيل ────────────────────────────────── */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: var(--s5); padding: var(--s5) var(--s4); max-width: 420px; margin: 0 auto; }
.login .brand { display: flex; align-items: center; justify-content: center; gap: var(--s2); }
.login .brand .mark { width: 48px; height: 48px; border-radius: 12px; display: block; }
.login h1 { text-align: center; margin: 0; font-size: 24px; line-height: 32px; font-weight: 700; }
.login p.lead { text-align: center; color: var(--muted); margin: calc(-1 * var(--s4)) 0 0; }
.linkbox { display: flex; flex-direction: column; gap: var(--s4); }
.qr { background: #fff; border-radius: var(--r-large); padding: var(--s2); width: 200px; margin: 0 auto; line-height: 0; }
.qr svg { width: 100%; height: auto; }
.invite-link { font-family: var(--font-mono); font-size: 12px; word-break: break-all; direction: ltr; text-align: left; }

/* ── النوافذ ─────────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 640px; border-radius: var(--r-large) var(--r-large) 0 0; box-shadow: var(--shadow-3);
  padding: var(--s5) var(--s4) calc(var(--s5) + var(--safe-b)); display: flex; flex-direction: column; gap: var(--s4);
  max-height: 90dvh; overflow-y: auto;
}
.sheet > * { flex-shrink: 0; } /* لما يطول المحتوى ينسحب بدل ما تنضغط الأزرار */
.sheet h2 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 500; }
/* ── المستحقات وصفحة السداد ─────────────────────── */
.dues { display: flex; align-items: center; gap: var(--s3); border-color: var(--badge-red-bg); background: linear-gradient(to left, var(--badge-red-bg), var(--bg) 70%); }
.dues .grow { flex: 1; min-width: 0; }
.dues h2 { margin: 0; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--muted); }
.dues-amount { font-size: 28px; line-height: 36px; font-weight: 700; color: var(--badge-red-ink); }
.dues-amount small { font-size: .55em; }
.dues .sub { font-size: 12px; line-height: 16px; color: var(--muted); }
.dues .btn { flex: none; }
.dues.clear { justify-content: center; border-color: var(--badge-ok-bg); background: linear-gradient(to left, var(--badge-ok-bg), var(--bg) 70%); }
.dues.clear { text-align: center; }
.dues-clear { font-size: 18px; line-height: 28px; font-weight: 700; color: var(--badge-ok-ink); padding-top: var(--s1); }
.dues-clear-sub { font-size: 12px; line-height: 16px; color: var(--muted); padding-bottom: var(--s1); }
/* قطية الاستراحة: نفس بطاقة الصندوق بالبنفسجي */
.dues.rent, .dues.rent.clear { border-color: var(--badge-purple-bg); background: linear-gradient(to left, var(--badge-purple-bg), var(--bg) 70%); }
.dues.rent .dues-amount, .dues.rent .dues-clear, .rent-wait { color: var(--badge-purple-ink); }
.rent-wait { font-size: 18px; line-height: 28px; font-weight: 700; }
.rent .btn, .btn.rent-btn { background: var(--purple); color: #fff; }
.rent .btn:hover, .btn.rent-btn:hover { filter: brightness(1.1); }
.rent-hero { background: linear-gradient(to left, var(--badge-purple-bg), var(--surface) 80%); }
.rent-hero .big { color: var(--badge-purple-ink); }
.rent-month { gap: var(--s2); }
.rent-month-nav { display: flex; align-items: center; justify-content: space-between; margin: calc(-1 * var(--s2)) calc(-1 * var(--s2)) 0; }
.rent-month-nav .label { font-size: 14px; font-weight: 700; color: var(--ink); }
.rent-month-nav .icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.flip svg { transform: scaleX(-1); }
.rent-fill { background: var(--purple); }
.rent-month .bar-track { display: block; background: var(--bg); margin-top: var(--s1); }
.row .btn.sm { flex: none; }
.row-link { border: 0; background: none; padding: 0; text-align: start; cursor: pointer; }
.row-link .title { text-decoration: underline dotted var(--muted); text-underline-offset: 4px; }
.row.cancelled { opacity: .5; }
.row.cancelled .title { text-decoration: line-through; }
.textarea {
  width: 100%; min-height: 120px; resize: vertical; padding: var(--s3); border: 1px solid var(--line);
  border-radius: var(--r-large); background: var(--bg); line-height: 22px;
}
.textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.pay-msg { white-space: pre-wrap; margin-top: var(--s1); color: var(--ink); }

/* ── نافذة التأكيد ─────────────────────────────────── */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: var(--s4);
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade-in .18s ease-out;
}
.dialog {
  width: 100%; max-width: 340px; background: var(--bg); border-radius: 20px; box-shadow: var(--shadow-3);
  padding: var(--s6) var(--s5) var(--s5); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--s2);
  animation: pop-in .22s cubic-bezier(.2, .9, .3, 1.2);
}
.dialog-icon {
  width: 64px; height: 64px; border-radius: var(--r-pill); display: grid; place-items: center; margin-bottom: var(--s2);
  background: var(--badge-red-bg); color: var(--red); box-shadow: 0 0 0 8px color-mix(in srgb, var(--badge-red-bg) 45%, transparent);
}
.dialog-icon.flip svg { transform: scaleX(-1); }
.dialog h2 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; }
.dialog p { margin: 0; font-size: 15px; line-height: 24px; }
.dialog .dialog-hint { font-size: 13px; line-height: 20px; color: var(--muted); }
.dialog-actions { width: 100%; display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s4); }
.btn.danger-fill { background: var(--red); color: #FFFFFF; }
.btn.danger-fill:hover { background: var(--red-hover); }
.dialog .btn:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
/* ── القائمة الجانبية ─────────────────────────────── */
.tb-home { border: 0; position: relative; }
.tb-dot { position: absolute; top: 8px; inset-inline-start: 8px; width: 9px; height: 9px; border-radius: var(--r-pill); background: var(--red); box-shadow: 0 0 0 2px var(--surface); }
.drawer-badge {
  margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--red); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center;
}
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 22; display: flex; justify-content: flex-start;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade-in .18s ease-out;
}
.drawer > * { flex-shrink: 0; }
.drawer {
  width: min(320px, 86vw); height: 100%; background: var(--bg); box-shadow: var(--shadow-3);
  border-radius: var(--r-large) 0 0 var(--r-large); display: flex; flex-direction: column;
  padding: var(--s5) var(--s3) calc(var(--s4) + var(--safe-b)); gap: var(--s4); overflow-y: auto;
  animation: slide-in .24s cubic-bezier(.2, .9, .3, 1);
}
.drawer-head { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2) var(--s4); border-bottom: 1px solid var(--line); }
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-head .title { font-size: 16px; line-height: 24px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-head .sub { font-size: 12px; line-height: 16px; color: var(--muted); }
.drawer-links { display: flex; flex-direction: column; gap: 2px; flex: 1 0 auto; }
.drawer-links a, .drawer-logout {
  display: flex; align-items: center; gap: var(--s3); height: 48px; padding: 0 var(--s3);
  border-radius: var(--r-large); font-size: 15px; font-weight: 500; transition: background .15s, color .15s;
}
.drawer-links a:hover { background: var(--surface); }
.drawer-links a.on { background: var(--badge-red-bg); color: var(--badge-red-ink); font-weight: 700; }
.drawer-logout { border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; }
.drawer-logout svg { transform: scaleX(-1); }
.drawer-logout:hover { color: var(--red); border-color: var(--red); background: var(--badge-red-bg); }
.drawer a:focus-visible, .drawer-logout:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }
@keyframes slide-in { from { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.94); } }
@media (prefers-reduced-motion: reduce) { .dialog-backdrop, .dialog, .drawer-backdrop, .drawer { animation: none; } }

.toast {
  position: fixed; z-index: 30; inset-inline: var(--s4); bottom: calc(var(--nav-h) + var(--safe-b) + var(--s4));
  max-width: 400px; margin: 0 auto; background: #0F0F0F; color: #FFFFFF;
  padding: var(--s3) var(--s4); border-radius: var(--r-modal); font-size: 14px; text-align: center; box-shadow: var(--shadow-3);
}
@media (prefers-color-scheme: dark) { .toast { background: #F1F1F1; color: #0F0F0F; } }
.toast.err { background: var(--red); color: #fff; }

.split { display: flex; gap: var(--s3); }
.split > * { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.danger-text { color: var(--red); }
.ok-text { color: var(--success); }

/* ── إعدادات النظام ─────────────────────────────── */
.setting { align-items: center; }
.setting .sub { margin-top: 2px; }
.switch {
  flex: none; width: 48px; height: 28px; border-radius: var(--r-pill); border: 0; padding: 3px;
  background: var(--surface-hover); display: flex; transition: background .15s;
}
.switch span { width: 22px; height: 22px; border-radius: 50%; background: var(--bg); box-shadow: var(--shadow-1, 0 1px 2px rgba(0,0,0,.2)); transition: transform .15s; }
.switch.on { background: var(--badge-ok-ink); }
.switch.on span { transform: translateX(-20px); }
.switch:disabled { opacity: .6; }

/* ── رسالة التذكير بعد الحفظ ─────────────────────── */
.pay-methods { display: flex; flex-direction: column; gap: var(--s2); }
.pay-method {
  display: flex; align-items: center; gap: var(--s3); width: 100%; padding: var(--s2) var(--s3); text-align: start;
  border: 1px solid var(--line); border-radius: var(--r-large); background: var(--bg); color: var(--ink); font-size: 14px; font-weight: 500;
}
.pay-method.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
/* الشعارات على خلفيتها الأصلية عشان تبان في الوضع الداكن */
.pay-logo { flex: none; width: 72px; height: 36px; border-radius: var(--r-modal); display: grid; place-items: center; background: #fff; overflow: hidden; }
.pay-logo.barq { background: #000; }
.pay-logo img { max-width: 64px; max-height: 26px; }
.pay-label { flex: 1; min-width: 0; }
.pay-tick { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; color: transparent; }
.pay-method.on .pay-tick { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.reminder-preview {
  white-space: pre-wrap; font-size: 14px; line-height: 22px; background: var(--surface);
  border-radius: var(--r-large); padding: var(--s3) var(--s4); user-select: text;
}

/* ── التذكير الدوري ─────────────────────────────── */
.check { display: flex; align-items: flex-start; gap: var(--s3); cursor: pointer; }
.check input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ink); }
.check span { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.check small { font-size: 12px; line-height: 16px; }
.reminder-opts { display: flex; flex-direction: column; gap: var(--s3); }
.reminder-opts.off { opacity: .45; }
.reminder-preview-box summary { cursor: pointer; font-size: 14px; font-weight: 500; }
.reminder-preview-box .reminder-preview { margin-top: var(--s2); }
.roster .row.check { align-items: center; min-height: 52px; }
.roster .row.check input { margin: 0; }
.roster .row.check.off { opacity: .55; cursor: default; }

/* عليك ولك: جلسات كل عضو تحت اسمه */
.balance-person + .balance-person { border-top: 1px solid var(--line); }
.balance-sessions { display: flex; flex-direction: column; padding: 0 0 var(--s3); margin-inline-start: 52px; }
.balance-session { display: flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s2);
  border-radius: 10px; color: inherit; text-decoration: none; font-size: 13px; }
.balance-session:hover, .balance-session:focus-visible { background: var(--line); }
.balance-session .chev { color: var(--muted); font-size: 18px; line-height: 1; }

/* سجل النشاط */
.activity-day { font-size: 12px; color: var(--muted); font-weight: 500; margin: var(--s4) 0 var(--s2); }
.activity-item { align-items: flex-start; color: inherit; text-decoration: none; }
.activity-item .ico { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: transparent; border: 1.5px solid var(--line); color: var(--muted); }
.activity-item .text { font-size: 14px; line-height: 21px; }
.activity-item .text b { font-weight: 600; }
.activity-item .chev { align-self: center; color: var(--muted); font-size: 18px; }
.drawer-tag { margin-inline-start: auto; }
.drawer-tag + .drawer-badge { margin-inline-start: var(--s2); }

/* زر التنبيهات والقائمة */
.tb-bell { margin-inline-end: 0; }
.tb-count { position: absolute; top: 2px; inset-inline-start: 2px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: var(--r-pill); background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 0 0 2px var(--surface); }
/* نافذة التنبيهات: شبه كاملة الطول وخط أكبر للقراءة. .notif مو .note (.note للملاحظات الرمادية) */
.notes-sheet { height: 92dvh; max-height: 92dvh; overflow: hidden; }
.notes-sheet h2 { font-size: 22px; }
.notes-sheet .notifs, .notes-sheet .empty { flex: 1 1 auto; flex-shrink: 1; min-height: 0; }
.notifs { margin: 0; overflow-y: auto; overscroll-behavior: contain; }
.notifs > .row + .row { border-top: 1px solid var(--line); }
.notif { align-items: flex-start; color: inherit; text-decoration: none; padding: var(--s4) 0; gap: var(--s3); }
.notif .ico { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line); color: var(--muted); }
.notif .text { font-size: 16px; line-height: 26px; }
.notif .text b { font-weight: 600; }
.notif .sub { font-size: 13px; line-height: 20px; margin-top: 2px; }
.notif-dot { flex: none; align-self: center; width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

/* ── التوافق مع كل المقاسات ───────────────────────── */
:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
/* النوتش وحواف الجوال بالعرض */
.topbar { height: calc(var(--top-h) + var(--safe-t)); padding-top: var(--safe-t);
  padding-inline: calc(var(--s4) + var(--safe-r)) calc(var(--s4) + var(--safe-l)); }
.page { padding-inline: calc(var(--s4) + var(--safe-r)) calc(var(--s4) + var(--safe-l)); }
.nav { padding-inline: var(--safe-r) var(--safe-l); }
.sheet { padding-inline: calc(var(--s4) + var(--safe-r)) calc(var(--s4) + var(--safe-l)); }
.drawer { padding-top: calc(var(--s5) + var(--safe-t)); }
/* نصوص طويلة (أسماء، رسائل تحويل) ما تطلع برا البطاقة */
.grow, .title, .text, .pay-msg, .reminder-preview, .note { overflow-wrap: anywhere; }
/* آيفون يكبّر الصفحة لو خط الحقل أقل من 16 */
.textarea { font-size: 16px; }

/* جوالات صغيرة (iPhone SE وأصغر) */
@media (max-width: 374px) {
  .topbar { gap: var(--s1); padding-inline: calc(var(--s3) + var(--safe-r)) calc(var(--s3) + var(--safe-l)); }
  .page { padding-inline: calc(var(--s3) + var(--safe-r)) calc(var(--s3) + var(--safe-l)); }
  .chip-bar { margin: 0 calc(-1 * var(--s3)); padding: 0 var(--s3); }
  .ns-submit { margin: 0 calc(-1 * var(--s3)); padding-inline: var(--s3); }
  .tb-home, .icon-btn, .topbar .back { width: 36px; height: 36px; }
  .topbar h1 { font-size: 18px; line-height: 24px; }
  .tb-actions { gap: 2px; }
  .hero .big { font-size: 30px; line-height: 38px; }
  .dues { flex-wrap: wrap; }
  .dues .btn { width: 100%; }
  .dues-amount { font-size: 24px; line-height: 32px; }
  .amount-input { font-size: 38px; line-height: 48px; }
  .counter { gap: var(--s3); }
  .stat { padding: var(--s3); }
  .stat .v { font-size: 18px; line-height: 26px; }
  .bar-row { grid-template-columns: 5.5em 1fr auto; gap: var(--s2); }
  .balance-sessions { margin-inline-start: 0; }
  .pay-logo { width: 60px; }
  .pay-logo img { max-width: 52px; }
  .split { flex-wrap: wrap; }
  .split > * { flex-basis: 120px; }
}
/* أصغر من كذا (Galaxy Fold مسكّر): نخفي النص الفرعي تحت العنوان */
@media (max-width: 300px) {
  .tb-title p { display: none; }
  .stats { grid-template-columns: 1fr; }
}
/* جوال بالعرض أو شاشة قصيرة: النوافذ تاخذ الطول كله */
@media (max-height: 500px) {
  .sheet, .notes-sheet { max-height: 100dvh; height: auto; border-radius: 0; }
  .notes-sheet { height: 100dvh; }
  .login { justify-content: flex-start; }
}
/* آيباد وأكبر: المحتوى أعرض شوي، والنوافذ بالنص بدل ما تلصق تحت */
@media (min-width: 768px) {
  .app, .nav-inner { max-width: 720px; }
  .sheet-backdrop { align-items: center; padding: var(--s5); }
  .sheet { max-width: 560px; border-radius: 20px; padding-bottom: var(--s5); max-height: 85dvh; }
  .notes-sheet { height: min(85dvh, 760px); }
  .toast { bottom: calc(var(--nav-h) + var(--s5)); }
}
@media (min-width: 1024px) {
  .page { padding-top: var(--s4); }
}

/* الاشتراكات والمصروفات الدورية */
.recurring-card { display: flex; flex-direction: column; gap: var(--s3); }
.recurring-head { display: flex; align-items: flex-start; gap: var(--s3); }
.recurring-head .grow { flex: 1; min-width: 0; }
.recurring-head h3 { margin: 0; font-size: 16px; line-height: 24px; font-weight: 700; }
.recurring-head .ico { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line); color: var(--muted); }
.recurring-card .sub { font-size: 13px; line-height: 20px; color: var(--muted); }
.recurring-history summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); }
.recurring-history .list { margin-top: var(--s2); }
.recurring-history .list > .row + .row { border-top: 1px solid var(--line); }
.recurring-form { gap: var(--s4); }
.chip-input { padding-inline: var(--s2) var(--s3); }
.chip-input input { width: 3.5ch; border: 0; background: transparent; outline: none; text-align: center; font-size: 16px; padding: 0; color: inherit; }
.field.off { opacity: .45; }

/* ناس من خارج الاستراحة: صفوف قابلة للضغط، وشاشة تأكيد الجلسة */
button.row { width: 100%; background: none; border: 0; padding-inline: 0; text-align: start; }
.check.off { opacity: .55; cursor: default; }
.confirm-line { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s2) 0; font-size: 14px; }
.list > .confirm-line + .confirm-line { border-top: 1px solid var(--line); }
.confirm-sheet .card { padding-block: var(--s2); }
.confirm-sheet h3 { margin: 0; }

/* ── تقويم اختيار التاريخ (جلسة جديدة) ───────────── */
button.date-shown { gap: var(--s2); color: var(--ink); font: inherit; font-size: 16px; cursor: pointer; }
button.date-shown svg { color: var(--muted); }
.cal-head { display: flex; align-items: center; gap: var(--s2); }
.cal-head .icon-btn:disabled { opacity: .3; cursor: default; }
.cal-title { flex: 1; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.cal-title .sub { font-size: 12px; line-height: 16px; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s1) 0; justify-items: center; }
.cal-wd { font-size: 11px; line-height: 16px; color: var(--muted); padding-bottom: var(--s2); }
.cal-day {
  width: 42px; height: 42px; border-radius: var(--r-pill); border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 15px; cursor: pointer; display: grid; place-items: center; position: relative;
  transition: background .15s, color .15s, transform .1s;
}
.cal-day:hover:not(:disabled) { background: var(--surface); }
.cal-day:active:not(:disabled) { transform: scale(.92); }
.cal-day:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.cal-day:disabled { color: var(--muted); opacity: .35; cursor: default; }
.cal-day.today { font-weight: 700; }
.cal-day.today::after { content: ''; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.cal-day.has { box-shadow: inset 0 0 0 2px var(--red); color: var(--badge-red-ink); font-weight: 500; }
.cal-day.on { background: var(--ink); color: var(--on-ink); font-weight: 700; }
.cal-day.on.has { background: var(--red); color: #fff; box-shadow: none; }
.cal-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: var(--s3); }
.cal-legend { display: inline-flex; align-items: center; gap: var(--s2); font-size: 12px; color: var(--muted); }
.cal-legend i { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--red); }
@media (min-width: 600px) { .cal-sheet { max-width: 420px; } }

/* أكثر من مجموعة من خارج الاستراحة، كل وحدة على حساب عضو */
.ns-group-head b { font-size: 13px; font-weight: 500; }
.ns-add-group { align-self: flex-start; display: inline-flex; align-items: center; gap: var(--s1); margin-top: var(--s1); }
