:root {
  --bg: #12140c;
  --bg-2: #1a1d12;
  --bg-3: #101208;
  --ink: #efece1;
  --muted: #8d8a7a;
  --line: #2d3022;
  --acid: #d6ff3d;
  --acid-ink: #14160c;
  --warn: #ff4d2e;
  --ok: #9dff7a;
  --low: #ffc857;
  --mono: "Red Hat Mono", ui-monospace, monospace;
  --sans: "Bricolage Grotesk", sans-serif;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}
body {
  min-height: 100dvh;
  background-image:
    radial-gradient(900px 420px at 8% -10%, oklch(0.42 0.09 120 / 0.18), transparent 70%),
    radial-gradient(700px 360px at 110% 0%, oklch(0.38 0.05 90 / 0.16), transparent 65%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: var(--acid); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}
code, .mono { font-family: var(--mono); font-size: 0.92em; font-variant-numeric: tabular-nums; }
.skip {
  position: absolute; left: -999px;
}
.skip:focus { left: 12px; top: 12px; z-index: 8; background: var(--acid); color: var(--acid-ink); padding: 8px 12px; }

.wrap {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  position: relative;
  z-index: 2;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-xl);
}
.brand {
  font-weight: 800;
  letter-spacing: -0.05em;
  font-size: 1.2rem;
  color: var(--ink);
  flex: 0 0 auto;
}
.brand span { color: var(--acid); }
.brand:hover { text-decoration: none; }
.nav {
  display: flex;
  align-items: center;
  gap: 6px 18px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav a {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 6px 0;
}
.nav a[aria-current="page"] { color: var(--ink); }
.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 600;
  padding: 8px 12px;
}

.flash {
  background: #24180c;
  border: 1px solid #5a3b12;
  color: #ffd79a;
  padding: 12px 14px;
  margin-bottom: 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.flash p { margin: 0; font-family: var(--mono); font-size: 0.85rem; word-break: break-word; }

h1 {
  font-size: 2rem;
  letter-spacing: -0.05em;
  line-height: 1.05;
  margin: 0 0 8px;
  text-wrap: balance;
}
h2 {
  font-size: 1.05rem;
  letter-spacing: -0.03em;
  margin: 32px 0 12px;
}
.lede { color: var(--muted); max-width: 46rem; line-height: 1.5; margin: 0; }
.kicker {
  color: var(--acid);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.shell {
  background: oklch(0.2 0.02 120 / 0.45);
  border: 1px solid var(--line);
  padding: 6px;
}
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 18px;
}
.shell > .card { border: 0; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.stats { grid-template-columns: minmax(22rem, 1.7fr) repeat(3, minmax(0, 1fr)); align-items: stretch; }
.grid.charts { grid-template-columns: 1.4fr 1fr; }

label { display: block; color: var(--muted); font-size: 0.8rem; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  background: var(--bg-3);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: 0.92rem;
}
input[type="checkbox"], input[type="radio"] {
  width: auto;
  margin: 0;
  accent-color: var(--acid);
}
textarea { min-height: 88px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: var(--acid);
  color: var(--acid-ink);
  font-family: var(--sans);
  font-weight: 700;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform 160ms var(--ease), opacity 160ms var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.sm { padding: 7px 10px; font-size: 0.82rem; font-weight: 600; }
.btn.wide { width: 100%; }

.stat b, .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat .tiny { display: block; margin-bottom: 6px; }
.stat b {
  display: block;
  font-size: 1.7rem;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.quota .num {
  display: block;
  font-size: clamp(1.35rem, 2.1vw, 1.8rem);
  letter-spacing: -0.04em;
  line-height: 1;
}
.stat.ok b, .quota .num.ok { color: var(--ok); }
.stat.dead b, .stat.empty b, .quota .num.empty { color: var(--warn); }
.stat.low b, .quota .num.low { color: var(--low); }
.tiny { color: var(--muted); font-size: 0.8rem; line-height: 1.4; }

.bar {
  height: 8px;
  background: #0c0e08;
  border: 1px solid var(--line);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--acid);
  transform-origin: left center;
}
.bar.empty > i { background: var(--warn); width: 100%; }
.bar.low > i { background: var(--low); }

.quota {
  display: grid;
  grid-template-columns: 120px minmax(12ch, 1fr);
  gap: 16px;
  align-items: center;
}
.chart-frame {
  position: relative;
  min-height: 220px;
}
.chart-frame.doughnut { min-height: 120px; width: 120px; }
.chart-frame.is-empty::after {
  content: "пока нет трат — график появится после первого ответа";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 16px;
  font-size: 0.85rem;
}
.chart-frame canvas { width: 100% !important; height: 100% !important; }

.fields { display: grid; gap: 10px; }
.field {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 10px 10px 10px 12px;
}
.field .name { color: var(--muted); font-size: 0.75rem; }
.field code { overflow: auto; white-space: nowrap; }

.steps { counter-reset: step; display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.steps li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: start;
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  font-family: var(--mono);
  font-size: 0.85rem;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--acid);
  color: var(--acid-ink);
  font-weight: 700;
}
.steps li p { margin: 6px 0 0; }

.guides {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 8px;
}
.guides a {
  display: block;
  border: 1px solid var(--line);
  padding: 12px 12px 11px;
  color: var(--ink);
  background: var(--bg-2);
}
.guides a:hover { border-color: var(--acid); text-decoration: none; }
.guides a small { display: block; color: var(--muted); font-size: 0.75rem; margin-top: 4px; }

pre {
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 12px 14px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  margin: 0;
}
.pre-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.table-wrap { overflow: auto; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 0.72rem;
  border: 1px solid var(--line);
}
.pill.ok { color: var(--ok); }
.pill.empty { color: var(--warn); }
.pill.low { color: var(--low); }
.pill.off, .pill.unknown { color: var(--muted); }

.login-hero { max-width: 520px; margin: 6vh auto 0; }
.howto { display: grid; gap: 10px; margin: 22px 0 0; }
.howto div {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  color: var(--muted);
}
.howto b { color: var(--ink); font-weight: 600; }

.fail { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.fail li {
  background: #1a1410;
  border: 1px solid #3d2a22;
  padding: 10px 12px;
  color: #f0c9bc;
  font-size: 0.9rem;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
}
.admin-tabs a {
  border: 1px solid var(--line);
  padding: 7px 12px;
  color: var(--muted);
  background: var(--bg-2);
}
.admin-tabs a[aria-current="page"], .admin-tabs a:hover {
  color: var(--acid-ink);
  background: var(--acid);
  text-decoration: none;
}

.sku-grid {
  display: grid;
  grid-template-columns: 110px 1fr 88px 110px 1fr 120px;
  gap: 8px;
  align-items: end;
}

.fp-pass {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.fp-pass-main {
  display: flex;
  gap: 16px;
  align-items: center;
  min-width: min(100%, 28rem);
}
.fp-avatar {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  background: #0c0e08;
  border: 1px solid var(--line);
  overflow: hidden;
}
.fp-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fp-name {
  margin: 4px 0 0;
  font-size: 1.35rem;
}
.fp-pass-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stall-board {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 18px 18px 16px;
  margin-bottom: 14px;
}
.stall-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px 24px;
  align-items: end;
  margin-bottom: 16px;
}
.stall-head h2 { margin: 0 0 6px; }
.stall-tally {
  margin: 0;
  text-align: right;
  min-width: 7.5rem;
}
.stall-tally b {
  display: block;
  font-family: var(--mono);
  font-size: 2.4rem;
  line-height: 0.9;
  letter-spacing: -0.06em;
  color: var(--acid);
  font-weight: 600;
}
.stall-tally span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}
.stall-tally i { font-style: normal; font-family: var(--mono); }
.stall-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.stall-tool {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 11px;
  cursor: pointer;
}
.stall-tool:hover { color: var(--ink); }
.stall-tool.is-on {
  background: var(--acid);
  border-color: var(--acid);
  color: var(--acid-ink);
}
.stall-tool-clear { margin-left: auto; }
.stall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.shelf {
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 12px 12px 11px;
  display: grid;
  gap: 10px;
  min-height: 100%;
}
.shelf.is-on { border-color: oklch(0.78 0.16 120 / 0.42); }
.stall-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  cursor: pointer;
  color: var(--ink);
}
.stall-cat-name {
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 0.98rem;
}
.stall-cat-n {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.shelf.is-on .stall-cat-n { color: var(--acid); }
.stall-chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 7px 8px;
  min-height: 32px;
  text-align: center;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
}
.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0.001;
  cursor: pointer;
  appearance: none;
  border: 0;
  background: transparent;
}
.chip:hover { color: var(--ink); }
.chip:has(input:checked) {
  background: var(--acid);
  border-color: var(--acid);
  color: var(--acid-ink);
}
.chip:has(input:focus-visible),
.stall-tool:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}
textarea.tall { min-height: 120px; }
.lot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.lot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.lot-chips .pill { text-decoration: none; }
.sku-one { margin-top: 10px; }

.foot { color: var(--muted); font-size: 0.8rem; padding: 48px 0 28px; max-width: 62ch; line-height: 1.45; }

@media (max-width: 960px) {
  .grid.stats, .grid.charts, .quota { grid-template-columns: 1fr; }
  .chart-frame.doughnut { width: 120px; }
}

@media (max-width: 800px) {
  .grid.two, .grid.three, .stall-head { grid-template-columns: 1fr; }
  .stall-tally { text-align: left; }
  .stall-tool-clear { margin-left: 0; }
  .sku-grid { grid-template-columns: 1fr 1fr; }
  .field { grid-template-columns: 1fr auto; }
  .field .name { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .wrap { width: min(var(--max), calc(100% - 24px)); }
  h1 { font-size: 1.65rem; }
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none;
    position: absolute;
    top: 62px;
    right: 0;
    left: 0;
    background: var(--bg-2);
    border: 1px solid var(--line);
    padding: 10px;
    flex-direction: column;
    align-items: stretch;
    z-index: 4;
  }
  .nav.open { display: flex; }
  .nav a { padding: 10px 8px; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  td {
    border: 0;
    padding: 4px 0;
    display: grid;
    grid-template-columns: 38% 1fr;
    gap: 8px;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
