/* App, pay page and docs. Hairline panels on the graphite desk; the invoice itself is the only paper-white object. */
.brand { display: inline-flex; align-items: center; gap: 10px; font: 800 22px var(--display); letter-spacing: -0.03em; text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.err { color: var(--bad); font-size: 14px; min-height: 0; }
.err:empty { display: none; }
.fine { color: var(--mute); font-size: 13px; line-height: 1.5; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.addr { overflow-wrap: anywhere; }
.empty { color: var(--mute); padding: 28px 0; }

/* ---------- app shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - 34px); }
.side { border-right: 1px solid var(--line); padding: 26px 20px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.tabs { display: grid; gap: 2px; }
.tabs a { display: flex; justify-content: space-between; text-decoration: none; padding: 10px 12px; border-radius: var(--r); color: var(--mute); font-weight: 500; transition: background .2s, color .2s; }
.tabs a:hover { color: var(--fg); background: var(--panel); }
.tabs a[aria-current="page"] { color: var(--fg); background: var(--panel-2); box-shadow: inset 3px 0 0 var(--acc); }
.count { color: var(--acc); font-size: 12px; }
.modebox { display: grid; gap: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; }
.seg button { background: none; border: 0; padding: 9px; cursor: pointer; color: var(--mute); font-weight: 600; transition: background .2s, color .2s; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.side-docs { margin-top: auto; align-self: start; }
.main { padding: 22px clamp(16px, 3vw, 44px) 80px; min-width: 0; }
.keybar { display: flex; justify-content: flex-end; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.keymeta { color: var(--mute); font-size: 12.5px; }
.vhead { display: grid; gap: 10px; padding: 34px 0 26px; max-width: 70ch; }
.vhead h1 { font-size: clamp(2.6rem, 5.4vw, 4.6rem); }
.vhead p { color: var(--mute); }

/* builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr); gap: clamp(20px, 3vw, 44px); align-items: start; }
.form { display: grid; gap: 18px; min-width: 0; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.items { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 16px; }
.items-h, .irow { display: grid; grid-template-columns: minmax(0, 1fr) 70px 120px 34px; gap: 8px; align-items: center; }
.items-h { font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
#rows { display: grid; gap: 8px; }
.irow .x { background: none; border: 1px solid var(--line); color: var(--mute); border-radius: var(--r); height: 42px; cursor: pointer; font-size: 18px; }
.irow .x:hover { color: var(--bad); border-color: var(--bad); }
.items > .btn { justify-self: start; }
textarea.field { resize: vertical; }
.made { display: grid; gap: 10px; padding: 16px; border: 1px solid rgba(242, 210, 75, .35); border-radius: var(--r); background: rgba(242, 210, 75, .04); }
.linkbox { font-size: 12.5px; color: var(--fg); overflow-wrap: anywhere; max-height: 7.5em; overflow: auto; }
.preview { position: sticky; top: 20px; }

/* ---------- the paper */
.paper { position: relative; background: var(--paper); color: var(--paper-ink); border-radius: 3px; padding: clamp(20px, 3vw, 34px); display: grid; gap: 20px;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 30px 60px -20px rgba(0,0,0,.6), 0 8px 20px rgba(0,0,0,.35); overflow: hidden; }
.paper::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, transparent 0 27px, rgba(23,32,28,.035) 27px 28px); }
.paper.is-placeholder { opacity: .82; }
.p-head { display: flex; justify-content: space-between; align-items: start; }
.p-kind { font: 800 clamp(30px, 3.4vw, 44px)/.9 var(--display); letter-spacing: -0.04em; text-transform: uppercase; }
.p-no { font-size: 13px; color: #4b5650; margin-top: 6px; }
.p-mark { width: 38px; height: 38px; }
.p-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; font-size: 14px; }
.p-parties span { display: block; font: 500 10.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: #6b766f; }
.p-parties b { font-weight: 600; overflow-wrap: anywhere; }
.p-lines { width: 100%; border-collapse: collapse; font-size: 14px; }
.p-lines th { text-align: left; font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: #6b766f; border-bottom: 1.5px solid var(--paper-ink); padding: 0 0 8px; }
.p-lines td { padding: 9px 0; border-bottom: 1px solid rgba(23,32,28,.12); overflow-wrap: anywhere; }
.p-lines .n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; padding-left: 10px; white-space: nowrap; }
.p-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; background: var(--acc); margin: 0 calc(-1 * clamp(20px, 3vw, 34px)); padding: 14px clamp(20px, 3vw, 34px); }
.p-total span { font: 600 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.p-total b { font-size: clamp(22px, 2.6vw, 30px); font-weight: 500; }
.p-total small { font-size: 13px; }
.p-memo { font-size: 14px; color: #3b4741; border-left: 2px solid var(--paper-ink); padding-left: 12px; }
.p-foot { font-size: 10.5px; color: #6b766f; letter-spacing: .04em; }
.p-stamp { position: absolute; right: 8%; top: 38%; transform: rotate(-14deg); font: 800 clamp(44px, 6vw, 76px)/1 var(--display); letter-spacing: -0.02em; text-transform: uppercase;
  color: #1f7a4a; border: 6px solid #1f7a4a; padding: 6px 18px 10px; border-radius: 8px; opacity: .78; mix-blend-mode: multiply; animation: stamp .5s var(--ease) both; }
@keyframes stamp { from { transform: rotate(-14deg) scale(1.6); opacity: 0; } }

/* ---------- invoices table */
.toolbar { margin-bottom: 14px; }
.scanbar { height: 3px; background: var(--line); margin-bottom: 14px; }
.scanbar i { display: block; height: 100%; width: 0; background: var(--acc); transition: width .4s var(--ease); }
.tablebox { overflow-x: auto; border-top: 1px solid var(--line-2); }
table.inv { width: 100%; border-collapse: collapse; min-width: 720px; }
.inv th { text-align: left; font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); padding: 12px 10px; border-bottom: 1px solid var(--line); }
.inv td { padding: 14px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.inv td small { display: block; color: var(--dim); font-size: 12px; }
.inv .n { text-align: right; }
.inv .acts { text-align: right; white-space: nowrap; }
.inv .acts .btn + .btn { margin-left: 6px; }

/* ---------- vault */
.vsum { display: flex; gap: 40px; padding-bottom: 20px; }
.vsum b { display: block; font-size: clamp(26px, 3vw, 38px); font-weight: 500; }
.sweepto { display: grid; gap: 8px; max-width: 620px; padding: 18px 0 24px; border-top: 1px solid var(--line); }
.vlist { display: grid; border-top: 1px solid var(--line); }
.vrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 18px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.vrow > div { display: grid; gap: 2px; min-width: 0; }

/* ---------- keys */
.keygrid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--r); }
.kcard { padding: 22px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.kcard + .kcard { border-left: 1px solid var(--line); }
.kcard .btn { justify-self: start; }
.keynote { margin-top: 18px; max-width: 70ch; }

/* ---------- pay page */
.appbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px var(--gutter); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.paywrap { width: min(1180px, 100% - 2 * var(--gutter)); margin: 0 auto; padding: 40px 0 70px; }
.paygrid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: clamp(22px, 4vw, 60px); align-items: start; }
.sheet-stage { perspective: 1400px; }
.sheet-stage .paper { transform: rotate(-1.2deg); transform-origin: 50% 0; }
.paypanel { position: sticky; top: 24px; display: grid; gap: 16px; }
#payer, .receipt { display: grid; gap: 16px; }
.bigtotal { font-size: clamp(44px, 6vw, 76px); font-weight: 500; letter-spacing: -0.03em; line-height: 1; }
.bigtotal small { font-size: 18px; color: var(--mute); letter-spacing: 0; }
.demo-note { border: 1px dashed var(--line-2); padding: 10px 12px; border-radius: var(--r); font-size: 14px; color: var(--warn); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; border-top: 1px solid var(--line); }
.steps li { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--mute); }
.steps .dot { width: 10px; height: 10px; margin-top: 6px; border: 1.5px solid var(--dim); border-radius: 2px; }
.steps .st { font-size: 12px; white-space: nowrap; }
.steps li.run { color: var(--fg); } .steps li.run .dot { border-color: var(--acc); animation: blink 1s infinite; }
.steps li.ok { color: var(--fg); } .steps li.ok .dot { background: var(--ok); border-color: var(--ok); } .steps li.ok .st { color: var(--ok); }
@keyframes blink { 50% { opacity: .3; } }
.btn.wide { width: 100%; padding: 16px; font-size: 16px; }
.seen { display: grid; gap: 10px; }
.seen > div { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 14px; }
.seen .pill { justify-content: center; }
.receipt h2 { font-size: clamp(44px, 6vw, 72px); color: var(--acc); }
.r-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.r-row span { color: var(--mute); }
.r-row b { font-weight: 500; overflow-wrap: anywhere; }
.r-note { color: var(--mute); font-size: 13px; padding-top: 6px; }
.r-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pastebox { max-width: 640px; display: grid; gap: 16px; padding: 30px 0; }
.pastebox h1 { font-size: clamp(2.6rem, 6vw, 4.4rem); }
.appfoot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 26px 0 40px; border-top: 1px solid var(--line); color: var(--dim); font-size: 13px; }

@media print {
  body { background: #fff; color: #000; }
  .appbar, .appfoot, .r-actions, .banner, .cursor, .toast, .sheet-stage { display: none !important; }
  .paygrid { display: block; } .paypanel { position: static; }
  .receipt h2 { color: #000; } .r-row span, .r-note { color: #333; } .r-row { border-color: #ccc; }
}

@media (max-width: 1020px) {
  .builder, .paygrid { grid-template-columns: 1fr; }
  .preview, .paypanel { position: static; }
  .keygrid { grid-template-columns: 1fr; } .kcard + .kcard { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; gap: 14px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .tabs { grid-auto-flow: column; overflow-x: auto; width: 100%; order: 3; }
  .tabs a { white-space: nowrap; }
  .modebox { order: 2; margin-left: auto; } .modebox .label, .modebox .fine { display: none; }
  .side-docs { display: none; }
  .g2 { grid-template-columns: 1fr; }
  .items-h { display: none; }
  .irow { grid-template-columns: minmax(0, 1fr) 56px 92px 34px; }
  .vrow { grid-template-columns: minmax(0, 1fr) auto; } .vrow a { grid-column: 1; }
  .sheet-stage .paper { transform: none; }
  .p-parties { grid-template-columns: 1fr 1fr; }
  .r-row { grid-template-columns: 1fr; gap: 2px; }
}
