/* Kachink — receipt-paper interface tokens */

:root {
  /* Paper */
  --paper:        #F7F3EC;
  --paper-card:   #FBF8F2;
  --paper-inset:  #EFE9DE;
  --paper-edge:   #E6DFD0;

  /* Ink */
  --ink:          #161310;
  --ink-muted:    #5C544A;
  --ink-faint:    #948A7C;
  --ink-ghost:    #BFB6A6;

  /* Lines */
  --rule:         rgba(22, 19, 16, 0.18);
  --rule-soft:    rgba(22, 19, 16, 0.10);
  --perforation:  rgba(22, 19, 16, 0.32);

  /* Accents — used sparingly, each means something */
  --register-red: #C0392B;        /* primary action only */
  --register-red-ink: #8E2A20;    /* hover */
  --ledger-green: #4A7C3A;        /* income, positive */
  --stamp-purple: #6B4C8A;        /* tags / labels */

  /* Spacing — 4px base */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* Radius — paper barely rounds */
  --r-1: 3px;
  --r-2: 5px;
  --r-3: 8px;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Menlo", "SF Mono", monospace;

  /* Receipt width — actual receipts are ~80mm. We scale up. */
  --receipt-w: 460px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:        #1A1814;
    --paper-card:   #211E18;
    --paper-inset:  #15130F;
    --paper-edge:   #2A261F;
    --ink:          #F2EAD8;
    --ink-muted:    #B4A892;
    --ink-faint:    #7C7261;
    --ink-ghost:    #4A4337;
    --rule:         rgba(242, 234, 216, 0.18);
    --rule-soft:    rgba(242, 234, 216, 0.10);
    --perforation:  rgba(242, 234, 216, 0.30);
    --register-red: #D35446;
    --register-red-ink: #B53D2F;
    --ledger-green: #6BA354;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

/* ── Layout shell ──────────────────────────────────────────── */

.shell {
  width: 100%;
  max-width: 1080px;
  padding: var(--s-6) var(--s-5) var(--s-16);
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
}

@media (min-width: 720px) {
  .shell { padding: var(--s-10) var(--s-10) var(--s-16); }
}

/* ── Top bar ──────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--rule-soft);
}

.wordmark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

.wordmark::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--register-red);
  border-radius: 1px;
  display: inline-block;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  color: var(--ink-muted);
  font-size: 13px;
}

.topbar-link {
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 2px 4px;
  transition: color 120ms ease;
}

.topbar-link:hover { color: var(--ink); }

@media (max-width: 519px) {
  .topbar-link { display: none; }
}

.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--paper-inset);
  border: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
}

/* ── Tab nav ──────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: var(--s-5);
  font-size: 14px;
  border-bottom: 1px solid var(--rule-soft);
  margin-top: calc(-1 * var(--s-3));
}

.tab {
  color: var(--ink-faint);
  text-decoration: none;
  padding: var(--s-3) 0;
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms ease;
}

.tab:hover { color: var(--ink-muted); }

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
  font-weight: 500;
}

/* ── Receipt ──────────────────────────────────────────────── */

.receipt {
  width: 100%;
  max-width: var(--receipt-w);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: var(--s-8) var(--s-6) var(--s-6);
  margin: 0 auto;
  position: relative;
  font-family: var(--font-mono);
  font-size: 13.5px;
  letter-spacing: 0;
  color: var(--ink);
}

/* Torn top edge — subtle zig-zag, like a tear-off receipt */
.receipt::before {
  content: "";
  position: absolute;
  top: -1px; left: -1px; right: -1px;
  height: 8px;
  background:
    linear-gradient(135deg, var(--paper) 33%, transparent 33%) 0 0 / 12px 8px,
    linear-gradient(225deg, var(--paper) 33%, transparent 33%) 0 0 / 12px 8px;
  background-color: transparent;
}

.receipt-header {
  text-align: center;
  padding-bottom: var(--s-5);
  border-bottom: 1px dashed var(--perforation);
  margin-bottom: var(--s-4);
}

.receipt-header .store {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 13px;
}

.receipt-header .sub {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: var(--s-1);
  letter-spacing: 0;
}

.receipt-header .meta {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: var(--s-3);
  display: flex;
  justify-content: space-between;
}

/* Day group */
.day {
  margin-bottom: var(--s-4);
}

.day-label {
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: var(--s-2);
  display: flex;
  justify-content: space-between;
}

/* Transaction row */
.tx {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-4);
  padding: var(--s-2) 0;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}

.tx-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tx-name {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-meta {
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  margin-top: 1px;
}

.tx-amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tx-amount.income { color: var(--ledger-green); }

/* Section separator — perforated */
.perforated {
  border-top: 1px dashed var(--perforation);
  margin: var(--s-3) 0;
  height: 0;
}

/* Receipt footer — subtotals + TOTAL */
.subtotals {
  border-top: 1px dashed var(--perforation);
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  font-size: 12.5px;
  color: var(--ink-muted);
}

.subtotals .row {
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
}

.total {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1.5px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.total .label {
  font-weight: 700;
  letter-spacing: 0.22em;
  font-size: 13px;
}

.total .amount {
  font-weight: 700;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.receipt-footer-meta {
  margin-top: var(--s-5);
  text-align: center;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--r-2);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  text-decoration: none;
}

.btn:hover { background: var(--paper-inset); border-color: var(--rule); }

.btn-primary {
  background: var(--register-red);
  color: #FBF8F2;
  border-color: var(--register-red);
}

.btn-primary:hover {
  background: var(--register-red-ink);
  border-color: var(--register-red-ink);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-muted);
  padding: 8px 10px;
}

.btn-ghost:hover { color: var(--ink); background: var(--paper-inset); }

.btn-danger {
  border-color: var(--rule);
  color: var(--register-red);
  background: transparent;
}

.btn-danger:hover {
  background: var(--register-red);
  color: var(--paper-card);
  border-color: var(--register-red);
}

/* ── Card (used on account page) ──────────────────────────── */

.card {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: var(--s-6);
}

.card + .card { margin-top: var(--s-4); }

.card-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
  margin-bottom: var(--s-3);
}

.card-h {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.card-sub {
  color: var(--ink-muted);
  font-size: 13.5px;
  margin-top: var(--s-1);
}

/* Plan card — uses a rubber-stamp-styled status pill */
.plan-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-5);
  flex-wrap: wrap;
}

.plan-price {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.plan-price .unit {
  font-size: 13px;
  color: var(--ink-faint);
  font-weight: 400;
}

.stamp {
  display: inline-block;
  border: 1.5px solid currentColor;
  padding: 3px 10px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transform: rotate(-1.5deg);
  color: var(--ink-muted);
}

.stamp.free { color: var(--stamp-purple); }
.stamp.pro  { color: var(--ledger-green); }
.stamp.due  { color: var(--register-red); }

/* Usage meter — receipt-roll progress */
.usage {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

.usage-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.usage-row .label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.usage-row .label .name { color: var(--ink); font-weight: 500; }

.bar {
  height: 6px;
  background: var(--paper-inset);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--ink);
  border-radius: 2px;
}

.bar.warn > span { background: var(--register-red); }
.bar.ok   > span { background: var(--ledger-green); }

/* Action list (settings rows) */
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) 0;
  border-top: 1px solid var(--rule-soft);
}

.action-row:first-child { border-top: 0; }

.action-row .a-main { display: flex; flex-direction: column; }
.action-row .a-title { font-size: 14px; color: var(--ink); font-weight: 500; }
.action-row .a-sub { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }

.card.danger {
  border-color: rgba(192, 57, 43, 0.28);
  background: var(--paper-card);
}

.card.danger .card-title { color: var(--register-red); }

/* ── Index page ──────────────────────────────────────────── */

.index-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

.index-list a {
  display: flex;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  background: var(--paper-card);
  color: var(--ink);
  text-decoration: none;
}

.index-list a:hover { background: var(--paper-inset); }

.index-list .num {
  font-family: var(--font-mono);
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.1em;
}

/* ── Filter bar (transactions) ────────────────────────────── */

.filterbar {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.month-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
}

.month-picker .month {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 13px;
}

.month-picker .nav-btn {
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 var(--s-2);
  font-family: var(--font-mono);
}

.month-picker .nav-btn:hover { color: var(--ink); }

.month-picker .summary {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.chip {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--rule);
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  text-decoration: none;
  display: inline-block;
}

.tab { text-decoration: none; }
.card-link { text-decoration: none; }
.nav-btn { text-decoration: none; }

.chip:hover { background: var(--paper-inset); color: var(--ink); }

.chip.active {
  color: var(--paper-card);
  background: var(--ink);
  border-color: var(--ink);
}

.chip .count {
  color: var(--ink-faint);
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.chip.active .count { color: var(--paper-edge); }

.search {
  width: 100%;
  background: var(--paper-inset);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-2);
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
}

.search::placeholder { color: var(--ink-faint); }

.search:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--paper-card);
}

/* Light receipt — for transactions list, no torn edge, no TOTAL */
.receipt.flat { padding-top: var(--s-5); }
.receipt.flat::before { display: none; }

/* Transactions desktop layout — sidebar filters + receipt */
.tx-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
}

@media (min-width: 880px) {
  .tx-layout {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: var(--s-8);
    align-items: start;
  }

  .tx-layout .filterbar {
    position: sticky;
    top: var(--s-6);
  }

  .tx-layout .receipt {
    max-width: 620px;
    margin: 0;
  }
}

/* Filterbar tightened for sidebar use */
.tx-layout .chips { flex-direction: column; align-items: stretch; }
.tx-layout .chip { text-align: left; }

@media (max-width: 879px) {
  .tx-layout .chips { flex-direction: row; }
}

/* ── Recurring slips ──────────────────────────────────────── */

.slip {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: var(--s-5);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-4);
  align-items: center;
  position: relative;
}

.slip + .slip { margin-top: var(--s-2); }

.slip.paused {
  background: var(--paper);
  border-style: dashed;
  border-color: var(--perforation);
}

.slip.paused .slip-name,
.slip.paused .slip-amount { color: var(--ink-faint); }

.slip-left { min-width: 0; }

.slip-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.slip-meta {
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 4px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.slip-meta .next {
  color: var(--ink-muted);
}

.slip-right {
  display: flex;
  align-items: center;
  gap: var(--s-4);
}

.slip-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
}

.slip-amount.income { color: var(--ledger-green); }

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  padding: 2px 7px;
  border-radius: 2px;
  background: var(--paper-inset);
  color: var(--ink-muted);
  font-weight: 600;
}

.tag.green { background: rgba(74, 124, 58, 0.12); color: var(--ledger-green); }
.tag.red   { background: rgba(192, 57, 43, 0.10); color: var(--register-red); }
.tag.muted { background: var(--paper-inset); color: var(--ink-faint); }

/* Toggle switch */
.toggle {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--paper-inset);
  border: 1px solid var(--rule);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
  flex-shrink: 0;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink-muted);
  transition: transform 140ms ease, background 140ms ease;
}

.toggle.on {
  background: var(--ink);
  border-color: var(--ink);
}

.toggle.on::after {
  transform: translateX(14px);
  background: var(--paper-card);
}

/* Empty state */
.empty {
  text-align: center;
  padding: var(--s-12) var(--s-5);
  color: var(--ink-muted);
  font-size: 14px;
  border: 1px dashed var(--perforation);
  border-radius: var(--r-3);
}

.empty .h {
  color: var(--ink);
  font-weight: 500;
  font-size: 16px;
  margin-bottom: var(--s-1);
}

/* ── Sheet (log expense) ──────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(22, 19, 16, 0.32);
  backdrop-filter: blur(2px);
  z-index: 40;
}

.sheet {
  position: fixed;
  z-index: 50;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  color: var(--ink);
  box-shadow: -24px 0 60px -30px rgba(22, 19, 16, 0.30);
}

@media (min-width: 720px) {
  .sheet {
    top: 0; bottom: 0; right: 0;
    width: 460px;
    max-width: 100vw;
  }
}

@media (max-width: 719px) {
  .sheet {
    left: 0; right: 0; bottom: 0;
    top: var(--s-10);
    border-left: 0;
    border-top: 1px solid var(--rule);
    border-radius: 12px 12px 0 0;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--rule-soft);
}

.sheet-head .h {
  font-size: 16px;
  font-weight: 600;
}

.sheet-head .close {
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  font-size: 22px;
  cursor: pointer;
  font-family: var(--font-mono);
  line-height: 1;
  padding: 0 6px;
}

.sheet-head .close:hover { color: var(--ink); }

.sheet-body {
  padding: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  flex: 1;
  overflow-y: auto;
}

.sheet-foot {
  padding: var(--s-4) var(--s-6) var(--s-6);
  border-top: 1px solid var(--rule-soft);
  display: flex;
  gap: var(--s-3);
}

.sheet-foot .btn-primary { flex: 1; justify-content: center; padding: 12px 16px; }

/* Big amount input — the centerpiece */
.amount-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--s-2);
}

.amount-row .currency {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.amount-input {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-3);
  align-items: baseline;
  padding: var(--s-5) var(--s-5);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
}

.amount-input .sign {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 500;
  color: var(--ink-muted);
}

.amount-input > input {
  background: transparent;
  border: 0;
  outline: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 40px;
  font-weight: 600;
  color: var(--ink);
  width: 100%;
  letter-spacing: -0.02em;
  min-width: 0;
}

.amount-input > input::placeholder { color: var(--ink-ghost); }

.amount-input .cur-pick {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--rule);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.05em;
}

.amount-input .cur-pick:hover { color: var(--ink); background: var(--paper-inset); }

.amount-input .cur-pick:disabled { cursor: default; opacity: 0.7; }
.amount-input .cur-pick .caret {
  font-size: 10px;
  color: var(--ink-faint);
  margin-left: 4px;
}

/* Currency popover */
.cur-wrap { position: relative; }

.cur-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  width: 260px;
  max-width: calc(100vw - var(--s-6) * 2);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  box-shadow:
    0 1px 0 rgba(22, 19, 16, 0.04),
    0 14px 36px -18px rgba(22, 19, 16, 0.30);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cur-menu[hidden] { display: none; }

.cur-search-wrap {
  position: relative;
  padding: var(--s-2);
  border-bottom: 1px solid var(--rule-soft);
}

.cur-search-wrap::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: var(--ink-faint);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%23000' fill-rule='evenodd' d='M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Zm-.82 4.74a6 6 0 1 1 1.06-1.06l3.04 3.04-1.06 1.06-3.04-3.04Z' clip-rule='evenodd'/></svg>") no-repeat center / contain;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%23000' fill-rule='evenodd' d='M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Zm-.82 4.74a6 6 0 1 1 1.06-1.06l3.04 3.04-1.06 1.06-3.04-3.04Z' clip-rule='evenodd'/></svg>") no-repeat center / contain;
  pointer-events: none;
}

.cur-search {
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: var(--r-2);
  padding: 8px 10px 8px 30px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--ink);
  outline: 0;
}

.cur-search::placeholder { color: var(--ink-faint); }

.cur-list {
  max-height: 264px;
  overflow-y: auto;
  padding: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.cur-list::-webkit-scrollbar { width: 6px; }
.cur-list::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.cur-option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-3);
  align-items: center;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 7px 10px;
  cursor: pointer;
  border-radius: var(--r-2);
  font-family: var(--font-sans);
  min-height: 32px;
}

.cur-option-name {
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.cur-option-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  flex-shrink: 0;
}

.cur-option:hover {
  background: var(--paper-inset);
}

.cur-option:hover .cur-option-code {
  color: var(--ink-muted);
}

.cur-option.on {
  background: var(--paper-inset);
}

.cur-option.on .cur-option-name {
  font-weight: 600;
}

.cur-option.on .cur-option-code {
  color: var(--ink);
}

.cur-option[hidden] { display: none; }

.cur-empty {
  padding: var(--s-6) var(--s-4);
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-faint);
  font-family: var(--font-sans);
}

.cur-empty[hidden] { display: none; }

/* Mobile: full width within sheet padding */
@media (max-width: 519px) {
  .cur-menu {
    width: 240px;
  }
}

/* Toggle: expense / income segmented */
.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--paper-inset);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
}

.segment button {
  background: transparent;
  border: 0;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.segment button.on {
  background: var(--paper-card);
  color: var(--ink);
  box-shadow: 0 1px 0 var(--rule);
}

.segment button.on.income { color: var(--ledger-green); }

/* Field group */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.field-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  font-weight: 500;
}

.field input[type="text"],
.field input[type="date"],
.field textarea {
  background: var(--paper-inset);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-2);
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 14.5px;
  color: var(--ink);
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.field input:focus,
.field textarea:focus {
  outline: 0;
  border-color: var(--ink);
  background: var(--paper-card);
}

.field textarea { resize: vertical; min-height: 60px; font-family: var(--font-sans); }

/* Category grid */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
}

.cat-pick {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 10px 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.cat-pick .glyph {
  font-size: 18px;
  line-height: 1;
}

.cat-pick:hover { background: var(--paper-inset); color: var(--ink); }

.cat-pick.on {
  background: var(--ink);
  color: var(--paper-card);
  border-color: var(--ink);
}

/* Date pill row */
.date-row {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.date-pill {
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink-muted);
  cursor: pointer;
}

.date-pill:hover { background: var(--paper-inset); color: var(--ink); }
.date-pill.on { background: var(--ink); color: var(--paper-card); border-color: var(--ink); }

.date-pill .day {
  font-family: var(--font-mono);
  margin-left: 6px;
  color: var(--ink-faint);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.date-pill.on .day { color: var(--paper-edge); }

/* Inline toggle row */
.inline-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) 0;
  border-top: 1px solid var(--rule-soft);
}

.inline-toggle .lbl {
  display: flex;
  flex-direction: column;
}

.inline-toggle .lbl .t { font-size: 14px; color: var(--ink); font-weight: 500; }
.inline-toggle .lbl .s { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }

/* Page header (title + action) */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-head .sub {
  color: var(--ink-muted);
  font-size: 13px;
  margin-top: 2px;
}

/* ── Dashboard layout ─────────────────────────────────────── */

.dash {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
}

@media (min-width: 880px) {
  .dash {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: var(--s-6);
  }
  .dash .col-wide  { grid-column: 1; }
  .dash .col-side  { grid-column: 2; }
}

/* Hero — month at a glance */
.hero {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: var(--s-8) var(--s-8) var(--s-6);
}

.hero-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  margin-bottom: var(--s-4);
}

.hero-head .period { color: var(--ink); font-weight: 600; }

.hero-total {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1.5px solid var(--ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.hero-total .label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
}

.hero-total .amount {
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-left: auto;
  line-height: 1;
}

.hero-total .amount.positive { color: var(--ledger-green); }

.hero-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px dashed var(--perforation);
}

.hero-split .item .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.hero-split .item .v {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
}

.hero-split .item .v.income { color: var(--ledger-green); }

.hero-split .item .delta {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* Spending breakdown — receipt subtotals + inline bars */
.breakdown {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.bd-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: var(--s-4);
  align-items: center;
  font-size: 13.5px;
}

.bd-row .cat {
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bd-row .track {
  height: 8px;
  background: var(--paper-inset);
  border-radius: 2px;
  overflow: hidden;
}

.bd-row .track > span {
  display: block;
  height: 100%;
  background: var(--ink);
  border-radius: 2px;
}

.bd-row .track.income > span { background: var(--ledger-green); }
.bd-row .track.over > span   { background: var(--register-red); }

.bd-row .amt {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  color: var(--ink);
  text-align: right;
  min-width: 80px;
}

.bd-row .amt.income { color: var(--ledger-green); }

/* Card variants used on dashboard */
.card-h-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--s-3);
}

.card-link {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
  text-decoration: none;
  letter-spacing: 0.06em;
}

.card-link:hover { color: var(--ink); }

/* Upcoming list (compact slips, no toggle) */
.upcoming {
  display: flex;
  flex-direction: column;
}

.up-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-top: 1px dashed var(--perforation);
  align-items: baseline;
}

.up-row:first-child { border-top: 0; padding-top: 0; }

.up-row .name {
  font-size: 14px;
  color: var(--ink);
}

.up-row .when {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.up-row .when.tomorrow { color: var(--register-red); }
.up-row .when.today    { color: var(--register-red); font-weight: 600; }

.up-row .amt {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
}

.up-row .amt.income { color: var(--ledger-green); }

/* Recent activity preview — tight tx rows */
.recent {
  display: flex;
  flex-direction: column;
}

.recent .tx {
  padding: var(--s-3) 0;
  border-top: 1px dashed var(--perforation);
}

.recent .tx:first-child { border-top: 0; padding-top: 0; }

