/* Монитор партии: картонная шапка как у сканера, плотная таблица, код крупно по последним 4 цифрам */
:root {
  --kraft: #a97f52;
  --kraft-deep: #8a6540;
  --page: #eceef1;
  --paper: #ffffff;
  --ink: #000000;
  --ink-soft: #5d636b;
  --line: #dfe2e6;
  --st-new: #6b7280;
  --st-sent: #1d5fd1;
  --st-accepted: #128a46;
  --st-error: #c81e3a;
  --fresh: #ecfccb;
  --kind-intake: #0f766e;
  --kind-outbound: #7c3aed;
  font-family: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--st-sent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Шапка */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 10px 20px;
  background: var(--kraft);
  color: #fff;
}
.brand { margin: 0; font-size: 20px; font-weight: 700; }
.batch-pick select {
  min-width: 230px;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
}
.follow { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.follow input { width: 16px; height: 16px; accent-color: #000; }
.live { font-size: 14px; }
.live::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: #f87171; }
.live[data-on="true"]::before { background: #4ade80; }
.top-gap { flex: 1 1 auto; }

.btn {
  padding: 7px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 7px;
  background: var(--paper);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f3f4f6; }
.btn-light { border-color: #fff; background: transparent; color: #fff; }
.btn-light:hover { background: rgba(255, 255, 255, .15); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #222; }
.btn-danger { border-color: var(--st-error); color: var(--st-error); }

/* Инструменты */
.main { padding: 14px 20px 40px; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; }
.tools-second { margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  cursor: pointer;
}
.chip b { font-size: 17px; }
.chip[aria-checked="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.chip[data-s="error"] b { color: var(--st-error); }
.chip[data-s="accepted"] b { color: var(--st-accepted); }
.chip[data-s="sent"] b { color: var(--st-sent); }
.chip[aria-checked="true"] b { color: #fff; }
.search input {
  width: 220px;
  padding: 7px 12px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
}
.stats { margin: 0; color: var(--ink-soft); font-size: 14px; }

/* Таблица */
.table-wrap { overflow-x: auto; border-radius: 10px; background: var(--paper); box-shadow: 0 0 0 1px var(--line); }
.codes { width: 100%; border-collapse: collapse; }
.codes th {
  position: sticky;
  top: 0;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.codes td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.codes tr:last-child td { border-bottom: 0; }
.codes tr.fresh td { animation: fresh 2.2s ease-out; }
@keyframes fresh { from { background: var(--fresh); } to { background: transparent; } }
.c-n { width: 3.5em; color: var(--ink-soft); }
.code { display: inline-flex; align-items: baseline; gap: 6px; }
.code-head { font-size: 14px; font-weight: 500; }
.code-tail { font-size: 21px; font-weight: 700; line-height: 1; }
.lag { color: var(--ink-soft); }
.lag.slow { color: var(--st-error); font-weight: 500; }
.st { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 500; color: #fff; }
.st-new { background: var(--st-new); }
.st-sent { background: var(--st-sent); }
.st-accepted { background: var(--st-accepted); }
.st-error { background: var(--st-error); }
.c-msg { max-width: 360px; }
td.c-msg { white-space: normal; color: var(--ink-soft); font-size: 14px; }
tr[data-s="error"] td.c-msg { color: var(--st-error); }
.c-act { width: 1%; text-align: right; }
.row-del {
  padding: 3px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}
.row-del:hover { background: #fee2e2; color: var(--st-error); }
.empty { margin: 0; padding: 40px 20px; color: var(--ink-soft); text-align: center; font-size: 16px; }

.c-src { color: var(--ink-soft); font-size: 13px; }
.c-src[data-src="handheld"] { color: var(--ink); }
.c-src .more { display: block; color: var(--ink-soft); font-size: 12px; }
.lag.wait { color: var(--st-sent); font-weight: 500; }
tr[data-pending="1"] .code-tail { color: var(--st-sent); }
.codes tr.again td { animation: again 1.4s ease-out; }
@keyframes again { 0%, 30% { background: #fde68a; } to { background: transparent; } }

/* Тип партии */
.kind { padding: 3px 10px; border-radius: 999px; background: #fff; font-size: 13px; font-weight: 700; color: var(--kind-intake); }
.kind[data-kind="outbound"] { color: var(--kind-outbound); }
.kind-pick { display: grid; gap: 10px; }
.kind-btn {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}
.kind-btn b { font-size: 19px; color: var(--kind-intake); }
.kind-btn[data-kind="outbound"] b { color: var(--kind-outbound); }
.kind-btn span { color: var(--ink-soft); font-size: 14px; }
.kind-btn:hover { border-color: var(--ink); }

/* Ручной сканер */
.btn[aria-pressed="true"] { background: var(--st-accepted); border-color: var(--st-accepted); color: #fff; }
.hand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-bottom: 14px;
  padding: 12px 16px;
  border: 2px solid var(--st-accepted);
  border-radius: 10px;
  background: #f0fdf4;
}
.hand[hidden] { display: none; }
.hand-info { flex: 1 1 340px; min-width: 0; }
.hand-info p { margin: 0; }
.hand-title { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; }
.hand-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--st-accepted); animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.hand-batch { margin-top: 3px !important; }
.hand-net { margin-top: 3px !important; color: var(--ink-soft); font-size: 14px; }
.hand-net[data-state="queue"] { color: var(--st-sent); }
.hand-net[data-state="error"] { color: var(--st-error); font-weight: 500; }
.hand-last {
  display: grid;
  min-width: 230px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 0 0 1px var(--line);
}
.hand-last-code { font-size: 24px; font-weight: 700; letter-spacing: .02em; }
.hand-last-text { color: var(--ink-soft); font-size: 14px; }
.hand-last[data-kind="ok"] .hand-last-code { color: var(--st-accepted); }
.hand-last[data-kind="dup"] .hand-last-code { color: #b45309; }
.hand-last[data-kind="bad"] .hand-last-code { color: var(--st-error); }
.hand-last[data-kind="bad"] { box-shadow: 0 0 0 2px var(--st-error); }
.hand-last.pulse { animation: pulse .5s ease-out; }
@keyframes pulse { from { transform: scale(1.04); } to { transform: none; } }

/* Подвал */
.foot { display: flex; flex-wrap: wrap; gap: 6px 28px; justify-content: center; padding: 6px 20px 28px; color: var(--ink-soft); font-size: 14px; }
.foot a, .foot-link { color: var(--ink); font-weight: 500; }
.foot .lan { flex: 1 1 100%; text-align: center; color: var(--ink); }
.add-photos { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.add-photos .hint { margin: 0; }
.modal-panel textarea { width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 7px; font-size: 16px; font-variant-numeric: tabular-nums; resize: vertical; }
.foot-link { padding: 0; border: 0; background: none; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Окна */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, .45); }
.modal[hidden] { display: none; }
/* окно выше экрана (форма на телефоне, низкий ноутбук): прокрутка, по центру, когда помещается */
.modal { display: flex; overflow-y: auto; overscroll-behavior: contain; }
.modal-panel { width: 100%; max-width: 460px; margin: auto; padding: 20px 22px; border-radius: 12px; background: var(--paper); }
.modal-panel h2 { margin: 0 0 12px; font-size: 20px; }
.modal-panel p { line-height: 1.45; }
.modal-panel input[type="password"], .modal-panel input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.qr { width: 260px; margin: 0 auto 8px; }
.qr svg { display: block; width: 100%; height: auto; }
.qr-small { width: 170px; }
.qr-url { margin: 0 0 6px; text-align: center; }
.modal-wide { max-width: 560px; max-height: calc(100dvh - 40px); overflow-y: auto; }
.ca { margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.ca-title { margin: 0 0 8px; }
.steps { margin: 10px 0; padding-left: 20px; line-height: 1.5; }
.steps li + li { margin-top: 6px; }
.hint { color: var(--ink-soft); font-size: 14px; }
.error { color: var(--st-error); }
.copy-row { display: flex; gap: 8px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}
.toast[hidden] { display: none; }

/* Вход, приглашение, сотрудники, настройка */
.user-btn { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth { display: grid; gap: 4px; }
.auth > p { margin: 0 0 8px; }
.auth .field { margin-top: 8px; font-size: 14px; font-weight: 500; }
.auth .hint { margin: 10px 0 0; }
.auth input[type="text"], .auth input[type="password"], .staff-add input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  font-size: 16px;
}
.pw { position: relative; display: block; }
.pw input { padding-right: 44px !important; }
.eye {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 36px;
  height: 36px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 6px;
  background: var(--ink-soft);
  cursor: pointer;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / 22px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / 22px no-repeat;
}
.eye[aria-pressed="true"] {
  background: var(--ink);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M3 3l18 18'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M3 3l18 18'/%3E%3C/svg%3E");
}
.auth-done { display: grid; justify-items: center; gap: 6px; padding: 18px 0 6px; text-align: center; }
.auth-done[hidden] { display: none; }
.auth-done p { margin: 0; font-size: 17px; }
.check {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--st-accepted);
  color: #fff;
  font-size: 30px;
  font-weight: 700;
}
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.sub { margin: 16px 0 6px; font-size: 16px; }
.devices, .staff { margin: 0; padding: 0; list-style: none; }
.devices li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.devices li span { flex: 1 1 auto; min-width: 0; }
.devices small { display: block; color: var(--ink-soft); }
.devices .this { color: var(--st-accepted); font-weight: 500; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.staff-add { display: grid; grid-template-columns: 1fr 1fr auto auto; align-items: center; gap: 8px; }
.check-label { display: flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }
.invite-box { margin: 12px 0 4px; padding: 12px 14px; border-radius: 10px; background: #f0fdf4; box-shadow: 0 0 0 1.5px var(--st-accepted); }
.invite-box[hidden] { display: none; }
.invite-box p { margin: 0 0 8px; }
.invite-box .hint { margin: 8px 0 0; }
.invite-box input { flex: 1 1 auto; min-width: 0; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 7px; font-size: 14px; }
.staff { margin-top: 14px; }
.staff > li { padding: 10px 0; border-top: 1px solid var(--line); }
.staff-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.staff-head b { font-size: 16px; }
.staff-head .tag { padding: 1px 7px; border-radius: 999px; background: #eef0f3; color: var(--ink-soft); font-size: 12px; }
.staff-head .tag[data-t="admin"] { background: #ede9fe; color: var(--kind-outbound); }
.staff-head .tag[data-t="invited"] { background: #fef3c7; color: #92400e; }
.staff-head .tag[data-t="off"] { background: #fee2e2; color: var(--st-error); }
.staff-meta { margin: 2px 0 6px; color: var(--ink-soft); font-size: 13px; }
.staff-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.staff .devices { margin-top: 6px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--st-sent); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.setup { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.setup-step { position: relative; padding: 10px 0 10px 40px; border-bottom: 1px solid var(--line); counter-increment: s; }
.setup-step::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 10px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef0f3;
  font-weight: 700;
}
.setup-step[data-ok="true"]::before { content: "✓"; background: var(--st-accepted); color: #fff; }
.setup-step[data-ok="false"]::before { background: #fef3c7; color: #92400e; }
.setup-step b { font-size: 16px; }
.setup-step p { margin: 4px 0 0; }
.setup-step ol { margin: 8px 0 0; padding-left: 20px; line-height: 1.5; }
.setup-step ol li + li { margin-top: 4px; }
.setup-step .btn { margin-top: 2px; }

@media (max-width: 700px) {
  .top, .main { padding-left: 12px; padding-right: 12px; }
  .top { gap: 8px 10px; }
  .brand { flex: 1 1 auto; font-size: 18px; }
  .batch-pick select { min-width: 0; width: 100%; }
  .batch-pick { flex: 1 1 100%; order: 5; }
  .search input { width: 100%; }
  .search { flex: 1 1 100%; }
  .top-gap { display: none; }
  /* на телефоне: код, время, статус, сообщение; остальное на компьютере */
  .codes .c-src, .codes .c-lag, .codes .c-avito, .c-time .d { display: none; }
  .codes td, .codes th { padding-left: 8px; padding-right: 8px; }
  .c-n { width: 2.2em; }
  td.c-msg { min-width: 140px; }
  .hand-last { min-width: 0; flex: 1 1 100%; }
  .staff-add { grid-template-columns: 1fr 1fr; }
  .user-btn { max-width: 140px; }
  .stats { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { .codes tr.fresh td, .codes tr.again td, .hand-dot, .hand-last.pulse { animation: none; } }
