@font-face { font-family: 'Cormorant Garamond'; font-style: italic; font-weight: 600; font-display: swap; src: url('../fonts/cormorant-garamond-latin-600-italic.woff2') format('woff2'); }
/* Perisso themes. Luxe (default): charcoal with warm gold sampled from the gold P logo. Ivory: light alternative.
 * All text/background pairs below were checked for WCAG AA contrast (4.5:1 or better). */
:root, :root[data-theme="luxe"] {
  --bg: #131617; --panel: #1c2022; --panel2: #262b2e; --text: #f6f1e7; --muted: #bdb6a8; --line: #3b4145;
  --accent: #d9c08f; --accent-ink: #16191b; --accent-soft: #2e2a20; --neg: #ff9d92; --neg-soft: #3a2123; --pos: #8fd6a6;
  --hi: #8fd6a6; --lo: #eac46b; --today: #d9c08f; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
  --gold-deep: #b29a73; --gold-hi: #f4e6c4;
  --r: 14px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
:root[data-theme="ivory"] {
  --bg: #f7f3ea; --panel: #fffdf8; --panel2: #efe9db; --text: #1d1b17; --muted: #5a5447; --line: #d9cfb8;
  --accent: #7c5b1c; --accent-ink: #ffffff; --accent-soft: #efe3c6; --neg: #a8281f; --neg-soft: #fbe3df; --pos: #1d6a38;
  --hi: #1d6a38; --lo: #8a5a00; --today: #7c5b1c; --shadow: 0 1px 2px rgba(60,45,10,.08), 0 4px 16px rgba(60,45,10,.08);
  --gold-deep: #7c5b1c; --gold-hi: #7c5b1c;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
body { padding-bottom: env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* stop iOS zoom */
button { cursor: pointer; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.neg { color: var(--neg); } .pos { color: var(--pos); } .muted { color: var(--muted); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Cormorant Garamond', 'Playfair Display', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif; font-style: italic; font-weight: 600; font-size: 28px; line-height: 1; letter-spacing: .02em; color: var(--accent); }
.brand img { flex: none; }
.brand span, .topbar .brand::after { padding-bottom: 3px; }
.brand img { border-radius: 7px; }
.mainnav { display: flex; gap: 4px; margin-left: 16px; flex: 1; }
.mainnav button, .tabs button { border: 0; background: transparent; padding: 7px 12px; border-radius: 999px; color: var(--muted); }
.mainnav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.mainnav button:hover { color: var(--text); }
.iconbtn { border: 1px solid var(--line); background: var(--panel); color: var(--accent); border-radius: 999px; width: 38px; height: 38px; font-size: 16px; }
.topright { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--neg); color: var(--bg); font-weight: 700; font-size: 11px; line-height: 18px; text-align: center; }

/* account tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; min-width: 110px; }
.tabs button .n { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tabs button .b { font-weight: 600; font-size: 14px; }
.tabs button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tabs button .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

main { padding: 0 16px 24px; max-width: 1400px; margin: 0 auto; }
.view { display: none; } .view.active { display: block; }

/* calendar */
.calwrap { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.calnav { display: flex; align-items: center; gap: 6px; margin: 4px 0 10px; flex-wrap: wrap; }
.calnav h2 { margin: 0 6px; font-size: 20px; font-weight: 650; cursor: pointer; min-width: 170px; }
.calnav h2:hover { color: var(--accent); }
.btn { white-space: nowrap; border: 1px solid var(--line); background: var(--panel2); color: var(--text); border-radius: 10px; padding: 8px 14px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--neg); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.spacer { flex: 1; }
.monthpick { position: relative; }
.monthpick input { position: absolute; inset: 0; opacity: 0; width: 100%; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.grid .dow { background: var(--panel2); padding: 6px 8px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.day { background: var(--panel); min-height: 118px; padding: 6px 7px 24px; position: relative; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.day:hover { background: color-mix(in srgb, var(--panel) 85%, var(--accent-soft)); }
.day.other { background: var(--panel2); opacity: .72; }
.day .dn { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.day.today .dn span { background: var(--today); color: var(--accent-ink); border-radius: 999px; padding: 0 7px; }
.day .bm { color: var(--accent); font-size: 13px; }
.day .it { font-size: 12.5px; display: flex; justify-content: space-between; gap: 4px; white-space: nowrap; overflow: hidden; }
.day .it .t { overflow: hidden; text-overflow: ellipsis; }

.day .more { font-size: 11px; color: var(--muted); }
.day .bal { position: absolute; left: 7px; right: 7px; bottom: 5px; font-size: 14px; font-weight: 700; text-align: right; }
.day.negday { background: var(--neg-soft); }
.day.negday .bal { color: var(--neg); }
.day .tag { position: absolute; right: 6px; top: 6px; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 6px; }
.day .tag.hi { background: color-mix(in srgb, var(--hi) 18%, transparent); color: var(--hi); }
.day .tag.lo { background: color-mix(in srgb, var(--lo) 22%, transparent); color: var(--lo); }
.dots { display: none; gap: 2px; flex-wrap: wrap; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.dots i.p { background: var(--pos); } .dots i.n { background: var(--neg); }

/* side panel */
.side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 72px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font-size: 13.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold-deep); font-weight: 650; }
:root[data-theme="luxe"] .card h3 { color: var(--accent); }
.kv { display: flex; justify-content: space-between; padding: 3px 0; gap: 10px; }
.kv.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 650; }
.catrow { padding: 7px 0; border-bottom: 1px solid var(--line); }
.catrow:last-child { border-bottom: 0; }
.catrow .top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.catrow .top .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catrow .sub { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin: 4px 0 2px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar i.over { background: var(--neg); }
.bar i.inc { background: var(--pos); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--panel2); color: var(--text); padding: 7px 14px; }
.seg button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* lists */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .ttl { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.click { cursor: pointer; } .row.click:hover { background: var(--panel2); }
.row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel2); color: var(--muted); }

/* alerts */
.alert { border-left: 4px solid var(--muted); }
.alert.high { border-left-color: var(--neg); } .alert.medium { border-left-color: var(--lo); } .alert.low { border-left-color: var(--accent); }
.alert h4 { margin: 0 0 4px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: var(--panel2); border-radius: 999px; padding: 3px 9px; font-size: 12.5px; }

/* reports */
.reports { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chartbox { position: relative; height: 320px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 14px; }

/* forms */
.form { display: grid; gap: 12px; }
.field label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field input, .field select, .field textarea, .inp { width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 9px; padding: 9px 10px; }
.field textarea { min-height: 64px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl td, .tbl th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl input, .tbl select { width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 7px; padding: 5px 7px; font-size: 14px; }
.tbl td.r, .tbl th.r { text-align: right; }
.note { font-size: 13.5px; color: var(--muted); }
.empty { text-align: center; padding: 48px 16px; }
.empty h2 { margin: 0 0 6px; }

/* modal sheet */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 5, 6, .72); }
.sheet { position: relative; background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--accent); border-radius: 16px; width: min(560px, 94vw); max-height: 90vh; overflow: auto; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.sheet h2 { margin: 0 0 4px; font-size: 19px; }
.sheet .hd { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.sheet .hd .grow { flex: 1; }
.x { border: 0; background: var(--panel2); color: var(--text); width: 34px; height: 32px; border-radius: 50%; font-size: 18px; line-height: 1; }
.toast { pointer-events: none; position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60; font-size: 14px; max-width: 90vw; }

.bottomnav { display: none; }

@media (max-width: 1000px) {
  .calwrap { grid-template-columns: 1fr; }
  .side { position: static; }
  .reports { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  html, body { font-size: 15px; }
  .mainnav, .topbar .brand span { display: none; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar .brand::after { content: 'Perisso'; }
  .brand { font-size: 26px; }
  main { padding: 0 8px calc(84px + env(safe-area-inset-bottom)); }
  .tabs { padding: 8px; }
  .tabs button { min-width: 96px; padding: 5px 10px; }
  .calnav h2 { font-size: 17px; min-width: 0; flex: 1; text-align: center; }
  .calnav .wide { display: none; }
  .grid { border-radius: 10px; }
  .grid .dow { padding: 4px 2px; text-align: center; font-size: 10.5px; }
  .day { min-height: 76px; padding: 4px 2px 20px; align-items: center; }
  .day .it, .day .more { display: none; }
  .dots { display: flex; justify-content: center; }
  .day .bal { font-size: 11px; font-weight: 700; left: 0; right: 0; text-align: center; bottom: 3px; letter-spacing: -.3px; }
  .day .tag { display: none; }
  .day.hiday { box-shadow: inset 0 -3px 0 var(--hi); } .day.loday { box-shadow: inset 0 -3px 0 var(--lo); }
  .day.negday.loday { box-shadow: inset 0 -3px 0 var(--neg); }
  .sheet { width: 100vw; max-height: 92vh; border-radius: 16px 16px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .modal { align-items: flex-end; }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav button { flex: 1; border: 0; background: transparent; padding: 7px 0 6px; font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 1px; position: relative; }
  .bottomnav button span { font-size: 18px; line-height: 1.1; }
  .bottomnav button.active { color: var(--accent); font-weight: 600; }
  .bottomnav .dot { position: absolute; top: 6px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--neg); }
  .settings { grid-template-columns: 1fr; }
  .chartbox { height: 280px; }
  .two { grid-template-columns: 1fr; }
}

/* cloud sync + selection bar */
.sync-ok { color: var(--pos); } .sync-error { color: var(--neg); } .sync-syncing, .sync-pending { color: var(--muted); }
.selbar { position: sticky; top: 56px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding: 8px 10px; background: var(--accent-soft); border-radius: 10px; }

/* envelopes */
.envlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 12px 0; }
.envlist .card { margin: 0; }
.envhd { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.envhd .sw { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.envhd .spacer { flex: 1; }
.envgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.envgrid .big { font-size: 20px; font-weight: 650; }

/* luxe details */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: .8; }
.num { font-weight: 600; }
.tabs button .b { font-size: 16px; font-weight: 700; }
.tabs button .n { font-size: 13px; }
.tabs button.active { background: var(--accent-soft); }
.bottomnav { box-shadow: 0 -6px 18px rgba(0,0,0,.25); }
.topbar { background: color-mix(in srgb, var(--bg) 94%, transparent); }
.day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.envgrid .big { font-size: 24px; font-weight: 700; }
.kv.total, .kv b { font-weight: 700; }
.row .num, .catrow .num { font-weight: 650; }

/* advanced import (collapsed) */
details.adv summary { cursor: pointer; list-style: none; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary h3 { display: inline; margin: 0; }
details.adv summary::after { content: ' ▾'; color: var(--muted); }
details.adv[open] summary { margin-bottom: 10px; }

/* setup guide */
.guide { max-width: 760px; margin: 8px auto 24px; }
.guidehd { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.guidehd h2 { margin: 6px 0 4px; font-size: 24px; font-weight: 650; color: var(--gold-hi); }
:root[data-theme="ivory"] .guidehd h2 { color: var(--text); }
.progress { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin: 8px 0 16px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.step { display: flex; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.step.done { border-color: color-mix(in srgb, var(--pos) 45%, var(--line)); }
.stepno { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.step.done .stepno { background: var(--pos); color: var(--accent-ink); border-color: var(--pos); }
.stepbody { flex: 1; min-width: 0; }
.stepbody h3 { margin: 4px 0 6px; font-size: 17px; font-weight: 650; text-transform: none; letter-spacing: 0; color: var(--text); }
:root[data-theme="luxe"] .stepbody h3 { color: var(--text); }
.steptext { color: var(--muted); font-size: 15px; }
.steptext b { color: var(--text); }
ul.plain { margin: 0; padding-left: 18px; } ul.plain li { margin: 4px 0; }

.sync-signedout { border-style: dashed; color: var(--muted); }

/* categories, colour coding, quick panel */
.cdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; flex: none; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 25%, transparent); }
.day .it { border-left: 3px solid transparent; padding-left: 4px; }
.dots i.c { background: var(--muted); }
.cfield .swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 30%, transparent); display: inline-flex; align-items: center; justify-content: center; position: relative; color: var(--bg); font-weight: 700; }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.swatch.none { background: var(--panel2); color: var(--muted); font-size: 11px; width: auto; border-radius: 15px; padding: 0 10px; }
.swatch.custom { background: conic-gradient(#d9776a, #e0b84f, #7aa874, #5b9bd5, #a47fd0, #d9776a); overflow: hidden; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; padding: 0; border: 0; }
.swatch.custom span { pointer-events: none; font-size: 16px; text-shadow: 0 0 3px rgba(0,0,0,.5); color: #fff; }
.catitem { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.catitem .sw { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 30%, transparent); }
.catitem .ic { width: 22px; text-align: center; flex: none; }
.catitem .grow { flex: 1; min-width: 0; } .catitem .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catitem .sub { font-size: 12.5px; color: var(--muted); }
.catitem .acts { display: flex; gap: 6px; flex: none; }
.fab { position: fixed; right: 22px; bottom: 22px; z-index: 40; width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--gold-deep, var(--accent)); background: var(--accent); color: var(--bg); display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.4); cursor: pointer; }
.fab:hover { filter: brightness(1.08); }
.fabpanel { position: fixed; right: 22px; bottom: 84px; z-index: 40; width: min(340px, calc(100vw - 28px)); max-height: min(70vh, 520px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 12px; }
.fabpanel h3 { margin: 0 0 8px; font-size: 16px; display: flex; align-items: center; }
.fabpanel .addrow { display: flex; gap: 6px; margin-bottom: 8px; } .fabpanel .addrow input { flex: 1; min-width: 0; } .fabpanel .addrow select { width: auto; }
.fabpanel .catitem { padding: 6px 2px; } .fabpanel .catitem .x { border: 0; background: transparent; color: var(--neg); font-size: 20px; line-height: 1; padding: 2px 8px; cursor: pointer; }
.morepanel { display: none; }
@media (max-width: 700px) {
  .fab { right: 14px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 48px; height: 48px; }
  .fabpanel { right: 14px; bottom: calc(132px + env(safe-area-inset-bottom)); }
  .morepanel:not([hidden]) { display: flex; flex-direction: column; position: fixed; right: 8px; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 45; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; min-width: 190px; }
  .morepanel button { display: flex; align-items: center; gap: 12px; border: 0; background: transparent; color: var(--text); padding: 12px 14px; font-size: 15px; text-align: left; border-radius: 10px; }
  .morepanel button.active { color: var(--accent); font-weight: 600; background: var(--panel2); }
  .morepanel button span { width: 20px; text-align: center; color: var(--accent); }
  .bottomnav button.active, #moreBtn.active { color: var(--accent); font-weight: 600; }
}
@media (min-width: 701px) { main { padding-bottom: 84px; } }
.fabpanel input, .fabpanel select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font: inherit; }
.fabpanel input:focus, .fabpanel select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* envelopes page */
.envlist { display: block; margin: 12px 0; }
.envlist .card, .envcard { margin: 0 0 16px; padding: 16px 18px; }
.envhd { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.envhd h3 { margin: 0; font-size: 19px; } .envhd .sw { width: 13px; height: 13px; border-radius: 50%; flex: none; }
.etotal { border: 1px solid var(--accent); border-radius: var(--r); padding: 10px 14px 6px; margin-bottom: 14px; background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.etlabel, .etname { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--accent); font-weight: 700; }
.etotal .erow:first-of-type { border-top: 0; }
.egrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.etile { border: 1px solid var(--line); background: var(--panel2); border-radius: var(--r); padding: 12px 14px 6px; min-width: 0; }
.etile.unal { background: transparent; border-style: dashed; } .etile.unal .etname { color: var(--muted); } .etile.unal .num { opacity: .85; }
.etile-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.etname { color: var(--text); font-size: 14px; letter-spacing: .04em; text-transform: none; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.erow { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 8px 0; border-top: 1px solid var(--line); }
.erow .lb { color: var(--muted); font-size: 13.5px; flex: none; }
.erow .vl { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; }
.erow .vl b, .erow .vl > .num { font-size: 17px; font-weight: 650; } .erow .vl small { font-size: 12px; margin-top: 1px; }
.etotal .erow .vl b { font-size: 20px; }
.menuwrap { position: relative; flex: none; }
.kebab { border: 1px solid var(--line); background: transparent; color: var(--text); width: 34px; height: 30px; border-radius: 9px; font-size: 18px; line-height: 1; cursor: pointer; }
.kebab:hover, .kebab[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 170px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 5px; display: flex; flex-direction: column; }
.menu.up { top: auto; bottom: calc(100% + 4px); } .menu[hidden] { display: none; }
.menu button { border: 0; background: transparent; color: var(--text); text-align: left; padding: 10px 12px; border-radius: 8px; font-size: 14.5px; cursor: pointer; }
.menu button:hover { background: var(--panel2); } .menu button.danger { color: var(--neg); }
.envfield { border-left: 3px solid var(--accent); padding-left: 10px; }
@media (max-width: 700px) { .egrid { grid-template-columns: 1fr; } .envcard { padding: 14px 12px; } .erow .vl b, .erow .vl > .num { font-size: 16px; } }

/* investments */
.hold .hsym { font-weight: 700; font-size: 18px; margin-right: 8px; letter-spacing: .02em; } .hold .hsub { font-size: 13px; margin-top: 2px; }
.hold .hname { min-width: 0; } .hold .erow .vl small { max-width: 220px; }
.hold .note { margin: 4px 0 8px; }
ul.plain { margin: 0; padding-left: 18px; } ul.plain li { margin: 6px 0; line-height: 1.5; }
.catlist { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; } .catitem.pick { width: 100%; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); cursor: pointer; }
.catitem.pick:hover { border-color: var(--accent); }
.addrow { display: flex; gap: 8px; } .addrow input { flex: 1; min-width: 0; }

.picklist { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.picklist .check { margin: 0; }
ul.plain a, .hold a, .note a { color: var(--accent); text-decoration: underline; }

/* category groups */
.cgroup { margin: 0 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.cgroup .cghead { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: grab; }
.cgroup .cghead .sw { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.cgroup .cghead .nm { font-weight: 600; color: var(--accent); }
.cgroup .cghead .sub { font-size: .8rem; color: var(--muted); }
.cgroup .chev { background: none; border: 0; color: var(--muted); font-size: 1rem; width: 28px; height: 28px; cursor: pointer; }
.cgroup .cgbody .catitem { padding-left: 14px; }
.cgroup .grip { color: var(--muted); cursor: grab; letter-spacing: -2px; user-select: none; }
.cgroup .dropon { outline: 2px dashed var(--accent); outline-offset: -2px; }
.cgroup .dragging { opacity: .45; }
.cgroup .acts .btn[disabled] { opacity: .35; }
.rowgroup { max-width: 120px; font-size: .8rem; }
.card > .seg { margin: 4px 0 8px; }
table.tbl th.r, table.tbl td.r { text-align: right; }
@media (max-width: 700px) {
  .cgroup .catitem, .cgroup .cghead { flex-wrap: wrap; }
  .cgroup .catitem .grow, .cgroup .cghead .grow { flex: 1 1 140px; min-width: 0; }
  .cgroup .catitem .acts, .cgroup .cghead .acts { flex: 1 1 100%; display: flex; justify-content: flex-end; gap: 6px; }
}
#qcustom { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } #qcustom[hidden] { display: none; }

/* completed entries: Tick and fade (default) / Cross out / Tick only. Set in Settings; read from html[data-done]. */
.tick { color: var(--accent); font-weight: 700; margin-right: 4px; font-size: .9em; }
.day .it .tick { font-size: .8em; margin-right: 2px; }
input[type=checkbox] { accent-color: var(--accent); }
.row.done .ttl, .row.done .meta, .row.done .num, .day .it.done, .day .dots i.dn { transition: opacity .15s; }
html[data-done=fade] .row.done > .grow, html[data-done=fade] .row.done > .num, html[data-done=fade] .day .it.done, html[data-done=fade] .dots i.dn { opacity: .55; }
html[data-done=fade] .row.done > .grow .tick, html[data-done=fade] .row.done > .grow .tick { opacity: 1; }
html[data-done=cross] .row.done .ttl, html[data-done=cross] .day .it.done .t { text-decoration: line-through; }
html[data-done=cross] .row.done > .grow, html[data-done=cross] .day .it.done { opacity: .75; }
html[data-done=cross] .tick { display: none; }
html[data-done=tick] .row.done, html[data-done=tick] .day .it.done { opacity: 1; }
.row .bin { background: none; border: 0; cursor: pointer; font-size: 1.05rem; padding: 8px; margin: -4px -6px -4px 0; border-radius: 8px; opacity: .65; line-height: 1; flex: none; }
.row .bin:hover, .row .bin:focus-visible { opacity: 1; background: var(--neg-soft); }

/* Envelopes v5: a plain list. One row per envelope (name left, today's balance right); tap a row for the look-ahead balance and actions. */
#view-envelopes .envlist { max-width: 760px; }
#view-envelopes .envacc { max-width: 760px; margin: 0 0 34px; }
#view-envelopes .envhd { display: flex; align-items: center; gap: 10px; padding: 0 2px 10px; }
#view-envelopes .envhd h3 { margin: 0; font-size: 1rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
#view-envelopes .envhd .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
#view-envelopes .btn.ghost { background: none; border-color: transparent; color: var(--muted); }
#view-envelopes .btn.ghost:hover { color: var(--accent); }
.erow2 { border-top: 1px solid var(--line); }
.erow2:last-child { border-bottom: 1px solid var(--line); }
.erow2 .ehead { display: flex; align-items: center; gap: 12px; width: 100%; padding: 16px 4px; background: none; border: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.erow2 .ehead:hover .en { color: var(--accent); }
.erow2 .en { flex: 1; min-width: 0; font-size: 1.05rem; }
.erow2 .ev { font-size: 1.1rem; font-weight: 600; text-align: right; }
.erow2 .ech { color: var(--muted); transition: transform .15s; width: 14px; text-align: center; }
.erow2 .ehead[aria-expanded=true] .ech { transform: rotate(90deg); }
.erow2.etot .en { color: var(--muted); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.erow2.etot .ev { font-size: 1.25rem; }
.erow2.unal .en, .erow2.unal .ev { color: var(--muted); font-weight: 400; }
.erow2 .edetail { padding: 0 4px 18px; }
.erow2 .edetail dl { margin: 0 0 12px; }
.erow2 .edetail dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; color: var(--muted); }
.erow2 .edetail dd { margin: 0; text-align: right; color: var(--text); }
.erow2 .edetail small { display: block; }
.erow2 .eacts { display: flex; flex-wrap: wrap; gap: 8px; }
details.lookahead { max-width: 760px; margin: 0 0 18px; color: var(--muted); font-size: .9rem; }
details.lookahead summary { cursor: pointer; list-style: none; padding: 4px 2px; }
details.lookahead summary::-webkit-details-marker { display: none; }
details.lookahead summary b { color: var(--text); font-weight: 600; }
details.lookahead[open] summary .muted { display: none; }

.sav { color: var(--accent); font-weight: 600; }
.catrow .sub.hint { color: var(--lo, #e0a64a); font-size: .78rem; margin-top: 2px; }

/* v5: inline Day panel */
.day.sel { background: color-mix(in srgb, var(--accent) 13%, var(--panel)); box-shadow: inset 0 0 0 2px var(--accent); }
.side#dayPanel { max-height: calc(100vh - 88px); overflow-y: auto; }
.dp { padding: 14px; }
.dp .dphd h3 { margin: 0 0 2px; font-size: 1.05rem; }
.dp .dphd { margin-bottom: 10px; }
.qa { display: flex; flex-direction: column; gap: 8px; padding: 10px; margin: 0 -4px 8px; background: var(--panel2); border-radius: 12px; }
.qa .qa1 { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.qa .qa2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.qa .qa2[hidden], .qa [hidden] { display: none; }
.qa input, .qa select { width: 100%; min-width: 0; padding: 8px 9px; font-size: 14px; }
.qa .qamt { text-align: right; }
.qa .qabtns { display: flex; gap: 6px; justify-content: flex-end; }
.qa .qabtns .btn { padding: 8px 12px; }
.qa .qabtns .primary { flex: 1; }
.dp .list { margin-top: 4px; }
.dp .bmk { margin-top: 10px; font-size: 14px; color: var(--muted); }
.dp .bmk summary { cursor: pointer; }
.dp .row { padding: 9px 2px; gap: 8px; }
.dp .row .num { white-space: nowrap; }
@media (max-width: 1000px) { .side#dayPanel { max-height: none; overflow: visible; } }

/* v5: reorder accounts */
#accountTabs .reorderbtn { flex: none; background: none; border: 1px dashed var(--line); color: var(--muted); border-radius: 10px; padding: 6px 10px; cursor: pointer; }
#accountTabs .reorderbtn:hover { color: var(--text); border-color: var(--accent); }
#accountTabs button[draggable=true][data-acc]:not([data-acc=all]) { cursor: grab; }
#accountTabs .dropb { box-shadow: -3px 0 0 var(--accent); } #accountTabs .dropa { box-shadow: 3px 0 0 var(--accent); }
.rord .row { cursor: grab; } .rord .grip, .accmv .grip { color: var(--muted); cursor: grab; padding: 0 6px; user-select: none; }
.row.dropb, tr.dropb { box-shadow: inset 0 2px 0 var(--accent); } .row.dropa, tr.dropa { box-shadow: inset 0 -2px 0 var(--accent); }
.row.dragging, tr.dragging { opacity: .5; }
.accmv .btn.sm { padding: 2px 6px; font-size: 11px; line-height: 1.2; }

#accTbl td { vertical-align: middle; padding: 6px 6px; }
#accTbl input[data-f=name] { min-width: 150px; }
#accTbl select[data-f=type] { width: auto; min-width: 170px; margin-top: 0 !important; }
#accTbl td .btn.sm { vertical-align: middle; }
#accountTabs .reorderbtn { align-self: center; padding: 8px 12px; }
#accountTabs .reorderbtn { min-width: 0 !important; width: auto; flex-direction: row; align-items: center; font-size: 16px; }

/* v5: hover preview, the day cell opens out in place */
.calwrap > div:first-child { position: relative; }
.dayhover { position: absolute; z-index: 40; pointer-events: auto; cursor: pointer; box-sizing: border-box; padding: 8px 10px 9px; background: var(--panel); border: 1.5px solid var(--accent); border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .45), 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent); font-size: 12.5px; line-height: 1.3; animation: dhin .12s ease-out; }
@keyframes dhin { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.dayhover .dh-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.dayhover .dh-n { font-size: 15px; } .dayhover .dh-bal { font-weight: 650; }
.dayhover .dh-sub { font-size: 11px; margin: 0 0 4px; }
.dayhover .dh-it { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 6px; align-items: start; padding: 3px 0 3px 6px; border-left: 3px solid transparent; border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.dayhover .dh-it:first-of-type { border-top: 0; }
.dayhover .dh-c { width: 12px; height: 12px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--muted); box-sizing: border-box; display: inline-block; position: relative; }
.dayhover .dh-it.done .dh-c { background: var(--accent); border-color: var(--accent); }
.dayhover .dh-it.done .dh-c::after { content: '✓'; position: absolute; inset: -2px 0 0 0; text-align: center; font-size: 9px; font-weight: 800; color: var(--accent-ink); line-height: 14px; }
.dayhover .dh-t { white-space: normal; overflow-wrap: anywhere; font-weight: 550; }
.dayhover .dh-mv { color: var(--muted); font-size: 11px; margin-left: 2px; }
.dayhover .num { white-space: nowrap; font-weight: 650; }
.dayhover .dh-empty { padding: 6px 0 2px; }
html[data-done=fade] .dayhover .dh-it.done .dh-t, html[data-done=fade] .dayhover .dh-it.done .num { opacity: .55; }
html[data-done=cross] .dayhover .dh-it.done .dh-t { text-decoration: line-through; opacity: .75; }
html[data-done=cross] .dayhover .dh-it.done .dh-c { background: none; border-color: var(--muted); } html[data-done=cross] .dayhover .dh-it.done .dh-c::after { display: none; }
@media (hover: none), (pointer: coarse) { .dayhover { display: none !important; } }

/* v5: title autocomplete */
.qa, #txForm { position: relative; }
.sugg { position: absolute; z-index: 70; background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); overflow: hidden; }
.sugg .si { display: grid; grid-template-columns: minmax(0, 1fr) auto 10px; gap: 8px; align-items: center; padding: 8px 10px; cursor: pointer; border-top: 1px solid var(--line); font-size: 14px; }
.sugg .si:first-child { border-top: 0; }
.sugg .si.on { background: var(--accent-soft); }
.sugg .st { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg .sm { color: var(--muted); font-size: 12px; white-space: nowrap; max-width: 52%; overflow: hidden; text-overflow: ellipsis; }
.sugg .sw2 { width: 10px; height: 10px; border-radius: 50%; }

/* v5: undo */
.toast.act { pointer-events: auto; }
.toast.act:not([hidden]) { display: flex; align-items: center; gap: 6px; }
.toast .toastbtn { background: none; border: 0; color: var(--accent2, #e6c27a); font-weight: 700; font-size: inherit; cursor: pointer; padding: 2px 4px; text-decoration: underline; }
html[data-theme=ivory] .toast .toastbtn { color: #8a6a1f; }
.iconbtn:disabled { opacity: .35; cursor: default; }
.hist .row { padding: 7px 2px; }

/* v5: Allocate */
.erhead { display: flex; align-items: center; gap: 8px; } .erhead .ehead { flex: 1; min-width: 0; }
.erow2.unal .alloc { flex: none; margin-right: 2px; }
.allocleft { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; margin: 6px 0 10px; background: var(--panel2); border-radius: 12px; font-size: 1.05rem; }
.allocleft .num { font-size: 1.35rem; }
.allocrows { display: flex; flex-direction: column; }
.allocrow { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); }
.allocrow:first-child { border-top: 0; }
.allocrow .grow { display: flex; flex-direction: column; min-width: 0; } .allocrow small { font-size: 12px; }
.allocrow input { width: 130px; text-align: right; flex: none; }

/* v5: on a desktop screen the whole calendar page fits the window: no page scrolling. Phones and short windows scroll as before. */
@media (min-width: 1001px) and (min-height: 540px) {
  body { --fitmode: 1; }
  body.calfit { height: 100vh; height: 100dvh; overflow: hidden; }
  body.calfit #app { height: 100%; display: flex; flex-direction: column; }
  body.calfit .topbar { position: static; padding: 4px 16px; gap: 8px; }
  body.calfit .brand { font-size: 24px; } body.calfit .brand img { width: 24px; height: 24px; }
  body.calfit .mainnav { margin-left: 10px; }
  body.calfit .mainnav button { padding: 4px 10px; font-size: 14px; }
  body.calfit .iconbtn { width: 30px; height: 30px; font-size: 14px; }
  body.calfit .tabs { padding: 5px 16px; gap: 5px; flex: none; }
  body.calfit .tabs button { flex-direction: row; align-items: center; gap: 8px; min-width: 0; padding: 3px 10px; border-radius: 9px; }
  body.calfit .tabs button .n { font-size: 12.5px; } body.calfit .tabs button .b { font-size: 13px; }
  body.calfit #accountTabs .reorderbtn { padding: 3px 10px; }
  body.calfit main { flex: 1; min-height: 0; width: 100%; padding: 0 16px 10px; }
  body.calfit #view-calendar.active { height: 100%; }
  body.calfit .calwrap { height: 100%; align-items: stretch; grid-template-rows: minmax(0, 1fr); gap: 12px; }
  body.calfit .calwrap > div:first-child { display: flex; flex-direction: column; min-height: 0; }
  body.calfit .calnav { margin: 2px 0 6px; flex: none; flex-wrap: nowrap; }
  body.calfit .calnav h2 { font-size: 18px; min-width: 150px; }
  body.calfit .calnav .btn { padding: 4px 11px; }
  body.calfit .grid { flex: 1; min-height: 0; grid-template-rows: auto repeat(var(--weeks, 6), minmax(0, 1fr)); }
  body.calfit .grid .dow { padding: 4px 8px; font-size: 11px; }
  body.calfit .day { min-height: 0; overflow: hidden; padding: 3px 6px 20px; gap: 1px; }
  body.calfit .day .dn { font-size: 13px; line-height: 1.2; }
  body.calfit .day .it { font-size: 12px; line-height: 1.25; }
  body.calfit .day .bal { font-size: 13px; bottom: 3px; }
  body.calfit .day .tag { top: 3px; }
  body.calfit .calwrap .note { flex: none; margin: 4px 0 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.calfit .side#dayPanel { position: static; height: 100%; max-height: none; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
}
@media (min-width: 1001px) and (min-height: 540px) {
  body.calfit main { max-width: 2000px; }
  body.calfit .side#dayPanel { padding-bottom: 60px; }   /* leaves room so the round Quick categories button never covers the last entry */
}
@media (min-width: 1500px) and (min-height: 540px) { body.calfit .calwrap { grid-template-columns: minmax(0, 1fr) 400px; } }
@media (max-width: 1000px) {
  .calnav { flex-wrap: nowrap; gap: 4px; }
  .calnav h2 { min-width: 0; font-size: 17px; white-space: nowrap; margin: 0 2px; }
  .calnav .btn { padding: 7px 10px; }
  .calnav .btn[data-summary] { margin-left: auto; padding: 7px 10px; font-size: 13.5px; }
}
@media (max-width: 1000px) { .calnav .btn { padding: 7px 8px; } .calnav h2 { font-size: 16px; } .calnav .btn[data-summary] { font-size: 13px; } }

/* v5: everything you can press looks pressable: hand cursor, a gold-tinted hover, a chevron or underline, a keyboard focus ring and a pressed state */
:root, :root[data-theme="luxe"] { --tint: color-mix(in srgb, var(--accent) 11%, var(--panel)); --tint2: color-mix(in srgb, var(--accent) 20%, var(--panel)); }
:root[data-theme="ivory"] { --tint: color-mix(in srgb, var(--accent) 9%, var(--panel)); --tint2: color-mix(in srgb, var(--accent) 17%, var(--panel)); }
html { -webkit-tap-highlight-color: transparent; }
button:not(:disabled), [role=button], a[href], summary, label, select:not(:disabled), input[type=checkbox]:not(:disabled), input[type=radio]:not(:disabled), input[type=color], input[type=date], input[type=month], input[type=range],
.click, [data-go], [data-edit], [data-cat], [data-day], [data-key], [data-jump], .si, .menu button { cursor: pointer; }
button:disabled, select:disabled, input:disabled { cursor: not-allowed; }
.grip, .grip *, [draggable=true] .grip { cursor: grab; }
/* keyboard focus: a clear gold ring on every control and on rows and day cells */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.day:focus-visible { outline-offset: -3px; z-index: 1; }
.row.click:focus-visible, .grow.click:focus-visible, .catrow:focus-visible, .ehead:focus-visible { outline-offset: -2px; border-radius: 8px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 1px; }
/* hover (mouse only), so touch screens never get a stuck highlight */
@media (hover: hover) {
  .btn:not(:disabled):not(.primary):hover { background: var(--tint2); }
  .btn.primary:not(:disabled):hover { filter: brightness(1.08); }
  .mainnav button:hover, .tabs button:hover:not(.active) { background: var(--tint); color: var(--text); }
  .tabs button:hover:not(.active) { border-color: var(--accent); }
  .chip:hover, button.chip:hover { background: var(--tint2); border-color: var(--accent); }
  .iconbtn:not(:disabled):hover { background: var(--tint); border-color: var(--accent); }
  .bottomnav button:hover { color: var(--text); }
  .menu button:hover { background: var(--tint); }
  .day:not(.sel):hover { background: var(--tint); }
  .row.click:hover, .grow.click:hover { background: var(--tint); }
  .grow.click:hover .ttl { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: 3px; }
  .catrow[data-cat]:hover { background: var(--tint); }
  .catrow[data-cat]:hover .nm { text-decoration: underline; text-underline-offset: 3px; }
  .erow2 .ehead:hover { background: var(--tint); border-radius: 8px; }
  .erow2 .ehead:hover .ech { color: var(--accent); }
  .calnav h2:hover { text-decoration: underline; text-underline-offset: 4px; }
  a[href]:hover, .linkbtn:hover { text-decoration: underline; text-underline-offset: 3px; }
  .sugg .si:hover { background: var(--tint2); }
  summary:hover { color: var(--accent); }
  .swatch:hover { transform: scale(1.1); }
  .toastbtn:hover { filter: brightness(1.15); }
  label:hover > input[type=checkbox], label:hover > input[type=radio] { filter: brightness(1.15); }
}
/* rows that open something carry a small chevron on the right */
.row.click { position: relative; padding-right: 22px; }
.row.click::after, .catrow[data-cat]::after { content: '›'; position: absolute; right: 5px; top: 50%; transform: translateY(-52%); color: var(--muted); opacity: .45; font-size: 1.15em; line-height: 1; pointer-events: none; transition: opacity .12s, transform .12s; }
.catrow[data-cat] { position: relative; padding-right: 18px; }
@media (hover: hover) { .row.click:hover::after, .catrow[data-cat]:hover::after { opacity: 1; color: var(--accent); transform: translate(2px, -52%); } }
.dp .row.click { padding-right: 2px; } .dp .row.click::after { content: none; }   /* the day panel's row has its own bin button at the end */
.dp .row { align-items: center; } .dp .grow.click { border-radius: 8px; padding: 3px 6px; margin: -3px -2px; }
.catrow[data-cat], .row.click, .grow.click { transition: background .12s; }
/* pressed (touch and mouse) */
.btn:not(:disabled):active, .iconbtn:not(:disabled):active, .chip:active, .menu button:active, .tabs button:active, .mainnav button:active, .bottomnav button:active, .fab:active, .swatch:active { transform: scale(.97); filter: brightness(.94); }
.day:active, .row.click:active, .grow.click:active, .catrow[data-cat]:active, .erow2 .ehead:active, .sugg .si:active, summary:active { background: var(--tint2); }
.btn, .iconbtn, .chip, .tabs button, .mainnav button, .bottomnav button, .fab { transition: background .12s, border-color .12s, transform .06s, filter .12s, color .12s; }
@media (prefers-reduced-motion: reduce) { .btn, .iconbtn, .chip, .tabs button, .mainnav button, .bottomnav button, .fab, .catrow, .row.click::after { transition: none !important; } }
input[type=file], input[type=file]::file-selector-button { cursor: pointer; }

/* v5: day-of-week toggles for "Weekly on selected days" */
.dows { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.dowbtn { min-width: 46px; padding: 8px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-weight: 600; font-size: 14px; }
.dowbtn[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (hover: hover) { .dowbtn[aria-pressed=false]:hover { background: var(--tint2); border-color: var(--accent); color: var(--text); } }
.dowbtn:active { transform: scale(.96); }
@media (max-width: 520px) { .dowbtn { flex: 1 1 0; min-width: 0; padding: 8px 2px; } }
.ivrow { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.ivrow input { width: 76px; text-align: center; }
@media (min-width: 1001px) { .toast { bottom: calc(22px + env(safe-area-inset-bottom)); } }   /* no bottom bar on a desktop, so the toast sits low and clear of the calendar */

/* v6: the preview is part of the hover region and its rows are clickable */
.dayhover .dh-it { cursor: pointer; border-radius: 6px; margin-right: -4px; padding-right: 4px; }
@media (hover: hover) { .dayhover .dh-it:hover { background: var(--tint2); } .dayhover .dh-it:hover .dh-t { text-decoration: underline; text-underline-offset: 3px; } }
.dayhover .dh-it:active { background: var(--tint2); }

.alert.info { border-left-color: var(--line); }
.typehint { flex: none; margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.typehint .linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* v6: quick add fold-away, and the Categories panel */
.qahead { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; padding: 4px 2px 6px; color: var(--muted); font-size: 12.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; text-align: left; }
.qahead:hover { color: var(--accent); }
.qahead .qach { display: inline-block; transition: transform .15s; font-size: 15px; transform: rotate(90deg); }
.qahead[aria-expanded=false] .qach { transform: none; }
.calnav .btn.sel { border-color: var(--accent); color: var(--accent); }
.cp { padding: 14px; }
.cphd { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.cphd h3 { margin: 0; font-size: 1.05rem; } .cphd .muted { font-size: 12.5px; flex: 1; }
.cphd .x { background: none; border: 1px solid var(--line); border-radius: 999px; width: 30px; height: 30px; font-size: 18px; line-height: 1; color: var(--text); align-self: center; }
.cptools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.seg.sm button { padding: 4px 9px; font-size: 12px; }
.cpnote { margin: 8px 0 4px; font-size: 12.5px; }
.cpsec h4 { margin: 12px 0 2px; font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.cgl { margin: 8px 0 1px; font-size: 11.5px; color: var(--muted); font-weight: 650; }
.cprow { display: grid; grid-template-columns: 20px 12px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 6px; margin: 1px -4px; border-radius: 8px; border-left: 3px solid transparent; cursor: pointer; }
.cprow input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.cprow .sw { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 30%, transparent); }
.cprow .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cprow .ctot { font-size: 13px; font-weight: 650; white-space: nowrap; text-align: right; } .cprow .ctot small { font-weight: 400; color: var(--muted); }
.cprow.on { background: color-mix(in srgb, var(--cc) 24%, transparent); border-left-color: var(--cc); }
@media (hover: hover) { .cprow:hover { background: var(--tint); } .cprow.on:hover { background: color-mix(in srgb, var(--cc) 32%, transparent); } }
.cprow:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.day .it.hit { border-radius: 4px; font-weight: 600; } .day .it.hit .num { color: inherit; }
.day .it.dim { opacity: .28; } .dots i.dim { opacity: .25; } .dayhover .dh-it.dim { opacity: .35; }
.calwrap.cat3 { grid-template-columns: minmax(0, 1fr) 300px 360px; }
@media (min-width: 1500px) and (min-height: 540px) { body.calfit .calwrap.cat3 { grid-template-columns: minmax(0, 1fr) 320px 400px; } }
@media (min-width: 1001px) and (min-height: 540px) { body.calfit .side#catPanel { position: static; height: 100%; max-height: none; overflow-y: auto; min-height: 0; overscroll-behavior: contain; } }
@media (min-width: 1001px) { .side#catPanel { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; } }
#sheet .cp { padding: 4px 2px; } #sheet .cplist { max-height: 55vh; overflow-y: auto; }
@media (max-width: 1000px) {
  .calnav { flex-wrap: wrap; }
  .calnav .btn[data-catpanel], .calnav .btn[data-summary] { flex: 1 1 calc(50% - 4px); margin-left: 0; text-align: center; }
}

/* v6: no empty envelope row; the add-envelopes button is a small one in the calendar header */
.envtabs:empty { display: none; }
.calnav [data-addenv] { padding-left: 10px; padding-right: 10px; }
.dp .schedhd { margin: 10px 2px 4px; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.dp .schedhd.none { font-weight: 500; font-style: italic; }
select.needs { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* v6: entry lines in a day cell never squash into each other: fixed line height, whole lines only (fitCells shows as many as fit, then "+N more") */
.day .it, .day .more { flex: 0 0 auto; }
.day .it { line-height: 1.3; min-height: 1.3em; }
.day .more { line-height: 1.3; min-height: 1.3em; }
body.calfit .day .it { line-height: 14px; min-height: 14px; height: 14px; }
body.calfit .day .more { line-height: 12px; min-height: 12px; height: 12px; }
body.calfit .day { padding-bottom: 18px; }
body.calfit .day .dn { line-height: 14px; }
body.calfit .day .bal { font-size: 12.5px; line-height: 15px; bottom: 2px; }

/* v6: investment groups, total invested (eye), super funds */
.eye { border: 0; background: transparent; color: var(--muted); padding: 2px 4px; margin-left: 4px; cursor: pointer; vertical-align: middle; border-radius: 6px; }
.eye:hover, .eye[aria-pressed="true"] { color: var(--accent); }
.masked { letter-spacing: 1px; color: var(--muted); }
.invgroup { margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.invgroup .ighead { display: flex; align-items: center; gap: 10px; padding: 10px 12px; flex-wrap: wrap; }
.invgroup .ighead .grow { flex: 1; min-width: 220px; }
.invgroup .ighead .nm { font-weight: 650; font-size: 1.05rem; color: var(--accent); }
.invgroup .chev { background: none; border: 0; color: var(--muted); font-size: 1rem; width: 28px; height: 28px; cursor: pointer; }
.invgroup .igsum { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.invgroup .igsum b { color: var(--text); font-weight: 650; }
.invgroup .acts { display: flex; gap: 6px; }
.invgroup .igbody { padding: 4px 12px 0; }
.nwg { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 8px 0 6px; font-size: 13.5px; }
.fchart { width: 100%; height: auto; max-height: 150px; display: block; margin: 6px 0; }
.fchart path { fill: none; stroke: var(--accent); stroke-width: 2; }
.fchart circle { fill: var(--accent); }
.fchart text { fill: var(--muted); font-size: 10px; }
.fund .fhist, .fund .fcons { border-top: 1px solid var(--line); padding: 6px 0; }
.fund .fhist summary { cursor: pointer; font-size: 13.5px; color: var(--muted); }
.fund .fcon { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; padding: 4px 0; font-size: 13.5px; }
.fund .fconhd { font-size: 13px; margin-bottom: 2px; }

/* v6: select several entries to delete */
.dp .schedrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dp .schedrow .schedhd { margin-right: auto; }
.selbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 8px; margin: 4px 0; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); font-size: 13px; }
.dp .row.picked { background: var(--accent-soft); border-radius: 8px; }

/* ---------- calendar Select mode ---------- */
.day .it.picked, .dayhover .dh-it.picked { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.day .it.picked .t::before { content: '✓ '; font-weight: 800; color: var(--accent); }
.dayhover .dh-it.picked .dh-t::before { content: '✓ '; font-weight: 800; color: var(--accent); }
.calselecting .day .it[data-key], .calselecting .dayhover .dh-it { cursor: pointer; }
.calsel { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 45; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  min-width: min(520px, calc(100vw - 16px)); padding: 9px 12px; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.35); }
.calsel[hidden] { display: none; }
.calsel-btns { display: flex; gap: 6px; }
body.calselecting .fab { display: none; }
body.calselecting main { padding-bottom: 90px; }
@media (max-width: 699px) {
  .calsel { left: 8px; right: 8px; transform: none; min-width: 0; bottom: calc(62px + env(safe-area-inset-bottom)); }
}

/* ---------- bank statement import ---------- */
.impwrap { max-width: 860px; margin: 0 auto; padding: 4px 0 24px; }
.imphead h2 { margin: 14px 0 4px; font-weight: 600; letter-spacing: .01em; }
.impsteps { list-style: none; display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; padding: 0; font-size: 13px; color: var(--muted); }
.impsteps li { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }
.impsteps li b { font-weight: 600; margin-right: 2px; }
.impsteps li.on { color: var(--accent); border-color: var(--accent); }
.impsteps li.past { color: var(--text); }
.impcard { margin-bottom: 12px; }
.impcard h3 { margin: 0 0 6px; }
.impcard .actions { margin-top: 14px; }
.impform { margin-top: 12px; display: grid; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.imptable { overflow-x: auto; margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; }
.imptable table { border-collapse: collapse; width: 100%; font-size: 13px; }
.imptable td, .imptable th { padding: 5px 9px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.imptable tr.hdr td { color: var(--muted); font-weight: 600; }
.improle { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.improle.none { color: var(--muted); font-weight: 500; }
.impsample { margin-top: 12px; padding: 10px 12px; background: var(--accent-soft); border-radius: 10px; }
.impsample h4 { margin: 0 0 6px; font-size: 13.5px; font-weight: 600; }
.improw { display: flex; align-items: baseline; gap: 10px; padding: 6px 4px; border-top: 1px solid var(--line); font-size: 14px; }
.improw:first-of-type { border-top: 0; }
.improw .d { min-width: 92px; color: var(--muted); font-size: 13px; }
.improw .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.improw.pick { cursor: pointer; padding: 8px 6px; border-radius: 8px; }
.improw.pick.picked { background: var(--accent-soft); }
.improws { margin-top: 8px; }
.impbar { position: sticky; top: 56px; }
.pill.warn { color: var(--text); border: 1px solid var(--line); background: transparent; }
.impsug { margin-bottom: 10px; opacity: .72; }
.impsug.on { opacity: 1; border-color: var(--accent); }
.sugtop { align-items: center; }
.sugtop .inp { flex: 1; font-weight: 600; }
.sugfields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
@media (max-width: 699px) {
  .sugfields { grid-template-columns: 1fr 1fr; }
  .improw .d { min-width: 70px; }
  .impbar { top: 48px; }
}

/* ---------- attached files and reminders ---------- */
.clip { font-size: .82em; margin-right: 3px; cursor: pointer; background: none; border: 0; padding: 0 1px; line-height: 1; color: inherit; }
.row .ttl .clip { font-size: .95em; }
.clip:hover, .clip:focus-visible { filter: brightness(1.3); outline: none; }
.filebtns { margin-top: 6px; }
.fileitem { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.fileitem:first-child { border-top: 0; }
.fileitem .fname { flex: 1; min-width: 120px; overflow-wrap: anywhere; font-size: 14px; }
.fileitem .fsize { font-size: 12.5px; }
.fileview { position: fixed; inset: 0; z-index: 90; background: rgba(8, 8, 8, .86); display: flex; flex-direction: column; padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom)); }
.fileview .fv-bar { display: flex; align-items: center; gap: 8px; padding: 6px 4px; color: #f3efe6; }
.fileview .fv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fileview .fv-body { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; color: #f3efe6; text-align: center; }
.fileview img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.remrow { align-items: center; }
.remcustom { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.remcustom input { width: 90px; }
.remitem { align-items: center; gap: 10px; }
.rembtns { white-space: nowrap; }
@media (max-width: 699px) { .remitem { flex-wrap: wrap; } }

/* ---------- top menu ---------- */
button.brand { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-align: left; font-weight: inherit; line-height: inherit; border-radius: 10px; }
button.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.topbar .topright { gap: 6px; }
.calbtn.active { border-color: var(--accent); color: var(--accent); }
.navwrap { position: relative; }
.menubtn { display: inline-flex; align-items: center; gap: 7px; }
.menubtn.active { border-color: var(--accent); color: var(--accent); }
.menuico { display: inline-block; width: 15px; height: 2px; background: currentColor; border-radius: 2px; box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor; margin: 5px 0; }
.menubtn .badge { margin-left: 0; }
.navpanel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 70; min-width: 250px; padding: 6px; display: flex; flex-direction: column; gap: 1px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 14px 38px rgba(0,0,0,.4); }
.navpanel[hidden] { display: none; }
.navpanel button { border: 0; background: transparent; text-align: left; padding: 10px 14px; border-radius: 9px; color: var(--text); font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.navpanel button:hover { background: var(--tint); }
.navpanel button.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.navpanel button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.navpanel hr { border: 0; border-top: 1px solid var(--line); margin: 5px 6px; width: calc(100% - 12px); }
.helpwrap { max-width: 760px; margin: 0 auto; padding-bottom: 24px; }
.helpitem { margin-bottom: 10px; padding: 0; }
.helpitem summary { cursor: pointer; padding: 12px 14px; list-style: none; }
.helpitem summary::-webkit-details-marker { display: none; }
.helpitem summary h3 { margin: 0; font-size: 16px; font-weight: 600; }
.helpitem summary h3::before { content: '+'; display: inline-block; width: 18px; color: var(--accent); }
.helpitem[open] summary h3::before { content: '–'; }
.helpitem p { margin: 0; padding: 0 14px 14px 32px; color: var(--text); }
.helpfoot h3 { margin-top: 0; }
.comingsoon { padding: 12px 14px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); }
@media (max-width: 699px) {
  .topbar { gap: 6px; }
  .topbar .topright { gap: 3px; }
  .topright .iconbtn { padding-left: 7px; padding-right: 7px; min-width: 32px; }
  .calbtn { padding: 6px 9px; font-size: 13.5px; }
  .menubtn { padding: 6px 9px; }
  .menutxt { display: none; }
  #themeBtn { display: none; }   /* on a phone the theme switch is in Settings, which leaves room for Calendar and Menu */
  .navpanel { position: fixed; right: 8px; left: 8px; top: calc(56px + env(safe-area-inset-top)); min-width: 0; }
}

/* v8: partner sharing */
#partnerBody .card { margin: 10px 0; }
.invite .invcode { font: 600 34px/1.1 ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; letter-spacing: .14em; color: var(--accent); text-align: center; padding: 14px 8px; margin: 8px 0 12px; border: 1px solid var(--gold-deep); border-radius: 12px; background: var(--accent-soft); user-select: all; }
#partnerBody ol.steps { margin: 8px 0 4px 1.2em; padding: 0; color: var(--muted); line-height: 1.5; }
#partnerBody ol.steps li { margin: 4px 0; }
#partnerBody .row-inline { display: flex; gap: 8px; } #partnerBody .row-inline .inp { flex: 1; min-width: 0; }
#partnerBody details.adv { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
#partnerBody .inp.code { text-transform: uppercase; letter-spacing: .12em; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 18px; }
.sheet .hd .who { margin-top: 2px; font-size: 13px; }

/* v8: the line of the day under the header (calendar page only) */
.dailyline { margin: 2px 16px 0; padding: 0; font-size: 13px; line-height: 1.35; color: var(--muted); font-style: italic; letter-spacing: .01em; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dailyline[hidden] { display: none; }
@media (max-width: 600px) { .dailyline { margin: 2px 12px 0; font-size: 12.5px; white-space: normal; } }
@media (min-width: 1001px) and (min-height: 540px) { body.calfit .dailyline { flex: none; margin: 0 16px; font-size: 12.5px; } }

/* v8.1: net worth figure on a deep green panel (same in both themes, gold on green) */
.nwhero { --nw-bg: #0b3b2e; --nw-gold: #e6cf8a; --nw-pill: rgba(255, 255, 255, .1); background: var(--nw-bg); border-radius: 14px; padding: 18px 22px 20px; margin: 0 0 14px; border: 1px solid color-mix(in srgb, var(--nw-gold) 22%, transparent); }
:root[data-theme="ivory"] .nwhero { --nw-bg: #0f4433; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.nwhero .nwfig { font-family: 'Cormorant Garamond', 'Playfair Display', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif; font-style: italic; font-weight: 600; font-size: clamp(40px, 9vw, 72px); line-height: 1.02; color: var(--nw-gold); letter-spacing: .01em; overflow-wrap: anywhere; }
.nwhero .nwfig.neg { color: #ffb4aa; }
.nwhero .nwpill { display: inline-block; margin-top: 10px; padding: 6px 14px; border-radius: 999px; background: var(--nw-pill); color: #f3ecdc; font-size: 13px; font-weight: 600; line-height: 1.3; }
.nwhero .nwbtn { display: block; margin-top: 14px; padding: 11px 24px; border: 0; border-radius: 999px; background: #c9a43a; color: #1a1607; font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; }
.nwhero .nwbtn:hover { background: #d8b54b; } .nwhero .nwbtn:focus-visible { outline: 2px solid var(--nw-gold); outline-offset: 2px; } .nwhero .nwbtn:disabled { opacity: .7; cursor: default; }
@media (max-width: 600px) { .nwhero { padding: 14px 16px 16px; } .nwhero .nwpill { font-size: 12px; } }

/* v8.1: the line of the day sits in the header bar, centred between the logo and the buttons, when there is room; narrow phones keep it under the header */
.hdrline { display: none; flex: 1 1 auto; min-width: 0; margin: 0 12px; text-align: center; font-size: 13px; line-height: 1.3; color: var(--muted); font-style: italic; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 760px) {
  .hdrline:not([hidden]) { display: block; }
  #dailyLine { display: none !important; }
}

/* v8.1: Investments page totals in the account chip row */
.tabs .nwchip { flex: none; display: flex; flex-direction: column; gap: 2px; min-width: 120px; padding: 8px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.tabs .nwchip .n { font-size: 12.5px; color: var(--muted); } .tabs .nwchip .b { font-size: 16px; font-weight: 700; }
.tabs .nwchip.hi { border-color: var(--accent); background: var(--accent-soft); } .tabs .nwchip.hi .n { color: var(--accent); }
@media (min-width: 1001px) and (min-height: 540px) { body.calfit .tabs .nwchip { flex-direction: row; align-items: center; gap: 8px; padding: 3px 10px; } }
@media (max-width: 640px) { .tabs:has(.nwchip) { flex-wrap: wrap; overflow: visible; } .tabs .nwchip { flex: 1 1 calc(50% - 8px); min-width: 0; } .tabs .nwchip.hi { flex-basis: 100%; } }
/* v8.1: Calendar + Investments buttons side by side; on narrow phones show the logo mark only so the Menu button stays on screen */
@media (max-width: 480px) { .topbar .brand::after, .brand > span { display: none; } .topright { gap: 4px; } .calbtn { padding: 6px 8px; font-size: 13px; } }
@media (max-width: 480px) { .topbar { gap: 8px; } .topright .iconbtn { width: 32px; height: 32px; min-width: 32px; padding: 0; } }
@media (max-width: 420px) { #helpBtn { display: none; } }   /* small phones: the setup guide is still in Settings, and Help is in the Menu */

/* v8.1: phone month bar in two tidy rows: ‹ month › on top, then Today / Select / Categories / summary */
@media (max-width: 700px) {
  .calnav, body.calfit .calnav { flex-wrap: wrap; gap: 6px; row-gap: 8px; }
  .calnav h2, body.calfit .calnav h2 { flex: 1 1 calc(100% - 110px); min-width: 0; text-align: center; font-size: 18px; margin: 0; }
  .calnav .btn[data-nav] { flex: 0 0 44px; padding: 7px 0; }
  .calnav .btn[data-today], .calnav .btn[data-cselect], .calnav .btn[data-catpanel], .calnav .btn[data-addenv], .calnav .btn[data-summary] { flex: 1 1 0; min-width: 0; margin-left: 0; padding: 7px 4px; font-size: 13.5px; white-space: nowrap; }
}
@media (max-width: 700px) { .calnav .btn[data-summary] { font-size: 12.5px; padding: 7px 2px; overflow: hidden; text-overflow: ellipsis; } }

/* ======================================================================
   v9 phone and installed app (up to 700px wide). Desktop is unchanged.
   Header: Menu left, logo mark centred, a few buttons right. No bottom bar.
   The month, the account chips and the header fit on one screen; the selected day follows below.
   ====================================================================== */
.bottomnav, .morepanel { display: none !important; }
.addentry, .mshort { display: none; }
.noteic { display: inline-flex; vertical-align: -1px; margin-left: 4px; color: var(--muted); font-size: .85em; }
.cellmark { display: none; }
.login { position: fixed; inset: 0; z-index: 200; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 16%, var(--bg)) 0%, var(--bg) 60%); }
.loginbox { width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; }
.loginlogo { border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.loginname { margin: 14px 0 2px; font-family: 'Cormorant Garamond', 'Playfair Display', Georgia, serif; font-style: italic; font-weight: 600; font-size: 44px; line-height: 1; color: var(--accent); letter-spacing: .02em; }
.logintag { margin: 4px 0 22px; color: var(--muted); font-size: 15px; }
.oauth { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.oauthbtn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 16px; border-radius: 999px; font-weight: 600; font-size: 16px; }
.oauthbtn.apple { background: #ffffff; color: #000000; border-color: #ffffff; }
:root[data-theme="ivory"] .oauthbtn.apple { background: #000000; color: #ffffff; border-color: #000000; }
.oauthbtn.google { background: #ffffff; color: #1f1f1f; border-color: #dadce0; }
.orline { width: 100%; display: flex; align-items: center; gap: 10px; margin: 18px 0 6px; color: var(--muted); font-size: 13px; }
.orline::before, .orline::after { content: ''; flex: 1; height: 1px; background: var(--line); }
#loginForm { width: 100%; text-align: left; }
#loginForm .check { margin: 4px 0 10px; }
.loginbtn { width: 100%; padding: 12px 16px; border-radius: 999px; font-size: 16px; }
.loginlinks { display: flex; justify-content: center; margin-top: 8px; }
.loginlocal { margin-top: 18px; color: var(--muted); font-size: 13.5px; }
body.loginopen { overflow: hidden; }

@media (max-width: 700px) {
  html, body { overflow-x: clip; max-width: 100%; }
  main { padding: 0 8px calc(16px + env(safe-area-inset-bottom)); }
  .fab, .fabpanel { display: none !important; }
  .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }

  /* header */
  .topbar { position: sticky; display: flex; align-items: center; gap: 6px; min-height: 52px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px; border-bottom: 0;
    background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  .topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 55%, transparent), transparent); }
  .topright { display: contents; }
  .navwrap { order: -1; }
  .menubtn { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; }
  .brand { position: absolute; left: 50%; top: calc(50% + env(safe-area-inset-top) / 2); transform: translate(-50%, -50%); gap: 0; }
  .brand img { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
  .topbar .brand::after, .brand > span { display: none !important; }
  .hdrline { display: none !important; }
  #redoBtn, #helpBtn, #themeBtn, #calBtn { display: none !important; }
  #undoBtn { margin-left: auto; }
  .topright .iconbtn { width: 34px; height: 34px; min-width: 34px; padding: 0; font-size: 15px; }
  #invBtn { padding: 7px 11px; font-size: 13px; border-radius: 999px; }
  body[data-view="investments"] #invBtn { display: none !important; }
  body[data-view="investments"] #calBtn { display: inline-flex !important; padding: 7px 11px; font-size: 13px; border-radius: 999px; }
  .navpanel { left: 8px; right: 8px; top: calc(58px + env(safe-area-inset-top)); border-radius: 16px; }

  /* line of the day: centred, quiet */
  #dailyLine:not([hidden]) { display: block !important; text-align: center; margin: 2px 16px 0; font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; font-size: 15px; line-height: 1.25; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* account chips: compact pills */
  .tabs { padding: 6px 8px; gap: 6px; }
  .tabs button { min-width: 0; padding: 5px 12px 6px; border-radius: 14px; gap: 0; }
  .tabs button .n { font-size: 11.5px; letter-spacing: .02em; } .tabs button .b { font-size: 14.5px; }
  .tabs button.active { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 16%, var(--panel)), var(--panel)); box-shadow: inset 0 0 0 1px var(--accent); }

  /* month bar: one row */
  .calnav, body.calfit .calnav { flex-wrap: nowrap; gap: 6px; row-gap: 0; margin: 4px 0 8px; }
  .calnav h2, body.calfit .calnav h2 { flex: 1 1 auto; min-width: 0; margin: 0 2px; text-align: left; white-space: nowrap; font-family: 'Cormorant Garamond', 'Playfair Display', Georgia, serif; font-style: italic; font-weight: 600; font-size: 25px; line-height: 1; color: var(--accent); }
  .calnav .mfull { display: none; } .calnav .mshort { display: inline; }
  .calnav .btn[data-nav] { flex: 0 0 34px; width: 34px; height: 34px; padding: 0; border-radius: 50%; background: transparent; }
  .calnav .btn[data-today], .calnav .btn[data-summary] { flex: 0 0 auto; height: 34px; padding: 0 12px; border-radius: 999px; font-size: 13.5px; background: transparent; color: var(--text); border-color: var(--line); font-weight: 600; }
  .calnav .btn[data-cselect], .calnav .btn[data-catpanel], .calnav .btn[data-addenv] { display: none; }
  .calnav .addentry { display: inline-flex; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; align-items: center; justify-content: center; border-radius: 50%; font-size: 30px; line-height: 1; font-weight: 400;
    background: linear-gradient(160deg, var(--gold-hi), var(--accent) 45%, var(--gold-deep)); color: var(--accent-ink); border: 0; box-shadow: 0 6px 16px rgba(0,0,0,.35), 0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent); }
  .calnav .addentry span { margin-top: -3px; }

  /* calendar cells: one size for every day; a gold count in the top-right, and a note icon beside it */
  .grid { border-radius: 14px; box-shadow: none; }
  .grid .dow { padding: 3px 0 4px; font-size: 10.5px; letter-spacing: .08em; }
  .day, body.calfit .day { height: var(--rowh, 64px); min-height: 0; padding: 3px 2px 0; gap: 2px; overflow: hidden; align-items: flex-start; justify-content: flex-start; }
  .day .dn, body.calfit .day .dn { font-size: 13px; line-height: 18px; font-weight: 600; padding: 0 20px 0 3px; }
  .day.today .dn span { padding: 0 6px; }
  .day.today { box-shadow: none; }
  .day.sel { box-shadow: inset 0 0 0 1.5px var(--accent); }
  .day.sel.hiday, .day.sel.loday { box-shadow: inset 0 0 0 1.5px var(--accent), inset 0 -3px 0 var(--hi); }
  .dots { display: none; }
  .day .bal, body.calfit .day .bal { font-size: 10.5px; line-height: 1; bottom: 4px; letter-spacing: -.2px; }
  .cellmark { display: flex; position: absolute; top: 3px; right: 2px; align-items: center; gap: 2px; z-index: 1; line-height: 0; }
  .celln { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
    background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; font-style: normal; }
  .day .bm { position: static; font-size: 10px; }

  /* below the calendar: the selected day only */
  .calwrap .note, .calwrap > div:first-child > .note { display: none !important; }
  #dayPanel .qa, #dayPanel .qahead { display: none !important; }
  .side#dayPanel { margin-top: 10px; }
  .card { border-radius: 16px; }

  /* text size for older eyes: zoom the content, not the header */
  html[data-text="lg"] main, html[data-text="lg"] #accountTabs, html[data-text="lg"] #envTabs, html[data-text="lg"] #dailyLine, html[data-text="lg"] .navpanel { zoom: 1.15; }
  html[data-text="xl"] main, html[data-text="xl"] #accountTabs, html[data-text="xl"] #envTabs, html[data-text="xl"] #dailyLine, html[data-text="xl"] .navpanel { zoom: 1.3; }
  html[data-text="lg"] .sheet { zoom: 1.15; width: calc(100vw / 1.15); } html[data-text="xl"] .sheet { zoom: 1.3; width: calc(100vw / 1.3); }
  html[data-text="lg"] .navpanel { left: 7px; right: 7px; } html[data-text="xl"] .navpanel { left: 6px; right: 6px; }
}
.login .linkbtn { background: none; border: 0; padding: 4px 6px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; cursor: pointer; }
.login .loginlocal { color: var(--muted); }
@media (max-width: 700px) {
  .calwrap { grid-template-columns: minmax(0, 1fr); }
  .calwrap > div:first-child { min-width: 0; }
  .calnav .caret { font-family: var(--font); font-style: normal; font-size: 13px; vertical-align: 3px; color: var(--muted); }
}
@media (max-width: 700px) {
  .calnav .caret { display: none; }
  .calnav, body.calfit .calnav { gap: 5px; }
  .calnav h2, body.calfit .calnav h2 { flex: 1 1 auto; font-size: 23px; }
  .calnav .btn[data-nav] { flex-basis: 32px; width: 32px; height: 32px; }
  .calnav .btn[data-today], .calnav .btn[data-summary] { padding: 0 10px; }
  .calnav .addentry { flex-basis: 42px; width: 42px; height: 42px; }
  /* when one row does not fit (small phone with large text): month on top, buttons below */
  .calnav.two, body.calfit .calnav.two { flex-wrap: wrap; row-gap: 8px; }
  .calnav.two h2 { flex: 1 1 calc(100% - 90px); text-align: center; }
  .calnav.two .btn[data-today], .calnav.two .btn[data-summary] { flex: 1 1 0; }
}
@media (max-width: 700px) { .calnav h2, body.calfit .calnav h2 { overflow: hidden; } }
@media (max-width: 700px) {
  body .calnav.two { display: grid; grid-template-columns: 42px 1fr 1fr 1fr 1fr 42px; gap: 8px 6px; align-items: center; }
  body .calnav.two > * { min-width: 0; }
  body .calnav.two .btn[data-nav="-1"] { grid-area: 1 / 1 / 2 / 2; justify-self: start; }
  body .calnav.two h2 { grid-area: 1 / 2 / 2 / 6; text-align: center; }
  body .calnav.two .btn[data-nav="1"] { grid-area: 1 / 6 / 2 / 7; justify-self: end; }
  body .calnav.two .btn[data-today] { grid-area: 2 / 1 / 3 / 3; width: 100%; }
  body .calnav.two .btn[data-summary] { grid-area: 2 / 3 / 3 / 6; width: 100%; }
  body .calnav.two .addentry { grid-area: 2 / 6 / 3 / 7; justify-self: end; }
}

/* v9.1 phones: the calendar is fixed on screen; only the selected day's entries scroll, in their own panel below */
@media (max-width: 700px) {
  html.phonecal, html.phonecal body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  html.phonecal main { padding-bottom: 0; }
  html.phonecal .side#dayPanel { margin-top: 10px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; position: static; max-height: none;
    border-radius: 16px; scrollbar-width: thin; }
  html.phonecal .side#dayPanel > .card { min-height: 100%; margin: 0; }
}
@media (max-width: 700px) {
  html.phonecal.phonecalscroll, html.phonecal.phonecalscroll body { height: auto; overflow-y: auto; }
  html.phonecal .side#dayPanel { background: var(--panel); border: 1px solid var(--line); }
  html.phonecal .side#dayPanel > .card.dp { flex: none; border: 0; box-shadow: none; background: transparent; padding-top: 0; border-radius: 0; }
  /* the day heading stays at the top of the panel while its entries scroll */
  html.phonecal .dp .dphd { position: sticky; top: 0; z-index: 2; margin: 0 -14px 6px; padding: 12px 14px 8px; background: var(--panel);
    border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
  /* larger text: the month bar keeps its standard size (it is already large), so the calendar keeps more room */
  html[data-text="lg"] .calnav { zoom: calc(1 / 1.15); } html[data-text="xl"] .calnav { zoom: calc(1 / 1.3); }
}
@media (max-width: 700px) {
  html.phonecal .side#dayPanel { display: block; }
  html.phonecal .dp .selbar { top: 64px; }
  /* small rows (small phones, larger text): a tighter cell so the number and balance stay clear of each other */
  .grid.tight .day { padding-top: 2px; gap: 1px; }
  .grid.tight .day .dn { line-height: 16px; }
  .grid.tight .day .bal { bottom: 3px; }
  .grid.tight .cellmark { top: 2px; right: 1px; }
  .grid.tight .celln { min-width: 16px; height: 16px; font-size: 10.5px; padding: 0 3px; }
}

/* v9: signed-in email at the top of the Menu */
.navpanel .menuemail { padding: 8px 14px 6px; font-size: 12.5px; line-height: 1.3; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--line); margin: 0 6px 4px; padding-left: 8px; padding-right: 8px; }
/* v9 phones: low and high balance days (Settings, Highlight low and high balances): a tinted outline, red for low, green for high */
@media (max-width: 700px) {
  .day.hiday, .day.loday, .day.negday.loday { box-shadow: none; }
  .day.hiday { background: color-mix(in srgb, var(--hi) 10%, var(--panel)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--hi) 70%, transparent); }
  .day.loday, .day.negday.loday { background: color-mix(in srgb, var(--neg) 11%, var(--panel)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--neg) 70%, transparent); }
  .day.sel, .day.sel.hiday, .day.sel.loday { box-shadow: inset 0 0 0 2px var(--accent); }
}
@media (max-width: 700px) {
  /* v9: a wide child (a table) must not stretch the whole page past the screen */
  .settings, .two { grid-template-columns: minmax(0, 1fr); }
  .settings > *, .card { min-width: 0; }
}
@media (max-width: 700px) { .card:has(table) { overflow-x: auto; -webkit-overflow-scrolling: touch; } }
@media (max-width: 700px) { html.phonecal .calselecting #dayPanel > .card { padding-bottom: 84px; } }   /* the Select bar floats at the bottom: leave room so it never covers the last entry */
/* v9 phones: the sync icon no longer crowds the centred logo; sync state is the dot beside the email at the top of the Menu */
.navpanel .menuemail::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; background: var(--muted); }
.navpanel .menuemail[data-sync="ok"]::before { background: var(--pos); }
.navpanel .menuemail[data-sync="syncing"]::before, .navpanel .menuemail[data-sync="pending"]::before { background: var(--accent); }
.navpanel .menuemail[data-sync="error"]::before { background: var(--neg); }
@media (max-width: 700px) { #syncBtn { display: none !important; } }
