:root {
  --bg: #f6f5f1; --card: #ffffff; --ink: #1d2420; --muted: #5d6a63; --line: #dcdad2; --brand: #1f6b46; --brand-ink: #ffffff;
  --brand-soft: #e3f0e8; --warn: #8a5a00; --warn-soft: #fff3d6; --bad: #a3271f; --bad-soft: #fde7e4; --ok: #1f6b46; --ok-soft: #e3f0e8;
  --focus: #1b5fd1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121714; --card: #1b221e; --ink: #e8ece9; --muted: #9aa8a0; --line: #2f3a34; --brand: #4cb783; --brand-ink: #08150e;
    --brand-soft: #1d3327; --warn: #f0c36a; --warn-soft: #3a2f12; --bad: #ff8f84; --bad-soft: #3d1b18; --ok: #4cb783; --ok-soft: #1d3327;
    --focus: #7fb0ff;
  }
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.45; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand small { font-weight: 500; color: var(--muted); margin-left: 4px; }
.mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-weight: 800; }
nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
nav button { background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--muted); font: inherit; cursor: pointer; }
nav button[aria-current="page"] { background: var(--brand-soft); color: var(--ink); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 0 0 6px; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 0 0 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.row > * { flex: 0 1 auto; }
.spacer { flex: 1 1 auto; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; width: 100%; }
.field { flex: 1 1 180px; }
button.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
button.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.btn.danger { color: var(--bad); border-color: var(--bad); }
button.btn:disabled { opacity: .55; cursor: default; }
a.btn { display: inline-block; text-decoration: none; font: inherit; border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; color: var(--ink); background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--line); color: var(--ink); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.note { border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; background: var(--brand-soft); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.price { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.price small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); width: max-content; max-width: min(92vw, 520px); pointer-events: none; }
.toast div { margin-top: 8px; padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast div.bad { background: var(--bad); color: #fff; }
.login { max-width: 380px; margin: 0 auto 24px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.hide { display: none; }
@media (max-width: 560px) { nav { order: 3; flex-basis: 100%; } .who { margin-left: auto; } .who span { display: none; } th, td { padding: 8px 6px; } }

textarea { resize: vertical; }
.field.wide { flex: 2 1 320px; }
.msg.from-vendor { background: var(--brand-soft); }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.thumb { position: relative; }
.thumb button.btn { position: absolute; top: 4px; right: 4px; padding: 0 8px; }
.filechip { display: inline-block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: inherit; text-decoration: none; }
.thumbs img { display: block; max-width: 240px; max-height: 160px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
label > input[type="checkbox"] { width: auto; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* the invoice (step 102) */
.invoice { max-width: 820px; }
.invoice h1 { margin: 0; }
.invoice-no { text-align: right; margin-left: auto; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
@media (max-width: 560px) { .parties { grid-template-columns: 1fr; } }
tr.total td { font-weight: 600; border-top: 2px solid var(--line); }
@media print {
  header.top, .noprint, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .card.invoice { border: 0; max-width: none; padding: 0; background: #fff; color: #000; }
  .muted { color: #444; }
}
