/* ---------- colour themes (chosen per person in Settings) ---------- */
:root { --radius: 10px; }
html, html.theme-green { --a-l: #146c5c; --as-l: #e3f1ed; --bg-l: #f5f6f4; --chip-l: #eef1ef; --bi-l: #3f9c7f;
  --a-d: #3bb393; --as-d: #1d3530; --bg-d: #121615; --card-d: #1b2120; --chip-d: #26302d; --line-d: #2c3432; --bi-d: #45b08f; }
html.theme-pink { --bo-l: #8e7cc3; --bo-d: #a898db; --a-l: #c2185b; --as-l: #fce4ee; --bg-l: #fdf2f7; --chip-l: #f8e4ed; --bi-l: #e0609a;
  --a-d: #f48fb1; --as-d: #3d1f2c; --bg-d: #1a1216; --card-d: #251a20; --chip-d: #35242c; --line-d: #3b2a32; --bi-d: #f06d9f; }
html.theme-blue { --a-l: #1f5fa8; --as-l: #e2ecf8; --bg-l: #f3f6fa; --chip-l: #e9eff6; --bi-l: #4a8fd6;
  --a-d: #7cb3f0; --as-d: #1c2a3b; --bg-d: #11151b; --card-d: #1a2029; --chip-d: #252e3a; --line-d: #2c3542; --bi-d: #6aa7ea; }
html.theme-purple { --a-l: #6a3fa0; --as-l: #efe6f8; --bg-l: #f7f4fb; --chip-l: #efe9f6; --bi-l: #9468c9;
  --a-d: #c3a2ef; --as-d: #2b2139; --bg-d: #151219; --card-d: #1f1a26; --chip-d: #2c2536; --line-d: #352d40; --bi-d: #b48ce8; }
html.theme-orange { --bo-l: #5b84c4; --bo-d: #7fa3dd; --a-l: #b5520e; --as-l: #fbeadd; --bg-l: #fbf6f1; --chip-l: #f5ebe1; --bi-l: #e08a3c;
  --a-d: #f5a05a; --as-d: #3a2717; --bg-d: #18130f; --card-d: #221b15; --chip-d: #33281f; --line-d: #3d3026; --bi-d: #f0974d; }
html {
  --bg: var(--bg-l); --card: #ffffff; --ink: #1d2422; --muted: #66706c; --line: #e2e6e3;
  --accent: var(--a-l); --accent-ink: #ffffff; --accent-soft: var(--as-l); --chip: var(--chip-l);
  --pos: #17784a; --neg: #b3332b; --warn: #c27c0e; --xfer: #4a5fa8;
  --bar-in: var(--bi-l); --bar-out: var(--bo-l, #d9735b);
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
html.mode-dark {
  --bg: var(--bg-d); --card: var(--card-d); --ink: #e8ecea; --muted: #a0aaa6; --line: var(--line-d);
  --accent: var(--a-d); --accent-ink: #0d0d0d; --accent-soft: var(--as-d); --chip: var(--chip-d);
  --pos: #5fd096; --neg: #f58378; --warn: #eaae45; --xfer: #96a9f2;
  --bar-in: var(--bi-d); --bar-out: var(--bo-d, #e88a72);
  --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  html.mode-auto {
    --bg: var(--bg-d); --card: var(--card-d); --ink: #e8ecea; --muted: #a0aaa6; --line: var(--line-d);
    --accent: var(--a-d); --accent-ink: #0d0d0d; --accent-soft: var(--as-d); --chip: var(--chip-d);
    --pos: #5fd096; --neg: #f58378; --warn: #eaae45; --xfer: #96a9f2;
    --bar-in: var(--bi-d); --bar-out: var(--bo-d, #e88a72);
    --shadow: none;
    color-scheme: dark;
  }
}
/* text sizes; everything is sized in rem so it all scales */
html, html.ts-normal { font-size: 15px; }
html.ts-large { font-size: 17px; }
html.ts-xl { font-size: 19.5px; }
html.ts-xxl { font-size: 22.5px; }
html.ts-large svg.chart text { font-size: 14px; }
html.ts-xl svg.chart text { font-size: 16.5px; }
html.ts-xxl svg.chart text { font-size: 19px; }
html.ts-xl header nav a, html.ts-xxl header nav a { padding: .35rem .45rem; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: .4rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
h3.kind { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .8rem 0 .2rem; }
code { font-size: .85em; background: var(--chip); padding: .1em .35em; border-radius: 4px; word-break: break-all; }

/* header */
header.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem; padding: .55rem 1.2rem; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); display: flex; align-items: center; gap: .45rem; }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 1.5rem; justify-content: center; margin-bottom: 1rem; }
.logo { display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); font-family: Georgia, serif; }
header nav { display: flex; gap: .15rem; flex-wrap: wrap; align-items: center; margin-left: auto; }
header nav a, header nav .linklike { padding: .4rem .65rem; border-radius: 7px; color: var(--muted); font-size: .92rem; }
header nav a:hover, header nav .linklike:hover { background: var(--chip); color: var(--ink); text-decoration: none; }
header nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.menu-btn { display: none; margin-left: auto; font-size: 1.3rem; background: none; border: 0; color: var(--ink); cursor: pointer; }
.linklike { background: none; border: 0; cursor: pointer; font: inherit; }
@media (max-width: 860px) {
  .menu-btn { display: block; }
  header nav { display: none; width: 100%; flex-direction: column; align-items: stretch; margin: 0; }
  body.nav-open header nav { display: flex; }
  header nav form { display: block; }
  header nav .linklike { width: 100%; text-align: left; }
}

main { max-width: 79rem; margin: 0 auto; padding: 1.2rem 1.2rem 5rem; }
main.narrow { max-width: 45rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
  margin-bottom: 1rem; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 1rem; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pagehead h1 { margin-bottom: .8rem; }
.hero { text-align: center; padding: 2.5rem 1rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; font-weight: normal; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.xfer { color: var(--xfer); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.stat .k { font-size: .78rem; color: var(--muted); }
.stat .v { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.stat .v.small { font-size: .95rem; font-weight: 500; }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr 1fr; } .stat .v { font-size: 1.1rem; } }

/* tables */
table { border-collapse: collapse; width: 100%; }
table.list td, table.list th { padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600; }
table.list th.r { text-align: right; }
table.list tr:last-child td { border-bottom: 0; }
table.list tfoot th { font-size: .9rem; color: var(--ink); border-top: 2px solid var(--line); }
table.tx { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
section table.tx { border: 0; }
table.tx th { text-align: left; font-size: .78rem; color: var(--muted); padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
table.tx td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tx tr:last-child td { border-bottom: 0; }
table.tx tr.click { cursor: pointer; }
table.tx tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
table.tx tr.pending td { opacity: .75; }
td.date { white-space: nowrap; color: var(--muted); font-size: .88rem; width: 1%; }
td.cb, th.cb { width: 1%; }
.desc { color: var(--ink); font-weight: 500; }
.meta { font-size: .8rem; color: var(--muted); margin-top: .1rem; }
.meta.notes { font-style: italic; }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 0 .5rem; font-size: .74rem; margin: .1rem .15rem 0 0; color: var(--ink); }
tr.archived td { opacity: .55; }
tr.overdue td.date { color: var(--neg); font-weight: 600; }
.scroll { overflow-x: auto; }
table.raw td, table.raw th { font-size: .8rem; white-space: nowrap; }
@media (max-width: 700px) {
  .hide-sm { display: none; }
  table.tx td.date { font-size: .78rem; }
  table.tx td, table.tx th { padding: .5rem .4rem; }
}

/* forms */
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 7px; padding: .45rem .55rem; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.form label { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; font-size: .88rem; font-weight: 500; }
.form label input, .form label select, .form label textarea { font-weight: normal; width: 100%; }
.form .row { display: flex; gap: .8rem; flex-wrap: wrap; }
.form .row > label { flex: 1 1 180px; }
label.check { flex-direction: row !important; align-items: center; gap: .5rem; font-weight: normal; }
label.check input { width: auto !important; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font: inherit; font-size: .9rem; font-weight: 550;
  padding: .45rem .9rem; border-radius: 7px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--chip); }
.btn.danger { background: transparent; border-color: var(--neg); color: var(--neg); }
.btn.tiny { padding: .18rem .55rem; font-size: .78rem; }
.btn.wide { width: 100%; }
form.inline { display: inline; }
.danger-zone { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.danger-zone h3 { color: var(--neg); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 1rem; }
.seg label { margin: 0 !important; flex-direction: row !important; justify-content: center; padding: .5rem .2rem; cursor: pointer;
  border-right: 1px solid var(--line); font-weight: 550; font-size: .88rem; }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); }
.seg .seg-expense:has(input:checked) { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }
.seg .seg-income:has(input:checked), .seg .seg-refund:has(input:checked) { background: color-mix(in srgb, var(--pos) 14%, transparent); color: var(--pos); }
.seg .seg-transfer:has(input:checked) { background: color-mix(in srgb, var(--xfer) 14%, transparent); color: var(--xfer); }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem; }
.filters .grow { flex: 1 1 200px; }
.filters details.more { display: contents; }
.filters details.more summary { cursor: pointer; color: var(--accent); font-size: .88rem; padding: 0 .3rem; }
.filters details.more[open] { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; width: 100%; order: 10; }
.filters label { font-size: .85rem; display: inline-flex; gap: .3rem; align-items: center; }
.summary { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: .88rem; margin: .2rem .2rem .7rem; }
.bulkbar { position: sticky; top: 3.4rem; z-index: 10; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: .5rem .7rem; margin-bottom: .6rem; }
.pager { display: flex; justify-content: center; gap: 1rem; align-items: center; margin: 1rem 0; }
.periodnav { display: flex; gap: .7rem; align-items: center; margin-bottom: .8rem; }

.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .9rem; border: 1px solid; font-size: .92rem; }
.flash.ok { background: color-mix(in srgb, var(--pos) 10%, var(--card)); border-color: color-mix(in srgb, var(--pos) 40%, transparent); }
.flash.error { background: color-mix(in srgb, var(--neg) 10%, var(--card)); border-color: color-mix(in srgb, var(--neg) 40%, transparent); }

/* budgets */
.budget { margin-bottom: 1rem; }
.bhead { display: flex; justify-content: space-between; gap: 1rem; font-size: .92rem; margin-bottom: .25rem; }
.bhead a { font-weight: 600; color: var(--ink); }
.bar { position: relative; height: 10px; background: var(--chip); border-radius: 99px; overflow: visible; }
.bar .fill { height: 100%; border-radius: 99px; background: var(--bar-in); }
.bar.warn .fill { background: var(--warn); }
.bar.over .fill { background: var(--neg); }
.bar .marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .45; border-radius: 2px; }
.btags { margin: -.6rem 0 1rem; }
.total { margin: .5rem 0 0; padding-top: .7rem; border-top: 1px solid var(--line); }

/* charts */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; }
svg.chart .label { fill: var(--ink); font-size: 12px; }
svg.chart .value { fill: var(--muted); font-size: 11px; }
svg.chart .bar-in { fill: var(--bar-in); }
svg.chart .bar-out { fill: var(--bar-out); }
svg.chart .bar-over { fill: var(--neg); }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.2; }
svg.chart .area { fill: var(--accent); opacity: .1; }
svg.chart .dot { fill: var(--accent); }
svg.chart .limit { stroke: var(--ink); stroke-dasharray: 5 4; opacity: .6; }
.legend { font-size: .8rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; margin-top: .4rem; }
.sw { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-left: .6rem; }
.sw.in { background: var(--bar-in); } .sw.out { background: var(--bar-out); } .sw.over { background: var(--neg); }
.sw.limit { height: 2px; background: var(--ink); opacity: .6; }

/* import */
.mapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .7rem; margin: .8rem 0; }
.mapgrid label { display: flex; flex-direction: column; gap: .2rem; font-size: .84rem; font-weight: 500; }
ol.steps { padding-left: 1.2rem; } ol.steps li { margin-bottom: .3rem; }
ul.log { font-family: ui-monospace, monospace; font-size: .85rem; padding-left: 1.1rem; }

/* reminders pay popover */
details.pay { display: inline-block; position: relative; }
details.pay summary { list-style: none; }
details.pay summary::-webkit-details-marker { display: none; }
.popover { position: absolute; right: 0; top: 2rem; z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: .7rem; box-shadow: 0 6px 20px rgba(0,0,0,.15); display: flex; flex-direction: column; gap: .4rem; text-align: left; min-width: 13rem; }
.popover label { display: flex; flex-direction: column; font-size: .8rem; }

/* tag autocomplete */
.ac-wrap { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); max-height: 14rem; overflow-y: auto; margin-top: 2px; }
.ac-list div { padding: .4rem .6rem; cursor: pointer; font-size: .88rem; font-weight: normal; }
.ac-list div.sel, .ac-list div:hover { background: var(--accent-soft); }

/* login */
main.login { padding-top: 12vh; max-width: 27rem; }
.login-card label { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .9rem; font-size: .9rem; }

/* floating add button on phones */
.fab { display: none; }
@media (max-width: 700px) {
  .fab { display: grid; place-items: center; position: fixed; right: 1.1rem; bottom: 1.1rem; width: 3.4rem; height: 3.4rem;
    border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 2rem; box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 40; }
  .fab:hover { text-decoration: none; }
  main { padding: .9rem .7rem 6rem; }
  .card { padding: .9rem; }
}
.bulkbar[hidden], [hidden] { display: none !important; }
svg.chart.hbars { max-width: 760px; }
h3.kind { display: flex; justify-content: space-between; }
.total-card { display: flex; justify-content: space-between; font-size: 1.05rem; }
select.small { font-size: .82rem; padding: .25rem .4rem; }
table.acct-table { table-layout: fixed; }
table.acct-table td.kindcol { width: 150px; }
table.acct-table td.balcol { width: 140px; }
table.acct-table td.editcol { width: 64px; }

/* split transactions */
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: .85rem; margin: -.4rem 0 .8rem; }
.splitbox { border: 1px solid var(--line); border-radius: 8px; padding: .7rem; margin-bottom: .9rem; background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.split-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; font-size: .9rem; }
.split-head .linkbtn { margin: 0; }
.split-row { display: grid; grid-template-columns: minmax(0, 1fr) 6.5rem 2rem; gap: .4rem; margin-bottom: .4rem; align-items: center; }
.split-row .ac-wrap input { width: 100%; }
.split-row .split-amt { text-align: right; }
.split-del { background: none; border: 0; font-size: 1.3rem; color: var(--muted); cursor: pointer; }
.split-foot { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-top: .3rem; }
.chip b { font-weight: 600; }
.split-row input { width: 100%; }
.split-row .ac-wrap { min-width: 0; } .split-row input { min-width: 0; }
/* keep everything inside the screen on phones */
.seg { position: relative; }
.seg input { left: 0; top: 0; width: 1px; height: 1px; }
.filters label { flex-wrap: wrap; max-width: 100%; }
.filters input[type=date] { max-width: 10.5rem; }
@media (max-width: 700px) {
  table.tx td.date { white-space: normal; width: 4.3rem; line-height: 1.25; }
  table.tx .desc, table.tx .meta { word-break: break-word; }
  table.list td.nowrap { white-space: normal; }
  table.list td.nowrap form { display: inline-block; margin: .1rem 0; }
}

/* search box in the header */
.topsearch { flex: 0 1 240px; margin-left: 1rem; }
.topsearch input { width: 100%; padding: .38rem .7rem; border-radius: 999px; background: var(--bg); font-size: .9rem; }
header nav { margin-left: auto; }
@media (max-width: 1100px) { .topsearch { flex-basis: 180px; } header nav a { padding: .4rem .45rem; } }
@media (max-width: 860px) {
  .topsearch { order: 3; flex: 1 1 100%; margin: .35rem 0 .1rem; }
  .menu-btn { order: 2; }
  header nav { order: 4; }
}
@media (max-width: 860px) { .page-transactions .topsearch { display: none; } }

/* status ticks and reconciling */
th.stcol, td.stcol { width: 2.2rem; text-align: center; padding-left: 0 !important; padding-right: .4rem !important; }
.st { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; font: 700 .72rem/1 system-ui, sans-serif;
  border: 1.5px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.st.small { width: 1.25rem; height: 1.25rem; font-size: .62rem; cursor: default; vertical-align: -.2rem; margin-right: .15rem; }
.st-reconciled { background: var(--pos); border-color: var(--pos); color: var(--card); }
.st-cleared { border-color: var(--muted); color: var(--ink); }
.st-pending { border-color: var(--warn); color: var(--warn); border-style: dashed; }
.st:disabled { opacity: .5; }
.recbar { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; align-items: center; font-size: .86rem; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .8rem; margin: -.2rem 0 .8rem; }
.recsum { display: grid; grid-template-columns: repeat(5, 1fr); gap: .8rem; align-items: end; position: sticky; top: 3.4rem; z-index: 5; }
.recsum .k { display: block; font-size: .75rem; color: var(--muted); margin-bottom: .2rem; }
.recsum b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.recsum input { width: 100%; font-size: 1rem; }
.recsum .diff.ok b { color: var(--pos); }
.recsum .diff.bad b { color: var(--neg); }
.recactions { position: sticky; bottom: 0; background: var(--bg); padding: .7rem 0; }
@media (max-width: 860px) { .recsum { grid-template-columns: 1fr 1fr; top: 0; } .recsum .diff { grid-column: span 2; } }

/* appearance settings */
.look-grid { display: grid; grid-template-columns: 1.2fr 1fr 1.4fr; gap: 1.2rem; }
@media (max-width: 860px) { .look-grid { grid-template-columns: 1fr; } }
.look-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.look-form legend { font-weight: 600; font-size: .9rem; margin-bottom: .5rem; padding: 0; }
.swatches, .pills { display: flex; flex-wrap: wrap; gap: .45rem; }
.look-form label.swatch, .look-form label.pill { flex-direction: row !important; align-items: center; gap: .4rem; margin: 0 !important;
  border: 1.5px solid var(--line); border-radius: 999px; padding: .35rem .75rem .35rem .45rem; cursor: pointer; font-weight: 500; }
.look-form label.pill { padding-left: .75rem; }
.look-form label input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.look-form label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.look-form label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch .dot { width: 1.3rem; height: 1.3rem; border-radius: 50%; display: inline-block; }
.sw-green .dot { background: #146c5c; } .sw-pink .dot { background: #e0609a; } .sw-blue .dot { background: #1f5fa8; }
.sw-purple .dot { background: #6a3fa0; } .sw-orange .dot { background: #d26a1e; }
.sizes .aa { font-weight: 700; line-height: 1; }
.size-normal .aa { font-size: 15px; } .size-large .aa { font-size: 17px; } .size-xl .aa { font-size: 19.5px; } .size-xxl .aa { font-size: 22.5px; }
/* let cards shrink to the screen (matters with large text) */
.grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 860px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.grid2 > *, .card { min-width: 0; }
input[type=file] { max-width: 100%; }
h2 { flex-wrap: wrap; }
@media (max-width: 700px) {
  table.list td.date { white-space: normal; }
  table.list td.nowrap form, table.list td.nowrap details { display: inline-block; margin: .1rem 0; }
  .popover { right: -.5rem; max-width: calc(100vw - 2rem); }
  table.list td, table.list th { padding-left: .25rem; padding-right: .25rem; }
}
.stats > * { min-width: 0; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); } }
.filters input, .filters select { min-width: 0; max-width: 100%; }
.filters .grow { flex: 1 1 12rem; }
.filters details.more:not([open]) > :not(summary) { display: none; }
.pagehead form.inline { display: flex; flex-wrap: wrap; gap: .4rem; max-width: 100%; }
.pagehead form.inline input { min-width: 0; flex: 1 1 10rem; }
@media (max-width: 700px) {
  table.list td.nowrap form, table.list td.nowrap details { display: block; margin: .15rem 0; }
}
@media (max-width: 700px) {
  table.list-tx { table-layout: fixed; }
  table.list-tx th.cb { width: 1.9rem; }
  table.list-tx th.datecol { width: 4.4rem; }
  table.list-tx th.amtcol { width: 6.4rem; }
  table.list-tx th.stcol { width: 2.3rem; }
  table.list-tx td { overflow-wrap: anywhere; }
}
/* ledger switcher in the header */
.ledger-switch select { font-size: .85rem; padding: .3rem .5rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; max-width: 12rem; }
@media (max-width: 860px) { .ledger-switch { order: 1; } }

/* keep money columns lined up: headers follow their column's alignment */
table.tx th.r, table.list th.r, table th.r, table td.r { text-align: right; }
table th.center, table td.center { text-align: center; }
h3.kind { padding-right: .4rem; padding-left: .4rem; }
@media (max-width: 700px) { h3.kind { padding-left: .25rem; padding-right: .25rem; } }
table.acct-table tfoot td { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 700; }
/* account requests */
.badge { display: inline-grid; place-items: center; min-width: 1.2rem; height: 1.2rem; padding: 0 .3rem; border-radius: 999px; background: var(--neg); color: #fff; font-size: .7rem; font-weight: 700; }
.signup-req { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: .7rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.signup-req form { display: inline-block; }
.login-card h1 { font-size: 1.35rem; text-align: center; }
/* budget report */
svg.chart .bar-budget { fill: var(--muted); opacity: .45; }
.sw.budget { background: var(--muted); opacity: .45; }
table.budget-report tr.grouphead td { font-weight: 700; padding-top: .9rem; border-bottom: 0; text-transform: uppercase; font-size: .78rem; letter-spacing: .05em; color: var(--muted); }
table.budget-report td.indent { padding-left: 1.1rem; }
table.budget-report tr.groupfoot td { font-weight: 600; background: color-mix(in srgb, var(--chip) 60%, transparent); }
table.budget-report tfoot th { font-size: .95rem; color: var(--ink); border-top: 2px solid var(--line); }
.mini.bar { height: 5px; margin-top: .3rem; max-width: 14rem; }
table.budget-report td { vertical-align: middle; }
table.budget-report tr.subtag td { font-size: .9rem; color: var(--muted); padding-top: .25rem; padding-bottom: .25rem; border-bottom-style: dotted; }
table.budget-report tr.subtag td.amt { color: var(--ink); }
@media (max-width: 640px) {
  table.budget-report td.subname { padding-left: .9rem !important; }
  table.budget-report td, table.budget-report th { padding-left: .25rem; padding-right: .25rem; font-size: .8rem; }
  table.budget-report tr.subtag td { font-size: .75rem; }
  table.budget-report th:first-child, table.budget-report td:first-child { width: 30%; }
}
svg.chart rect.hit { fill: transparent; }
svg.chart a:hover rect.bar-in, svg.chart a:hover rect.bar-over { opacity: .75; }
svg.chart rect.bar-current { stroke: var(--ink); stroke-width: 1.5; }

/* ---- printing ---- */
.print-only { display: none; }
@media print {
  @page { margin: 12mm; }
  html, html.mode-dark { --bg: #fff; --card: #fff; --ink: #000; --muted: #444; --line: #bbb; --chip: #eee; }
  body { background: #fff !important; color: #000; font-size: 10.5pt; }
  header.top, .fab, .filters, .no-print, .flash, footer, .btn, button { display: none !important; }
  .print-only { display: block; }
  .printhead { margin: 0 0 4mm; font-size: 10pt; }
  .printhead span { color: #444; font-size: 9pt; }
  main, .wrap, .narrow { max-width: none !important; padding: 0 !important; margin: 0 !important; }
  .card, .stat { box-shadow: none !important; border: 1px solid #bbb; break-inside: avoid; }
  .grid2 { display: block; }
  .grid2 > .card { margin-bottom: 4mm; }
  table { break-inside: auto; }
  .card:has(table) { break-inside: auto; }
  tr { break-inside: avoid; }
  thead { display: table-header-group; }
  a { color: #000 !important; text-decoration: none !important; }
  td.hide-sm, th.hide-sm { display: table-cell !important; }
  table.budget-report td, table.budget-report th { font-size: 9.5pt !important; padding: .2rem .35rem !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.logo-pig { width: 2em; height: 2em; object-fit: contain; }
.brand.big .logo-pig { width: 2.6em; height: 2.6em; }
svg.chart .bar-prev { fill: var(--muted); opacity: .45; }
.sw.prev { background: var(--muted); opacity: .45; }
table.yoy td.chg { white-space: nowrap; }
table.yoy tr.sub td:first-child { padding-left: 1.4rem; font-size: .92em; }
@media (max-width: 640px) { table.yoy td, table.yoy th { font-size: .8rem; padding-left: .25rem; padding-right: .25rem; } }
svg.chart .dot.neg { fill: var(--neg); }
.warnbox { border-left: 4px solid var(--neg); }
tr.overdrawn td { background: color-mix(in srgb, var(--neg) 8%, transparent); }
.chip.warn { background: color-mix(in srgb, var(--neg) 15%, transparent); color: var(--neg); }
.receipts { border-top: 1px solid var(--line); padding-top: .6rem; }
.receipt-list { display: flex; flex-wrap: wrap; gap: .6rem; margin: .5rem 0; }
.receipt { width: 7.5rem; }
.receipt img, .receipt .filebox { width: 7.5rem; height: 7.5rem; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; background: var(--chip); }
.receipt .filebox { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.receipt-add { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .4rem; }
.filebtn { position: relative; overflow: hidden; cursor: pointer; }
.filebtn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.clip { font-size: .85em; }
.linkbtn.neg { color: var(--neg); }
table.list td.nowrap { white-space: nowrap !important; }
/* ---- help ---- */
details.inline-form { display: inline-block; vertical-align: middle; }
details.inline-form[open] { display: block; margin: .3rem 0; text-align: left; }
details.inline-form summary { list-style: none; display: inline-block; }
details.inline-form summary::-webkit-details-marker { display: none; }
.helpbtn { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 50%;
  border: 1px solid var(--line); color: var(--muted); font-weight: 700; text-decoration: none; flex: none; }
.helpbtn:hover { color: var(--accent); border-color: var(--accent); }
.help-search { display: flex; flex-wrap: wrap; gap: .4rem .8rem; align-items: center; }
.help-search input { flex: 1 1 16rem; font-size: 1.05rem; }
.help-wrap { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 1rem; align-items: start; }
.help-toc { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; font-size: .9rem; }
.help-toc ol { padding-left: 1.2rem; margin: .4rem 0 0; }
.help-toc ul { padding-left: .9rem; margin: .1rem 0 .3rem; list-style: none; font-size: .85em; }
.help-toc li.hidden { display: none; }
.manual { line-height: 1.6; }
.manual section, .manual h3 { scroll-margin-top: 8rem; }
.manual section + section { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: .5rem; }
.manual h3 { margin-top: 1.4rem; }
.manual figure { margin: 1rem 0; }
.manual figure img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; display: block; }
.manual figure.phone img { max-width: 260px; }
.manual figcaption { font-size: .85rem; color: var(--muted); margin-top: .3rem; }
.manual .tip { background: color-mix(in srgb, var(--accent) 9%, transparent); border-left: 4px solid var(--accent); padding: .5rem .8rem; border-radius: 6px; }
.manual dt { font-weight: 700; margin-top: .6rem; }
.manual dd { margin-left: 1rem; }
.manual mark { background: #ffe066; color: #000; border-radius: 2px; }
.manual section.nomatch { display: none; }
@media (max-width: 800px) {
  .help-wrap { grid-template-columns: minmax(0, 1fr); }
  .help-toc { position: static; max-height: none; }
  .help-toc ol ul { display: none; }
}
@media print {
  .help-wrap { display: block; }
  .manual figure { break-inside: avoid; }
  .manual figure.phone img { max-width: 200px; }
  .manual section { break-before: page; }
}

/* ---- transaction lists on phones: one card per transaction ---- */
.date-sm, .bal-sm { display: none; }
.chip { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
@media (max-width: 700px) {
  table.cards, table.cards tbody { display: block; table-layout: auto; }
  table.cards thead tr { display: flex; align-items: center; gap: .5rem; padding: .2rem 0 .4rem; }
  table.cards thead th:not(.cb) { display: none; }
  table.cards tbody tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; column-gap: .55rem; align-items: start;
    padding: .55rem 0; border-bottom: 1px solid var(--line); }
  table.cards tbody td { display: block; padding: 0; border: 0; width: auto !important; overflow-wrap: break-word; word-break: normal; }
  table.cards td.date, table.cards td.hide-sm { display: none; }
  table.cards td.cb { padding-top: .15rem; }
  table.cards td.descc { line-height: 1.3; }
  table.cards td.descc .desc { font-weight: 600; overflow-wrap: break-word; word-break: normal; }
  table.cards td.descc .meta { margin-top: .2rem; line-height: 1.5; word-break: normal; overflow-wrap: break-word; }
  table.cards .date-sm { display: inline; }
  table.cards td.amtc { white-space: nowrap; text-align: right; }
  table.cards .bal-sm { display: block; font-size: .72rem; }
  table.cards td[colspan] { grid-column: 1 / -1; }
  /* header: keep the menu button on the first line */
  header.top:has(.ledger-switch) .brand-text { display: none; }
  .ledger-switch select { max-width: 9rem; }
}
@media (max-width: 380px) { .brand-text { display: none; } }
@media (max-width: 700px) {
  table.cards.nocb thead { display: none; }
  table.cards.nocb tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (max-width: 700px) {
  table.cards thead tr { border-bottom: 1px solid var(--line); }
  table.cards thead th { border: 0; padding: 0; }
  table.cards thead th.cb::after { content: "Select all"; font-size: .8rem; color: var(--muted); font-weight: 400; margin-left: .5rem; }
  table.cards thead th.cb { display: flex; align-items: center; }
}
.chip { white-space: normal; overflow: visible; text-overflow: clip; word-break: normal; overflow-wrap: normal; }
@media (max-width: 700px) { table.cards thead th.cb { white-space: nowrap; width: auto !important; } }
.chip { border-radius: .7rem; }
@media (max-width: 700px) { table.cards thead { display: block; } }

/* phones: the details line and notes use the full width, under the amount too */
@media (max-width: 700px) {
  table.cards td.descc { display: contents; }
  table.cards td.cb { grid-column: 1; grid-row: 1 / span 3; }
  table.cards .descline { grid-column: 2; grid-row: 1; line-height: 1.3; }
  table.cards td.amtc { grid-column: 3; grid-row: 1; }
  table.cards td.stc { grid-column: 4; grid-row: 1; }
  table.cards td.descc > .meta { grid-column: 2 / -1; }
  table.cards.nocb .descline { grid-column: 1; }
  table.cards.nocb td.amtc { grid-column: 2; }
  table.cards.nocb td.descc > .meta { grid-column: 1 / -1; }
}

/* ---- demo ---- */
.demo-banner { background: #fff4d6; color: #5a4300; border: 1px solid #f0d78a; border-radius: 10px; padding: .55rem .8rem; margin: 0 0 1rem; font-size: .9rem; }
.demo-banner form { display: inline; }
.demo-banner .linkbtn { color: #8a5a00; text-decoration: underline; }
html.mode-dark .demo-banner { background: #3a3120; color: #f3e2b0; border-color: #6b5a2c; }
@media (prefers-color-scheme: dark) { html.mode-auto .demo-banner { background: #3a3120; color: #f3e2b0; border-color: #6b5a2c; } }
.demo-try { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: .6rem; }
/* ---- login history ---- */
table.logins tr.bad td { color: var(--neg); }
.show-sm { display: none; }
@media (max-width: 700px) { .show-sm { display: block; } }
