/* ---- Typeface: Inter, served with the app (no outside font service) ----
   One variable file holds every weight. Licence: fonts/Inter-LICENSE.txt (SIL OFL). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---- Colours ----
   Light by default; dark when the phone or computer is set to dark mode. Every colour in
   this file comes from these tokens, so a re-colour (Stage 6 branding) happens here. */
:root {
  --bg: #f6f5f1;            /* the page */
  --bg-elev: #ffffff;       /* cards, lists, dialogs */
  --field: #ffffff;         /* text boxes and pickers */
  --chip: #ecebe6;          /* segmented controls, small pills */
  --seg-on: #ffffff;        /* the chosen side of a segmented control */
  --text: #16181d;
  --text-dim: #6b6f78;
  --border: #e4e1da;
  --track: rgba(16, 18, 24, 0.07);   /* bar backgrounds, chart grid lines */
  --hover: rgba(16, 18, 24, 0.04);
  --accent: #3e54d3;        /* indigo: buttons, links, the chosen thing */
  --accent-press: #2f43b8;
  --accent-soft: #eceefc;
  --on-accent: #ffffff;
  --pos: #0a7d55;           /* money in, all good */
  --pos-soft: #e2f3ec;
  --warn: #a85a00;          /* needs a look */
  --warn-soft: #fdf0dc;
  --danger: #c8372d;        /* money out of the red, delete */
  --danger-soft: #fce9e7;
  --tint-1: #eceefc; --tint-1-ink: #3e54d3;   /* icon tiles: indigo */
  --tint-2: #fdf0dc; --tint-2-ink: #b4610a;   /*             amber  */
  --tint-3: #e2f3ec; --tint-3-ink: #0a7d55;   /*             green  */
  --scrim: rgba(18, 20, 26, 0.42);           /* behind dialogs */
  --veil: rgba(246, 245, 241, 0.94);         /* the "reading your receipt" screen */
  --shadow-sm: 0 1px 2px rgba(16, 18, 24, 0.04), 0 2px 10px rgba(16, 18, 24, 0.04);
  --shadow-lg: 0 10px 34px rgba(16, 18, 24, 0.16);
  --glass: rgba(255, 255, 255, 0.24);        /* the floating tab bar: mostly clear */
  --glass-edge: rgba(255, 255, 255, 0.55);
  --glass-shine: rgba(255, 255, 255, 0.75);
  --glass-halo: rgba(255, 255, 255, 0.85);   /* soft glow behind tab labels */
  --glass-pick: rgba(62, 84, 211, 0.1);
  --radius: 18px;
  --tap: 56px;              /* minimum comfortable tap target */
  --maxw: 560px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f12;
    --bg-elev: #16191e;
    --field: #1c2027;
    --chip: #1f232a;
    --seg-on: #2d323b;
    --text: #f1f2f4;
    --text-dim: #969ca6;
    --border: #272b33;
    --track: rgba(255, 255, 255, 0.08);
    --hover: rgba(255, 255, 255, 0.05);
    --accent: #8394ff;
    --accent-press: #6d80f6;
    --accent-soft: rgba(131, 148, 255, 0.15);
    --on-accent: #0d0f12;
    --pos: #3fd09b;
    --pos-soft: rgba(63, 208, 155, 0.13);
    --warn: #f3b552;
    --warn-soft: rgba(243, 181, 82, 0.13);
    --danger: #ff7b70;
    --danger-soft: rgba(255, 123, 112, 0.14);
    --tint-1: rgba(131, 148, 255, 0.15); --tint-1-ink: #a3b0ff;
    --tint-2: rgba(243, 181, 82, 0.14);  --tint-2-ink: #f3b552;
    --tint-3: rgba(63, 208, 155, 0.13);  --tint-3-ink: #3fd09b;
    --scrim: rgba(0, 0, 0, 0.6);
    --veil: rgba(13, 15, 18, 0.94);
    --shadow-sm: none;
    --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.5);
    --glass: rgba(30, 33, 40, 0.28);
    --glass-edge: rgba(255, 255, 255, 0.16);
    --glass-shine: rgba(255, 255, 255, 0.18);
    --glass-halo: rgba(0, 0, 0, 0.7);
    --glass-pick: rgba(255, 255, 255, 0.1);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.006em;
  font-variant-numeric: tabular-nums;   /* every digit the same width: amounts line up */
  font-feature-settings: "cv11";        /* Inter's plainer single-storey "a" */
}
h1, h2, h3 { letter-spacing: -0.02em; }

.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px env(safe-area-inset-bottom);
}

[hidden] { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; touch-action: manipulation; }
button:disabled { opacity: 0.5; cursor: default; }

/* ---- Loading ---- */
#screen-loading { align-items: center; justify-content: center; }
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Brand ---- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.brand-mark {
  height: 1.3em; width: auto;   /* the receipt is taller than wide (icons/mark.png) */
  flex: none;
  display: block;
}

/* ---- Login ---- */
#screen-login, #screen-household { align-items: center; justify-content: center; }
.login-card {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card .brand { justify-content: center; font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.login-sub {
  margin: -8px 0 4px;
  text-align: center;
  color: var(--text-dim);
  font-size: 15px;
}

input {
  width: 100%;
  height: var(--tap);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  padding: 0 16px;
  font-family: inherit;
  font-size: 16px;
}
input::placeholder { color: var(--text-dim); opacity: 0.8; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* Date inputs: normalise so iOS Safari can't render them wider than their box */
input[type="date"] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; }

.login-card button[type="submit"] {
  height: var(--tap);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 600;
  border-radius: 999px;
}
.login-card button[type="submit"]:active { background: var(--accent-press); }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card #hh-join-btn { height: var(--tap); background: var(--accent); color: var(--on-accent); font-size: 17px; font-weight: 600; border-radius: 999px; }
#hh-join { display: flex; flex-direction: column; gap: 14px; }
#hh-join[hidden], .login-card form[hidden] { display: none; }
.btn-google {
  height: var(--tap);
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 16px;
  font-weight: 600;
  border-radius: 999px;
}
.btn-google:active { background: var(--hover); }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 14px; }
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login-or[hidden] { display: none; }
.login-fine { margin: 0; text-align: center; color: var(--text-dim); font-size: 13px; }
.hh-title { margin: 4px 0 0; font-size: 20px; font-weight: 650; text-align: center; }
.hh-text { margin: 0; color: var(--text-dim); font-size: 15px; line-height: 1.45; }
.hh-small { font-size: 13px; text-align: center; }
/* ---- Setup (setup.js): Home's card, and the sheet of steps ---- */
.home-setup {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  background: var(--accent-soft);
  color: var(--text);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 14px;
}
.home-setup[hidden] { display: none; }
.home-setup-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.home-setup-top strong { color: var(--accent); font-size: 15.5px; font-weight: 650; }
.home-setup-top span { color: var(--text-dim); font-size: 13px; }
.home-setup-track { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.home-setup-track span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .3s ease; }
.home-setup-next { color: var(--text-dim); line-height: 1.4; }
.setup-card { gap: 14px; }
.setup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.setup-count { margin: 4px 0 0; color: var(--text-dim); font-size: 14px; }
.setup-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.setup-step { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.setup-step:first-child { border-top: none; }
.setup-mark {
  flex: 0 0 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 650;
  background: var(--chip); color: var(--text-dim);
}
.setup-step.current .setup-mark { background: var(--accent); color: var(--on-accent); }
.setup-step.done .setup-mark { background: var(--pos-soft); color: var(--pos); }
.setup-body { flex: 1; min-width: 0; }
.setup-title { font-weight: 600; font-size: 15.5px; padding-top: 3px; }
.setup-step.done .setup-title { color: var(--text-dim); }
.setup-text { margin: 4px 0 10px; color: var(--text-dim); font-size: 14px; line-height: 1.4; }
.setup-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.setup-privacy { border-top: 1px solid var(--border); padding-top: 12px; font-size: 13.5px; color: var(--text-dim); line-height: 1.45; }
.setup-privacy summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.setup-privacy p { margin: 8px 0 0; }
.setup-privacy b { color: var(--text); font-weight: 600; }
.privacy-promises { margin: 8px 0 0; padding-left: 18px; }
.privacy-promises li { margin: 6px 0 0; }
.sample-note { flex-basis: 100%; margin: 0 0 4px; }
.invite-box { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.invite-box[hidden] { display: none; }
.invite-box input { font-size: 14px; }

.error { color: var(--danger); margin: 0; text-align: center; font-size: 15px; }
.info { color: var(--accent); margin: 0; text-align: center; font-size: 15px; }
.link-btn { background: none; color: var(--text-dim); font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; padding: 4px; align-self: center; }
.link-btn:active { color: var(--text); }
.confirm-msg { margin: 0; color: var(--text-dim); font-size: 15px; line-height: 1.45; }
.gst-breakdown { margin: -2px 2px 0; font-size: 13px; color: var(--text-dim); }
.money-input input[readonly] { color: var(--text-dim); }

/* ---- Toggle switch (GST-inclusive, "Include in the tenant's additional rent") ----
   A real checkbox stays under the hood (visually hidden, positioned over the
   track) so every existing .checked read/write and "change" listener in
   capture.js/income.js/receipts.js needs no changes — only this visual layer
   is new. */
.switch-field { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch-field-text { font-size: 15px; color: var(--text); }
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: none;
  border-radius: 999px;
  background: var(--track);
}
.switch:has(.switch-input:checked) { background: var(--accent); }
.switch-input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
.switch-input:checked ~ .switch-thumb { transform: translateX(20px); }

/* ---- Header ---- */
/* Every screen's top bar stays put while the page scrolls under it: a solid colour (no blur,
   no shadow), so it stays crisp, with a hairline under it. */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 -16px 4px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.app-header .brand { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; gap: 8px; }
.menu-wrap { position: relative; display: inline-flex; align-items: center; }
.icon-btn {
  position: relative;
  background: none;
  color: var(--text-dim);
  padding: 8px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { color: var(--text); }
/* Unread dot (emailed receipts to review) — badge.js toggles .has-dot, in the
   app's accent colour. Works
   on every platform regardless of Badging API support, so it's a reliable
   fallback where the OS-level badge can't reach (e.g. no PWA install). */
.icon-btn.has-dot::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg);
}
/* Round buttons in the top bar: the bell and the account (which opens the menu). */
.icon-btn.round {
  width: 40px; height: 40px; padding: 0;
  border-radius: 50%;
  background: var(--chip);
  color: var(--text);
}
.header-right { gap: 8px; }
.menu-account { font-size: 12.5px; color: var(--text-dim); padding: 8px 14px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-account[hidden] { display: none; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 220px;
  z-index: 10;
}
.menu-item {
  position: relative;
  width: 100%;
  text-align: left;
  background: none;
  color: var(--text);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 15.5px;
  font-weight: 500;
  white-space: nowrap;
}
.menu-item:active { background: var(--hover); }
.menu-item.has-dot::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.menu-sep { height: 1px; background: var(--border); margin: 6px 6px; }
.menu-cap { font-size: 11px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.06em; text-transform: uppercase; padding: 8px 14px 4px; }

/* ---- Home / Capture ----
   Top to bottom: this year's net (big), income and spending, each rental's net; then
   one main action (Add receipt) with three small tiles under it. */
.home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 4px 0 32px;
}
.home-body > * { width: 100%; max-width: 420px; }

/* The summary card: a headline number, two stats, then a list of rentals. */
.home-card {
  text-align: left;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
  padding: 20px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.home-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.home-card-title { font-size: 13.5px; font-weight: 500; color: var(--text-dim); }
.home-card-link { font-size: 13.5px; color: var(--accent); font-weight: 600; flex: none; }
.hc-hero { font-size: 40px; font-weight: 650; letter-spacing: -0.035em; line-height: 1.1; margin: 2px 0 10px; }
.hc-hero small { font-size: 22px; font-weight: 550; color: var(--text-dim); letter-spacing: -0.01em; }
.hc-hero.neg { color: var(--danger); }
.home-card-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hc-row {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg); border-radius: 14px; padding: 10px 12px;
  font-size: 12.5px; font-weight: 500; color: var(--text-dim);
}
.hc-row span:last-child { color: var(--text); font-weight: 650; font-size: 16.5px; letter-spacing: -0.01em; }
.home-card-props { display: flex; flex-direction: column; margin-top: 8px; }
.hc-prop {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 15px; padding: 11px 0; border-top: 1px solid var(--border);
}
.hc-prop-left { display: flex; align-items: center; min-width: 0; }
.hc-prop-name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-prop-net { font-weight: 600; padding-left: 10px; }
.hc-prop-net.pos { color: var(--pos); }
.hc-prop-net.neg { color: var(--danger); }
.hc-prop .prop-dot { width: 10px; height: 10px; margin-right: 10px; }
.hc-group {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); padding: 14px 0 6px; border-top: 1px solid var(--border);
}
.hc-group .hc-prop-net { font-size: 13.5px; text-transform: none; letter-spacing: normal; }
.hc-group + .hc-prop { border-top: none; }
.home-card-hint { font-size: 13.5px; color: var(--text-dim); margin: 4px 0 12px; }

/* The capture block: Expense | Income, the main button, then the three tiles. */
.home-capture { display: flex; flex-direction: column; gap: 12px; }
.home-capture .add-receipt { margin-bottom: 8px; }   /* clear air between the button and the tiles */
.add-receipt {
  width: 100%;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 600;
  border-radius: 999px;
}
.add-receipt:active { background: var(--accent-press); }
.line-icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.home-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.home-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 92px; padding: 12px 6px;
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-sm);
  font-size: 13.5px; font-weight: 550;
}
.tile-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; }
.tint-1 { background: var(--tint-1); color: var(--tint-1-ink); }
.tint-2 { background: var(--tint-2); color: var(--tint-2-ink); }
.tint-3 { background: var(--tint-3); color: var(--tint-3-ink); }

.home-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 13.5px;
  margin: 0;
}

/* ---- Bottom tab bar ----
   A floating "glass" pill: the page shows through, frosted, with a thin bright edge. */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 400px);
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(5px) saturate(1.9);
  backdrop-filter: blur(5px) saturate(1.9);
  border: 1px solid var(--glass-edge);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12), inset 0 1px 0 var(--glass-shine);
}
.tabbar[hidden] { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; height: 52px; background: none; color: var(--text);
  font-size: 10.5px; font-weight: 600; border-radius: 999px;
  text-shadow: 0 0 6px var(--glass-halo), 0 0 2px var(--glass-halo);
}
.tab .line-icon { filter: drop-shadow(0 0 3px var(--glass-halo)); }
.tab.active { color: var(--accent); background: var(--glass-pick); }
.tab:focus { outline: none; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tab.active .line-icon { stroke-width: 2.1; }
body.has-tabbar .screen { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
body.has-tabbar .queue-banner { bottom: calc(86px + env(safe-area-inset-bottom)); }

/* ---- Toast ---- */
/* Transient top banners — the info/error toast and the undo-delete banner share
   ONE geometry (position, width, height, radius, font) so they're
   indistinguishable except by COLOUR/text. Each stays on a single line (ellipsis
   on overflow), pinned across the content column near the top. (The "Update
   available" banner and the sync-status pill are deliberately NOT part of this —
   they're persistent status chrome, not transient toasts.) */
.toast,
.undo-toast {
  position: fixed;
  left: max(16px, calc(50% - var(--maxw) / 2 + 16px));
  right: max(16px, calc(50% - var(--maxw) / 2 + 16px));
  top: calc(62px + env(safe-area-inset-top));
  z-index: 85;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  box-sizing: border-box;
  padding: 10px 16px;
  border-radius: 16px;
  max-width: none;
  box-shadow: var(--shadow-lg);
}
/* Message text: one line, ellipsis when too long. Colour is the ONLY thing that
   differs between the two variants. */
.toast .toast-msg,
.undo-toast span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 600;
}
.toast { background: var(--bg-elev); border: 1px solid var(--border); }
.toast .toast-msg { color: var(--text); }
/* Accent banner — same accent/on-accent tokens as everywhere else in this app,
   so it stays Business's own colour. */
.undo-toast { background: var(--accent); border: none; }
.undo-toast span { color: var(--on-accent); }
.undo-toast-btn { background: var(--bg); color: var(--accent); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 700; flex: none; }

/* ---- Sync status (offline / pending-write pill) ---- */
.sync-status {
  position: fixed;
  left: 50%;
  top: calc(10px + env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 15px;
  border-radius: 999px;
  z-index: 60;
  box-shadow: var(--shadow-lg);
  max-width: calc(100% - 32px);
}
.sync-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  flex: none;
}
.sync-status.syncing::before { animation: syncpulse 1s ease-in-out infinite; }
@keyframes syncpulse { 50% { opacity: 0.25; } }

/* ---- Plain-title headers (non-brand screens) ---- */
.app-header h1 { margin: 0; font-size: 19px; font-weight: 650; }
.header-spacer { width: 38px; flex: none; }
/* Right-side header cluster (year select + the ⋮ menu button). */
.header-right { display: flex; align-items: center; flex: none; }
/* TRUE-centre the title regardless of what's in the right-side cluster: a plain
   ⋮ menu button (~38px, same as the back button) already centred it under the old
   flex/space-between layout, but a wider cluster (year select + ⋮, e.g. Summary/
   Tax checkup/Tax documents/Net worth) pushed it left instead. Grid keeps the
   title centred to the header's full width no matter how wide either side is.
   Scoped to headers whose first child is the back button, so the brand/Home
   header (logo + app-switch + menu, no back button, meant to be left-aligned)
   is untouched. */
.app-header:has(> button:first-child) { display: grid; grid-template-columns: 1fr auto 1fr; }
.app-header:has(> button:first-child) > button:first-child { justify-self: start; }
.app-header:has(> button:first-child) h1 {
  justify-self: center;
  text-align: center;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header:has(> button:first-child) > *:last-child { justify-self: end; }

/* ---- Manage ---- */
.manage-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-top: 6px;
  padding-bottom: 24px;
}
.manage-section { display: flex; flex-direction: column; gap: 10px; }
.list-group-head { grid-column: 1 / -1; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 8px 2px 2px; }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.section-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.015em;
}

.row-list { display: flex; flex-direction: column; gap: 10px; }
.row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
}
.row-main {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  background: none;
  color: var(--text);
  text-align: left;
  padding: 0;
}
.row-main.tappable { cursor: pointer; }
.row-info { flex: 1; min-width: 0; }
.row-name { font-size: 16px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex: none; }
.row-btn {
  background: none;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13.5px;
  font-weight: 550;
}
.row-btn:active { background: var(--hover); }
.row-btn.subtle { color: var(--text-dim); }
.row-btn.danger { color: var(--danger); border-color: var(--danger); }
.icon-row-btn {
  background: none;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-row-btn:active { color: var(--text); }
.icon-row-btn:disabled { opacity: 0.3; }
.text-toggle {
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 8px 4px;
  align-self: flex-start;
}
.row-list.archived .row-item { opacity: 0.55; }
.placeholder { color: var(--text-dim); text-align: center; margin: 8px 0; font-size: 15px; }

/* ---- Modal (add / edit editor) ---- */
.modal {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h2 { margin: 0; font-size: 20px; font-weight: 650; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13.5px; font-weight: 500; color: var(--text-dim); }
.field-opt { opacity: 0.7; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn { height: 48px; padding: 0 20px; border-radius: 999px; font-size: 15.5px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:active { background: var(--accent-press); }
.btn.ghost { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); }
.btn.ghost.danger-text { color: var(--danger); }   /* e.g. "Dismiss" in the emailed-receipt review */
/* Download all receipts: the progress bar */
.dl-count { margin: -6px 0 0; }
.dl-progress { display: flex; flex-direction: column; gap: 8px; }
.dl-progress .hint { margin: 0; }
.dl-track { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.dl-bar { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .25s ease; }
.btn.danger { background: none; color: var(--danger); border: 1px solid var(--danger); }

/* ---- Update-available banner ---- */
/* Sits just under the top bar, so it never covers the title or buttons; the top bar makes
   room for it below itself while it shows. */
body:has(#update-banner:not([hidden])) .app-header { margin-bottom: 62px; }
.update-banner {
  position: fixed;
  top: calc(66px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 420px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 8px 8px 16px;
  border-radius: 16px;
  z-index: 70;
  box-shadow: var(--shadow-sm);
}
.update-btn {
  background: var(--on-accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  flex: none;
}

/* ---- Units editor (inside the property modal) ---- */
.units-list { display: flex; flex-direction: column; gap: 8px; }
.units-size { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.units-size .unit-num input { text-align: left; }
.unit-row { display: flex; align-items: center; gap: 8px; }
.unit-row input { flex: 1; min-width: 0; height: 46px; }
.unit-remove {
  background: none;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.unit-remove:active { color: var(--danger); border-color: var(--danger); }
.btn-sm { height: 42px; font-size: 14px; padding: 0 14px; align-self: flex-start; }
.unit-card { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
.unit-card > input { height: 44px; }
.unit-fields { display: flex; gap: 8px; }
.unit-num { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.unit-num span { font-size: 12px; color: var(--text-dim); }
.unit-num input { height: 42px; width: 100%; text-align: right; }
.unit-ctrls { display: flex; gap: 8px; align-items: center; }
.unit-ctrls .unit-use { flex: 1; min-width: 0; }
.unit-share { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.unit-share-toggle, .unit-share-list label { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.unit-share-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 12px; }
.unit-share-list label { font-size: 13px; }

/* ---- Tax adjustments (inside the property modal) ---- */
.tax-adj { display: flex; flex-direction: column; gap: 8px; }
.tax-adj-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.tax-adj-row span { font-size: 14px; color: var(--text-dim); }
.tax-adj-row input { width: 92px; flex: none; height: 44px; text-align: right; }
#manage-prorate-rows { display: flex; flex-direction: column; gap: 8px; }
.manage-business-fields { display: flex; flex-direction: column; gap: 14px; }

/* ---- Capture: processing / saved overlays ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--veil);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 65;
  padding: 24px;
  text-align: center;
}
.overlay p { margin: 0; color: var(--text); font-size: 17px; }
.saved-check {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--pos);
  color: var(--bg-elev);
  font-size: 38px;
  display: flex; align-items: center; justify-content: center;
}
.saved-msg { font-size: 18px; }
.saved-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 280px; }
.saved-actions .btn { width: 100%; }

/* ---- Capture: confirm dialog fields ---- */
.confidence { margin: 0; font-size: 13px; font-weight: 550; padding: 8px 12px; border-radius: 12px; text-align: center; }
.confidence.high { background: var(--pos-soft); color: var(--pos); }
.confidence.medium { background: var(--warn-soft); color: var(--warn); }
.confidence.low { background: var(--danger-soft); color: var(--danger); }
.inbox-hint { margin: 0; font-size: 12.5px; line-height: 1.45; padding: 9px 12px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); border: none; }
/* Quick Exit/Later/Dismiss row under the preview during emailed-receipt review:
   three equal-width buttons that fill the row and auto-size to the viewport. */
.review-bar { display: flex; gap: 8px; align-items: stretch; }
.review-bar .btn { flex: 1 1 0; min-width: 0; padding: 10px 8px; font-size: 14px;
  text-align: center; justify-content: center; }
/* Email context (sender · subject · received date · open-in-Gmail) for review items. */
.email-meta { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: 12px;
  background: var(--hover); border: 1px solid var(--border); }
.email-meta .em-subject { font-weight: 600; font-size: 14px; line-height: 1.35; }
.email-meta .em-line { font-size: 12.5px; color: var(--text-dim); }

/* ---- Capture: possible-duplicate confirm ---- */
#dup-warning { z-index: 68; } /* above the open receipt editor (.modal = 60) */
.dup-list { display: flex; flex-direction: column; gap: 8px; }
.dup-item { border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.dup-item-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.dup-item-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* ---- Capture: receipt preview + full-screen zoom ---- */
.rc-preview {
  display: block;
  flex-shrink: 0; /* the modal card is a scrollable flex column — don't let the thumbnail get squished to nothing when the form overflows */
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg);
}
.rc-thumb { display: block; width: 100%; height: 140px; object-fit: cover; object-position: top; }
.rc-preview-hint { display: block; padding: 8px 10px; font-size: 13px; color: var(--text-dim); text-align: center; }

.zoom-overlay { z-index: 75; padding: 0; background: rgba(8, 12, 22, 0.96); }
.zoom-scroll {
  position: fixed;
  inset: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-overflow-scrolling: touch;
}
.zoom-img { max-width: 100%; max-height: 100%; cursor: zoom-in; }
.zoom-img.zoomed { max-width: none; max-height: none; width: auto; height: auto; cursor: zoom-out; }
.zoom-close {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  z-index: 2;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.zoom-overlay .zoom-hint {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 12px;
  border-radius: 999px;
  pointer-events: none;
}

/* In-app file viewer (saved receipts/income) — scrollable image / PDF pages. */
.fv-body {
  position: fixed;
  inset: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 8px calc(24px + env(safe-area-inset-bottom));
}
.fv-img, .fv-page {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}
.fv-status {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 15px;
}

/* ---- Spending graphs (charts) ---- */
.tracking-body { flex: 1; display: flex; flex-direction: column; gap: 22px; padding: 12px 0 16px; }
.track-section { display: flex; flex-direction: column; gap: 10px; }
.track-title { font-size: 17px; font-weight: 650; letter-spacing: -0.015em; margin: 0; }
.track-hint { text-align: center; color: var(--text-dim); font-size: 13px; margin: 0; padding-bottom: 2px; }
.chart-box {
  position: relative;
  height: 280px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px;
  cursor: pointer;
}
.chart-modal {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 80;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 14px env(safe-area-inset-bottom);
}
.chart-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px; }
.chart-modal-title { font-size: 16px; font-weight: 600; }
.chart-modal-body { flex: 1; min-height: 0; position: relative; }
.chart-rotate-hint { text-align: center; color: var(--text-dim); font-size: 13px; padding: 6px 0 2px; margin: 0; }
@media (orientation: landscape) { .chart-rotate-hint { display: none; } }

/* ---- Multi-select filter bar (spending graphs; reusable) ---- */
.filter-dd { position: relative; flex: 1; min-width: 0; }
.filter-dd-btn {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  text-align: left;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-dd-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
}
.filter-opt { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.filter-opt:active { background: var(--hover); }
.filter-opt input { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.filter-opt-prop { font-weight: 600; }
.filter-opt.unit { padding-left: 30px; font-weight: 400; color: var(--text-dim); }

/* ---- Summary (property -> unit -> category; income + spending) ---- */
.summary-body { display: flex; flex-direction: column; padding: 12px 0 16px; }
#summary-content { display: flex; flex-direction: column; gap: 8px; }
#summary-title, #checkup-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* select.* beats the later, equal-specificity `.select { width:100% }` rule. */
select.summary-year { flex: none; width: auto; min-width: 80px; max-width: 45%; height: 38px; padding: 0 10px; margin-left: 10px; }
select.summary-year.fiscal { min-width: 104px; }   /* a company's "FY2027" (scope.js) */
.sum-totals { display: flex; flex-direction: column; gap: 6px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px; }
.sum-tot { display: flex; justify-content: space-between; font-size: 15px; color: var(--text-dim); }
.sum-tot span:last-child { color: var(--text); font-weight: 600; }
.sum-tot.pos span:last-child { color: var(--pos); }
.sum-tot.neg span:last-child { color: var(--danger); }
.sum-section { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 12px 2px 2px; }
.sum-group { display: flex; flex-direction: column; gap: 2px; margin: 12px 2px 2px; }
.sum-group-title { flex: 1; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.sum-row { display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-sm); padding: 14px 16px; color: var(--text); }
.sum-row-btn { cursor: pointer; }
.sum-row-btn:active { background: var(--hover); }
.sum-head { display: flex; align-items: center; gap: 10px; }
.sum-name { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sum-amounts { font-weight: 600; flex: none; }
.sum-sub { font-size: 13px; color: var(--text-dim); }
.sum-bar { height: 6px; background: var(--track); border-radius: 999px; overflow: hidden; }
.sum-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.sum-net { font-weight: 700; font-size: 15px; flex: none; }
.sum-net.pos { color: var(--pos); }
.sum-net.neg { color: var(--danger); }

/* ---- Tax checkup ---- */
.checkup-banner { border-radius: 16px; padding: 14px 16px; font-size: 15px; font-weight: 600; }
.checkup-banner.ok { background: var(--pos-soft); border: none; color: var(--pos); }
.checkup-banner.warn { background: var(--warn-soft); border: none; color: var(--warn); }
.checkup-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-sm); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.checkup-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.checkup-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checkup-status { font-size: 13px; flex: none; }
.checkup-status.ok { color: var(--pos); }
.checkup-status.warn { color: var(--warn); }
.checkup-issues { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.checkup-issue { font-size: 14px; color: var(--text-dim); }
.checkup-issue.ok { color: var(--pos); }
.checkup-dup { display: block; width: 100%; text-align: left; font-size: 14px; padding: 8px 10px;
  border-radius: 12px; color: var(--warn); background: var(--warn-soft);
  border: none; }
.checkup-dup:hover { filter: brightness(0.97); }
.checkup-foot { font-size: 12px; color: var(--text-dim); margin: 4px 2px 0; }

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }

.money-input {
  display: flex;
  align-items: center;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
}
.money-input .dollar { color: var(--text-dim); font-size: 18px; flex: none; }
.money-input input {
  border: none;
  background: none;
  height: 52px;
  width: 100%;
  min-width: 0;
  padding: 0 0 0 8px;
  font-size: 17px;
  color: var(--text);
}
.money-input input:focus { outline: none; box-shadow: none; }
.money-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* Low-confidence read: nudge the eye to double-check the amount. */
.money-input.attention { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

.select {
  width: 100%;
  height: var(--tap);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  padding: 0 14px;
  font-family: inherit;
  font-size: 16px;
}
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select:disabled { opacity: 0.5; cursor: default; }

/* Segmented control: one soft pill track, the chosen side raised in white. */
.segmented { display: flex; gap: 0; padding: 4px; background: var(--chip); border-radius: 999px; }
.seg {
  flex: 1;
  height: 40px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
}
.seg.active { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 3px rgba(16, 18, 24, 0.12); }
.hint { font-size: 13px; color: var(--text-dim); }

/* A separate company's books are open (scope.js): says whose, with Close. */
.scope-bar { width: 100%; margin-bottom: 12px; }
.books-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: none; border-radius: 16px; background: var(--accent-soft);
}
.books-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.books-bar-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.books-bar-text span { font-size: 13px; color: var(--text-dim); }
.books-bar .btn { flex: none; align-self: center; }

/* iOS centers date inputs by default — left-align the value to match the other fields. */
#rc-date, #rd-date, #rc-invoice-date, #ie-date, #manage-gst-from { -webkit-appearance: none; appearance: none; text-align: left; }
#rc-date::-webkit-date-and-time-value,
#rd-date::-webkit-date-and-time-value { text-align: left; margin: 0; }

/* ---- Receipts list ---- */
.receipts-body { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-top: 6px; padding-bottom: 24px; }
.filters { display: flex; gap: 10px; }
.filters .select { flex: 1; min-width: 0; }
.search-input {
  width: 100%;
  height: 48px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 0 18px;
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.receipts-total { color: var(--text-dim); font-size: 14px; padding: 0 2px; }
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-group { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 4px 0; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.tx-group:first-child { padding-top: 0; }
.tx-group-sum { font-weight: 600; color: var(--text); }
/* Per-property colour swatch (propcolors.js) — used across cards, lists, summary. */
.prop-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; margin-right: 7px; vertical-align: middle; }
.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 13px 16px;
  color: var(--text);
  text-align: left;
  width: 100%;
}
.tx-row:active { border-color: var(--accent); }
.tx-main { flex: 1; min-width: 0; }
.tx-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.tx-vendor { font-size: 15.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amount { font-size: 16px; font-weight: 650; flex: none; }
.tx-sub { font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }

/* ---- Mileage: Google Maps link ---- */
.maps-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  padding: 4px 0 0;
  align-self: flex-start;
}
.maps-link:active { color: var(--accent-press); }

/* ---- Unit cards (use type) + manual-entry link ---- */
.unit-card { display: flex; flex-direction: column; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 10px; }
.unit-ctrls { display: flex; align-items: center; gap: 8px; }
.unit-ctrls .unit-use { flex: 1; min-width: 0; height: 44px; font-size: 14px; }

/* ---- Offline-capture queue banner ---- */
.queue-banner {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  /* The same width as Home's cards, so it lines up with them instead of a squeezed pill. */
  width: min(calc(100% - 32px), 420px);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--warn);
  color: var(--bg-elev);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  padding: 10px 10px 10px 18px;
  border-radius: 16px;
  z-index: 55;
  box-shadow: var(--shadow-lg);
}
.queue-banner > span { flex: 1; min-width: 0; }
.queue-banner .update-btn { flex: none; background: var(--bg-elev); color: var(--warn); }

/* Emailed receipts waiting: a full-width banner under Add receipt, shown only while there are some.
   The bell and the Emailed tile check for more, so it has no refresh button of its own. */
.inbox-overlay[hidden] { display: none; }
.inbox-overlay { display: flex; align-items: stretch; min-height: 52px; width: 100%; }
.inbox-review {                                   /* the big blue Review action */
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 16px;
  font-size: 15px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.inbox-review:active { filter: brightness(0.97); }
.inbox-card-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-card-cta { flex: none; }

/* Graph drill-down: the entries behind a tapped month bar. */
.drill-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drill-head h2 { margin: 0; font-size: 18px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.drill-body { display: flex; flex-direction: column; gap: 8px; }

/* ============================================================================
   Motion & interaction polish. All gated behind prefers-reduced-motion so it's
   fully off for users who ask for less motion.
   ============================================================================ */
@media (prefers-reduced-motion: no-preference) {
  /* Smooth, fast feedback on the things you tap. */
  .btn, .add-receipt, .home-tile, .tab, .home-card, .seg, .menu-item, .icon-btn,
  .tx-row, .sum-row-btn, .row-main, .filter-dd-btn, .select, .search-input,
  input, .rc-preview, .switch, .switch-thumb {
    transition: background-color .13s ease, border-color .13s ease,
      color .13s ease, box-shadow .13s ease, transform .08s ease;
  }
  /* A small tactile "give" on press. */
  .add-receipt:active, .btn:active, .home-tile:active, .home-card:active,
  .menu-item:active, .tx-row:active, .sum-row-btn:active, .seg:active,
  .icon-btn:active, .filter-dd-btn:active { transform: scale(.98); }

  /* Entrances — fade the backdrop, pop the card, slide the toasts. */
  .screen:not([hidden]) { animation: fadeIn .18s ease; }
  .modal:not([hidden]), .overlay:not([hidden]) { animation: fadeIn .15s ease; }
  .modal:not([hidden]) .modal-card { animation: cardIn .18s cubic-bezier(.2,.8,.2,1); }
  .menu:not([hidden]) { animation: menuIn .14s cubic-bezier(.2,.8,.2,1); transform-origin: top right; }
  .undo-toast:not([hidden]), .toast:not([hidden]) { animation: dropIn .2s cubic-bezier(.2,.7,.3,1); }
  .sync-status:not([hidden]) { animation: dropInC .2s ease; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes cardIn { from { transform: translateY(10px) scale(.97); } to { transform: none; } }
@keyframes menuIn { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes dropInC { from { opacity: 0; transform: translate(-50%, -12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Pointer (desktop) hover cues — never on touch, so rows don't get "stuck". */
@media (hover: hover) {
  .icon-btn:hover { color: var(--text); background: var(--hover); }
  .menu-item:hover, .filter-dd-btn:hover { background: var(--hover); }
  .home-tile:hover, .home-card:hover, .tx-row:hover, .sum-row-btn:hover { border-color: var(--accent); }
  .tab:hover { color: var(--text); }
  .btn.primary:hover { background: var(--accent-press); }
}

/* Header icon buttons -> comfortable 44px touch targets. */
.icon-btn { padding: 11px; }
.header-spacer { width: 44px; }

/* Roomier columns on laptops / desktops / large tablets.
   Content/list screens get a wider column and their lists flow into two columns
   instead of stretching into sparse wide rows. Home breathes a bit wider too (its
   column, not phone-pinned at 360); login stays phone-width. Phones / portrait
   tablets (< 760px) are untouched. Self-contained — delete this block to revert. */
@media (min-width: 760px) {
  #screen-manage, #screen-receipts, #screen-income,
  #screen-summary, #screen-checkup, #screen-graphs { max-width: 920px; }

  /* minmax(0, 1fr), not 1fr: see the Manage lists below. A long vendor would otherwise
     widen its column and push the row past the edge of the list. */
  #receipts-list, #income-list {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; align-content: start;
  }
  #receipts-list .tx-group, #income-list .tx-group { grid-column: 1 / -1; }

  /* Two equal columns where the longest category names fit on one line (480px each), one
     column below that. A plain 1fr track instead grows to fit its longest unbroken line
     (rows never wrap), which made the columns unequal and pushed long addresses past the
     edge of the section. grid-auto-rows keeps every row in a list the same height, with
     or without a sub-line. */
  #screen-manage { max-width: 1040px; }
  #prop-list, #cat-list, #people-list, #prop-archived, #cat-archived, #people-archived {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); grid-auto-rows: 1fr; gap: 10px;
  }
  #cat-list { grid-auto-rows: auto; }   /* its group headings are shorter than a row */

  /* Home dashboard column: a bit wider on PC. */
  .home-body > * { max-width: 520px; }
}

/* ---- Manage → Emailed receipts (Stage 5) ---- */
.sub-head { margin: 6px 2px 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.email-add-row { display: flex; gap: 8px; align-items: center; }
.email-add-row input { flex: 1; min-width: 0; font-size: 15px; }
#email-add-me { align-self: flex-start; }
.email-gmail-row { border-color: var(--accent); flex-wrap: wrap; }
.email-gmail-row .row-info { flex-basis: 100%; }
.email-gmail-row .row-name, .email-gmail-row .row-sub { white-space: normal; }
#email-addresses .row-name { font-variant-ligatures: none; }
.email-howto { font-size: 14px; color: var(--text); }
.email-howto summary { cursor: pointer; color: var(--accent); font-weight: 550; padding: 4px 0; }
.email-howto ol { margin: 6px 0 8px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.4; }
.email-name-row { display: flex; align-items: center; gap: 6px; }
.email-name-row input { flex: 1; min-width: 0; }
.email-name-domain { color: var(--text-dim); font-size: 15px; flex: none; }
