/* Till: the till receipt. The month's breakdown prints on a strip of paper with a torn edge and dotted
   leaders, the total gets a swipe of highlighter, and adding an expense is a till keypad.
   Bricolage Grotesque for amounts that matter, Geist for text, Geist Mono for the receipt lines. */
:root {
  --bg: #e9ebee;
  --paper: #fbfbf8;
  --paper-2: #f0f1ef;
  --ink: #14161b;
  --ink-2: #4a4f59;
  --ink-3: #7d828c;
  --line: rgba(20, 22, 27, 0.09);
  --line-strong: rgba(20, 22, 27, 0.2);
  --marker: #ffe14d;
  --marker-hl: #ffe14d;
  --on-marker: #14161b;
  --primary: #14161b;
  --on-primary: #fbfbf8;
  --bar: #c5c9d0;
  --good: #0f7a57;
  --danger: #c6392a;
  --scrim: rgba(20, 22, 27, 0.42);
  --shadow: 0 24px 60px -24px rgba(20, 22, 27, 0.45);
  --paper-shadow: rgba(20, 22, 27, 0.12);
  --dock: rgba(233, 235, 238, 0.86);
  --k0: #dd4a2e;
  --k1: #c98200;
  --k2: #5a930f;
  --k3: #128a64;
  --k4: #0c8592;
  --k5: #2a7fcb;
  --k6: #3b57db;
  --k7: #8a4cd6;
  --k8: #cf3d7b;
  --k9: #66707f;
  color-scheme: light;

  --font-display:
    "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --c: var(--k9);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f12;
    --paper: #181a1f;
    --paper-2: #22252c;
    --ink: #edeef0;
    --ink-2: #a6aab3;
    --ink-3: #6f747e;
    --line: rgba(237, 238, 240, 0.08);
    --line-strong: rgba(237, 238, 240, 0.18);
    --marker: #ffe14d;
    --marker-hl: rgba(255, 225, 77, 0.34);
    --on-marker: #14161b;
    --primary: #ffe14d;
    --on-primary: #14161b;
    --bar: #3a3e47;
    --good: #4fd6a0;
    --danger: #ff7a66;
    --scrim: rgba(0, 0, 0, 0.62);
    --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.85);
    --paper-shadow: rgba(0, 0, 0, 0.5);
    --dock: rgba(14, 15, 18, 0.86);
    --k0: #ff7a5c;
    --k1: #ffb938;
    --k2: #a6e04a;
    --k3: #44d6a2;
    --k4: #3ccfd8;
    --k5: #5cb3ff;
    --k6: #8798ff;
    --k7: #b98cff;
    --k8: #ff7eb3;
    --k9: #9aa3b2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0f12;
  --paper: #181a1f;
  --paper-2: #22252c;
  --ink: #edeef0;
  --ink-2: #a6aab3;
  --ink-3: #6f747e;
  --line: rgba(237, 238, 240, 0.08);
  --line-strong: rgba(237, 238, 240, 0.18);
  --marker: #ffe14d;
  --marker-hl: rgba(255, 225, 77, 0.34);
  --on-marker: #14161b;
  --primary: #ffe14d;
  --on-primary: #14161b;
  --bar: #3a3e47;
  --good: #4fd6a0;
  --danger: #ff7a66;
  --scrim: rgba(0, 0, 0, 0.62);
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.85);
  --paper-shadow: rgba(0, 0, 0, 0.5);
  --dock: rgba(14, 15, 18, 0.86);
  --k0: #ff7a5c;
  --k1: #ffb938;
  --k2: #a6e04a;
  --k3: #44d6a2;
  --k4: #3ccfd8;
  --k5: #5cb3ff;
  --k6: #8798ff;
  --k7: #b98cff;
  --k8: #ff7eb3;
  --k9: #9aa3b2;
  color-scheme: dark;
}

/* ---------- base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem / 1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] {
  display: none !important;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
svg {
  display: block;
}
h1,
h2,
h3,
p,
dl,
dd,
ul,
fieldset {
  margin: 0;
}
ul {
  padding: 0;
  list-style: none;
}
fieldset {
  border: 0;
  padding: 0;
  min-width: 0;
}
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.num {
  font-variant-numeric: tabular-nums;
}

.app {
  width: 100%;
  max-width: 30rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(16px, env(safe-area-inset-right))
    calc(env(safe-area-inset-bottom, 0px) + 120px) max(16px, env(safe-area-inset-left));
}
.view {
  display: flex;
  flex-direction: column;
  gap: 28px;
  animation: view-in 0.35s var(--ease);
}
@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  margin-bottom: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 800 1.5rem / 1 var(--font-display);
  letter-spacing: -0.03em;
}
.brand-mark {
  width: 14px;
  height: 18px;
  background: var(--marker);
  -webkit-mask:
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 4.67px 100%;
  mask:
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 4.67px 100%;
}
.month-nav {
  justify-self: center;
  display: flex;
  align-items: center;
}
.month-label {
  min-width: 7.5rem;
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: none;
  border-radius: 10px;
  font: 600 1rem / 1 var(--font-body);
  text-align: center;
  white-space: nowrap;
}
.month-label small {
  font: 400 0.8rem / 1 var(--font-mono);
  color: var(--ink-3);
  margin-left: 4px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--ink);
}
.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn:disabled {
  color: var(--line-strong);
  cursor: default;
}
@media (hover: hover) {
  .icon-btn:not(:disabled):hover,
  .month-label:hover {
    background: var(--line);
  }
}

/* ---------- hero ---------- */
.hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
}
.eyebrow {
  font: 500 0.72rem / 1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.total {
  font: 800 clamp(2.9rem, 15vw, 4.25rem) / 0.95 var(--font-display);
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.total mark {
  color: inherit;
  padding: 0 0.06em;
  margin-left: -0.06em;
  background: linear-gradient(176deg, transparent 0 50%, var(--marker-hl) 50% 86%, transparent 86%);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.total.is-zero mark {
  background: none;
  color: var(--ink-3);
}
.budget {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.tape {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}
.tape span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--ink);
  transition:
    width 0.6s var(--ease),
    background-color 0.3s;
}
.tape i {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--marker);
  box-shadow: 0 0 0 1px var(--bg);
}
.budget.is-over .tape span {
  background: var(--danger);
}
.budget-line {
  font-size: 0.92rem;
  color: var(--ink-2);
}
.budget-line b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.budget.is-over .budget-line b {
  color: var(--danger);
}
.link-btn {
  align-self: flex-start;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}
@media (hover: hover) {
  .link-btn:hover {
    color: var(--ink);
  }
}

/* ---------- receipt ---------- */
.receipt {
  position: relative;
  padding: 18px 18px 22px;
  background: var(--paper);
  border-radius: 6px 6px 0 0;
  margin-bottom: 10px;
  filter: drop-shadow(0 8px 14px var(--paper-shadow));
}
.receipt::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 10px;
  background: var(--paper);
  -webkit-mask:
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 16px 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 16px 100%;
}
.receipt-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 12px;
  font: 500 0.72rem / 1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.receipt-head h2 {
  font: inherit;
  color: var(--ink);
}
.ribbon {
  display: flex;
  gap: 2px;
  height: 12px;
  margin-bottom: 10px;
}
.ribbon span {
  min-width: 3px;
  border-radius: 3px;
  background: var(--c);
}
.lines {
  border-top: 1px dashed var(--line-strong);
  padding-top: 6px;
}
.line {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  margin: 0 -6px;
  border: 0;
  background: none;
  border-radius: 8px;
  text-align: left;
  font: 400 0.9rem / 1.2 var(--font-mono);
  width: calc(100% + 12px);
}
.line .dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 3px;
  background: var(--c);
}
.line .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.95rem;
}
.line .leader {
  flex: 1;
  min-width: 12px;
  height: 1px;
  align-self: center;
  margin-top: 8px;
  border-bottom: 2px dotted var(--line-strong);
}
.line .amt {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.line .pct {
  width: 2.8em;
  text-align: right;
  color: var(--ink-3);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.line[aria-pressed="true"] {
  background: color-mix(in oklab, var(--marker) 38%, transparent);
}
.line[aria-pressed="true"] .leader {
  border-color: var(--ink-3);
}
@media (hover: hover) {
  .line:hover {
    background: var(--paper-2);
  }
  .line[aria-pressed="true"]:hover {
    background: color-mix(in oklab, var(--marker) 50%, transparent);
  }
}
.line-more {
  color: var(--ink-3);
}
.sums {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-strong);
  display: grid;
  gap: 6px;
  font: 400 0.85rem / 1.3 var(--font-mono);
}
.sums div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}
.sums dt {
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}
.sums .grand {
  padding-top: 6px;
  font-size: 1rem;
  font-weight: 500;
}
.sums .grand dt {
  color: var(--ink);
  font-size: 0.82rem;
}
.sums .pos {
  color: var(--good);
}
.sums .neg {
  color: var(--danger);
}

/* ---------- activity ---------- */
.activity {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
}
.section-title {
  font: 700 1.3rem / 1.1 var(--font-display);
  letter-spacing: -0.02em;
}
.aside {
  font: 400 0.78rem / 1.2 var(--font-mono);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 8px 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--marker);
  color: var(--on-marker);
  font-weight: 500;
  font-size: 0.85rem;
}
.filter-chip svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.day {
  margin-top: 14px;
}
.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0 6px;
  font: 500 0.72rem / 1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line-strong);
}
.day-head .num {
  color: var(--ink-2);
}
.rows li + li .row {
  border-top: 1px solid var(--line);
}
.row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 0;
  border: 0;
  background: none;
  text-align: left;
  border-radius: 0;
}
.row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.row-title {
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-sub {
  font-size: 0.8rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-amt {
  font: 500 1rem / 1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.row-amt.in {
  color: var(--good);
}
.row.flash {
  animation: flash 1.4s var(--ease);
}
@keyframes flash {
  0%,
  30% {
    background: color-mix(in oklab, var(--marker) 45%, transparent);
  }
}
@media (hover: hover) {
  .row:hover .row-title {
    text-decoration: underline;
    text-decoration-color: var(--line-strong);
    text-underline-offset: 3px;
  }
}

.glyph {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: color-mix(in oklab, var(--c) 15%, var(--paper));
  color: var(--c);
}
.glyph svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.glyph-sm {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}
.glyph-sm svg {
  width: 18px;
  height: 18px;
}

/* ---------- empty ---------- */
.empty {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 0 8px;
}
.empty h2 {
  font: 800 2.3rem / 1 var(--font-display);
  letter-spacing: -0.04em;
}
.empty h2 em {
  font-style: normal;
  background: linear-gradient(176deg, transparent 0 52%, var(--marker-hl) 52% 88%, transparent 88%);
}
.empty p {
  color: var(--ink-2);
  max-width: 32ch;
}
.empty-sm h2 {
  font-size: 1.6rem;
}
.empty-stub {
  position: relative;
  width: 120px;
  padding: 16px 16px 12px;
  background: var(--paper);
  border-radius: 4px 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
  transform: rotate(-3deg);
  filter: drop-shadow(0 8px 12px var(--paper-shadow));
}
.empty-stub::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 8px;
  background: var(--paper);
  -webkit-mask:
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 12px 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 12px 100%;
}
.empty-stub span {
  height: 6px;
  border-radius: 3px;
  background: var(--line-strong);
}
.empty-stub span:nth-child(2) {
  width: 70%;
}
.empty-stub span:nth-child(3) {
  width: 50%;
  background: var(--marker);
}
.empty-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

/* ---------- buttons ---------- */
.btn {
  min-height: 52px;
  padding: 0 20px;
  border-radius: 14px;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1rem;
  text-align: center;
  transition:
    transform 0.15s var(--ease),
    opacity 0.2s;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:disabled {
  opacity: 0.35;
  cursor: default;
}
.btn-ghost {
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.btn-block {
  width: 100%;
}
.btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- dock ---------- */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  background: var(--dock);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--line);
  padding: 8px max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom, 0px) + 8px)
    max(16px, env(safe-area-inset-left));
}
.dock-inner {
  max-width: 30rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}
.tab {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 12px;
}
.tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab[aria-current="page"] {
  color: var(--ink);
}
.tab[aria-current="page"] span {
  background: linear-gradient(176deg, transparent 0 55%, var(--marker-hl) 55% 92%, transparent 92%);
  padding: 0 2px;
}
.add-btn {
  min-height: 56px;
  min-width: 132px;
  padding: 0 26px;
  border: 0;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  font-size: 1.05rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s var(--ease);
}
.add-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}
.add-btn:active {
  transform: scale(0.95);
}

/* ---------- sheets ---------- */
.sheet {
  width: 100%;
  max-width: 30rem;
  max-height: 94dvh;
  margin: auto auto 0;
  padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet[open] {
  animation: sheet-in 0.32s var(--ease);
}
.sheet::backdrop {
  background: var(--scrim);
}
@keyframes sheet-in {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}
@media (min-width: 640px) {
  .sheet {
    margin: auto;
    border-radius: 24px;
    padding-bottom: 20px;
  }
}
.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 10px auto 6px;
  border-radius: 4px;
  background: var(--line-strong);
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 10px;
  background: var(--bg);
}
.sheet-head h2 {
  font: 800 1.6rem / 1 var(--font-display);
  letter-spacing: -0.03em;
}
.sheet form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sheet-copy {
  color: var(--ink-2);
  font-size: 0.92rem;
}
.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.sheet-actions .btn {
  flex: 1;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field-label {
  font: 500 0.72rem / 1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 0;
}
.field input,
.money-input {
  min-height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  border: 0;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 1.05rem;
  width: 100%;
}
.field input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 0;
}
.money-input {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 700 1.6rem / 1 var(--font-display);
}
.money-input span {
  color: var(--ink-3);
}
.money-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 0;
  min-height: 56px;
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.money-input:focus-within {
  box-shadow: inset 0 0 0 2px var(--ink);
}
.money-input input:focus-visible {
  outline: none;
}

/* segmented control */
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
}
.seg button {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 0.92rem;
}
.seg button[aria-pressed="true"] {
  background: var(--primary);
  color: var(--on-primary);
}
.seg-sm button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.85rem;
}
.seg-wide {
  display: flex;
}
.seg-wide button {
  flex: 1;
}

/* ---------- entry sheet ---------- */
.entry-sheet form {
  gap: 12px;
}
.entry-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.amount {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-height: 76px;
  padding: 4px 0;
  font: 800 clamp(2.8rem, 14vw, 3.6rem) / 1 var(--font-display);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  white-space: nowrap;
}
.amount:focus {
  outline: none;
}
.amount.is-long {
  font-size: clamp(2rem, 10vw, 2.6rem);
}
.amount-sym {
  font-size: 0.55em;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 0;
}
.amount.is-empty #amount-num {
  color: var(--ink-3);
}
.amount.in #amount-num {
  color: var(--good);
}
.caret {
  width: 3px;
  height: 0.8em;
  align-self: center;
  border-radius: 2px;
  background: var(--marker);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.amount.shake {
  animation: shake 0.3s;
}
@keyframes shake {
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

.again {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 0 16px;
}
.again::-webkit-scrollbar {
  display: none;
}
.again-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px 0 6px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.85rem;
  white-space: nowrap;
}
.again-chip .glyph {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.again-chip .glyph svg {
  width: 15px;
  height: 15px;
}
.again-chip b {
  font: 500 0.82rem / 1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.cats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px 4px;
}
.cat {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0 6px;
  border: 0;
  border-radius: 14px;
  background: none;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.1;
  color: var(--ink-2);
}
.cat .glyph {
  width: 44px;
  height: 44px;
  transition:
    transform 0.2s var(--ease),
    background-color 0.2s;
}
.cat span:last-child {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}
.cat[aria-checked="true"] {
  color: var(--ink);
}
.cat[aria-checked="true"] .glyph {
  background: var(--c);
  color: var(--paper);
  transform: scale(1.06);
}
.cat[aria-checked="true"] span:last-child {
  font-weight: 600;
}

.entry-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.note {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-3);
}
.note:focus-within {
  box-shadow: inset 0 0 0 2px var(--ink);
}
.note svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.note input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  min-height: 46px;
  color: var(--ink);
  font-size: 1rem;
}
.note input:focus-visible {
  outline: none;
}
.note input::placeholder {
  color: var(--ink-3);
}
.when {
  display: flex;
  gap: 6px;
}
.when button,
.when-pick {
  position: relative;
  flex: 1;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 12px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.when-pick svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.when-pick input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.when-pick:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.when [aria-pressed="true"],
.when .is-on {
  background: var(--ink);
  color: var(--bg);
  box-shadow: none;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.keypad button {
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font: 600 1.5rem / 1 var(--font-display);
  display: grid;
  place-items: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition:
    transform 0.1s,
    background-color 0.15s;
}
.keypad button svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.keypad button:active,
.keypad button.press {
  transform: scale(0.95);
  background: var(--paper-2);
}
.keypad button:disabled {
  color: var(--line-strong);
}
.entry-actions {
  display: flex;
  gap: 8px;
}
.entry-actions .btn-save {
  flex: 1;
  min-height: 56px;
  font-size: 1.05rem;
}
.entry-actions .btn-danger-ghost {
  width: 56px;
  min-height: 56px;
  padding: 0;
}
.btn-save .save-amt {
  font-variant-numeric: tabular-nums;
}

/* ---------- settings ---------- */
.group {
  border-top: 1px solid var(--line-strong);
}
.setting {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  font-weight: 500;
}
.setting select {
  max-width: 60%;
  min-height: 40px;
  padding: 0 32px 0 12px;
  border: 0;
  border-radius: 10px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  appearance: none;
  -webkit-appearance: none;
  font-size: 0.92rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.setting-val {
  font: 400 0.9rem / 1 var(--font-mono);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.group-title {
  margin: 26px 0 10px;
  font: 500 0.72rem / 1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.cat-list {
  margin-top: 8px;
}
.cat-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 4px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  font-weight: 500;
}
.cat-row .count {
  margin-left: auto;
  font: 400 0.78rem / 1 var(--font-mono);
  color: var(--ink-3);
}
.cat-row svg.chev {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.add-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-weight: 500;
}
.add-row span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: 10px;
}
.add-row svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 8px;
}
.data-grid .btn {
  font-size: 0.9rem;
  padding: 0 10px;
  cursor: pointer;
}
.foot {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--ink-3);
  text-align: center;
}

.cat-preview {
  display: grid;
  place-items: center;
  padding: 4px 0;
}
.cat-preview .glyph {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--c);
  color: var(--paper);
}
.cat-preview .glyph svg {
  width: 32px;
  height: 32px;
}
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.swatch {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--c);
  display: grid;
  place-items: center;
  color: var(--paper);
}
.swatch svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.swatch[aria-checked="true"] svg {
  opacity: 1;
}
.swatch[aria-checked="true"] {
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px var(--ink);
}
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
}
.icon-pick {
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink-2);
  display: grid;
  place-items: center;
}
.icon-pick svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-pick[aria-checked="true"] {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- insights ---------- */
.figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line-strong);
}
.figures > div {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.figures > div:nth-child(even) {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}
.figures dt {
  font: 500 0.68rem / 1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.figures dd {
  margin-top: 8px;
  font: 800 1.6rem / 1 var(--font-display);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.figures dd small {
  display: block;
  margin-top: 6px;
  font: 400 0.75rem / 1.2 var(--font-body);
  letter-spacing: 0;
  color: var(--ink-3);
}
.figures .up {
  color: var(--danger);
}
.figures .down {
  color: var(--good);
}
.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chart {
  position: relative;
}
.chart svg {
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart svg:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
  border-radius: 6px;
}
.chart .bar {
  fill: var(--bar);
  transition: fill 0.2s;
}
.chart .bar.is-cur {
  fill: var(--ink);
}
.chart .bar.is-over {
  fill: var(--danger);
}
.chart .bar.is-sel {
  fill: var(--marker);
}
.chart .bar.is-future {
  fill: transparent;
  stroke: var(--line-strong);
  stroke-dasharray: 2 2;
}
.chart .hit {
  fill: transparent;
  cursor: pointer;
}
.chart .axis {
  stroke: var(--line-strong);
  stroke-width: 1;
}
.chart .cut {
  stroke: var(--bg);
  stroke-width: 3;
}
.chart .guide {
  stroke: var(--ink-2);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.chart text {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.chart text.val {
  fill: var(--ink-2);
  font-size: 10.5px;
}
.chart text.val-cur {
  fill: var(--ink);
  font-weight: 500;
}
.chart text.guide-label {
  fill: var(--ink-2);
}
.readout {
  min-height: 1.4em;
  font: 400 0.82rem / 1.4 var(--font-mono);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.compare li {
  border-bottom: 1px solid var(--line);
}
.compare li:first-child {
  border-top: 1px solid var(--line-strong);
}
.cmp {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
  padding: 12px 0;
}
.cmp .glyph {
  grid-row: span 2;
}
.cmp-name {
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmp-amt {
  font: 500 0.92rem / 1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.cmp-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
}
.cmp-track span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: var(--c);
}
.cmp-track i {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--ink);
}
.delta {
  justify-self: end;
  font: 500 0.72rem / 1 var(--font-mono);
  padding: 4px 6px;
  border-radius: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.delta.up {
  color: var(--danger);
  background: color-mix(in oklab, var(--danger) 12%, transparent);
}
.delta.down {
  color: var(--good);
  background: color-mix(in oklab, var(--good) 12%, transparent);
}
.delta.flat,
.delta.new {
  color: var(--ink-3);
  background: var(--line);
}
.legend-note {
  font-size: 0.8rem;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-note i {
  width: 2px;
  height: 12px;
  background: var(--ink);
  border-radius: 1px;
}

/* ---------- import ---------- */
.import-file {
  font: 400 0.82rem / 1.3 var(--font-mono);
  color: var(--ink-3);
  overflow-wrap: anywhere;
}
.import-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line-strong);
}
.import-facts div {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.import-facts div:nth-child(even) {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
.import-facts dt {
  font: 500 0.68rem / 1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.import-facts dd {
  margin-top: 6px;
  font: 700 1.15rem / 1.15 var(--font-display);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.import-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--ink-2);
}
.import-notes:empty {
  display: none;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  margin: 2px 0;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  background: color-mix(in oklab, var(--c) 15%, var(--paper));
  color: var(--ink);
}
.tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--c);
}
.import-preview {
  border-top: 1px dashed var(--line-strong);
}
.import-preview li.row + li.row {
  border-top: 1px solid var(--line);
}
.import-preview .more {
  padding: 10px 0 0;
  font: 400 0.8rem / 1.2 var(--font-mono);
  color: var(--ink-3);
}
.data-grid a.btn {
  text-decoration: none;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
  z-index: 20;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  min-height: 48px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.3s var(--ease);
}
.toast button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: var(--marker);
  color: var(--on-marker);
  font-weight: 600;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .caret {
    animation: none;
  }
}

/* Account sheet: maps Till's tokens onto the shared account sheet (css/account.css). */
:root {
  --acct-bg: var(--bg);
  --acct-field: var(--paper);
  --acct-raised: var(--paper);
  --acct-raised-on: var(--paper-2);
  --acct-ink: var(--ink);
  --acct-muted: var(--ink-2);
  --acct-faint: var(--ink-3);
  --acct-line: var(--line);
  --acct-line-strong: var(--line-strong);
  --acct-accent: var(--good);
  --acct-danger: var(--danger);
  --acct-primary: var(--primary);
  --acct-on-primary: var(--on-primary);
  --acct-seg-on: var(--primary);
  --acct-on-seg-on: var(--on-primary);
  --acct-headline-accent: var(--ink);
  --acct-headline-mark: var(--marker-hl);
  --acct-scrim: var(--scrim);
  --acct-shadow: var(--shadow);
  --acct-font-body: var(--font-body);
  --acct-font-display: var(--font-display);
  --acct-font-label: var(--font-mono);
  --acct-display-size: 2.35rem;
  --acct-display-weight: 800;
  --acct-display-tracking: -0.035em;
  --acct-label-weight: 500;
  --acct-label-tracking: 0.1em;
  --acct-sheet-radius: 24px 24px 0 0;
  --acct-radius: 14px;
  --acct-btn-radius: 14px;
  --acct-seg-radius: 12px;
  --acct-btn-h: 52px;
}
