:root {
  --ink: #1a1a1a; --muted: #6b6b6b; --line: #e6e2dc; --bg: #ffffff; --soft: #f7f5f2;
  --gold: #a8833a; --gold-soft: #f6efe0; --warn: #b3261e; --warn-soft: #fbeaea; --ok: #2e6b3a;
  --r: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Assistant, system-ui, -apple-system, "Segoe UI", Arial, sans-serif; font-size: 17px; line-height: 1.45;
  color: var(--ink); background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
a { color: inherit; }
.top { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand img { display: block; }
nav { display: flex; gap: 4px; overflow-x: auto; }
nav a { text-decoration: none; padding: 6px 10px; border-radius: 999px; font-size: 15px; white-space: nowrap; color: var(--muted); }
nav a.on { background: var(--ink); color: #fff; }
main { max-width: 820px; margin: 0 auto; padding: 14px 16px 60px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 22px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.search { width: 100%; font: inherit; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--soft); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip { font: inherit; font-size: 15px; font-weight: 400; color: var(--ink); border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.count { font-size: 14px; color: var(--muted); margin: 6px 0 8px; }
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list li a { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); text-decoration: none; }
.list .code { font-weight: 700; font-size: 15px; }
.list .desc { grid-column: 1; }
.list .meta { grid-column: 1; font-size: 14px; color: var(--muted); }
.list .price { grid-column: 2; grid-row: 1 / span 3; align-self: center; text-align: left; font-weight: 700; font-size: 18px; white-space: nowrap; }
.list .price small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; margin-inline-start: 6px; vertical-align: 1px; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.grey { background: var(--soft); color: var(--muted); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form .full { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 14px; color: var(--muted); }
label.f input, label.f select, label.f textarea { font: inherit; font-size: 17px; color: var(--ink); padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; width: 100%; }
label.f textarea { min-height: 60px; resize: vertical; }
input[inputmode="decimal"] { direction: ltr; text-align: right; }
.box { background: var(--soft); border-radius: var(--r); padding: 12px 14px; margin: 14px 0; }
.box.warn { background: var(--warn-soft); color: var(--warn); }
.box.gold { background: var(--gold-soft); }
.rows { width: 100%; border-collapse: collapse; }
.rows td { padding: 4px 0; vertical-align: top; }
.rows td:last-child { text-align: left; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rows tr.total td { border-top: 1px solid var(--line); font-weight: 700; padding-top: 8px; }
.rows tr.client td { font-size: 20px; font-weight: 700; }
.btns { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
button, .btn { font: inherit; font-weight: 600; border: 0; border-radius: var(--r); padding: 11px 20px; cursor: pointer; background: var(--ink); color: #fff; text-decoration: none; }
button.ghost, .btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: default; }
.err { color: var(--warn); font-size: 15px; margin: 8px 0; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--r); }
table.data { border-collapse: collapse; width: 100%; font-size: 14.5px; }
table.data th, table.data td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data td.num, table.data th.num { text-align: left; font-variant-numeric: tabular-nums; }
table.data td.d { white-space: normal; min-width: 160px; }
.up { color: var(--ok); } .down { color: var(--warn); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 10px 0 16px; }
.kpi { background: var(--soft); border-radius: var(--r); padding: 10px 12px; }
.kpi b { display: block; font-size: 19px; }
.kpi span { font-size: 13px; color: var(--muted); }
#toast { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); inset-inline: 16px; margin: auto; max-width: 420px; background: var(--ink); color: #fff;
  padding: 11px 16px; border-radius: var(--r); opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; text-align: center; }
#toast.on { opacity: 1; transform: none; }
#toast.has-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: start; }
#toast.on.has-action { pointer-events: auto; }
.toast-btn { background: #fff; color: var(--ink); padding: 7px 16px; flex: none; }
button.link { background: none; color: var(--gold); padding: 4px 0; font-weight: 600; font-size: 14.5px; text-decoration: underline; text-underline-offset: 3px; }
.hist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); font-size: 15px; }
.hist > li { padding: 9px 2px; border-bottom: 1px solid var(--line); }
.hist-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.hist ul, .changes { margin: 4px 0 0; padding-inline-start: 18px; }
.hist li li, .changes li { margin: 2px 0; }
.modal-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.modal { background: #fff; border-radius: 14px; padding: 16px 18px 6px; width: 100%; max-width: 460px; max-height: 85vh; overflow-y: auto; }
.modal h2 { margin: 0 0 8px; }
.modal p { margin: 8px 0; }
@media (min-width: 521px) { .modal-wrap { align-items: center; } }
.gate { text-align: center; padding: 50px 10px; }
.gate img { width: 120px; height: auto; }
@media (max-width: 520px) {
  .brand span { display: none; }
  .form { grid-template-columns: 1fr 1fr; }
}
