/* Billfold app styles. Brand: paper #F3EEE4, ink #1A1814, pine #234039, copper #B5522A. */
:root {
  --ink: #1a1814;
  --pine: #234039;
  --pine-soft: #3d6558;
  --paper: #f3eee4;
  --card: #fffdf9;
  --line: #e2d9cb;
  --line-strong: #d3c7b5;
  --copper: #b5522a;
  --muted: #655d53;
  --ring: 0 0 0 3px rgba(35, 64, 57, 0.28);
  --shadow: 0 1px 2px rgba(26,24,20,.05), 0 18px 44px rgba(26, 24, 20, 0.08);
  --radius: 18px;
  font-family: "Outfit", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
a { color: var(--pine); }
:focus-visible { outline: none; box-shadow: var(--ring); }

.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 10px; z-index: 20; text-decoration: none; }
.skip:focus { top: 12px; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 4;
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  padding: 14px 28px;
  background: rgba(243, 238, 228, 0.88);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; border-radius: 12px; }
.mark { width: 40px; height: 40px; display: block; flex: none; }
.mark img { width: 40px; height: 40px; display: block; }
.brand h1 { margin: 0; font-family: "Fraunces", serif; font-size: 1.35rem; font-weight: 560; letter-spacing: -0.03em; line-height: 1.1; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 0.84rem; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Buttons: one system */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.93rem; font-weight: 500; line-height: 1.2;
  color: var(--ink);
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--pine); color: #f6f3ec; border-color: var(--pine); }
.btn.primary:hover { background: #1b332d; border-color: #1b332d; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--copper); border-color: rgba(181, 82, 42, 0.35); background: transparent; }
.btn.danger:hover { background: rgba(181, 82, 42, 0.07); border-color: var(--copper); }
.pro-btn { border-color: var(--pine); color: var(--pine); }
a.btn { text-decoration: none; }
.btn.buy { background: var(--copper); border-color: var(--copper); color: #fff8f1; }
.btn.buy:hover { background: #9c4522; border-color: #9c4522; }
.btn.is-disabled, .btn[aria-disabled="true"] { background: var(--card); border-color: var(--line); color: var(--muted); cursor: not-allowed; pointer-events: none; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.92fr);
  gap: 24px;
  max-width: 1360px; margin: 0 auto;
  padding: 24px 28px 40px;
  align-items: start;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(26,24,20,.04);
}
.preview-wrap {
  position: sticky; top: 92px;
  background: #ebe4d7;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
}
.preview-label { font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px 4px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.panel h2, .saved h2 {
  font-family: "Fraunces", serif; font-size: 1.4rem; margin: 0; font-weight: 560; letter-spacing: -0.02em;
}
.group {
  grid-column: 1 / -1; margin-bottom: 10px !important;
  font-family: "Fraunces", serif; font-weight: 560; font-size: 1.05rem; letter-spacing: -0.01em;
  margin: 18px 0 2px; padding-top: 18px; border-top: 1px solid var(--line);
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field span { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea, .item input {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
  outline: none;
  width: 100%; min-width: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
.field input:hover, .field select:hover, .field textarea:hover, .item input:hover { border-color: #bfb19c; }
.field input:focus, .field select:focus, .field textarea:focus, .item input:focus { border-color: var(--pine-soft); box-shadow: var(--ring); }
.field input[type=file] { padding: 6px; font-size: 0.88rem; color: var(--muted); }
.field input[type=file]::file-selector-button {
  font: inherit; font-size: 0.86rem; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; margin-right: 10px; cursor: pointer;
}
.notes { margin-top: 16px; }

.row-head, .item {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 0.5fr) minmax(0, 0.75fr) 88px 40px;
  gap: 8px; align-items: center;
}
.row-head { color: var(--muted); font-size: 0.74rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; margin: 10px 0 6px; }
.item { margin-bottom: 8px; }
.icon-btn { width: 40px; height: 40px; border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; }
.icon-btn:hover { background: rgba(181, 82, 42, 0.08); color: var(--copper); }
.add-line { margin-top: 2px; }

.toggles { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; gap: 2px; }
.seg .chip { border-color: transparent; background: transparent; }
.chip {
  border: 1px solid var(--line-strong); background: #fff; border-radius: 999px;
  padding: 7px 14px; font-size: 0.9rem; font-weight: 500; min-height: 36px;
  transition: background-color .15s ease, color .15s ease;
}
.chip.on, .seg .chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.main-actions { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.backup { align-items: center; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line-strong); }
.backup-label { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
label.btn { cursor: pointer; }
label.btn:focus-within { box-shadow: var(--ring); }

/* Paper (the document) */
.paper {
  background: white; color: #1c1915;
  border-radius: 10px;
  min-height: 640px;
  padding: 34px 32px;
  box-shadow: var(--shadow);
}
.paper-top { display: flex; justify-content: space-between; gap: 12px; }
.logo { width: 72px; height: 72px; object-fit: contain; border-radius: 8px; margin-bottom: 8px; }
/* Company logo on the paper: capped box, natural aspect ratio, never stretched. */
.paper .doc-logo { display: block; width: auto; height: auto; max-width: min(240px, 100%); max-height: 80px; object-fit: contain; border-radius: 0; margin: 0 0 12px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.logo-field .logo-row { flex-direction: column; align-items: flex-start; gap: 10px; }
.logo-preview { display: grid; place-items: center; min-width: 120px; max-width: 100%; min-height: 96px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 12px;
  background: #fff conic-gradient(#f1ece3 25%, #fff 0 50%, #f1ece3 0 75%, #fff 0) 0 0 / 16px 16px; }
.logo-preview img { display: block; max-width: min(240px, 100%); max-height: 96px; width: auto; height: auto; object-fit: contain; }
.logo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.logo-field small { color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.logo-field:focus-within label.btn { box-shadow: var(--ring); }
.logo-prompt { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 0 0 12px; padding: 10px 12px 10px 14px;
  background: var(--card); border: 1px dashed var(--line-strong); border-radius: 14px; font-size: 0.86rem; color: var(--muted); }
.logo-prompt .btn { min-height: 36px; padding: 6px 14px; font-size: 0.86rem; }
.badge { display: inline-block; border: 1px solid #1c1915; border-radius: 999px; padding: 2px 8px; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; }
.badge.paid { background: #234039; color: #f6f3ec; border-color: #234039; }
.badge.late { border-color: #b5522a; color: #b5522a; }
.paybox { margin-top: 16px; font-size: 0.84rem; color: #3f3a33; }
.due-note { color: #b5522a; font-size: 0.84rem; margin: 0 0 8px; }
.doc-kind { font-family: "Fraunces", serif; font-size: 2rem; margin: 0; letter-spacing: -0.04em; }
.biz { margin-top: 8px; }
.biz strong { display: block; font-size: 1.02rem; }
.biz, .meta, .client { font-size: 0.88rem; line-height: 1.5; color: #3f3a33; }
.meta { text-align: right; }
.rule { height: 1px; background: #ece6dc; margin: 18px 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: #6f675d; padding-bottom: 8px; }
td { padding: 9px 0; border-top: 1px solid #f0ebe3; }
td.num, th.num { text-align: right; padding-left: 12px; white-space: nowrap; }
.totals { margin-left: auto; width: min(250px, 100%); margin-top: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.92rem; }
.totals .due { font-family: "Fraunces", serif; font-size: 1.25rem; border-top: 1px solid #1c1915; margin-top: 6px; padding-top: 8px; }
.note { margin-top: 22px; font-size: 0.84rem; color: #5c564e; white-space: pre-wrap; }
.watermark { margin-top: 28px; font-size: 0.75rem; color: #a59b8e; letter-spacing: 0.08em; text-transform: uppercase; }

/* Saved list */
.saved { max-width: 1360px; margin: 0 auto; padding: 8px 28px 40px; }
.saved h2 { margin-bottom: 14px; }
.saved h2 .cap { font-family: "Outfit", system-ui, sans-serif; font-size: 0.82rem; color: var(--muted); font-weight: 400; margin-left: 8px; letter-spacing: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 14px 16px; text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.card:hover { border-color: var(--line-strong); box-shadow: 0 8px 22px rgba(26,24,20,.06); transform: translateY(-1px); }
.card b { display: block; font-weight: 600; }
.card.active { border-color: var(--pine-soft); box-shadow: 0 0 0 1px var(--pine-soft); }
.card .badge { margin-top: 8px; color: var(--ink); }
.card .badge.paid { color: #f6f3ec; }
.card .badge.late { color: var(--copper); }
.card span { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.card span.badge { display: inline-block; }
.empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  border: 1.5px dashed var(--line-strong); border-radius: 18px; padding: 22px 22px 22px 68px; position: relative;
  color: var(--muted); background: rgba(255,253,249,.5); margin: 0;
}
.empty::before {
  content: ""; position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 36px; border-radius: 5px; border: 2px solid var(--line-strong); background: linear-gradient(var(--line-strong),var(--line-strong)) 6px 10px / 14px 2px no-repeat, linear-gradient(var(--line-strong),var(--line-strong)) 6px 17px / 12px 2px no-repeat;
}
.empty b { color: var(--ink); font-weight: 600; }

.privacy { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 8px 22px 36px; margin: 0; line-height: 1.6; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 8px);
  background: var(--ink); color: var(--paper);
  padding: 11px 18px; border-radius: 999px; font-size: 0.92rem;
  box-shadow: 0 10px 30px rgba(26,24,20,.25);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Sheets */
.paywall {
  position: fixed; inset: 0; background: rgba(26,24,20,.5);
  display: none; place-items: center; padding: 18px; z-index: 10;
}
.paywall.open { display: grid; animation: fade .18s ease; }
.paywall.open .sheet { animation: rise .22s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.sheet {
  width: min(480px, 100%);
  max-height: calc(100vh - 36px); overflow-y: auto;
  background: var(--paper); border-radius: 24px; padding: 26px;
  box-shadow: 0 30px 80px rgba(26,24,20,.3);
}
.sheet h3 { font-family: "Fraunces", serif; margin: 0 0 8px; font-size: 1.7rem; font-weight: 560; letter-spacing: -0.03em; }
.sheet p { color: var(--muted); line-height: 1.55; }
.sheet .grid { margin-top: 6px; }
.sheet .field input, .sheet .field textarea { background: #fff; }
.price { font-family: "Fraunces", serif; font-size: 2rem; margin: 8px 0; }
.logo-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.logo-row small { color: var(--muted); width: 100%; }
.buy-line { margin: 16px 0 0; }

/* ---------- Sections (Quotes & invoices | Payslips) ---------- */
[hidden] { display: none !important; }
.mode-tabs { max-width: 1360px; margin: 0 auto; padding: 18px 28px 0; }
.mode-tabs .seg { background: var(--card); }
.mode-tabs .chip { min-height: 40px; padding: 8px 18px; }

/* ---------- Payslip editor ---------- */
.hint { color: var(--muted); font-size: 0.84rem; line-height: 1.5; margin: 0 0 10px; }
.hint.none { margin: 0 0 8px; font-style: italic; }
.field-hint { align-self: center; margin: 0 0 12px; }
.ps-fine { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line-strong); }
.salary-only { display: none; }
.is-salary .salary-only { display: flex; }
.ps-row { display: grid; gap: 8px; align-items: center; margin-bottom: 8px; }
.ps-hrow, .ps-hours-head { grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.55fr) minmax(0, 0.7fr) 72px 40px; }
.ps-xrow { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.2fr) minmax(0, 0.7fr) 72px 40px; }
.ps-drow, .ps-ded-head { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) minmax(0, 0.7fr) 40px; }
.ps-row input, .ps-row select {
  border: 1px solid var(--line-strong); background: #fff; border-radius: 12px; padding: 10px 12px; min-height: 44px; width: 100%; min-width: 0; outline: none;
}
.ps-row input:focus, .ps-row select:focus { border-color: var(--pine-soft); box-shadow: var(--ring); }
.ps-cell { display: block; min-width: 0; }
.ps-cell span { display: none; }
.ps-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--muted); cursor: pointer; }
.ps-chk input { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--pine); }

/* ---------- Payslip paper ---------- */
.payslip .ps-type { font-weight: 500; }
.payslip .totals { width: min(300px, 100%); }
.payslip .totals .gross { font-weight: 600; }
.payslip .totals div > span:last-child { white-space: nowrap; padding-left: 10px; }
.payslip .totals .ded span:first-child { display: flex; flex-direction: column; }
.payslip .totals .ded small { color: #6f675d; font-size: 0.76rem; }
.ps-boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.ps-box { border: 1px solid #ece6dc; border-radius: 10px; padding: 12px 14px; font-size: 0.84rem; color: #3f3a33; display: flex; flex-direction: column; gap: 2px; }
.ps-box strong { font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: #6f675d; font-weight: 600; margin-bottom: 4px; }
.ps-big { font-family: "Fraunces", serif; font-size: 1.25rem; color: #1c1915; }
.ps-ytd { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.ps-ytd span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .mode-tabs { padding: 12px 12px 0; }
  .mode-tabs .seg { display: flex; }
  .mode-tabs .chip { flex: 1 1 0; }
  .ps-hours-head, .ps-ded-head { display: none; }
  .ps-cell span { display: block; font-size: 0.7rem; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px 2px; }
  .ps-row { align-items: end; }
  .ps-chk, .ps-row .icon-btn { margin-bottom: 2px; min-height: 40px; }
  .ps-row { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .ps-hrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 72px 40px; }
  .ps-hrow input[data-k=desc] { grid-column: 1 / -1; }
  .ps-xrow { grid-template-columns: minmax(0, 1fr) 72px 40px; }
  .ps-xrow select, .ps-xrow input[data-k=desc] { grid-column: 1 / -1; }
  .ps-drow { grid-template-columns: minmax(0, 1fr) 40px; }
  .ps-drow input[data-k=desc], .ps-drow input[data-k=payee] { grid-column: 1 / -1; }
}
@media (max-width: 520px) { .ps-boxes { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 900px) {
  .app-header { padding: 10px 14px; position: static; }
  .brand p { display: none; }
  .layout { grid-template-columns: 1fr; padding: 14px 12px 24px; gap: 14px; }
  .panel { padding: 18px 16px; border-radius: 20px; }
  .preview-wrap { position: static; padding: 12px; border-radius: 20px; }
  .paper { min-height: 0; padding: 24px 20px; }
  .saved { padding: 4px 12px 28px; }
  .grid, .sheet .grid { grid-template-columns: 1fr; }
  .row-head { display: none; }
  .item { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; }
  .item input[data-k=desc] { grid-column: 1 / -1; }
  .item { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .main-actions .btn, .sub-actions .btn { flex: 1 1 calc(50% - 8px); }
  .sub-actions .btn { flex: 1 1 calc(33% - 8px); }
}
@media (max-width: 600px) {
  .app-header { flex-wrap: wrap; gap: 10px; }
  .header-actions { width: 100%; flex-wrap: nowrap; }
  .header-actions .btn { flex: 1 1 0; padding: 8px 10px; font-size: 0.88rem; white-space: nowrap; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  html, body { background: #fff; }
  .app-header, .mode-tabs, .panel, .saved, .toast, .paywall, .privacy, .preview-label, .logo-prompt, .skip { display: none !important; }
  .ps-boxes { break-inside: avoid; }
  .layout { display: block; padding: 0; }
  .preview-wrap { border: 0; padding: 0; background: none; border-radius: 0; position: static; }
  .paper { box-shadow: none; border-radius: 0; padding: 0; min-height: 0; }
  .paper, .paper * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr, .totals, .paybox { break-inside: avoid; }
}

/* Illustrated empty states */
.empty.has-art { align-items:center; text-align:center; padding:20px; }
.empty.has-art::before, .empty.has-art::after { display:none; }
.empty.has-art .empty-art { width:min(200px,70%); height:auto; margin:0 auto 6px; display:block; }

/* ---------- Quick wins (billfold-v13): Home, resume, saved items, search ---------- */
.home-main { max-width: 1360px; margin: 0 auto; padding: 18px 28px 8px; }
.home-hero { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 22px 24px; margin-bottom: 14px; }
.home-hero h2 { margin: 0; font-family: "Fraunces", Georgia, serif; font-size: 1.7rem; }
.home-hero p { margin: 4px 0 0; color: var(--muted); }
.home-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.home-stats div { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.home-stats b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.home-stats span { color: var(--muted); font-size: .84rem; }
.home-stats .late b { color: var(--copper); }
.home-h { font-size: 1.05rem; margin: 18px 0 10px; }
.shortcuts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.shortcuts .btn { min-height: 52px; border-radius: 16px; justify-content: flex-start; padding: 10px 16px; }
.shortcuts svg { width: 22px; height: 22px; fill: none; stroke: var(--pine); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.recent { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.recent li + li { border-top: 1px solid var(--line); }
.recent button { all: unset; box-sizing: border-box; display: flex; justify-content: space-between; gap: 12px; width: 100%; min-height: 56px; padding: 10px 16px; cursor: pointer; }
.recent button:focus-visible { box-shadow: var(--ring); border-radius: 18px; }
.recent small { display: block; color: var(--muted); }
.recent .amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.home-note, .resume-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; background: #e8efe9; color: var(--pine); border: 1px solid #c9d8cf; border-radius: 16px; padding: 12px 16px; margin-bottom: 14px; }
.resume-bar { margin: 0 0 16px; }
.home-note .actions, .resume-bar .actions { margin: 0; }
.home-note .btn, .resume-bar .btn, .item-tools .btn, .item-tools select, .saved-tools input, .saved-tools select, .line-gst, .saved-items .icon-btn { min-height: 44px; }
.item-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 2px; }
.item-tools select, .saved-tools input, .saved-tools select { font: inherit; font-size: .93rem; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; color: var(--ink); padding: 8px 14px; }
.item-tools select { max-width: 240px; }
.saved-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -4px 0 14px; }
.saved-tools input { flex: 1 1 220px; max-width: 360px; }
.line-gst { padding: 6px 10px; font-size: .82rem; justify-content: center; }
.line-gst:not(.on) { color: var(--ink); }
.gst-free { color: #555; font-size: .8em; }
.saved-items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.saved-items li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; }
.saved-items li + li { border-top: 1px solid var(--line); }
.saved-items li.none { color: var(--muted); padding: 10px 12px; font-size: .88rem; }
.saved-items small { color: var(--muted); }
.saved-items .icon-btn { width: 44px; }
body.mode-home .saved, body.mode-home #main, body.mode-home #payMain { display: none !important; }
@media (max-width: 760px) {
  .home-main { padding: 12px 12px 4px; }
  .home-hero { padding: 18px; border-radius: 20px; }
  .home-stats, .shortcuts { grid-template-columns: 1fr 1fr; }
  .row-head .gst-head { display: none; }
  .item-tools select { max-width: none; flex: 1 1 100%; }
}
@media (max-width: 900px) { .item { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 88px 40px; } }
@media print { .home-main, .resume-bar { display: none !important; } }

/* Pro polish (billfold-v13): keeps Billfold ink/pine/copper + existing art; 8px rhythm, quiet type, tabular numbers. */
.home-hero { display: grid; gap: 8px; padding: 16px; border-radius: 16px; }
.home-art { display: block; width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 8px; }
.home-h.eyebrow { font-family: "Outfit", system-ui, sans-serif; font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 24px 0 8px; }
.home-stats div, .shortcuts .btn { border-radius: 12px; }
.home-stats b, .recent .amt, .totals span, .paper td.num, .card span { font-variant-numeric: tabular-nums; }
.paper td.num, .paper th.num { text-align: right; }
.badge { font-weight: 600; font-size: .74rem; letter-spacing: .02em; }
.sheet { border-radius: 16px; }
@media (min-width: 901px) { .home-hero { grid-template-columns: 1fr 360px; align-items: center; } .home-art { grid-column: 2; grid-row: 1 / span 2; margin: 0; } }

/* Tap targets at least 44px (header, tabs, buttons). */
.app-header .brand, .app-header .btn, .mode-tabs .chip, .tabs .tab, .skip, .btn { min-height: 44px; }
.app-header .btn, .mode-tabs .chip { display: inline-flex; align-items: center; justify-content: center; }
/* First-run 3-field setup with live preview (billfold-v16) */
.setup-card { display: grid; grid-template-columns: 1fr; gap: 18px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 20px; padding: 18px; margin-bottom: 14px; }
@media (min-width: 760px) { .setup-card { grid-template-columns: 1fr 1fr; align-items: start; } }
.setup-card h3 { margin: 0 0 4px; font-family: "Fraunces", Georgia, serif; font-size: 1.3rem; color: var(--ink); }
.setup-card p { margin: 0 0 12px; color: var(--muted); }
.setup-card input:not([type=file]) { min-height: 44px; }
.setup-logo { display: flex; gap: 8px; flex-wrap: wrap; position: relative; overflow: hidden; }
.setup-logo .btn, .setup-card .actions .btn { min-height: 44px; }
.setup-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.setup-err { color: #9a3412; font-weight: 600; }
.setup-prev small { display: block; margin-top: 8px; color: var(--muted); }
.sp-paper { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); color: var(--ink); font-size: .9rem; }
.sp-head { display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.sp-head img { max-width: 96px; max-height: 48px; object-fit: contain; }
.sp-logo { display: inline-flex; width: 56px; height: 40px; border: 1px dashed var(--line-strong); border-radius: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: .75rem; }
.sp-head b { display: block; font-size: 1rem; word-break: break-word; }
.sp-head small { color: var(--muted); }
.sp-kind { font-weight: 700; color: var(--pine); margin: 10px 0 2px !important; }
.setup-card .sp-to { margin: 0 0 8px; color: var(--muted); }
.sp-line { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); }
.sp-total { font-weight: 700; }
.sp-logo.sp-pro { width: auto; padding: 0 8px; text-align: center; color: var(--copper); border-color: var(--copper); font-weight: 600; min-height: 40px; }

/* ===== Billfold's own look (billfold-v16): stationery and ledger =====
   Fonts: Fraunces headings + IBM Plex Sans body. Pine letterhead band, copper accents, square-cornered buttons,
   folder-tab section nav, ledger-style Home. Not shared with any other Muscat Labs app. */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/ibm-plex-sans-latin.woff2) format("woff2"); }
:root { font-family: "IBM Plex Sans", system-ui, sans-serif; --radius: 6px; }
body { background: var(--paper); }
.app-header { background: var(--pine); color: #f6f3ec; border-bottom: 4px solid var(--copper); }
.app-header .brand h1 { color: #f6f3ec; }
.app-header .brand p { color: #d9e2dd; }
.app-header .btn { background: transparent; color: #f6f3ec; border-color: rgba(246,243,236,.55); }
.app-header .btn:hover { border-color: #f6f3ec; background: rgba(246,243,236,.08); }
.btn { border-radius: 4px; letter-spacing: .01em; }
.app-header .pro-btn { border-radius: 2px; border: 2px solid #f0b48f; color: #ffe9da; font-variant-caps: all-small-caps; letter-spacing: .08em; font-size: .78rem; font-weight: 700; }
.mode-tabs .seg { background: transparent; border: 0; border-bottom: 2px solid var(--line-strong); border-radius: 0; padding: 0; gap: 4px; display: flex; }
.mode-tabs .chip { border-radius: 6px 6px 0 0; border: 1px solid var(--line-strong); border-bottom: 0; background: #ebe4d6; color: var(--ink); min-height: 44px; margin-bottom: -2px; }
.mode-tabs .chip.on, .mode-tabs .seg .chip.on { background: var(--card); color: var(--pine); border-color: var(--line-strong); border-top: 3px solid var(--copper); font-weight: 600; }
/* Home: letterhead + ledger */
.home-hero.bf-letterhead { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 4px; padding: 18px 20px; border-left: 6px solid var(--pine); }
.bf-letterhead .home-art { width: 140px; height: auto; flex: none; margin: 0; grid-column: auto; grid-row: auto; }
.bf-letterhead .lh-eyebrow { margin: 0 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--copper); font-weight: 600; }
.bf-letterhead h2 { font-family: "Fraunces", Georgia, serif; font-size: 1.6rem; margin: 0; }
.bf-letterhead .lh-sub { margin: 6px 0 0; color: var(--muted); }
@media (max-width: 560px) { .bf-letterhead .home-art { width: 96px; } }
.home-stats.bf-ledger { display: block; margin: 0 0 14px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 4px; padding: 4px 18px; }
.bf-ledger div { display: flex; align-items: baseline; gap: 10px; padding: 12px 0; border: 0; border-radius: 0; background: none; }
.bf-ledger div + div { border-top: 1px dashed var(--line-strong); }
.bf-ledger dt { color: var(--ink); white-space: nowrap; }
.bf-ledger dt::after { content: ""; flex: 1; }
.bf-ledger div::after { content: none; }
.bf-ledger dd { margin: 0 0 0 auto; font-weight: 600; font-variant-numeric: tabular-nums; font-family: "IBM Plex Sans", system-ui, sans-serif; }
.bf-ledger .late dd { color: var(--copper); }
.bf-ledger .total { border-top: 2px solid var(--ink) !important; }
.bf-ledger .total dt, .bf-ledger .total dd { font-weight: 700; }
.home-h.eyebrow { font-family: "Fraunces", Georgia, serif; text-transform: none; letter-spacing: 0; font-size: 1.1rem; color: var(--pine); border-bottom: 1px solid var(--line-strong); padding-bottom: 6px; }
.shortcuts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.shortcuts .btn { flex-direction: column; align-items: flex-start; justify-content: flex-end; min-height: 92px; border-radius: 2px 14px 2px 2px; background: var(--card); border: 1px solid var(--line-strong); box-shadow: 3px 3px 0 #e2d9cb; padding: 12px 14px; font-weight: 600; }
.shortcuts .btn:hover { box-shadow: 3px 3px 0 var(--copper); }
.shortcuts svg { stroke: var(--copper); width: 26px; height: 26px; }
@media (max-width: 700px) { .shortcuts { grid-template-columns: 1fr 1fr; } }
.recent { border-radius: 4px; border-color: var(--line-strong); }
.recent .amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.home-note { border-radius: 4px; border-left: 4px solid var(--copper); background: #fbf3ea; color: var(--ink); border-color: #e7cdb9; }
.setup-card { border-radius: 4px; }
.sp-paper { border-radius: 2px; }
