/* Coinleaf styles.
   Look: formal ledger. Dark is the default: near-black green-tinted surfaces with emerald lettering and the
   winged emblem; a light theme mirrors it (toggle in the sidebar / top bar).
   Layout tiers: >=1181px full sidebar | 861–1180px icon rail | <=860px top bar + bottom tabs + floating +.
   The entry form is a slide-over drawer at every size. */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f5f3; --surface: #ffffff; --sunk: #f5f8f6; --raise: #ffffff; --ink: #0b1a12; --muted: #4c6155; --faint: #82958a; --line: #dbe4de;
  --accent: #11803e; --accent-2: #169c4c; --accent-soft: #e2f2e8; --accent-ink: #0a5a2b; --on-accent: #ffffff;
  --brand: #0e7a3b; --logo-1: #1ea85a; --logo-2: #0b6b33;
  --exp: #c8413b; --inc: #1d6fd1; --warn: #b7791f; --danger: #c62828; --today: #f0b429;
  --shadow-sm: 0 1px 2px rgb(10 30 20 / .06), 0 1px 3px rgb(10 30 20 / .05);
  --shadow-md: 0 1px 2px rgb(10 30 20 / .04), 0 8px 24px rgb(10 30 20 / .07);
  --shadow-lg: 0 18px 60px rgb(10 30 20 / .25);
  --hero: linear-gradient(135deg, #0a3a20 0%, #0f5a30 55%, #12803e 100%); --hero-ink: #ffffff; --hero-sub: rgb(255 255 255 / .82);
  --display: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --mark: "Cinzel", "Libre Baskerville", Georgia, serif;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 14px; --r-sm: 10px; --side: 248px;
  padding-top: env(safe-area-inset-top, 0px);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b09; --surface: #0d1411; --sunk: #0a100d; --raise: #111a16; --ink: #e6efe9; --muted: #92a699; --faint: #5f7367; --line: #1b2620;
  --accent: #3ddc84; --accent-2: #63e89f; --accent-soft: #0f2519; --accent-ink: #7cf0b0; --on-accent: #03140a;
  --brand: #3ddc84; --logo-1: #7ef0b1; --logo-2: #2dbb6c;
  --exp: #ff7a70; --inc: #6cb6ff; --warn: #f0b429; --danger: #ff8a80; --today: #f0b429;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .5);
  --shadow-md: inset 0 1px 0 rgb(255 255 255 / .025), 0 10px 30px rgb(0 0 0 / .45);
  --shadow-lg: 0 24px 70px rgb(0 0 0 / .7);
  --hero: linear-gradient(135deg, #0b2416 0%, #0f3320 55%, #134a2c 100%); --hero-ink: #8ff3bd; --hero-sub: #a9c9b6;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14.5px; line-height: 1.45; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
.num { font-variant-numeric: tabular-nums; }
.exp { color: var(--exp); } .inc { color: var(--inc); } .muted { color: var(--muted); } .faint { color: var(--faint); }
.err { color: var(--danger); font-size: 13px; margin: 0; min-height: 1em; }
.ok { color: var(--accent-ink); font-size: 13px; margin: 0; }
h2 { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -.005em; text-wrap: balance; }
.label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.green { color: var(--accent-ink); background: var(--accent-soft); border-color: transparent; }
.badge.red { color: var(--exp); background: color-mix(in srgb, var(--exp) 12%, transparent); border-color: transparent; }
.badge.amber { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: transparent; }

/* ---------- brand ---------- */
.emblem { display: inline-block; aspect-ratio: 727 / 477; height: 30px; background: linear-gradient(180deg, var(--logo-1), var(--logo-2));
  -webkit-mask: url(brand/emblem-mask.png) center / contain no-repeat; mask: url(brand/emblem-mask.png) center / contain no-repeat; flex: none; }
.wordmark { font-family: var(--mark); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--brand); font-size: 17px; }
.side-brand, .top-brand { display: flex; align-items: center; gap: 10px; }

/* ---------- shell ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px; padding: calc(22px + env(safe-area-inset-top, 0px)) 14px calc(16px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px)); z-index: 20; overflow-y: auto; }
.side-brand { padding: 0 6px 4px; }
.nav { display: grid; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 12px; border: 0; background: transparent; padding: 10px 12px; border-radius: 10px; font-weight: 600; color: var(--muted); text-align: left; position: relative; }
.nav button svg { width: 20px; height: 20px; }
.nav button:hover { background: var(--sunk); color: var(--ink); }
.nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.nav button[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.side-foot { margin-top: auto; display: grid; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--accent-soft); color: var(--accent-ink); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); flex: none; }
.me-text { display: grid; min-width: 0; line-height: 1.25; }
.me-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.me-text small { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.side-actions { display: flex; gap: 6px; }
.sync-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.sync { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.sync.ok { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.sync.warn { background: var(--warn); }
.main { margin-left: var(--side); padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); padding-block: 0 48px; max-width: calc(var(--side) + 1560px); }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); display: flex; align-items: center; gap: 14px; padding-block: 18px 14px; }
.top-brand { display: none; }
.page-title { font-family: var(--display); font-size: 25px; font-weight: 700; letter-spacing: -.01em; margin: 0 auto 0 0; color: var(--ink); }
.top-tools { display: flex; align-items: center; gap: 8px; }
.top-theme { display: none; }
.month { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; box-shadow: var(--shadow-sm); }
.month-title { font-weight: 700; min-width: 8.6em; text-align: center; font-size: 14px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; display: grid; place-items: center; color: var(--muted); flex: none; }
.month .icon-btn { border-radius: 50%; width: 32px; height: 32px; }
.icon-btn:hover { background: var(--sunk); color: var(--ink); }
.icon-btn.bordered { border: 1px solid var(--line); background: var(--surface); }
.icon-btn svg { width: 18px; height: 18px; }
.fab { display: none; }
.view { display: grid; gap: 18px; }
.notice { margin: 0 0 14px; padding: 11px 14px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line)); font-size: 13.5px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-md); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .sub { font-size: 12.5px; color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.g-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.kpi { display: grid; gap: 6px; align-content: start; }
.kpi .v { font-size: clamp(19px, 1.2vw + 10px, 26px); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; overflow-wrap: anywhere; }
.kpi .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 12px; padding: 2px 7px; border-radius: 99px; }
.delta.bad { background: color-mix(in srgb, var(--exp) 13%, transparent); color: var(--exp); }
.delta.good { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent-ink); }
.delta.flat { background: var(--sunk); color: var(--muted); }
.kpi.hero { background: var(--hero); color: var(--hero-ink); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); box-shadow: 0 12px 34px color-mix(in srgb, var(--accent) 18%, transparent); position: relative; overflow: hidden; }
.kpi.hero::after { content: ""; position: absolute; right: -18px; bottom: -22px; width: 150px; aspect-ratio: 727 / 477; background: var(--hero-ink); opacity: .07; -webkit-mask: url(brand/emblem-mask.png) center / contain no-repeat; mask: url(brand/emblem-mask.png) center / contain no-repeat; }
.kpi.hero .label, .kpi.hero .meta { color: var(--hero-sub); }
.kpi.hero .delta { background: rgb(255 255 255 / .12); color: var(--hero-ink); }
.meter { height: 8px; border-radius: 99px; background: var(--sunk); overflow: hidden; border: 1px solid var(--line); }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.meter.warn i { background: var(--warn); } .meter.over i { background: var(--exp); }
.chart svg { width: 100%; height: auto; display: block; }
.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.empty { text-align: center; color: var(--muted); padding: 26px 8px; font-size: 14px; }
.skeleton { height: 140px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--sunk), var(--line), var(--sunk)); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: sk 1.4s ease infinite; } .meter i { transition: width .35s ease; } }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- lists ---------- */
.item { width: 100%; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 6px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--sunk); }
.item.sel-mode { grid-template-columns: 22px 38px minmax(0, 1fr) auto; }
.item.selected { background: var(--accent-soft); }
.item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; flex: none; }
.item .t { min-width: 0; }
.item .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .a { font-weight: 700; text-align: right; }
.item .a small { display: block; font-weight: 500; color: var(--faint); font-size: 11.5px; }
.group-h { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 700; padding: 14px 6px 6px; border-bottom: 1px solid var(--line); }
.link-btn { border: 0; background: transparent; color: var(--accent-ink); font-weight: 700; padding: 4px 2px; }
.crow { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 4px; border: 0; background: transparent; width: 100%; text-align: left; border-bottom: 1px solid var(--line); }
.crow:last-child { border-bottom: 0; }
.crow .meta { min-width: 0; display: grid; gap: 6px; }
.crow .nm { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.crow .nm span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.crow .nm span:last-child { flex: none; }
.crow .bar { height: 6px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.crow .bar i { display: block; height: 100%; border-radius: 99px; }
.crow .r { text-align: right; font-weight: 700; display: grid; gap: 1px; }
.crow .r small { font-weight: 500; font-size: 11.5px; color: var(--muted); }
button.crow:hover { background: var(--sunk); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--sunk); }
.heat td { text-align: right; font-size: 12px; padding: 7px 8px; border-bottom: 2px solid var(--surface); }
.heat td.c { text-align: left; font-weight: 600; max-width: 190px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- filters & forms ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 12px; }
.seg { display: inline-grid; grid-auto-flow: column; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 3px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--raise); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg button[aria-pressed="true"].e { color: var(--exp); } .seg button[aria-pressed="true"].i { color: var(--inc); }
.select, .input { border: 1px solid var(--line); background: var(--sunk); border-radius: 10px; padding: 9px 11px; font-size: 14px; color: var(--ink); min-width: 0; }
.select:focus, .input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm { width: 112px; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--sunk); border-radius: 10px; padding: 0 10px; flex: 1 1 200px; min-width: 0; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 16px; height: 16px; color: var(--muted); }
.search input { border: 0; background: transparent; padding: 9px 0; width: 100%; outline: none; min-width: 0; }
details.dd { position: relative; }
details.dd summary { list-style: none; cursor: pointer; }
details.dd summary::-webkit-details-marker { display: none; }
details.dd .menu { position: absolute; z-index: 15; top: calc(100% + 6px); left: 0; width: min(340px, 86vw); max-height: 380px; overflow: auto; background: var(--raise); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px; }
details.dd.right .menu { left: auto; right: 0; }
.menu label { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; font-size: 13.5px; }
.menu label:hover { background: var(--sunk); }
.menu input[type="checkbox"] { accent-color: var(--accent); }
.menu .mh { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.summary-bar { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; font-size: 13.5px; }
.summary-bar b { font-size: 16px; }
label.f { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.selbar { position: sticky; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 12; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; background: var(--raise); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 10px 12px; }
.selbar b { margin-right: auto; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .wd { text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 700; padding-bottom: 2px; }
.day { border: 1px solid var(--line); background: var(--sunk); border-radius: 10px; min-height: 78px; padding: 6px 7px 7px; display: grid; align-content: start; gap: 2px; text-align: left; min-width: 0; overflow: hidden; position: relative; }
.day:hover { border-color: var(--accent); }
.day .d { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.day small { font-size: 11px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.day .heatbar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--exp); opacity: .75; }
.day.today .d { color: #1b1b1b; background: var(--today); border-radius: 99px; padding: 0 6px; justify-self: start; }
.day[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.day.blank { visibility: hidden; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .55); z-index: 40; backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface); border-left: 1px solid var(--line); z-index: 41; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px); }
@media (prefers-reduced-motion: no-preference) { .drawer:not([hidden]) { animation: slide .22s ease-out; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-family: var(--display); font-size: 19px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: grid; gap: 16px; align-content: start; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.seg.wide { display: grid; grid-template-columns: 1fr 1fr; }
.seg.wide button { padding: 9px 0; font-size: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.amount-box { display: flex; align-items: baseline; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; background: var(--sunk); }
.amount-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.amount-box b { font-size: 22px; color: var(--muted); }
.amount-box input { border: 0; background: transparent; font-size: 30px; font-weight: 800; width: 100%; outline: none; min-width: 0; }
.date-row { display: flex; gap: 6px; align-items: center; }
.date-row .input { flex: 1; }
.date-row .icon-btn { border: 1px solid var(--line); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { border: 1px solid var(--line); background: var(--sunk); border-radius: 99px; padding: 4px 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick button:hover { border-color: var(--accent); color: var(--ink); }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.cat { border: 1px solid var(--line); background: var(--sunk); border-radius: 12px; padding: 9px 4px 8px; display: grid; justify-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; line-height: 1.2; text-align: center; min-width: 0; }
.cat:hover { border-color: var(--accent); }
.cat .ico { width: 32px; height: 32px; border-radius: 10px; font-size: 16px; }
.cat span:last-child { overflow-wrap: anywhere; max-width: 100%; }
.cat[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--raise); border-radius: 10px; padding: 10px 16px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: var(--shadow-sm); text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 25%, transparent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.grow { flex: 1; }
.btn.danger { color: var(--danger); }
.btn.solid-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; z-index: 50; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); }

/* ---------- settings / admin ---------- */
.set-grid { display: grid; gap: 14px; }
.catedit { display: grid; gap: 6px; }
.catrow { display: grid; grid-template-columns: 30px 48px minmax(0, 1fr) 40px 40px; gap: 6px; align-items: center; }
.catrow.budgeted { grid-template-columns: 30px 48px minmax(0, 1fr) 96px 40px 40px; }
.catrow input { border: 1px solid var(--line); background: var(--sunk); border-radius: 9px; padding: 7px 8px; min-width: 0; width: 100%; }
.catrow input[type="color"] { padding: 2px; height: 36px; }
.catrow .ico-in { text-align: center; font-size: 17px; }
.catrow .order { display: grid; gap: 2px; }
.catrow .order button { border: 0; background: transparent; color: var(--muted); height: 17px; padding: 0; display: grid; place-items: center; }
.catrow .order button:hover { color: var(--accent-ink); }
.catrow .order svg { width: 14px; height: 14px; }
.catrow .uses { grid-column: 3 / -1; font-size: 11.5px; color: var(--faint); margin-top: -2px; }
.catmove { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: var(--sunk); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.small-btn { border: 1px solid var(--line); background: var(--raise); border-radius: 9px; height: 36px; font-size: 16px; color: var(--muted); }
.small-btn:hover { color: var(--danger); border-color: var(--danger); }
.toggle-list { display: grid; gap: 6px; }
.toggle-list label { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink); font-weight: 500; }
.toggle-list input { width: 18px; height: 18px; accent-color: var(--accent); }
.cred { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 12px; padding: 14px 16px; display: grid; gap: 8px; }
.cred pre { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; white-space: pre-wrap; color: var(--ink); }
.share { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share code { background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; overflow-wrap: anywhere; flex: 1 1 220px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- sign-in ---------- */
.gate { min-height: 100%; display: grid; place-items: center; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 40px; background: radial-gradient(900px 480px at 50% -8%, var(--accent-soft), transparent 70%), var(--bg); }
.gate-card { width: 100%; max-width: 400px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px 22px; box-shadow: var(--shadow-md); }
.gate-brand { display: grid; justify-items: center; gap: 6px; margin-bottom: 6px; }
.gate-brand .emblem { height: 74px; }
.gate-brand .wordmark { font-size: 24px; }
.tagline { font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.gate-title { font-family: var(--display); font-size: 19px; font-weight: 700; margin: 6px 0 0; text-align: center; }
.gate-card p { margin: 0; text-align: center; }
.gate-card .input { padding: 12px 14px; font-size: 16px; }
.gate-foot { font-family: var(--mark); font-size: 11px; letter-spacing: .22em; color: var(--faint); text-transform: uppercase; margin-top: 4px !important; }

/* ---------- responsive tiers ---------- */
@media (min-width: 1700px) {
  body { font-size: 15px; }
  .kpis { gap: 22px; } .view, .grid { gap: 22px; }
  .day { min-height: 92px; }
}
@media (max-width: 1380px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  :root { --side: 76px; }
  .side { padding-left: 10px; padding-right: 10px; align-items: center; }
  .side-brand .wordmark, .nav button span, .new-btn span, .me-text, .sync-row span:last-child { display: none; }
  .side-brand { padding: 0; }
  .nav button { justify-content: center; padding: 11px; }
  .nav button[aria-current="page"]::before { left: -10px; }
  .new-btn { padding: 10px; width: 46px; height: 46px; }
  .side-foot { justify-items: center; }
  .side-actions { flex-direction: column; }
  .g-3-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  body { font-size: 15px; }
  .side { inset: auto 0 0 0; width: auto; height: auto; flex-direction: row; gap: 0; padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px)); border-right: 0; border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgb(0 0 0 / .18); overflow: visible; }
  .side-brand, .side .new-btn, .side-foot { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .nav button { flex-direction: column; gap: 3px; padding: 8px 0 7px; font-size: 10.5px; border-radius: 0; background: transparent !important; }
  .nav button span { display: block !important; }
  .nav button[aria-current="page"] { color: var(--accent-ink); }
  .nav button[aria-current="page"]::before { left: 30%; right: 30%; top: 0; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .main { margin-left: 0; padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }
  .top { padding-block: 10px; gap: 10px; flex-wrap: wrap; }
  .top-brand { display: flex; margin-right: auto; }
  .top-brand .emblem { height: 24px; }
  .top-brand .wordmark { font-size: 14px; }
  .page-title { display: none; }
  .top-theme { display: grid; }
  .month-title { min-width: 7.4em; font-size: 13.5px; }
  .fab { display: grid; place-items: center; position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(74px + env(safe-area-inset-bottom, 0px)); width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 35%, transparent); z-index: 25; }
  .fab svg { width: 26px; height: 26px; }
  .card { padding: 15px; }
  .g-2 { grid-template-columns: minmax(0, 1fr); }
  .kpis, .view, .grid { gap: 12px; }
  .day { min-height: 56px; padding: 4px 4px 5px; border-radius: 8px; }
  .day small { font-size: 9.5px; }
  .cal { gap: 3px; }
  .toast { bottom: calc(146px + env(safe-area-inset-bottom, 0px)); }
  .filters { padding: 10px; gap: 8px; }
  .filters > * { flex: 1 1 auto; }
  .selbar { bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }
  .catrow.budgeted { grid-template-columns: 26px 44px minmax(0, 1fr) 76px 36px 36px; }
}
@media (max-width: 560px) {
  .top-tools { display: contents; }
  .top-theme { order: 2; }
  .month { order: 3; flex: 1 1 100%; justify-content: space-between; }
  .catrow, .catrow.budgeted { grid-template-columns: 26px 44px minmax(0, 1fr) 36px; }
  .catrow input[data-cf="budget"] { grid-column: 3 / 4; }
}
@media (max-width: 380px) {
  body { font-size: 14px; }
  .kpi .v { font-size: 17px; }
  .card { padding: 13px; }
  .nav button { font-size: 9.5px; }
  .nav button svg { width: 19px; height: 19px; }
  .gate-card { padding: 24px 18px 18px; }
}
@media (max-height: 520px) and (orientation: landscape) and (max-width: 960px) {
  .fab { bottom: calc(66px + env(safe-area-inset-bottom, 0px)); width: 48px; height: 48px; }
  .nav button { padding: 5px 0 4px; }
}
@media (max-width: 560px) {
  .catrow .small-btn { grid-row: 1; grid-column: 4; }
  .catrow input[data-cf="budget"] { grid-row: 2; grid-column: 3 / 5; }
}
@media (max-width: 330px) { .kpis { grid-template-columns: minmax(0, 1fr); } }

/* entry drawer: modes, several lines, grouped categories */
.drawer-mode { padding: 12px 20px 0; }
.lines { display: grid; gap: 8px; }
.line { display: grid; grid-template-columns: 34px minmax(0, 1.2fr) 100px 36px; gap: 6px; align-items: center; background: var(--sunk); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.line input[data-lf="memo"] { grid-column: 2 / 4; }
.line .small-btn { grid-row: 1; grid-column: 4; }
.line .select, .line .input { padding: 8px 9px; font-size: 14px; background: var(--surface); }
.line-type { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; font-weight: 800; line-height: 1; }
.line-type.exp { color: var(--exp); } .line-type.inc { color: var(--inc); }
.batch-total { font-size: 13.5px; color: var(--muted); }
.cat-group { display: grid; gap: 6px; }
.cat-group + .cat-group { margin-top: 6px; }

/* category editor */
.catrow { grid-template-columns: 30px 40px minmax(0, 1fr) 40px 40px; }
.catrow.budgeted { grid-template-columns: 30px 40px minmax(0, 1fr) 110px 40px 40px; }
.catrow .cat-ico { width: 40px; height: 36px; border: 1px solid var(--line); cursor: pointer; }
.catrow.is-hidden > input[data-cf="name"] { opacity: .55; text-decoration: line-through; }
.catrow .uses { grid-column: 3 / -1; }
.catedit-panel { grid-column: 1 / -1; display: grid; gap: 12px; background: var(--sunk); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; max-height: 176px; overflow-y: auto; }
.emoji-grid button { height: 38px; border: 1px solid transparent; background: var(--surface); border-radius: 8px; font-size: 18px; }
.emoji-grid button:hover, .emoji-grid button[aria-pressed="true"] { border-color: var(--accent); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }
.swatches input[type="color"] { width: 40px; height: 30px; padding: 1px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
label.f.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
label.f.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.grouprow { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 6px; }
@media (max-width: 560px) {
  .catrow, .catrow.budgeted { grid-template-columns: 26px 40px minmax(0, 1fr) 36px 36px; }
  .catrow .small-btn.more { grid-row: 1; grid-column: 4; }
  .catrow .small-btn:not(.more) { grid-row: 1; grid-column: 5; }
  .catrow input[data-cf="budget"] { grid-row: 2; grid-column: 3 / 6; }
  .line { grid-template-columns: 34px minmax(0, 1fr) 90px 34px; }
}

/* import */
.dropzone { display: grid; justify-items: center; gap: 6px; padding: 26px 16px; border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 14px; background: var(--sunk); cursor: pointer; text-align: center; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 30px; height: 30px; color: var(--accent); }
.howto summary { cursor: pointer; font-weight: 700; font-size: 13.5px; }
.howto ul { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; color: var(--muted); }
.quick button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
table.raw td, table.raw th { font-size: 12.5px; }

/* ================= Royal finish =================
   Antique gold joins the emerald: engraved serif titles and figures, gold hairlines and frames,
   cheque-style amounts in words. Gold is ornament only; green stays the action colour. */
:root, :root[data-theme="light"] {
  --gold: #9a7428; --gold-2: #c09a4e; --gold-soft: #f4ecd9; --gold-line: color-mix(in srgb, #b08d45 45%, transparent);
  --serif: "Cormorant Garamond", "Libre Baskerville", Georgia, serif;
  --hero: linear-gradient(140deg, #072e19 0%, #0b4626 50%, #0f6a37 100%); --hero-ink: #fbf4e2; --hero-sub: #e5d6ad;
}
:root[data-theme="dark"] {
  --gold: #d8b765; --gold-2: #f0d89a; --gold-soft: #2a2312; --gold-line: color-mix(in srgb, #d8b765 32%, transparent);
  --hero: linear-gradient(140deg, #061a10 0%, #0b2a19 55%, #10402a 100%); --hero-ink: #f3e3b3; --hero-sub: #cdbb8c;
}
body { background: radial-gradient(1400px 700px at 110% -20%, color-mix(in srgb, var(--gold) 7%, transparent), transparent 60%),
                   radial-gradient(1000px 600px at -10% 110%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 60%), var(--bg); background-attachment: fixed; }

/* titles */
.page-title { font-family: var(--serif); font-size: 34px; font-weight: 700; letter-spacing: .005em; line-height: 1.05; }
.top { border-bottom: 1px solid transparent; border-image: linear-gradient(90deg, var(--gold-line), color-mix(in srgb, var(--gold) 55%, transparent) 30%, var(--gold-line) 70%, transparent) 1; margin-bottom: 18px; }
h2, .card h2 { font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: .01em; }
.label { color: var(--gold); letter-spacing: .16em; font-size: 10.5px; }
.card-head { padding-bottom: 10px; border-bottom: 1px solid var(--gold-line); }
.drawer-head h2, .gate-title { font-family: var(--serif); font-size: 24px; }

/* cards: fine gold frame on top */
.card { position: relative; }
.card::before { content: ""; position: absolute; left: 18px; right: 18px; top: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold) 50%, transparent); opacity: .55; pointer-events: none; }
.kpi .v { font-family: var(--serif); font-weight: 700; font-size: clamp(26px, 1.5vw + 14px, 36px); letter-spacing: 0; font-variant-numeric: lining-nums tabular-nums; }
.kpi.hero { border: 1px solid var(--gold-line); box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--gold) 10%, transparent), inset 0 0 0 5px var(--gold-line), 0 14px 40px rgb(0 0 0 / .35); }
.kpi.hero::before { display: none; }
.kpi.hero .label { color: var(--gold-2); }
.kpi.hero .v { color: var(--hero-ink); }

/* amounts in words: written like a cheque */
.words { display: block; font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 15px; line-height: 1.3; color: var(--gold); letter-spacing: .005em; text-wrap: pretty; }
.words.sm { font-size: 13px; color: color-mix(in srgb, var(--gold) 80%, var(--muted)); }
.words:empty { display: none; }
.kpi.hero .words { color: var(--hero-sub); }
.kpi .words { border-top: 1px dashed var(--gold-line); padding-top: 4px; }
.amount-box + .words { padding: 2px 4px 0; min-height: 1.3em; }
.summary-bar .words { max-width: 280px; }

/* sidebar & navigation */
.side { border-right: 1px solid var(--gold-line); }
.side-brand { padding-bottom: 14px; border-bottom: 1px solid var(--gold-line); }
.nav button[aria-current="page"]::before { background: linear-gradient(180deg, var(--gold-2), var(--gold)); }
.side-foot { border-top-color: var(--gold-line); }
.avatar { border-color: var(--gold-line); color: var(--gold); background: var(--gold-soft); font-family: var(--serif); font-size: 15px; }
.wordmark { text-shadow: 0 0 18px color-mix(in srgb, var(--accent) 25%, transparent); }

/* buttons & controls: gold focus ring, engraved primary */
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: color-mix(in srgb, var(--gold) 45%, var(--accent)); }
:focus-visible { outline-color: var(--gold); }
.month { border-color: var(--gold-line); }
.month-title { font-family: var(--serif); font-size: 17px; letter-spacing: .02em; }

/* tables: small-caps headers in gold */
th { color: var(--gold); letter-spacing: .12em; }

/* sign-in: framed like a certificate */
.gate-card { border: 1px solid var(--gold-line); box-shadow: inset 0 0 0 6px var(--surface), inset 0 0 0 7px var(--gold-line), var(--shadow-md); }
.gate-brand { padding-bottom: 14px; border-bottom: 1px solid var(--gold-line); }
.tagline { color: var(--gold); }
.gate-foot { color: var(--gold); opacity: .8; }

/* ornament between page title and content on wide screens */
@media (min-width: 861px) {
  .top::after { content: "❖"; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); color: var(--gold); font-size: 13px; background: var(--bg); padding: 0 10px; line-height: 1; }
}
@media (max-width: 860px) {
  .kpi .v { font-size: 26px; }
  .words { font-size: 14px; }
  .page-title { font-size: 28px; }
}
@media (max-width: 380px) { .kpi .v { font-size: 22px; } .words { font-size: 13px; } }
.crow .meta > * { min-width: 0; }

/* chart tooltips */
.tip { position: fixed; z-index: 60; pointer-events: none; min-width: 170px; max-width: 280px; background: var(--raise); color: var(--ink); border: 1px solid var(--gold-line); border-radius: 10px; padding: 9px 12px; box-shadow: var(--shadow-lg); font-size: 13px; display: grid; gap: 4px; }
.tip b { font-family: var(--serif); font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.tip .tr { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; }
.tip .tr i { width: 10px; height: 10px; border-radius: 3px; }
.tip .tr em { font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }
.tip small { color: var(--muted); font-size: 12px; }
.hit { fill: transparent; cursor: crosshair; }
.hg:hover .hit, .hg.on .hit { fill: color-mix(in srgb, var(--gold) 9%, transparent); }
.hg .guide { stroke: var(--gold); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.hg .dot { opacity: 0; }
.hg:hover .guide, .hg:hover .dot, .hg.on .guide, .hg.on .dot { opacity: 1; }
.arc { cursor: pointer; transition: stroke-width .15s; }
.arc:hover, .arc.on { stroke-width: 32; }
.heat td[data-tip] { cursor: default; }

/* adding income is as visible as adding an expense */
.new-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.new-row .btn { padding: 10px 8px; }
.btn.new-inc, .btn.add-inc { color: var(--inc); border-color: color-mix(in srgb, var(--inc) 45%, var(--line)); }
.btn.add-exp { color: var(--exp); border-color: color-mix(in srgb, var(--exp) 45%, var(--line)); }
.btn.new-inc:hover, .btn.add-inc:hover { background: color-mix(in srgb, var(--inc) 10%, var(--raise)); }
.btn.add-exp:hover { background: color-mix(in srgb, var(--exp) 10%, var(--raise)); }
.drawer-mode { display: grid; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-switch button { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--sunk); font-weight: 800; font-size: 15px; color: var(--muted); }
.type-switch button span { font-size: 20px; line-height: 1; }
.type-switch button.e[aria-pressed="true"] { color: var(--exp); border-color: var(--exp); background: color-mix(in srgb, var(--exp) 12%, var(--surface)); box-shadow: 0 0 0 1px var(--exp); }
.type-switch button.i[aria-pressed="true"] { color: var(--inc); border-color: var(--inc); background: color-mix(in srgb, var(--inc) 12%, var(--surface)); box-shadow: 0 0 0 1px var(--inc); }
.line { grid-template-columns: 92px minmax(0, 1fr) 100px 36px; }
.line-type { width: auto; font-size: 12.5px; padding: 0 6px; white-space: nowrap; }
.fab-menu { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(140px + env(safe-area-inset-bottom, 0px)); z-index: 26; display: grid; gap: 8px; justify-items: end; }
.fab-menu .btn { box-shadow: var(--shadow-lg); padding: 11px 18px; font-size: 15px; background: var(--raise); }
@media (min-width: 861px) { .fab-menu { display: none !important; } }
@media (max-width: 1180px) and (min-width: 861px) {
  .new-row { grid-template-columns: 1fr; }
  .new-row .btn span { display: none; }
  .new-row .btn { width: 46px; height: 46px; padding: 0; }
}
@media (max-width: 860px) { .new-row { display: none; } }
@media (max-width: 560px) { .line { grid-template-columns: 84px minmax(0, 1fr) 80px 34px; } }
.tip .hint { color: var(--gold); font-style: italic; font-family: var(--serif); font-size: 13px; border-top: 1px dashed var(--gold-line); padding-top: 4px; margin-top: 2px; }
[data-drill] { cursor: pointer; }

/* fixing mistakes */
.suspect { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.suspect:last-child { border-bottom: 0; }
.suspect .t { min-width: 0; display: grid; }
.suspect .t b { font-weight: 600; }
.suspect .t small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suspect .t small.why { color: var(--warn); white-space: normal; font-weight: 600; }
.suspect .a { font-weight: 800; font-size: 16px; }
.suspect .row-actions { grid-column: 2 / -1; justify-content: flex-start; }
.card.checks { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.edit-table td { padding: 4px 4px; }
.edit-table .input, .edit-table .select { padding: 6px 8px; font-size: 13.5px; background: var(--surface); }
.edit-table .cell[data-cell="memo"] { min-width: 180px; width: 100%; }
.edit-table .amt { width: 120px; text-align: right; font-weight: 700; }
.edit-table select.exp { color: var(--exp); } .edit-table select.inc { color: var(--inc); }
.edit-table .st { font-size: 12.5px; min-width: 70px; }
.toast { display: flex; align-items: center; gap: 12px; }
.toast-undo { border: 0; background: transparent; color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 4px; }
.fixin { display: inline-flex; gap: 4px; }
.fixin .input { width: 120px; padding: 6px 8px; }

/* summary figures open their entries */
.kpi.click { cursor: pointer; transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; }
.kpi.click:hover { border-color: var(--gold-line); transform: translateY(-2px); box-shadow: var(--shadow-md), 0 0 0 1px var(--gold-line); }
.kpi.click:not(.hero)::after { content: "View entries ›"; position: absolute; right: 14px; top: 14px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--gold); opacity: 0; transition: opacity .12s; }
.kpi.click:not(.hero):hover::after, .kpi.click:not(.hero):focus-visible::after { opacity: .9; }
/* the hero keeps its emblem watermark (::after); its hint uses ::before instead */
.kpi.hero.click::before { display: block; content: "View entries ›"; left: auto; right: 14px; top: 14px; height: auto; background: none; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--gold-2); opacity: 0; transition: opacity .12s; }
.kpi.hero.click:hover::before, .kpi.hero.click:focus-visible::before { opacity: .9; }
@media (hover: none) { .kpi.click:not(.hero)::after, .kpi.hero.click::before { opacity: .75; content: "›"; font-size: 18px; top: 10px; } }

/* calendar: editable day list + quick add */
.erow { display: grid; grid-template-columns: 36px minmax(110px, 1fr) minmax(0, 1.2fr) 130px auto; gap: 6px; align-items: center; padding: 6px 2px; border-bottom: 1px solid var(--line); }
.erow:has(input[type="date"]) { grid-template-columns: 36px minmax(110px, 1fr) minmax(0, 1.2fr) 140px 130px auto; }
.erow .select, .erow .input { padding: 6px 8px; font-size: 13.5px; background: var(--surface); min-width: 0; }
.erow .amt-wrap { display: flex; align-items: center; gap: 2px; }
.erow .sign { font-weight: 800; width: 12px; text-align: center; }
.erow.is-exp .sign, .erow.is-exp .amt { color: var(--exp); } .erow.is-inc .sign, .erow.is-inc .amt { color: var(--inc); }
.erow .amt { width: 100%; text-align: right; font-weight: 800; }
.erow .row-tools { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.erow .row-tools .st { min-width: 14px; font-size: 13px; }
.erow .small-btn { width: 32px; height: 32px; }
.qadd { display: grid; grid-template-columns: auto minmax(110px, 1fr) minmax(0, 1.2fr) 120px auto; gap: 6px; align-items: center; margin-top: 12px; padding: 10px; border: 1px dashed var(--gold-line); border-radius: 12px; background: var(--sunk); }
.qadd .select, .qadd .input { padding: 7px 8px; font-size: 13.5px; background: var(--surface); min-width: 0; }
.qadd .amt { text-align: right; font-weight: 800; }
.type-switch.sm { gap: 4px; }
.type-switch.sm button { padding: 6px 8px; font-size: 12.5px; border-radius: 9px; white-space: nowrap; }
.cal-detail { container-type: inline-size; }
@container (max-width: 640px) {
  .erow, .erow:has(input[type="date"]) { grid-template-columns: 34px minmax(0, 1fr) 118px auto; row-gap: 4px; }
  .erow .ico { grid-column: 1; grid-row: 1 / 3; align-self: start; }
  .erow .cell[data-cell="category"] { grid-column: 2; grid-row: 1; }
  .erow .amt-wrap { grid-column: 3; grid-row: 1; }
  .erow .row-tools { grid-column: 4; grid-row: 1; }
  .erow .cell[data-cell="memo"] { grid-column: 2 / 4; grid-row: 2; }
  .erow:has(input[type="date"]) .cell[data-cell="memo"] { grid-column: 2; }
  .erow .cell[data-cell="date"] { grid-column: 3; grid-row: 2; }
  .qadd { grid-template-columns: minmax(0, 1fr) 118px auto; }
  .qadd .type-switch { grid-column: 1 / -1; }
  .qadd .select { grid-column: 1 / -1; }
  .qadd .input[data-qa="memo"] { grid-column: 1; }
}
@container (max-width: 380px) {
  .erow, .erow:has(input[type="date"]) { grid-template-columns: 30px minmax(0, 1fr) 104px; }
  .erow .row-tools { grid-column: 3; grid-row: 3; }
  .erow .cell[data-cell="date"] { grid-column: 2; grid-row: 3; }
  .qadd { grid-template-columns: minmax(0, 1fr) 104px; }
  .qadd .btn { grid-column: 1 / -1; }
}

/* ===== every summary figure gets its own jewel tone (Spent = emerald, Income = sapphire,
   Net = antique gold, Budget/Average = amethyst, anything in the red = garnet) ===== */
.kpi.hero.v-exp { --hero: linear-gradient(140deg, #061a10 0%, #0b2a19 55%, #10402a 100%); --hero-ink: #f3e3b3; --hero-sub: #cdbb8c; }
.kpi.hero.v-inc { --hero: linear-gradient(140deg, #06142a 0%, #0b2546 55%, #123b6b 100%); --hero-ink: #d6e9ff; --hero-sub: #a8c3e2; }
.kpi.hero.v-net { --hero: linear-gradient(140deg, #1c1406 0%, #30230b 55%, #4a3612 100%); --hero-ink: #f6e2a6; --hero-sub: #d8c38c; }
.kpi.hero.v-bud { --hero: linear-gradient(140deg, #170b1f 0%, #281436 55%, #3d1f52 100%); --hero-ink: #efdcfa; --hero-sub: #c9b2db; }
.kpi.hero.v-neg { --hero: linear-gradient(140deg, #1f0708 0%, #360d10 55%, #551518 100%); --hero-ink: #ffd6d0; --hero-sub: #e3aca4; }
:root[data-theme="light"] .kpi.hero.v-exp { --hero: linear-gradient(140deg, #072e19 0%, #0b4626 50%, #0f6a37 100%); }
:root[data-theme="light"] .kpi.hero.v-inc { --hero: linear-gradient(140deg, #0a2a52 0%, #123d75 50%, #1d5aa3 100%); }
:root[data-theme="light"] .kpi.hero.v-net { --hero: linear-gradient(140deg, #3a2a08 0%, #5c4410 50%, #87661c 100%); }
:root[data-theme="light"] .kpi.hero.v-bud { --hero: linear-gradient(140deg, #2b1238 0%, #44205a 50%, #643184 100%); }
:root[data-theme="light"] .kpi.hero.v-neg { --hero: linear-gradient(140deg, #3d0b0e 0%, #631317 50%, #8f1c22 100%); }
.kpi.hero .v.inc, .kpi.hero .v.exp, .kpi.hero .v { color: var(--hero-ink); }
.kpi.hero .meta .muted, .kpi.hero .v .muted { color: var(--hero-sub) !important; }
.kpi.hero .delta.bad { background: rgb(255 120 110 / .22); color: #ffd0cb; }
.kpi.hero .delta.good { background: rgb(120 230 170 / .2); color: #c9f7dc; }
.kpi.hero .delta.flat { background: rgb(255 255 255 / .1); color: var(--hero-sub); }
.kpi.hero .meter { background: rgb(255 255 255 / .16); }
.kpi.hero .meter i { background: var(--hero-ink); }
.kpi.hero .meter.over i { background: #ff8f84; }
.kpi.hero .link-btn { color: var(--hero-ink); text-decoration: underline; }
.kpi.hero .words { border-top-color: rgb(255 255 255 / .16); }

/* "type it" quick entry */
.quickbar, .qt-box { display: flex; gap: 8px; align-items: center; }
.quickbar .search { flex: 1; background: var(--surface); border-color: var(--gold-line); box-shadow: var(--shadow-sm); }
.quickbar .search input { padding: 11px 0; font-size: 15px; }
.qt-prev { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; min-height: 0; }
.qt-prev:empty { display: none; }
.qt-prev .qp { background: var(--sunk); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-weight: 700; color: var(--ink); }
.qt-prev .qp.exp { border-color: color-mix(in srgb, var(--exp) 35%, var(--line)); }
.qt-prev .qp.inc { border-color: color-mix(in srgb, var(--inc) 35%, var(--line)); }
.qt-prev .qp small { font-weight: 500; color: var(--muted); }
.line:has(input[data-lf="date"]) input[data-lf="memo"] { grid-column: 2 / 3; }
.line input[data-lf="date"] { grid-column: 3 / 4; grid-row: 2; padding: 6px; font-size: 12.5px; }
.qclear { border: 0; background: transparent; color: var(--muted); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.qclear:hover { background: var(--sunk); color: var(--ink); }
.qclear svg { width: 14px; height: 14px; }

/* ---------- v4: payslips, documents, two-step sign-in, photos, demo ---------- */
.small { font-size: 12.5px; margin: 0; }
.warn { color: var(--warn); }
p.warn { margin: 0; }
.notice.soft { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 28%, var(--line)); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: inherit; }
.form-grid.three { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.form-grid.four { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.select.sm { width: auto; padding-block: 5px; font-size: 13px; }
.code-in { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .25em; font-size: 18px !important; text-align: center; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline .input { flex: 1 1 160px; max-width: 260px; }

/* confirmation dialog */
.modal-wrap { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgb(0 0 0 / .45); backdrop-filter: blur(2px); }
.modal { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 20px; display: grid; gap: 12px; }
.modal h2 { margin: 0; font-family: var(--display); font-size: 18px; }
.modal p { margin: 0; }
.modal .actions { justify-content: flex-end; }
.big-amt { display: grid; gap: 3px; padding: 10px 12px; border-radius: 10px; background: var(--sunk); border: 1px solid var(--line); }
.big-amt b { font-size: 22px; }
.big-amt small { color: var(--muted); font-size: 12.5px; }
@media (prefers-reduced-motion: no-preference) { .modal { animation: pop .16s ease-out; } @keyframes pop { from { transform: scale(.96); opacity: 0; } } }

/* photo */
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.xl { width: 64px; height: 64px; font-size: 22px; }
.photo-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* payslips */
.fy-seg { justify-self: start; }
.pay-income { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px; margin: 0; display: grid; gap: 8px; }
.pay-income legend { font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 6px; }
label.radio { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
label.radio input { accent-color: var(--accent); width: 17px; height: 17px; }
.pf-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.pf-sum > div { display: grid; gap: 2px; }
.pf-sum b { font-size: 20px; }
.pf-sum small { color: var(--muted); font-size: 12px; }
.pf-bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 5px; align-items: end; height: 96px; margin-bottom: 10px; }
.pf-bar { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 4px; text-align: center; }
.pf-bar i { align-self: end; display: block; min-height: 2px; border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, var(--gold-2, var(--accent-2)), var(--gold, var(--accent))); }
.pf-bar span { font-size: 10.5px; color: var(--faint); }
.pay-months { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.pm { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--sunk); }
.pm span { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.pm b { font-size: 14px; }
.pm.have { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.pm.have b { color: var(--inc); }
.pm.miss { border-style: dashed; border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.pay-table td { white-space: nowrap; }

/* documents */
.vault-lock { display: grid; justify-items: center; text-align: center; gap: 10px; padding-block: 34px; }
.vault-lock h2 { margin: 0; font-family: var(--display); }
.vault-lock p { max-width: 520px; margin: 0; }
.vault-ico { font-size: 38px; }
.vault-form { display: grid; gap: 10px; width: 100%; max-width: 320px; justify-items: stretch; }
.vault-form .seg { justify-self: center; }
.vault-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: var(--r-sm); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); font-size: 13.5px; }
.vault-bar > span:first-child { margin-right: auto; }
.vault-bar b { font-variant-numeric: tabular-nums; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.doc { display: grid; gap: 10px; align-content: start; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--sunk); }
.doc-head { display: flex; align-items: center; gap: 10px; }
.doc-ico { font-size: 24px; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--raise); border: 1px solid var(--line); flex: none; }
.doc-title { display: grid; min-width: 0; flex: 1; }
.doc-title small { color: var(--muted); font-size: 12.5px; }
.doc-num { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.doc-num code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 160px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: .08em; padding: 7px 10px; border-radius: 8px; background: var(--raise); border: 1px solid var(--line); overflow-wrap: anywhere; }
.doc-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.doc-files { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 10px; border-radius: 10px; background: var(--raise); border: 1px solid var(--line); font-size: 13px; }
.file-chip small { color: var(--faint); }
.file-chip .small-btn { height: 30px; width: 30px; }
details.audit summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; list-style: none; }
details.audit summary::-webkit-details-marker { display: none; }
details.audit summary h2 { margin: 0; }
details.audit summary .sub { font-size: 12.5px; color: var(--muted); }
details.audit[open] summary { margin-bottom: 12px; }

/* two-step sign-in */
.sec-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.sec-row > div { display: grid; flex: 1; min-width: 0; }
.sec-row small { color: var(--muted); font-size: 12.5px; }
.sec-ico { font-size: 22px; width: 36px; text-align: center; flex: none; }
.sec-setup { display: grid; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--sunk); border: 1px solid var(--line); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 13.5px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; letter-spacing: .06em; padding: 3px 7px; border-radius: 6px; background: var(--raise); border: 1px solid var(--line); overflow-wrap: anywhere; }
.gate-alt { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; font-size: 13.5px; }

/* admin */
.sys { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; font-size: 13.5px; align-items: center; }
.sys > span { color: var(--muted); }
.sys > b { font-weight: 500; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* navigation: "More" on phones */
.nav-more { display: none !important; }
.more-sheet { position: fixed; z-index: 45; right: max(10px, env(safe-area-inset-right, 0px)); bottom: calc(70px + env(safe-area-inset-bottom, 0px)); min-width: 210px; display: grid; gap: 2px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.more-sheet[hidden] { display: none; }
.more-sheet button { display: flex; align-items: center; gap: 12px; border: 0; background: transparent; padding: 11px 12px; border-radius: 10px; font-weight: 600; color: var(--ink); text-align: left; font-size: 15px; }
.more-sheet button svg { width: 20px; height: 20px; color: var(--muted); }
.more-sheet button[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
@media (max-width: 860px) {
  .nav .nav-extra { display: none !important; }
  .nav-more { display: flex !important; }
  .pf-sum b { font-size: 17px; }
  .sys { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .sys > b { margin-bottom: 8px; }
}
