:root {
  --bg: #f4f6f5; --surface: #ffffff; --ink: #17211f; --muted: #5d6b68; --line: #d9e0de;
  --brand: #0f5f56; --brand-ink: #ffffff; --brand-soft: #e2f1ee;
  --ok: #17764a; --ok-soft: #e1f3e9; --warn: #8a5a00; --warn-soft: #fbefd3; --bad: #a3271f; --bad-soft: #fbe4e1; --info: #1d4f91; --info-soft: #e2ecfa;
  --radius: 12px; --gap: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101514; --surface: #1a2120; --ink: #e8eeec; --muted: #9aa8a5; --line: #2c3634;
    --brand: #4fc3b3; --brand-ink: #06231f; --brand-soft: #16302c;
    --ok: #6fd3a0; --ok-soft: #153324; --warn: #f0c36a; --warn-soft: #3a2c0c; --bad: #ff9b91; --bad-soft: #3c1815; --info: #9cc2f5; --info-soft: #16263d;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.35rem; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* замовники часто вписують у назву весь перелік товарів — показуємо три рядки */
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
[hidden] { display: none !important; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)); background: var(--brand); color: var(--brand-ink); }
.brand { color: inherit; font-weight: 700; text-decoration: none; letter-spacing: .2px; }
#nav { display: flex; gap: 4px; }
#nav a { color: inherit; text-decoration: none; padding: 6px 10px; border-radius: 999px; font-size: .95rem; opacity: .85; }
#nav a[aria-current="page"] { background: rgba(255, 255, 255, .22); opacity: 1; }
@media (prefers-color-scheme: dark) { #nav a[aria-current="page"] { background: rgba(0, 0, 0, .22); } }

main { max-width: 980px; margin: 0 auto; padding: var(--gap) 16px calc(40px + env(safe-area-inset-bottom)); outline: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: var(--gap); }
.narrow { max-width: 460px; margin-inline: auto; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

label { display: block; font-size: .875rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; font: inherit; font-weight: 600;
  border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); cursor: pointer; text-decoration: none; }
button.ghost, .btn.ghost { background: transparent; color: var(--brand); }
button.plain { background: transparent; border-color: transparent; color: var(--brand); padding-inline: 6px; min-height: 36px; }
button.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
button:disabled { opacity: .55; cursor: default; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.choice button[aria-pressed="false"] { background: transparent; color: var(--brand); }

.note { border-radius: 10px; padding: 10px 12px; font-size: .95rem; }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.info { background: var(--info-soft); color: var(--info); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* стрічка запитів */
.req { display: block; color: inherit; text-decoration: none; }
.req:hover { border-color: var(--brand); }
.req h2 { margin: 6px 0 4px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: .9rem; }

/* картка запиту */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.total { padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.total b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.total span { font-size: .8rem; color: var(--muted); }
.total.main { background: var(--brand-soft); grid-column: 1 / -1; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.pos { border-top: 1px solid var(--line); padding: 14px 0; }
.pos:first-of-type { border-top: 0; padding-top: 4px; }
.pos-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.pos-title { font-weight: 600; }
.pos-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin-top: 6px; }
.pos-grid .money { text-align: right; }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--brand); font-weight: 600; min-height: 36px; display: flex; align-items: center; }
.alt { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px dashed var(--line); }
.alt:first-child { border-top: 0; }
.steps { counter-reset: step; list-style: none; margin: 0; padding: 0; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 16px 40px; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.steps > li:last-child { padding-bottom: 0; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.scroll { overflow-x: auto; }
progress { width: 100%; height: 10px; accent-color: var(--brand); }

#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(92vw, 520px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 10; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }
@media (max-width: 520px) { .pos-grid { grid-template-columns: 1fr; } .pos-grid .money { text-align: left; } }
@media (prefers-reduced-motion: no-preference) { .card, button { transition: border-color .15s, background-color .15s; } }

/* сторінки політики й умов */
main.doc { max-width: 820px; }
main.doc h2 { margin-top: 22px; }
main.doc li { margin-bottom: 6px; }
main.doc table { display: block; overflow-x: auto; margin-bottom: 12px; }
main.doc td, main.doc th { min-width: 140px; }
