  :root{
    --ink:#14181d; --muted:#5b6672; --line:#dde3ea; --bg:#f6f8fa; --card:#fff;
    --accent:#0b6bcb; --good:#0d7a4a; --warn:#8a5a00; --bad:#a8302a;
  }
  *{box-sizing:border-box}
  body{margin:0;background:var(--bg);color:var(--ink);
       font:16px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
  .wrap{max-width:38rem;margin:0 auto;padding:1.5rem 1rem 4rem}
  h1{font-size:1.5rem;margin:.2rem 0 .3rem}
  .lede{color:var(--muted);margin:0 0 1.5rem}
  .card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:1.1rem;margin-bottom:1rem}
  label{display:block;font-weight:600;font-size:.86rem;margin-bottom:.3rem}
  .hint{font-weight:400;color:var(--muted);font-size:.82rem}
  input,select{width:100%;padding:.6rem .7rem;font-size:1rem;border:1px solid #c3ccd6;border-radius:8px;background:#fff;color:var(--ink)}
  input:focus,select:focus{outline:2px solid var(--accent);outline-offset:1px;border-color:var(--accent)}
  .row{display:flex;gap:.75rem;flex-wrap:wrap}
  .row>div{flex:1 1 9rem;min-width:0;margin-bottom:.85rem}
  button{font:inherit;font-weight:600;padding:.7rem 1.1rem;border-radius:8px;border:1px solid transparent;
         background:var(--accent);color:#fff;cursor:pointer}
  button:hover{filter:brightness(1.08)}
  button.ghost{background:#fff;color:var(--accent);border-color:#c3ccd6}
  .note{margin:.9rem 0 0;padding:.7rem .8rem;border-radius:8px;background:#fff8e6;border:1px solid #f0dca8;
        color:var(--warn);font-size:.9rem}
  .err{background:#fdeceb;border-color:#f3c4c1;color:var(--bad)}
  .toggle{background:none;border:0;color:var(--accent);padding:0;font-weight:600;font-size:.88rem;cursor:pointer}

  /* a receipt */
  .r{border:1px solid var(--line);border-radius:12px;background:#fff;padding:1.1rem;margin-bottom:.85rem}
  .r .merchant{font-weight:700}
  .r .addr{color:var(--muted);font-size:.88rem;white-space:pre-line}
  .r dl{display:grid;grid-template-columns:auto 1fr;gap:.2rem .9rem;margin:.8rem 0 0;font-size:.9rem}
  .r dt{color:var(--muted)}
  .r dd{margin:0;word-break:break-word}
  .items{width:100%;border-collapse:collapse;margin:.85rem 0 0;font-size:.95rem}
  .items th{text-align:left;font-weight:400;padding:.3rem 0;border-bottom:1px solid var(--line)}
  .items td{text-align:right;padding:.3rem 0;border-bottom:1px solid var(--line);font-variant-numeric:tabular-nums}
  .oneitem{color:var(--muted);font-size:.95rem;margin-top:.5rem}
.items .ref{display:block;font-size:.76rem;color:var(--muted);font-variant-numeric:tabular-nums;word-break:break-all}
.items td .ref{text-align:right}
.items .sum th .ref{font-weight:400}
.addr.contact{margin-top:.8rem}
  .tag{display:inline-block;font-size:.76rem;font-weight:700;letter-spacing:.02em;text-transform:uppercase;
       padding:.15rem .45rem;border-radius:5px;background:#eef3f8;color:var(--muted)}
  .tag.paid{background:#e7f5ee;color:var(--good)}
  .tag.pending{background:#fff4df;color:var(--warn)}
  .tag.none{background:#fdeceb;color:var(--bad)}
  .total{display:flex;justify-content:space-between;align-items:baseline;font-weight:700;
         padding:.9rem 1.1rem;background:#fff;border:1px solid var(--line);border-radius:12px;margin-bottom:1rem}
  .total .v{font-size:1.4rem}
  .actions{display:flex;gap:.6rem;flex-wrap:wrap;margin:.2rem 0 1.4rem}

  @media (prefers-color-scheme: dark){
    :root:not([data-theme="light"]){
      --ink:#e9edf2; --muted:#9aa6b2; --line:#2b333c; --bg:#11151a; --card:#171c22;
      --accent:#5aa9f8; --good:#4cc38a; --warn:#e0a33a; --bad:#f2817a;
    }
    :root:not([data-theme="light"]) input,:root:not([data-theme="light"]) select{background:#0e1216;border-color:#39424c;color:var(--ink)}
    :root:not([data-theme="light"]) .r,:root:not([data-theme="light"]) .total{background:var(--card)}
    :root:not([data-theme="light"]) .tag{background:#222a32}
    :root:not([data-theme="light"]) .note{background:#2a2110;border-color:#4a3a14}
    :root:not([data-theme="light"]) .err{background:#2b1514;border-color:#4d2422}
    :root:not([data-theme="light"]) button.ghost{background:transparent;border-color:#39424c}
  }

  /* Printing IS the download. A browser prints to PDF, so the receipts have to stand alone on
     paper: the form, the buttons and the page furniture all go. */
  @media print{
    body{background:#fff}
    .wrap{max-width:none;padding:0}
    .noprint{display:none !important}
    .r{break-inside:avoid;page-break-inside:avoid;border-color:#999}
    .total{border-color:#999}
  }

/* Moved out of the page: the Content-Security-Policy is styleSrc 'self', which blocks an inline
   <style> block and inline style attributes alike. Weakening the CSP on a PUBLIC page to save a
   file would be the wrong trade. */
.hint.tight{margin:-.4rem 0 1rem}
.sub-hint{margin:.3rem 0 .9rem}
.place{margin-top:.8rem}
.wide{flex:2 1 14rem}
.upper{text-transform:uppercase}
.note.inline{margin-top:.7rem}

/* The confirm and unsubscribe pages: one short message, nothing else. */
.wrap.narrow{max-width:30rem;padding-top:3rem}
.wrap.narrow h1{font-size:1.35rem;margin:0 0 .4rem}
.wrap.narrow p{color:var(--muted);margin:0}

/* The printed-invoice shape: a centred merchant block, then label-and-value rows with the total
   first. The amount is emphasised by weight rather than by a large display figure, because on this
   receipt the total sits in a row with its label rather than standing alone above everything. */
.r .merchant{text-align:center;font-size:1.25rem}
.r .addr{text-align:center}
.r .items.charges{margin-top:.2rem}
.r .items.charges th{font-weight:600}
.r .thanks{margin-top:1rem;text-align:center}

.r .prenote{font-size:.8rem;margin-top:.7rem}
