/* =====================================================================
   PropertyLedger — native.css  (v3, "Native")
   =====================================================================
   Loaded AFTER style.css and v2.css. It does not rewrite components:
   it redefines the palette and re-skins the existing classes
   (.card, .stat-card, .btn, .subtabs-nav, …) plus adds the native
   cost-card list that replaces the old .costs-table.

   Two themes, one system. Dark is the design's default; light is a real
   variant of the same design — same radii, type scale and layout, different
   surfaces. Every colour used by a rule below must come from a token declared
   here, so a theme flip is a token flip. (v1.11.13: light mode used to be
   forced back to the dark tokens — the toggle appeared dead.)
   ===================================================================== */

/* ---------------------------------------------------------------------
   0a. Tokens — dark (default)
   ------------------------------------------------------------------ */
:root,
:root[data-theme="dark"] {
  --bg:          #0B1020;
  --bg-2:        #1A2236;
  --bg-3:        #151E31;
  --bg-elev:     #1A2236;
  --border:      #2A3650;
  --border-2:    #33415C;
  --text:        #F8FAFC;
  --text-2:      #94A3B8;
  --text-3:      #94A3B8;
  --primary:     #2ECC71;
  --primary-dark:#25B863;
  --primary-ink: #07220F;
  --accent:      #FFC857;
  --warn:        #FFC857;
  --warn-bg:     rgba(255, 200, 87, .12);
  --danger:      #F97316;
  --shadow:      0 8px 32px rgba(0, 0, 0, .4);
  --focus-ring:  rgba(46, 204, 113, .35);
  --on-bg-3-text:#F8FAFC;
  --auth-glow:   rgba(46, 204, 113, .10);

  /* theme-dependent surfaces + inks (new in v1.11.13) */
  --ink-strong:    #F8FAFC;             /* headings, amounts, primary values */
  --bg-deep:       #070B18;             /* behind the app shell */
  --surface-raised:#242F4A;             /* inputs, chips, icon tiles, tracks */
  --surface-sunk:  #151E31;             /* nested blocks inside a card */
  --accent-soft:   #1E3329;             /* avatar / active tab pill */
  --appbar-bg:     rgba(11, 16, 32, .88);
  --tabbar-bg:     rgba(14, 21, 38, .86);
  --hairline:      rgba(42, 54, 80, .7);
  --placeholder:   rgba(148, 163, 184, .75);
  --hover-tint:    rgba(255, 255, 255, .02);
  --chip-on-bg:    #F8FAFC;
  --chip-on-ink:   #0B1020;
  --primary-br:    rgba(46, 204, 113, .55);
  --glow-primary:  0 6px 18px rgba(46, 204, 113, .32);
  --danger-br:     rgba(249, 115, 22, .35);
  --shadow-sm:     0 2px 8px rgba(0, 0, 0, .35);
  --chart-grid:    rgba(255, 255, 255, .07);

  /* shell — the rail stays dark navy in both themes (brand) */
  --rail:        #0E1526;
  --rail-2:      #151E31;
  --rail-3:      #1E3329;
  --rail-ink:    #94A3B8;
  --rail-muted:  #64748B;
  --rail-line:   #1E2A42;
  --rail-accent: #2ECC71;

  --r-card: 20px;
  --r-btn:  14px;
  --ink-paid:   #10B981;
  --ink-unpaid: #F97316;
  --ink-vat:    #FFC857;
}

/* ---------------------------------------------------------------------
   0b. Tokens — light
   ------------------------------------------------------------------
   Not cream: the native design is a cool navy system, so its light variant is
   a cool white one. The primary green is darkened (#12A150) so white text on
   it clears 4.5:1, and the amber/orange inks are darkened for the same reason
   — #2ECC71 and #FFC857 are unreadable on white. */
:root[data-theme="light"] {
  --bg:          #F5F7FB;
  --bg-2:        #FFFFFF;
  --bg-3:        #EEF2F8;
  --bg-elev:     #FFFFFF;
  --border:      #E3E8F0;
  --border-2:    #CBD5E1;
  --text:        #0F172A;
  --text-2:      #5B6B82;
  --text-3:      #7C8899;
  --primary:     #12A150;
  --primary-dark:#0E8A43;
  --primary-ink: #FFFFFF;
  --accent:      #B45309;
  --warn:        #B45309;
  --warn-bg:     rgba(180, 83, 9, .10);
  --danger:      #C2410C;
  --shadow:      0 4px 18px rgba(15, 23, 42, .07);
  --focus-ring:  rgba(18, 161, 80, .20);
  --on-bg-3-text:#0F172A;
  --auth-glow:   rgba(18, 161, 80, .07);

  --ink-strong:    #0B1220;
  --bg-deep:       #E7EBF3;
  --surface-raised:#EDF1F7;
  --surface-sunk:  #F7F9FC;
  --accent-soft:   #E4F6EB;
  --appbar-bg:     rgba(255, 255, 255, .88);
  --tabbar-bg:     rgba(255, 255, 255, .92);
  --hairline:      rgba(203, 213, 225, .85);
  --placeholder:   rgba(91, 107, 130, .70);
  --hover-tint:    rgba(15, 23, 42, .035);
  --chip-on-bg:    #0F172A;
  --chip-on-ink:   #FFFFFF;
  --primary-br:    rgba(18, 161, 80, .45);
  --glow-primary:  0 6px 18px rgba(18, 161, 80, .20);
  --danger-br:     rgba(194, 65, 12, .35);
  --shadow-sm:     0 2px 8px rgba(15, 23, 42, .08);
  --chart-grid:    rgba(15, 23, 42, .07);

  --rail:        #0E1526;
  --rail-2:      #151E31;
  --rail-3:      #1E3329;
  --rail-ink:    #94A3B8;
  --rail-muted:  #64748B;
  --rail-line:   #1E2A42;
  --rail-accent: #2ECC71;

  --ink-paid:   #0E8A43;
  --ink-unpaid: #C2410C;
  --ink-vat:    #A16207;
}

html, body { background: var(--bg-deep); }
body.has-shell, body.has-shell #app { background: var(--bg); color: var(--text); }

/* ---------------------------------------------------------------------
   1. Shell — rail / app bar / tab bar
   ------------------------------------------------------------------ */
/* The rail is desktop-only. v2.css already switches to a single column under
   1024px, but this file loads after it, so the rule must be re-stated INSIDE the
   breakpoint — an unscoped grid-template-columns here silently keeps the 248px
   rail on phones, which squeezes .main to 248px and collapses the cost-card
   text stacks to 0 width. That bug shipped once; keep both rules scoped. */
@media (min-width: 1025px) {
  body.has-shell #app { grid-template-columns: 248px minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  body.has-shell #app { grid-template-columns: minmax(0, 1fr); }
}

.rail { background: var(--rail); border-right: 1px solid var(--rail-line); }
.rail-brand b { color: #F8FAFC; letter-spacing: -.3px; }
.rail-brand span { color: var(--rail-muted); }
.rail-brand svg { color: var(--primary); }

.rail-switch { background: var(--rail-2); border: 1px solid var(--rail-line); border-radius: var(--r-btn); }
.rail-switch b { color: #F8FAFC; font-size: 13px; }
.rail-switch i { color: var(--rail-muted); }
.rs-av { background: var(--rail-3); color: var(--primary); font-weight: 700; }
.rail-nav .grp { color: #55637C; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; }
.rail-nav a { color: var(--rail-ink); border-radius: 10px; font-size: 13.5px; }
.rail-nav a:hover { background: rgba(255,255,255,.04); color: #F8FAFC; }
.rail-nav a.on { background: var(--rail-3); color: var(--primary); font-weight: 600; }
.rail-nav a.on .dot { background: var(--primary); }
.rail-nav a .cnt { background: rgba(255,255,255,.07); color: var(--rail-ink); }
.rail-me { border-top: 1px solid var(--rail-line); }
.me-av { background: var(--rail-3); color: var(--primary); }
.me-n { color: #F8FAFC; }
.me-e { color: var(--rail-muted); }
.rail-version { color: var(--rail-muted); }

/* phone app bar */
.appbar {
  background: var(--appbar-bg);
  backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--hairline);
  grid-template-columns: 40px minmax(0,1fr) auto;
}
.appbar .ab-title b { color: var(--ink-strong); font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.appbar .ab-title i { color: var(--text-2); font-size: 11.5px; }
.appbar .ico-btn { color: var(--ink-strong); }
.appbar .bars, .appbar .bars::before, .appbar .bars::after { background: var(--ink-strong); }
.appbar .ab-add {
  background: var(--primary); color: var(--primary-ink);
  border-radius: 999px; font-weight: 700;
  box-shadow: var(--glow-primary);
}

/* bottom tab bar */
.tabbar {
  background: var(--tabbar-bg);
  backdrop-filter: blur(22px) saturate(160%);
  border-top: 1px solid var(--hairline);
  height: auto;
  min-height: 84px;            /* design spec: 84px incl. the home-indicator area */
  align-items: flex-start;
  padding: 9px 8px calc(9px + env(safe-area-inset-bottom));
}
.tabbar a, .tabbar button {
  color: var(--text-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .01em;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 0 2px;
  border-radius: 999px;
  background: none;
}
.tabbar a .tb-ic, .tabbar button .tb-ic {
  width: 46px; height: 30px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  transition: background-color .18s ease, color .18s ease;
}
.tabbar a .tb-ic svg, .tabbar button .tb-ic svg { width: 21px; height: 21px; }
.tabbar a.on, .tabbar button.on { color: var(--primary); }
.tabbar a.on .tb-ic, .tabbar button.on .tb-ic { background: var(--accent-soft); color: var(--primary); }
.tabbar a.on .tb-ic svg, .tabbar button.on .tb-ic svg { stroke-width: 2.1; }

/* ---------------------------------------------------------------------
   2. Page headers + sections
   ------------------------------------------------------------------ */
.page-head { padding: 14px 16px 10px; align-items: flex-start; }
.page-head h1 {
  font-size: 28px; line-height: 1.1; font-weight: 900;
  letter-spacing: -.9px; color: var(--ink-strong); margin: 0;
}
.page-meta { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.page-head .btn { margin-top: 6px; }

.main h2, .card h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .09em;
  font-weight: 600; color: var(--text-2); margin: 0 0 10px;
}
.main h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-2); font-weight: 600; }
.muted { color: var(--text-2); }

/* ---------------------------------------------------------------------
   3. Cards + stat grid
   ------------------------------------------------------------------ */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 16px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.stat-card .label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-2); line-height: 1;
}
.stat-card .value {
  font-size: 21px; font-weight: 800; letter-spacing: -.6px;
  color: var(--ink-strong); margin-top: 10px; line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat-card .value.pos { color: var(--ink-paid); }
.stat-card .value.neg { color: var(--ink-unpaid); }
.stat-card .sub { font-size: 12px; color: var(--text-2); margin-top: 4px; line-height: 1.25; }

/* ---------------------------------------------------------------------
   4. Buttons + inputs
   ------------------------------------------------------------------ */
.btn {
  border-radius: var(--r-btn);
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text);
  transition: transform .15s ease, background-color .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(.975); }
.btn-primary {
  background: var(--primary); border-color: var(--primary);
  color: var(--primary-ink); font-weight: 700;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--bg-3); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg-2); border-color: var(--border-2); }
.btn-danger, .btn-danger-outline { color: var(--ink-unpaid); border-color: var(--danger-br); background: transparent; }
.btn-sm { padding: 7px 12px; font-size: 12px; }

input, select, textarea {
  background: var(--surface-raised);
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  color: var(--text);
  font-size: 15px;
  padding: 11px 12px;
}
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary-br);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
select { appearance: none; background-image: none; }

/* ---------------------------------------------------------------------
   5. Segmented control (Overview / Budgets sub-tabs)
   ------------------------------------------------------------------ */
.subtabs-nav {
  display: flex; gap: 4px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 14px;
}
.subtab-btn {
  flex: 1 1 0;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subtab-btn:hover { color: var(--text); background: transparent; }
.subtab-btn.active {
  background: var(--surface-raised);
  color: var(--ink-strong);
  box-shadow: var(--shadow-sm);
}

/* Budget groups carry real category names ("Renovation & Repairs",
   "Move In & Furnishing") which cannot fit four-across on a phone, so they
   used to render as "Renovati…" / "Ongoing (…". Two rows of two keeps every
   label complete and every target full width. The Overview sub-tabs use short
   words and stay on one row. */
.subtabs-nav.subtabs-wrap {
  flex-wrap: wrap;
  border-radius: 18px;
}
.subtabs-nav.subtabs-wrap .subtab-btn {
  flex: 1 1 calc(50% - 4px);
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
}
/* Desktop has room for one row of four. */
@media (min-width: 1025px) {
  .subtabs-nav.subtabs-wrap { flex-wrap: nowrap; }
  .subtabs-nav.subtabs-wrap .subtab-btn { flex: 1 1 0; }
}

/* ---------------------------------------------------------------------
   6. Badges / chips
   ------------------------------------------------------------------ */
.badge {
  border-radius: 999px; padding: 3px 9px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-raised); color: var(--text-2); border: 0;
}
.badge-paid { background: rgba(16,185,129,.14); color: var(--ink-paid); }
.badge-quote { background: rgba(255,200,87,.14); color: var(--ink-vat); }
.badge-unpaid { background: rgba(249,115,22,.14); color: var(--ink-unpaid); }
.status-chip {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px;
  color: var(--text); font-size: 12px; font-weight: 600;
}
.status-chip-count { color: var(--text-2); font-weight: 500; }

/* ---------------------------------------------------------------------
   7. Cost cards — the table is gone
   ------------------------------------------------------------------ */
.cost-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.cost-toolbar .search {
  flex: 1 1 auto; display: flex; align-items: center; gap: 8px;
  background: var(--surface-raised); border-radius: var(--r-btn); padding: 0 12px; height: 42px;
}
.cost-toolbar .search input {
  background: none; border: 0; padding: 0; height: 100%; font-size: 14px; flex: 1 1 auto;
}
.cost-toolbar .search input:focus { box-shadow: none; }
.cost-toolbar .search svg { width: 16px; height: 16px; color: var(--text-2); flex: none; }
.cost-toolbar select { height: 42px; padding: 0 28px 0 12px; font-size: 12px; color: var(--text-2); flex: 0 1 auto; max-width: 46%; }
.cost-toolbar .icon-btn {
  width: 42px; height: 42px; border-radius: var(--r-btn);
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-2); display: flex; align-items: center; justify-content: center;
}

.cost-list { display: flex; flex-direction: column; gap: 10px; }

.cost-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cost-card > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
}
.cost-card > summary::-webkit-details-marker { display: none; }
.cost-card > summary:active { background: var(--hover-tint); }

.cc-icon {
  width: 40px; height: 40px; border-radius: 999px;
  background: var(--surface-raised); flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1;
}
.cc-main { min-width: 0; flex: 1 1 0%; }
.cc-desc {
  font-size: 15px; font-weight: 600; color: var(--ink-strong); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cc-cat {
  font-size: 12px; color: var(--text-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cc-meta {
  font-size: 11.5px; color: var(--text-3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cc-right { flex: none; text-align: right; }
.cc-amt { font-size: 15px; font-weight: 700; color: var(--ink-strong); font-variant-numeric: tabular-nums; }
.cc-status { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 6px; font-size: 11px; font-weight: 600; }
.cc-dot { width: 6px; height: 6px; border-radius: 999px; }
.cc-chev { color: var(--text-2); flex: none; margin-top: 4px; transition: transform .25s ease; }
.cost-card[open] .cc-chev { transform: rotate(90deg); }
/* A long description is clamped to two lines in the collapsed row; opening the
   card reveals the whole thing, so no data is lost to ellipsis. */
.cost-card[open] .cc-desc { -webkit-line-clamp: unset; display: block; }
.cost-card[open] .cc-cat, .cost-card[open] .cc-meta { white-space: normal; overflow: visible; }

.cc-panel { padding: 0 14px 14px; }
.cc-breakdown {
  display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px;
  border-top: 1px solid var(--border); padding-top: 12px;
}
.cc-k { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); }
.cc-v { font-size: 12.5px; font-weight: 700; color: var(--ink-strong); margin-top: 2px; font-variant-numeric: tabular-nums; }
.cc-actions { display: flex; gap: 8px; margin-top: 12px; }
.cc-actions .btn { flex: 1 1 auto; }
.cc-actions .icon-only { flex: 0 0 42px; width: 42px; padding: 0; display: flex; align-items: center; justify-content: center; }

/* VAT breakdown — rate blocks instead of a 6-column ledger */
.vat-rates { display: flex; flex-direction: column; gap: 10px; }
.vat-rate {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
}
.vat-rate.total { background: var(--surface-sunk); border-color: var(--border-2); }
.vr-head { display: flex; align-items: center; gap: 8px; }
.vr-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--ink-vat); flex: none; }
.vr-name { font-size: 14px; font-weight: 600; color: var(--ink-strong); flex: 1 1 auto; }
.vr-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-top: 10px; }
.vr-source { margin-top: 8px; font-size: 11px; color: var(--text-2); }
.vat-details > summary.vat-summary { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-2); font-weight: 600; }

/* legacy tables (journey, documents, tax) — keep readable, drop the grid */
.costs-table { display: none; }

/* ---------------------------------------------------------------------
   8. Empty states
   ------------------------------------------------------------------ */
.empty-state {
  background: var(--bg-2); border: 1px dashed var(--border);
  border-radius: var(--r-card); padding: 32px 20px; text-align: center;
  color: var(--text-2); font-size: 13.5px;
}

/* ---------------------------------------------------------------------
   9. Desktop keeps the rail, everything else follows the phone scale
   ------------------------------------------------------------------ */
@media (min-width: 1025px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .page-head { padding: 24px 28px 12px; }
  .page-head h1 { font-size: 32px; }
  .main { padding: 0 28px 28px; }
  .card, .stat-card { border-radius: var(--r-card); }
  .cost-list { gap: 12px; }
}

@media (max-width: 1024px) {
  body.has-shell #app {
    grid-template-rows: 56px minmax(0, 1fr) auto;
  }
  .main { padding: 0 16px 20px; }
  .page-head { padding-left: 16px; padding-right: 16px; margin: 0 -16px; }
}

/* Legacy tables (resale projection, SA108 tax bands) used a 9.5px header at
   every width — below the reading floor. Applies on desktop too; the phone
   block used to be the only place this was raised. */
.main table th, .main table td { font-size: 12px; }

/* ---------------------------------------------------------------------
   10. Motion / focus
   ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tabbar a:focus-visible, .tabbar button:focus-visible { outline-offset: -2px; }

/* ---------------------------------------------------------------------
   11. Portfolio redesign (v1.11.6) — real data only
   ------------------------------------------------------------------ */
.stat-card .value.vat { color: var(--ink-vat); }

/* merged paid / unpaid card */
.stat-card .pair { display: flex; flex-direction: column; gap: 4px; margin-top: 9px; }
.stat-card .pair-cell { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.stat-card .pair .value {
  font-size: 14px; margin-top: 0; letter-spacing: -.3px;
  white-space: nowrap;
  overflow: visible;                /* two amounts side-by-side in a 163px card
                                       were ellipsised ("£1,376.0…"); stacked
                                       lines give each the full card width */
  text-overflow: clip;
}
.stat-card .pair .sub { margin-top: 0; font-size: 11.5px; }

.section-block { margin-top: 22px; }
.section-block > h2 { margin: 0 0 10px; }

/* counted status pills */
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-strong);
}
.sp-dot { width: 7px; height: 7px; border-radius: 999px; flex: none; }
.sp-count {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  background: var(--surface-raised); color: var(--text-2);
  font-size: 11px; font-weight: 700; display: inline-flex;
  align-items: center; justify-content: center;
}

/* cost per property vs budget */
.spend-list { display: flex; flex-direction: column; gap: 14px; }
.spend-row { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px 16px; box-shadow: var(--shadow); }
.spend-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.spend-name { font-size: 13.5px; font-weight: 600; color: var(--ink-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spend-amt { font-size: 13.5px; font-weight: 700; color: var(--ink-strong); font-variant-numeric: tabular-nums; flex: none; }
.spend-track { height: 7px; border-radius: 999px; background: var(--surface-raised); overflow: hidden; margin-top: 10px; }
.spend-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.spend-scale { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--text-2); }

/* filter chips */
.chip {
  height: 34px; padding: 0 14px; border-radius: 999px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-2); font-size: 12px; font-weight: 600;
}
.chip.on { background: var(--chip-on-bg); border-color: var(--chip-on-bg); color: var(--chip-on-ink); }

/* avatar initials on cost cards */
.cc-avatar {
  width: 40px; height: 40px; border-radius: 999px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; letter-spacing: .3px;
  border: 1px solid transparent;
}

/* property row figures */
.pc-figures { display: flex; gap: 16px; margin-top: 6px; font-size: 13px; flex-wrap: wrap; }
.pc-meta { margin-top: 4px; font-size: 12px; }

/* ---------------------------------------------------------------------
   12. Settings redesign — identity card, tax-default cards
   ------------------------------------------------------------------ */
.profile-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.profile-avatar {
  width: 52px; height: 52px; border-radius: 999px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--primary);
  font-size: 17px; font-weight: 700; letter-spacing: .5px;
  border: 1px solid var(--primary-br);
}
.profile-id { min-width: 0; }
.profile-name { font-size: 17px; font-weight: 700; color: var(--ink-strong); letter-spacing: -.2px; }
.profile-mail { font-size: 12.5px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }

.default-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px;
}
.default-flag { font-size: 20px; line-height: 1.2; flex: none; }
.default-body { min-width: 0; }
.default-title { font-size: 13.5px; font-weight: 600; color: var(--ink-strong); }
.default-bands { font-size: 12px; line-height: 1.5; color: var(--text-2); margin-top: 3px; }
.settings-version {
  text-align: center; font-size: 11px; color: var(--text-3);
  padding: 18px 0 4px;
}

/* ---------------------------------------------------------------------
   13. Budgets — progress cards with an inline editable amount
   ------------------------------------------------------------------ */
.budget-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.bc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.bc-name {
  font-size: 13.5px; font-weight: 600; color: var(--ink-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bc-pct { font-size: 12px; font-weight: 600; color: var(--text-2); flex: none; font-variant-numeric: tabular-nums; }
.bc-pct.over { color: var(--ink-unpaid); }
.bc-track { height: 6px; border-radius: 999px; background: var(--surface-raised); overflow: hidden; margin-top: 9px; }
.bc-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width .25s ease; }
.bc-fill.over { background: var(--ink-unpaid); }
.bc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 9px; }
.bc-spent { font-size: 12px; font-weight: 600; color: var(--ink-strong); font-variant-numeric: tabular-nums; }
.bc-spent .muted { font-weight: 500; }
.bc-input {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface-raised); border: 1px solid transparent; border-radius: 10px;
  padding: 0 8px; height: 34px; min-width: 96px;
}
.bc-input:focus-within { border-color: var(--primary-br); }
.bc-cur { font-size: 12px; color: var(--text-2); }
.bc-input input {
  width: 68px; background: none; border: 0; padding: 0; height: 100%;
  font-size: 13px; font-weight: 600; color: var(--ink-strong); text-align: right;
}
.bc-input input:focus { box-shadow: none; }

/* ---------------------------------------------------------------------
   14. Legibility fixes found by the theme contrast sweep (v1.11.13)
   ------------------------------------------------------------------ */
/* The rail is dark in both themes, so its version stamp only needs to clear
   the rail, not the app surface. The old slate was 2.3:1 on it. */
.rail-version { color: var(--rail-muted); }

/* Active document-type filter: white on the old #2ECC71 was 2:1. On-primary
   ink is the token that is designed to sit on a primary fill. */
.segmented-option.active { color: var(--primary-ink); }

/* The room "% used" label lives INSIDE the progress fill, so at a low
   percentage it spills onto the track (dark ink on the dark track: 1.0:1) and
   at 100% it sits on green. Give it its own small surface, pinned to the end of
   the bar, so it is legible wherever the fill happens to end. */
.rg-bar { height: 20px; border-radius: 999px; }
.rg-bar-fill { border-radius: 999px; padding: 0; justify-content: flex-end; }
.rg-bar-fill > span {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 6px; font-size: 10px; line-height: 1.45; font-weight: 700;
}
.rg-overflow { text-shadow: none !important; }

/* Cost-card initials: the inline style tints the chip per category, so the ink
   comes from the theme rather than from the tint (cyan on pale cyan was 2.2:1
   in light mode). */
.cc-avatar { color: var(--ink-strong); font-weight: 800; }

/* ---------------------------------------------------------------------
   11. Desktop-mode phone rescue
   ---------------------------------------------------------------------
   Browsers in "Desktop site" mode (and several in-app WebViews) ignore
   width=device-width and lay the page out at ~980 CSS px, then shrink the
   whole thing to fit the screen: the phone UI renders ~2.5x too wide with a
   large empty band beneath it. index.html's inline bootstrap adds .pl-fit and
   sets --pl-fit-z when it detects that viewport; here we scale the shell back
   into a phone-sized frame so the layout matches the phone design again.
   On a real device viewport, or in the installed PWA, .pl-fit is never set. */
html.pl-fit { zoom: var(--pl-fit-z, 1); }

html.pl-fit body.has-shell {
  height: calc(100dvh / var(--pl-fit-z, 1));
  min-height: 0;
  overflow: hidden;
}

html.pl-fit body.has-shell #app {
  width: calc(100vw / var(--pl-fit-z, 1));
  height: calc(100dvh / var(--pl-fit-z, 1));
}

/* ---------------------------------------------------------------------
   v1.13.0 — two-factor authentication
   Login second step (.mfa-*) and Settings → Security (.security-* /
   .recovery-*). Every colour comes from a token so both themes work.
   --------------------------------------------------------------------- */

.mfa-who {
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  margin: -6px 0 14px;
}

.mfa-row input.mfa-code {
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  letter-spacing: .40em;
  /* letter-spacing adds a phantom gap after the last digit — nudge it back */
  text-indent: .40em;
  padding: 14px 10px;
}

.mfa-row input.mfa-code.mfa-recovery {
  font-size: 16px;
  letter-spacing: .10em;
  text-indent: .10em;
}

.mfa-status:empty { display: none; }

.security-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.security-title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink-strong);
}

.security-note {
  margin: 4px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
}

.security-badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  color: var(--text-2);
  background: var(--surface-sunk);
}

.security-badge.on {
  color: var(--primary);
  border-color: var(--primary-br);
  background: var(--accent-soft);
}

.security-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
}

.security-stat-label { font-size: 12.5px; color: var(--text-2); }
.security-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-strong);
  font-variant-numeric: tabular-nums;
}
.security-stat-value.warn { color: var(--ink-unpaid); }

.security-warn {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-unpaid);
  background: var(--warn-bg);
  border: 1px solid var(--danger-br);
}

.security-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.security-form { margin-top: 14px; }
.security-cancel { margin-top: 10px; }

.mfa-qr-wrap {
  display: flex;
  justify-content: center;
  margin: 14px 0;
}

/* White plate in both themes — scanners need the quiet zone to be light. */
.mfa-qr {
  display: block;
  background: #FFFFFF;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  width: 200px;
  height: 200px;
}

.secret-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  letter-spacing: .08em;
  text-align: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-sunk);
  border: 1px dashed var(--border-2);
  color: var(--ink-strong);
  overflow-wrap: anywhere;
  cursor: pointer;
}

.recovery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 0;
}

.recovery-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  text-align: center;
  padding: 9px 6px;
  border-radius: 10px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  color: var(--ink-strong);
  letter-spacing: .04em;
}

.recovery-confirm {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
  cursor: pointer;
}

.recovery-confirm input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--primary);
}

/* ---------------------------------------------------------------------
   v1.14.0 — Income tab + mortgage tax line
   Reuses .cost-card / .stat-card so income reads as the mirror of costs
   rather than a new visual language.
   --------------------------------------------------------------------- */

.income-stats { margin-bottom: 14px; }

/* Three cards, three columns — the generic 4-up desktop grid left a dead
   fourth cell that read as a missing card. Phones stay 2-up (the base rule). */
@media (min-width: 1025px) {
  .income-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.income-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.income-avatar {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink-paid);
}

.income-card .cc-amt { color: var(--ink-paid); }

.income-months { margin-bottom: 14px; }

.income-month-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.income-month {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 78px 64px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.income-month-label {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.income-month-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-raised);
  overflow: hidden;
}

.income-month-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

.income-month.void .income-month-bar > span { background: var(--ink-unpaid); }

.income-month-amt {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-strong);
}

.income-month-gap {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-unpaid);
}

.income-month-gap.ok { color: var(--ink-paid); }

.mortgage-taxline {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
  font-size: 12.5px;
}

@media (max-width: 420px) {
  .income-month {
    grid-template-columns: 44px minmax(0, 1fr) 68px;
  }
  /* The shortfall column is the first thing to go on a narrow phone; the bar
     colour already carries the same information. */
  .income-month-gap { display: none; }
}
