/* Приёмка — operations console. No external resources (CSP self-only).
   Type: a Swiss grotesk for text, monospace for every id, phone, code and
   number column; tabular numerals everywhere. Hairline grid, square corners,
   one accent (signal orange) plus semantic stage colours. Light + dark. */

:root {
  --sans: "Helvetica Neue", Helvetica, "Arial Nova", Arial, "Liberation Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f2f1ec;
  --panel: #fbfaf6;
  --sunk: #ebe9e2;
  --line: #d9d6cc;
  --line-strong: #b9b5aa;
  --ink: #1a1916;
  --ink-2: #3b3934;
  --muted: #6a665c;
  --faint: #8f8a7e;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fbe6da;
  --focus: #c2410c;

  --q-fg: #4f4b43;   --q-bg: #e6e3da;   /* очередь */
  --c-fg: #1d55b3;   --c-bg: #e2eaf7;   /* проверяется */
  --l-fg: #146c37;   --l-bg: #dcefe2;   /* зачёт · в работе */
  --b-fg: #fbfaf6;   --b-bg: #2a2925;   /* блок */
  --r-fg: #b0261a;   --r-bg: #f7e1dc;   /* отказ */
  --k-fg: #6b3fa0;   --k-bg: #ece4f6;   /* у клиента */

  --ok: #146c37;
  --ok-ink: #ffffff;
  --err: #b0261a;
  --row-hover: #f4f2ec;
  --row-open: #fbefe6;
  --new: #fff4c2;
  --shadow: 0 10px 30px rgba(26, 25, 22, 0.16);
  --overlay: rgba(20, 19, 17, 0.72);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --panel: #191917;
    --sunk: #20201d;
    --line: #2d2c28;
    --line-strong: #44423c;
    --ink: #ecebe5;
    --ink-2: #cfcdc4;
    --muted: #9c988c;
    --faint: #7a766b;
    --accent: #f07a3c;
    --accent-ink: #160d07;
    --accent-soft: #3a2014;
    --focus: #f07a3c;

    --q-fg: #cbc7bb;   --q-bg: #2a2924;
    --c-fg: #8fb6ff;   --c-bg: #182339;
    --l-fg: #63d08f;   --l-bg: #12291b;
    --b-fg: #141412;   --b-bg: #d8d5cb;
    --r-fg: #ff8b7b;   --r-bg: #36170f;
    --k-fg: #c6a6ff;   --k-bg: #261b38;

    --ok: #2f9a5a;
    --ok-ink: #06140b;
    --err: #ff8b7b;
    --row-hover: #1d1d1a;
    --row-open: #2a1d15;
    --new: #3a3313;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --overlay: rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.45 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 20px; line-height: 1.2; }
h2 { font-size: 14px; }
.mono, code { font-family: var(--mono); font-size: 12px; }
code { word-break: break-all; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-family: var(--mono); font-size: 12px; }
.pos { color: var(--ok); }
.neg { color: var(--err); }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.label {
  font: 600 10.5px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
[hidden] { display: none !important; }
.offscreen { position: fixed; top: -1000px; left: 0; }
html.is-loading, html.is-loading * { cursor: progress; }
html.is-loading main { opacity: 0.75; transition: opacity 0.15s 0.12s; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: stretch; gap: 20px;
  height: 44px; padding: 0 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  font: 700 12px/1 var(--mono); letter-spacing: 0.16em; text-transform: uppercase;
}
.brand-mark { width: 10px; height: 10px; background: var(--accent); }
.nav { display: flex; align-items: stretch; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: flex; align-items: center; gap: 6px; padding: 0 10px;
  color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--ink); }
.nav a.is-on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.badge {
  font: 600 11px/16px var(--mono); padding: 0 5px; min-width: 18px; text-align: center;
  background: var(--sunk); color: var(--ink-2);
}
.badge.is-hot { background: var(--accent); color: var(--accent-ink); }
.nav .counters { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; }
.nav .counters .badge { font-weight: 600; }
.nav .counters .dot { color: var(--faint); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.sync { display: inline-flex; align-items: center; gap: 6px; font: 11px/1 var(--mono); color: var(--faint); }
.sync::before { content: ""; width: 7px; height: 7px; background: var(--faint); border-radius: 50%; }
.sync.is-live::before { background: var(--ok); }
.sync.is-off { color: var(--err); }
.sync.is-off::before { background: var(--err); }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; white-space: nowrap; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-body {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 200px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  display: grid; gap: 10px;
}

/* ---------- page ---------- */
main { padding: 18px 20px 48px; max-width: 1240px; margin: 0 auto; }
main.wide { max-width: none; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.pagehead .sub { color: var(--muted); margin-top: 4px; }
.backlink { display: inline-block; margin-bottom: 6px; color: var(--muted); text-decoration: none; font-size: 12px; }
.backlink:hover { color: var(--ink); }
.section { border-top: 1px solid var(--line); padding: 16px 0; }
.section > .label, .section h2.label { display: block; margin: 20px 0 10px; }
.section > .label:first-child, .section h2.label:first-child { margin-top: 0; }
.section-gap { margin-top: 20px; }
.cols > .section { min-width: 0; }
.note { margin: 0 0 14px; max-width: 900px; }
.panel { background: var(--panel); border: 1px solid var(--line); }
.panel-pad { padding: 14px 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
.stack-sm { display: grid; gap: 4px; align-content: start; }
.grow { flex: 1 1 180px; }
.empty { padding: 32px 16px; color: var(--muted); text-align: center; }

/* ---------- flash / toast ---------- */
.flash { padding: 9px 12px; margin-bottom: 14px; border-left: 3px solid var(--ink); background: var(--panel); }
.flash-ok { border-left-color: var(--ok); }
.flash-err { border-left-color: var(--err); color: var(--err); }
.flash-info { border-left-color: var(--line-strong); }
/* bottom-left: away from the stage / work-timer columns and the row actions */
.toast {
  position: fixed; left: 20px; bottom: 20px; z-index: 60;
  max-width: min(560px, calc(100vw - 32px)); padding: 10px 14px;
  background: var(--ink); color: var(--panel); box-shadow: var(--shadow);
  display: flex; gap: 12px; align-items: center;
}
.toast.is-err { background: var(--err); color: #fff; }
.toast a { color: inherit; font-weight: 600; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 0;
  background: var(--panel); color: var(--ink); font: 600 12.5px/1 var(--sans);
  text-decoration: none; cursor: pointer; white-space: nowrap; user-select: none;
}
.btn:hover { border-color: var(--ink); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.btn-primary:hover { background: var(--ink-2); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: var(--ok-ink); }
.btn-ok:hover { filter: brightness(1.08); border-color: var(--ok); }
.btn-danger { color: var(--err); border-color: currentColor; }
.btn-danger:hover { background: var(--r-bg); border-color: var(--err); }
/* «Блок»: a distinct danger-outline action (never looks like «Взять») */
.btn-block { background: transparent; border: 1px dashed var(--err); color: var(--err); }
.btn-block::before { content: ""; width: 9px; height: 2px; background: currentColor; }
.btn-block:hover { background: var(--r-bg); border-style: solid; border-color: var(--err); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line-strong); }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn.is-busy { opacity: 0.6; pointer-events: none; }
/* a small button next to a 30px input/select sits on the same line height */
.row input ~ .btn-sm, .row select ~ .btn-sm, .row label ~ .btn-sm,
.op-edit .btn-sm, .d-fix .row .btn-sm, .filters .btn-sm { height: 30px; }
input, select, textarea {
  font: 13px/1.3 var(--sans); color: var(--ink); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: 0; height: 30px; padding: 0 8px; min-width: 0;
}
textarea { height: auto; padding: 6px 8px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: inset 0 0 0 1px var(--focus); }
input[type="checkbox"], input[type="radio"] { height: auto; accent-color: var(--ink); }
label.field { display: grid; gap: 4px; }
label.field > span { font: 600 10.5px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.narrow { width: 90px; }

/* ---------- chips (stage / status) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px;
  font: 600 11px/1 var(--sans); white-space: nowrap; letter-spacing: 0.01em;
}
.chip::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.st-queue { color: var(--q-fg); background: var(--q-bg); }
.st-checking { color: var(--c-fg); background: var(--c-bg); }
.st-live { color: var(--l-fg); background: var(--l-bg); }
.st-blocked { color: var(--b-fg); background: var(--b-bg); }
.st-rejected { color: var(--r-fg); background: var(--r-bg); }
.st-client { color: var(--k-fg); background: var(--k-bg); }
.chip.st-checking::before, .chip.st-live::before { border-radius: 50%; }
.chip.st-client::before { transform: rotate(45deg); }
.chip-del { color: var(--panel); background: var(--faint); margin-right: 4px; }
.chip-del::before { display: none; }
.chip-prio { color: var(--accent-ink); background: var(--accent); }
.chip-prio::before { display: none; }
.chip.st-blocked::before { width: 8px; height: 2px; }
.chip-plain { color: var(--muted); background: var(--sunk); }
.chip-plain::before { display: none; }
.kind { color: var(--muted); font-size: 11.5px; margin-left: 4px; }
.flag {
  display: inline-block; font: 600 10.5px/16px var(--mono); padding: 0 5px; margin: 0 4px 2px 0;
  border: 1px solid currentColor; color: var(--r-fg); white-space: nowrap;
}
.flag-muted { color: var(--faint); }

/* ---------- tables ---------- */
.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
.grid th {
  position: sticky; top: 44px; z-index: 2; background: var(--panel); text-align: left;
  font: 600 10.5px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  padding: 9px 10px 8px; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: var(--row-hover); }
.grid .num, .grid th.num { text-align: right; }
.grid.compact td { padding: 5px 10px; }
.grid tr.empty td { padding: 30px 12px; text-align: center; color: var(--muted); }
.grid tr.total td { font-weight: 700; border-top: 1px solid var(--line-strong); background: var(--sunk); }
.grid th:first-child, .grid td:first-child { padding-left: 12px; }
.grid th:last-child, .grid td:last-child { padding-right: 12px; }
.table-wrap { position: relative; }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; align-items: start; }
.stagebar { display: flex; align-items: flex-end; gap: 10px; border-bottom: 1px solid var(--line-strong); }
.stages {
  display: flex; align-items: flex-end; gap: 0; flex: 1 1 auto; min-width: 0;
  margin-bottom: -1px; overflow-x: auto; scrollbar-width: none;
}
/* more tabs hidden behind an edge: that edge fades out */
.stages.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
.stages.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); }
.stages.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); }
.stages::-webkit-scrollbar { display: none; }
.stage-tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px 9px;
  color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.stage-tab:hover { color: var(--ink); }
.stage-tab.is-on { color: var(--ink); border-bottom-color: var(--accent); }
.stage-tab .n { font: 600 11px/16px var(--mono); padding: 0 5px; background: var(--sunk); color: var(--ink-2); }
.stage-tab.is-on .n { background: var(--ink); color: var(--panel); }
.stagebar .next { flex: none; margin: 0 0 6px auto; }
.substages { display: flex; gap: 6px; padding: 10px 0; flex-wrap: wrap; }
.sub-tab {
  display: inline-flex; gap: 6px; align-items: center; height: 26px; padding: 0 10px;
  border: 1px solid var(--line-strong); text-decoration: none; color: var(--muted); font-weight: 600; font-size: 12px;
}
.sub-tab b { font: 600 11px var(--mono); color: var(--ink-2); }
.sub-tab.is-on { border-color: var(--ink); color: var(--ink); background: var(--panel); }
.sub-tab.is-mine b { background: var(--c-bg); color: var(--c-fg); padding: 0 4px; }

.fbox > summary {
  display: none; list-style: none; cursor: pointer; padding: 10px 0 0; font-weight: 600; color: var(--muted);
}
.fbox > summary::-webkit-details-marker { display: none; }
.fbox > summary b { font: 600 11px/16px var(--mono); padding: 0 5px; background: var(--ink); color: var(--panel); }
@media (max-width: 760px) { .fbox > summary { display: block; } }
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 0;
}
.filters input[name="user"] { width: 150px; }
.filters input[name="phone"] { width: 130px; font-family: var(--mono); font-size: 12px; }
.filters input[name="id"] { width: 74px; font-family: var(--mono); font-size: 12px; }
.filters input[type="date"] { width: 132px; font-family: var(--mono); font-size: 12px; }
.filters .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.seg { display: inline-flex; }
.seg > * { margin-left: -1px; }
.seg-btn {
  display: inline-flex; align-items: center; height: 30px; padding: 0 10px; border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--muted); text-decoration: none; font: 600 12px/1 var(--sans); cursor: pointer;
}
.seg-btn.is-on { background: var(--ink); color: var(--panel); border-color: var(--ink); position: relative; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-on:hover { color: var(--panel); }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-bottom: 10px; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px;
  background: var(--sunk); text-decoration: none; font-size: 12px;
}
.fchip .x { color: var(--muted); }
.fchip:hover .x { color: var(--err); }
.fchip-reset { font-size: 12px; color: var(--muted); }

.board-table td { height: 40px; }
.board-table .c-id { width: 1%; }
.board-table .c-id a { font: 600 12.5px var(--mono); text-decoration: none; }
.board-table .c-id a:hover { color: var(--accent); }
.c-time { white-space: nowrap; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.c-phone { white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.c-user { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-work { white-space: nowrap; }
.c-work .who { color: var(--muted); }
.timer { font: 600 12px var(--mono); }
.c-act { width: 1%; white-space: nowrap; text-align: right; }
.c-act .acts, .c-act .row { display: inline-flex; gap: 4px; align-items: center; flex-wrap: nowrap; }
.board-table tr.is-mine td:first-child { box-shadow: inset 3px 0 0 var(--c-fg); }
.board-table tr.is-pin-last td { border-bottom: 2px solid var(--line-strong); }
.c-stage .flag { margin: 2px 0 0 4px; }
.c-act .note { color: var(--muted); }
.board-table tr.is-open td { background: var(--row-open); }
.board-table tr.is-open td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.board-table tr.is-new td { animation: flash-new 3.5s ease-out; }
@keyframes flash-new { from { background: var(--new); } to { background: transparent; } }
.unit { color: var(--faint); font-size: 10.5px; }
.pager { display: flex; gap: 6px; padding: 12px 0; flex-wrap: wrap; }
.pager:empty { display: none; }
.live { overflow-anchor: none; }

/* dropdown menu (details) */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 150px;
  display: grid; background: var(--panel); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
}
.menu-body button {
  border: 0; background: none; text-align: left; padding: 8px 12px; font: 600 12.5px var(--sans);
  color: var(--r-fg); cursor: pointer; border-bottom: 1px solid var(--line);
}
.menu-body button:last-child { border-bottom: 0; }
.menu-body button:hover { background: var(--r-bg); }

/* side pane (desktop) */
.pane:empty { display: none; }
@media (min-width: 1180px) {
  .board.has-pane { grid-template-columns: minmax(0, 1fr) minmax(460px, 36%); gap: 20px; }
  .board.has-pane .c-user, .board.has-pane .c-flags, .board.has-pane .c-time { display: none; }
  .pane {
    position: sticky; top: 56px; max-height: calc(100vh - 68px); overflow: auto;
    background: var(--panel); border: 1px solid var(--line); overscroll-behavior: contain;
  }
}
@media (max-width: 1179px) {
  .pane { display: none; }
}

/* ---------- detail ---------- */
.detail { display: grid; gap: 0; }
.d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding-bottom: 12px; }
.d-title h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.d-title h1 .mono { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.d-meta { color: var(--muted); margin-top: 4px; }
.d-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.d-action {
  display: grid; gap: 10px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
}
.d-action.st-queue { border-left-color: var(--q-fg); }
.d-action.st-checking { border-left-color: var(--c-fg); }
.d-action.st-live { border-left-color: var(--l-fg); }
.d-action.st-blocked { border-left-color: var(--b-bg); }
.d-action.st-rejected { border-left-color: var(--r-fg); }
.d-action, .d-action.st-queue, .d-action.st-checking, .d-action.st-live, .d-action.st-blocked, .d-action.st-rejected { color: var(--ink); background: var(--panel); }
.d-state { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.d-state .big { font: 700 18px/1.2 var(--mono); }
.verdicts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.verdicts .v-main { grid-column: 1 / -1; height: 40px; font-size: 14px; }
.d-body { display: grid; grid-template-columns: minmax(260px, 400px) minmax(0, 1fr); gap: 20px; padding: 16px 0; }
.d-qr { margin: 0; display: grid; gap: 8px; align-content: start; }
.qr-frame {
  display: block; width: 100%; padding: 10px; background: #fff; border: 1px solid var(--line);
  cursor: zoom-in; aspect-ratio: 1 / 1; overflow: hidden;
}
.qr-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.qr-note { padding: 8px 10px; background: var(--accent-soft); color: var(--ink); font-size: 12px; }
.qr-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.codes { display: grid; border: 1px solid var(--line); background: var(--panel); }
.cf { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.cf:last-child { border-bottom: 0; }
.cf-k { font: 600 10.5px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.cf-v { font: 13px/1.35 var(--mono); word-break: break-all; user-select: all; }
.cf-v.is-long { font-size: 11.5px; }
.cf-btn {
  border: 1px solid var(--line-strong); background: none; color: var(--muted); height: 24px; padding: 0 8px;
  font: 600 11px var(--sans); cursor: pointer;
}
.cf-btn:hover { color: var(--ink); border-color: var(--ink); }
.cf-btn.is-copied { color: var(--ok); border-color: var(--ok); }
.kv { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 7px 10px; margin: 14px 0 0; }
.kv dt { font: 600 10.5px/1.7 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.history li:last-child { border-bottom: 0; }
.history time { font: 12px var(--mono); color: var(--muted); }
.history .pending div { color: var(--muted); }
.intercept > summary { list-style: none; width: max-content; }
.intercept > summary::-webkit-details-marker { display: none; }
.intercept[open] > summary { border-color: var(--ink); }
.intercept p { margin: 8px 0; }
.d-fix { border-top: 1px solid var(--line); padding: 12px 0; }
.d-fix summary { cursor: pointer; font-weight: 600; }
.d-fix .row { margin-top: 10px; }

.detail.is-pane { padding: 14px 16px; }
.detail.is-pane .d-body { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.detail.is-pane .qr-frame { max-width: 360px; }
.detail.is-pane .verdicts { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* lightbox (native <dialog>: Esc closes it without any script) */
.lightbox { padding: 0; border: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; background: transparent; }
.lightbox::backdrop { background: var(--overlay); }
.lb-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.lb-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.lb-stage { position: fixed; inset: 46px 0 0 0; overflow: auto; display: grid; place-items: center; }
.lb-canvas { position: relative; }
.lb-img { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #fff; cursor: zoom-in; max-width: none; }
.lightbox.is-zoomed .lb-img { cursor: zoom-out; }

/* ---------- other pages ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); border: 1px solid var(--line); background: var(--panel); margin-bottom: 16px; }
.stat { padding: 12px 14px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .big { font: 700 22px/1.2 var(--mono); margin-top: 4px; }
.stat .small { color: var(--muted); }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line-strong); margin-bottom: 14px; align-items: flex-end; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 9px 12px 8px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:first-child { padding-left: 0; }
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .muted { margin-left: auto; padding: 0 0 9px 12px; white-space: nowrap; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; }
.period { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; }
.period .seg { flex-wrap: wrap; }
.period input[type="date"] { font-family: var(--mono); font-size: 12px; }
.mix { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 16px; }
.mix div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.mix b { font-family: var(--mono); }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.ops { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.op { background: var(--panel); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 16px; display: grid; gap: 12px; align-content: start; }
.op-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.op-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.op-stats b { display: block; font: 700 16px var(--mono); }
.op-stats > div { min-width: 0; }
.op-stats .small { display: block; }
.op-edit { display: grid; gap: 8px; border-top: 1px dashed var(--line); padding-top: 12px; }
.op-edit form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.op-field { display: inline-grid; grid-template-columns: 84px 76px 30px; align-items: center; gap: 6px; }
.op-field > span:first-child { color: var(--ink-2); }
.op-field .narrow { width: 76px; }
.meter { width: 100%; height: 4px; background: var(--sunk); }
.meter > i { display: block; height: 100%; background: var(--ink); }
progress.bar { width: 100%; height: 4px; appearance: none; border: 0; background: var(--sunk); }
progress.bar::-webkit-progress-bar { background: var(--sunk); }
progress.bar::-webkit-progress-value { background: var(--ink); }
progress.bar::-moz-progress-bar { background: var(--ink); }
.wd { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 20px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-top: 0; }
.wd:first-of-type { border-top: 1px solid var(--line); }
.wd-amount { font: 700 20px var(--mono); text-align: right; }
.wd-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.wd-actions input { width: 260px; }
.addr { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.searchbar { display: flex; gap: 6px; margin-bottom: 14px; }
.searchbar input { flex: 1; max-width: 420px; }
.sblock { display: grid; gap: 8px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); }
.sblock p { margin: 0; }
.sblock-state.is-on { color: var(--err); }
.sblock input[name="reason"], .sblock input[name="duration"] { flex: 1 1 200px; }
.sblock .seg { flex-wrap: wrap; }
.sblock .seg-btn { height: 30px; }
.access-on { color: var(--ok); font-weight: 600; }
.access-off { color: var(--faint); }
.kvpair { display: inline-block; margin-right: 10px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* ---------- login ---------- */
body.auth { display: grid; min-height: 100vh; place-items: center; }
.auth-wrap { width: 100%; max-width: 380px; padding: 20px; }
.auth-card { display: grid; gap: 14px; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); }
.auth-card input { height: 38px; font-size: 14px; }
.code-input { font-family: var(--mono); letter-spacing: 0.3em; font-size: 18px !important; }
.btn-wide { width: 100%; height: 40px; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .top { gap: 10px; padding: 0 12px; }
  .brand span:last-child { display: none; }
  .sync { display: none; }
  .usermenu summary .muted { display: none; }
  main { padding: 12px 12px 40px; }
  .filters input[name="user"], .filters input[name="phone"] { width: calc(50% - 4px); }
  .filters input[type="date"] { width: calc(50% - 4px); }
  .filters .sep { display: none; }
  /* «Следующая в очереди»: a floating button within thumb reach */
  .stagebar .next {
    position: fixed; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 40;
    height: 44px; padding: 0 16px; font-size: 14px; margin: 0; box-shadow: var(--shadow);
  }
  main.wide { padding-bottom: 84px; }
  .toast { left: 12px; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); max-width: none; }
  .grid th { position: static; }
  .table-wrap { overflow-x: auto; }
  .fbox:not([open]) > .filters { display: none; }
  .board-table thead { display: none; }
  .board-table, .board-table tbody { display: block; border: 0; background: none; }
  .board-table tr {
    display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 4px 10px; padding: 10px 12px;
    background: var(--panel); border: 1px solid var(--line); border-top: 0;
    grid-template-areas: "id op sum" "stage stage act" "work work act" "phone user user";
  }
  .board-table tr:first-child { border-top: 1px solid var(--line); }
  .board-table td { display: block; padding: 0; border: 0; height: auto; background: none !important; }
  .board-table .c-id { grid-area: id; }
  .board-table .c-op { grid-area: op; font-weight: 600; }
  .board-table .c-sum { grid-area: sum; }
  .board-table .c-stage { grid-area: stage; }
  .board-table .c-work { grid-area: work; }
  .board-table .c-act { grid-area: act; align-self: center; }
  .board-table .c-phone { grid-area: phone; color: var(--muted); }
  .board-table .c-user { grid-area: user; max-width: none; text-align: right; color: var(--muted); }
  .board-table .c-time, .board-table .c-flags { display: none; }
  .board-table tr.empty { display: block; }
  .board-table tr.empty td { display: block; }
  .c-act .acts { flex-direction: column; align-items: stretch; }
  .d-body { grid-template-columns: minmax(0, 1fr); }
  .d-data { order: -1; }
  .qr-frame { max-width: 320px; }
  .verdicts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .cf { grid-template-columns: minmax(0, 1fr) auto; }
  .cf-k { grid-column: 1 / -1; }
  .kv { grid-template-columns: 96px minmax(0, 1fr); }
  .history li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .hide-sm { display: none; }
  .wd { grid-template-columns: minmax(0, 1fr); }
  .wd-amount { text-align: left; }
  .wd-actions form.row { flex: 1 1 100%; flex-wrap: nowrap; }
  .wd-actions input { width: auto; flex: 1 1 auto; min-width: 0; }
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .stat:nth-child(odd):not(:last-child) { border-right: 1px solid var(--line); }
  .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat .big { font-size: 18px; }
  .pagehead { align-items: flex-start; }
  .stock { grid-template-columns: minmax(0, 1fr); }
  .stock-op { padding: 12px; }
  .stock-nums { gap: 14px; }
  .toolbar-form select, .issue select { flex: 1 1 100%; max-width: none; min-width: 0; }
  .c-fill { width: auto; }
  .fill progress.bar { display: none; }
  .op-edit form { flex-wrap: nowrap; }
  .op-field { flex: 1 1 auto; grid-template-columns: 84px minmax(0, 1fr) 30px; }
  .op-field .narrow { width: 100%; }
  .searchbar input { max-width: none; }
  .grid td, .grid th { padding-left: 8px; padding-right: 8px; }
  .grid th:first-child, .grid td:first-child { padding-left: 10px; }
  .grid th:last-child, .grid td:last-child { padding-right: 10px; }
  .menu-form { min-width: 220px; }
  .board-table td:first-child, .board-table td:last-child { padding: 0; }
}

/* ---------- «Склад» ---------- */
.toolbar-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 16px; }
.toolbar-form select { max-width: 300px; }
.stock { display: grid; grid-template-columns: repeat(auto-fill, minmax(560px, 1fr)); gap: 16px; align-items: start; }
.stock-op { display: grid; gap: 12px; padding: 14px 16px 16px; background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.stock-op p { margin: 0; }
.stock-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.stock-head h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.stock-nums { display: flex; gap: 18px; flex-wrap: wrap; }
.stock-nums b { display: block; font: 700 16px/1.3 var(--mono); }
.stock-op .grid { border-color: var(--line); }
.stock-op .grid th { position: static; }
.stock-op .table-wrap { overflow-x: auto; }
.c-fill { width: 150px; }
.fill { display: flex; align-items: center; gap: 8px; }
.fill progress.bar { flex: 1 1 auto; min-width: 60px; }
tr.is-prio td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.menu-form { padding: 10px; min-width: 260px; }
.menu-form select { flex: 1 1 auto; }
.issue select { min-width: 220px; }
.d-action.st-client { border-left-color: var(--k-fg); }
.d-action.st-deleted { border-left-color: var(--faint); }
