/* Paidwell site.css. Concept: "One sheet, folded". Needs tokens.css first.
   Public pages, the member app (/app/), onboarding and the client invoice page (/i/) all use this file.
   Snippets for every class: studio/components.md. Build only from those snippets and studio/shell*.html.

   CLASS REFERENCE
   Layout ........ .page .wrap .wrap--text .wrap--form .stage .stage--paper .section .split .stack .cluster .grid-2 .grid-3 .grid-4
   Type .......... .h-hero .h-page .h-section .h-card .lede .eyebrow .small .soft .amount .num
   Header ........ .site-head .site-head__in .logo .nav .nav__link .nav-toggle  (public)
                   .app-head .app-head__in .app-nav .app-nav__link .app-head__who .app-head__biz  (member)
   Footer ........ .site-foot .site-foot__in .site-foot__links .demo-line   .app-foot
   Buttons ....... .btn (ink) .btn--main (red, one per view) .btn--quiet .btn--small .btn--block .linkish .icon
   Page header ... .page-head .page-head__title .page-head__actions
   Stat tiles .... .tiles .tile .tile__label .tile__value .tile__note .tile--paper
   Tables ........ .table-wrap .table (td[data-label] stacks rows at 640px) .table__amount .table__actions
   Status ........ .tag + .tag--open .tag--today .tag--overdue .tag--paid .tag--paused .tag--void
                   .tag--says-paid .tag--archived .tag--cancelled
   Plan .......... .plan-badge .plan-badge--pro .plan-notice
   Forms ......... .form .field .field__label .field__hint .field__error .input .select .textarea .check
                   .form-actions .field[data-invalid]
   Messages ...... .notice .notice--bad .notice--good .toast-region .toast .toast--bad
   Dialog ........ dialog.dialog .dialog__title .dialog__body .dialog__actions
   Empty state ... .empty .empty__art .empty__text
   Tabs/filters .. .tabs .tabs__item[aria-current] .filters .filter[aria-pressed]
   Timeline ...... .timeline .timeline__item .timeline__date .timeline__what (.is-done .is-next .is-skipped)
   Envelope ...... .envelope .envelope__flap .envelope__when .envelope__what
   Chart ......... .chart .chart__bars .chart__bar (--v: 0..1) .chart__bar.is-now .chart__labels
   Email ......... .letter .letter__meta .letter__subject .letter__body
   More .......... .more .pager .pager__info
   Steps ......... .steps .steps__item[aria-current]  (onboarding)
   Sheets ........ .sheet .sheet--corner .sheet--tilt .invoice-sheet (client page)
   Owner gaps .... [data-gap]  (dashed outline + "Owner: add ..." note from the attribute value)
   Motion ........ .fold-enter (page enter) .fold-in (any block) .fold-hero (home hero sequence, fold.js)
   Helpers ....... .visually-hidden .skip .hide-sm .show-sm
*/

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--yellow); color: var(--ink);
  font: var(--w-read) var(--t-m)/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body.is-app, body.is-paper { background: var(--paper); }
img, svg { max-width: 100%; height: auto; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 3px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
::selection { background: var(--ink); color: var(--yellow); }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.05; font-family: var(--font-display); }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
hr { border: 0; border-top: var(--rule) solid var(--ink); margin: 32px 0; }

/* ---------- Type ---------- */
.h-hero { font-size: var(--t-3xl); font-weight: var(--w-display); letter-spacing: -0.035em; line-height: .98; max-width: 15ch; text-wrap: balance; }
.h-page { font-size: var(--t-2xl); font-weight: var(--w-display); letter-spacing: -0.025em; line-height: 1.02; text-wrap: balance; }
.h-section { font-size: var(--t-xl); font-weight: var(--w-strong); letter-spacing: -0.015em; line-height: 1.1; }
.h-card { font-size: var(--t-l); font-weight: var(--w-strong); letter-spacing: -0.01em; line-height: 1.2; margin-bottom: .35em; }
.lede { font-size: var(--t-l); font-weight: var(--w-label); line-height: 1.45; max-width: 44ch; }
.eyebrow { font-size: var(--t-s); font-weight: var(--w-strong); letter-spacing: 0; margin: 0 0 12px; }
.small { font-size: var(--t-s); }
.soft { color: var(--ink-soft); }
.amount { font-size: var(--t-amount); font-weight: var(--w-display); letter-spacing: -0.035em; line-height: 1; }
.num { white-space: nowrap; }
.prose { max-width: var(--w-text); }
.prose h2 { font-size: var(--t-xl); font-weight: var(--w-strong); margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li { margin-bottom: .4em; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--w-page); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.wrap--text { max-width: calc(var(--w-text) + 2 * var(--gutter)); }
.wrap--form { max-width: calc(var(--w-form) + 2 * var(--gutter)); }
.page { padding-top: clamp(28px, 4vw, 56px); padding-bottom: clamp(56px, 8vw, 120px); }
.section { padding: clamp(48px, 8vw, 112px) 0; }
.section + .section { border-top: var(--rule-strong) solid var(--ink); }
.stage { background: var(--yellow); }
.stage--paper { background: var(--paper); }
.stack > * + * { margin-top: var(--stack, 16px); }
.cluster { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.split { display: grid; gap: clamp(28px, 5vw, 72px); grid-template-columns: 1fr; align-items: center; }
@media (min-width: 900px) { .split { grid-template-columns: 1.05fr 1fr; } }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-2, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1060px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---------- Sheets of paper ---------- */
.sheet { background: var(--paper); color: var(--ink); padding: clamp(20px, 3vw, 36px); position: relative; box-shadow: 10px 12px 0 var(--floor); }
.is-app .sheet, .stage--paper .sheet { background: var(--white); box-shadow: 6px 7px 0 var(--fold-2); border: var(--rule) solid var(--ink); }
.sheet--corner { clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--corner)), calc(100% - var(--corner)) 100%, 0 100%); }
.sheet--corner::after { content: ""; position: absolute; right: 0; bottom: 0; width: var(--corner); height: var(--corner); background: var(--fold-2); clip-path: polygon(0 0, 100% 0, 0 100%); }
.sheet--tilt { transform: rotate(-1.5deg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border: var(--rule-strong) solid var(--ink); border-radius: 0;
  background: var(--ink); color: var(--paper); font: var(--w-strong) var(--t-m)/1 var(--font-body);
  text-decoration: none; cursor: pointer; white-space: nowrap; box-shadow: 4px 4px 0 var(--fold-3);
}
.btn:hover { text-decoration: none; box-shadow: 2px 2px 0 var(--fold-3); transform: translate(2px, 2px); }
.btn:active { box-shadow: none; transform: translate(4px, 4px); }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--fold-2); color: var(--ink-soft); border-color: var(--fold-3); box-shadow: none; transform: none; cursor: not-allowed; }
.btn--main { background: var(--action); color: var(--action-ink); border-color: var(--action); box-shadow: 4px 4px 0 var(--ink); }
.btn--main:hover { box-shadow: 2px 2px 0 var(--ink); }
.btn--main:active { background: var(--action-press); }
.stage .btn--main, .site-head .btn--main { box-shadow: 4px 4px 0 var(--ink); }
.btn--quiet { background: transparent; color: var(--ink); box-shadow: none; }
.btn--quiet:hover { background: var(--fold-1); box-shadow: none; transform: none; }
.stage .btn--quiet:hover { background: var(--floor); }
.btn--small { min-height: 44px; padding: 0 14px; font-size: var(--t-s); }
.btn--block { width: 100%; }
.btn .icon { width: 20px; height: 20px; }
.icon { width: 20px; height: 20px; flex: none; fill: currentColor; vertical-align: -4px; }
.linkish { background: none; border: 0; padding: 0; min-height: 44px; font: inherit; font-weight: var(--w-label); color: inherit; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: .18em; cursor: pointer; }
.linkish--danger { color: var(--bad); }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: var(--w-display); font-size: 1.5rem; letter-spacing: -0.03em; color: var(--ink); min-height: 44px; }
.logo svg { width: 36px; height: 36px; flex: none; }
.logo:hover { text-decoration: none; }

/* ---------- Public header ---------- */
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: var(--paper); padding: 10px 14px; z-index: 50; }
.skip:focus { top: 8px; }
.site-head { background: var(--yellow); border-bottom: var(--rule-strong) solid var(--ink); position: relative; z-index: 20; }
.site-head__in { display: flex; align-items: center; gap: 16px; min-height: 76px; flex-wrap: wrap; }
.site-head .logo { margin-right: auto; }
.nav { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; }
.nav__link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; font-weight: var(--w-label); text-decoration: none; }
.nav__link:hover { text-decoration: underline; }
.nav__link[aria-current="page"] { font-weight: var(--w-strong); text-decoration: underline; text-decoration-thickness: 3px; }
.site-head__cta { display: none; }
.nav-toggle { display: none; min-height: 44px; padding: 0 14px; background: transparent; color: var(--ink); border: var(--rule-strong) solid var(--ink); font: var(--w-strong) var(--t-s)/1 var(--font-body); cursor: pointer; }
.nav-toggle[aria-expanded="true"] { background: var(--ink); color: var(--paper); }
@media (max-width: 900px) {
  .site-head__in { padding-top: 10px; padding-bottom: 10px; }
  .js .nav-toggle { display: inline-flex; align-items: center; }
  .js .site-head .nav { display: none; }
  .js .site-head .nav.is-open { display: flex; flex-direction: column; align-items: stretch; width: 100%; padding: 8px 0 16px; transform-origin: top; animation: fold-down var(--fold-time) var(--fold-ease); }
  .js .site-head .nav.is-open .nav__link { border-top: var(--rule) solid var(--ink); padding: 0; min-height: 52px; font-size: var(--t-l); }
  .js .site-head .nav .nav__cta { display: none; }
  .js .site-head__cta { display: inline-flex; }
}
@media (max-width: 420px) { .site-head__in, .app-head__in { gap: 8px 10px; } .js .site-head__cta { padding: 0 12px; } .nav-toggle { padding: 0 12px; } .logo { font-size: 1.3rem; gap: 8px; } .logo svg { width: 30px; height: 30px; } }

/* ---------- Member header (/app/) ---------- */
.app-head { background: var(--yellow); border-bottom: var(--rule-strong) solid var(--ink); position: relative; z-index: 20; }
.app-head__in { display: flex; align-items: center; gap: 10px 18px; min-height: 72px; flex-wrap: wrap; }
.app-nav { display: flex; gap: 2px; flex-wrap: wrap; margin-right: auto; }
.app-nav__link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; text-decoration: none; font-weight: var(--w-label); }
.app-nav__link .icon { width: 18px; height: 18px; }
.app-nav__link:hover { background: var(--floor); text-decoration: none; }
.app-nav__link[aria-current="page"] { background: var(--ink); color: var(--yellow); font-weight: var(--w-strong); }
.app-head__who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-head__biz { font-weight: var(--w-strong); max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-head__logout { min-height: 44px; }
.app-head .nav-toggle { display: none; }
@media (min-width: 901px) {
  .app-head__menu { display: contents; }
  .app-head .logo { order: 1; }
  .app-head__who { order: 2; margin-left: auto; }
  .app-head__add { order: 3; }
  .app-nav { order: 4; width: 100%; margin: 0 0 -2px; padding-top: 2px; }
  .app-head__in { padding-top: 10px; }
}
@media (max-width: 900px) {
  .app-head .logo { margin-right: auto; }
  .js .app-head .nav-toggle { display: inline-flex; align-items: center; order: 3; }
  .app-head__add { order: 2; }
  .app-head__menu { order: 4; width: 100%; }
  .js .app-head__menu { display: none; }
  .js .app-head__menu.is-open { display: block; padding: 4px 0 14px; transform-origin: top; animation: fold-down var(--fold-time) var(--fold-ease); }
  .app-nav { flex-direction: column; margin: 0; }
  .app-nav__link { min-height: 52px; border-top: var(--rule) solid var(--ink); font-size: var(--t-l); }
  .app-head__who { flex-wrap: wrap; padding-top: 12px; border-top: var(--rule) solid var(--ink); }
  .app-head__biz { max-width: none; white-space: normal; }
}
@media (max-width: 400px) { .app-head__add { padding: 0 12px; } .app-head .logo span { display: none; } }

/* ---------- Footers ---------- */
.site-foot { background: var(--yellow); border-top: var(--rule-strong) solid var(--ink); padding: 48px 0 28px; font-size: var(--t-s); }
.site-foot__in { display: grid; gap: 28px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .site-foot__in { grid-template-columns: 1.3fr 1fr; } }
.site-foot__about { max-width: 46ch; font-size: var(--t-m); font-weight: var(--w-label); }
.site-foot__links { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, max-content); gap: 0 32px; align-content: start; }
.site-foot__links a { display: inline-flex; min-height: 44px; align-items: center; font-weight: var(--w-label); }
.demo-line { grid-column: 1 / -1; margin: 0; padding-top: 18px; border-top: var(--rule) solid var(--ink); font-size: var(--t-s); font-weight: var(--w-label); }
.app-foot { padding: 28px 0 32px; border-top: var(--rule) solid var(--fold-2); font-size: var(--t-s); color: var(--ink-soft); }

/* ---------- Page header (member screens) ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: clamp(24px, 3vw, 40px); }
.page-head__title { margin: 0; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.page-head .lede { margin-top: 10px; width: 100%; }

/* ---------- Stat tiles (folded corner) ---------- */
.tiles { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 32px; }
.tile {
  position: relative; background: var(--yellow); color: var(--ink); padding: 20px 22px 24px; min-height: 148px;
  display: flex; flex-direction: column; gap: 6px;
  clip-path: polygon(0 0, calc(100% - var(--corner)) 0, 100% var(--corner), 100% 100%, 0 100%);
}
.tile::before { content: ""; position: absolute; top: 0; right: 0; width: var(--corner); height: var(--corner); background: var(--floor); clip-path: polygon(0 0, 0 100%, 100% 100%); }
.tile--paper { background: var(--white); outline: var(--rule) solid var(--ink); outline-offset: calc(-1 * var(--rule)); }
.tile--paper::before { background: var(--fold-2); }
.tile__label { font-size: var(--t-s); font-weight: var(--w-strong); }
.tile__value { font-size: var(--t-amount); font-weight: var(--w-display); letter-spacing: -0.035em; line-height: 1; margin-top: auto; }
.tile__note { font-size: var(--t-s); font-weight: var(--w-label); }
.tile a.tile__note { min-height: 24px; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--white); border: var(--rule) solid var(--ink); }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-m); }
.table th { text-align: left; font-size: var(--t-s); font-weight: var(--w-strong); padding: 12px 16px; border-bottom: var(--rule-strong) solid var(--ink); background: var(--fold-1); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: var(--rule) solid var(--fold-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--paper); }
.table a { font-weight: var(--w-strong); }
.table__amount { text-align: right !important; font-weight: var(--w-strong); white-space: nowrap; }
.table__actions { text-align: right; white-space: nowrap; }
@media (max-width: 640px) {
  .table-wrap { background: transparent; border: 0; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { background: var(--white); border: var(--rule) solid var(--ink); margin-bottom: 12px; padding: 6px 0; position: relative; }
  .table tbody tr:hover td { background: transparent; }
  .table td { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 10px; padding: 8px 16px; border: 0; text-align: left; }
  .table td[data-label]::before { content: attr(data-label); font-size: var(--t-s); font-weight: var(--w-strong); color: var(--ink-soft); }
  .table td:first-child { font-size: var(--t-l); grid-template-columns: 1fr; padding-top: 12px; }
  .table td:first-child::before { display: none; }
  .table__amount { text-align: left !important; }
  .table__actions { text-align: left; white-space: normal; }
  .table td .tag { white-space: normal; justify-self: start; }
}

/* ---------- Status tags (rectangular, folded corner) ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 14px 4px 9px; min-height: 28px;
  font-size: var(--t-s); font-weight: var(--w-strong); line-height: 1.2; white-space: nowrap;
  background: var(--white); color: var(--ink); box-shadow: inset 0 0 0 var(--rule) var(--ink);
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%); position: relative;
}
.tag::after { content: ""; position: absolute; top: 0; right: 0; width: 9px; height: 9px; background: var(--ink); clip-path: polygon(0 0, 0 100%, 100% 100%); }
.tag svg { width: 14px; height: 14px; fill: currentColor; }
.tag--open { }
.tag--today { background: var(--yellow); }
.tag--overdue { background: var(--ink); color: var(--paper); }
.tag--overdue::after { background: var(--action); }
.tag--paid { background: var(--fold-2); box-shadow: none; }
.tag--paid::before { content: ""; width: 12px; height: 8px; border-left: 3px solid currentColor; border-bottom: 3px solid currentColor; transform: rotate(-45deg) translate(1px, -2px); }
.tag--paused, .tag--cancelled { background: var(--fold-1); box-shadow: none; }
.tag--paused::before { content: ""; width: 9px; height: 11px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.tag--void { background: transparent; box-shadow: inset 0 0 0 var(--rule) var(--ink-soft); color: var(--ink-soft); text-decoration: line-through; text-decoration-thickness: 1.5px; border: 0; outline: 1.5px dashed var(--ink-soft); outline-offset: -1.5px; }
.tag--says-paid { background: var(--yellow); box-shadow: inset 0 0 0 var(--rule-strong) var(--ink); }
.tag--says-paid::before { content: "?"; display: inline-grid; place-items: center; width: 16px; height: 16px; background: var(--ink); color: var(--yellow); font-size: 11px; }
.tag--archived { background: var(--fold-1); color: var(--ink-soft); box-shadow: none; }
.tag--archived::after, .tag--paused::after, .tag--cancelled::after { background: var(--fold-3); }

/* ---------- Plan ---------- */
.plan-badge { display: inline-flex; align-items: center; min-height: 26px; padding: 2px 10px; font-size: var(--t-xs); font-weight: var(--w-strong); background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 var(--rule) var(--ink); }
.plan-badge--pro { background: var(--ink); color: var(--yellow); box-shadow: none; }
.plan-notice { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: center; background: var(--yellow); padding: 18px 20px; border: var(--rule-strong) solid var(--ink); margin-bottom: 24px; }
.plan-notice__art { width: 84px; grid-row: span 2; }
.plan-notice__text { font-weight: var(--w-label); }
.plan-notice__text strong { font-weight: var(--w-strong); display: block; font-size: var(--t-l); }
.plan-notice .btn { justify-self: start; }
@media (max-width: 520px) { .plan-notice { grid-template-columns: 1fr; } .plan-notice__art { grid-row: auto; width: 72px; } }

/* ---------- Forms ---------- */
.form { max-width: var(--w-form); }
.form--wide { max-width: none; }
.field { margin-bottom: 20px; }
.field__label { display: block; font-weight: var(--w-strong); font-size: var(--t-m); margin-bottom: 6px; }
.field__hint { display: block; font-size: var(--t-s); color: var(--ink-soft); margin: -2px 0 8px; }
.input, .select, .textarea {
  display: block; width: 100%; min-height: 50px; padding: 12px 14px; border: var(--rule-strong) solid var(--ink); border-radius: 0;
  background: var(--white); color: var(--ink); font: var(--w-read) var(--t-m)/1.4 var(--font-body);
}
.textarea { min-height: 140px; resize: vertical; }
.select { appearance: none; padding-right: 44px; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 22px) 52%, calc(100% - 15px) 52%; background-size: 7px 7px; background-repeat: no-repeat; }
.input:focus, .select:focus, .textarea:focus { outline: 3px solid var(--ink); outline-offset: 2px; }
.input::placeholder, .textarea::placeholder { color: #6E6A5E; }
.field[data-invalid] .input, .field[data-invalid] .select, .field[data-invalid] .textarea, .input[aria-invalid="true"] { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.field__error { display: flex; gap: 6px; align-items: flex-start; margin-top: 8px; color: var(--bad); font-weight: var(--w-label); font-size: var(--t-s); }
.field__error::before { content: "!"; flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; background: var(--bad); color: var(--white); font-weight: var(--w-display); font-size: 12px; margin-top: 1px; }
.field__error:empty { display: none; }
.check { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; padding: 8px 0; font-weight: var(--w-label); cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--ink); flex: none; }
.form-row { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-row { grid-template-columns: 1fr 1fr; } }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 28px; }
.form-status { font-weight: var(--w-label); }
.stage .input, .stage .select, .stage .textarea { background: var(--paper); }

/* ---------- Notices and toasts ---------- */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--white); border: var(--rule-strong) solid var(--ink); font-weight: var(--w-label); margin-bottom: 20px; }
.notice .icon { margin-top: 2px; }
.notice--bad { border-color: var(--bad); color: var(--bad); background: var(--paper); box-shadow: inset 6px 0 0 var(--bad); padding-left: 22px; }
.notice--good { background: var(--fold-1); }
.toast-region { position: fixed; left: 0; right: 0; bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; z-index: 60; padding: 0 16px; perspective: 900px; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; max-width: 440px; width: max-content; min-height: 52px; padding: 12px 18px; background: var(--ink); color: var(--paper); font-weight: var(--w-label); box-shadow: 6px 6px 0 var(--floor); transform-origin: top center; animation: fold-down var(--fold-time) var(--fold-ease) both; }
.toast .icon { fill: var(--yellow); }
.toast--bad { background: var(--paper); color: var(--bad); box-shadow: inset 0 0 0 var(--rule-strong) var(--bad), 6px 6px 0 var(--fold-3); }
.toast--bad .icon { fill: var(--bad); }
.toast.is-leaving { animation: fold-up var(--fold-time) var(--fold-ease) both; }

/* ---------- Dialog ---------- */
dialog.dialog { border: var(--rule-strong) solid var(--ink); border-radius: 0; padding: 0; max-width: min(520px, calc(100vw - 32px)); width: 100%; background: var(--paper); color: var(--ink); box-shadow: 12px 14px 0 var(--floor); }
dialog.dialog[open] { transform-origin: top center; animation: fold-down var(--fold-time) var(--fold-ease); }
dialog.dialog::backdrop { background: rgba(20, 20, 20, .55); }
.dialog__title { font-size: var(--t-xl); font-weight: var(--w-strong); padding: 24px 24px 0; margin: 0 0 10px; }
.dialog__body { padding: 0 24px; }
.dialog__actions { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: 12px; padding: 24px; margin-top: 12px; border-top: var(--rule) solid var(--fold-2); }

/* ---------- Empty state ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 16px; padding: 32px 20px 40px; background: var(--white); border: var(--rule) solid var(--ink); }
.empty__art { width: 100%; max-width: 360px; background: var(--yellow); padding: 16px 24px 8px; }
.empty__art img, .empty__art svg { display: block; width: 100%; max-width: 260px; margin: 0 auto; }
.empty__text { font-size: var(--t-l); font-weight: var(--w-label); max-width: 34ch; margin: 0; }

/* ---------- Tabs and filters ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 0; border-bottom: var(--rule-strong) solid var(--ink); margin-bottom: 24px; }
.tabs__item { display: inline-flex; align-items: center; min-height: 48px; padding: 0 18px; font-weight: var(--w-label); text-decoration: none; background: none; border: 0; font-family: inherit; font-size: var(--t-m); color: var(--ink); cursor: pointer; margin-bottom: -2px; border-bottom: 4px solid transparent; }
.tabs__item:hover { background: var(--fold-1); text-decoration: none; }
.tabs__item[aria-current="page"], .tabs__item[aria-current="true"], .tabs__item[aria-selected="true"] { font-weight: var(--w-strong); border-bottom-color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.filter { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border: var(--rule-strong) solid var(--ink); background: var(--white); color: var(--ink); font: var(--w-label) var(--t-s)/1 var(--font-body); cursor: pointer; text-decoration: none; }
.filter b { font-weight: var(--w-strong); }
.filter[aria-pressed="true"], .filter[aria-current="page"] { background: var(--ink); color: var(--paper); font-weight: var(--w-strong); }
.search { position: relative; max-width: 360px; flex: 1 1 220px; }
.search .input { padding-left: 42px; min-height: 44px; }
.search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); }

/* ---------- Timeline (reminder schedule) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--ink); }
.timeline__item { position: relative; display: grid; grid-template-columns: 6.5em 1fr; gap: 4px 14px; padding: 0 0 22px 40px; }
.timeline__item::before { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: var(--white); box-shadow: inset 0 0 0 2px var(--ink); clip-path: polygon(0 0, 100% 0, 100% 60%, 60% 100%, 0 100%); }
.timeline__item.is-done::before { background: var(--ink); }
.timeline__item.is-next::before { background: var(--yellow); box-shadow: inset 0 0 0 3px var(--ink); }
.timeline__item.is-skipped { color: var(--ink-soft); }
.timeline__item.is-skipped .timeline__what { text-decoration: line-through; }
.timeline__date { font-weight: var(--w-strong); }
.timeline__what { font-weight: var(--w-label); }
.timeline__what small { display: block; font-size: var(--t-s); color: var(--ink-soft); font-weight: var(--w-read); }
@media (max-width: 480px) { .timeline__item { grid-template-columns: 1fr; } }

/* ---------- Envelope: the next reminder ---------- */
.envelope { position: relative; background: var(--paper); padding: 72px 24px 22px; border: var(--rule-strong) solid var(--ink); box-shadow: 8px 9px 0 var(--fold-2); max-width: 440px; }
.stage .envelope { box-shadow: 8px 9px 0 var(--floor); border-color: var(--paper); }
.envelope__flap { position: absolute; left: -2px; right: -2px; top: -2px; height: 64px; background: var(--fold-2); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.envelope__flap::after { content: ""; position: absolute; inset: 0 0 6px; background: var(--fold-1); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.envelope__when { font-size: var(--t-s); font-weight: var(--w-strong); }
.envelope__what { font-size: var(--t-xl); font-weight: var(--w-strong); line-height: 1.15; margin: 4px 0 8px; }
.envelope__to { font-size: var(--t-s); color: var(--ink-soft); margin-bottom: 14px; }

/* ---------- 12-month chart ---------- */
.chart { background: var(--white); border: var(--rule) solid var(--ink); padding: 20px 20px 14px; }
.chart__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.chart__bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; height: 180px; border-bottom: var(--rule-strong) solid var(--ink); }
.chart__bar { position: relative; height: calc(var(--v, 0) * 100%); min-height: 3px; background: var(--ink); }
.chart__bar.is-now { background: var(--yellow); box-shadow: inset 0 0 0 2px var(--ink); }
.chart__bar span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.chart__labels { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; margin-top: 8px; font-size: var(--t-xs); font-weight: var(--w-label); text-align: center; }
@media (max-width: 480px) { .chart__labels span:nth-child(even) { visibility: hidden; } .chart__bars, .chart__labels { gap: 3px; } .chart__bars { height: 140px; } }

/* ---------- Email preview (a sheet of paper) ---------- */
.letter { background: var(--white); max-width: 620px; box-shadow: 10px 11px 0 var(--fold-2); border: var(--rule) solid var(--ink); }
.letter__meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; padding: 18px 24px; border-bottom: var(--rule) solid var(--fold-2); font-size: var(--t-s); background: var(--paper); }
.letter__meta dt { font-weight: var(--w-strong); }
.letter__meta dd { margin: 0; overflow-wrap: anywhere; }
.letter__subject { font-size: var(--t-l); font-weight: var(--w-strong); padding: 20px 24px 0; margin: 0; }
.letter__body { padding: 14px 24px 28px; font-size: var(--t-m); line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
.letter__body a { color: var(--ink); font-weight: var(--w-strong); }

/* ---------- More / pagination ---------- */
.more { display: flex; justify-content: center; padding: 20px 0; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 0; }
.pager__info { font-size: var(--t-s); font-weight: var(--w-label); }

/* ---------- Onboarding steps ---------- */
.steps { display: flex; gap: 6px; list-style: none; margin: 0 0 28px; padding: 0; counter-reset: s; }
.steps__item { flex: 1; padding-top: 10px; border-top: 6px solid var(--fold-2); font-size: var(--t-s); font-weight: var(--w-label); counter-increment: s; }
.steps__item::before { content: counter(s) ". "; font-weight: var(--w-strong); }
.steps__item.is-done { border-top-color: var(--ink); }
.steps__item[aria-current="step"] { border-top-color: var(--yellow); font-weight: var(--w-strong); box-shadow: inset 0 2px 0 var(--ink); }
@media (max-width: 480px) { .steps__item span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }

/* ---------- Client invoice page (/i/) ---------- */
.invoice-sheet { background: var(--paper); max-width: 720px; margin: 0 auto; padding: clamp(24px, 5vw, 56px); box-shadow: 12px 14px 0 var(--floor); position: relative; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 36px), calc(100% - 36px) 100%, 0 100%); }
.invoice-sheet::after { content: ""; position: absolute; right: 0; bottom: 0; width: 36px; height: 36px; background: var(--fold-2); clip-path: polygon(0 0, 100% 0, 0 100%); }
.invoice-sheet__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; padding-bottom: 20px; border-bottom: var(--rule-strong) solid var(--ink); margin-bottom: 24px; }
.invoice-sheet__total { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; padding: 20px 0; border-top: var(--rule-strong) solid var(--ink); border-bottom: var(--rule-strong) solid var(--ink); margin: 24px 0; }
.lines { width: 100%; border-collapse: collapse; }
.lines td, .lines th { padding: 10px 0; border-bottom: var(--rule) solid var(--fold-2); text-align: left; vertical-align: top; }
.lines th { font-size: var(--t-s); font-weight: var(--w-strong); }
.lines td:last-child, .lines th:last-child { text-align: right; white-space: nowrap; padding-left: 16px; }
.pay-box { background: var(--fold-1); padding: 18px 20px; margin: 20px 0; }
.pay-box dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.pay-box dt { font-weight: var(--w-strong); }
.pay-box dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Owner gaps ---------- */
[data-gap] { outline: 2px dashed var(--ink); outline-offset: 4px; position: relative; }
[data-gap]::after { content: "Owner: add " attr(data-gap); display: block; margin-top: 8px; padding: 6px 10px; background: var(--paper); color: var(--ink); font: var(--w-strong) var(--t-xs)/1.3 var(--font-body); border: 1.5px dashed var(--ink); width: fit-content; max-width: 100%; }
img[data-gap], svg[data-gap] { min-height: 80px; background: var(--fold-1); }

/* ---------- Helpers ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 700px) { .hide-sm { display: none !important; } }
@media (min-width: 701px) { .show-sm { display: none !important; } }
[hidden] { display: none !important; }

/* ---------- Motion: the fold is the only transition ---------- */
@keyframes fold-down { from { transform: perspective(900px) rotateX(-90deg); } to { transform: perspective(900px) rotateX(0); } }
@keyframes fold-up { from { transform: perspective(900px) rotateX(0); } to { transform: perspective(900px) rotateX(-90deg); } }
@keyframes fold-open { from { transform: perspective(1400px) rotateX(-10deg); } to { transform: perspective(1400px) rotateX(0); } }
@keyframes fold-flat { from { transform: scaleY(0); } to { transform: scaleY(1); } }
/* Page enter: put .fold-enter on <main>. The page is fully visible from the first frame; only the angle moves. */
.fold-enter { transform-origin: 50% 0; animation: fold-open var(--fold-time) var(--fold-ease) both; }
/* One block folding open (a new row, a revealed answer). Add the class when the block appears. */
.fold-in { transform-origin: 50% 0; animation: fold-down var(--fold-time) var(--fold-ease) both; }

/* Home hero: scene-hero-fold.svg pasted inline. Still frame without script. fold.js adds the classes. */
.fold-hero { display: block; width: 100%; max-width: 640px; height: auto; overflow: visible; }
.fold-hero * { transform-box: view-box; }
.fold-hero .fh-top-f, .fold-hero .fh-top-b, .fold-hero .fh-flap { transform-origin: 0 210px; }
.fold-hero .fh-bot-f, .fold-hero .fh-bot-b { transform-origin: 0 350px; }
.fold-hero .fh-mover { transform-origin: 320px 280px; }
.fold-hero .fh-floor { transform-origin: 352px 514px; }
.fold-hero .fh-corner { transform-origin: 460px 460px; }
.fold-hero .fh-tick { transform-origin: 400px 140px; }
.fold-hero .fh-tab-env { transform-origin: 0 634px; }
.fold-hero .fh-stage { fill: var(--yellow); }
.fold-hero.is-playing .fh-top-f, .fold-hero.is-playing .fh-bot-f { transition: transform calc(var(--fold-time) / 2) ease-in; }
.fold-hero.is-playing .fh-top-b, .fold-hero.is-playing .fh-bot-b { transform: scaleY(0); transition: transform calc(var(--fold-time) / 2) ease-out calc(var(--fold-time) / 2); }
.fold-hero.is-playing .fh-flap { transform: scaleY(0); transition: transform calc(var(--fold-time) * .6) var(--fold-ease); }
.fold-hero.is-playing .fh-mover, .fold-hero.is-playing .fh-floor { transition: transform var(--fold-time) var(--fold-ease); }
.fold-hero.is-playing .fh-tab-env, .fold-hero.is-playing .fh-corner, .fold-hero.is-playing .fh-tick { transition: transform var(--fold-time) var(--fold-ease); }
.fold-hero.is-f1 .fh-top-f { transform: scaleY(0); }
.fold-hero.is-f1 .fh-top-b { transform: scaleY(-1); }
.fold-hero.is-f2 .fh-bot-f { transform: scaleY(0); }
.fold-hero.is-f2 .fh-bot-b { transform: scaleY(-1); }
.fold-hero.is-f3 .fh-flap { transform: scaleY(1); }
.fold-hero.is-lift .fh-mover { transform: translate(var(--lift-x, 0px), var(--lift-y, 330px)) scale(.12); }
.fold-hero.is-lift .fh-floor { transform: scale(.08); }
.fold-hero.is-return .fh-mover { transform-origin: 320px 70px; animation: fold-flat var(--fold-time) var(--fold-ease) both; }
.fold-hero.is-playing .fh-tab:not(.is-sent) .fh-tab-env { transform: scaleY(0); }
.fold-hero.is-playing:not(.is-paid) .fh-corner, .fold-hero.is-playing:not(.is-paid) .fh-tick { transform: scale(0); }
.fold-hero.no-anim, .fold-hero.no-anim * { transition: none !important; }
.fold-hero[data-status] [data-status-text] { display: none; }
.fold-hero[data-status="open"] [data-status-text="open"],
.fold-hero[data-status="late3"] [data-status-text="late3"],
.fold-hero[data-status="late10"] [data-status-text="late10"],
.fold-hero[data-status="paid"] [data-status-text="paid"] { display: inline; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important; }
  .btn:hover, .btn:active { transform: none; }
}

@media print {
  body { background: #fff; }
  .site-head, .app-head, .site-foot, .app-foot, .btn, .toast-region { display: none !important; }
  .invoice-sheet, .sheet, .letter { box-shadow: none; clip-path: none; }
}
