@import url('/assets/fonts/fonts.css');

/* ==========================================================================
   Kafala — bilingual donation ledger
   One system: a single type scale, four weights, three elevations, two curves.
   Every value below is deliberate; nothing is decorative.
   ========================================================================== */

:root {
  /* ---- type scale (px) ---------------------------------------------------
     Each step carries its own tracking: display tightens, micro opens up.  */
  --t-11: 11px;  --tr-11:  .06em;
  --t-12: 12px;  --tr-12:  0;
  --t-13: 13px;  --tr-13: -.004em;
  --t-14: 14px;  --tr-14: -.008em;
  --t-15: 15px;  --tr-15: -.012em;
  --t-17: 17px;  --tr-17: -.018em;
  --t-20: 20px;  --tr-20: -.022em;
  --t-24: 24px;  --tr-24: -.026em;
  --t-30: 30px;  --tr-30: -.032em;
  --t-44: 44px;  --tr-44: -.042em;

  --w-regular: 400;
  --w-medium:  500;
  --w-semi:    600;
  --w-bold:    700;

  /* ---- space (4pt grid) ---- */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px;

  /* ---- radius (nested: parent − padding) ---- */
  --r-2xl: 24px;
  --r-xl:  20px;
  --r-lg:  16px;
  --r-md:  12px;
  --r-sm:  10px;

  /* ---- neutral ramp (light) ---- */
  --bg:        #f2f1ed;   /* limestone */
  --bg-2:      #e8e6e0;
  --surface:   #ffffff;
  --surface-2: #f7f6f3;
  --sunk:      #eceae5;
  --raised:    #ffffff;
  --ink:       #14120f;   /* warm ink, not blue-black */
  --ink-2:     #5c584f;   /* 6.4:1 on --surface */
  --ink-3:     #6b665c;   /* 5.6:1 on --surface, 4.6:1 on --sunk */
  --hair:      rgba(24, 20, 14, .11);
  --hair-2:    rgba(24, 20, 14, .06);
  --hair-hi:   rgba(24, 20, 14, .2);
  --edge-hi:   inset 0 1px 0 rgba(255, 255, 255, .7);

  /* ---- semantic ---- */
  --accent:      #1d5c8f;   /* deep slate blue — an ink, not a highlighter */
  --accent-2:    #2f7fbd;
  --accent-fill: #1d5c8f;
  --red-fill:    #a3242b;
  --accent-soft: rgba(29, 92, 143, .10);
  --ring:        rgba(29, 92, 143, .32);
  --in:          #3f6b3a;   /* olive */
  --in-soft:     rgba(63, 107, 58, .11);
  --out:         #7a5a2e;   /* sumac */
  --warn:        #8a5a00;
  --warn-soft:   rgba(138, 90, 0, .10);
  --red:         #a3242b;
  --red-soft:    rgba(163, 36, 43, .09);

  /* ---- elevation ---- */
  --e1: 0 .5px 1px rgba(0,0,0,.045), 0 2px 6px -1px rgba(0,0,0,.05);
  --e2: 0 .5px 1px rgba(0,0,0,.05),  0 10px 26px -8px rgba(0,0,0,.13);
  --e3: 0 1px 2px rgba(0,0,0,.06),   0 28px 64px -14px rgba(0,0,0,.30);

  /* ---- motion: two curves, four durations ---- */
  --spring: cubic-bezier(.32, .72, 0, 1);
  --ease:   cubic-bezier(.4, 0, .2, 1);
  --d-1: 120ms;  /* state change on the spot         */
  --d-2: 200ms;  /* small movement                   */
  --d-3: 320ms;  /* element entering                 */
  --d-4: 460ms;  /* surface entering, value counting */

  /* Plex Arabic is drawn as Arabic, with a Latin cut that shares its skeleton —
     one voice across both directions instead of two fonts pretending to match. */
  --lat: "Plex", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ar:  "Plex Arabic", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma;
  --sans: var(--lat), var(--ar), sans-serif;
  --lh: 1.5;
}

html[data-lang="ar"] {
  --sans: var(--ar), var(--lat), sans-serif;
  --lh: 1.62;              /* Arabic carries more leading than Latin */
  /* connected script is never optically tightened */
  --tr-11: 0; --tr-12: 0; --tr-13: 0; --tr-14: 0; --tr-15: 0;
  --tr-17: 0; --tr-20: 0; --tr-24: -.01em; --tr-30: -.012em; --tr-44: -.015em;
}
html[data-lang="ar"] h1, html[data-lang="ar"] h2, html[data-lang="ar"] h3,
html[data-lang="ar"] .balance, html[data-lang="ar"] .ttl { line-height: 1.4; }

html[data-theme="dark"] {
  --bg:        #0a0908;
  --bg-2:      #12100e;
  --surface:   #17150f;
  --surface-2: #1f1c16;
  --sunk:      #100e0b;
  --raised:    #2a261e;
  --ink:       #f4f1ea;
  --ink-2:     #a8a294;
  --ink-3:     #8d8779;
  --hair:      rgba(244, 241, 234, .12);
  --hair-2:    rgba(244, 241, 234, .07);
  --hair-hi:   rgba(244, 241, 234, .24);
  --edge-hi:   inset 0 1px 0 rgba(255, 255, 255, .05);

  --accent:      #6aaede;
  --accent-2:    #8cc3ea;
  --accent-fill: #256b9f;  /* white on this clears AA */
  --red-fill:    #a8322f;
  --accent-soft: rgba(106, 174, 222, .16);
  --ring:        rgba(106, 174, 222, .4);
  --in:          #8fbe7a;   /* olive, lifted for dark */
  --in-soft:     rgba(143, 190, 122, .15);
  --out:         #d0a366;   /* sumac, lifted */
  --warn:        #ffd426;
  --warn-soft:   rgba(255, 212, 38, .14);
  --red:         #ff453a;
  --red-soft:    rgba(255, 69, 58, .16);

  --e1: 0 .5px 1px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.45);
  --e2: 0 .5px 1px rgba(0,0,0,.6),  0 12px 34px -8px rgba(0,0,0,.65);
  --e3: 0 1px 3px rgba(0,0,0,.7),   0 36px 80px -18px rgba(0,0,0,.85);
}

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--t-15);
  line-height: var(--lh);
  letter-spacing: var(--tr-15);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
::selection { background: var(--accent-soft); }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

/* the focus ring follows the element's own shape — it never reshapes it */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:focus-visible, .icon-btn:focus-visible, .seg button:focus-visible, .tab:focus-visible { outline-offset: 3px; }

.num {
  font-family: var(--lat);   /* Geeza/Tahoma have no tabular figures */
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  direction: ltr; unicode-bidi: isolate;
  letter-spacing: -.02em;
}
/* the isolate must not re-align its own box: figures begin where the page begins */
html[dir="rtl"] .num { text-align: right; }
html[dir="rtl"] .amt-col .num, html[dir="rtl"] .row-end .num { text-align: left; }

.eyebrow {
  font-size: var(--t-11); font-weight: var(--w-semi); letter-spacing: var(--tr-11);
  text-transform: uppercase; color: var(--ink-3);
}
html[data-lang="ar"] .eyebrow { letter-spacing: 0; text-transform: none; font-size: var(--t-12); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* true 1-device-pixel hairlines on retina */
@media (min-resolution: 2dppx) {
  .panel, .hero, .fam, .stat, .login-card, .sheet, .who, .chip { border-width: .5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    animation-delay: 0ms !important; transition-duration: .01ms !important;
    transition-delay: 0ms !important; scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Login
   ========================================================================== */
.login-wrap {
  min-height: 100dvh; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  position: relative; overflow: hidden;
  background:
    radial-gradient(900px 560px at 82% -12%, var(--accent-soft), transparent 60%),
    radial-gradient(720px 480px at 8% 112%, var(--in-soft), transparent 58%),
    var(--bg);
}
.login-card {
  width: min(384px, 100%); position: relative;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-2xl);
  padding: var(--s-7) var(--s-6) var(--s-5);
  box-shadow: var(--e3), var(--edge-hi);
  text-align: center;
  animation: rise var(--d-4) var(--spring) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.975); } }
.mark {
  width: 56px; height: 56px; margin: 0 auto var(--s-4); border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(155deg, #4a7a42 0%, #1d5c8f 100%);
  box-shadow: 0 10px 24px -14px rgba(29,92,143,.8), inset 0 1px 0 rgba(255,255,255,.22);
}
.mark svg { width: 27px; height: 27px; fill: #fff; }
.login-card h1 { font-size: var(--t-24); font-weight: var(--w-bold); letter-spacing: var(--tr-24); }
.login-card .sub { color: var(--ink-2); font-size: var(--t-14); margin: 3px 0 var(--s-5); }
.login-card .lang-line { display: flex; justify-content: center; margin-bottom: var(--s-5); }
.login-card .lang-line .seg { width: 100%; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; }
.login-card .lang-line .seg button { padding: 8px 10px; font-size: var(--t-14); font-weight: var(--w-semi); }
.login-foot { margin-top: var(--s-5); font-size: var(--t-12); color: var(--ink-3); }

/* ==========================================================================
   Form controls
   ========================================================================== */
.field { text-align: start; }
.field + .field { margin-top: var(--s-3); }
.field label {
  display: block; font-size: var(--t-12); font-weight: var(--w-medium);
  color: var(--ink-2); margin: 0 2px 6px;
}
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%;
  background: var(--sunk);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-md);
  padding: 11px 13px;
  outline: none;
  appearance: none;
  transition: border-color var(--d-2) var(--ease), background var(--d-2) var(--ease), box-shadow var(--d-2) var(--ease);
}
select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 32px;
}
html[dir="rtl"] select { background-position: 12px 50%, 17px 50%; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3.5px var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
textarea { min-height: 76px; resize: vertical; line-height: var(--lh); }
.err { color: var(--red); font-size: var(--t-13); min-height: 20px; margin-top: var(--s-3); }
.shake { animation: shake .42s var(--ease); }
@keyframes shake { 20%{transform:translateX(-8px)} 40%{transform:translateX(7px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(2px)} }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent-fill); color: #fff;
  border-radius: 999px; padding: 9px 17px; min-height: 36px;
  font-weight: var(--w-semi); font-size: var(--t-14); white-space: nowrap;
  transition: transform var(--d-1) var(--spring), filter var(--d-2) var(--ease),
              background var(--d-2) var(--ease), opacity var(--d-2) var(--ease);
}

.btn:active { transform: scale(.96); filter: brightness(.94); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.76; stroke-linecap: round; stroke-linejoin: round; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--hair); box-shadow: var(--e1); }

.btn.quiet { background: var(--sunk); color: var(--ink); }

.btn.danger { background: var(--red-fill); }
.btn.full { width: 100%; margin-top: var(--s-1); min-height: 44px; font-size: var(--t-15); }
.btn.sm { padding: 6px 12px; min-height: 30px; font-size: var(--t-13); }

.seg { display: inline-flex; background: var(--sunk); border-radius: 999px; padding: 2px; gap: 2px; }
.seg button {
  padding: 6px 13px; border-radius: 999px; font-size: var(--t-13); font-weight: var(--w-medium);
  color: var(--ink-2); white-space: nowrap;
  transition: background var(--d-2) var(--ease), color var(--d-2) var(--ease),
              box-shadow var(--d-2) var(--ease), transform var(--d-1) var(--spring);
}
.seg button:active { transform: scale(.96); }
.seg button.on {
  background: var(--surface); color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,.14), 0 0 0 .5px rgba(0,0,0,.05);
}
html[data-theme="dark"] .seg { background: var(--sunk); }
/* quiet buttons and pills are raised controls, not wells */
html[data-theme="dark"] .btn.quiet, html[data-theme="dark"] .lang-pill { background: var(--surface-2); }
html[data-theme="dark"] .seg button.on {
  background: #34343a; box-shadow: 0 1px 2px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.07);
}
.theme-seg button { width: 34px; height: 30px; display: grid; place-items: center; padding: 0; }
.theme-seg button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.76; stroke-linecap: round; stroke-linejoin: round; }

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center;
  color: var(--ink-2);
  transition: background var(--d-1) var(--ease), color var(--d-1) var(--ease), transform var(--d-1) var(--spring);
}

.icon-btn:active { transform: scale(.92); }

.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

/* hover is a capability, not an assumption: iOS latches :hover on the last
   element tapped, so every hover paint lives behind a real pointer query */
@media (hover: hover) and (pointer: fine) {
  .fam .acts, .row-actions { opacity: 0; }
  .fam:hover .acts, .fam:focus-within .acts,
  tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }
  .fam:hover { transform: translateY(-2px); box-shadow: var(--e2); border-color: var(--hair-hi); }
  .stat:hover { transform: translateY(-1px); box-shadow: var(--e2); }
  tbody tr:hover, .attn-row:hover, .row-item:hover { background: color-mix(in srgb, var(--accent) 3.5%, transparent); }
  .btn:hover { filter: brightness(1.08); }
  .btn.ghost:hover { background: var(--surface-2); filter: none; border-color: var(--hair-hi); }
  .btn.quiet:hover { background: var(--bg-2); filter: none; }
  .icon-btn:hover { background: var(--sunk); color: var(--ink); }
  .icon-btn.del:hover { background: var(--red-soft); color: var(--red); }
  aside nav button:hover { background: var(--sunk); color: var(--ink); }
  .chart g.col:hover rect.b { opacity: .78; }
  .status .set-need:hover { background: var(--accent-soft); }
  .lang-pill:hover { background: var(--bg-2); }
  html[data-theme="dark"] .btn.quiet:hover,
  html[data-theme="dark"] .lang-pill:hover { background: var(--raised); }
}

/* ==========================================================================
   Shell
   ========================================================================== */
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100dvh; }

aside {
  grid-column: 1; grid-row: 1;
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s-5) var(--s-3) var(--s-4);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-inline-end: 1px solid var(--hair);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px var(--s-2) var(--s-4); }
.brand .mark { width: 32px; height: 32px; border-radius: 10px; margin: 0; box-shadow: 0 5px 12px -8px rgba(29,92,143,.9); }
.brand .mark svg { width: 17px; height: 17px; }
.brand b { font-size: var(--t-15); font-weight: var(--w-semi); letter-spacing: var(--tr-15); display: block; line-height: 1.25; }
.brand span { font-size: var(--t-12); color: var(--ink-2); letter-spacing: 0; }

aside nav { display: flex; flex-direction: column; gap: 2px; }
aside nav button {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 11px; border-radius: var(--r-md); min-height: 38px;
  color: var(--ink-2); font-size: var(--t-14); font-weight: var(--w-medium); text-align: start;
  transition: background var(--d-1) var(--ease), color var(--d-1) var(--ease);
}
aside nav button svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }

aside nav button.on { background: var(--accent-fill); color: #fff; box-shadow: 0 6px 14px -9px var(--accent); }
aside nav button.on .count { background: rgba(255,255,255,.22); color: #fff; }
aside nav .count {
  margin-inline-start: auto; font-size: var(--t-11); font-weight: var(--w-semi); letter-spacing: 0;
  background: var(--sunk); color: var(--ink-2); padding: 1px 7px; border-radius: 999px;
  min-width: 22px; text-align: center;
}
.side-foot { margin-top: auto; display: grid; gap: var(--s-3); }
.side-toggles { display: flex; gap: var(--s-2); align-items: center; padding: 0 var(--s-1); }
.who {
  display: flex; align-items: center; gap: var(--s-2); padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--hair-2); border-radius: var(--r-md);
}
.who .n { font-size: var(--t-13); font-weight: var(--w-medium); line-height: 1.2; }
.who .r { font-size: var(--t-11); color: var(--ink-3); letter-spacing: 0; }
.who .out { margin-inline-start: auto; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: linear-gradient(155deg, #4a7a42, #1d5c8f); color: #fff;
  display: grid; place-items: center; font-size: var(--t-12); font-weight: var(--w-bold);
}

main { grid-column: 2; grid-row: 1; min-width: 0; }
.wrap { max-width: 1140px; padding: var(--s-7) var(--s-8) 96px; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5); margin-bottom: var(--s-6); }
.head h1 { font-size: var(--t-30); font-weight: var(--w-bold); letter-spacing: var(--tr-30); line-height: 1.15; }
.head .sub { color: var(--ink-2); font-size: var(--t-14); margin-top: 4px; }
.head-actions { display: flex; gap: var(--s-2); flex: none; }

/* ==========================================================================
   Surfaces
   ========================================================================== */
.panel {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--r-lg); box-shadow: var(--e1);
  overflow: hidden; margin-bottom: var(--s-4);
}
.panel > header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  min-height: 52px; padding: 0 var(--s-5); border-bottom: 1px solid var(--hair-2);
}
.panel > header h2 { font-size: var(--t-15); font-weight: var(--w-semi); letter-spacing: var(--tr-15); }
.panel > header .hint { font-size: var(--t-12); color: var(--ink-3); text-align: end; line-height: 1.4; }
.panel > header .hint .hijri { display: block; font-size: var(--t-11); opacity: .8; letter-spacing: 0; }

/* --- hero --- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl); border: 1px solid var(--hair);
  background: var(--surface); box-shadow: var(--e2), var(--edge-hi);
  padding: var(--s-5) var(--s-6);
  margin-bottom: var(--s-4);
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "main ring" "split split";
  column-gap: var(--s-6); row-gap: var(--s-5); align-items: center;
}
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(520px 240px at 88% -40%, var(--accent-soft), transparent 70%),
    radial-gradient(400px 200px at 4% 150%, var(--in-soft), transparent 68%);
}
.hero > * { position: relative; }
.hero .hero-main { grid-area: main; }
.hero > .ring { grid-area: ring; }
.hero .split {
  grid-area: split;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3) var(--s-5);
  border-top: 1px solid var(--hair-2); padding-top: var(--s-4);
}
.hero .split > div { display: grid; grid-template-rows: 18px auto; align-content: start; }
.hero .balance { font-size: var(--t-44); font-weight: var(--w-bold); letter-spacing: var(--tr-44); line-height: 1.05; margin: 5px 0 2px; }
.hero .balance.neg { color: var(--red); }
.hero .caption { font-size: var(--t-13); color: var(--ink-2); }
.hero .split .k { font-size: var(--t-12); color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.hero .split .k i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; flex: none; }
.hero .split .v { font-size: var(--t-20); font-weight: var(--w-semi); letter-spacing: var(--tr-20); margin-top: 2px; }
.dot-in { background: var(--in); }
.dot-out { background: var(--out); }
.dot-transit { background: var(--warn); }
.attn-row.transit .amt-col .amt, .attn-row.unconfirmed .amt-col .amt { color: var(--warn); }
.attn-row.season .amt-col .amt { font-size: var(--t-13); font-weight: var(--w-medium); color: var(--ink-2); }
.attn-row.season.late .amt-col .amt { color: var(--red); }
.panel.horizon .mono.sm { display: grid; place-items: center; }

.ring { display: grid; place-items: center; position: relative; flex: none; }
.ring svg { transform: rotate(-90deg); overflow: visible; }
.ring .track { stroke: var(--sunk); fill: none; }
.ring .val { fill: none; stroke-linecap: round; transition: stroke-dashoffset var(--d-4) var(--spring); }
.ring .label { position: absolute; text-align: center; max-width: 78%; }
.ring .label b { display: block; font-size: var(--t-20); font-weight: var(--w-semi); letter-spacing: var(--tr-20); }
.ring .label span { font-size: var(--t-11); color: var(--ink-3); letter-spacing: 0; }

/* --- stats --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(184px, 100%), 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
.stat {
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5); box-shadow: var(--e1);
  transition: transform var(--d-2) var(--spring), box-shadow var(--d-2) var(--ease);
}

.stat .k { font-size: var(--t-12); color: var(--ink-2); font-weight: var(--w-medium); }
.stat .v { font-size: var(--t-24); font-weight: var(--w-semi); letter-spacing: var(--tr-24); margin-top: 5px; line-height: 1.1; }
.stat .s { font-size: var(--t-12); color: var(--ink-3); margin-top: 3px; }
.stat.in .v { color: var(--in); }
.stat.out .v { color: var(--out); }

/* --- chart --- */
.chart { padding: var(--s-4) var(--s-5) var(--s-2); }
.chart svg { width: 100%; max-width: 100%; height: 148px; display: block; overflow: visible; }
.chart .grid line { stroke: var(--hair-2); stroke-width: 1; }
.chart .axis { font-size: 10.5px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart rect.b { transition: opacity var(--d-2) var(--ease); }

.chart g.col rect.hit { fill: transparent; }
.legend { display: flex; gap: var(--s-4); align-items: center; font-size: var(--t-12); color: var(--ink-2); }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-inline-end: 6px; }
.tip {
  position: fixed; z-index: 80; pointer-events: none;
  background: color-mix(in srgb, var(--ink) 94%, transparent); color: var(--bg);
  padding: 7px 11px; border-radius: var(--r-sm); font-size: var(--t-12); line-height: 1.5;
  box-shadow: var(--e2); white-space: nowrap;
}
html[data-theme="dark"] .tip { color: #000; }

/* ==========================================================================
   The roll call — the one place the fund says who it is for
   ========================================================================== */
.roll-panel { background: var(--surface); }
.roll {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 4px var(--s-4);
  padding: var(--s-5) var(--s-5) var(--s-6);
}
.roll .name {
  font-size: clamp(19px, 1.9vw, 26px);
  font-weight: var(--w-medium);
  letter-spacing: -.016em;
  line-height: 1.5;
  color: var(--ink);
  padding: 0; border-radius: 4px;
  transition: color var(--d-2) var(--ease), opacity var(--d-2) var(--ease);
}
html[data-lang="ar"] .roll .name { letter-spacing: 0; line-height: 1.7; }
/* waiting is quieter, never struck: a child is not a failed line item */
.roll .name:not(.got) {
  color: var(--ink-3);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
  text-decoration-color: var(--hair-hi);
}
.roll .name.got { color: var(--ink); }
.roll .name.got::after {
  content: ''; display: inline-block; vertical-align: middle;
  width: 5px; height: 5px; border-radius: 50%; background: var(--in);
  margin-inline-start: 7px; margin-bottom: 2px;
}
@media (hover: hover) and (pointer: fine) {
  .roll .name:hover { color: var(--accent); }
}

/* ==========================================================================
   Attention queue
   ========================================================================== */
.two-up { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--s-4); align-items: stretch; }
.two-up > .panel { display: flex; flex-direction: column; }
.two-up > .panel > .chart, .two-up > .panel > .timeline, .two-up > .panel > .empty { flex: 1; }
.two-up > .panel > .chart { display: flex; flex-direction: column; justify-content: flex-end; }
.two-up > .panel { margin-bottom: 0; }

.badge {
  font-size: var(--t-11); font-weight: var(--w-bold); letter-spacing: 0;
  padding: 1.5px 8px; border-radius: 999px; background: var(--red-fill); color: #fff;
}
.attn-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 92px 132px; align-items: center;
  gap: var(--s-3); min-height: 68px; padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--hair-2);
  cursor: pointer; transition: background var(--d-1) var(--ease);
}
.attn-row:last-child { border-bottom: 0; }

.attn-row:active { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.attn-row .ttl { font-size: var(--t-14); font-weight: var(--w-medium); letter-spacing: var(--tr-14); }
.attn-row .sub { font-size: var(--t-12); color: var(--ink-3); margin-top: 1px; }
.attn-row .amt-col { text-align: end; }
.attn-row .amt-col .amt { font-size: var(--t-15); font-weight: var(--w-semi); letter-spacing: -.024em; }
.attn-row.short .amt-col .amt { color: var(--red); }
.attn-row.due .amt-col .amt { color: var(--warn); }
.attn-row .rail { margin-top: 7px; max-width: 260px; }
.mono.sm { width: 34px; height: 34px; border-radius: var(--r-md); font-size: var(--t-13); }

.rail { height: 4px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.rail i {
  display: block; height: 100%; width: 100%; border-radius: 999px;
  background: linear-gradient(to right, var(--out), var(--in));
  transform: scaleX(var(--p, 0)); transform-origin: left center;
  transition: transform var(--d-4) var(--spring);
}
html[dir="rtl"] .rail i { transform-origin: right center; background: linear-gradient(to left, var(--out), var(--in)); }

.all-clear { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-5); }
.all-clear .tick {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--in-soft); color: var(--in);
}
.all-clear .tick svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }
.all-clear b { font-size: var(--t-15); font-weight: var(--w-semi); }
.all-clear p { font-size: var(--t-13); color: var(--ink-3); margin-top: 1px; }

/* timeline */
.timeline { padding: 6px 0; }
.tl-row {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center;
  gap: var(--s-3); min-height: 56px; padding: 0 var(--s-5);
}
.tl-row .tl-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.tl-row .tl-ico svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.89; stroke-linecap: round; stroke-linejoin: round; }
.tl-row .tl-ico.in { background: var(--in-soft); color: var(--in); }
.tl-row .tl-ico.out { background: var(--accent-soft); color: var(--out); }
.tl-row .ttl { font-size: var(--t-14); font-weight: var(--w-medium); }
.tl-row .sub { font-size: var(--t-12); color: var(--ink-3); margin-top: 1px; }
.tl-row .amt { font-size: var(--t-14); font-weight: var(--w-semi); letter-spacing: -.02em; }
.tl-row .amt.in { color: var(--in); }
.tl-row .amt.out { color: var(--out); }

/* ==========================================================================
   Family cards
   ========================================================================== */
.fam-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: var(--s-3); align-items: start;
}
.fam {
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-lg);
  box-shadow: var(--e1); padding: var(--s-5);
  display: grid;
  grid-template-rows: 44px 2lh 58px 22px auto;   /* header · situation · chips(2 rows) · status · footer */
  gap: var(--s-3);
  transition: transform var(--d-2) var(--spring), box-shadow var(--d-2) var(--ease), border-color var(--d-2) var(--ease);
  animation: cardIn var(--d-3) var(--spring) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } }

.fam .top { display: flex; gap: var(--s-3); align-items: center; min-width: 0; }
.fam .top .tag { margin-inline-start: auto; flex: none; }
.mono {
  width: 40px; height: 40px; border-radius: var(--r-md); flex: none;
  display: grid; place-items: center; font-size: var(--t-15); font-weight: var(--w-semi); color: #fff;
  letter-spacing: -.02em; line-height: 1; box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
}
.fam h3 {
  font-size: var(--t-17); font-weight: var(--w-semi); letter-spacing: var(--tr-17); line-height: 1.28;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fam .top > div:nth-child(2) { min-width: 0; flex: 1; }
.fam .meta { font-size: var(--t-12); color: var(--ink-3); margin-top: 2px; }
.fam .meta a { color: var(--ink-2); }
.fam .situation {
  font-size: var(--t-13); color: var(--ink-2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;                       /* two lines, always — the row height is fixed */
}
.fam .acts { display: flex; gap: 2px; flex: none; opacity: 1; transition: opacity var(--d-2) var(--ease); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; overflow: hidden; align-content: start; }
.chip.more { color: var(--ink-3); font-weight: var(--w-medium); flex: none; }
.chip {
  font-size: var(--t-12); height: 26px; padding: 0 10px; border-radius: 999px; max-width: 100%;
  background: var(--surface-2); border: 1px solid var(--hair-2); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 5px; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chip b { color: var(--ink); font-weight: var(--w-medium); }
.chip .age { color: var(--ink-3); font-size: var(--t-11); letter-spacing: 0; }
.fam .foot {
  display: grid; grid-template-columns: 1fr 1fr auto; gap: var(--s-4); align-items: end;
  border-top: 1px solid var(--hair-2); padding-top: var(--s-3);
}
.fam .foot .acts { justify-self: end; align-self: center; }
.fam .foot .k { font-size: var(--t-11); color: var(--ink-3); letter-spacing: 0; }
.fam .foot .v { font-size: var(--t-15); font-weight: var(--w-semi); letter-spacing: -.024em; }
.fam .foot .in { color: var(--in); }
.fam .foot .out { color: var(--out); }
.fam .foot .ring { justify-self: end; }

/* family status line */
.status { display: grid; gap: 6px; font-size: var(--t-12); color: var(--ink-2); }
.status .line { display: flex; align-items: center; gap: 7px; }
.status .pip { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-3); }
.status .tail { margin-inline-start: auto; font-weight: var(--w-medium); color: var(--ink); }
.status.ok .pip { background: var(--in); }
.status.ok .tail { color: var(--in); }
.status.short .pip { background: var(--warn); }
.status.short .tail { color: var(--warn); }
.status.none { display: flex; align-items: center; gap: 7px; color: var(--ink-3); }
.status .set-need {
  margin-inline-start: auto; font-size: var(--t-12); font-weight: var(--w-medium);
  color: var(--accent); padding: 2px 6px; border-radius: 7px;
}


.tag {
  font-size: var(--t-11); font-weight: var(--w-semi); padding: 3px 9px; border-radius: 999px;
  background: var(--in-soft); color: var(--in); white-space: nowrap; letter-spacing: 0;
}
.tag.paused { background: var(--sunk); color: var(--ink-2); }
.tag.alone { background: var(--red-soft); color: var(--red); }

/* money that has not landed yet is never shown as if it had */
.state-tag {
  display: inline-block; margin-top: 3px;
  font-size: var(--t-11); font-weight: var(--w-semi); letter-spacing: 0;
  padding: 2px 8px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn); white-space: nowrap;
}
.state-tag.planned { background: var(--sunk); color: var(--ink-2); }
td .state-tag { display: block; width: fit-content; margin-inline-start: auto; }

/* ==========================================================================
   Tables
   ========================================================================== */
.tbl-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; height: 52px; padding: 8px var(--s-5); font-size: var(--t-14); border-bottom: 1px solid var(--hair-2); vertical-align: middle; }
th {
  height: 40px; font-size: var(--t-11); font-weight: var(--w-semi); color: var(--ink-3);
  letter-spacing: .045em; text-transform: uppercase;
  background: var(--surface-2); position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
html[data-lang="ar"] th { letter-spacing: 0; text-transform: none; font-size: var(--t-12); }
tbody tr { transition: background var(--d-1) var(--ease); }

tbody tr:last-child td { border-bottom: 0; }
td.amt { font-weight: var(--w-semi); letter-spacing: -.022em; white-space: nowrap; }
td.amt.in { color: var(--in); }
td.amt.out { color: var(--out); }
td .sub { color: var(--ink-3); font-size: var(--t-12); margin-top: 1px; }
.cell-name { font-weight: var(--w-medium); }
tbody tr.off { opacity: .55; }
/* a corrected row stays on the record, struck, with its reason beside it */
tbody tr.voided td, .row-item.voided { opacity: .55; }
tbody tr.voided td.amt, .row-item.voided .amt { text-decoration: line-through; }
.sub.voided-why { color: var(--red); }
td .muted, .muted { color: var(--ink-3); }
html[dir="rtl"] .end { text-align: left; }
html[dir="ltr"] .end { text-align: right; }
.row-actions { display: flex; gap: var(--s-1); justify-content: flex-end; opacity: 1; transition: opacity var(--d-1) var(--ease); }
tfoot td { font-weight: var(--w-semi); border-top: 1px solid var(--hair); background: var(--surface-2); }

.empty { padding: 52px var(--s-5); text-align: center; }
.empty .ico {
  width: 46px; height: 46px; margin: 0 auto var(--s-3); border-radius: var(--r-lg);
  display: grid; place-items: center; background: var(--sunk); color: var(--ink-3);
}
.empty .ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.empty b { display: block; font-size: var(--t-15); font-weight: var(--w-semi); margin-bottom: 3px; }
.empty p { color: var(--ink-3); font-size: var(--t-13); }

.toolbar { display: flex; gap: var(--s-2); align-items: center; margin-bottom: var(--s-4); flex-wrap: wrap; }
.toolbar .search { position: relative; }
.toolbar .search svg { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: none; stroke: var(--ink-3); stroke-width: 1.76; stroke-linecap: round; }
.toolbar input[type=search] { width: 236px; padding-inline-start: 33px; background: var(--surface); border-color: var(--hair); }
.toolbar select { width: auto; min-width: 168px; background-color: var(--surface); border-color: var(--hair); }
.toolbar .spacer { margin-inline-start: auto; }

/* ==========================================================================
   Sheet
   ========================================================================== */
.scrim {
  position: fixed; inset: 0; z-index: 60; padding: var(--s-5);
  display: grid; place-items: center;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade var(--d-2) var(--ease) both;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(548px, 100%); max-height: 88dvh; overflow: auto;
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--r-2xl); box-shadow: var(--e3), var(--edge-hi);
  animation: pop var(--d-3) var(--spring) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.975); } }
.sheet .grabber { display: none; }
.sheet > header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-6) var(--s-1); }
.sheet > header h3 { font-size: var(--t-20); font-weight: var(--w-semi); letter-spacing: var(--tr-20); }
.sheet > header .sub { font-size: var(--t-13); color: var(--ink-3); margin-top: 2px; }
.sheet .body { padding: var(--s-3) var(--s-6) var(--s-1); display: grid; gap: var(--s-3); }
.sheet .body > p { color: var(--ink-2); font-size: var(--t-14); line-height: 1.55; }
.sheet footer { display: flex; gap: var(--s-2); justify-content: flex-end; padding: var(--s-4) var(--s-6) var(--s-5); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.divider { height: 1px; background: var(--hair-2); margin: var(--s-1) 0; }
.kid-row { display: flex; gap: 7px; align-items: center; margin-bottom: 7px; }
.kid-row input { flex: 1; min-width: 0; }
.kid-row input.age { flex: none; width: 74px; text-align: center; }

.toast {
  position: fixed; bottom: 28px; left: 50%; z-index: 90;
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--ink) 94%, transparent); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: var(--t-14); font-weight: var(--w-medium);
  box-shadow: var(--e3);
  animation: toastIn var(--d-3) var(--spring) both;
  display: flex; align-items: center; gap: var(--s-2);
}
html[data-theme="dark"] .toast { color: #000; }
.toast svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px) scale(.95); } }
.toast.closing { animation: toastOut var(--d-2) var(--ease) both; }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 10px) scale(.96); } }
.scrim.closing { animation: fadeOut var(--d-2) var(--ease) both; }
.scrim.closing .sheet { animation: popOut var(--d-2) var(--ease) both; }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes popOut { to { opacity: 0; transform: translateY(10px) scale(.985); } }

.btn.loading { pointer-events: none; opacity: .75; }
.btn.loading::before {
  content: ''; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* no entrance animations on a data refresh — only when the view itself changes */
.no-anim .fam, .no-anim .panel, .no-anim .hero { animation: none !important; }

.needs-preview { border: 1px solid var(--hair-2); border-radius: var(--r-md); overflow: hidden; }
.needs-row {
  display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: var(--s-3);
  align-items: center; padding: 9px var(--s-3); font-size: var(--t-13);
  border-bottom: 1px solid var(--hair-2);
}
.needs-row:last-child { border-bottom: 0; }
.needs-row.skipped { opacity: .45; }
.needs-row.total { background: var(--surface-2); font-weight: var(--w-semi); }
.needs-row .amt { font-weight: var(--w-semi); }

/* ==========================================================================
   Proof of delivery
   ========================================================================== */
.photo-field .shot { margin-top: 6px; }
.shot img { width: 100%; max-height: 220px; object-fit: cover; border-radius: var(--r-md); display: block; border: 1px solid var(--hair); }
.shot-acts { display: flex; gap: var(--s-2); margin-top: var(--s-2); }
.shot-add {
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  width: 100%; min-height: 88px; border-radius: var(--r-md);
  border: 1px dashed var(--hair-hi); background: var(--surface-2); color: var(--ink-2);
  font-size: var(--t-14); font-weight: var(--w-medium);
  transition: background var(--d-1) var(--ease), border-color var(--d-1) var(--ease), transform var(--d-1) var(--spring);
}
.shot-add:active { transform: scale(.985); }
.shot-add svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.shot-hint { font-size: var(--t-12); color: var(--ink-3); margin-top: 6px; line-height: 1.45; }
.shot-status { font-size: var(--t-12); color: var(--ink-3); margin-top: 6px; }

.proof { width: 34px; height: 34px; border-radius: var(--r-sm); overflow: hidden; display: block; padding: 0; }
.proof img { width: 100%; height: 100%; object-fit: cover; display: block; }
.proof.none { display: inline-grid; place-items: center; color: var(--ink-3); background: var(--sunk); font-size: var(--t-12); }
.row-item .proof { margin-top: var(--s-2); width: 44px; height: 44px; }

.lightbox {
  position: fixed; inset: 0; z-index: 95; display: grid; place-items: center;
  background: rgba(0,0,0,.82); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: var(--s-5); animation: fade var(--d-2) var(--ease) both; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 92dvh; border-radius: var(--r-lg); box-shadow: var(--e3); }

/* ==========================================================================
   Language control — a destination, not a preference
   ========================================================================== */
.lang-switch { padding: 0 var(--s-1) var(--s-4); }
.seg.lang-seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; padding: 3px; }
.seg.lang-seg button { padding: 7px 10px; font-size: var(--t-13); font-weight: var(--w-semi); }
.ar-face { font-family: var(--ar), var(--lat), sans-serif; font-size: var(--t-14); }

.lang-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px;
  border-radius: 999px; background: var(--sunk); color: var(--ink);
  font-size: var(--t-13); font-weight: var(--w-semi); white-space: nowrap;
  transition: transform var(--d-1) var(--spring), background var(--d-2) var(--ease);
}
.lang-pill:active { transform: scale(.95); background: var(--bg-2); }
.lang-pill svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.76; }

html.lang-flip main, html.lang-flip aside, html.lang-flip .topbar, html.lang-flip .tabbar {
  animation: langFlip var(--d-3) var(--spring) both;
}
@keyframes langFlip { from { opacity: .3; transform: translateY(3px); } }

/* this build is not the live ledger — say so, quietly but unmistakably */
.env-pill {
  font-size: var(--t-11); font-weight: var(--w-bold); letter-spacing: .06em;
  padding: 4px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--warn-soft); color: var(--warn);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 35%, transparent);
}

/* ==========================================================================
   Mobile chrome — app bar + bottom tab bar
   ========================================================================== */
.topbar, .tabbar { display: none; }

.topbar {
  grid-column: 1 / -1; position: sticky; top: 0; z-index: 40;
  align-items: center; justify-content: space-between; gap: var(--s-2);
  padding: max(8px, env(safe-area-inset-top)) var(--s-3) var(--s-2);
  padding-inline-start: max(var(--s-3), env(safe-area-inset-left));
  padding-inline-end: max(var(--s-3), env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hair-2);
}
.brand-sm { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.brand-sm .mark { width: 28px; height: 28px; border-radius: 9px; margin: 0; box-shadow: none; }
.brand-sm .mark svg { width: 15px; height: 15px; }
.brand-sm b {
  font-size: var(--t-15); font-weight: var(--w-semi); letter-spacing: var(--tr-15);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar:has(.env-pill) .brand-sm b { display: none; }
.topbar-actions { display: flex; align-items: center; gap: var(--s-2); }

.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 45;
  grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px var(--s-1) calc(4px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid var(--hair);
}
.tabbar .tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px 4px; min-height: 48px; border-radius: var(--r-md);
  color: var(--ink-3); transition: color var(--d-1) var(--ease), transform var(--d-1) var(--spring);
}
.tabbar .tab:active { transform: scale(.94); }
.tabbar .tab.on { color: var(--accent); }
.tabbar .tab-ico { position: relative; display: grid; place-items: center; height: 24px; }
.tabbar .tab-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar .tab.on .tab-ico svg { stroke-width: 1.75; }   /* selection is the only weight change */
.tabbar .tab-ico .dot {
  position: absolute; top: 0; inset-inline-end: -2px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--accent); opacity: .8;
}
.tabbar .tab.on .tab-ico .dot { opacity: 1; }
.tabbar .tab-label { font-size: 10.5px; font-weight: var(--w-medium); letter-spacing: 0; line-height: 1.1; text-align: center; }
html[data-lang="ar"] .tabbar .tab-label { font-size: var(--t-11); }

/* ==========================================================================
   List rows — what tables become on a phone
   ========================================================================== */
.rows { display: flex; flex-direction: column; }
.row-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--hair-2);
  transition: background var(--d-1) var(--ease);
}
.row-item:last-child { border-bottom: 0; }
.row-item:active { background: var(--surface-2); }
.row-item.off { opacity: .55; }
.row-item .ttl { font-size: var(--t-15); font-weight: var(--w-medium); letter-spacing: var(--tr-15); }
.row-item .sub { font-size: var(--t-12); color: var(--ink-3); margin-top: 2px; }
.row-item .sub.note { color: var(--ink-2); }
.row-end { display: flex; align-items: center; gap: 6px; }
.row-end .amt { font-size: var(--t-15); font-weight: var(--w-semi); letter-spacing: -.024em; white-space: nowrap; }
.row-end .amt.in { color: var(--in); }
.row-end .amt.out { color: var(--out); }
.row-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--s-3) var(--s-4); border-top: 1px solid var(--hair);
  background: var(--surface-2); font-size: var(--t-13); color: var(--ink-2); font-weight: var(--w-medium);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1180px) { .two-up { grid-template-columns: 1fr; } }
@media (max-width: 1080px) { .wrap { padding: var(--s-6) var(--s-6) 96px; } }

@media (max-width: 900px) {
  aside { display: none; }
  .topbar { display: flex; }
  .tabbar { display: grid; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  main { grid-column: 1; grid-row: 2; }
  .wrap {
    padding: var(--s-4) var(--s-4) calc(84px + env(safe-area-inset-bottom));
    padding-inline-start: max(var(--s-4), env(safe-area-inset-left));
    padding-inline-end: max(var(--s-4), env(safe-area-inset-right));
    max-width: none;
  }

  .head { flex-direction: column; align-items: stretch; gap: var(--s-3); margin-bottom: var(--s-5); }
  .head h1 { font-size: var(--t-24); letter-spacing: var(--tr-24); }
  .head-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
  .head-actions > * { min-height: 44px; }
  .head-actions > *:first-child:nth-last-child(3) { grid-column: 1 / -1; }

  .hero {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main ring" "split split";
    padding: var(--s-5) var(--s-4); row-gap: var(--s-4); column-gap: var(--s-3); border-radius: var(--r-xl);
  }
  .hero .balance { font-size: 38px; }
  .hero .split { grid-template-columns: 1fr 1fr; gap: var(--s-3); }
  .hero .ring svg { width: 88px; height: 88px; }
  .hero .ring .label b { font-size: var(--t-17); }
  .hero > .ring { align-self: start; }

  .panel { border-radius: var(--r-lg); }
  .panel > header { padding: var(--s-3) var(--s-4); }
  .attn-row, .tl-row { padding: var(--s-3) var(--s-4); }
  .attn-row { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: var(--s-3); }
  .attn-row > .btn { grid-column: 1 / -1; justify-self: stretch; min-height: 44px; }
  .attn-row .rail { max-width: none; }
  .fam-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
  .fam { grid-template-rows: auto auto auto auto auto; }   /* single column: no alignment to hold */
  .fam .situation { -webkit-line-clamp: 3; }
  .fam .acts { opacity: 1; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar input[type=search] { width: 100%; min-height: 44px; }
  .toolbar select { flex: 1; min-height: 44px; }
  .toolbar .spacer { display: none; }


  /* sheets become bottom sheets */
  .scrim { place-items: end center; padding: 0; }
  .sheet {
    width: 100%; max-width: none; max-height: 92dvh;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0; border-bottom: 0;
    animation: sheetUp var(--d-3) var(--spring) both;
  }
  .scrim.closing .sheet { animation: sheetDown var(--d-2) var(--ease) both; }
  .sheet .grabber { display: block; width: 38px; height: 5px; border-radius: 999px; background: var(--hair-hi); margin: var(--s-2) auto 0; }
  .sheet > header { padding: var(--s-3) var(--s-5) var(--s-1); }
  .sheet .body { padding: var(--s-2) var(--s-5) var(--s-1); }
  .sheet footer {
    position: sticky; bottom: 0; z-index: 2;
    padding: var(--s-3) var(--s-5) calc(var(--s-4) + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--hair-2);
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--s-2);
  }
  .sheet footer .btn { min-height: 46px; font-size: var(--t-15); }
  .two { grid-template-columns: 1fr; gap: var(--s-2); }
  /* 16px keeps iOS from zooming the field on focus */
  input[type=text], input[type=password], input[type=number], input[type=date],
  input[type=search], select, textarea { font-size: 16px; padding: 12px 14px; }

  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
}

@keyframes sheetUp { from { opacity: .7; transform: translateY(100%); } }

/* every coarse pointer — phone or iPad — gets Apple's 44pt floor */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; border-radius: var(--r-md); }
  .icon-btn svg { width: 19px; height: 19px; stroke-width: 1.39; }
  .row-actions, .fam .acts { gap: var(--s-1); }
  /* the irreversible control gets separation, not just a colour */
  .row-actions .icon-btn.del, .fam .acts .icon-btn.del { margin-inline-start: var(--s-2); }
  .btn { min-height: 44px; padding: 11px var(--s-5); }
  .btn.sm { min-height: 44px; padding: 11px var(--s-4); font-size: var(--t-15); }
  .btn.full { min-height: 50px; }
  .seg button { min-height: 40px; padding: 0 var(--s-4); }
  .theme-seg button { min-height: 40px; width: 44px; }
  .lang-pill { height: 40px; }
  .who .out { width: 44px; height: 44px; }
  .chip { padding: 6px var(--s-3); font-size: var(--t-13); }
  input[type=text], input[type=password], input[type=number],
  input[type=date], input[type=search], select, textarea {
    font-size: 16px; min-height: 46px; padding: 12px 14px;
  }
  textarea { min-height: 92px; }
  .kid-row input.age { width: 84px; }
  .status .set-need { min-height: 44px; padding: 0 var(--s-3); display: inline-flex; align-items: center; }
  .seg button { min-height: 44px; }
  .theme-seg button { min-height: 44px; width: 46px; }
  .lang-pill { height: 44px; padding: 0 var(--s-4); }
  .tabbar .tab { min-height: 52px; }
}
@keyframes sheetDown { to { opacity: .5; transform: translateY(100%); } }

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { background: var(--bg); }
  .tabbar, aside { background: var(--surface); }
}

@media (max-width: 380px) {
  .hero { grid-template-areas: "main" "ring" "split"; grid-template-columns: 1fr; }
  .hero .balance { font-size: 34px; }
  .tabbar .tab-label { font-size: 9.5px; }
  .brand-sm b { display: none; }
  .fam .top { flex-wrap: wrap; }
  .fam .acts { flex-basis: 100%; margin-inline-start: 0; justify-content: flex-end; }
}
