:root {
  --bg: #0a0920;
  --bg-2: #12102e;
  --line: #262254;
  --violet: #6b4dff;
  --violet-soft: #2a2464;
  --cyan: #4fc3f7;
  --mint: #35d07f;
  --amber: #ffc857;
  --orange: #ff8a3d;
  --red: #ff6b6b;
  --text: #eceaff;
  --muted: #9c95cf;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background:
    radial-gradient(1100px 600px at 50% -10%, #1d1a4d 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

/* ------------------------------------------------------------------ шапка */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 9px 20px;
  background: rgba(8, 7, 26, 0.9);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.topbar-mid { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-supply { color: var(--muted); font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar { padding: 12px 20px; }

.score { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.score b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.score span { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.score-warn b { color: var(--amber); }

.chip {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}
.chip-demo { background: var(--amber); color: #1c1400; }
.chip-offline { background: var(--red); color: #2a0000; }
.chip-wb { background: var(--violet); color: #fff; }
.chip-kiz { background: rgba(255, 200, 87, 0.16); color: var(--amber); border: 1px solid rgba(255, 200, 87, 0.4); }

.ctl {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 20px;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.15;
  cursor: pointer;
  max-width: 340px;
}
.ctl:hover { border-color: var(--violet); }
.ctl:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.ctl-accent { background: var(--violet); border-color: var(--violet); font-weight: 600; }
.ctl-print {
  background: rgba(79, 195, 247, 0.14);
  border-color: rgba(79, 195, 247, 0.5);
  color: var(--cyan);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.ctl-print:hover { background: rgba(79, 195, 247, 0.24); }

/* необратимое действие — отделено цветом от обычных кнопок */
.ctl-danger { border-color: rgba(255, 107, 107, 0.45); color: var(--red); }
.ctl-danger:hover { background: rgba(255, 107, 107, 0.14); border-color: var(--red); }
.ctl[disabled] { opacity: 0.5; cursor: default; }

/* ------------------------------------------------------------------ сцена */

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto auto 1fr;
  gap: 14px 20px;
  padding: 16px 20px 20px;
  min-height: 0;
  overflow: hidden;
}

.hintline {
  grid-column: 1;
  color: var(--amber);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.hintline.kiz { color: var(--cyan); }
.hintline.ready { color: var(--mint); }

/* поле сканирования */
.scanbar {
  grid-column: 1;
  width: 100%;
  padding: 18px 26px;
  border-radius: 14px;
  border: 2px solid var(--violet);
  background: rgba(10, 8, 32, 0.75);
  color: var(--text);
  font-family: var(--mono);
  font-size: clamp(1.1rem, 0.6rem + 1.3vw, 1.7rem);
  letter-spacing: 0.12em;
  text-align: center;
  outline: none;
  box-shadow: 0 0 0 4px rgba(107, 77, 255, 0.12), 0 0 26px rgba(107, 77, 255, 0.35) inset;
  transition: border-color 140ms, box-shadow 140ms;
}
.scanbar::placeholder { color: #46407e; }
.scanbar.kiz {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(79, 195, 247, 0.12), 0 0 26px rgba(79, 195, 247, 0.3) inset;
}
.scanbar.locked {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(53, 208, 127, 0.12), 0 0 26px rgba(53, 208, 127, 0.25) inset;
}

/* ------------------------------------------------------------------ карточка */

.chooser { text-align: center; padding: 12px 0 0; }
.chooser h1 { font-size: 1.5rem; margin: 0 0 6px; }
.chooser-hint { color: var(--muted); margin: 0 0 18px; font-size: 0.92rem; }
.chooser-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.chooser-list button {
  width: 100%;
  text-align: left;
  background: linear-gradient(155deg, #2b2570 0%, #1e1a56 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chooser-list button:hover { border-color: var(--cyan); }
.chooser-list button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.ch-qty { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.ch-qty small { font-size: 0.8rem; font-weight: 400; color: var(--muted); margin-left: 6px; }
.ch-when { font-size: 0.88rem; }
.ch-id { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }

/* ------------------------------------------------------------------ сборка поставок */

.assemble { padding: 8px 0 0; }
.assemble h1 { font-size: 1.45rem; margin: 0 0 6px; }
.assemble-hint { color: var(--muted); margin: 0 0 16px; font-size: 0.92rem; }
.assemble-list { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.assemble-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
}
.as-qty { font-size: 1.9rem; font-weight: 700; line-height: 1; min-width: 3ch; text-align: right; }
.as-wh { font-size: 1.05rem; font-weight: 600; }
.as-office { display: block; font-size: 0.8rem; color: var(--muted); }
.assemble-list select { max-width: 280px; }
.assemble-actions { display: flex; gap: 10px; }
.assemble-result { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.as-row {
  border-left: 3px solid var(--mint);
  padding: 8px 12px;
  background: rgba(53, 208, 127, 0.08);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}
.as-row.bad { border-left-color: var(--red); background: rgba(255, 107, 107, 0.1); }
.as-row b { display: block; }
.as-row span { color: var(--muted); font-size: 0.82rem; }

.card, .idlebox, .alert, .chooser, .assemble {
  grid-column: 1;
  grid-row: 3;
  align-self: start;
  overflow-y: auto;
  max-height: 100%;
}

.card {
  border-radius: 18px;
  padding: 20px 22px 18px;
  background: linear-gradient(155deg, #322a86 0%, #241f66 55%, #1b1750 100%);
  border: 2px solid rgba(79, 195, 247, 0.55);
  box-shadow: 0 0 34px rgba(79, 195, 247, 0.18), 0 18px 40px rgba(0, 0, 0, 0.45);
}

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.order-no { font-size: 1.18rem; font-weight: 700; }

.card-body { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 18px; }

.thumb {
  position: relative;
  width: 128px;
  height: 128px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  padding: 8px;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  word-break: break-all;
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sizeline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.size-badge {
  background: rgba(79, 195, 247, 0.16);
  border: 1px solid rgba(79, 195, 247, 0.45);
  color: var(--cyan);
  border-radius: 8px;
  padding: 3px 12px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand { color: var(--muted); font-size: 0.85rem; }

.card-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }

.title {
  margin: 0;
  font-size: clamp(1.25rem, 0.9rem + 1.1vw, 1.85rem);
  line-height: 1.18;
  color: var(--cyan);
  font-weight: 700;
  text-wrap: balance;
}

.barcode-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.barcode-line .lbl { font-size: 0.66rem; letter-spacing: 0.12em; color: var(--muted); }
.barcode-line .val { font-family: var(--mono); font-size: 1.25rem; color: var(--cyan); letter-spacing: 0.04em; }

.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.82rem; }
.facts i { font-style: normal; color: var(--muted); }
.facts b { font-weight: 600; font-variant-numeric: tabular-nums; }

.qty {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 10px 16px;
}
.qty-num { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.qty-text { display: flex; flex-direction: column; }
.qty-text b { font-size: 0.92rem; }
.qty-text span { font-size: 0.78rem; color: var(--muted); }

.asks { font-size: 0.84rem; }
.asks-head { color: var(--text); margin-bottom: 5px; }
.asks ul { margin: 0; padding-left: 18px; }
.asks li { margin-bottom: 2px; }
.asks li em { font-style: normal; color: var(--muted); }
.asks li em.req { color: var(--amber); font-weight: 600; }
.asks-note { color: var(--muted); margin-top: 6px; font-size: 0.8rem; }

.kizbox {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.kiz-ask { font-size: 1rem; font-weight: 600; color: var(--cyan); }
.kiz-ok { font-size: 0.86rem; color: var(--mint); }
.kiz-ok code { font-family: var(--mono); font-size: 0.8rem; word-break: break-all; }
.kiz-ok::before { content: "✓ "; font-weight: 700; }
.kiz-note { font-size: 0.78rem; color: var(--amber); }
.kiz-skip { font-size: 0.78rem; color: var(--muted); }

.printbtn {
  margin-top: 16px;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 16px 20px 12px;
  background: linear-gradient(180deg, #4ee08a 0%, #2bbd6b 100%);
  color: #05230f;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 8px 26px rgba(53, 208, 127, 0.3);
}
.printbtn small { font-size: 0.62rem; letter-spacing: 0.14em; opacity: 0.65; text-transform: none; }
.printbtn:hover:not([disabled]) { filter: brightness(1.07); }
.printbtn[disabled] {
  background: rgba(255, 255, 255, 0.09);
  color: var(--muted);
  box-shadow: none;
  cursor: default;
}
.printbtn.busy { background: linear-gradient(180deg, #ffd166 0%, #f0a92c 100%); color: #2b1c00; }

/* ------------------------------------------------------------------ пустое состояние и ошибка */

.idlebox { padding: 40px 8px; text-align: center; }
.idlebox h1 { font-size: 1.6rem; margin: 0 0 10px; }
.idlebox p { color: var(--muted); max-width: 62ch; margin: 0 auto; line-height: 1.6; }

.alert {
  border-radius: 16px;
  padding: 22px 24px;
  background: rgba(255, 107, 107, 0.1);
  border: 2px solid rgba(255, 107, 107, 0.5);
}
.alert-title { font-size: 1.5rem; font-weight: 700; color: var(--red); margin-bottom: 6px; }
.alert-text { color: var(--text); font-size: 0.95rem; line-height: 1.5; }

/* ------------------------------------------------------------------ правая колонка */

.panels {
  grid-column: 2;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
}
.panel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 10px;
}
.link-tight { margin-left: 10px; }

.link {
  margin-left: auto;
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font: inherit;
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: 0;
  text-decoration: underline;
  cursor: pointer;
}

.picklist, .problems { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.picklist li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  font-size: 0.83rem;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.picklist li:last-child { border-bottom: none; }
.pl-name { line-height: 1.25; word-break: break-word; }
.pl-sku { display: block; font-family: var(--mono); font-size: 0.68rem; color: var(--muted); }
.pl-kiz { color: var(--amber); }
.pl-size { color: var(--cyan); font-weight: 700; white-space: nowrap; }
.pl-china { color: var(--mint); font-weight: 700; white-space: nowrap; }
.pl-qty { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1rem; }

.problems li {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.4;
  border-left: 2px solid var(--red);
  padding-left: 8px;
}
.empty { color: var(--muted); font-size: 0.78rem; border: none !important; padding: 0 !important; }

/* ------------------------------------------------------------------ подвал */

.foot {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 9px 20px;
  border-top: 1px solid var(--line);
  background: rgba(8, 7, 26, 0.9);
  font-size: 0.82rem;
  color: var(--muted);
}
.foot a { color: var(--muted); }
.foot .link { margin-left: 0; font-size: 0.82rem; }
kbd {
  font-family: var(--mono);
  font-size: 0.7rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

#printframe { position: fixed; width: 0; height: 0; border: 0; visibility: hidden; }

@media (max-width: 1000px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .panels { display: none; }
  .card-body { grid-template-columns: 1fr; }
  .thumb { display: none; }
}
