/* ============================================================
   American System — Group Expense Manager
   Design system per DESIGN.md §6 + screenshot analysis
   RTL-safe: uses CSS logical properties throughout
   Developed By: Muhammad Ali Ansari
   ============================================================ */

/* ---------------- Tokens: light (default) ----------------
   Surface ramp rule: --surface-0 is the MOST elevated (modals, sheets,
   drawer, rail, inputs, card-plain) and --surface-1 is the page. In light
   mode elevation gets lighter; the dark palette below keeps the SAME
   relationship so nothing looks inverted when the theme flips. */
:root{
  color-scheme:light;

  --brand-400:#FFDC5C;
  --brand-500:#FFD028;   /* primary action yellow */
  --brand-600:#F0C43C;   /* golden */
  --brand-700:#E7B51D;

  --surface-0:#FFFDF5;   /* elevated: modals / sheets / drawer / inputs */
  --surface-1:#FBF3D9;   /* page background */
  --surface-2:#FAF0CE;   /* cards */
  --surface-3:#F5E7BC;   /* pressed / active chip */

  --inverse-bg:#111111;  /* inverted blocks: table head, credit, auth pill */
  --inverse-fg:#FFFDF5;

  --ink-900:#111111;
  --ink-700:#454545;
  --ink-500:#77736A;

  /* darkened from #218A55 / #D93A3A: on the cream cards those only reached
     3.8:1 and 4.0:1, under the 4.5:1 needed for 16px bold amounts */
  --success:#146C43;
  --success-soft:#E7F5EC;
  --danger:#B3261E;
  --danger-soft:#FDECEC;
  --warning:#8A5800;
  --pdf:#B3261E;
  --xls:#146C43;

  --amount:#111111;      /* neutral amount colour */
  --border:#111111;
  --border-soft:#C9BC8E;
  --bw:1.5px;            /* standard border */
  --bw-strong:2.5px;     /* modal / primary border */

  --radius-xs:8px;
  --radius-sm:10px;
  --radius-md:14px;
  --radius-lg:20px;
  --radius-pill:999px;

  --shadow-card:0 2px 0 rgba(0,0,0,.12);
  --shadow-raised:0 3px 0 rgba(0,0,0,.18);
  --shadow-modal:0 8px 28px rgba(0,0,0,.28);

  --tap:44px;
  --bar-h:76px;
  --appbar-h:64px;

  /* Montserrat carries body copy, Poppins carries headings and figures.
     Both fall back to the system stack, and to the Noto faces for Urdu and
     Arabic, which Poppins/Montserrat do not cover. */
  --font:"Montserrat","Segoe UI Variable","Segoe UI",system-ui,-apple-system,
         "Noto Sans Arabic","Noto Nastaliq Urdu",sans-serif;
  --font-head:"Poppins","Segoe UI Variable","Segoe UI",system-ui,-apple-system,
         "Noto Sans Arabic","Noto Nastaliq Urdu",sans-serif;
}

/* Self-hosted faces take priority when present. Drop the .woff2 files into
   assets/fonts/ (see assets/fonts/README.txt) and the app stops depending on
   the Google Fonts CDN entirely, including offline. */
@font-face{font-family:"Montserrat";font-style:normal;font-weight:400 800;font-display:swap;
  src:url("../fonts/montserrat.woff2") format("woff2-variations"),
      url("../fonts/montserrat.woff2") format("woff2")}
@font-face{font-family:"Poppins";font-style:normal;font-weight:600;font-display:swap;
  src:url("../fonts/poppins-600.woff2") format("woff2")}
@font-face{font-family:"Poppins";font-style:normal;font-weight:700;font-display:swap;
  src:url("../fonts/poppins-700.woff2") format("woff2")}
@font-face{font-family:"Poppins";font-style:normal;font-weight:800;font-display:swap;
  src:url("../fonts/poppins-800.woff2") format("woff2")}

/* ---------------- Tokens: dark ---------------- */
html[data-theme="dark"]{
  /* tells the browser to paint native controls dark: date pickers, select
     dropdowns, scrollbars, spinners and form autofill */
  color-scheme:dark;

  /* elevation gets LIGHTER, same as the light palette */
  --surface-1:#161616;   /* page background (darkest) */
  --surface-2:#232323;   /* cards */
  --surface-0:#2E2E2E;   /* elevated: modals / sheets / drawer / rail / inputs */
  --surface-3:#3C3C3C;   /* pressed / active chip (lightest) */

  --inverse-bg:#0E0E0E;
  --inverse-fg:#FFD028;

  --ink-900:#F2F2F2;
  --ink-700:#C7C7C7;
  --ink-500:#9E9E9E;

  --success:#4ADE80;
  --success-soft:#1B3325;
  --danger:#FF7A7A;
  --danger-soft:#3A2020;
  --warning:#E9B84A;
  --pdf:#FF7A7A;
  --xls:#4ADE80;

  --amount:#E8C33D;      /* yellow amounts in dark mode */
  /* both were #3A3A3A, which vanished against the cards. Keep the strong
     border clearly visible and the soft one a quiet hairline. */
  --border:#4E4E4E;
  --border-soft:#383838;
  --bw:1px;
  --bw-strong:1.5px;

  --shadow-card:none;
  --shadow-raised:none;
  --shadow-modal:0 10px 34px rgba(0,0,0,.66);
}

/* ============================================================
   Base
   ============================================================ */
*,*::before,*::after{box-sizing:border-box}
html,body{margin:0;padding:0}
html{-webkit-text-size-adjust:100%;background:var(--surface-1)}
body{
  font-family:var(--font);
  background:var(--surface-1);
  color:var(--ink-900);
  font-size:15px;
  line-height:1.45;
  min-height:100vh;
  min-height:100dvh;
  -webkit-font-smoothing:antialiased;
  overflow-wrap:break-word;
}
h1,h2,h3,h4{margin:0;font-family:var(--font-head);font-weight:700;letter-spacing:-.3px;line-height:1.2}
h1{font-size:26px}
h2{font-size:19px}
h3{font-size:17px}
p{margin:0 0 10px}
a{color:inherit;text-decoration:none}
ul,ol{margin:0;padding-inline-start:18px}
img,svg{max-width:100%}
[hidden]{display:none !important}

/* Screen-reader only */
.sr-only{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;
}
.skip-link{
  position:absolute;inset-inline-start:-9999px;top:0;z-index:999;
  background:var(--brand-500);color:#111;font-weight:800;
  padding:10px 16px;border:var(--bw-strong) solid var(--border);
}
.skip-link:focus{inset-inline-start:8px;top:8px}

:focus-visible{outline:3px solid var(--brand-700);outline-offset:2px;border-radius:4px}

.muted{color:var(--ink-500)}
.t-center{text-align:center}
.t-end{text-align:end}
.nowrap{white-space:nowrap}
.pos{color:var(--success)}
.neg{color:var(--danger)}
.stack-8>*+*{margin-block-start:8px}
.stack-12>*+*{margin-block-start:12px}
.stack-16>*+*{margin-block-start:16px}
.row{display:flex;align-items:center;gap:10px}
.row-between{display:flex;align-items:center;justify-content:space-between;gap:10px}
.wrap{flex-wrap:wrap}
.grow{flex:1;min-width:0}

/* ============================================================
   Icons (SVG sprite, no emoji anywhere)
   ============================================================ */
.ic{
  width:1.15em;height:1.15em;flex:0 0 auto;
  fill:none;stroke:currentColor;stroke-width:1.9;
  stroke-linecap:round;stroke-linejoin:round;
  vertical-align:-.16em;pointer-events:none;
}
.ic-sm{width:16px;height:16px}
.ic-md{width:20px;height:20px}
.ic-lg{width:24px;height:24px}
.ic-xl{width:32px;height:32px}
/* mirror directional icons in RTL */
[dir="rtl"] .ic-flip{transform:scaleX(-1)}

/* ============================================================
   Buttons
   ============================================================ */
.btn{
  --btn-bg:var(--surface-2);
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  font-family:var(--font);font-size:14px;font-weight:800;line-height:1;
  min-height:var(--tap);padding:12px 18px;
  background:var(--btn-bg);color:var(--ink-900);
  border:var(--bw) solid var(--border);border-radius:var(--radius-sm);
  box-shadow:var(--shadow-card);
  cursor:pointer;text-align:center;
  transition:transform .1s ease,box-shadow .1s ease,filter .1s ease;
  -webkit-tap-highlight-color:transparent;
}
.btn:hover{filter:brightness(.98)}
.btn:active{transform:translateY(2px);box-shadow:none}
.btn:disabled,.btn[aria-disabled="true"]{opacity:.5;cursor:not-allowed;transform:none;box-shadow:none}

.btn-primary{--btn-bg:var(--brand-500);color:#111;border-width:var(--bw-strong);font-weight:800}
.btn-ghost{--btn-bg:transparent;box-shadow:none}
.btn-plain{--btn-bg:var(--surface-0)}
.btn-danger{--btn-bg:var(--danger);color:#fff}
html[data-theme="dark"] .btn-danger{color:#111}
.btn-sm{min-height:34px;padding:8px 14px;font-size:13px;border-radius:var(--radius-xs)}
.btn-lg{min-height:52px;padding:15px 22px;font-size:16px;border-radius:var(--radius-md)}
.btn-block{width:100%}
.btn-icon{padding:0;width:var(--tap);height:var(--tap);min-height:var(--tap)}
.btn-round{border-radius:var(--radius-pill)}

/* circular header buttons (screenshots: profile L, export R) */
.icon-circle{
  width:var(--tap);height:var(--tap);flex:0 0 var(--tap);
  display:inline-flex;align-items:center;justify-content:center;
  background:var(--brand-500);color:#111;
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-pill);
  box-shadow:var(--shadow-card);cursor:pointer;
  transition:transform .1s ease;
}
html[data-theme="dark"] .icon-circle:not(.icon-circle-plain){border-color:var(--brand-700)}
.icon-circle:active{transform:translateY(2px)}
/* neutral variant must stay neutral in both themes. --surface-0 is the elevated
   surface in BOTH palettes, so it reads as a raised control on the appbar
   without needing a dark-mode special case. */
.icon-circle-plain{background:var(--surface-0);color:var(--ink-900);border-color:var(--border)}

.actions{display:flex;flex-wrap:wrap;gap:10px}
.actions-end{justify-content:flex-end}

/* ============================================================
   Cards / surfaces
   ============================================================ */
.card{
  background:var(--surface-2);
  border:var(--bw) solid var(--border-soft);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);
  padding:14px;
}
.card-plain{background:var(--surface-0)}
.card-tight{padding:12px}
.card-flat{box-shadow:none}
.card-outline{background:transparent}
.section-title{
  font-size:13px;font-weight:800;color:var(--ink-700);
  margin-block:18px 8px;letter-spacing:.2px;
}
.divider{border:0;border-top:var(--bw) solid var(--border-soft);margin-block:14px}

.empty{
  padding:34px 16px;text-align:center;color:var(--ink-500);
  font-weight:600;font-size:14px;
}
.empty .ic{display:block;margin:0 auto 10px;width:34px;height:34px;opacity:.5}

/* ============================================================
   App shell
   ============================================================ */
.shell{
  display:flex;flex-direction:column;
  min-height:100vh;min-height:100dvh;
}
.appbar{
  position:sticky;top:0;z-index:40;
  display:flex;align-items:center;gap:12px;
  padding:10px 14px;
  padding-top:calc(10px + env(safe-area-inset-top));
  background:var(--surface-1);
}
.appbar-title{flex:1;min-width:0;text-align:center}
.appbar-title .t{
  font-size:16px;font-weight:800;line-height:1.15;
  display:inline-flex;align-items:center;gap:6px;justify-content:center;
  max-width:100%;
}
.appbar-title .t span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.appbar-title .s{font-size:12px;color:var(--ink-500);font-weight:600;margin-top:1px}
.appbar-title button.t{background:none;border:0;padding:0;color:inherit;cursor:pointer;font-family:inherit}

.main{
  flex:1;min-width:0;
  padding:4px 14px calc(var(--bar-h) + 26px);
  max-width:760px;width:100%;margin-inline:auto;
}
.page-head{margin-block:6px 14px}
.page-head h1{font-size:24px}
.page-head .s{font-size:13px;color:var(--ink-500);font-weight:600;margin-top:3px}

/* bottom action bar (screenshots: group pill + "+ Add") */
.bottombar{
  position:fixed;inset-inline:0;bottom:0;z-index:45;
  display:flex;align-items:center;justify-content:space-between;
  gap:14px;
  padding:14px 16px;
  padding-bottom:calc(14px + env(safe-area-inset-bottom));
  background:linear-gradient(to top,var(--surface-1) 55%,rgba(0,0,0,0));
  pointer-events:none;
}
.bottombar>*{pointer-events:auto}
.group-pill{
  display:inline-flex;align-items:center;gap:8px;
  flex:0 1 auto;min-width:0;max-width:calc(100% - 150px);
  font-size:13px;font-weight:800;
  padding:11px 14px;min-height:42px;
  background:var(--surface-2);color:var(--ink-900);
  border:var(--bw) solid var(--border);border-radius:var(--radius-sm);
  box-shadow:var(--shadow-card);cursor:pointer;
}
.group-pill span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.group-pill:active{transform:translateY(2px);box-shadow:none}
.add-btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  flex:0 0 auto;
  font-size:15px;font-weight:800;line-height:1;
  padding:14px 26px;min-height:50px;
  background:var(--brand-500);color:#111;
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  box-shadow:var(--shadow-raised);cursor:pointer;white-space:nowrap;
}
html[data-theme="dark"] .add-btn{border-color:var(--brand-700)}
.add-btn:active{transform:translateY(2px);box-shadow:none}
@media (max-width:359px){
  .add-btn{padding:14px 18px}
  .group-pill{max-width:calc(100% - 128px)}
}

/* ============================================================
   Mobile off-canvas drawer (side menu)
   ============================================================ */
.drawer-scrim{
  position:fixed;inset:0;z-index:90;background:rgba(0,0,0,.5);
  opacity:0;pointer-events:none;transition:opacity .18s ease;
}
/* the markup ships with [hidden]; JS reveals it. Belt and braces so a
   stale/missing stylesheet can never dump the menu into the page flow. */
.drawer[hidden],.drawer-scrim[hidden]{display:none !important}
.drawer{
  position:fixed;inset-block:0;inset-inline-start:0;z-index:91;
  width:284px;max-width:86vw;
  display:flex;flex-direction:column;gap:2px;
  background:var(--surface-0);
  border-inline-end:var(--bw-strong) solid var(--border);
  box-shadow:var(--shadow-modal);
  padding:14px 12px calc(20px + env(safe-area-inset-bottom));
  padding-top:calc(14px + env(safe-area-inset-top));
  overflow-y:auto;overscroll-behavior:contain;
  transform:translateX(-104%);
  transition:transform .22s cubic-bezier(.2,.8,.2,1);
}
[dir="rtl"] .drawer{transform:translateX(104%)}
body.drawer-open{overflow:hidden}
body.drawer-open .drawer{transform:none}
body.drawer-open .drawer-scrim{opacity:1;pointer-events:auto}
.drawer-head{
  display:flex;align-items:center;gap:11px;
  padding:6px 8px 12px;margin-bottom:6px;
  border-bottom:var(--bw) solid var(--border-soft);
}
.drawer-head .grow{min-width:0}
.drawer-head .n{font-weight:800;font-size:15px;line-height:1.2;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.drawer-head .m{font-size:12px;color:var(--ink-500);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.drawer-close{
  width:38px;height:38px;flex:0 0 38px;margin-inline-start:auto;
  display:flex;align-items:center;justify-content:center;
  background:transparent;color:var(--ink-900);
  border:var(--bw) solid var(--border);border-radius:var(--radius-pill);cursor:pointer;
}
.rail-only{display:none}
@media (min-width:1080px){
  .drawer,.drawer-scrim,.nav-toggle{display:none !important}
  .rail-only{display:inline-flex}
}

/* ============================================================
   Member chips (screenshots: Ali / Hitesh / Max)
   ============================================================ */
.chips{
  display:flex;gap:8px;overflow-x:auto;padding-block:2px 4px;
  scrollbar-width:none;-ms-overflow-style:none;
}
.chips::-webkit-scrollbar{display:none}
.chip{
  display:inline-flex;align-items:center;gap:6px;flex:0 0 auto;
  font-size:13px;font-weight:800;
  padding:8px 14px;min-height:36px;
  background:var(--surface-2);color:var(--ink-900);
  border:var(--bw) solid var(--border);border-radius:var(--radius-sm);
  box-shadow:var(--shadow-card);cursor:pointer;white-space:nowrap;
}
.chip[aria-pressed="true"],.chip.is-active{
  background:var(--brand-500);color:#111;border-color:var(--border);
}
html[data-theme="dark"] .chip[aria-pressed="true"],
html[data-theme="dark"] .chip.is-active{background:var(--brand-500);border-color:var(--brand-700)}
.chip .ic{width:14px;height:14px}

/* filter chips (Transactions: All / Expense / Payment / Paid by) */
.filterbar{display:flex;gap:8px;overflow-x:auto;padding-block:4px 10px;scrollbar-width:none}
.filterbar::-webkit-scrollbar{display:none}
.filter-chip{
  display:inline-flex;align-items:center;gap:6px;flex:0 0 auto;
  font-size:13px;font-weight:700;
  padding:8px 14px;min-height:36px;
  background:transparent;color:var(--ink-900);
  border:var(--bw) solid var(--border-soft);border-radius:var(--radius-pill);
  cursor:pointer;white-space:nowrap;
}
.filter-chip.is-active{
  background:var(--surface-3);border-color:var(--border);font-weight:800;
}
.filter-chip .ic{width:14px;height:14px;color:var(--warning)}
html[data-theme="dark"] .filter-chip .ic{color:var(--brand-500)}

/* ============================================================
   Summary cards (Total Expense / Your share / You paid / You get)
   ============================================================ */
.summary-grid{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;
  margin-block:12px 4px;
}
.stat{
  position:relative;overflow:hidden;
  background:var(--surface-2);
  border:var(--bw) solid var(--border-soft);
  border-radius:var(--radius-md);
  padding:14px 14px 13px;
  min-height:88px;
}
.stat .v{font-size:26px;font-weight:800;letter-spacing:-.6px;line-height:1.1;position:relative;z-index:1}
.stat .v .cur{font-size:15px;font-weight:700;margin-inline-end:3px;opacity:.85}
.stat .k{font-size:13px;font-weight:600;color:var(--ink-500);margin-top:5px;position:relative;z-index:1}
.stat .wm{
  position:absolute;top:-6px;inset-inline-end:-6px;
  width:64px;height:64px;opacity:.09;
  color:var(--ink-900);stroke-width:1.4;pointer-events:none;
}
html[data-theme="dark"] .stat .wm{opacity:.11}
/* screenshots keep every card cream — only the value colour changes */
.stat.is-paid .v{color:var(--danger)}
.stat.is-get .v{color:var(--success)}
@media (max-width:340px){
  .summary-grid{grid-template-columns:1fr}
  .stat .v{font-size:23px}
}

/* ============================================================
   Transaction rows
   ============================================================ */
.date-head{
  font-size:12px;font-weight:700;color:var(--ink-500);
  margin-block:16px 8px;
}
.txn{
  display:flex;align-items:flex-start;gap:11px;
  background:var(--surface-2);
  border:var(--bw) solid var(--border-soft);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);
  padding:12px;margin-bottom:9px;
  width:100%;text-align:start;cursor:pointer;
  font-family:var(--font);color:inherit;
}
.txn:active{transform:translateY(1px)}
.txn-badge{
  width:30px;height:30px;flex:0 0 30px;
  display:flex;align-items:center;justify-content:center;
  background:var(--brand-500);color:#111;
  border-radius:var(--radius-xs);
}
.txn-badge.is-payment{background:var(--success);color:#fff}
/* keep the tile in dark mode, just tinted, so rows do not read as flat text */
html[data-theme="dark"] .txn-badge{background:rgba(255,208,40,.16);color:var(--brand-500)}
html[data-theme="dark"] .txn-badge.is-payment{background:rgba(74,222,128,.16);color:var(--success)}
.txn-badge .ic{width:19px;height:19px}
.txn-body{flex:1;min-width:0}
.txn-title{font-size:15px;font-weight:800;line-height:1.25}
.txn-sub{font-size:13px;color:var(--ink-500);font-weight:600;margin-top:2px}
.txn-sub b{color:var(--ink-900);font-weight:800}
.txn-right{text-align:end;flex:0 0 auto;padding-inline-start:6px}
.txn-amt{font-size:17px;font-weight:800;color:var(--amount);white-space:nowrap;letter-spacing:-.3px}
.txn-amt .cur{font-size:12px;font-weight:700;opacity:.8;margin-inline-end:2px}
.txn-amt.is-payment{color:var(--success)}
.txn-meta{font-size:11px;color:var(--ink-500);font-weight:600;margin-top:4px;white-space:nowrap}

/* ============================================================
   Settlement cards ("Hitesh Should pay Ali")
   ============================================================ */
.settle-card{
  background:var(--surface-2);
  border:var(--bw) solid var(--border-soft);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);
  padding:12px;margin-bottom:10px;
}
.settle-top{display:flex;align-items:center;gap:10px}
.settle-ic{
  width:26px;height:26px;flex:0 0 26px;
  display:flex;align-items:center;justify-content:center;
  color:var(--brand-700);
}
html[data-theme="dark"] .settle-ic{color:var(--brand-500)}
.settle-ic .ic{width:22px;height:22px}
.settle-text{flex:1;min-width:0;font-size:14.5px;font-weight:600;color:var(--ink-500)}
.settle-text b{color:var(--ink-900);font-weight:800}
.settle-amt{
  font-size:16px;font-weight:800;color:var(--danger);white-space:nowrap;letter-spacing:-.3px;
}
.settle-amt .cur{font-size:12px;font-weight:700;opacity:.85;margin-inline-end:2px}
.settle-actions{display:flex;gap:9px;margin-top:10px}
.settle-actions .btn{min-height:36px;padding:9px 20px;font-size:13px}

.settled-banner{
  display:flex;align-items:center;gap:12px;
  background:var(--success-soft);
  border:var(--bw-strong) solid var(--success);
  border-radius:var(--radius-md);padding:16px;
}
.settled-banner .ic{width:28px;height:28px;color:var(--success)}
.settled-banner b{display:block;font-size:16px;font-weight:800}

/* ============================================================
   Avatars
   ============================================================ */
.avatar{
  width:38px;height:38px;flex:0 0 38px;
  display:flex;align-items:center;justify-content:center;
  font-size:13px;font-weight:800;
  background:var(--brand-500);color:#111;
  border:var(--bw) solid var(--border);border-radius:var(--radius-pill);
  overflow:hidden;
}
.avatar-lg{width:64px;height:64px;flex-basis:64px;font-size:22px}
.avatar-sm{width:30px;height:30px;flex-basis:30px;font-size:11px}
.avatar img{width:100%;height:100%;object-fit:cover}

.person{display:flex;align-items:center;gap:10px;min-width:0}
.person .n{font-weight:800;font-size:15px;line-height:1.2}
.person .m{font-size:12.5px;color:var(--ink-500);font-weight:600}

/* ============================================================
   Forms
   ============================================================ */
.field{display:block;margin-bottom:14px}
.field>.lbl{
  display:block;font-size:13px;font-weight:800;margin-bottom:6px;color:var(--ink-900);
}
.field .hint{display:block;font-size:12px;color:var(--ink-500);font-weight:600;margin-top:5px}
.field .err{display:block;font-size:12.5px;color:var(--danger);font-weight:700;margin-top:5px}

input[type=text],input[type=email],input[type=password],input[type=number],
input[type=date],input[type=search],input[type=tel],input[type=url],
select,textarea{
  width:100%;font-family:var(--font);font-size:15px;font-weight:600;
  min-height:var(--tap);padding:12px 13px;
  background:var(--surface-0);color:var(--ink-900);
  border:var(--bw) solid var(--border);border-radius:var(--radius-sm);
  appearance:none;
}
input::placeholder,textarea::placeholder{color:var(--ink-500);font-weight:500}
textarea{min-height:104px;resize:vertical;line-height:1.5}

/* Chrome paints autofilled fields pale yellow/blue and ignores background,
   which looked broken on dark. Repaint via an inset shadow (the only property
   the autofill style does not override) and force the text colour. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill{
  -webkit-text-fill-color:var(--ink-900);
  -webkit-box-shadow:0 0 0 1000px var(--surface-0) inset;
  box-shadow:0 0 0 1000px var(--surface-0) inset;
  caret-color:var(--ink-900);
  transition:background-color 9999s ease-out 0s;
}
/* native date / time pickers ship a black glyph; invert it on dark */
html[data-theme="dark"] input[type=date]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type=time]::-webkit-calendar-picker-indicator{
  filter:invert(1) opacity(.75);cursor:pointer;
}
html[data-theme="dark"] input[type=search]::-webkit-search-cancel-button{filter:invert(1) opacity(.7)}
select{
  padding-inline-end:34px;
  background-image:
    linear-gradient(45deg,transparent 50%,currentColor 50%),
    linear-gradient(135deg,currentColor 50%,transparent 50%);
  background-position:right 17px center,right 11px center;
  background-size:6px 6px,6px 6px;background-repeat:no-repeat;
}
[dir="rtl"] select{background-position:left 11px center,left 17px center}
input:focus,select:focus,textarea:focus{outline:3px solid var(--brand-700);outline-offset:1px}
input[type=checkbox],input[type=radio]{
  width:22px;height:22px;min-height:0;accent-color:var(--brand-700);
  margin:0;cursor:pointer;flex:0 0 auto;
}
.check{display:flex;align-items:flex-start;gap:10px;font-size:14px;font-weight:700;cursor:pointer;min-height:var(--tap)}
.check span{padding-top:1px}

/* amount input with currency prefix */
.amount-input{position:relative;display:flex;align-items:center}
.amount-input .cur{
  position:absolute;inset-inline-start:13px;font-size:15px;font-weight:800;
  color:var(--ink-500);pointer-events:none;
}
.amount-input input{padding-inline-start:44px;font-size:20px;font-weight:800}

.grid-2{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}
.grid-3{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:12px}
.span-2{grid-column:1 / -1}

/* segmented control (split methods, reminder tones) */
.segmented{
  display:flex;gap:4px;padding:4px;
  background:var(--surface-2);
  border:var(--bw) solid var(--border-soft);
  border-radius:var(--radius-pill);
}
.segmented input{position:absolute;opacity:0;width:0;height:0}
.segmented label{
  flex:1;display:flex;align-items:center;justify-content:center;gap:6px;
  font-size:13px;font-weight:800;text-align:center;
  padding:10px 8px;min-height:40px;border-radius:var(--radius-pill);
  cursor:pointer;color:var(--ink-500);
  transition:background .12s ease,color .12s ease;
}
.segmented input:checked+label{background:var(--surface-0);color:var(--ink-900);box-shadow:var(--shadow-card)}
/* dark mode has no drop shadow to signal "raised", so the selected pill takes
   the lightest surface plus a brand hairline instead */
html[data-theme="dark"] .segmented input:checked+label{
  background:var(--surface-3);box-shadow:inset 0 0 0 1px var(--brand-700);
}
.segmented input:focus-visible+label{outline:3px solid var(--brand-700);outline-offset:1px}
.segmented .ic{width:20px;height:20px}
.segmented-4 label{flex-direction:column;gap:2px;font-size:11px}

/* split rows (member + amount/percent/shares) */
.split-row{
  display:flex;align-items:center;gap:10px;flex-wrap:wrap;
  padding:10px 0;border-bottom:var(--bw) solid var(--border-soft);
}
.split-row:last-child{border-bottom:0}
.split-row .who{flex:1 1 150px;min-width:0;display:flex;align-items:center;gap:9px}
.split-row .who .n{font-size:14.5px;font-weight:700;min-width:0;overflow-wrap:anywhere}
.split-row .val{flex:0 0 108px}
.split-row .val input{min-height:38px;padding:8px 10px;font-size:14px;text-align:end}
.split-row .out{
  flex:0 0 auto;font-size:14px;font-weight:800;min-width:84px;text-align:end;color:var(--ink-900);
  font-variant-numeric:tabular-nums;
}
.split-row.is-off{opacity:.45}
@media (max-width:400px){
  .split-row .who{flex:1 1 100%}
  .split-row .val{flex:1 1 auto}
}

.total-bar{
  position:sticky;bottom:calc(var(--bar-h) + 4px);z-index:30;
  display:flex;flex-wrap:wrap;gap:6px 18px;align-items:center;
  background:var(--brand-500);color:#111;
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  box-shadow:var(--shadow-raised);padding:11px 14px;margin-top:14px;
}
html[data-theme="dark"] .total-bar{border-color:var(--brand-700)}
.total-bar .k{font-size:10.5px;font-weight:800;text-transform:uppercase;letter-spacing:.5px;opacity:.75}
.total-bar .v{font-size:15px;font-weight:800;display:block}
.total-bar .bad{color:#8E1A1A}
/* pages that hide the bottom bar (forms) need the bar to sit lower */
body.no-bottombar .total-bar{bottom:8px}
body.no-bottombar .main{padding-bottom:34px}
body.no-bottombar .toasts{bottom:16px}

/* ============================================================
   Modals / bottom sheets
   ============================================================ */
.overlay{
  position:fixed;inset:0;z-index:100;
  display:flex;align-items:flex-end;justify-content:center;
  background:rgba(0,0,0,.5);
  padding:0;
  animation:fade .16s ease;
}
@keyframes fade{from{opacity:0}to{opacity:1}}
.sheet{
  width:100%;max-width:560px;max-height:92dvh;overflow-y:auto;
  background:var(--surface-0);
  border:var(--bw-strong) solid var(--border);
  border-radius:var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow:var(--shadow-modal);
  padding:16px 16px calc(20px + env(safe-area-inset-bottom));
  animation:up .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes up{from{transform:translateY(14px)}to{transform:none}}
.sheet-head{
  display:flex;align-items:center;gap:12px;margin-bottom:14px;
}
.sheet-head .close{
  width:40px;height:40px;flex:0 0 40px;
  display:flex;align-items:center;justify-content:center;
  background:transparent;color:var(--ink-900);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-pill);
  cursor:pointer;
}
.sheet-head .close .ic{width:19px;height:19px;stroke-width:2.4}
.sheet-title{flex:1;min-width:0;text-align:center;padding-inline-end:40px}
.sheet-title .t{font-size:17px;font-weight:800}
.sheet-title .s{font-size:12.5px;color:var(--ink-500);font-weight:600;margin-top:1px}
.sheet-body>p{font-size:14px;color:var(--ink-700);line-height:1.55}

/* popover menu (Groups menu: New/Join/Switch/Settings) */
.menu-list{list-style:none;margin:0;padding:0}
.menu-list li+li{margin-top:6px}
.menu-item{
  display:flex;align-items:center;gap:13px;width:100%;
  font-family:var(--font);font-size:16px;font-weight:800;text-align:start;
  padding:14px 12px;min-height:52px;
  background:transparent;color:var(--ink-900);
  border:0;border-radius:var(--radius-sm);cursor:pointer;
}
.menu-item:hover,.menu-item:focus-visible{background:var(--surface-2)}
.menu-item .ic{width:23px;height:23px;stroke-width:1.8}

/* selectable row (Select Group modal) */
.pick-row{
  display:flex;align-items:center;gap:12px;width:100%;
  font-family:var(--font);text-align:start;
  padding:14px;min-height:64px;
  background:var(--surface-2);color:var(--ink-900);
  border:var(--bw) solid var(--border);border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);cursor:pointer;
}
.pick-row+.pick-row{margin-top:10px}
.pick-row.is-active{background:var(--brand-400)}
html[data-theme="dark"] .pick-row.is-active{background:var(--surface-3)}
.pick-row .pi{
  width:26px;height:26px;flex:0 0 26px;display:flex;align-items:center;justify-content:center;
}
.pick-row .pi .ic{width:24px;height:24px}
.pick-row .pt{flex:1;min-width:0}
.pick-row .pt .n{font-size:18px;font-weight:800;line-height:1.2}
.pick-row .pt .m{font-size:13px;color:var(--ink-500);font-weight:600;margin-top:1px}
.pick-row .pc .ic{width:20px;height:20px;color:var(--ink-500)}

/* download buttons (PDF / Excel) */
.dl-btn{
  display:flex;align-items:center;justify-content:center;gap:10px;width:100%;
  font-family:var(--font);font-size:15px;font-weight:800;
  padding:16px;min-height:56px;
  background:var(--surface-2);color:var(--ink-900);
  border:var(--bw) solid var(--border);border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);cursor:pointer;
}
.dl-btn+.dl-btn{margin-top:12px}
.dl-btn .ic{width:24px;height:24px}
.dl-btn .ic-pdf{color:var(--pdf)}
.dl-btn .ic-xls{color:var(--xls)}

/* ============================================================
   Notifications
   ============================================================ */
.notif{
  display:flex;align-items:flex-start;gap:11px;
  background:var(--surface-2);
  border:var(--bw) solid var(--border-soft);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);
  padding:12px;margin-bottom:9px;
  width:100%;text-align:start;font-family:var(--font);color:inherit;cursor:pointer;
}
.notif.is-unread{background:var(--brand-400);border-color:var(--border)}
html[data-theme="dark"] .notif.is-unread{background:var(--surface-3);border-color:var(--brand-700)}
.notif-badge{
  width:34px;height:34px;flex:0 0 34px;
  display:flex;align-items:center;justify-content:center;
  background:var(--brand-500);color:#111;
  border:var(--bw) solid var(--border);border-radius:var(--radius-xs);
}
.notif-badge .ic{width:20px;height:20px}
.notif-body{flex:1;min-width:0}
.notif-title{font-size:14px;font-weight:800;line-height:1.3}
.notif-text{font-size:13px;color:var(--ink-700);font-weight:600;margin-top:2px;line-height:1.4}
.notif-time{font-size:11px;color:var(--ink-500);font-weight:700;flex:0 0 auto;white-space:nowrap}
.dot{
  display:inline-block;width:8px;height:8px;border-radius:50%;
  background:var(--danger);margin-inline-start:5px;vertical-align:middle;
}
.badge-count{
  position:absolute;top:-3px;inset-inline-end:-3px;
  min-width:19px;height:19px;padding:0 4px;
  display:flex;align-items:center;justify-content:center;
  font-size:10.5px;font-weight:800;
  background:var(--danger);color:#fff;
  border:1.5px solid var(--surface-1);border-radius:var(--radius-pill);
}
html[data-theme="dark"] .badge-count{color:#111}
.has-badge{position:relative}

/* ============================================================
   Reminder composer
   ============================================================ */
.tone-grid{display:flex;gap:6px;padding:5px;background:var(--surface-2);
  border:var(--bw) solid var(--border-soft);border-radius:var(--radius-pill);margin-bottom:14px}
.tone-grid input{position:absolute;opacity:0;width:0;height:0}
.tone-grid label{
  flex:1;display:flex;align-items:center;justify-content:center;
  min-height:44px;border-radius:var(--radius-pill);cursor:pointer;
  color:var(--ink-500);transition:background .12s ease,color .12s ease;
}
.tone-grid label .ic{width:24px;height:24px;stroke-width:1.8}
.tone-grid input:checked+label{background:var(--surface-0);color:var(--ink-900);box-shadow:var(--shadow-card)}
html[data-theme="dark"] .tone-grid input:checked+label{
  background:var(--surface-3);box-shadow:inset 0 0 0 1px var(--brand-700);
}
.tone-grid input:focus-visible+label{outline:3px solid var(--brand-700)}
.tone-friendly.is-on{color:var(--success)}
.tone-strong.is-on{color:var(--danger)}
.msg-wrap{position:relative}
.msg-wrap textarea{padding-bottom:50px}
.msg-tools{
  position:absolute;bottom:9px;inset-inline-end:9px;display:flex;gap:7px;
}
.msg-tools button{
  width:36px;height:36px;min-height:36px;padding:0;
  display:flex;align-items:center;justify-content:center;
  background:var(--surface-2);color:var(--ink-900);
  border:var(--bw) solid var(--border-soft);border-radius:var(--radius-xs);cursor:pointer;
}
.msg-tools .ic{width:18px;height:18px}

/* ============================================================
   Toasts / banners
   ============================================================ */
.toasts{
  position:fixed;inset-inline:14px;bottom:calc(var(--bar-h) + 14px);z-index:200;
  display:flex;flex-direction:column;gap:8px;align-items:center;pointer-events:none;
}
.toast{
  max-width:440px;width:fit-content;
  background:var(--ink-900);color:var(--surface-0);
  border-radius:var(--radius-sm);padding:11px 16px;
  font-size:13.5px;font-weight:700;box-shadow:var(--shadow-modal);
  animation:up .18s ease;
}
html[data-theme="dark"] .toast{background:var(--surface-3);color:var(--ink-900);border:1px solid var(--border)}
.toast.is-ok{background:var(--success);color:#fff}
.toast.is-err{background:var(--danger);color:#fff}
html[data-theme="dark"] .toast.is-ok,html[data-theme="dark"] .toast.is-err{color:#111}

.banner{
  display:flex;align-items:flex-start;gap:10px;
  border:var(--bw) solid var(--border);border-radius:var(--radius-md);
  padding:12px 13px;margin-bottom:14px;font-size:13.5px;font-weight:700;line-height:1.45;
}
.banner .ic{width:20px;height:20px;flex:0 0 20px;margin-top:1px}
.banner-info{background:var(--surface-2)}
.banner-ok{background:var(--success-soft);border-color:var(--success)}
.banner-err{background:var(--danger-soft);border-color:var(--danger)}
.banner-warn{background:var(--brand-400)}
html[data-theme="dark"] .banner-warn{background:var(--surface-3)}
.banner .close-x{
  margin-inline-start:auto;background:none;border:0;padding:2px;cursor:pointer;color:inherit;
}

.offline-bar{
  display:none;align-items:center;justify-content:center;gap:8px;
  background:var(--danger);color:#fff;font-size:12.5px;font-weight:800;
  padding:7px 12px;text-align:center;
}
html[data-theme="dark"] .offline-bar{color:#111}
body.is-offline .offline-bar{display:flex}

/* skeleton loader */
.skel{
  background:linear-gradient(90deg,var(--surface-2) 25%,var(--surface-3) 37%,var(--surface-2) 63%);
  background-size:400% 100%;animation:shim 1.3s ease infinite;
  border-radius:var(--radius-sm);height:14px;
}
@keyframes shim{0%{background-position:100% 0}100%{background-position:0 0}}

/* ============================================================
   Auth screens
   ============================================================ */
.auth{
  min-height:100dvh;display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  padding:22px 16px calc(22px + env(safe-area-inset-bottom));
}
.auth-box{width:100%;max-width:420px}
.auth-brand{text-align:center;margin-bottom:22px}

/* original brand illustration above the wordmark */
.auth-art{margin:0 auto 6px;max-width:288px}
.auth-art svg{display:block;width:100%;height:auto}
.auth-art + .auth-logo{width:56px;height:56px;margin-bottom:10px}
.auth-art + .auth-logo .ic{width:31px;height:31px}
@media (max-height:660px){.auth-art{display:none}}

/* brand mark = assets/icons/logo.svg. The artwork already carries its own
   rounded tile, so its container drops the tile styling to avoid doubling. */
.brand-mark{display:block;width:100%;height:100%;object-fit:contain}
.is-mark{background:none !important;border:0 !important;box-shadow:none !important;padding:0 !important}
.auth-logo.is-mark{border-radius:var(--radius-lg);overflow:hidden}

.auth-logo{
  width:76px;height:76px;margin:0 auto 14px;
  display:flex;align-items:center;justify-content:center;
  background:var(--brand-500);color:#111;
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-lg);
  box-shadow:var(--shadow-raised);
}
.auth-logo .ic{width:42px;height:42px;stroke-width:1.7}
.auth-brand h1{font-size:28px}
.auth-tagline{
  margin-top:9px;
  font-size:11.5px;font-weight:800;letter-spacing:1.4px;text-transform:uppercase;
}
.auth-pill{
  display:inline-block;margin-top:10px;padding:6px 13px;
  background:var(--inverse-bg);color:var(--inverse-fg);
  border-radius:var(--radius-pill);font-size:11.5px;font-weight:800;letter-spacing:.2px;
}
html[data-theme="dark"] .auth-pill{border:1px solid var(--border-soft)}
.auth-links{
  display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;
  margin-top:16px;font-size:13.5px;font-weight:700;
}
.auth-links a{text-decoration:underline}
.oauth-btn{
  display:flex;align-items:center;justify-content:center;gap:10px;width:100%;
  font-size:15px;font-weight:800;padding:14px;min-height:52px;
  background:var(--surface-0);color:var(--ink-900);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);cursor:pointer;
}
.oauth-btn+.oauth-btn{margin-top:10px}
.oauth-btn .ic{width:22px;height:22px}
.or-split{
  display:flex;align-items:center;gap:12px;margin-block:18px;
  font-size:12px;font-weight:800;color:var(--ink-500);text-transform:uppercase;letter-spacing:.6px;
}
.or-split::before,.or-split::after{content:"";flex:1;border-top:var(--bw) solid var(--border-soft)}

/* ============================================================
   Tables (settings, admin, exports)
   ============================================================ */
.table-wrap{
  border:var(--bw) solid var(--border);border-radius:var(--radius-md);
  background:var(--surface-0);overflow:hidden;box-shadow:var(--shadow-card);margin-bottom:16px;
}
.table-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch}
table.tbl{width:100%;border-collapse:collapse;font-size:13.5px}
table.tbl th,table.tbl td{padding:10px 11px;text-align:start;border-bottom:var(--bw) solid var(--border-soft)}
table.tbl thead th{
  background:var(--inverse-bg);color:var(--inverse-fg);
  font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.5px;white-space:nowrap;
}
table.tbl tbody tr:last-child td{border-bottom:0}
table.tbl tfoot td{background:var(--brand-400);font-weight:800;border-top:var(--bw-strong) solid var(--border)}
html[data-theme="dark"] table.tbl tfoot td{background:var(--surface-3)}
.num{text-align:end;font-variant-numeric:tabular-nums;white-space:nowrap}

.pill{
  display:inline-block;font-size:10.5px;font-weight:800;text-transform:uppercase;
  letter-spacing:.4px;padding:3px 9px;border-radius:var(--radius-pill);
  border:1.5px solid var(--border);background:var(--surface-2);white-space:nowrap;
}
.pill-ok{background:var(--success);color:#fff;border-color:var(--success)}
.pill-err{background:var(--danger);color:#fff;border-color:var(--danger)}
.pill-warn{background:var(--brand-500);color:#111}
html[data-theme="dark"] .pill-ok,html[data-theme="dark"] .pill-err{color:#111}

/* ============================================================
   Tablet  (screenshots 8-14)
   ============================================================ */
@media (min-width:700px){
  :root{--bar-h:84px}
  .main{padding-inline:24px;max-width:840px}
  .page-head h1{font-size:28px}
  .summary-grid{gap:14px}
  .stat{padding:18px;min-height:104px}
  .stat .v{font-size:30px}
  .stat .wm{width:76px;height:76px}
  .appbar{padding:14px 24px}
  .appbar-title .t{font-size:17px}
  .bottombar{padding:14px 24px}
  .group-pill{max-width:280px;font-size:13px}
  .overlay{align-items:center;padding:24px}
  .sheet{
    border-radius:var(--radius-lg);
    max-height:86dvh;padding:20px;
  }
  .settle-actions .btn{padding:11px 26px;font-size:14px}
  .txn-title{font-size:16px}
  .toasts{inset-inline:auto;inset-inline-end:24px}
}

/* ============================================================
   Desktop: fixed left rail + content + optional right rail
   The rail is taken OUT of flow so its height can never stretch the
   layout or push the bottom bar down the page.
   ============================================================ */
@media (max-width:1079px){
  .rail,.aside{display:none !important}
}

@media (min-width:1080px){
  :root{--rail-w:256px;--bar-h:0px}

  .shell{display:block;padding-inline-start:var(--rail-w)}

  .rail{
    position:fixed;inset-block:0;inset-inline-start:0;z-index:50;
    width:var(--rail-w);
    display:flex;flex-direction:column;
    padding:16px 12px calc(20px + env(safe-area-inset-bottom));
    background:var(--surface-0);
    border-inline-end:var(--bw) solid var(--border-soft);
    overflow-y:auto;overscroll-behavior:contain;
  }

  .appbar{
    position:sticky;top:0;
    padding:14px 28px;
    border-bottom:var(--bw) solid var(--border-soft);
  }
  .appbar-title{text-align:start}
  .appbar-title .t{justify-content:flex-start}

  .main{
    max-width:1200px;margin-inline:auto;
    padding:18px 28px 26px;
    display:grid;grid-template-columns:minmax(0,1fr);gap:26px;align-items:start;
  }
  .main.has-aside{grid-template-columns:minmax(0,1fr) 316px}
  .aside{position:sticky;top:88px;align-self:start}

  /* action bar sits in the content column, not floating over the page */
  .bottombar{
    position:sticky;bottom:0;
    inset-inline-start:auto;
    max-width:1200px;margin-inline:auto;
    padding:12px 28px calc(16px + env(safe-area-inset-bottom));
    background:linear-gradient(to top,var(--surface-1) 62%,rgba(0,0,0,0));
  }
  .group-pill{max-width:340px}

  .summary-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
  .total-bar{bottom:84px}
  .toasts{inset-inline:auto;inset-inline-end:28px;bottom:96px}
}

@media (min-width:1080px) and (max-width:1319px){
  .main.has-aside{grid-template-columns:minmax(0,1fr)}
  .aside{display:none !important}
}

.rail-nav{display:flex;flex-direction:column;gap:3px}
.rail-nav a{
  display:flex;align-items:center;gap:11px;
  padding:11px 12px;min-height:46px;
  font-size:14.5px;font-weight:800;border-radius:var(--radius-sm);
  border:var(--bw) solid transparent;
}
.rail-nav a:hover{background:var(--surface-2)}
.rail-nav a.is-active{background:var(--brand-500);color:#111;border-color:var(--border);box-shadow:var(--shadow-card)}
html[data-theme="dark"] .rail-nav a.is-active{border-color:var(--brand-700)}
.rail-nav a .ic{width:21px;height:21px}
.rail-nav a .cnt{
  margin-inline-start:auto;min-width:20px;height:20px;padding:0 5px;
  display:flex;align-items:center;justify-content:center;
  background:var(--danger);color:#fff;border-radius:var(--radius-pill);
  font-size:10.5px;font-weight:800;
}
html[data-theme="dark"] .rail-nav a .cnt{color:#111}
.rail-title{
  font-size:10.5px;font-weight:800;text-transform:uppercase;letter-spacing:1px;
  color:var(--ink-500);margin:16px 12px 6px;
}

/* mobile tab bar (secondary nav) */
.tabbar{display:none}
@media (max-width:1079px){
  .tabbar{
    display:flex;position:fixed;inset-inline:0;bottom:0;z-index:44;
    background:var(--surface-0);border-top:var(--bw) solid var(--border);
    padding:4px 2px;padding-bottom:calc(4px + env(safe-area-inset-bottom));
  }
  .tabbar a{
    flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;
    padding:6px 2px;border-radius:var(--radius-xs);
    font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.3px;
    color:var(--ink-500);
  }
  .tabbar a .ic{width:22px;height:22px}
  .tabbar a.is-active{color:var(--ink-900)}
  .tabbar a.is-active .ic{color:var(--brand-700)}
  body.has-tabbar .bottombar{bottom:calc(58px + env(safe-area-inset-bottom))}
  body.has-tabbar{--bar-h:130px}
}

/* ============================================================
   PDF preview / print — identical CSS to screen (DESIGN.md §7.16)
   ============================================================ */
.print-head{display:none}
/* generous, even margin on all four sides so nothing sits edge to edge */
@page{size:A4;margin:14mm 13mm}
@media print{
  *,*::before,*::after{
    -webkit-print-color-adjust:exact !important;
    print-color-adjust:exact !important;
  }
  /* Paper is always white, so a dark reader must still print the light palette. */
  html[data-theme="dark"]{
    color-scheme:light;
    --surface-0:#fff;--surface-1:#fff;--surface-2:#FAF0CE;--surface-3:#F5E7BC;
    --ink-900:#111;--ink-700:#454545;--ink-500:#6B6B6B;--border:#111;--border-soft:#C9BC8E;
    --inverse-bg:#111;--inverse-fg:#fff;--pdf:#D93A3A;--xls:#1D7C4D;
    --amount:#111;--success:#218A55;--danger:#D93A3A;
  }
  html,body{background:#fff !important;font-size:10.5pt}
  .appbar,.bottombar,.tabbar,.rail,.aside,.overlay,.toasts,.offline-bar,
  .drawer,.drawer-scrim,.splash,
  .no-print,.filterbar,.chips,.actions,.total-bar,.banner{display:none !important}
  /* undo the dark-only tints so the printed sheet matches the light design */
  html[data-theme="dark"] .txn-badge{background:var(--brand-500) !important;color:#111 !important}
  html[data-theme="dark"] .txn-badge.is-payment{background:var(--success) !important;color:#fff !important}
  html[data-theme="dark"] .segmented input:checked+label,
  html[data-theme="dark"] .tone-grid input:checked+label{box-shadow:none !important}
  html[data-theme="dark"] .credit{color:#fff !important}
  html[data-theme="dark"] .credit strong{color:#fff !important}
  html[data-theme="dark"] .auth-pill{border:0 !important}
  .shell{display:block}
  .main{display:block;max-width:none;padding:0}
  .print-head{display:block !important}
  .card,.stat,.txn,.settle-card,.notif{
    box-shadow:none !important;break-inside:avoid;page-break-inside:avoid;
  }
  /* A scroll container clips on paper, so the transactions table would lose
     its right-hand columns. Let it lay out at full width instead. */
  .table-scroll{overflow:visible !important}
  .table-wrap{
    overflow:hidden !important;                 /* keeps the rounded corners */
    box-shadow:none !important;
    break-inside:auto;page-break-inside:auto;
    border:1pt solid var(--border);border-radius:3mm;
    margin-bottom:6mm;
  }
  table.tbl{width:100% !important;table-layout:auto;border-collapse:separate;border-spacing:0}
  table.tbl th,table.tbl td{white-space:normal;overflow-wrap:anywhere;padding:2mm 2.4mm}
  .num{white-space:nowrap}
  /* the strict-responsive clipping must not swallow printed content */
  .shell,.main,.thermal-page{overflow:visible !important}
  /* a little breathing room inside the page box */
  .main{padding:0 !important}
  .doc-head{margin-bottom:6mm}
  .section-title{margin:6mm 0 2.5mm}
  thead{display:table-header-group}
  tfoot{display:table-footer-group}
  tr,td,th{page-break-inside:avoid}
  a[href]::after{content:""}
  .summary-grid{grid-template-columns:repeat(4,1fr)}
}

/* ============================================================
   Print/PDF document header
   ============================================================ */
.doc-head{
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  background:var(--brand-400);color:#111;padding:14px;margin-bottom:16px;
}
.doc-head .dh-top{display:flex;align-items:center;gap:12px}
.doc-head .dh-badge{
  width:44px;height:44px;flex:0 0 44px;display:flex;align-items:center;justify-content:center;
  background:var(--brand-500);border:var(--bw-strong) solid var(--border);border-radius:var(--radius-sm);
}
.doc-head h2{font-size:20px}
.doc-head .dh-sub{font-size:12.5px;font-weight:700}
.doc-head .dh-meta{
  display:flex;flex-wrap:wrap;gap:4px 20px;margin-top:10px;padding-top:9px;
  border-top:var(--bw) solid var(--border);font-size:11px;font-weight:700;
}

/* ============================================================
   Installer
   ============================================================ */
.install-wrap{
  max-width:820px;width:100%;margin-inline:auto;
  padding:24px 16px calc(28px + env(safe-area-inset-bottom));
}
.install-head{display:flex;align-items:center;gap:14px;margin-bottom:20px}
.install-head .mark{
  width:60px;height:60px;flex:0 0 60px;
  display:flex;align-items:center;justify-content:center;
  background:var(--brand-500);color:#111;
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  box-shadow:var(--shadow-raised);
}
.install-head .mark .ic{width:34px;height:34px;stroke-width:1.7}
.install-head h1{font-size:23px}
.install-head .s{font-size:12.5px;color:var(--ink-500);font-weight:700}
.stepper{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:18px}
.stepper .st{
  display:inline-flex;align-items:center;gap:7px;
  font-size:12.5px;font-weight:800;
  padding:8px 13px;min-height:36px;
  background:var(--surface-2);color:var(--ink-500);
  border:var(--bw) solid var(--border-soft);border-radius:var(--radius-pill);
}
.stepper .st .n{
  width:20px;height:20px;flex:0 0 20px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  background:var(--surface-3);color:var(--ink-700);font-size:11px;
}
.stepper .st.is-active{background:var(--brand-500);color:#111;border-color:var(--border);box-shadow:var(--shadow-card)}
.stepper .st.is-active .n{background:#111;color:var(--brand-500)}
.stepper .st.is-done{background:var(--success);color:#fff;border-color:var(--success)}
.stepper .st.is-done .n{background:rgba(255,255,255,.28);color:#fff}
html[data-theme="dark"] .stepper .st.is-done{color:#111}
.install-wrap .banner ul{margin:6px 0 0;padding-inline-start:18px;font-weight:600}
.install-wrap code{
  background:var(--surface-3);border:1.5px solid var(--border-soft);
  border-radius:6px;padding:1px 6px;font-weight:700;font-size:.92em;
}

/* ============================================================
   Footer credit
   ============================================================ */
.credit{
  margin-top:26px;padding:14px;text-align:center;
  font-size:11.5px;font-weight:700;line-height:1.85;
  background:var(--inverse-bg);color:var(--inverse-fg);
  border:var(--bw) solid var(--border);border-radius:var(--radius-md);
}
html[data-theme="dark"] .credit{color:var(--ink-700)}
html[data-theme="dark"] .credit strong{color:var(--brand-500)}
.credit a{color:var(--brand-500);text-decoration:underline}
.credit .ic{width:14px;height:14px}

/* reduced motion */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms !important;transition-duration:.01ms !important}
}

/* ============================================================
   FORM CONTROLS v2 — themed selects, pickers and date fields
   Native controls are kept in the DOM so everything still works
   without JS; the themed shell is layered on top.
   ============================================================ */

/* --- the cream "field box" shared by pickers, amounts and date rows --- */
.f-box{
  display:flex;align-items:center;gap:10px;width:100%;
  min-height:56px;padding:14px 15px;
  background:var(--surface-2);color:var(--ink-900);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  font-family:var(--font);font-size:16px;font-weight:700;
  text-align:start;cursor:pointer;
}
.f-box:active{transform:translateY(1px)}
.f-box .lead{flex:0 0 auto;display:flex;align-items:center;color:var(--ink-700)}
.f-box .lead .ic{width:21px;height:21px}
.f-box .txt{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.f-box .txt.is-empty{color:var(--ink-500);font-weight:600}
.f-box .chev{flex:0 0 auto;color:var(--ink-700)}
.f-box .chev .ic{width:20px;height:20px}
.f-box[disabled],.f-box.is-disabled{opacity:.55;cursor:not-allowed}

/* --- picker: a native <select> plus a themed button that replaces it --- */
.picker{position:relative;display:block}
.picker-native{
  /* still focusable and submittable; the themed button sits on top */
  position:absolute;inset:0;width:100%;height:100%;
  opacity:0;border:0;padding:0;margin:0;
}
.picker-btn{display:flex}
/* JS present -> themed button drives it; JS absent -> plain styled select */
.picker:not(.is-ready) .picker-btn{display:none}
.picker:not(.is-ready) .picker-native{position:static;opacity:1;height:auto}
.picker.is-ready .picker-native{pointer-events:none;visibility:hidden}
.picker.is-ready .picker-native:focus-visible+.picker-btn{outline:3px solid var(--brand-700);outline-offset:2px}

/* option list inside the picker sheet */
.opt-list{list-style:none;margin:0;padding:0;max-height:58dvh;overflow-y:auto}
.opt{
  display:flex;align-items:center;gap:12px;width:100%;
  font-family:var(--font);font-size:15.5px;font-weight:700;text-align:start;
  padding:13px 12px;min-height:52px;
  background:transparent;color:var(--ink-900);
  border:0;border-bottom:var(--bw) solid var(--border-soft);
  border-radius:var(--radius-sm);cursor:pointer;
}
.opt:last-child{border-bottom:0}
.opt:hover,.opt:focus-visible{background:var(--surface-2)}
.opt .oi{
  width:34px;height:34px;flex:0 0 34px;
  display:flex;align-items:center;justify-content:center;
  background:var(--surface-3);border-radius:var(--radius-xs);color:var(--ink-900);
}
.opt .oi .ic{width:20px;height:20px}
.opt .ot{flex:1;min-width:0}
.opt .ot .n{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.opt .ot .m{display:block;font-size:12.5px;font-weight:600;color:var(--ink-500)}
.opt .ok{flex:0 0 auto;color:var(--success);opacity:0}
.opt.is-on{background:var(--brand-400)}
.opt.is-on .oi{background:var(--surface-0)}
.opt.is-on .ok{opacity:1;color:var(--ink-900)}
html[data-theme="dark"] .opt.is-on{background:var(--surface-3)}
html[data-theme="dark"] .opt.is-on .ok{color:var(--brand-500)}
.opt-search{margin-bottom:10px}

/* --- date field: ‹ Today, 8th Aug ›  + calendar button --- */
.date-field{display:flex;align-items:stretch;gap:10px}
.date-row{
  flex:1;min-width:0;display:flex;align-items:center;gap:4px;
  min-height:56px;padding:8px 6px;
  background:var(--surface-2);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
}
.date-step{
  width:40px;height:40px;flex:0 0 40px;
  display:flex;align-items:center;justify-content:center;
  background:transparent;color:var(--ink-900);
  border:0;border-radius:var(--radius-pill);cursor:pointer;
}
.date-step:hover{background:var(--surface-3)}
.date-step:disabled{opacity:.3;cursor:not-allowed}
.date-step .ic{width:20px;height:20px;stroke-width:2.4}
.date-label{
  flex:1;min-width:0;text-align:center;
  font-size:16px;font-weight:800;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.date-cal{
  width:56px;flex:0 0 56px;
  display:flex;align-items:center;justify-content:center;
  background:var(--brand-500);color:#111;
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);cursor:pointer;
}
html[data-theme="dark"] .date-cal{border-color:var(--brand-700)}
.date-cal .ic{width:24px;height:24px;stroke-width:1.9}
.date-cal:active{transform:translateY(2px);box-shadow:none}
@media (max-width:359px){
  .date-cal{width:48px;flex-basis:48px}
  .date-label{font-size:14.5px}
}

/* --- wheel date picker sheet --- */
.sheet-actions{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:6px}
.sheet-actions .t{font-size:17px;font-weight:800}
.wheels{
  position:relative;display:flex;gap:6px;
  height:246px;overflow:hidden;
  margin-block:6px 4px;
}
.wheel{
  flex:1;min-width:0;height:100%;overflow-y:auto;
  scroll-snap-type:y mandatory;scrollbar-width:none;-ms-overflow-style:none;
  text-align:center;
}
.wheel::-webkit-scrollbar{display:none}
.wheel-pad{height:103px}
.wheel-item{
  display:flex;align-items:center;justify-content:center;
  height:40px;scroll-snap-align:center;
  font-size:16px;font-weight:700;color:var(--ink-500);
  cursor:pointer;user-select:none;
  transition:color .12s ease,font-size .12s ease;
}
.wheel-item.is-on{font-size:19px;font-weight:800;color:var(--ink-900)}
/* the selected band, drawn behind the columns */
.wheels::before{
  content:"";position:absolute;inset-inline:0;top:103px;height:40px;
  background:var(--surface-3);border-radius:var(--radius-sm);
  pointer-events:none;z-index:0;
}
.wheel{position:relative;z-index:1}
/* fade the rows that scroll out of the band */
.wheels::after{
  content:"";position:absolute;inset:0;pointer-events:none;z-index:2;
  background:linear-gradient(var(--surface-0) 4%,rgba(0,0,0,0) 36%,rgba(0,0,0,0) 64%,var(--surface-0) 96%);
}

/* --- big amount input (screenshot: "Rs. 0.00") --- */
.amount-big{position:relative;display:flex;align-items:center}
.amount-big input{
  min-height:74px;padding:16px 16px;font-size:26px;font-weight:800;
  background:var(--surface-2);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  letter-spacing:-.5px;
}
.amount-big input::placeholder{color:var(--ink-500);font-weight:800;opacity:.65}
.f-lbl{display:block;font-size:15px;font-weight:800;margin:18px 0 8px}
.f-lbl:first-child{margin-top:0}

/* text field matching the screenshots */
.f-text{
  min-height:64px;padding:16px 15px;font-size:16px;font-weight:700;
  background:var(--surface-2);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
}
.f-text::placeholder{color:var(--ink-500);font-weight:600}

/* ============================================================
   Selectable member chips (Who paid? / Split between?)
   ============================================================ */
.pick-chips{display:flex;flex-wrap:wrap;gap:9px}
.pick-chip{position:relative;display:inline-flex}
.pick-chip input{position:absolute;opacity:0;width:0;height:0}
.pick-chip span{
  display:inline-flex;align-items:center;gap:5px;
  font-size:14.5px;font-weight:800;line-height:1;
  padding:12px 16px;min-height:44px;
  background:var(--surface-0);color:var(--ink-900);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-sm);
  cursor:pointer;white-space:nowrap;
}
.pick-chip .ic{width:15px;height:15px;stroke-width:2.6;opacity:0;margin-inline-end:-3px}
.pick-chip input:checked+span{background:var(--brand-500);color:#111}
.pick-chip input:checked+span .ic{opacity:1}
html[data-theme="dark"] .pick-chip input:checked+span{border-color:var(--brand-700)}
.pick-chip input:focus-visible+span{outline:3px solid var(--brand-700);outline-offset:2px}
.pick-chip.is-hidden{display:none}

/* split-method segmented, screenshot style: = Equally | Rs. | % | (+) */
.split-seg{
  display:flex;gap:0;
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  overflow:hidden;background:var(--surface-0);
}
.split-seg input{position:absolute;opacity:0;width:0;height:0}
.split-seg label{
  flex:1;display:flex;align-items:center;justify-content:center;gap:6px;
  min-height:56px;padding:10px 8px;
  font-size:14.5px;font-weight:700;color:var(--ink-900);
  border-inline-start:var(--bw-strong) solid var(--border);
  cursor:pointer;white-space:nowrap;
}
.split-seg label:first-of-type{border-inline-start:0}
.split-seg .wide{flex:2.1}
.split-seg .ic{width:17px;height:17px}
.split-seg input:checked+label{background:var(--brand-400);font-weight:800}
html[data-theme="dark"] .split-seg input:checked+label{background:var(--surface-3)}
.split-seg input:focus-visible+label{outline:3px solid var(--brand-700);outline-offset:-3px}

/* sticky primary action at the foot of a form page */
.form-cta{
  position:sticky;bottom:0;z-index:30;
  padding-block:12px;
  padding-bottom:calc(12px + env(safe-area-inset-bottom));
  background:linear-gradient(to top,var(--surface-1) 58%,rgba(0,0,0,0));
}
.form-cta .btn{width:100%;min-height:58px;font-size:16.5px;border-radius:var(--radius-md)}

/* ============================================================
   Drop-UP menus anchored to the bottom bar
   ============================================================ */
.dropup{
  position:fixed;z-index:96;
  inset-inline-start:14px;inset-inline-end:14px;
  max-width:340px;
  background:var(--surface-0);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-lg);
  box-shadow:var(--shadow-modal);
  padding:8px;
  transform:translateY(10px);opacity:0;pointer-events:none;
  transition:transform .16s cubic-bezier(.2,.8,.2,1),opacity .16s ease;
}
.dropup[hidden]{display:none !important}
.dropup.is-open{transform:none;opacity:1;pointer-events:auto}
.dropup.at-end{inset-inline-start:auto}
.dropup-scrim{position:fixed;inset:0;z-index:95;background:rgba(0,0,0,.32)}
html[data-theme="dark"] .dropup-scrim{background:rgba(0,0,0,.55)}
.dropup-scrim[hidden]{display:none !important}
.dropup-item{
  display:flex;align-items:center;gap:13px;width:100%;
  font-family:var(--font);font-size:15.5px;font-weight:800;text-align:start;
  padding:13px 12px;min-height:52px;
  background:transparent;color:var(--ink-900);
  border:0;border-radius:var(--radius-sm);cursor:pointer;
}
.dropup-item:hover,.dropup-item:focus-visible{background:var(--surface-2)}
.dropup-item .di{
  width:34px;height:34px;flex:0 0 34px;
  display:flex;align-items:center;justify-content:center;
  background:var(--brand-500);color:#111;border-radius:var(--radius-xs);
}
html[data-theme="dark"] .dropup-item .di{background:rgba(255,208,40,.18);color:var(--brand-500)}
.dropup-item .di .ic{width:20px;height:20px}
.dropup-item.is-danger{color:var(--danger)}
.dropup-item.is-danger .di{background:var(--danger);color:#fff}
html[data-theme="dark"] .dropup-item.is-danger .di{background:rgba(255,122,122,.18);color:var(--danger)}

/* ============================================================
   Transactions: dense, responsive rows with a category icon
   ============================================================ */
.txn-list{display:flex;flex-direction:column;gap:7px}
.txn.txn-dense{
  align-items:center;gap:10px;padding:9px 11px;margin-bottom:0;
  border-radius:var(--radius-sm);
}
.txn-dense .txn-badge{width:26px;height:26px;flex-basis:26px;border-radius:7px}
.txn-dense .txn-badge .ic{width:16px;height:16px}
.txn-dense .txn-title{font-size:13.5px;font-weight:800;line-height:1.2}
.txn-dense .txn-sub{font-size:11.5px;margin-top:1px}
.txn-dense .txn-amt{font-size:14px}
.txn-dense .txn-amt .cur{font-size:10.5px}
.txn-dense .txn-meta{font-size:10px;margin-top:2px}
/* the amount column must never squeeze the title into one letter per line */
.txn-dense .txn-right{max-width:46%}
.txn-dense .txn-body{flex:1 1 auto;min-width:0}
.txn-dense .txn-title,.txn-dense .txn-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media (max-width:359px){
  .txn-dense{padding:8px 9px;gap:8px}
  .txn-dense .txn-title{font-size:12.5px}
  .txn-dense .txn-amt{font-size:13px}
  .txn-dense .txn-meta{display:none}
}
@media (min-width:700px){
  .txn-dense{padding:12px 14px}
  .txn-dense .txn-title{font-size:15px}
  .txn-dense .txn-amt{font-size:16px}
  .txn-dense .txn-badge{width:30px;height:30px;flex-basis:30px}
}
.date-head.is-sticky{
  position:sticky;top:var(--appbar-h);z-index:12;
  background:var(--surface-1);padding-block:6px;margin-block:12px 6px;
}

/* floating "+ Add" for the transactions screen */
.fab-add{
  position:fixed;z-index:46;
  inset-inline-end:16px;bottom:calc(16px + env(safe-area-inset-bottom));
  display:inline-flex;align-items:center;gap:8px;
  font-size:15px;font-weight:800;line-height:1;
  padding:14px 22px;min-height:52px;
  background:var(--brand-500);color:#111;
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-pill);
  box-shadow:var(--shadow-raised);cursor:pointer;
}
html[data-theme="dark"] .fab-add{border-color:var(--brand-700)}
.fab-add:active{transform:translateY(2px);box-shadow:none}

/* ============================================================
   Group Settings / Profile — screenshot layout
   ============================================================ */
.gs-name{
  display:flex;align-items:center;gap:12px;width:100%;
  min-height:60px;padding:16px;
  background:var(--surface-2);color:var(--ink-900);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  font-family:var(--font);font-size:16.5px;font-weight:800;text-align:start;cursor:pointer;
}
.gs-name .n{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.gs-name .ic{width:21px;height:21px;flex:0 0 21px}

.code-box{
  display:flex;align-items:center;gap:10px;
  min-height:62px;padding:12px 12px 12px 16px;
  background:var(--surface-2);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
}
.code-box code{
  flex:1;min-width:0;font-size:22px;font-weight:800;letter-spacing:7px;
  font-family:var(--font);overflow:hidden;text-overflow:ellipsis;
}
.code-box .btn-round-sm{
  width:40px;height:40px;flex:0 0 40px;
  display:flex;align-items:center;justify-content:center;
  background:transparent;color:var(--ink-900);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-pill);cursor:pointer;
}
.code-box .btn-round-sm .ic{width:19px;height:19px}
@media (max-width:359px){.code-box code{font-size:18px;letter-spacing:4px}}

.mem-row{
  display:flex;align-items:center;gap:12px;
  min-height:64px;padding:12px 14px;
  background:var(--surface-0);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
}
.mem-row+.mem-row{margin-top:10px}
.mem-row .avatar{background:var(--brand-400)}
html[data-theme="dark"] .mem-row .avatar{background:rgba(255,208,40,.2);color:var(--brand-500)}
.mem-row .n{flex:1;min-width:0;font-size:15.5px;font-weight:800;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mem-row .role{font-size:12.5px;font-weight:700;color:var(--ink-500);flex:0 0 auto}
.mem-row .more{
  width:38px;height:38px;flex:0 0 38px;
  display:flex;align-items:center;justify-content:center;
  background:transparent;color:var(--ink-700);
  border:0;border-radius:var(--radius-pill);cursor:pointer;
}
.mem-row .more:hover{background:var(--surface-2)}

.danger-link{
  display:block;width:100%;margin-top:22px;padding:14px;
  background:none;border:0;cursor:pointer;
  font-family:var(--font);font-size:15.5px;font-weight:800;color:var(--danger);text-align:center;
}
.danger-link:hover{text-decoration:underline}

/* profile stat trio */
.mini-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:14px}
.mini-stat{
  padding:12px 10px;text-align:start;
  background:var(--surface-0);
  border:var(--bw) solid var(--border-soft);border-radius:var(--radius-sm);
}
.mini-stat .v{font-size:24px;font-weight:800;line-height:1.1}
.mini-stat .k{font-size:11.5px;font-weight:600;color:var(--ink-500);margin-top:3px;line-height:1.25}

.list-row{
  display:flex;align-items:center;gap:13px;width:100%;
  min-height:58px;padding:14px 15px;
  background:var(--surface-2);color:var(--ink-900);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  font-family:var(--font);font-size:15.5px;font-weight:700;text-align:start;cursor:pointer;
}
.list-row+.list-row{margin-top:10px}
.list-row .lead .ic{width:21px;height:21px}
.list-row .n{flex:1;min-width:0}
.list-row .tail{flex:0 0 auto;color:var(--ink-500);font-size:13px;font-weight:700;display:flex;align-items:center;gap:6px}

/* ============================================================
   Paywall — always dark, matches the published pricing sheet
   ============================================================ */
.paywall{
  --pw-bg:#171717;--pw-card:#242424;--pw-ink:#F4F4F4;--pw-muted:#A8A8A8;
  background:var(--pw-bg);color:var(--pw-ink);
  min-height:100dvh;margin:0 auto;padding:20px 16px calc(24px + env(safe-area-inset-bottom));
  max-width:520px;
}
.paywall .pw-close{
  position:absolute;top:16px;inset-inline-end:16px;
  width:44px;height:44px;display:flex;align-items:center;justify-content:center;
  background:var(--brand-500);color:#111;border:0;border-radius:var(--radius-pill);cursor:pointer;
}
.paywall .pw-mark{width:96px;height:96px;margin:12px auto 18px;border-radius:22px;overflow:hidden}
.paywall .pw-mark img{display:block;width:100%;height:100%}
.paywall h1{font-size:25px;text-align:center;margin-bottom:12px}
.paywall .pw-blurb{text-align:center;color:var(--pw-muted);font-size:14.5px;font-weight:600;line-height:1.5;margin-bottom:22px}
.paywall .pw-sub{font-size:15px;font-weight:800;margin-bottom:12px}
.paywall .pw-feats{list-style:none;margin:0 0 20px;padding:0;display:flex;flex-direction:column;gap:12px}
.paywall .pw-feats li{display:flex;align-items:center;gap:12px;font-size:14px;font-weight:600;color:var(--pw-ink)}
.paywall .pw-feats .ic{width:21px;height:21px;flex:0 0 21px;color:var(--brand-500)}
.paywall .pw-art{
  border:2px solid #3A3A3A;border-radius:var(--radius-md);
  background:var(--brand-500);margin-bottom:22px;overflow:hidden;
}
.paywall .pw-art svg{display:block;width:100%;height:auto}

.pw-tiers{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-bottom:18px}
.pw-tier{position:relative;display:block}
.pw-tier input{position:absolute;opacity:0;width:0;height:0}
.pw-tier .body{
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
  padding:20px 8px 16px;min-height:132px;
  background:var(--pw-card);color:var(--pw-ink);
  border:2px solid #3A3A3A;border-radius:var(--radius-md);cursor:pointer;text-align:center;
}
.pw-tier .qty{font-size:27px;font-weight:800;line-height:1;letter-spacing:-1px}
.pw-tier .unit{font-size:12.5px;font-weight:700;color:var(--pw-muted)}
.pw-tier .price{margin-top:9px;font-size:15px;font-weight:800}
.pw-tier .once{font-size:11px;font-weight:600;color:var(--pw-muted)}
.pw-tier input:checked+.body{background:var(--brand-500);color:#111;border-color:var(--brand-500)}
.pw-tier input:checked+.body .unit,.pw-tier input:checked+.body .once{color:rgba(17,17,17,.68)}
.pw-tier input:focus-visible+.body{outline:3px solid var(--brand-500);outline-offset:2px}
.pw-tier .tick{
  position:absolute;top:-9px;inset-inline-end:-6px;z-index:2;
  width:24px;height:24px;display:none;align-items:center;justify-content:center;
  background:#111;color:var(--brand-500);border-radius:50%;
}
.pw-tier input:checked~.tick{display:flex}
.pw-tier .tick .ic{width:15px;height:15px;stroke-width:3}
.pw-badge{
  position:absolute;top:-11px;inset-inline-start:50%;transform:translateX(-50%);
  z-index:2;padding:3px 11px;border-radius:var(--radius-pill);
  background:#D98BFF;color:#111;font-size:11px;font-weight:800;white-space:nowrap;
}
[dir="rtl"] .pw-badge{transform:translateX(50%)}
.pw-cta{
  display:block;width:100%;min-height:56px;
  font-family:var(--font);font-size:16.5px;font-weight:800;
  background:var(--brand-500);color:#111;
  border:0;border-radius:var(--radius-md);cursor:pointer;
}
.pw-restore{
  display:block;width:100%;margin-top:14px;padding:8px;
  background:none;border:0;cursor:pointer;
  font-family:var(--font);font-size:13.5px;font-weight:800;color:var(--pw-ink);text-align:center;
}
@media (max-width:340px){
  .pw-tiers{gap:7px}
  .pw-tier .qty{font-size:22px}
  .pw-tier .price{font-size:13.5px}
}

/* ============================================================
   Rail v2 — grouped, quieter, matches the app chrome
   ============================================================ */
.rail-brand{display:flex;align-items:center;gap:10px;padding:2px 8px 14px}
.rail-brand .m{width:34px;height:34px;flex:0 0 34px;border-radius:9px;overflow:hidden}
.rail-brand .m img{display:block;width:100%;height:100%}
.rail-brand .t{font-size:15px;font-weight:800;line-height:1.15;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rail-foot{margin-top:auto;padding-top:12px}

/* full-bleed page (the paywall supplies its own frame and background) */
.main.is-bare{padding:0;max-width:none}
.main.is-bare>div{min-width:0}

/* ============================================================
   Super admin console
   ============================================================ */
.adm-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px;margin-block:12px}
.adm-stat{
  padding:14px;background:var(--surface-2);
  border:var(--bw) solid var(--border-soft);border-radius:var(--radius-md);
}
.adm-stat .v{font-size:26px;font-weight:800;line-height:1.1;letter-spacing:-.6px}
.adm-stat .k{font-size:12px;font-weight:600;color:var(--ink-500);margin-top:4px}
.adm-stat.is-paid .v{color:var(--success)}
.adm-stat.is-free .v{color:var(--ink-700)}
.plan-pill{
  display:inline-flex;align-items:center;gap:5px;
  font-size:10.5px;font-weight:800;text-transform:uppercase;letter-spacing:.4px;
  padding:3px 9px;border-radius:var(--radius-pill);border:1.5px solid var(--border);
}
.plan-free{background:var(--surface-3);color:var(--ink-900)}
.plan-paid{background:var(--brand-500);color:#111;border-color:var(--border)}
.plan-trial{background:var(--warning);color:#fff}
html[data-theme="dark"] .plan-trial{color:#111}
.adm-bar{
  display:flex;align-items:center;gap:8px;height:10px;
  border-radius:99px;overflow:hidden;background:var(--surface-3);margin-top:8px;
}
.adm-bar span{display:block;height:100%;background:var(--brand-500)}

/* ============================================================
   Payment detail card (the delete sheet)
   ============================================================ */
.pay-card{
  background:var(--surface-2);
  border:var(--bw-strong) solid var(--border);
  border-radius:var(--radius-md);
  padding:14px 16px;
  display:flex;flex-direction:column;gap:11px;
  font-size:14.5px;
}
.pay-card .muted{font-weight:600}
.pay-card strong{font-weight:800;text-align:end;min-width:0;overflow-wrap:anywhere}

/* ============================================================
   Thermal receipt — 80mm roll, same palette as the app
   ============================================================ */
.thermal-page{
  padding:18px 12px calc(24px + env(safe-area-inset-bottom));
  display:flex;flex-direction:column;align-items:center;
}
/* Width follows the device: a phone gets the 80mm roll width, a larger screen
   gets a roomier preview. "Save as Image" measures whatever is on screen, so
   the PNG always matches the preview the user is looking at. */
@media (min-width:700px){
  .thermal{max-width:380px;font-size:13px}
  .thermal .th-mark{width:64px;height:64px}
}
.thermal{
  width:100%;max-width:302px;            /* 80mm at 96dpi, minus the margins */
  background:var(--surface-0);color:var(--ink-900);
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-sm);
  padding:16px 14px;
  font-size:12px;line-height:1.45;
  font-variant-numeric:tabular-nums;
}
.th-head{text-align:center}
.th-mark{display:block;width:56px;height:56px;margin:0 auto 8px}
.th-app{font-size:15px;font-weight:800;letter-spacing:-.2px}
.th-tag{font-size:10px;font-weight:700;color:var(--ink-500);text-transform:uppercase;letter-spacing:.7px}
.th-rule{border-top:1.5px dashed var(--border-soft);margin-block:10px}
.th-title{text-align:center;font-size:13px;font-weight:800;text-transform:uppercase;letter-spacing:.8px}
.th-group{text-align:center;font-size:13px;font-weight:800;margin-top:3px}
.th-when{text-align:center;font-size:10.5px;font-weight:600;color:var(--ink-500);margin-top:2px}
.th-sub{
  font-size:10.5px;font-weight:800;text-transform:uppercase;letter-spacing:.7px;
  color:var(--ink-700);margin-bottom:6px;
}
.th-kv{display:flex;justify-content:space-between;gap:10px;padding-block:3px}
.th-kv span{color:var(--ink-700);font-weight:600;min-width:0;overflow-wrap:anywhere}
.th-kv b{font-weight:800;text-align:end;white-space:nowrap}
.th-ref{margin-top:6px;font-size:10px;font-weight:700;color:var(--ink-500);text-align:center;letter-spacing:.5px}
.th-total{
  display:flex;justify-content:space-between;gap:10px;align-items:center;
  margin-top:9px;padding:8px 10px;
  background:var(--brand-500);color:#111;
  border:1.5px solid var(--border);border-radius:var(--radius-xs);
  font-size:13px;font-weight:800;
}
html[data-theme="dark"] .th-total{border-color:var(--brand-700)}
.th-note{text-align:center;font-weight:700;padding-block:4px}
.th-foot{text-align:center;font-size:10px;font-weight:600;color:var(--ink-700);line-height:1.6}
.th-thanks{margin-top:6px;font-size:11px;font-weight:800;color:var(--ink-900)}

/* an 80mm roll has no margins and no colour to spare on chrome */
@media print{
  @page{size:80mm auto;margin:3mm}
  body.is-bare-doc{background:#fff !important}
  .thermal-page{padding:0;display:block}
  .thermal{
    max-width:none;width:auto;
    border:0;border-radius:0;padding:0;
    font-size:11pt;
  }
  .th-total{background:#FFD028 !important;color:#111 !important}
}

/* ============================================================
   Dashboard v2 — member chips, stat grid, settled banner
   ============================================================ */
.dash-chips{margin-block:4px 12px}
.dash-settled{
  display:flex;flex-direction:column;align-items:center;gap:10px;
  padding:26px 16px;text-align:center;
  background:var(--surface-2);
  border:var(--bw) solid var(--border-soft);border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);
  margin-block:12px 4px;
}
.dash-settled .ic{width:34px;height:34px;color:var(--ink-900)}
.dash-settled .t{font-size:16.5px;font-weight:800}
.view-all{
  display:flex;align-items:center;justify-content:center;
  width:100%;min-height:54px;margin-top:12px;
  font-family:var(--font);font-size:16px;font-weight:800;
  background:var(--brand-500);color:#111;
  border:var(--bw-strong) solid var(--border);border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);cursor:pointer;
}
html[data-theme="dark"] .view-all{border-color:var(--brand-700)}
.view-all:active{transform:translateY(2px);box-shadow:none}

/* stacked sheets: the newest must paint above the one it came from */
#sheetHost>.overlay{z-index:100}
#sheetHost>.overlay~.overlay{z-index:102}
#sheetHost>.overlay~.overlay~.overlay{z-index:104}

/* ============================================================
   Typography roles
   Poppins for anything that reads as a heading or a figure,
   Montserrat (the body default) for everything else.
   ============================================================ */
.appbar-title .t,
.sheet-title .t,
.section-title,
.f-lbl,
.page-head h1,
.date-label,
.stat .v,
.mini-stat .v,
.adm-stat .v,
.txn-amt,
.settle-amt,
.total-bar .v,
.amount-big input,
.code-box code,
.pw-tier .qty,
.pw-tier .price,
.th-app,
.th-title,
.th-group,
.th-total,
.dash-settled .t,
.view-all,
.rail-brand .t,
.auth-brand h1,
.install-head h1,
.doc-head h2,
.gs-name,
.mem-row .n,
.person .n,
.pick-row .pt .n,
.txn-title,
.btn-primary,
.add-btn,
.fab-add,
.pw-cta,
.form-cta .btn{
  font-family:var(--font-head);
}
/* Poppins runs a touch wider, so headings keep 700 where 800 was used before */
.appbar-title .t,.sheet-title .t,.stat .v,.mini-stat .v,.adm-stat .v,
.txn-amt,.settle-amt,.amount-big input,.pw-tier .qty,.th-total{font-weight:700}
.section-title,.f-lbl,.txn-title,.person .n,.mem-row .n{font-weight:600}
/* tabular figures everywhere money is shown */
.stat .v,.mini-stat .v,.adm-stat .v,.txn-amt,.settle-amt,
.total-bar .v,.amount-big input,.th-total b,.th-kv b,.pw-tier .price{
  font-variant-numeric:tabular-nums;
}

/* (the language switcher was removed: the app ships in English only) */

/* developer credit line inside the exported document header */
.doc-head .dh-dev{
  display:flex;flex-wrap:wrap;gap:4px 14px;align-items:center;
  margin-top:8px;padding-top:8px;
  border-top:1.5px solid rgba(17,17,17,.22);
  font-size:11px;font-weight:700;
}
.doc-head .dh-dev strong{font-weight:800}
.doc-head .dh-dev .ic{width:13px;height:13px;vertical-align:-.15em}

/* The PDF screen shows the very header it will print, so the user can see the
   logo, group and credit before hitting Save as PDF. */
.doc-head.is-preview{display:block}

/* stat sub-line: explains the figure above it (e.g. "+ Rs 5,000 settled") */
.stat .s{
  position:relative;z-index:1;
  margin-top:3px;font-size:11.5px;font-weight:700;
  color:var(--success);line-height:1.25;
}
.stat.is-paid .s{color:var(--ink-500)}
@media (max-width:340px){.stat .s{font-size:10.5px}}

/* ============================================================
   STRICT RESPONSIVE LAYER
   Nothing may overflow its container, and nothing may create a
   horizontal page scrollbar. Loaded last so it always wins.
   ============================================================ */

/* --- 1. no page-level sideways scroll ------------------------------------ */
html,body{max-width:100%}
/* clip, not hidden: hidden would break every position:sticky descendant */
.shell,.main,.auth,.paywall,.install-wrap,.thermal-page{overflow-x:clip}
@supports not (overflow:clip){
  .shell{overflow-x:hidden}
}

/* --- 2. flex/grid children must be allowed to shrink -------------------- */
.row>*,.row-between>*,.actions>*,.summary-grid>*,.mini-stats>*,.adm-grid>*,
.pw-tiers>*,.grid-2>*,.grid-3>*,.split-row>*,.txn>*,.mem-row>*,.list-row>*,
.f-box>*,.code-box>*,.pick-row>*,.settle-top>*,.notif>*,.drawer-head>*,
.person>*,.date-row>*,.main>div,.card>*,.sheet>*{min-width:0}

/* --- 3. user-supplied text can be anything ------------------------------ */
/* wrapping elements: break anywhere rather than push the card wider */
.page-head h1,.txn-title,.txn-sub,.person .n,.person .m,
.pick-row .pt .n,.pick-row .pt .m,.settle-text,.notif-title,.notif-text,
.drawer-head .n,.drawer-head .m,
.opt .ot .n,.opt .ot .m,.th-kv span,.pay-card strong,
.banner,.empty,.dash-settled .t{
  overflow-wrap:anywhere;
}
/* single-line elements: truncate with an ellipsis instead of wrapping */
.txn-dense .txn-title,.txn-dense .txn-sub,.appbar-title .t span,
.f-box .txt,.mem-row .n,.gs-name .n,.group-pill span,.list-row .n{
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}

/* --- 4. buttons: never squeezed narrower than their label ---------------- */
.btn,.add-btn,.fab-add,.view-all,.pw-cta,.dl-btn{white-space:nowrap}
.btn>span,.add-btn>span,.fab-add>span{min-width:0}
/* an action row wraps onto the next line instead of crushing its buttons */
.actions.actions-fit>*{flex:0 1 auto;min-width:-moz-max-content;min-width:max-content}
.actions.actions-fit .btn{width:100%}
@media (max-width:430px){
  /* one action per row: guaranteed to fit whatever the label says */
  .actions.actions-fit{display:grid;grid-template-columns:1fr;gap:9px}
  .actions.actions-fit>*{min-width:0;width:100%}
}

/* --- 5. figures scale with the viewport so amounts always fit ----------- */
.stat .v{font-size:clamp(19px,6.2vw,26px)}
.stat .v .cur{font-size:.6em}
.mini-stat .v{font-size:clamp(18px,5.4vw,24px)}
.txn-amt{font-size:clamp(13px,3.9vw,17px)}
.settle-amt{font-size:clamp(13px,3.9vw,16px)}
.amount-big input{font-size:clamp(21px,7vw,26px)}
.page-head h1{font-size:clamp(19px,5.6vw,24px)}
.adm-stat .v{font-size:clamp(19px,5.6vw,26px);overflow-wrap:anywhere}
@media (min-width:700px){
  .stat .v{font-size:30px}
  .mini-stat .v{font-size:24px}
  .txn-amt{font-size:17px}
  .page-head h1{font-size:28px}
}

/* --- 6. rows that pair a label with a figure ---------------------------- */
.split-row{gap:8px 10px}
.split-row .who{flex:1 1 140px}
.split-row .out{
  flex:0 1 auto;min-width:0;max-width:100%;
  display:inline-flex;flex-wrap:wrap;justify-content:flex-end;gap:0 5px;
  overflow-wrap:anywhere;
}
.th-kv{align-items:flex-start}
.th-kv b{white-space:normal;overflow-wrap:anywhere}

/* --- 7. the stat sub-line must not push the card wider ------------------ */
.stat .s{overflow-wrap:anywhere}

/* --- 8. anything that scrolls sideways does it on purpose --------------- */
.chips,.filterbar,.table-scroll,.wheel{max-width:100%}
pre,code:not(.code-box code){overflow-x:auto;max-width:100%}
.code-box code{overflow-wrap:anywhere;white-space:normal}

/* --- 9. very small phones (320px) ------------------------------------- */
@media (max-width:340px){
  .main{padding-inline:11px}
  .card,.txn,.stat{padding:11px}
  .f-box,.f-text,.date-row{padding:12px}
  .btn{padding:11px 14px;font-size:13.5px}
  .pick-chip span{padding:10px 12px;font-size:13.5px}
  .code-box code{letter-spacing:3px}
  .mini-stats{gap:7px}
  .mini-stat{padding:10px 8px}
}

/* ============================================================
   Export document polish
   Rounded, clipped table frames so no square corner pokes through
   the rounded border, on screen and on paper alike.
   ============================================================ */
.table-wrap{
  overflow:hidden;                     /* clip the square cells to the radius */
  border-radius:var(--radius-md);
  border:var(--bw) solid var(--border);
}
.table-wrap>.table-scroll{border-radius:inherit}
table.tbl{border-collapse:separate;border-spacing:0}
/* the head/foot corners must follow the wrapper's radius */
table.tbl thead tr:first-child th:first-child{border-start-start-radius:calc(var(--radius-md) - 2px)}
table.tbl thead tr:first-child th:last-child{border-start-end-radius:calc(var(--radius-md) - 2px)}
table.tbl tbody tr:last-child td:first-child{border-end-start-radius:calc(var(--radius-md) - 2px)}
table.tbl tbody tr:last-child td:last-child{border-end-end-radius:calc(var(--radius-md) - 2px)}
/* a separate-borders table needs the row rule drawn per cell */
table.tbl th,table.tbl td{border-bottom:var(--bw) solid var(--border-soft)}
table.tbl tbody tr:last-child td{border-bottom:0}
table.tbl tfoot td{border-top:var(--bw-strong) solid var(--border);border-bottom:0}

/* the four headline cards on the export document */
.doc-cards{grid-template-columns:repeat(2,minmax(0,1fr));margin-block:4px 8px}
.doc-cards .stat{min-height:78px}
@media (min-width:700px){.doc-cards{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media print{
  .doc-cards{grid-template-columns:repeat(4,1fr) !important;gap:3mm}
  .doc-cards .stat{
    min-height:0;padding:2.5mm 3mm;
    border:1pt solid var(--border) !important;border-radius:2.5mm;
  }
  .doc-cards .stat .v{font-size:12pt !important}
  .doc-cards .stat .k{font-size:7.5pt !important;margin-top:1mm}
  .doc-cards .stat .wm{display:none}
  .pill{border-width:.5pt}
}
