:root {
  --bg: #eef1ef;
  --surface: #ffffff;
  --ink: #17242a;
  --muted: #5d6b70;
  --line: #d5dcd8;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #dcebdd;
  --danger: #b4283f;
  --danger-soft: #f7dfe3;
  --warn: #8a5410;
  --warn-soft: #f6e8cf;
  --info-soft: #dfe8f3;
  --info: #25496f;
  --radius: 10px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Unbounded", "Onest", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11191c; --surface: #19252a; --ink: #e6eeea; --muted: #9db0aa; --line: #2c3b40;
    --accent: #6fbf94; --accent-ink: #0d1a14; --accent-soft: #1f3a2d;
    --danger: #f08fa0; --danger-soft: #3b1e25; --warn: #e6b86a; --warn-soft: #3a2d14;
    --info: #9cc3ee; --info-soft: #1c2f44;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; max-width: 68ch; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Каркас */
.main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 96px; }
.with-nav .main { margin-left: 232px; margin-right: 0; max-width: 1100px; padding: 32px 36px 48px; }
.side { position: fixed; inset: 0 auto 0 0; width: 232px; background: var(--ink); color: #e6eeea;
  padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; z-index: 5; }
@media (prefers-color-scheme: dark) { .side { background: #0b1215; } }
.brand { font-family: var(--font-display); font-size: 1.05rem; padding: 0 12px 20px; color: #fff; text-decoration: none; }
.side a.nav { display: block; padding: 10px 12px; border-radius: 8px; color: #c9d8d1; text-decoration: none; }
.side a.nav:hover { background: rgba(255,255,255,.08); }
.side a.nav[aria-current="page"] { background: var(--accent-soft); color: #17242a; font-weight: 600; }
.side .spacer { flex: 1; }
.side .who { font-size: .8rem; color: #9db0aa; padding: 0 12px 8px; overflow-wrap: anywhere; }
.side button.link { background: none; border: 0; color: #c9d8d1; text-align: left; padding: 10px 12px; cursor: pointer; font: inherit; border-radius: 8px; }
.side button.link:hover { background: rgba(255,255,255,.08); }
@media (max-width: 820px) {
  .with-nav .main { margin-left: 0; padding: 20px 16px 96px; }
  .side { inset: auto 0 0 0; width: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 2px; overflow-x: auto; }
  .brand, .side .who, .side .spacer { display: none; }
  .side a.nav, .side button.link { white-space: nowrap; padding: 10px 12px; text-align: center; }
}

/* Заголовок страницы */
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.head h1 { margin: 0; }
.crumbs { font-size: .875rem; color: var(--muted); margin-bottom: 6px; }

/* Компоненты */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.grow { flex: 1 1 200px; min-width: 0; }

label.field { display: grid; gap: 4px; font-size: .875rem; color: var(--muted); }
label.field > span { font-weight: 500; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; width: 100%; min-height: 42px; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--ink); }
.hint { font-size: .8125rem; color: var(--muted); }

.btn { font: inherit; font-weight: 600; min-height: 42px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .875rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.chip.new { background: var(--info-soft); color: var(--info); }
.chip.processed, .chip.pending, .chip.processing { background: var(--warn-soft); color: var(--warn); }
.chip.paid, .chip.completed, .chip.sent, .chip.active { background: var(--accent-soft); color: var(--accent); }
.chip.cancelled, .chip.failed, .chip.error { background: var(--danger-soft); color: var(--danger); }
.chip.off { background: var(--line); color: var(--muted); }

.stat { display: grid; gap: 2px; }
.stat b { font-family: var(--font-display); font-size: 2rem; font-weight: 500; line-height: 1.1; }
.alert { padding: 12px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin-bottom: 16px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }

/* Чек заказа */
.receipt { max-width: 440px; background: var(--surface); border: 1px solid var(--line); padding: 24px 22px 28px; position: relative;
  font-variant-numeric: tabular-nums; border-radius: 4px 4px 0 0;
  --tooth: 10px;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--tooth) 100%;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / var(--tooth) 100%; }
.receipt h2 { font-size: 1rem; margin-bottom: 2px; }
.receipt .rule { border: 0; border-top: 1.5px dashed var(--line); margin: 14px 0; }
.receipt .line { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; }
.receipt .line span:first-child { color: var(--muted); }
.receipt .line span:last-child { text-align: right; overflow-wrap: anywhere; }
.receipt .total { font-weight: 700; font-size: 1.2rem; }
.receipt .total span:first-child { color: var(--ink); }

/* Toasts и диалог */
#toasts { position: fixed; right: 16px; bottom: 88px; display: grid; gap: 8px; z-index: 50; max-width: min(92vw, 380px); }
@media (min-width: 821px) { #toasts { bottom: 24px; } }
.toast { background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.error { background: var(--danger); }
dialog { border: 0; border-radius: var(--radius); padding: 22px; max-width: min(92vw, 420px); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10, 20, 24, .5); }

.auth { max-width: 420px; margin: 8vh auto 0; }
.auth h1 { font-size: 1.6rem; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.steps { counter-reset: s; }
.steps li { counter-increment: s; }
.steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem; }
.steps li.done::before { content: "✓"; background: var(--accent); color: var(--accent-ink); }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: 2px 6px; border-radius: 4px; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: pop .18s ease-out; } @keyframes pop { from { transform: translateY(6px); opacity: 0; } } }
