/* ───────────────────────────────────────────────────────────
   Masjithul Qhaif — Jamath portal
   Palette taken from the building: tile-panel teal, sandstone
   lettering, the green dome, and the white jaali wall.
   ─────────────────────────────────────────────────────────── */
/* Fonts are bundled (SIL Open Font License) so the portal never waits on Google. */
@font-face { font-family: 'Marcellus'; src: url('fonts/marcellus-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Noto Serif Tamil'; src: url('fonts/noto-serif-tamil-tamil-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0B80-0BFF, U+200C-200D; }
@font-face { font-family: 'Noto Serif Tamil'; src: url('fonts/noto-serif-tamil-tamil-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; unicode-range: U+0B80-0BFF, U+200C-200D; }
@font-face { font-family: 'Amiri'; src: url('fonts/amiri-arabic-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Amiri'; src: url('fonts/amiri-arabic-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Hanken Grotesk'; src: url('fonts/hanken-grotesk-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Hanken Grotesk'; src: url('fonts/hanken-grotesk-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Hanken Grotesk'; src: url('fonts/hanken-grotesk-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Hanken Grotesk'; src: url('fonts/hanken-grotesk-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Hanken Grotesk'; src: url('fonts/hanken-grotesk-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }

:root {
  --tile: #123f3a;        /* deep tile teal — sidebar, primary */
  --tile-2: #1b5a52;      /* hover / primary buttons */
  --tile-3: #2b7a6f;
  --dome: #2f8a4f;        /* paid / success */
  --dome-soft: #e2f1e6;
  --sand: #b98a3e;        /* sandstone lettering — accent */
  --sand-2: #d4ad66;
  --sand-soft: #f6eedd;
  --void: #a2383a;
  --void-soft: #f8e5e3;
  --warn: #b26a12;
  --warn-soft: #fbefdc;

  --bg: #f3f5f2;          /* limestone */
  --surface: #ffffff;
  --surface-2: #f8faf7;
  --line: #dce3dd;
  --line-2: #c9d3cc;
  --ink: #12241f;
  --ink-2: #33473f;
  --muted: #62756d;
  --focus: #d4ad66;

  --r-lg: 18px;
  --r: 12px;
  --r-sm: 9px;
  --shadow: 0 1px 2px rgba(18, 63, 58, .06), 0 8px 24px -12px rgba(18, 63, 58, .18);
  --shadow-lg: 0 24px 60px -20px rgba(10, 40, 35, .45);

  --f-ui: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-display: 'Marcellus', 'Iowan Old Style', Georgia, serif;
  --f-ar: 'Amiri', 'Traditional Arabic', serif;

  --jaali: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23d4ad66' stroke-opacity='.32' stroke-width='1'%3E%3Cpath d='M32 17 47 32 32 47 17 32Z'/%3E%3Cpath d='M21.5 21.5h21v21h-21z'/%3E%3Cpath d='M32 0v17M32 47v17M0 32h17M47 32h17M0 0l21.5 21.5M64 0 42.5 21.5M0 64l21.5-21.5M64 64 42.5 42.5'/%3E%3Ccircle cx='32' cy='32' r='3'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tile: #0d2e2a; --tile-2: #2b7a6f; --tile-3: #4aa395;
    --dome: #4fb36f; --dome-soft: #173326;
    --sand: #d4ad66; --sand-2: #e3c58a; --sand-soft: #2e2618;
    --void: #e0716f; --void-soft: #3a1d1c; --warn: #e4a352; --warn-soft: #33260f;
    --bg: #0c1714; --surface: #12201c; --surface-2: #0f1c18;
    --line: #22352f; --line-2: #2d443c;
    --ink: #e5eee9; --ink-2: #c3d1ca; --muted: #8fa49b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--f-ui); font-feature-settings: "tnum" 1, "lnum" 1;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 400; }
h1, h2 { font-family: var(--f-display); letter-spacing: .005em; }
h3 { font-weight: 700; font-size: 1rem; }
a { color: var(--tile-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
p { margin: 0; }
small, .muted { color: var(--muted); }
.muted { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ar { font-family: var(--f-ar); direction: rtl; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Shell ─────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  background: var(--tile); color: #e7efe9; padding: 18px 14px 14px; overflow-y: auto;
  background-image: linear-gradient(180deg, rgba(18,63,58,.0), rgba(18,63,58,.92) 62%), var(--jaali);
  background-size: auto, 64px 64px;
}
.side::after { /* sandstone edge, like the lettering band on the facade */
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--sand-2), var(--sand) 40%, transparent);
  opacity: .55;
}
.brand { display: flex; align-items: center; gap: 11px; color: inherit; padding: 4px 6px 16px; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 50%; object-fit: cover; border: 2px solid var(--sand-2); background: #fff; flex: none; }
.brand-name { display: block; font-family: var(--f-display); font-size: 1.12rem; color: #fff; line-height: 1.15; }
.brand-sub { display: block; font-size: .76rem; color: var(--sand-2); letter-spacing: .02em; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: #c8d8d0; font-weight: 600; font-size: .93rem; transition: background .15s, color .15s;
}
.side-nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side-nav a.on { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--sand-2); }
.side-nav a.side-cta { margin: 6px 0 8px; background: var(--sand-2); color: #1a1408; }
.side-nav a.side-cta:hover { background: #e3c58a; }
.side-nav a.side-cta.on { box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.side-sep { margin: 16px 12px 4px; font-size: .74rem; color: var(--sand-2); opacity: .85; font-weight: 600; }
.side-user {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.side-user-name { flex: 1; min-width: 0; color: #fff; font-weight: 600; font-size: .9rem; line-height: 1.2; }
.side-user-name small { display: block; color: #9fb7ad; font-weight: 500; font-size: .76rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--sand-soft); color: #6d4f1d; font-weight: 800; font-size: .8rem;
}
.avatar.sm { width: 30px; height: 30px; font-size: .74rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.15rem; }

.topbar, .tabbar { display: none; }
.main { padding: 28px clamp(16px, 3vw, 40px) 64px; max-width: 1240px; width: 100%; }

/* ── Page header ───────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: clamp(1.7rem, 2.6vw, 2.2rem); line-height: 1.1; }
.page-head p { color: var(--muted); margin-top: 6px; max-width: 64ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: .86rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  --b: var(--tile-2); --c: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 11px; border: 1px solid transparent;
  background: var(--b); color: var(--c); font: 700 .92rem/1 var(--f-ui); cursor: pointer;
  transition: background .15s, transform .08s, box-shadow .15s; white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.gold { --b: var(--sand-2); --c: #1a1408; }
.btn.ghost { --b: var(--surface); --c: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.danger { --b: var(--void); }
.btn.danger-ghost { --b: transparent; --c: var(--void); border-color: color-mix(in srgb, var(--void) 40%, transparent); }
.btn.wa { --b: #1f8f55; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .84rem; border-radius: 9px; }
.btn.lg { min-height: 52px; padding: 0 24px; font-size: 1rem; border-radius: 13px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.ghost-light { color: #9fb7ad; }
.icon-btn.ghost-light:hover { background: rgba(255,255,255,.08); color: #fff; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Panels ────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.panel-pad { padding: 20px 22px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1.2rem; }
.panel-head .muted { margin-left: auto; }
.panel-head .actions { margin-left: auto; display: flex; gap: 8px; }
.stack { display: grid; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 18px; align-items: start; }

/* ── Forms ─────────────────────────────────────────────── */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: .8rem; color: var(--muted); }
.req::after { content: " *"; color: var(--void); }
input:where(:not([type]),[type=text],[type=search],[type=number],[type=date],[type=month],[type=tel],[type=password],[type=email]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 13px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: 500 .95rem/1.3 var(--f-ui); transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; }
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2362756d' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--tile-3); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--tile-3) 22%, transparent); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.form-grid { display: grid; gap: 16px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--tile-2); flex: none; }

/* segmented + chips (radio based) */
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: .88rem; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg input:focus-visible + span { outline: 2.5px solid var(--focus); }
.seg a { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: .88rem; color: var(--muted); }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg .count { font-size: .76rem; color: var(--muted); font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; cursor: pointer; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; font-size: .9rem; color: var(--ink-2);
  transition: background .12s, border-color .12s, color .12s;
}
.chips label:hover span { border-color: var(--tile-3); }
.chips input:checked + span { background: var(--tile-2); border-color: var(--tile-2); color: #fff; }
.chips input:focus-visible + span { outline: 2.5px solid var(--focus); outline-offset: 2px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: .82rem; font-weight: 600; color: var(--ink-2); background: var(--surface); }
.quick a:hover { border-color: var(--tile-3); text-decoration: none; }
.quick a.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* month picker (subscription months) */
.months { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.months label { position: relative; }
.months input { position: absolute; opacity: 0; }
.months span {
  display: grid; place-items: center; gap: 1px; padding: 9px 2px 7px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface); font-weight: 700; font-size: .88rem; line-height: 1.1;
}
.months span small { font-size: .68rem; font-weight: 600; color: var(--muted); }
.months input:checked + span { background: var(--tile-2); color: #fff; border-color: var(--tile-2); }
.months input:checked + span small { color: #cfe5df; }
.months input:disabled + span { background: var(--dome-soft); border-color: transparent; color: var(--dome); cursor: default; }
.months input:disabled + span small { color: var(--dome); }
.months input:focus-visible + span { outline: 2.5px solid var(--focus); outline-offset: 2px; }
.fy-switch { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: .88rem; }

/* ── Tables ────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th { text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr[data-href] { cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .r { text-align: right; }
.tbl .amt { font-weight: 700; text-align: right; white-space: nowrap; }
.tbl tr.is-void td { color: var(--muted); }
.tbl tr.is-void .amt { text-decoration: line-through; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who b { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }
.who small { display: block; font-size: .8rem; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* member code badges: Database 1 = teal, Database 2 = sandstone */
.code { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; padding: 3px 8px; border-radius: 7px; font-weight: 800; font-size: .78rem; letter-spacing: .01em; flex: none; }
.code-a { background: color-mix(in srgb, var(--tile-2) 12%, transparent); color: var(--tile-2); }
.code-b { background: var(--sand-soft); color: #7c5a1f; }
.code-guest { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .code-a { color: var(--tile-3); } :root:not([data-theme="light"]) .code-b { color: var(--sand-2); } }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.pill-void { background: var(--void-soft); color: var(--void); }
.pill-ok { background: var(--dome-soft); color: var(--dome); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-mute { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.mode { font-size: .84rem; color: var(--ink-2); }

/* 12-month strip — the portal's signature: each square is a month of the financial year */
.mstrip { display: inline-grid; grid-template-columns: repeat(12, 9px); gap: 3px; vertical-align: middle; }
.mstrip .m { width: 9px; height: 13px; border-radius: 2.5px; background: var(--line); }
.mstrip .m.paid { background: var(--dome); }
.mstrip .m.due { background: color-mix(in srgb, var(--void) 30%, var(--line)); }
.mstrip .m.now { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--sand); }
.mstrip .m.future { background: var(--line); opacity: .55; }
.mstrip-lg { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; width: 100%; }
.mstrip-lg .m { width: auto; height: auto; display: grid; place-items: center; gap: 2px; padding: 10px 2px; border-radius: 10px; font-size: .82rem; }
.mstrip-lg .m b { font-weight: 700; }
.mstrip-lg .m i { font-style: normal; font-size: .7rem; font-weight: 600; min-height: 1em; }
.mstrip-lg .m.paid { color: #fff; }
.mstrip-lg .m.due { background: var(--void-soft); color: var(--void); }
.mstrip-lg .m.now { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--sand); }
.mstrip-lg .m.future { color: var(--muted); opacity: 1; background: var(--surface-2); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 12px; border-radius: 2.5px; display: inline-block; }

/* ── Filter bar ────────────────────────────────────────── */
.filters { display: grid; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.filters-row { display: grid; grid-template-columns: minmax(200px, 2fr) repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; align-items: end; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px; }
.summary-line { display: flex; align-items: baseline; gap: 10px 20px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.summary-line .big { font-family: var(--f-display); font-size: 1.6rem; line-height: 1; }
.summary-line .split { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.summary-line .split b { color: var(--ink); font-weight: 700; }
.summary-line .actions { margin-left: auto; display: flex; gap: 8px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-top: 1px solid var(--line); }

/* ── Dashboard ─────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-lg); color: #fff;
  background: var(--tile); padding: 28px 28px 24px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end;
}
.hero::before {
  content: ""; position: absolute; inset: 0; background: var(--jaali); background-size: 64px 64px; opacity: .55;
  -webkit-mask-image: linear-gradient(100deg, transparent 35%, #000 95%); mask-image: linear-gradient(100deg, transparent 35%, #000 95%);
}
.hero > * { position: relative; }
.hero .greet { color: var(--sand-2); font-weight: 600; font-size: .95rem; }
.hero .greet .ar { font-size: 1.15rem; margin-left: 6px; }
.hero h1 { font-size: clamp(2.6rem, 6vw, 4.2rem); line-height: 1; margin: 10px 0 8px; font-family: var(--f-display); }
.hero h1 .rs { font-size: .55em; vertical-align: .55em; margin-right: 4px; color: var(--sand-2); }
.hero p { color: #c7d8d1; max-width: 52ch; }
.hero p b { color: #fff; font-weight: 700; }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ledger { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ledger > div { padding: 18px 22px; border-right: 1px solid var(--line); min-width: 0; }
.ledger > div:last-child { border-right: 0; }
.ledger .k { font-size: .84rem; color: var(--muted); font-weight: 600; }
.ledger .v { font-family: var(--f-display); font-size: 1.65rem; line-height: 1.15; margin-top: 4px; white-space: nowrap; }
.ledger .s { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.ledger a.s { display: inline-block; color: var(--tile-2); font-weight: 600; }

.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; align-items: end; height: 190px; padding: 6px 22px 0; }
.bar { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 6px; text-align: center; }
.bar-col { position: relative; display: flex; align-items: flex-end; justify-content: center; }
.bar-col i {
  display: block; width: 100%; max-width: 34px; border-radius: 7px 7px 3px 3px; background: color-mix(in srgb, var(--tile-2) 26%, var(--line));
  min-height: 3px; transform-origin: bottom; animation: grow .6s cubic-bezier(.2,.8,.2,1) both;
}
.bar.now .bar-col i { background: var(--sand-2); }
.bar.has .bar-col i { background: var(--tile-2); }
.bar.now.has .bar-col i { background: var(--sand); }
.bar-col b { position: absolute; bottom: calc(var(--h) + 6px); font-size: .7rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; opacity: 0; transition: opacity .15s; }
.bar:hover .bar-col b, .bar.now .bar-col b { opacity: 1; }
.bar span { font-size: .76rem; color: var(--muted); font-weight: 600; }
.bar.now span { color: var(--ink); }
@keyframes grow { from { transform: scaleY(0); } }
.chart-foot { display: flex; justify-content: space-between; padding: 12px 22px 18px; font-size: .82rem; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .grow small { display: block; font-size: .8rem; }
.list a.row-link { color: inherit; display: contents; }
.list li:hover { background: var(--surface-2); }

.purpose-bars { display: grid; gap: 12px; padding: 18px 22px; }
.pbar { display: grid; gap: 6px; }
.pbar-top { display: flex; justify-content: space-between; font-size: .88rem; }
.pbar-top b { font-weight: 700; }
.pbar-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.pbar-track i { display: block; height: 100%; background: var(--tile-2); border-radius: 99px; }
.pbar:nth-child(2) .pbar-track i { background: var(--sand); }
.pbar:nth-child(3) .pbar-track i { background: var(--dome); }
.pbar:nth-child(4) .pbar-track i { background: var(--tile-3); }

/* ── Receipt composer ──────────────────────────────────── */
.composer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, .9fr); gap: 24px; align-items: start; }
.composer .preview-col { position: sticky; top: 24px; display: grid; gap: 12px; }
.step { padding: 20px 22px; border-bottom: 1px solid var(--line); display: grid; gap: 14px; }
.step:last-child { border-bottom: 0; }
.step-title { display: flex; align-items: center; gap: 10px; }
.step-title h2 { font-size: 1.15rem; }
.step-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--sand-soft); color: #7c5a1f; font-weight: 800; font-size: .8rem; flex: none; }
.step-title .aside { margin-left: auto; }

.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow-lg); max-height: 360px; overflow-y: auto; padding: 6px;
}
.combo-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.combo-item[aria-selected="true"], .combo-item:hover { background: var(--surface-2); }
.combo-item .grow { flex: 1; min-width: 0; }
.combo-item b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-item small { display: block; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-item mark { background: var(--sand-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.combo-empty { padding: 14px; color: var(--muted); font-size: .9rem; display: grid; gap: 10px; }
.combo-foot { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }

.picked {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line);
}
.picked .name { font-weight: 800; font-size: 1.05rem; }
.picked .meta { font-size: .84rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.picked .meta span { display: inline-flex; align-items: center; gap: 5px; }
.picked .status { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 10px; border-top: 1px dashed var(--line-2); font-size: .85rem; }

.amount-field { position: relative; }
.amount-field .rs { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-family: var(--f-display); font-size: 1.6rem; color: var(--sand); }
.amount-field input { min-height: 64px; padding-left: 44px; font: 400 2rem/1 var(--f-display); letter-spacing: .01em; }
.words { font-size: .88rem; color: var(--muted); font-style: italic; min-height: 1.3em; }

.save-bar { display: flex; gap: 10px; align-items: center; padding: 18px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.save-bar .kbd { margin-left: auto; font-size: .78rem; color: var(--muted); }
kbd { font: 600 .74rem var(--f-ui); padding: 2px 6px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--surface); }

/* ── The receipt — A5 landscape (screen preview + print) ── */
.paper-fit { position: relative; width: 100%; min-width: 0; height: 508px; }
.paper-fit > .paper { position: absolute; top: 0; left: 0; transform-origin: top left; }
.preview-col, .receipt-page > div { min-width: 0; }
.paper {
  --ink: #123f3a; --brass: #b98a3e; --brass-2: #c9a35d; --pale: #f4ecdb; --rule: #e3d6b8; --soft: #6c7b74;
  position: relative; width: 744px; height: 508px; overflow: hidden;
  display: grid; grid-template-rows: auto 1fr auto;
  background: #fffdf8; color: #1d2a25; border-radius: 4px; padding: 26px 30px 18px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 22px 44px -20px rgba(10,40,35,.5);
  font: 500 12.5px/1.45 var(--f-ui);
}
.paper::before { /* double sandstone rule border */
  content: ""; position: absolute; inset: 9px; border: 1px solid var(--brass-2); border-radius: 3px; pointer-events: none;
  box-shadow: inset 0 0 0 3px #fffdf8, inset 0 0 0 4px #e8d6ac;
}
.paper-corner { position: absolute; width: 16px; height: 16px; color: var(--brass); background: #fffdf8; z-index: 1; }
.paper-corner.tl { top: 2px; left: 2px; } .paper-corner.tr { top: 2px; right: 2px; } .paper-corner.bl { bottom: 2px; left: 2px; } .paper-corner.br { bottom: 2px; right: 2px; }
.paper-wm { position: absolute; width: 260px; height: 260px; right: 40px; top: 150px; color: var(--brass); opacity: .07; pointer-events: none; }
.paper .ghost { color: #b5b9b2; font-weight: 500; }

/* header: balanced letterhead — logo | centred name | receipt number, side columns equal width */
.pp-head { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center; padding-bottom: 12px; margin: 0 -8px; }
.pp-head::after { /* brass rule, like the lettering band on the facade */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass-2) 8%, var(--brass-2) 92%, transparent);
}
.pp-side { display: grid; place-items: center; align-self: stretch; }
.pp-logo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 2.5px solid var(--brass-2); box-shadow: 0 0 0 3px #fffdf8, 0 0 0 4px #e8d6ac; }
.pp-org { min-width: 0; overflow: hidden; text-align: center; display: grid; justify-items: center; gap: 2px; padding: 4px 0; }
.paper .bism { font-family: var(--f-ar); font-size: 19px; color: var(--ink); line-height: 1.5; margin-bottom: 3px; word-spacing: .4em; }
.paper .org { font-family: var(--f-display); font-size: 19.5px; line-height: 1.2; color: var(--ink); white-space: nowrap; letter-spacing: -.005em; }
.pp-flourish { display: flex; align-items: center; gap: 8px; width: 62%; margin: 3px 0 1px; color: var(--brass-2); }
.pp-flourish::before, .pp-flourish::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .7; }
.pp-flourish svg { width: 9px; height: 9px; flex: none; }
.paper .org-ar { font-family: var(--f-ar); font-size: 16px; color: #8b6a2c; line-height: 1.5; word-spacing: .35em; margin: 1px 0 2px; }
.paper .addr { font-size: 10px; color: #5f6f68; line-height: 1.4; text-wrap: balance; }
.paper .reg { font-size: 9.5px; color: #8b6a2c; font-weight: 700; letter-spacing: .02em; }
.pp-no { align-content: center; justify-items: center; text-align: center; gap: 0; border: 1px solid var(--rule); border-radius: 6px; padding: 9px 14px; min-width: 112px; background: linear-gradient(#fffdf8, #fbf5e8); align-self: center; }
.pp-kind { font-family: var(--f-display); font-size: 13px; color: var(--brass); letter-spacing: .14em; text-transform: uppercase; }
.pp-num { display: flex; align-items: baseline; gap: 3px; }
.pp-num small { font-size: 10px; color: var(--soft); }
.pp-num b { font-family: var(--f-display); font-weight: 400; font-size: 28px; line-height: 1.05; color: #1d2a25; }
.pp-date { font-size: 11px; font-weight: 700; color: #1d2a25; }
.pp-fy { font-size: 10px; color: var(--soft); }

/* body: details left, amount right */
.pp-body { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 22px; align-items: center; padding: 12px 0 6px; min-height: 0; }
.pp-lines { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; row-gap: 6px; align-content: center; }
.pline { display: grid; gap: 1px; border-bottom: 1px dotted #d3c6a8; padding-bottom: 4px; min-width: 0; }
.pline.wide { grid-column: 1 / -1; }
.pline[hidden] { display: none; }
.pline > span { font-size: 9.5px; color: var(--soft); letter-spacing: .02em; }
.pline b { font-weight: 700; font-size: 13px; overflow-wrap: anywhere; line-height: 1.3; }
.pline.wide:first-child b { font-size: 15px; }
.pline b small { color: var(--soft); font-weight: 500; font-size: 11px; }
.pp-amount {
  position: relative; display: grid; gap: 4px; align-content: center; text-align: center; padding: 16px 14px;
  background: var(--pale); border: 1px solid #e3cc9d; border-radius: 6px; min-height: 140px;
}
.pp-amount::before { content: ""; position: absolute; inset: 4px; border: 1px dashed #d9bf86; border-radius: 4px; pointer-events: none; }
.pp-amount-k { font-size: 10px; color: #8b6a2c; font-weight: 700; letter-spacing: .04em; }
.pp-amount .fig { font-family: var(--f-display); font-size: 34px; line-height: 1.1; color: var(--ink); white-space: nowrap; }
.pp-amount .w { font-size: 11px; font-style: italic; color: #5f4a22; line-height: 1.35; }

/* signatures */
.pp-foot { display: grid; gap: 8px; }
.pp-signs { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 34px; padding: 0 10px; }
.pp-sign { display: grid; justify-items: center; text-align: center; }
.pp-sign-ink { height: 52px; width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid #a8946a; padding-bottom: 2px; }
.pp-sign-ink img { max-height: 50px; max-width: 150px; object-fit: contain; transform: rotate(-2deg); margin-bottom: -6px; }
.pp-sign-ta { font-family: 'Noto Serif Tamil', var(--f-ui); font-weight: 600; font-size: 12px; color: var(--ink); margin-top: 5px; line-height: 1.3; }
.pp-sign-en { font-size: 9px; color: var(--soft); letter-spacing: .08em; text-transform: uppercase; }
.pp-note { display: flex; justify-content: space-between; gap: 12px; font-size: 9.5px; color: #8a958f; border-top: 1px solid #efe5cf; padding-top: 6px; }
.pp-note .note { color: #8b6a2c; font-style: italic; font-size: 10.5px; }

.paper-void { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; overflow: hidden; z-index: 2; }
.paper-void span {
  transform: rotate(-16deg); border: 5px double #a2383a; color: #a2383a; padding: 8px 34px; border-radius: 12px;
  font: 400 64px/1 var(--f-display); letter-spacing: .14em; opacity: .75; background: rgba(255,253,248,.55);
}

.receipt-page { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.receipt-actions { display: grid; gap: 10px; }

/* success state after saving */
.done { text-align: center; display: grid; justify-items: center; gap: 10px; padding: 36px 22px; }
.done .tick { width: 64px; height: 64px; border-radius: 50%; background: var(--dome-soft); color: var(--dome); display: grid; place-items: center; animation: pop .35s cubic-bezier(.2,1.4,.4,1) both; }
.done h2 { font-size: 1.8rem; }
.done .actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

/* ── Member profile ────────────────────────────────────── */
.profile-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 22px; }
.profile-head h1 { font-size: 1.9rem; line-height: 1.1; }
.profile-head .meta { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); margin-top: 8px; }
.profile-head .meta span { display: inline-flex; align-items: center; gap: 6px; }
.profile-head .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--line); }
.facts > div { padding: 14px 22px; border-right: 1px solid var(--line); }
.facts > div:last-child { border-right: 0; }
.facts .k { font-size: .8rem; color: var(--muted); font-weight: 600; }
.facts .v { font-weight: 700; margin-top: 2px; }

/* ── Dues grid (year view) ─────────────────────────────── */
.ygrid th.mcol, .ygrid td.mcol { text-align: center; padding-left: 2px; padding-right: 2px; width: 44px; }
.ygrid .cell { display: inline-block; width: 26px; height: 22px; border-radius: 6px; background: var(--line); opacity: .55; }
.ygrid .cell.paid { background: var(--dome); opacity: 1; }
.ygrid .cell.due { background: var(--void-soft); opacity: 1; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--void) 35%, transparent); }
.ygrid .cell.now { background: transparent; opacity: 1; box-shadow: inset 0 0 0 1.5px var(--sand); }
.ygrid td.mcol a { display: inline-block; line-height: 0; }

/* ── Dialogs, sheet, toast, flash ──────────────────────── */
dialog { border: 0; padding: 0; color: var(--ink); background: transparent; max-width: calc(100vw - 24px); }
dialog::backdrop { background: rgba(8, 28, 24, .55); backdrop-filter: blur(2px); }
.modal { width: min(560px, calc(100vw - 24px)); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden; }
dialog[open] .modal { animation: rise .22s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.3rem; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 20px 22px; display: grid; gap: 16px; max-height: min(70vh, 640px); overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }
.modal-foot .left { margin-right: auto; }

.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; }
.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 10px auto; }
.sheet { background: var(--surface); border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
.sheet-nav { display: grid; padding: 4px 10px 16px; }
.sheet-nav a { display: flex; gap: 14px; align-items: center; padding: 14px 12px; border-radius: 12px; color: var(--ink); font-weight: 600; }
.sheet-nav a:hover { background: var(--surface-2); text-decoration: none; }

.toast-wrap { position: fixed; z-index: 90; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; min-width: 240px; max-width: 420px;
  background: var(--ink); color: var(--surface); font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg);
  animation: rise .2s ease-out;
}
.toast.err { background: var(--void); color: #fff; }
.flash { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 600; font-size: .92rem; }
.flash-ok { background: var(--dome-soft); color: var(--dome); }
.flash-err { background: var(--void-soft); color: var(--void); }
.note-box { padding: 12px 14px; border-radius: 12px; background: var(--sand-soft); color: #6d4f1d; font-size: .88rem; display: flex; gap: 10px; align-items: flex-start; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .note-box { color: var(--sand-2); } }
.err-box { padding: 12px 14px; border-radius: 12px; background: var(--void-soft); color: var(--void); font-size: .9rem; font-weight: 600; }

.empty-state { text-align: center; padding: 48px 24px; display: grid; justify-items: center; gap: 10px; }
.empty-state h2 { font-size: 1.4rem; }
.empty-state p { color: var(--muted); max-width: 46ch; }
.empty-state .glyph { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--sand); border: 1px solid var(--line); }

.drop { border: 1.5px dashed var(--line-2); border-radius: 14px; padding: 24px; text-align: center; display: grid; gap: 6px; justify-items: center; cursor: pointer; background: var(--surface-2); }
.drop:hover, .drop.over { border-color: var(--tile-3); }
.drop input { display: none; }

/* ── Auth screens ──────────────────────────────────────── */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); background: var(--tile);
}
.auth-art { position: relative; background: #0f2a26 url('mosque-hero.jpg') center 30% / cover no-repeat; min-height: 100%; }
.auth-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(12,40,35,0) 40%, rgba(12,40,35,.85)); }
.auth-art .cap { position: absolute; z-index: 1; left: 36px; right: 36px; bottom: 34px; color: #fff; }
.auth-art .cap .ar { font-size: 1.5rem; color: var(--sand-2); display: block; text-align: left; }
.auth-art .cap p { color: #d3e1db; font-size: .95rem; margin-top: 4px; }
.auth-panel {
  display: grid; place-items: center; padding: 40px 28px; background: var(--bg);
  background-image: var(--jaali); background-size: 64px 64px; position: relative;
}
.auth-panel::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, var(--bg) 35%, color-mix(in srgb, var(--bg) 82%, transparent)); }
.auth-card { position: relative; width: min(380px, 100%); display: grid; gap: 18px; }
.auth-card .crest { display: flex; align-items: center; gap: 12px; }
.auth-card .crest img { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--sand-2); object-fit: cover; }
.auth-card .crest b { font-family: var(--f-display); font-weight: 400; font-size: 1.25rem; line-height: 1.15; display: block; }
.auth-card .crest small { display: block; font-size: .78rem; }
.auth-card h1 { font-size: 2.2rem; line-height: 1.05; }
.auth-card form { display: grid; gap: 14px; background: var(--surface); padding: 24px; border-radius: 20px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.pw { position: relative; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font: 600 .8rem var(--f-ui); padding: 8px; cursor: pointer; }

.install { max-width: 760px; margin: 0 auto; padding: 40px 18px 80px; display: grid; gap: 20px; }
.install h1 { font-size: 2.2rem; }
.install .log { font: 500 .88rem/1.6 var(--f-ui); display: grid; gap: 6px; padding: 18px 22px; }
.install .log div { display: flex; gap: 10px; }
.install .log svg { color: var(--dome); flex: none; margin-top: 3px; }
.find { display: grid; gap: 0; }
.find > div { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line); align-items: start; }
.find > div:last-child { border-bottom: 0; }
.find .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dome); margin-top: 7px; }
.find .dot.off { background: var(--line-2); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1100px) {
  .composer { grid-template-columns: minmax(0, 1fr); }
  .composer .preview-col { position: static; }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger > div:nth-child(2) { border-right: 0; }
  .ledger > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .receipt-page { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40;
    padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
    background: var(--tile); color: #fff; background-image: var(--jaali); background-size: 64px 64px;
  }
  .topbar .brand { padding: 0; }
  .topbar .brand-name { font-size: 1.05rem; }
  .topbar .brand img { border-width: 1.5px; }
  .main { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  }
  .tab { display: grid; justify-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font: 600 .7rem var(--f-ui); background: none; border: 0; cursor: pointer; }
  .tab:hover { text-decoration: none; color: var(--ink); }
  .tab-new svg { width: 46px; height: 46px; padding: 11px; margin-top: -22px; border-radius: 50%; background: var(--sand-2); color: #1a1408; box-shadow: 0 8px 18px -6px rgba(185,138,62,.7); border: 3px solid var(--surface); }
  .tab-new { color: var(--ink); }
  .page-head .actions { margin-left: 0; width: 100%; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 24px 20px 20px; }
  .bars { gap: 4px; padding: 6px 12px 0; height: 160px; }
  .bar span { font-size: .66rem; }
  .profile-head { grid-template-columns: auto minmax(0, 1fr); }
  .profile-head .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .toast-wrap { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  .filters-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filters-row .search { grid-column: 1 / -1; }
  .auth { grid-template-columns: minmax(0, 1fr); grid-template-rows: 38vh auto; }
  .auth-art .cap { left: 20px; right: 20px; bottom: 18px; }
  .auth-panel { padding: 0 18px 40px; place-items: start center; }
  .auth-card { margin-top: -54px; }
  .auth-card .crest { display: none; }
  .auth-card h1 { color: #fff; position: relative; top: -12px; font-size: 1.9rem; text-shadow: 0 2px 12px rgba(0,0,0,.35); }
  .auth-panel::before { display: none; }
  .auth-panel { background: var(--bg); }

  /* tables become stacked rows */
  .tbl.stack-sm thead { display: none; }
  .tbl.stack-sm, .tbl.stack-sm tbody, .tbl.stack-sm tr, .tbl.stack-sm td { display: block; width: 100%; }
  .tbl.stack-sm tr { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .tbl.stack-sm td { border: 0; padding: 0; }
  .tbl.stack-sm td.hide-sm { display: none; }
  .tbl.stack-sm td.amt, .tbl.stack-sm td.r { text-align: right; }
  .tbl.stack-sm td.full { grid-column: 1 / -1; }
  .tbl.stack-sm td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: .78rem; }
  .ledger .v { font-size: 1.35rem; }
  .ledger > div { padding: 14px 16px; }
  .months { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .mstrip-lg { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .panel-head, .step, .panel-pad { padding-left: 16px; padding-right: 16px; }
  .list li { padding: 12px 16px; }
  .save-bar { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 20; border-radius: 0; box-shadow: 0 -10px 24px -16px rgba(0,0,0,.3); padding: 12px 16px; }
  .save-bar .kbd { display: none; }
  .save-bar .btn.lg { flex: 1; }
}
@media (max-width: 420px) {

}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Print ─────────────────────────────────────────────── */
@media print {
  @page { size: A5 landscape; margin: 5mm; }
  body { background: #fff; }
  .side, .topbar, .tabbar, .no-print, .flash, .toast-wrap, .page-head .actions, .receipt-actions { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .receipt-page { display: block; }
  .paper-fit { height: auto !important; }
  .paper-fit > .paper { position: relative; }
  .paper { box-shadow: none; border-radius: 0; transform: none !important; margin: 0 auto; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .panel { box-shadow: none; break-inside: avoid; }
  .print-report .panel { border-color: #ccc; }
  body.report-print { font-size: 12px; }
}

.show-sm { display: none; }
@media (max-width: 860px) { .show-sm { display: inline; } }
@media print {
  .print-report { page: report; }
  @page report { size: A4 portrait; margin: 12mm; }
  .print-report .ledger { grid-template-columns: repeat(4, 1fr); }
}

/* phone refinements */
.more-filters-btn { display: none; }
@media (max-width: 860px) {
  .auth-art .cap { display: none; }
  .step-title { flex-wrap: wrap; }
  .step-title .aside { margin-left: 0; width: 100%; }
  .step-title .aside label { flex: 1; }
  .step-title .aside span { justify-content: center; }
  .seg { display: flex; }
  .picked { grid-template-columns: minmax(0, 1fr) auto; }
  .picked .avatar { display: none; }
  .more-filters-btn { display: inline-flex; }
  .filters.collapsible:not(.show-all) .filters-row > .field:not(.search) { display: none; }
  .filters-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .summary-line .actions { margin-left: 0; }
  .page-head .actions .btn { flex: 1; }
}
@media (max-width: 860px) {
  .filters-row[style] { grid-template-columns: minmax(0, 1fr) !important; }
  .filters-row .fy-switch { justify-content: space-between; }
  .filters-row .fy-switch input { flex: 1; }
}

/* settings: signature cards */
.sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 0 22px 18px; }
.sig-card { display: grid; justify-items: center; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); text-align: center; }
.sig-preview { height: 80px; width: 100%; display: grid; place-items: center; background: #fffdf8; border-radius: 10px; border: 1px solid var(--line); }
.sig-preview img { max-height: 66px; max-width: 90%; }

/* grid children may shrink below their content (wide tables scroll inside .tbl-wrap instead of widening the page) */
.stack > *, .grid-2 > *, .grid-main > *, .composer > * { min-width: 0; }
.panel-head { flex-wrap: wrap; }
