/* Веб-кабинет «Умный чек»: без сборки и внешних зависимостей. Цвета — переменные, тёмная тема по настройке системы. */
:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #1c1f1c;
  --muted: #5f6b5f;
  --line: #dfe3dc;
  --accent: #2e7d32;
  --accent-soft: #e5f1e5;
  --warn: #a15c00;
  --warn-soft: #fff2dd;
  --danger: #b3261e;
  --bar: #4f9a52;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121512;
    --surface: #1b1f1b;
    --text: #e6eae4;
    --muted: #9aa69a;
    --line: #2f362f;
    --accent: #7cc47f;
    --accent-soft: #223322;
    --warn: #f0b45a;
    --warn-soft: #3a2c14;
    --danger: #f2877f;
    --bar: #6db470;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 24px 0 10px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.87rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); }
nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

button, .button {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 7px 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { button.primary { color: #0f1a0f; } }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-align: left; }
button:disabled { opacity: 0.55; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; }
label > span { display: block; font-size: 0.87rem; color: var(--muted); margin-bottom: 4px; }
form.stack input, form.stack select { width: 100%; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }

.badge { display: inline-block; font-size: 0.78rem; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.grey { background: var(--line); color: var(--muted); }

.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; }
.bar { height: 12px; border-radius: 6px; background: var(--bar); min-width: 2px; }
.bar.alt { background: var(--line); }
svg.chart { display: block; }
svg.chart text { fill: var(--muted); font-size: 12px; }
svg.chart .col { fill: var(--bar); }

.match { margin-top: 4px; padding: 4px 8px; border-radius: 6px; background: var(--warn-soft); color: var(--text); }
.stars button { border: 0; background: none; padding: 0 2px; font-size: 1.4rem; color: var(--line); }
.stars button.on { color: #e3a008; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px);
}
.toast.error { background: var(--danger); color: #fff; }
.center { max-width: 380px; margin: 48px auto; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.code { font: 600 1.8rem ui-monospace, monospace; letter-spacing: 0.2em; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

@media (max-width: 600px) {
  /* позиции чека — карточками: название, категория, затем «кол-во × цена» и сумма в одну строку */
  table.items thead { display: none; }
  table.items tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.items td { border: 0; padding: 0; }
  table.items td:first-child, table.items td:nth-child(2) { grid-column: 1 / -1; }
  table.items td select { width: 100%; }
  table.items td.qty { text-align: left; color: var(--muted); }
  .topbar { gap: 8px; }
  main { padding-top: 16px; }
  .hide-sm { display: none; }
}
