/*
  Главный образ — окно. Пока этап в работе, рама и стекло нарисованы жёлтым пунктиром;
  готовая рама — сплошная, готовый стеклопакет — синее стекло.
  Цвета везде значат одно: жёлтый — изготовляется, зелёный — готово.
*/

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --soft: #f9fafb;
  --hover: #f2f4f7;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #98a2b3;
  --ink: #101828;
  --ink-hover: #263247;

  --amber: #f79009;
  --amber-text: #b54708;
  --amber-bg: #fffaeb;
  --amber-soft: #fffcf5;
  --green: #12b76a;
  --green-text: #067647;
  --green-bg: #ecfdf3;
  --blue-bg: #eff8ff;
  --blue-line: #84caff;
  --danger: #d92d20;
  --danger-bg: #fef3f2;

  --font: 'Golos Text Variable', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --r: 10px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue-line); outline-offset: 2px; }
.i { flex: none; }
.win { display: block; flex: none; }
.muted { color: var(--text-3); }
.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: 20;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text-2);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--text); color: #fff; }
.live { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--text-3); font-size: 13px; white-space: nowrap; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.live--wait::before { background: var(--text-3); box-shadow: none; }
.live--lost { color: var(--danger); font-weight: 500; }
.live--lost::before { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }

/* ---------- Страница ---------- */

.page { max-width: 1180px; margin: 0 auto; padding: 32px 28px 96px; }
.head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 20px;
}
.title { margin: 0; font-size: 28px; font-weight: 650; line-height: 1.2; letter-spacing: -0.01em; }
.subtitle { margin: 6px 0 0; color: var(--text-2); }
.card { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow); }

/* Переключатель (вкладки и фильтры) */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: #eaecf0;
}
.seg > a, .seg > button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.seg > :hover { color: var(--text); }
.seg > [aria-current="page"], .seg > [aria-pressed="true"] {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .1);
}
/* Выбор роли: название и одна строка о том, что человек делает. */
.role-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.role-pick > button {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--card);
  text-align: left;
  transition: border-color .15s;
}
.role-pick > button:hover { border-color: var(--border-strong); }
.role-pick > button b { font-size: 14px; font-weight: 600; }
.role-pick > button span { color: var(--text-3); font-size: 12.5px; }
.role-pick > button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.seg .n {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(16, 24, 40, .06);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.seg .n:empty { display: none; }

.search {
  width: 260px;
  height: 44px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%2398a2b3' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='5.5'/%3E%3Cpath d='M12.2 12.2L16 16'/%3E%3C/svg%3E") 13px center no-repeat;
  outline: none;
}
.search:focus { border-color: var(--text-2); box-shadow: 0 0 0 4px rgba(16, 24, 40, .06); }
.search::placeholder { color: var(--text-3); }

/* ---------- Кнопки ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--card);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn--dark { border-color: var(--ink); background: var(--ink); color: #fff; }
.btn--dark:hover { background: var(--ink-hover); }
.btn--lg { height: 54px; padding: 0 26px; font-size: 16px; border-radius: 12px; }
.btn:disabled { cursor: progress; }
.btn > span { position: relative; }
.btn-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(255, 255, 255, .18); transition: width .2s; }
.kbd {
  padding: 1px 7px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--card);
  color: var(--text-2);
  font-size: 12px;
}
.icon-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--r);
  background: none;
  color: var(--text-3);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

/* Короткое состояние: точка + слово */
.state { display: inline-flex; align-items: center; gap: 7px; color: var(--amber-text); font-size: 13px; font-weight: 550; white-space: nowrap; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.state--ready { color: var(--green-text); }
.state--ready::before { background: var(--green); }
.state--shipped { color: var(--text-3); }
.state--shipped::before { background: var(--border-strong); }

/* ---------- Менеджер: новый заказ ---------- */

.compose { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.compose-form { padding: 28px; }
.label { display: block; margin-bottom: 8px; color: var(--text-2); font-size: 14px; font-weight: 600; }
.number {
  width: 100%;
  height: 64px;
  padding: 0 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--card);
  font-size: 28px;
  font-weight: 650;
  letter-spacing: .01em;
  outline: none;
}
.number:focus { border-color: var(--text-2); box-shadow: 0 0 0 4px rgba(16, 24, 40, .06); }
.number::placeholder { color: #c3c8d1; font-weight: 450; }
.note { min-height: 22px; margin: 8px 0 18px; color: var(--text-3); font-size: 14px; }
.note--warn { color: var(--amber-text); font-weight: 500; }
.note button { padding: 0; border: 0; background: none; color: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--soft);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover { border-color: #98a2b3; background: var(--hover); }
.drop:focus-within { border-color: var(--blue-line); }
.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text-2);
  box-shadow: var(--shadow);
}
.drop-title { font-weight: 600; }
.drop-title u { text-decoration: none; border-bottom: 1.5px solid currentColor; }
.drop-hint { color: var(--text-3); font-size: 13px; }

.files { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.files:empty { display: none; }
.file {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 36px;
  gap: 12px;
  align-items: center;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}
.ext {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--hover);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
}
.file-name { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--text-3); font-size: 13px; white-space: nowrap; }
.files-total { margin-top: 8px; color: var(--text-3); font-size: 13px; }
.files-total:empty { display: none; }

.submit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.submit-hint { color: var(--text-3); font-size: 13px; }
.error { flex-basis: 100%; color: var(--danger); font-weight: 500; }
.error:empty { display: none; }

.drop-overlay {
  position: fixed;
  inset: 16px;
  z-index: 60;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  border: 2px dashed var(--text-2);
  border-radius: 24px;
  background: rgba(244, 245, 247, .94);
  color: var(--text);
  font-size: 22px;
  font-weight: 650;
  pointer-events: none;
}

/* Последние переданные */
.recent { padding: 20px 8px 8px; }
.recent-title { margin: 0 12px 8px; font-size: 15px; font-weight: 650; }
.recent-list { margin: 0; padding: 0; list-style: none; }
.recent-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 2px 12px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
}
.recent-item:hover { background: var(--hover); }
.recent-item .win { grid-row: span 2; }
.recent-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.recent-num { font-size: 16px; font-weight: 650; }
.recent-when { color: var(--text-3); font-size: 12.5px; }
.recent-more { display: block; width: 100%; border: 0; background: none; text-align: left; padding: 12px; color: var(--text-2); font-size: 14px; font-weight: 600; text-decoration: none; }
.recent-more:hover { color: var(--text); }
.recent-empty { display: grid; justify-items: center; gap: 10px; padding: 24px 12px 28px; color: var(--text-3); font-size: 14px; text-align: center; }

/* ---------- Завершённые ---------- */

.table-card { overflow: hidden; }
.table-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.table-scroll { overflow-x: auto; }
.table { width: 100%; min-width: 760px; border-collapse: collapse; }
.table th {
  padding: 12px 20px;
  background: var(--soft);
  color: var(--text-3);
  font-size: 13px;
  font-weight: 550;
  text-align: left;
}
.table td { padding: 14px 20px; border-top: 1px solid var(--border); vertical-align: middle; }
.table .group td { padding: 20px 20px 8px; border-top: 0; color: var(--text-2); font-size: 13px; font-weight: 650; }
.table .group .n { margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--text-3); font-weight: 600; }
.table tr.row { cursor: pointer; }
.table tr.row:hover td { background: var(--soft); }
.table .more { padding: 16px 20px; text-align: center; }
.table .empty { padding: 56px 20px; color: var(--text-3); text-align: center; }
.cell-order { display: flex; align-items: center; gap: 12px; }
.cell-num { font-size: 16px; font-weight: 650; }
.cell-time { font-weight: 550; }
.cell-sub { color: var(--text-3); font-size: 13px; }

/* ---------- Цех ---------- */

.workbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.orders { display: grid; gap: 10px; }
.order {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr) minmax(0, 1fr) 210px;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: border-color .2s;
}
.order.is-ready { border-color: #6ce9a6; }
.order.is-new { animation: arrive 4s ease-out; }
@keyframes arrive { 0%, 30% { border-color: var(--blue-line); background: var(--blue-bg); } }
.order-id {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}
.order-id:hover .order-num { text-decoration: underline; text-underline-offset: 4px; }
.order-num, .order-meta { display: block; }
.order-num { font-size: 22px; font-weight: 650; line-height: 1.2; }
.order-meta { color: var(--text-3); font-size: 13px; }
.win.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.86); } 60% { transform: scale(1.06); } }

.stage {
  display: grid;
  gap: 1px;
  width: 100%;
  min-height: 62px;
  padding: 9px 14px;
  border: 1.5px dashed var(--amber);
  border-radius: 12px;
  background: var(--amber-soft);
  color: var(--amber-text);
  text-align: left;
  transition: background .15s, border-color .15s;
}
.stage:hover { border-style: solid; background: var(--amber-bg); }
.stage-label { font-size: 12.5px; font-weight: 500; opacity: .85; }
.stage-status { display: flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 650; }
.stage-time { margin-left: auto; font-size: 12.5px; font-weight: 500; }
.stage--done { border-style: solid; border-color: var(--green); background: var(--green-bg); color: var(--green-text); }
.stage--done:hover { background: #dcfae6; }
.stage--armed, .stage--armed:hover { border-style: solid; border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
/* Этап чужого участка: видно, как идут дела, но кнопки нет. */
.stage--static, .stage--static:hover { border-style: solid; border-color: var(--border); background: var(--soft); color: var(--text-3); cursor: default; }
.stage--static.stage--done { border-color: transparent; background: var(--green-bg); color: var(--green-text); }

.ship { width: 100%; height: 62px; border-radius: 12px; font-size: 15px; }
.ship-wait { padding-left: 4px; }
.ship-wait-label { color: var(--text-3); font-size: 12.5px; }
.ship-wait-text { color: var(--text-2); font-size: 14px; font-weight: 500; }

.empty-card { display: grid; justify-items: center; gap: 12px; padding: 64px 24px; color: var(--text-2); text-align: center; }
.empty-card b { color: var(--text); font-size: 17px; }

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

dialog.drawer {
  width: min(480px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: var(--card);
  color: var(--text);
  box-shadow: -12px 0 40px rgba(16, 24, 40, .14);
}
dialog.drawer[open] { display: flex; flex-direction: column; animation: drawer-in .2s ease-out; }
dialog.drawer::backdrop { background: rgba(16, 24, 40, .35); }
@keyframes drawer-in { from { transform: translateX(32px); opacity: 0; } }
.drawer-head { display: flex; align-items: flex-start; gap: 18px; padding: 24px 24px 20px; border-bottom: 1px solid var(--border); }
.drawer-title { flex: 1; }
.drawer-label { color: var(--text-3); font-size: 13px; }
.drawer-num { margin: 0 0 6px; font-size: 30px; font-weight: 700; line-height: 1.15; }
.drawer-body { flex: 1; padding: 22px 24px 40px; overflow-y: auto; }
.drawer-section { margin: 0 0 12px; color: var(--text-2); font-size: 14px; font-weight: 650; }
.drawer-msg { padding: 64px 24px; color: var(--text-3); }
.drawer-msg--error { color: var(--danger); }

.drawer-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.drawer-row .drawer-section { margin: 0; }
.drawer-section--spaced { margin-top: 28px; }
.drawer-note { margin: 10px 0 0; font-size: 13px; }
.drawer-admin { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.btn--quiet-danger { color: var(--danger); }
.btn--quiet-danger:hover { border-color: var(--danger); background: var(--danger-bg); }

.events { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.event { display: grid; gap: 1px; padding-left: 12px; border-left: 2px solid var(--border); }
.event-time { color: var(--text-3); font-size: 12.5px; }
.event-text { font-size: 14px; }
.event-text b { font-weight: 600; }

.timeline { margin: 0 0 28px; padding: 0; list-style: none; }
.tl { position: relative; display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; padding-bottom: 18px; }
.tl::after { content: ""; position: absolute; top: 24px; bottom: 2px; left: 10px; width: 2px; background: var(--border); }
.tl:last-child { padding-bottom: 0; }
.tl:last-child::after { display: none; }
.tl-dot { display: grid; place-items: center; width: 22px; height: 22px; border: 2px dashed var(--amber); border-radius: 50%; background: var(--card); color: #fff; }
.tl--done .tl-dot { border: 0; background: var(--green); }
.tl--idle .tl-dot { border: 2px solid var(--border-strong); }
.tl-title { font-weight: 600; }
.tl-state { color: var(--text-3); font-size: 13px; }
.tl--wip .tl-state { color: var(--amber-text); }
.tl-time { color: var(--text-2); font-size: 13px; text-align: right; white-space: nowrap; }

.docs { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.doc {
  display: grid;
  grid-template-columns: 20px 38px minmax(0, 1fr) auto 36px;
  gap: 10px;
  align-items: center;
  padding: 8px 6px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.doc:hover { background: var(--soft); }
.doc-n { color: var(--text-3); font-size: 13px; }
.doc-name { overflow: hidden; font-weight: 500; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.doc-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.doc-size { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }

/* ---------- Уведомления ---------- */

.toasts {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 100;
  display: grid;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
}
.toast {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 13px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .22);
  animation: toast-in .18s ease-out;
  transition: opacity .2s, transform .2s;
}
.toast-text { flex: 1; }
.toast--error { background: var(--danger); }
.toast--out { opacity: 0; transform: translateY(8px); }
.toast button { padding: 0; border: 0; background: none; color: #84caff; font-weight: 650; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Выбор рабочего места ---------- */

.entry { max-width: 1000px; padding-top: 72px; text-align: center; }
.entry .title { font-size: 34px; }
.entry .subtitle { margin-bottom: 40px; font-size: 17px; }
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; text-align: left; }
.role {
  align-content: start;
  display: grid;
  gap: 6px;
  padding: 26px;
  text-decoration: none;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.role:hover { border-color: var(--border-strong); box-shadow: 0 10px 30px rgba(16, 24, 40, .08); transform: translateY(-2px); }
.role-art { display: flex; gap: 6px; height: 64px; margin-bottom: 14px; }
.role-name { display: flex; align-items: center; justify-content: space-between; font-size: 20px; font-weight: 650; }
.role-name .i { color: var(--text-3); transition: transform .15s, color .15s; }
.role:hover .role-name .i { color: var(--text); transform: translateX(3px); }
.role-desc { color: var(--text-2); }
.role-key { margin-top: 10px; color: var(--text-3); font-size: 13px; }

/* ---------- Dashboard (ТВ) ---------- */

body.tv {
  --tv-bg: #0b0d11;
  --tv-card: #14171d;
  --tv-line: #232831;
  --tv-text: #f2f4f7;
  --tv-text-2: #9aa3b2;
  --tv-text-3: #626b7a;
  --tv-green: #4ade80;
  --tv-amber: #fbbf24;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--tv-bg);
  color: var(--tv-text);
  color-scheme: dark;
}
body.tv.idle, body.tv.idle * { cursor: none; }

.tv-head { display: flex; align-items: center; gap: 4vw; padding: 2.6vh 2.6vw 2.2vh; }
.tv-brand { display: flex; align-items: center; gap: .8vw; color: var(--tv-text-2); font-size: max(13px, 2vh); font-weight: 600; }
.kpi { display: flex; align-items: baseline; gap: .7vw; }
.kpi b { font-size: max(26px, 6vh); font-weight: 700; line-height: 1; }
.kpi span { color: var(--tv-text-2); font-size: max(12px, 2.1vh); }
.kpi--ready b { color: var(--tv-green); }
.clock { margin-left: auto; text-align: right; }
.clock-time { font-size: max(26px, 6vh); font-weight: 700; line-height: 1; }
.clock-date { margin-top: .6vh; color: var(--tv-text-2); font-size: max(11px, 1.9vh); }
.tv-back {
  align-self: flex-start;
  padding: 8px 14px;
  border: 1px solid var(--tv-line);
  border-radius: 999px;
  color: var(--tv-text-2);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.tv-back:hover { border-color: var(--tv-text-3); color: var(--tv-text); }
.tv-full {
  align-self: flex-start;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--tv-line);
  border-radius: var(--r);
  background: none;
  color: var(--tv-text-3);
}
.tv-full:hover { color: var(--tv-text); }

.tv-grid {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  grid-auto-rows: var(--card-h, 220px);
  align-content: start;
  gap: var(--gap, 16px);
  min-height: 0;
  padding: 0 2.6vw;
  overflow: hidden;
}
.tv-card {
  --h: var(--card-h, 220px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  padding: calc(var(--h) * .09) calc(var(--h) * .1);
  border: max(2px, calc(var(--h) * .008)) solid var(--tv-line);
  border-radius: calc(var(--h) * .07);
  background: var(--tv-card);
  text-align: left;
}
.tv-card.is-ready { border-color: #3bb46a; }
.tv-card.flash { animation: tv-flash 3s ease-out; }
@keyframes tv-flash { 0%, 25% { border-color: var(--tv-amber); background: #262010; } }
.tv-top { display: flex; align-items: center; gap: calc(var(--h) * .08); min-width: 0; }
.tv-top .win { width: auto; height: calc(var(--h) * .4); }
.tv-id { min-width: 0; }
.tv-num {
  overflow: hidden;
  font-size: calc(var(--h) * .19);
  font-weight: 700;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tv-sub { display: flex; align-items: center; gap: .4em; margin-top: .2em; color: var(--tv-text-3); font-size: calc(var(--h) * .075); }
.tv-sub .i { width: 1.2em; height: 1.2em; }
.tv-card.is-ready .tv-sub { color: var(--tv-green); font-weight: 600; }
.tv-lines { display: grid; gap: calc(var(--h) * .025); }
.tv-line { display: flex; justify-content: space-between; gap: 1em; color: var(--tv-text-2); font-size: calc(var(--h) * .088); white-space: nowrap; }
.tv-line b { font-weight: 650; }
.tv-line .done { color: var(--tv-green); }
.tv-line .wip { color: var(--tv-amber); }
.tv-empty { display: grid; flex: 1; place-content: center; justify-items: center; gap: 2vh; color: var(--tv-text-3); font-size: max(18px, 3.2vh); }

.tv-foot { display: flex; align-items: center; gap: 2vw; padding: 2vh 2.6vw 2.4vh; color: var(--tv-text-2); font-size: max(11px, 1.8vh); }
.conn { display: flex; align-items: center; gap: .6vw; white-space: nowrap; }
.conn::before { content: ""; width: 1.1vh; height: 1.1vh; border-radius: 50%; background: var(--tv-green); }
.conn--lost { color: #ff8a65; font-weight: 600; }
.conn--lost::before { background: #ff8a65; }
.pages { display: flex; flex: 1; gap: .5vw; }
.pages i { position: relative; flex: 1; height: .6vh; overflow: hidden; border-radius: 99px; background: var(--tv-line); }
.pages i.seen { background: var(--tv-text-3); }
.pages i.current::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tv-text);
  transform-origin: left;
  animation: page-fill var(--rotate, 15s) linear forwards;
}
@keyframes page-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.pager { white-space: nowrap; }

/* ---------- Узкие экраны ---------- */

/* На средних экранах в шапке не хватает места для всех разделов администратора. */
@media (max-width: 1180px) {
  .top { gap: 16px; }
  .brand span { display: none; }
  .live { font-size: 0; gap: 0; }
}

@media (max-width: 1000px) {
  .compose { grid-template-columns: 1fr; }
  .order { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .order-id { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .top { gap: 12px; padding: 0 16px; }
  .brand { display: none; }
  .nav a { padding: 6px 10px; font-size: 14px; }
  .live { font-size: 0; gap: 0; }
  .page { padding: 24px 16px 96px; }
  .title { font-size: 24px; }
  .compose-form { padding: 20px 16px; }
  .number { height: 58px; font-size: 24px; }
  .search { width: 100%; }
  .seg { width: 100%; }
  .order { grid-template-columns: 1fr; }
  .toasts { width: auto; left: 16px; right: 16px; transform: none; }
}

/* ---------- Пользователь в шапке ---------- */

.who { display: flex; align-items: center; gap: 12px; }
.nav + .who { margin-left: auto; }
.who-name { display: grid; font-size: 14px; font-weight: 600; line-height: 1.2; text-align: right; text-decoration: none; white-space: nowrap; }
.who-name span { color: var(--text-3); font-size: 12px; font-weight: 500; }
.who-name:hover { color: var(--text-2); }
.who-out {
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
}
.who-out:hover { border-color: var(--text-2); color: var(--text); }

/* ---------- Формы ---------- */

.form-field { display: grid; gap: 6px; margin-bottom: 16px; }
.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--card);
  font-size: 16px;
  outline: none;
}
.input:focus { border-color: var(--text-2); box-shadow: 0 0 0 4px rgba(16, 24, 40, .06); }
.input:disabled { background: var(--soft); color: var(--text-3); }
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 52px; }
.password-wrap .icon-btn { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); }
.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 20px; color: var(--text-2); font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.btn--block { width: 100%; }
.btn--sm { height: 34px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
.btn--danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.btn--danger:hover { background: #b42318; }

/* Окно подтверждения */
dialog.confirm {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(16, 24, 40, .24);
}
dialog.confirm[open] { animation: confirm-in .16s ease-out; }
dialog.confirm::backdrop { background: rgba(16, 24, 40, .4); }
@keyframes confirm-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.confirm-box { padding: 24px; }
.confirm-title { margin: 0 0 8px; font-size: 19px; font-weight: 650; line-height: 1.3; }
.confirm-text { margin: 0; color: var(--text-2); }
.confirm-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--soft);
  font-size: 14px;
}
.confirm-details dt { color: var(--text-3); }
.confirm-details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.select {
  height: 36px;
  padding: 0 32px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23475467' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E") right 10px center no-repeat;
  font-size: 14px;
  appearance: none;
}
.select:disabled { color: var(--text-3); }

.alert { margin-bottom: 16px; padding: 12px 14px; border-radius: var(--r); font-size: 14px; font-weight: 500; }
.alert:empty { display: none; }
.alert--error { background: var(--danger-bg); color: var(--danger); }
.alert--info { background: var(--blue-bg); color: #175cd3; }

/* ---------- Вход ---------- */

body.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); padding: 32px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; color: var(--text-2); font-weight: 650; }
.auth-title { margin: 0 0 4px; font-size: 26px; font-weight: 650; }
.auth-sub { margin: 0 0 24px; color: var(--text-2); }
.auth-foot { margin: 20px 0 0; color: var(--text-3); font-size: 13px; text-align: center; }

/* ---------- Мой пароль ---------- */

.narrow { max-width: 560px; }
.panel { margin-bottom: 16px; padding: 24px; }
.panel-title { margin: 0 0 4px; font-size: 18px; font-weight: 650; }
.panel-text { margin: 0 0 20px; color: var(--text-2); }
.rules { display: grid; gap: 4px; margin: -4px 0 20px; padding: 0; list-style: none; color: var(--text-3); font-size: 13px; }
.rules li::before { content: "○"; display: inline-block; width: 18px; }
.rules li.ok { color: var(--green-text); }
.rules li.ok::before { content: "✓"; }
.profile { display: grid; grid-template-columns: auto 1fr; gap: 8px 20px; margin: 0; font-size: 14px; }
.profile dt { color: var(--text-3); }
.profile dd { margin: 0; font-weight: 550; }

/* ---------- Пользователи ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.secret {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 20px 24px;
  border: 1px solid #abefc6;
  border-radius: var(--r-lg);
  background: var(--green-bg);
  color: var(--green-text);
}
.secret-title { font-weight: 650; }
.secret-pair { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; color: var(--text); }
.secret-pair code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 20px; font-weight: 700; letter-spacing: .03em; }
.secret-pair span { color: var(--text-3); font-size: 13px; }
.secret-note { color: var(--text-2); font-size: 13px; }
.secret-url { overflow-wrap: anywhere; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 14px; }
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge--ok { background: var(--green-bg); color: var(--green-text); }
.badge--temp { background: var(--amber-bg); color: var(--amber-text); }
.badge--blocked { background: var(--danger-bg); color: var(--danger); }
.journal-select { height: 44px; min-width: 220px; font-size: 15px; }
.integrity { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; color: var(--text-2); font-size: 14px; }
.integrity::before { content: "✓"; color: var(--green-text); font-weight: 700; }
.integrity button { padding: 0; border: 0; background: none; color: var(--text-2); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.integrity--broken { padding: 14px 16px; border-radius: var(--r); background: var(--danger-bg); color: var(--danger); font-weight: 500; }
.integrity--broken::before { content: "!"; color: var(--danger); }
.cell-who { white-space: nowrap; }
.order-link-plain { padding: 0; border: 0; background: none; color: var(--text); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.table tr.is-blocked td { color: var(--text-3); }
.you { margin-left: 6px; color: var(--text-3); font-size: 12px; font-weight: 500; }

@media (max-width: 640px) {
  .who-name { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 24px 20px; }
}
