/* ─────────────────────────────────────────────────────────────────────────
   app.css — SAJ ONE - Tally, mobile-first.

   WHY THIS REPLACED THE TABLE LAYOUT
     The first build was a desktop web app: a top nav bar and wide tables. It
     is the wrong shape for this product. The people who use it are salespeople
     standing in a customer's shop holding a phone, and the question they need
     answered is "how much does this party owe" — one number, immediately.
     A 9-column table answers that badly.

     So the structure follows the pattern the market already understands:
       * a coloured app bar with the company switcher in it
       * ONE big number at the top of every report
       * a date-range control that drives everything
       * a Group By pivot instead of more columns
       * bottom tabs, because thumbs reach the bottom of a phone

   BRANDING IS OURS, LAYOUT IS THE CATEGORY CONVENTION.
     Navy + gold, IBM Plex — the same as every other SAJ product. Copying a
     competitor's blue would make our own app look like a clone of theirs in
     the one place customers actually compare: the screenshot on the website.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --navy:      #0f2547;
  --navy-2:    #16325e;
  --navy-3:    #1c3d70;
  --navy-ink:  #12203a;
  --gold:      #c9a227;
  --gold-dk:   #b08f1e;
  --ink:       #1a2332;
  --muted:     #6b7280;
  --muted-2:   #9aa3b2;
  --line:      #e3e8ef;
  --line-2:    #eef2f7;
  --bg:        #f4f6fa;
  --card:      #ffffff;
  --red:       #c0392b;
  --red-bg:    #fdecea;
  --green:     #1e7f4f;
  --green-bg:  #e8f6ee;
  --amber:     #92400e;
  --amber-bg:  #fef4e5;
  --radius:    12px;
  --font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Safe areas, so the tab bar clears the iPhone home indicator and the
     app bar clears a notch. Zero on everything else. */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);

  --appbar-h: 56px;
  --tabbar-h: 58px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--navy-2); }

/* ── App bar ──────────────────────────────────────────────────────────── */
.appbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--navy);
  color: #fff;
  padding-top: var(--sat);
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.appbar-row {
  height: var(--appbar-h);
  display: flex; align-items: center; gap: 4px;
  padding: 0 6px;
}
.ab-btn {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  background: none; border: 0; color: #fff; cursor: pointer;
  border-radius: 50%; padding: 0;
}
.ab-btn:active { background: rgba(255,255,255,.14); }
.ab-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ab-title {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 6px;
  font-size: 17px; font-weight: 600;
  background: none; border: 0; color: #fff; cursor: pointer;
  padding: 6px 4px; text-align: left;
}
.ab-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ab-title .caret { flex: 0 0 auto; opacity: .8; font-size: 11px; }
.ab-sub { font-size: 12.5px; opacity: .78; font-weight: 400; margin-top: -2px; }

/* The big-number block that sits inside the app bar on a report screen. */
.ab-hero { padding: 2px 18px 16px; }
.ab-hero .amt {
  font-size: 30px; font-weight: 600; letter-spacing: -.5px;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.ab-hero .amt.sm { font-size: 24px; }
.ab-hero .meta { font-size: 12.5px; opacity: .8; margin-top: 3px; }
.ab-hero .row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

/* A select rendered on the navy bar. */
.ab-select {
  appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,.12);
  border: 0; border-radius: 8px;
  color: #fff; font-family: var(--font); font-size: 14px; font-weight: 500;
  padding: 8px 30px 8px 12px; max-width: 100%;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fff'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; background-size: 18px;
}
.ab-select option { color: var(--ink); background: #fff; }
.ab-tools { display: flex; gap: 8px; align-items: center; padding: 0 14px 14px; flex-wrap: wrap; }
.ab-tools .lbl { font-size: 12.5px; opacity: .8; }

/* ── Sync strip ───────────────────────────────────────────────────────── */
.syncbar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}
.syncbar b { color: var(--ink); font-weight: 600; }
.syncbar .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; background: var(--green); }
.syncbar .dot.stale { background: var(--gold); }
.syncbar .dot.off { background: var(--red); }

/* ── Page + tab bar ───────────────────────────────────────────────────── */
.page { padding: 14px 14px calc(var(--tabbar-h) + var(--sab) + 20px); max-width: 1100px; margin: 0 auto; }
.page.flush { padding-left: 0; padding-right: 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: var(--sab);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px 7px; text-decoration: none;
  color: var(--muted); font-size: 11.5px; font-weight: 500;
}
.tabbar a.on { color: var(--navy); font-weight: 600; }
.tabbar a.on svg { stroke: var(--navy); }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: var(--muted-2); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ── Drawer ───────────────────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15,32,58,.45);
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 61;
  width: 290px; max-width: 84vw; background: #fff;
  transform: translateX(-100%); transition: transform .2s ease;
  display: flex; flex-direction: column;
  box-shadow: 4px 0 24px rgba(10,26,52,.18);
}
.drawer.open { transform: none; }
.drawer-head {
  background: var(--navy); color: #fff;
  padding: calc(var(--sat) + 20px) 18px 18px;
}
.drawer-head .who { font-size: 16px; font-weight: 600; }
.drawer-head .sub { font-size: 12.5px; opacity: .78; margin-top: 3px; word-break: break-word; }
.drawer-head .badge {
  display: inline-block; margin-top: 10px; padding: 3px 9px;
  border-radius: 20px; background: rgba(201,162,39,.22); color: var(--gold);
  font-size: 11px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.drawer-body a, .drawer-body button {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 12px 18px; border: 0; background: none;
  font-family: var(--font); font-size: 14.5px; color: var(--ink);
  text-decoration: none; text-align: left; cursor: pointer;
}
.drawer-body a:active, .drawer-body button:active { background: var(--line-2); }
.drawer-body a.on { color: var(--navy); font-weight: 600; background: #f2f6fc; }
.drawer-body svg { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drawer-sec {
  padding: 14px 18px 6px; font-size: 11px; font-weight: 600;
  letter-spacing: .6px; text-transform: uppercase; color: var(--muted-2);
}
.drawer-foot { border-top: 1px solid var(--line); padding-bottom: var(--sab); }

/* ── Summary rows (the dashboard list) ────────────────────────────────── */
.sumlist { background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.sumrow {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 16px; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--line-2);
}
.sumrow:last-child { border-bottom: 0; }
.sumrow:active { background: var(--line-2); }
.sumrow .ic {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px;
  display: grid; place-items: center; background: #eef3fb;
}
.sumrow .ic svg { width: 21px; height: 21px; fill: none; stroke: var(--navy-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sumrow .ic.gold { background: #fbf4de; } .sumrow .ic.gold svg { stroke: var(--gold-dk); }
.sumrow .ic.red  { background: var(--red-bg); }  .sumrow .ic.red svg  { stroke: var(--red); }
.sumrow .ic.green{ background: var(--green-bg); }.sumrow .ic.green svg{ stroke: var(--green); }
.sumrow .txt { flex: 1; min-width: 0; }
.sumrow .val { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.sumrow .lbl { font-size: 13px; color: var(--muted); margin-top: 1px; }
.sumrow .chev { flex: 0 0 auto; color: var(--muted-2); }

/* ── Quick tiles ──────────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 7px;
}
.tile:active { background: var(--line-2); }
.tile svg { width: 22px; height: 22px; fill: none; stroke: var(--navy-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile .t { font-size: 14px; font-weight: 600; }
.tile .s { font-size: 12px; color: var(--muted); }

/* ── Two-up summary strip under a report header ───────────────────────── */
.splitbar { display: flex; background: #eef3fb; border-bottom: 1px solid var(--line); }
.splitbar > div { flex: 1; padding: 13px 12px; text-align: center; }
.splitbar > div + div { border-left: 1px solid #dbe4f1; }
.splitbar .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.splitbar .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.splitbar .v.neg { color: var(--red); }

/* ── List rows (the pivot output) ─────────────────────────────────────── */
.list { background: #fff; }
.lrow {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-2);
  text-decoration: none; color: inherit; width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0;
  font-family: var(--font); text-align: left; cursor: pointer;
}
.lrow:active { background: var(--line-2); }
.lrow .main { flex: 1; min-width: 0; }
.lrow .name { font-size: 14.5px; font-weight: 500; overflow-wrap: anywhere; }
.lrow .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.lrow .amt { flex: 0 0 auto; font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.lrow .amt .sub { font-weight: 400; }
.lrow .amt.red { color: var(--red); }
.lrow .amt.green { color: var(--green); }

/* Group tree (Outstanding → Group tab) */
.gnode > .lrow { background: #fafbfd; font-weight: 600; }
.gnode .kids { display: none; }
.gnode.open .kids { display: block; }
.gnode .twist { flex: 0 0 18px; color: var(--muted); transition: transform .15s; }
.gnode.open .twist { transform: rotate(90deg); }
.gnode .kids .lrow { padding-left: 40px; }

/* ── Segmented tabs ───────────────────────────────────────────────────── */
.segs { display: flex; background: #fff; border-bottom: 1px solid var(--line); }
.segs button {
  flex: 1; padding: 13px 8px; border: 0; background: none;
  font-family: var(--font); font-size: 14px; font-weight: 500; color: var(--muted);
  border-bottom: 2.5px solid transparent; cursor: pointer;
}
.segs button.on { color: var(--navy); font-weight: 600; border-bottom-color: var(--gold); }

/* ── Chart ────────────────────────────────────────────────────────────── */
.chart { background: #fff; padding: 14px 8px 6px; border-bottom: 1px solid var(--line); }
.chart svg { display: block; width: 100%; height: auto; }
.chart .cap { text-align: center; font-size: 11.5px; color: var(--muted); padding: 4px 0 6px; }
.donut-legend { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; padding: 4px 10px 10px; font-size: 12px; color: var(--muted); }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* ── Cards / panels ───────────────────────────────────────────────────── */
.card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 12px; overflow: hidden;
}
.card-h {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600; letter-spacing: .5px;
  text-transform: uppercase; color: var(--muted); background: #fafbfd;
}
.card-b { padding: 14px 16px; }
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--line-2); }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 500; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv .v.big { font-size: 16px; font-weight: 600; }

/* ── Stat strip ───────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--navy); border-radius: 10px; padding: 12px 13px; }
.stat.red { border-left-color: var(--red); } .stat.red .v { color: var(--red); }
.stat.green { border-left-color: var(--green); } .stat.green .v { color: var(--green); }
.stat.gold { border-left-color: var(--gold); }
.stat .l { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 18px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-size: 14.5px; font-weight: 600;
  padding: 12px 18px; border-radius: 10px; border: 0; cursor: pointer;
  text-decoration: none; line-height: 1;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: var(--navy-ink); }
.btn-primary:active:not(:disabled) { background: var(--gold-dk); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
.btn-ghost:active:not(:disabled) { border-color: var(--navy-2); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 8px 13px; font-size: 13px; }
.btn-block { width: 100%; }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Floating action button */
.fab {
  position: fixed; right: 16px; z-index: 35;
  bottom: calc(var(--tabbar-h) + var(--sab) + 16px);
  display: inline-flex; align-items: center; gap: 9px;
  padding: 14px 20px; border-radius: 30px; border: 0;
  background: var(--gold); color: var(--navy-ink);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(201,162,39,.42); cursor: pointer;
  text-decoration: none;
}

/* ── Sheets (bottom sheet + modal) ────────────────────────────────────── */
.sheet-back {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(15,32,58,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: #fff; width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; max-height: 84vh; overflow-y: auto;
  padding-bottom: var(--sab);
  animation: sheetUp .2s ease;
}
@keyframes sheetUp { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 18px; border-bottom: 1px solid var(--line);
  font-size: 17px; font-weight: 600; position: sticky; top: 0; background: #fff;
}
.sheet-h button { background: none; border: 0; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.sheet-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 15px 18px; border: 0; background: none;
  font-family: var(--font); font-size: 15px; color: var(--ink);
  text-align: left; cursor: pointer; border-bottom: 1px solid var(--line-2);
}
/* A sheet row may be a link (share sheet -> printable invoice). width:100%
   plus padding overflows an anchor without border-box. */
a.sheet-item { text-decoration: none; box-sizing: border-box; }
.sheet-item:active { background: var(--line-2); }
.sheet-item.on { color: var(--navy); font-weight: 600; }
.sheet-item .tick { color: var(--gold-dk); font-weight: 700; }
.sheet-body { padding: 16px 18px; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=date], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 12px 13px; font-family: var(--font); font-size: 15px;
  color: var(--ink); background: #fff; border: 1.5px solid var(--line);
  border-radius: 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--navy-2); }
input:disabled, select:disabled { background: #f7f8fa; color: var(--muted); }

/* Search bar that lives directly under the app bar. */
.searchbar { padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.searchbar input { padding: 10px 13px; font-size: 14px; }

/* An always-visible filter bar directly under the app bar -- the ledger-group
   dropdown on the party lists, and the stock-group one on Inventory. It reads
   as part of the header, so it carries the navy. */
/* Rows of a rolled-up group tree. The indent lives inline (it is data, not
   style: it is the depth the server returned), so only the caret is here. */
.tcaret { display: inline-block; width: 12px; color: var(--muted); font-size: 11px; }
.treerow { cursor: default; }
.treerow[data-kids]:not([data-kids="0"]) { cursor: pointer; }

.pickerbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 12px 16px; border: 0; cursor: pointer;
  background: var(--navy); color: #fff;
  font-family: var(--font); font-size: 15px; font-weight: 500; text-align: left;
}
.pickerbar:active { background: var(--navy-2); }
.pickerbar .caret { opacity: .75; font-size: 12px; }

/* ── Messages ─────────────────────────────────────────────────────────── */
.msg { padding: 12px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.5; margin-bottom: 12px; display: none; }
.msg.show { display: block; }
.msg.info { background: #eef3fb; color: var(--navy); border: 1px solid #cfe0f5; }
.msg.warn { background: var(--amber-bg); color: var(--amber); border: 1px solid #f6dcae; }
.msg.error { background: var(--red-bg); color: var(--red); border: 1px solid #f5c6c2; }
.msg.success { background: var(--green-bg); color: var(--green); border: 1px solid #bfe3ce; }
.msg code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.empty { padding: 44px 24px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.55; }
.empty svg { width: 56px; height: 56px; opacity: .3; margin-bottom: 12px; fill: none; stroke: var(--muted); stroke-width: 1.4; }

/* ── Chips + badges ───────────────────────────────────────────────────── */
.chip {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.gold { background: #fbf4de; color: var(--gold-dk); }
.chip.grey { background: #eef1f6; color: var(--muted); }

/* ── Pager ────────────────────────────────────────────────────────────── */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; font-size: 13px; color: var(--muted); background: #fff; }

/* ── Toast ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; z-index: 90;
  bottom: calc(var(--tabbar-h) + var(--sab) + 22px);
  transform: translate(-50%, 14px);
  background: var(--navy); color: #fff;
  padding: 12px 18px; border-radius: 10px; font-size: 13.5px;
  max-width: calc(100vw - 40px); text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); }

/* ── Spinner ──────────────────────────────────────────────────────────── */
.spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: sp .7s linear infinite; display: inline-block;
}
.spin.dark { border-color: var(--line); border-top-color: var(--navy); }
@keyframes sp { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; }

/* Skeleton rows, so a slow query looks like loading rather than emptiness. */
.skel { padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.skel i {
  display: block; height: 11px; border-radius: 6px;
  background: linear-gradient(90deg, #eef1f6 25%, #e3e8ef 37%, #eef1f6 63%);
  background-size: 400% 100%; animation: sh 1.3s ease infinite;
}
.skel i + i { margin-top: 8px; width: 55%; }
@keyframes sh { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── Auth screens (no tab bar) ────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px 20px;
  background: radial-gradient(1100px 520px at 50% -160px, var(--navy-3) 0%, var(--navy) 55%, #0a1a34 100%);
}
.auth-card {
  background: #fff; border-radius: 16px; padding: 26px 22px;
  width: 100%; max-width: 420px; box-shadow: 0 20px 50px rgba(6,18,38,.3);
}
.auth-brand { text-align: center; margin-bottom: 22px; color: #fff; }
.auth-brand .n { font-size: 26px; font-weight: 600; letter-spacing: -.4px; }
.auth-brand .n span { color: var(--gold); }
.auth-brand .t { font-size: 13px; opacity: .8; margin-top: 3px; }
.auth-card h1 { margin: 0 0 6px; font-size: 21px; color: var(--navy); font-weight: 600; }
.auth-card .lede { margin: 0 0 20px; font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.auth-links { margin-top: 18px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth-links a { color: var(--navy-2); font-weight: 600; text-decoration: none; }

/* ── Wide screens ─────────────────────────────────────────────────────── */
/* The layout stays mobile-shaped and simply stops growing. A phone-shaped
   report is not wrong on a laptop; a laptop-shaped one is unusable on a
   phone, and the phone is where this product is actually used. */
@media (min-width: 860px) {
  .tabbar { position: sticky; bottom: 0; max-width: 1100px; margin: 0 auto; border-radius: 0; }
  .list, .chart, .splitbar, .segs, .searchbar { border-radius: 0; }
  .page { padding-bottom: 32px; }
  .fab { right: calc(50vw - 530px); }
}
@media (min-width: 1130px) { .fab { right: calc(50vw - 540px); } }

@media print {
  .appbar, .tabbar, .fab, .drawer, .scrim, .searchbar, .toast { display: none !important; }
  .page { padding: 0; }
}

/* ── Financial statements ─────────────────────────────────────────────────
   A statement is not a list of records: it is a few sections with indented
   lines and a rule above each subtotal. Rendering one through the generic
   list engine produced something that read like a data dump and buried the
   three numbers anybody actually looks at. */
.stmt-cols { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 820px) { .stmt-cols { grid-template-columns: 1fr 1fr; align-items: start; } }

.stmt { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stmt h2 {
  margin: 0; padding: 13px 16px; font-size: 12px; font-weight: 600;
  letter-spacing: .5px; text-transform: uppercase; color: var(--muted);
  background: #fafbfd; border-bottom: 1px solid var(--line);
}
.stmt-body { padding: 6px 0; }
.stmt-row { display: flex; justify-content: space-between; gap: 14px; padding: 8px 16px; font-size: 14px; }
.stmt-row .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stmt-row.sub { color: var(--muted); padding-left: 30px; font-size: 13px; }
.stmt-row.head {
  font-weight: 600; color: var(--navy); padding-top: 13px;
  text-transform: uppercase; font-size: 11px; letter-spacing: .5px;
}
.stmt-row.total { font-weight: 600; border-top: 1.5px solid var(--line); margin-top: 4px; padding-top: 10px; }
.stmt-row.grand {
  font-weight: 600; background: #f7f9fc; border-top: 2px solid var(--navy);
  color: var(--navy); font-size: 15px; padding: 13px 16px;
}
.stmt-row.neg .amt { color: var(--red); }
.stmt-row.pos .amt { color: var(--green); }
.stmt-empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* Reminder picker rows */
td.pick, .pickbox { width: 30px; }
.lrow.dim { opacity: .55; }
.rem-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 14px; background: #fff; border-bottom: 1px solid var(--line);
}
.rem-bar .grow { flex: 1; font-size: 13px; color: var(--muted); }
.rem-bar .grow b { color: var(--ink); }

/* ── Auth-page legacy classes ─────────────────────────────────────────────
   The sign-in flow (login, signup, forgot, reset, accept-invite) predates the
   mobile rebuild and uses these names. Ported here rather than rewritten:
   those five screens already work, are already tested, and a rewrite of a
   working auth flow buys nothing but risk. */
.auth-head { padding: 24px 24px 18px; border-bottom: 1px solid var(--line); }
.auth-head h1 { font-size: 15px; font-weight: 500; color: var(--muted); margin: 0; }
.auth-body { padding: 22px 24px 26px; }
.brand { font-size: 21px; font-weight: 600; letter-spacing: .4px; color: var(--navy); margin: 0 0 3px; }
.brand span { color: var(--gold); }

.auth-card .field label,
label { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 6px; }

.pw-wrap { position: relative; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; padding: 6px 8px; font-size: 12px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-radius: 6px;
}
.pw-toggle:hover { color: var(--navy); background: #f2f4f8; }

.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.45; }

.meter { display: flex; gap: 4px; margin-top: 8px; }
.meter i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); transition: background .2s; }
.meter.s1 i:nth-child(1) { background: var(--red); }
.meter.s2 i:nth-child(-n+2) { background: var(--gold); }
.meter.s3 i:nth-child(-n+3) { background: var(--gold); }
.meter.s4 i { background: var(--green); }
.meter-label { font-size: 11.5px; color: var(--muted); margin-top: 5px; }

.link-btn {
  background: none; border: 1px solid rgba(255,255,255,.28); color: #fff;
  padding: 6px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; font-family: var(--font);
}
.link-btn:hover { background: rgba(255,255,255,.1); }

/* The auth card's own button is full-width; elsewhere .btn is inline. */
.auth-body .btn, .auth-card .btn { width: 100%; }

/* ── Icon sizing floor ────────────────────────────────────────────────────
   App.icon() now emits width/height attributes, so an icon is sized even with
   no CSS at all. These rules exist for the containers that were relying on a
   rule that did not exist: a bare <svg> in .lrow / .sheet-item / .ic had
   nothing constraining it and expanded to fill its parent — which is what
   turned the More page into one enormous black circle.
   Every specific rule above (.tabbar, .btn, .chart, .empty) is more specific
   and still wins. */
.lrow > svg,
.sheet-item > svg,
.drawer-foot svg { width: 20px; height: 20px; flex: 0 0 20px; stroke: var(--muted); }

/* The round/square icon chip used on dashboards and list rows. Was written
   inline in three places; a real class means one definition. */
.ic {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px;
  display: grid; place-items: center; background: #eef3fb;
}
.ic svg { width: 20px; height: 20px; stroke: var(--navy-2); }
.ic.round { border-radius: 50%; }
.ic.lg { width: 48px; height: 48px; flex: 0 0 48px; }
.ic.lg svg { width: 24px; height: 24px; }
.ic.gold { background: #fbf4de; } .ic.gold svg { stroke: var(--gold-dk); }
.ic.red { background: var(--red-bg); } .ic.red svg { stroke: var(--red); }
.ic.green { background: var(--green-bg); } .ic.green svg { stroke: var(--green); }

/* Charts are the one place an svg SHOULD fill its box. Restated after the
   floor above so the intent is visible in one place rather than relying on
   source order. */
.chart svg { width: 100%; height: auto; flex: none; }
