  /* Layout: sticky header → KPI tiles → tabbed workspace (Payments / Vendors / Aging).
     Palette: warm paper / deep ink neutrals, teal accent, semantic status hues. */
  :root {
    --paper: #f6f4ef;
    --surface: #ffffff;
    --surface-2: #faf8f3;
    --line: #e4e0d6;
    --line-strong: #d4cfc1;
    --ink: #22201b;
    --ink-soft: #6b665b;
    --ink-faint: #969083;
    --accent: #0d7d74;
    --accent-soft: #e2f1ef;
    --accent-ink: #0a5f58;
    --paid: #1f8f54;
    --paid-soft: #e4f3e9;
    --pending: #b8791a;
    --pending-soft: #faeedb;
    --partial: #2b6cb0;
    --partial-soft: #e5eefa;
    --overdue: #c0392f;
    --overdue-soft: #fae9e7;
    --shadow: 0 1px 2px rgba(34,32,27,.05), 0 8px 24px -16px rgba(34,32,27,.25);
    --radius: 12px;
    --radius-sm: 8px;
    --ff-head: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
    --ff-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --paper: #16150f; --surface: #1f1e17; --surface-2: #26241c;
      --line: #322f24; --line-strong: #413d2f;
      --ink: #efeadb; --ink-soft: #a9a391; --ink-faint: #797462;
      --accent: #2fb3a6; --accent-soft: #113430; --accent-ink: #5fd0c3;
      --paid: #43c07a; --paid-soft: #112c1d;
      --pending: #e0a63f; --pending-soft: #2e2512;
      --partial: #5b9be0; --partial-soft: #10233c;
      --overdue: #f0756a; --overdue-soft: #331713;
      --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -18px rgba(0,0,0,.8);
      color-scheme: dark;
    }
  }
  :root[data-theme="dark"] {
    --paper: #16150f; --surface: #1f1e17; --surface-2: #26241c;
    --line: #322f24; --line-strong: #413d2f;
    --ink: #efeadb; --ink-soft: #a9a391; --ink-faint: #797462;
    --accent: #2fb3a6; --accent-soft: #113430; --accent-ink: #5fd0c3;
    --paid: #43c07a; --paid-soft: #112c1d;
    --pending: #e0a63f; --pending-soft: #2e2512;
    --partial: #5b9be0; --partial-soft: #10233c;
    --overdue: #f0756a; --overdue-soft: #331713;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -18px rgba(0,0,0,.8);
    color-scheme: dark;
  }

  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  body { background: var(--paper); color: var(--ink); font-family: var(--ff-body); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; margin: 0; }
  h1, h2, h3 { font-family: var(--ff-head); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
  .num { font-variant-numeric: tabular-nums; }
  button { font-family: inherit; cursor: pointer; }
  input, select, textarea { font-family: inherit; font-size: 14px; }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }

  header.app { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.3) blur(8px); border-bottom: 1px solid var(--line); }
  .header-in { max-width: 100%; margin: 0 auto; padding-block: 13px; padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .brand { display: flex; align-items: center; gap: 11px; margin-right: auto; }
  .mark { width: 34px; height: 34px; border-radius: 9px; flex: none; background: linear-gradient(145deg, var(--accent), var(--accent-ink)); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow); }
  .mark svg { width: 19px; height: 19px; }
  .brand h1 { font-size: 18px; line-height: 1.1; }
  .brand .sub { font-size: 11.5px; color: var(--ink-faint); letter-spacing: .04em; text-transform: uppercase; }
  .header-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

  select.cur, .ghost-btn { appearance: none; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 11px; font-size: 13px; font-weight: 500; }
  select.cur { padding-right: 26px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23969083' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 8px center; }
  .ghost-btn { display: inline-flex; align-items: center; gap: 6px; }
  .ghost-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
  .ghost-btn:disabled { opacity: .5; cursor: not-allowed; }
  .primary-btn { background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 8px 14px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; box-shadow: var(--shadow); }
  .primary-btn:hover:not(:disabled) { background: var(--accent-ink); }
  .primary-btn:disabled { opacity: .55; cursor: not-allowed; }
  .primary-btn svg, .ghost-btn svg { width: 15px; height: 15px; flex: none; }

  main { max-width: 100%; margin: 0 auto; padding-block: 20px 56px; padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); }

  .banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); color: var(--accent-ink); border-radius: var(--radius); padding: 11px 15px; margin-bottom: 18px; font-size: 13px; }
  .banner strong { font-weight: 600; }
  .banner .spacer { margin-left: auto; }
  .banner button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 7px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; }
  .banner button:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }

  .kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 24px; }
  .tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px 16px; position: relative; overflow: hidden; }
  .tile .cap { font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
  .tile .val { font-family: var(--ff-head); font-size: 24px; font-weight: 600; margin-top: 9px; letter-spacing: -0.02em; }
  .tile .meta { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
  .tile .edge { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
  .tile.e-out .edge { background: var(--accent); }
  .tile.e-over .edge { background: var(--overdue); } .tile.e-over .val { color: var(--overdue); }
  .tile.e-appr .edge { background: var(--pending); } .tile.e-appr .val { color: var(--pending); }
  .tile.e-paid .edge { background: var(--paid); }

  .tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
  .tab { background: none; border: none; padding: 10px 4px; margin-right: 18px; font-size: 14px; font-weight: 600; color: var(--ink-soft); border-bottom: 2px solid transparent; margin-bottom: -1px; }
  .tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
  .tab .count { font-size: 12px; color: var(--ink-faint); font-weight: 500; margin-left: 4px; }

  .toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 15px; }
  .pills { display: flex; gap: 6px; flex-wrap: wrap; }
  .pill { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink-soft); border-radius: 999px; padding: 6px 13px; font-size: 12.5px; font-weight: 600; }
  .pill[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
  .pill .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
  .search { position: relative; margin-left: auto; }
  .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--ink-faint); }
  .search input { background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 8px 12px 8px 32px; width: 210px; max-width: 48vw; }
  .search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

  .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
  .tbl-scroll { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; min-width: 720px; }
  table.wide { min-width: 1060px; }
  .notecell { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); font-size: 12.5px; }
  .notecell.utrcell { max-width: 130px; }
  th.utrcol, td.utrcol { max-width: 130px; }
  .bulkbar { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); color: var(--accent-ink); border-radius: var(--radius); padding: 9px 14px; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
  .bulkbar .spacer { margin-left: auto; }
  .bulkbar .primary-btn { padding: 6px 12px; }
  .bulkbar .ghost-btn { padding: 6px 12px; background: transparent; border-color: currentColor; color: inherit; }
  th.selcol, td.selcol { width: 34px; text-align: center; padding-left: 14px; padding-right: 4px; }
  .rowchk, #selAll { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
  .pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 11px 2px 2px; font-size: 12.5px; color: var(--ink-soft); }
  .pager-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
  .pager-size select { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 5px 7px; margin-left: 4px; }
  .pager-nav { display: flex; align-items: center; gap: 8px; }
  .pgbtn { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 5px 11px; font-weight: 600; }
  .pgbtn:disabled { opacity: .45; cursor: not-allowed; }
  .pgbtn:not(:disabled):hover { border-color: var(--accent); color: var(--accent-ink); }
  .pgnum { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
  .vlink { cursor: pointer; }
  .vlink:hover { color: var(--accent-ink); text-decoration: underline; }
  .ledger-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
  .ls-tile { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
  .ls-tile .l { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); font-weight: 600; }
  .ls-tile .n { font-family: var(--ff-head); font-weight: 600; font-size: 17px; margin-top: 3px; font-variant-numeric: tabular-nums; }
  .ls-tile .n.out { color: var(--overdue); }
  table.ledger { min-width: 520px; }
  table.ledger tbody td { padding: 10px 14px; }
  table.ledger tr.tot td { font-weight: 700; border-top: 2px solid var(--line-strong); background: var(--surface-2); }
  .ledger-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12.5px; color: var(--ink-soft); }
  .ledger-tools label { display: inline-flex; align-items: center; gap: 5px; }
  .ledger-tools input[type=date] { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 5px 8px; }
  .ledger-tools .spacer { margin-left: auto; }
  .ledger-tools button { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 6px 11px; font-weight: 600; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
  .ledger-tools button:hover { border-color: var(--accent); color: var(--accent-ink); }
  .pr-sub { font-size: 11.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; margin: 4px 0 6px; }
  .comprow { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .comprow .ci-name { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 8px 10px; }
  .comprow .amt-wrap { width: 140px; flex: none; }
  .comprow .amt-wrap input { background: var(--surface-2); }
  .splitbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
  .splitbar .amt-wrap { flex: 1; }
  .splitbar input { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 9px 11px 9px 28px; width: 100%; font-variant-numeric: tabular-nums; }
  .splitbar input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
  .splitbar button { white-space: nowrap; }
  .splithint { font-size: 11.5px; color: var(--ink-faint); margin: 0 0 12px; }
  .linerow { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
  .linerow .li-item { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 8px 9px; }
  .linerow .li-qty { width: 60px; flex: none; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 8px 7px; text-align: right; }
  .linerow .li-rate-wrap { width: 100px; flex: none; }
  .linerow .li-rate-wrap input { background: var(--surface-2); }
  .linerow .li-amt { width: 88px; flex: none; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
  input.auto-amt { opacity: .7; }
  .linerow .li-tax { width: 56px; flex: none; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 8px 6px; text-align: right; }
  .linerow.wtax .li-rate-wrap { width: 88px; }
  .linerow.wtax .li-amt { width: 78px; }
  @media (max-width: 560px) { .linerow .li-qty { width: 44px; } .linerow .li-rate-wrap { width: 72px; } .linerow.wtax .li-rate-wrap { width: 64px; } .linerow .li-amt { width: 64px; } .linerow .li-tax { width: 46px; } }
  .pr-tot { display: flex; gap: 18px; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
  .pr-tot b { color: var(--ink); font-family: var(--ff-head); }
  .prseg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
  .prseg button { background: var(--surface-2); border: none; padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
  .prseg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
  @media (max-width: 560px) { .ledger-sum { grid-template-columns: repeat(2, 1fr); } }
  thead th { text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
  thead th.r, td.r { text-align: right; }
  thead th.c, td.c { text-align: center; }
  thead th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
  thead th.sortable:hover { color: var(--ink); }
  .caret { font-size: 9px; margin-left: 4px; opacity: .45; }
  .caret.on { opacity: 1; color: var(--accent-ink); }
  tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr:hover { background: var(--surface-2); }
  .v-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; white-space: nowrap; min-width: 0; }
  .v-name .avatar.sm { flex: none; }
  .v-name .vn { min-width: 0; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .v-sub { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }
  .amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
  .bal { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
  .inv { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
  .due { white-space: nowrap; font-variant-numeric: tabular-nums; }
  .due.late { color: var(--overdue); font-weight: 600; }

  .badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
  .badge .dot { width: 6px; height: 6px; border-radius: 50%; }
  .b-paid { background: var(--paid-soft); color: var(--paid); } .b-paid .dot { background: var(--paid); }
  .b-pending { background: var(--pending-soft); color: var(--pending); } .b-pending .dot { background: var(--pending); }
  .b-partial { background: var(--partial-soft); color: var(--partial); } .b-partial .dot { background: var(--partial); }
  .b-overdue { background: var(--overdue-soft); color: var(--overdue); } .b-overdue .dot { background: var(--overdue); }
  .b-appr { background: var(--pending-soft); color: var(--pending); border: 1px dashed color-mix(in srgb, var(--pending) 45%, transparent); } .b-appr .dot { background: var(--pending); }
  .tag-sample { background: var(--surface-2); color: var(--ink-faint); border: 1px solid var(--line-strong); font-size: 10px; padding: 1px 6px; border-radius: 5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
  .tag-draft { background: var(--partial-soft); color: var(--partial); border: 1px solid color-mix(in srgb, var(--partial) 40%, transparent); font-size: 10px; padding: 1px 6px; border-radius: 5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
  .pill-n { font-size: 11px; font-weight: 700; }

  .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
  .icon-btn { background: none; border: 1px solid transparent; border-radius: 7px; padding: 5px; color: var(--ink-faint); display: grid; place-items: center; }
  .icon-btn:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }
  .icon-btn.pay:hover { color: var(--paid); border-color: var(--paid); }
  .icon-btn.appr:hover { color: var(--pending); border-color: var(--pending); }
  .icon-btn.del:hover { color: var(--overdue); border-color: var(--overdue); }
  .icon-btn svg { width: 15px; height: 15px; }

  .vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 13px; }
  .vcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
  .vcard .top { display: flex; align-items: flex-start; gap: 10px; }
  .avatar { width: 36px; height: 36px; border-radius: 9px; flex: none; display: grid; place-items: center; font-family: var(--ff-head); font-weight: 600; font-size: 15px; color: #fff; }
  .avatar.sm { width: 28px; height: 28px; border-radius: 7px; font-size: 12px; }
  td .contact { font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; word-break: break-word; }
  .vcard h3 { font-size: 15px; }
  .vcard .vmeta { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; word-break: break-word; }
  .vcard .vstats { display: flex; gap: 16px; margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--line); }
  .vcard .vstat .l { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); font-weight: 600; }
  .vcard .vstat .n { font-family: var(--ff-head); font-weight: 600; font-size: 16px; margin-top: 2px; font-variant-numeric: tabular-nums; }
  .vcard .vstat .n.out { color: var(--overdue); }
  .vcard .vactions { display: flex; gap: 4px; margin-top: 12px; }

  .empty { text-align: center; padding: 52px 24px; color: var(--ink-soft); }
  .empty .ic { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--ink-faint); opacity: .7; }
  .empty h3 { font-size: 16px; color: var(--ink); margin-bottom: 6px; }
  .empty p { font-size: 13.5px; max-width: 340px; margin: 0 auto 16px; }
  .empty .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
  .spin { width: 22px; height: 22px; border: 2.5px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite; margin: 0 auto 14px; }
  @keyframes sp { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

  /* Aging */
  .age-wrap { overflow-x: auto; }
  table.age { min-width: 640px; }
  table.age td.r, table.age th.r { font-variant-numeric: tabular-nums; }
  table.age tbody tr.tot td { font-weight: 700; border-top: 2px solid var(--line-strong); background: var(--surface-2); }
  .age-cell.hot { color: var(--overdue); font-weight: 600; }
  .age-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-soft); margin-bottom: 14px; }

  /* Modal */
  .scrim { position: fixed; inset: 0; background: rgba(20,18,14,.5); backdrop-filter: blur(2px); z-index: 50; display: grid; place-items: center; padding: 16px; }
  .modal { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; width: 100%; max-width: 500px; max-height: 92vh; overflow-y: auto; box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); }
  .modal-h { display: flex; align-items: center; justify-content: space-between; padding: 17px 20px 13px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
  .modal-h h2 { font-size: 17px; }
  .modal-h .hsub { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
  .modal-body { padding: 18px 20px; display: grid; gap: 14px; }
  .modal-f { padding: 14px 20px 20px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
  .field { display: grid; gap: 5px; }
  .frow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  label.lbl { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
  .opt { color: var(--ink-faint); font-weight: 400; }
  .field input, .field select, .field textarea { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%; }
  .field textarea { resize: vertical; min-height: 54px; }
  .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
  .field.err input, .field.err select { border-color: var(--overdue); }
  .amt-wrap { position: relative; }
  .amt-wrap .sym { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); font-weight: 600; pointer-events: none; font-size: 13px; }
  .amt-wrap input { padding-left: 28px; }
  .ghost-btn.cancel { background: none; }

  .note { font-size: 12.5px; border-radius: var(--radius-sm); padding: 9px 11px; display: flex; gap: 8px; align-items: flex-start; }
  .note svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
  .note.info { background: var(--accent-soft); color: var(--accent-ink); }
  .note.warn { background: var(--pending-soft); color: var(--pending); }

  /* payment history */
  .txns { display: grid; gap: 7px; }
  .txn { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; }
  .txn .ta { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .txn .td { font-size: 12px; color: var(--ink-soft); min-width: 0; }
  .txn .td b { color: var(--ink); font-weight: 600; }
  .txn .tx-rm { margin-left: auto; }
  .prog { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
  .prog > i { display: block; height: 100%; background: var(--paid); }

  /* scan dropzone */
  .drop { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 26px 18px; text-align: center; color: var(--ink-soft); background: var(--surface-2); transition: border-color .15s, background .15s; cursor: pointer; }
  .drop.hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
  .drop .di { width: 40px; height: 40px; margin: 0 auto 10px; color: var(--ink-faint); }
  .drop h3 { font-size: 15px; color: var(--ink); margin-bottom: 4px; }
  .drop p { font-size: 12.5px; margin: 0; }
  .scan-stage { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 10px 0; }
  .scan-stage img.prev { max-height: 180px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
  .seg { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
  .seg button { flex: 1; background: var(--surface-2); border: none; padding: 9px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
  .seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

  .toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 500; z-index: 80; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center; }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  .toast.show.start { transform: translateX(-50%) translateY(6px); }

  @media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 440px) { .brand .sub { display: none; } .search { margin-left: 0; width: 100%; } .search input { width: 100%; max-width: none; } .frow { grid-template-columns: 1fr; } }

  /* auth */
  .loginwrap { position: fixed; inset: 0; z-index: 100; background: var(--paper); display: grid; place-items: center; padding: 20px; }
  .logincard { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 360px; padding: 26px 24px; display: grid; gap: 14px; }
  .loginbrand { display: flex; align-items: center; gap: 11px; margin-bottom: 2px; }
  .loginbrand .mark { width: 40px; height: 40px; border-radius: 10px; flex: none; background: linear-gradient(145deg, var(--accent), var(--accent-ink)); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow); }
  .loginbrand .mark svg { width: 22px; height: 22px; }
  .loginbrand .lt { font-family: var(--ff-head); font-weight: 600; font-size: 19px; line-height: 1.1; }
  .loginbrand .ls { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; }
  .logincard h2 { font-size: 16px; }
  .logincard .field input { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-sm); padding: 10px 12px; width: 100%; }
  .logincard .field input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
  .loginerr { background: var(--overdue-soft); color: var(--overdue); border-radius: var(--radius-sm); padding: 8px 11px; font-size: 12.5px; font-weight: 600; }
  .userchip { display: inline-flex; align-items: center; gap: 7px; }
  .userchip .uava { width: 24px; height: 24px; border-radius: 6px; background: linear-gradient(145deg, var(--accent), var(--accent-ink)); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; font-family: var(--ff-head); }
  .pill-role { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
  .pill-role.admin { background: var(--accent-soft); color: var(--accent-ink); }
  .pill-role.user { background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line-strong); }

  /* ---- app shell / sidebar ---- */
  .shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
  .sidebar { position: sticky; top: 0; align-self: start; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 40; }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
  .side-brand .mark { width: 32px; height: 32px; border-radius: 9px; flex: none; background: linear-gradient(145deg, var(--accent), var(--accent-ink)); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow); }
  .side-brand .mark svg { width: 18px; height: 18px; }
  .side-brand .bt { font-family: var(--ff-head); font-weight: 600; font-size: 16px; line-height: 1.05; }
  .side-brand .bs { font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }
  .side-nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
  .nav-group { font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); padding: 15px 12px 6px; }
  .nav-item { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; background: none; border: none; border-radius: 9px; padding: 9px 12px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
  .nav-item svg { width: 17px; height: 17px; flex: none; }
  .nav-item .nav-count { margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--ink-faint); }
  .nav-item:hover { background: var(--surface-2); color: var(--ink); }
  .nav-item[aria-current="true"] { background: var(--accent-soft); color: var(--accent-ink); }
  .nav-item[aria-current="true"] .nav-count { color: var(--accent-ink); }
  .side-foot { border-top: 1px solid var(--line); padding: 12px; }
  .side-foot .userchip { width: 100%; justify-content: flex-start; }

  .content { min-width: 0; display: flex; flex-direction: column; }
  .topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.3) blur(8px); border-bottom: 1px solid var(--line); padding: 11px max(18px, env(safe-area-inset-right, 0px)) 11px max(18px, env(safe-area-inset-left, 0px)); }
  .topbar h1 { font-size: 18px; }
  .topbar-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
  .hamb { display: none; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 8px; color: var(--ink); }
  .hamb svg { width: 18px; height: 18px; display: block; }
  .sb-scrim { position: fixed; inset: 0; background: rgba(20,18,14,.4); z-index: 39; display: none; }

  /* home dashboard */
  .hero { margin-bottom: 20px; }
  .hero h2 { font-size: 22px; }
  .hero p { color: var(--ink-soft); margin: 4px 0 0; font-size: 13.5px; }
  .quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 13px; }
  .quick { display: flex; align-items: flex-start; gap: 12px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
  .quick:hover { border-color: var(--accent); }
  .quick .qi { width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
  .quick .qi svg { width: 19px; height: 19px; }
  .quick .qt { display: block; font-weight: 600; font-size: 14px; color: var(--ink); }
  .quick .qd { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
  .section-h { font-family: var(--ff-head); font-weight: 600; font-size: 15px; margin: 4px 0 13px; }

  /* reminders calendar */
  .cal-layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(240px, 1fr); gap: 16px; align-items: start; }
  .cal-card, .cal-side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
  .cal-card { padding: 14px 16px 16px; }
  .cal-side { padding: 14px 16px; }
  .cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
  .cal-head #calTitle { font-family: var(--ff-head); font-weight: 600; font-size: 16px; min-width: 140px; }
  .cal-head .spacer { margin-left: auto; }
  .cal-nav-btn { background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 8px; width: 30px; height: 30px; display: grid; place-items: center; color: var(--ink); font-size: 17px; line-height: 1; }
  .cal-nav-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
  .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
  .cal-dow { text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); padding: 2px 0 4px; }
  .cal-cell { min-height: 76px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; background: var(--surface); display: flex; flex-direction: column; gap: 3px; cursor: pointer; overflow: hidden; }
  .cal-cell:hover { border-color: var(--accent); }
  .cal-cell.other { opacity: .38; }
  .cal-cell.today { border-color: var(--accent); background: var(--accent-soft); }
  .cal-cell .dnum { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
  .cal-cell.today .dnum { color: var(--accent-ink); }
  .cal-chip { font-size: 10.5px; font-weight: 600; border-radius: 5px; padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; line-height: 1.45; }
  .cal-more { font-size: 10px; color: var(--ink-faint); font-weight: 600; padding-left: 2px; }
  .rc-utility { background: #2b6cb0; } .rc-insurance { background: #7b5bb5; } .rc-tax { background: #b8791a; } .rc-rent { background: #1f8f8a; } .rc-other { background: #6b665b; }
  .cal-dotc.rc-utility { color: #2b6cb0; background: #2b6cb0; } /* for dots */
  .up-empty { font-size: 12.5px; color: var(--ink-soft); padding: 10px 2px; }
  .up-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
  .up-item:last-child { border-bottom: none; }
  .up-item:hover .up-title { color: var(--accent-ink); }
  .up-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; flex: none; }
  .up-main { min-width: 0; flex: 1; }
  .up-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .up-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 1px; }
  .up-when { font-size: 11.5px; font-weight: 700; white-space: nowrap; text-align: right; }
  .up-when .d { font-weight: 600; color: var(--ink-faint); display: block; font-size: 11px; }
  .up-when.soon { color: var(--pending); } .up-when.over { color: var(--overdue); } .up-when.today { color: var(--accent-ink); }
  @media (max-width: 860px) { .cal-layout { grid-template-columns: 1fr; } .cal-cell { min-height: 62px; } }

  @media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; width: 248px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.25); }
    .sidebar.open { transform: translateX(0); }
    .sb-scrim.show { display: block; }
    .hamb { display: inline-grid; place-items: center; }
  }
