/* Components for the money app (Ledger Brutal). Tokens live in tokens.css. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%;
  /* keep a focused field clear of the sticky header and the fixed bottom nav + "+" button */
  scroll-padding-top: calc(var(--safe-t) + 64px); scroll-padding-bottom: calc(var(--safe-b) + 120px); }
@media (min-width: 60em) { html { scroll-padding-bottom: 16px; } }
body {
  margin: 0; background: var(--paper); color: var(--text); font-family: var(--font); font-size: var(--fs); line-height: 1.45;
  font-variant-ligatures: none; font-feature-settings: "calt" 0; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* while JetBrains Mono loads, scale the fallback mono to the same character width so lines do not jump */
  font-size-adjust: ch-width 0.6;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.small { font-size: var(--fs-sm); } .xs { font-size: var(--fs-xs); }
.num { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
.row-flex { display: flex; align-items: center; gap: var(--sp-2); }
.wrap { flex-wrap: wrap; }
.lbl { font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- keyboard focus: always visible, never on mouse/touch clicks */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
/* radios hidden with .sr (colour swatches, segmented choices): ring the label that shows them */
label:has(> input.sr:focus-visible) { outline: 3px solid var(--text); outline-offset: 2px; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .input:focus-visible { outline-offset: 1px; }

/* ---------- shell */
/* sticky wrapper = scroll-state container; the header inside gets its line only once actually stuck */
.top-wrap { position: sticky; top: 0; z-index: 20; container: topbar / scroll-state; }
.top { display: flex; align-items: center; gap: var(--sp-2); padding: calc(var(--safe-t) + 10px) 16px 10px; background: var(--paper); }
.top.scrolled { box-shadow: 0 var(--bw-sm) 0 var(--ink); }
@container topbar scroll-state(stuck: top) { .top { box-shadow: 0 var(--bw-sm) 0 var(--ink); } }
.logo { background: var(--yellow); color: var(--on-color); border: var(--bw) solid var(--ink); border-radius: 10px; padding: 1px 10px; font-weight: 800; font-size: 1.0625rem; box-shadow: var(--sh-sm); letter-spacing: -0.04em; text-decoration: none; }
.topnav { display: none; gap: 6px; margin-left: 12px; flex-wrap: wrap; }
main { max-width: 620px; margin: 0 auto; padding: 4px 0 calc(120px + var(--safe-b)); }
.page-title { display: flex; align-items: center; gap: 8px; margin: 6px 16px 12px; }
.page-title h1 { font-size: 1.3125rem; margin: 0; letter-spacing: -0.03em; }
h2.sec { display: flex; align-items: baseline; margin: 22px 16px 8px; font-size: .9375rem; font-weight: 800; letter-spacing: -0.02em; }
h2.sec span { margin-left: auto; font-size: .75rem; color: var(--muted); font-weight: 600; }
h2.sec a { text-decoration: none; }
.pad { padding: 0 16px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 2px; padding: 8px max(12px, env(safe-area-inset-right, 0px)) calc(10px + var(--safe-b)) max(12px, env(safe-area-inset-left, 0px)); background: var(--surface); border-top: var(--bw) solid var(--ink); }
.nav a { flex: 1; text-align: center; font-size: .7188rem; font-weight: 700; padding: 7px 0 6px; border-radius: 10px; color: var(--muted); text-decoration: none; border: 2px solid transparent; position: relative; }
.nav a b { display: block; font-size: 17px; line-height: 1.1; font-weight: 400; }
.nav a.on { background: var(--yellow); color: var(--on-color); border-color: var(--ink); }
.nav a .dot { position: absolute; top: 2px; right: 22%; width: 9px; height: 9px; border-radius: 50%; background: var(--pink); border: 1.5px solid var(--ink); }
.nav .gap { width: 72px; flex: none; }
.fab { position: fixed; z-index: 31; right: 16px; bottom: calc(46px + var(--safe-b)); width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: var(--on-accent);
  border: var(--bw) solid var(--ink); box-shadow: var(--sh); font-size: 34px; font-weight: 800; display: grid; place-items: center; transition: transform var(--t-press) var(--ease-out), box-shadow var(--t-press) var(--ease-out); }
.fab:active, .btn:active, .key:active { transform: translate(2px, 2px); box-shadow: none; }
:root[data-hand="left"] .fab { right: auto; left: 16px; }
:root[data-hand="left"] .nav { flex-direction: row-reverse; }

.add-top { display: none !important; }
@media (min-width: 60em) {
  .topnav { display: flex; }
  .nav, .fab { display: none; }
  .top { padding: 12px 24px; border-bottom: var(--bw) solid var(--ink); background: var(--surface); }
  main { max-width: 1240px; padding: 18px 24px 60px; }
  main.narrow { max-width: 760px; }
  .add-top { display: inline-flex !important; }
}

/* ---------- basics */
.box { background: var(--surface); border: var(--bw) solid var(--ink); border-radius: var(--r); box-shadow: var(--sh); }
.box.flat { box-shadow: var(--sh-sm); }
.card { margin: 0 16px; padding: 12px 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--ink); border-radius: 99px; padding: 4px 11px; font-size: .7813rem; font-weight: 700; background: var(--surface); white-space: nowrap; flex: none; text-decoration: none; }
.chip.on { background: var(--yellow); color: var(--on-color); box-shadow: var(--sh-sm); }
.chip.pink { background: var(--pink); color: var(--on-color); }
.chip.ghost { border-style: dashed; background: transparent; }
.chip .d { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); flex: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: var(--bw) solid var(--ink); border-radius: var(--r-btn); background: var(--surface);
  padding: 10px 16px; font-weight: 800; box-shadow: var(--sh-sm); text-decoration: none; transition: transform var(--t-press) var(--ease-out), box-shadow var(--t-press) var(--ease-out); }
.btn.pri { background: var(--accent); color: var(--on-accent); }
.btn.ok { background: var(--green); color: var(--on-color); }
.btn.yel { background: var(--yellow); color: var(--on-color); }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { box-shadow: none; background: transparent; }
.btn.small { padding: 5px 10px; font-size: .7813rem; border-width: 2px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 38px; height: 38px; border: var(--bw) solid var(--ink); border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--surface); flex: none; }
.icon-btn.sm { width: 32px; height: 32px; }

.seg { display: flex; border: var(--bw) solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--surface); }
.seg button { flex: 1; border: 0; background: none; padding: 7px 4px; font-size: .7813rem; font-weight: 700; }
.seg button + button { border-left: 2px solid var(--ink); }
.seg button.on { background: var(--accent); color: var(--on-accent); }

.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: .75rem; font-weight: 700; margin: 0 0 4px; color: var(--muted); }
.field input, .field select, .field textarea, .input {
  width: 100%; border: 2px solid var(--ink); border-radius: var(--r-sm); background: var(--surface); padding: 9px 11px; font-size: .9375rem; outline: none; }
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { box-shadow: var(--sh-sm); background: var(--yellow-soft); }
.field small { display: block; color: var(--muted); font-size: .75rem; margin-top: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 2px dashed color-mix(in srgb, var(--ink) 18%, transparent); }
.switch:last-child { border-bottom: 0; }
.switch .txt { flex: 1; }
.switch .txt small { display: block; color: var(--muted); font-size: .75rem; }
.tog { appearance: none; width: 48px; height: 28px; border: 2px solid var(--ink); border-radius: 99px; background: var(--sunk); position: relative; flex: none; cursor: pointer; }
/* box-sizing: the global * rule does not reach ::after; without it the 2px border made the knob 24px and pushed it into the outline */
.tog::after { content: ""; box-sizing: border-box; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); transition: transform var(--t-ui) var(--ease-out); }
.tog:checked { background: var(--green); }
.tog:checked::after { transform: translateX(20px); }

.sticker { font-size: .625rem; font-weight: 800; background: var(--pink); color: var(--on-color); border: 2px solid var(--ink); border-radius: 6px; padding: 0 5px; transform: rotate(-4deg); display: inline-block; white-space: nowrap; }
.sticker.y { background: var(--yellow); } .sticker.p { background: var(--purple); color: #fff; } .sticker.g { background: var(--green); } .sticker.w { background: var(--surface); color: var(--text); }

.empty { text-align: center; padding: 26px 16px; color: var(--muted); }
.empty b { display: block; font-size: 30px; margin-bottom: 6px; color: var(--text); }
.err { background: var(--red-soft); border: 2px solid var(--ink); border-radius: var(--r-sm); padding: 8px 10px; font-size: .8125rem; margin: 0 0 12px; }
.note { background: var(--yellow-soft); border: 2px solid var(--ink); border-radius: var(--r-sm); padding: 8px 10px; font-size: .8125rem; margin: 0 0 12px; }

/* ---------- dashboard */
.dash { display: flex; flex-direction: column; gap: 0; }
.w { margin-bottom: 6px; }
.hero { margin: 0 16px; padding: 16px; background: var(--yellow); color: var(--on-color); }
.hero .big { font-size: var(--fs-hero); font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; margin: 4px 0 12px; }
.hero .big small { font-size: 1.0625rem; font-weight: 700; margin-right: 6px; letter-spacing: 0; }
.meter { height: 18px; border: var(--bw) solid var(--ink); border-radius: 99px; background: #fff; position: relative; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--ink); }
.meter i.over { background: var(--red); }
.meter u { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--pink); }
.hero .under { display: flex; justify-content: space-between; gap: 8px; font-size: .75rem; font-weight: 600; margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 16px 0; }
.stats .box { padding: 8px 10px; box-shadow: var(--sh-sm); min-width: 0; }
.stats .v { font-size: .9375rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.accs { display: flex; gap: 10px; overflow-x: auto; padding: 2px 16px 8px; scrollbar-width: none; }
.accs::-webkit-scrollbar { display: none; }
.acc { flex: none; width: 132px; padding: 0; overflow: hidden; box-shadow: var(--sh-sm); text-decoration: none; }
.acc .band { height: 8px; border-bottom: 2px solid var(--ink); }
.acc .in { padding: 8px 10px 9px; }
.acc .n { font-size: .75rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc .b { font-size: .9375rem; font-weight: 800; margin-top: 2px; }
.cats { margin: 0 16px; padding: 4px 12px; }
.cat { padding: 9px 0; border-bottom: 2px dashed color-mix(in srgb, var(--ink) 22%, transparent); display: block; text-decoration: none; }
.cat:last-child { border-bottom: 0; }
.cat .t { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; min-width: 0; }
.cat .t b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat .t .num { margin-left: auto; }
.cbar { height: 12px; border: 2px solid var(--ink); border-radius: 99px; background: var(--sunk); overflow: hidden; position: relative; }
.cbar i { display: block; height: 100%; border-right: 2px solid var(--ink); }
.cbar i.full { border-right: 0; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; border-bottom: 2px solid var(--ink); }
.chart i { flex: 1; background: var(--purple); border: 2px solid var(--ink); border-bottom: 0; border-radius: 4px 4px 0 0; min-height: 3px; position: relative; }
.chart i.cap { background: var(--pink); }
.chart i.zero { border: 0; background: color-mix(in srgb, var(--ink) 25%, transparent); min-height: 2px; height: 2px !important; border-radius: 0; }
.chart i.future { background: none; border: 2px dashed color-mix(in srgb, var(--muted) 60%, transparent); border-bottom: 0; height: 14% !important; }
.chart i.today { outline: 2px solid var(--pink); outline-offset: 1px; }
.axis { display: flex; justify-content: space-between; font-size: .6563rem; color: var(--muted); margin-top: 4px; }

/* ---------- lists */
.list { margin: 0 16px; overflow: hidden; }
.row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 2px solid var(--ink); background: var(--surface); width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0; }
.row:last-child { border-bottom: 0; }
button.row:hover { background: var(--yellow-soft); }
.ic { width: 36px; height: 36px; border: 2px solid var(--ink); border-radius: 10px; display: grid; place-items: center; font-size: 17px; }
.row .p::first-letter { text-transform: uppercase; }
.row .p { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .m { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .a { font-weight: 800; text-align: right; white-space: nowrap; }
.row .a.in { color: var(--good); } .row .a.tr { color: var(--muted); }
.row .a small { display: block; font-size: .6875rem; font-weight: 600; color: var(--muted); }
.dlabel { display: flex; align-items: center; margin: 16px 16px 8px; }
.dlabel b { background: var(--text); color: var(--paper); padding: 2px 9px; border-radius: 7px; font-size: .75rem; }
.dlabel span { margin-left: auto; font-weight: 800; font-size: .8125rem; }
.sum2 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 4px 16px 0; }
.sum2 .box { padding: 8px 10px; box-shadow: var(--sh-sm); min-width: 0; }
.more-link { display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 2px solid var(--ink); text-decoration: none; font-weight: 700; }
.more-link:last-child { border-bottom: 0; }
.more-link span { margin-left: auto; color: var(--muted); }
.mini { display: flex; gap: 4px; flex: none; }

/* ---------- toast */
/* a manual popover (top layer, so it shows above an open sheet); the reset undoes the UA popover box */
.toast { position: fixed; inset: auto auto calc(100px + var(--safe-b)) 50%; margin: 0; translate: -50% 0; z-index: 80; width: min(560px, calc(100% - 28px)); height: auto; overflow: visible;
  background: var(--ink); color: #fff; border: 0; border-radius: 12px; padding: 12px 8px 12px 14px; display: flex; gap: 8px; align-items: center; font-size: .8438rem; font-weight: 600; box-shadow: 4px 4px 0 var(--pink); }
.toast[popover]:not(:popover-open) { display: none; }
:root[data-theme="dark"] .toast { background: #000; }
.toast button { background: none; border: 0; color: var(--yellow); font-weight: 800; padding: 0 6px; min-height: 32px; border-radius: 8px; }
.toast .toast-x { color: #fff; opacity: .8; font-weight: 600; }
.toast button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 0; }
.toast.bad { box-shadow: 4px 4px 0 var(--red); }
@media (min-width: 60em) { .toast { bottom: 24px; } }

/* ---------- sheet (modal): a native <dialog> opened with showModal() */
dialog.sheet { width: 100%; max-width: 620px; max-height: calc(100dvh - 24px); overflow-y: auto; color: var(--text); background: var(--paper); border: var(--bw) solid var(--ink); border-bottom: 0; border-radius: 20px 20px 0 0;
  margin: auto auto 0; padding: 14px 16px calc(18px + var(--safe-b)); }
dialog.sheet[open] { animation: up var(--t-ui) var(--ease-out); }
/* both rules: otherwise scrolling inside the sheet or over the backdrop scrolls the page behind it */
dialog.sheet:modal { overscroll-behavior: contain; }
dialog.sheet::backdrop { background: rgba(18, 18, 18, .45); overflow: hidden; overscroll-behavior: contain; }
.sheet.full { height: calc(100dvh - 12px); }
@keyframes up { from { transform: translateY(24px); opacity: .4; } }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 1.125rem; flex: 1; letter-spacing: -0.02em; text-wrap: balance; }
@media (min-width: 43.75em) {
  dialog.sheet { margin: auto; border-radius: 20px; border-bottom: var(--bw) solid var(--ink); box-shadow: var(--sh-lg); max-height: calc(100dvh - 60px); }
  .sheet.full { height: auto; }
}
@media (prefers-reduced-motion: reduce) { dialog.sheet[open] { animation: none; } }
/* "Are you sure?" */
dialog.sheet.ask { max-width: 420px; }
.ask-q { margin: 4px 0 16px; font-weight: 700; text-wrap: pretty; }
.ask-btns { justify-content: flex-end; }

/* ---------- add / edit */
.amountbox { padding: 8px 14px; text-align: right; margin: 8px 0; box-shadow: var(--sh-sm); cursor: text; }
.amountbox .v { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1.1; overflow-wrap: anywhere; }
.amountbox .v small { font-size: 1.0625rem; margin-right: 8px; letter-spacing: 0; }
.amountbox .v.zero { color: var(--muted); }
.amountbox .l { display: flex; justify-content: space-between; gap: 8px; font-size: .75rem; color: var(--muted); }
.caret { display: inline-block; width: 3px; height: 34px; background: var(--accent); vertical-align: -4px; margin-left: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 10px; }
.modes button { border: 2px solid var(--ink); border-radius: 12px; background: var(--surface); padding: 8px 6px; font-weight: 700; font-size: .7813rem; box-shadow: var(--sh-sm); }
.modes button:disabled { opacity: .45; cursor: not-allowed; }
.modes button.on { background: var(--yellow); color: var(--on-color); }
.cgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 4px 0 8px; }
.cgrid button { border: 2px solid var(--ink); border-radius: 12px; text-align: center; padding: 6px 2px; font-size: .6875rem; font-weight: 700; background: var(--surface); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cgrid button b { display: block; font-size: 19px; font-weight: 400; }
.cgrid button.on { box-shadow: var(--sh-sm); transform: translate(-1px, -1px); color: var(--on-color); }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 8px 0; }
.key { border: 2px solid var(--ink); border-radius: 12px; background: var(--surface); text-align: center; padding: 10px 0; font-size: 1.1875rem; font-weight: 700; box-shadow: var(--sh-sm); }
.key.k2 { background: var(--sunk); }
@media (min-width: 60em) { .keys { display: none; } .hint-keys { display: block !important; } }
.hint-keys { display: none; font-size: .75rem; color: var(--muted); margin: 0 0 8px; }
.savebar { position: sticky; bottom: calc(-18px - var(--safe-b)); margin: 10px -16px calc(-18px - var(--safe-b)); padding: 10px 16px calc(14px + var(--safe-b)); background: var(--paper); border-top: 2px solid var(--ink); display: flex; gap: 8px; }
.savebar .btn.ok { flex: 1; justify-content: space-between; }
.rec { padding: 12px 14px; margin: 0 0 12px; }
.rec .ln { display: flex; gap: 8px; padding: 2px 0; font-size: .8438rem; }
.rec .ln span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-line { padding: 5px 0 7px; border-bottom: 1px dashed var(--muted); }
.item-line select, .item-all select { width: 100%; border: 2px solid var(--ink); border-radius: 9px; padding: 6px 8px; background: var(--surface); font-size: .8125rem; margin-top: 3px; }
.item-all { display: block; margin: 0 0 6px; }
.rec .ln.tot { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 8px; font-size: 1rem; font-weight: 800; }
.split-line { display: grid; grid-template-columns: minmax(0, 1fr) 120px 34px; gap: 6px; margin-bottom: 6px; }
.split-line select, .split-line input { border: 2px solid var(--ink); border-radius: 9px; padding: 7px 8px; background: var(--surface); min-width: 0; font-size: .8125rem; }
.busy { display: flex; align-items: center; gap: 10px; padding: 18px 4px; font-weight: 700; }
.busy::before { content: ""; width: 18px; height: 18px; border: 3px solid var(--ink); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.drop { border: 2.5px dashed var(--ink); border-radius: var(--r); padding: 26px 14px; text-align: center; background: var(--surface); display: block; cursor: pointer; }
.drop b { display: block; font-size: 32px; }

/* ---------- desktop dashboard grid */
@media (min-width: 60em) {
  .dash { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .dash .col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
  .dash .w { margin: 0; }
  .dash .hero, .dash .cats, .dash .list, .dash .card { margin: 0; }
  .dash .stats { margin: 12px 0 0; }
  .dash .accs { flex-wrap: wrap; padding: 2px 0; overflow: visible; }
  .dash h2.sec { margin: 0 0 8px; }
  .pagewide .list, .pagewide .card, .pagewide .cats { margin-left: 0; margin-right: 0; }
}

/* ---------- phone comfort
   iPhone Safari zooms in on any field under 16px when it gets focus and stays zoomed,
   so on phones every field is 16px. Nothing may push the page wider than the screen either. */
@media (max-width: 59.99em) {
  input, select, textarea, .input,
  .field input, .field select, .field textarea,
  .item-line select, .item-all select, .split-line select, .split-line input { font-size: max(16px, 1rem); }
}
/* touch screens: every control is at least 44px tall (a fingertip is not a mouse pointer) */
@media (pointer: coarse) {
  .btn.small, .icon-btn, .icon-btn.sm, .seg button, a.chip, button.chip, label.chip, .modes button, .split-line select, .split-line input, .item-line select, .item-all select { min-height: 44px; }
  .icon-btn, .icon-btn.sm { width: 44px; height: 44px; }
  .chips { gap: 8px; }
  .mini { gap: 6px; }
  .split-line { grid-template-columns: minmax(0, 1fr) 110px 44px; }
}

/* ---------- dashboard insights */
.ins { padding: 6px 14px; }
.in-row { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; font-size: .8438rem; border-bottom: 2px dashed color-mix(in srgb, var(--ink) 18%, transparent); }
.in-row:last-child { border-bottom: 0; }
.in-ic { width: 20px; flex: none; text-align: center; }

/* ---------- dashboard donut */
.pie { display: flex; align-items: center; gap: 14px; }
.donut { width: 108px; height: 108px; flex: none; }
.donut .d-big { font: 800 17px var(--font); fill: var(--text); letter-spacing: -0.03em; }
.donut .d-sm { font: 600 10px var(--font); fill: var(--muted); }
.legend { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lg { display: flex; align-items: center; gap: 7px; padding: 4px 0; font-size: .8125rem; text-decoration: none; min-width: 0; }
.lg i { width: 10px; height: 10px; border-radius: 3px; border: 1.5px solid var(--ink); flex: none; }
.lg-n { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.lg .num { font-size: .8125rem; }
.lg-p { width: 30px; text-align: right; flex: none; }
.tr-chip { font-size: .625rem; font-weight: 800; border: 1.5px solid currentColor; border-radius: 6px; padding: 0 4px; color: var(--muted); flex: none; }
.tr-chip.bad { color: var(--bad); } .tr-chip.good { color: var(--good); }
@media (max-width: 27.5em) { .lg-p { display: none; } .pie { gap: 12px; } }
@media (max-width: 20.625em) { .pie { flex-direction: column; align-items: stretch; } .donut { align-self: center; } }

/* ---------- sheets only scroll up and down
   iPhone gives date/time fields a minimum width wider than half the screen; inside the two-column
   row that pushed the sheet sideways and it could be dragged left and right. Columns may shrink,
   fields fill their column, and the sheet never scrolls sideways. */
.sheet { overflow-x: hidden; }
.sheet-body { min-width: 0; max-width: 100%; }
.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.two > * { min-width: 0; }
.field input, .field select, .field textarea { min-width: 0; max-width: 100%; display: block; }
input[type="date"], input[type="datetime-local"], input[type="time"] { -webkit-appearance: none; appearance: none; min-width: 0; min-height: 42px; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; }
@media (max-width: 27.5em) { .two:has(input[type="datetime-local"]) { grid-template-columns: minmax(0, 1fr); gap: 0; } }
