:root {
  --bg: #f6f5f0;
  --surface: #ffffff;
  --surface-2: #eeede6;
  --text: #16201b;
  --muted: #5d6a62;
  --line: #d9d8cf;
  --brand: #1f5a3f;
  --brand-ink: #ffffff;
  --brand-soft: #e3efe7;
  --oil: #f2b632;
  --oil-soft: #fdf2d4;
  --ok: #1d7a46;
  --ok-soft: #dff3e6;
  --warn: #9a5b00;
  --warn-soft: #fff0d1;
  --bad: #b3261e;
  --bad-soft: #fde4e1;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 14px rgb(0 0 0 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101512;
    --surface: #18201b;
    --surface-2: #212b25;
    --text: #eef2ee;
    --muted: #a2b0a7;
    --line: #2f3b34;
    --brand: #3f9b6d;
    --brand-soft: #1d3327;
    --oil-soft: #3a2f12;
    --ok: #5fd08f;
    --ok-soft: #173424;
    --warn: #f3b44b;
    --warn-soft: #3a2b10;
    --bad: #ff8a80;
    --bad-soft: #3d1b19;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand); color: var(--brand-ink);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: 17px; }
.brand img { border-radius: 7px; box-shadow: 0 0 0 1.5px rgb(255 255 255 / .35); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.chip {
  border: 1.5px solid rgb(255 255 255 / .5); background: transparent; color: #fff;
  border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.net { font-size: 12px; font-weight: 600; background: var(--oil); color: #2b2000; padding: 3px 9px; border-radius: 999px; }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }
h1 { font-size: 24px; line-height: 1.2; margin: 4px 0 4px; }
h2 { font-size: 18px; margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 54px; padding: 12px 18px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); font-size: 17px; font-weight: 650; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.ghost { background: transparent; color: var(--brand); min-height: 44px; }
.btn.wa { background: #1f9d55; }
.btn + .btn { margin-top: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row > .btn + .btn { margin-top: 0; }

label.lbl { display: block; font-weight: 650; margin: 16px 0 6px; }
label.lbl:first-child { margin-top: 0; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }
input.inp, textarea.inp, select.inp {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); font-size: 17px;
}
input.inp:focus, textarea.inp:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
textarea.inp { min-height: 80px; resize: vertical; }
.big-input { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); }
.big-input:focus-within { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
.big-input input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 34px; font-weight: 700; padding: 10px 14px; outline: none; }
.big-input span { padding-right: 16px; font-size: 20px; color: var(--muted); font-weight: 600; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 54px; height: 54px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-size: 26px; cursor: pointer; }
.stepper output { min-width: 48px; text-align: center; font-size: 26px; font-weight: 700; }

.choices { display: grid; gap: 8px; }
.choices.cols-2 { grid-template-columns: 1fr 1fr; }
.choice {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 12px 14px; min-height: 56px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface);
}
.choice[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1.5px var(--brand); }
.choice .grade { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--oil-soft); }
.choice .t { font-weight: 650; }
.choice .d { font-size: 13px; color: var(--muted); }
.choice .p { margin-left: auto; font-weight: 650; white-space: nowrap; }

.total {
  display: flex; justify-content: space-between; align-items: baseline;
  background: var(--oil-soft); border-radius: 12px; padding: 14px 16px; margin-top: 16px;
}
.total b { font-size: 26px; }

.steps { display: flex; gap: 6px; margin: 0 0 14px; }
.steps span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.steps span.on { background: var(--brand); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.alert { border-radius: 12px; padding: 12px 14px; margin: 12px 0; font-weight: 550; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--brand-soft); color: var(--text); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .r { text-align: right; white-space: nowrap; }
.list button.item { all: unset; display: flex; justify-content: space-between; gap: 12px; width: 100%; cursor: pointer; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); }
.badge.submitted { background: var(--brand-soft); color: var(--brand); }
.badge.verified { background: var(--ok-soft); color: var(--ok); }
.badge.disputed { background: var(--bad-soft); color: var(--bad); }
.badge.queued { background: var(--oil-soft); color: var(--warn); }

.sig-wrap { position: relative; border: 1.5px dashed var(--line); border-radius: 12px; background: #fff; touch-action: none; }
.sig-wrap canvas { display: block; width: 100%; height: 180px; border-radius: 12px; }
.sig-wrap .sig-line { position: absolute; left: 18px; right: 18px; bottom: 38px; border-bottom: 1.5px solid #c9c8bf; pointer-events: none; }
.sig-wrap .sig-x { position: absolute; left: 16px; bottom: 40px; color: #9a998f; font-weight: 700; pointer-events: none; }
.sig-wrap .sig-clear { position: absolute; top: 8px; right: 8px; border: 0; background: #eeede6; color: #333; border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.sig-wrap.done { border-style: solid; border-color: var(--brand); }
.sig-wrap.done .sig-x { display: none; }

.photo-prev { display: block; max-width: 100%; max-height: 220px; border-radius: 12px; margin-top: 10px; }

.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dots i.on { background: var(--brand); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button { height: 62px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 24px; font-weight: 650; cursor: pointer; }
.pinpad button:active { background: var(--brand-soft); }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

.hero-ok { text-align: center; padding: 18px 0 6px; }
.hero-ok .tick { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px; background: var(--ok-soft); color: var(--ok); font-size: 40px; }
.hero-ok .tick.queued { background: var(--oil-soft); color: var(--warn); }

.scanner { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; object-fit: cover; }
.scanner .frame { position: absolute; top: 50%; left: 50%; width: 64vmin; height: 64vmin; transform: translate(-50%, -50%); border: 3px solid var(--oil); border-radius: 18px; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .45); }
.scanner .bar { padding: 16px; background: #000; color: #fff; text-align: center; }
.scanner .bar p { margin: 0 0 10px; }

.spinner { width: 22px; height: 22px; border: 3px solid rgb(255 255 255 / .4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.btn.secondary .spinner, .loading .spinner { border-color: var(--line); border-top-color: var(--brand); }
.loading { display: flex; justify-content: center; padding: 40px 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer-links { text-align: center; font-size: 13px; margin-top: 24px; color: var(--muted); }
.footer-links a { color: var(--muted); }
