:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #5b6560;
  --line: #dcd8cf;
  --brand: #1f5f4a;
  --brand-ink: #ffffff;
  --accent: #b5462f;
  --soft: #e8f0ec;
  --b1: #7fb69f;
  --b2: #e2b34a;
  --needs: #9a6a00;
  --b3: #d9793f;
  --b4: #b5462f;
  --focus: #2f6fdd;
  --field: #8a8f8a;
  --field-bg: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131715;
    --card: #1b211e;
    --ink: #e9eeeb;
    --muted: #a3ada8;
    --line: #2e3733;
    --brand: #5bb08f;
    --brand-ink: #0d1411;
    --accent: #e0805f;
    --soft: #20302a;
    --focus: #7fa8ff;
    --field: #6b7570;
    --field-bg: #151a17;
    --needs: #e2b34a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 10; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

header.site { padding: 32px 0 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; margin: 0 0 12px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); display: inline-block; position: relative; }
.logo::after { content: ""; position: absolute; left: 6px; top: 4px; width: 6px; height: 11px; border: solid var(--brand-ink); border-width: 0 3px 3px 0; transform: rotate(40deg); }
.beta { font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }
h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.15; margin: 0 0 12px; }
.lede { font-size: 18px; margin: 0 0 8px; max-width: 46em; }
.promise { color: var(--muted); margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin: 18px 0; }
h2 { font-size: 20px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 16px; margin: 16px 0 8px; }
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: 14px; flex: none; }
.muted { color: var(--muted); }
.status { min-height: 1.5em; margin: 8px 0 0; }
.status.error { color: var(--accent); font-weight: 600; }

.drop { border: 2px dashed var(--field); border-radius: 12px; padding: 24px 16px; text-align: center; cursor: pointer; }
.drop.over { border-color: var(--brand); background: var(--soft); }
.drop p { margin: 4px 0; }
.drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.linkish { color: var(--brand); text-decoration: underline; cursor: pointer; }

button, .button { font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); padding: 9px 16px; cursor: pointer; text-decoration: none; display: inline-block; }
button.secondary, button.ghost { background: transparent; color: var(--brand); }
button.small { padding: 5px 10px; font-size: 14px; }
button:disabled { opacity: .5; cursor: default; }

textarea, input, select { font: inherit; color: var(--ink); background: var(--field-bg); border: 1px solid var(--field); border-radius: 8px; padding: 8px 10px; width: 100%; max-width: 100%; }
textarea { resize: vertical; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 15px; }
label.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; margin-top: 14px; }
label.check input { width: auto; margin-top: 4px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid .wide { grid-column: 1 / -1; }
details { margin-top: 12px; }
summary { cursor: pointer; font-weight: 600; color: var(--brand); }
details > *:not(summary) { margin-top: 10px; }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.stat .label { color: var(--muted); font-size: 14px; }
.stat .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 13px; }
.ageing { margin-top: 16px; }
.bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--soft); }
.bar span { display: block; height: 100%; }
.legend { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: baseline; }
.issues { margin-top: 16px; border-left: 4px solid var(--b2); padding-left: 12px; }
.issues ul { margin: 0; padding-left: 18px; }
.actions-row { margin: 16px 0 0; display: flex; gap: 10px; flex-wrap: wrap; }

.clients { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; counter-reset: c; }
.client { border: 1px solid var(--line); border-radius: 12px; padding: 14px; counter-increment: c; min-width: 0; overflow-wrap: anywhere; }
.client .email { margin: 4px 0 0; font-size: 14px; }
.small-note { font-weight: 400; font-size: 13px; }
select.needs-choice:not(:focus-visible) { outline: 3px solid var(--needs); outline-offset: 1px; }
#settings-msg { margin: 0 0 12px; }
.client-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.client-head h3 { margin: 0; font-size: 17px; }
.client-head h3::before { content: counter(c) ". "; color: var(--muted); }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 9px; background: var(--soft); color: var(--ink); }
.badge.upcoming, .badge.dueToday { background: var(--soft); }
.badge.due { background: color-mix(in srgb, var(--b1) 35%, transparent); }
.badge.firm { background: color-mix(in srgb, var(--b2) 40%, transparent); }
.badge.firmer { background: color-mix(in srgb, var(--b3) 40%, transparent); }
.badge.final { background: color-mix(in srgb, var(--b4) 40%, transparent); }
.next { margin: 6px 0; }
.inv { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--muted); }
.draft { margin-top: 10px; }
.draft input { font-weight: 600; margin-bottom: 6px; }
.draft textarea { min-height: 220px; font-size: 14px; line-height: 1.45; }
.draft-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.draft-actions button { max-width: 100%; overflow-wrap: anywhere; }
.drop:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

.offer { border-color: var(--brand); background: var(--soft); }
.faq details { border-top: 1px solid var(--line); padding-top: 10px; }
.site-foot { color: var(--muted); font-size: 14px; padding-bottom: 40px; }

@media (max-width: 520px) {
  .card { padding: 16px; }
  .stat .value { font-size: 22px; }
}

/* Secondary pages */
.home-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.prose h2 { margin-top: 18px; }
.prose ul { padding-left: 20px; }
.prose li { margin: 6px 0; }
