/*
 * Оформление интерфейса «Prodaction».
 *
 * Один файл без препроцессоров и сборки. Палитра и размеры собраны в переменные:
 * менять внешний вид можно правкой блока :root, не трогая правила ниже.
 * Тёмная тема включается автоматически по настройке системы.
 */

:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-2: #fafbf9;
  --border: #dcdfd8;
  --text: #1f2420;
  --muted: #6b7269;
  --accent: #2f6f4e;
  --accent-soft: #e6f0ea;
  --ok: #2f6f4e;
  --warn: #9a6b1f;
  --danger: #a63a2f;
  --work: #2b5b86;
  --radius: 14px;
  --radius-sm: 9px;
  /* Поле внутри карточки: 20 точек на компьютере, 16 на телефоне. */
  --pad: 20px;
  --line: color-mix(in srgb, var(--border) 70%, transparent);
  --shadow: 0 1px 2px rgba(20, 30, 24, 0.04), 0 2px 14px rgba(20, 30, 24, 0.045);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141715;
    --surface: #1c211e;
    --surface-2: #232823;
    --border: #333a35;
    --text: #e7ebe6;
    --muted: #98a096;
    --accent: #6fb98f;
    --accent-soft: #21302a;
    --ok: #6fb98f;
    --warn: #d6a656;
    --danger: #e07a6c;
    --work: #6ba4d8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

* {
  box-sizing: border-box;
}

/* Safari на iPhone увеличивает шрифт при повороте экрана «для удобства» — и вёрстка,
   рассчитанная на свою ширину, начинает вылезать за край. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  font-size: 26px;
}
h2 {
  font-size: 17px;
}
h3 {
  font-size: 16px;
}

a {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
  font-size: 0.94em;
  white-space: nowrap;
}

.right {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

/* --------------------------------------------------------------- оболочка

   Широкий экран: боковая панель с разделами слева, рабочая область справа.
   Телефон (до 900 точек): панели нет, сверху строка с названием раздела, снизу —
   вкладки со значками. Разметка одна на оба вида, переключает её этот файл. */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.logo {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px 12px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px;
  color: var(--text);
  text-decoration: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.brand-text strong {
  font-size: 16px;
}

.brand-text span {
  font-size: 12px;
  color: var(--muted);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.side-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-group-title {
  padding: 0 10px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.side-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}

.side-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.side-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.side-user {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  min-width: 0;
}

.who-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.who-name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who-role {
  font-size: 12px;
  color: var(--muted);
}

.side-actions {
  display: flex;
  flex-direction: column;
}

.side-action {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.side-action:hover {
  background: var(--surface-2);
  color: var(--text);
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.avatar-small {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  font-size: 12px;
}

.icon {
  flex: 0 0 auto;
  display: block;
}

/* Верхняя строка и вкладки — только на телефоне. */
.topbar,
.tabbar {
  display: none;
}

.content {
  flex: 1;
  padding: 24px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Раздел появляется мягко, а не вспышкой. Кому движение мешает — без него. */
.content > * {
  animation: rise 0.18s ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before {
    animation: none !important;
    transition: none !important;
  }
}

/* Контур раздела, пока он грузится. */
.skeleton .sk-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px var(--pad);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sk-head,
.sk-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sk-row {
  flex-direction: row;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.sk-line {
  display: block;
  height: 12px;
  flex: 1;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.sk-title {
  height: 18px;
  flex: none;
  width: 32%;
}

.sk-sub {
  flex: none;
  width: 55%;
}

.sk-short {
  flex: 0 0 22%;
}

.sk-tiny {
  flex: 0 0 12%;
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  align-items: start;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Шапка без черты снизу: заголовок отделён воздухом, а не линией — так карточка
   читается одним куском, как в современных рабочих системах. */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px var(--pad) 12px;
  flex-wrap: wrap;
}

.card-title h2 {
  font-size: 17px;
  letter-spacing: -0.01em;
}

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

.card-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* «⋯» с остальными действиями шапки — только на телефоне. Селектор с родителем:
   иначе его перебивает `.btn-icon`, объявленный ниже по файлу. */
.card-actions .card-more {
  display: none;
}

.card-body {
  padding: 4px 0 0;
}

.card-body .fields,
.card-body .note,
.card-body .empty,
.card-body .loading,
.card-body .form,
.card-body .toolbar,
.card-body > .form-row,
.card-body > .stats,
.card-body > h3 {
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.card-body > h3 {
  margin-top: 18px;
  font-size: 15px;
}

.card-body > *:last-child {
  margin-bottom: 14px;
}

/* --------------------------------------------------------------- таблицы */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th:first-child,
td:first-child {
  padding-left: var(--pad);
}

th:last-child,
td:last-child {
  padding-right: var(--pad);
}

/* Заголовки колонок — тихие и без капслока: их читают один раз, а смотрят на данные. */
th {
  font-weight: 500;
  color: var(--muted);
  font-size: 12.5px;
  background: var(--surface-2);
  white-space: nowrap;
  padding-top: 9px;
  padding-bottom: 9px;
}

@media (hover: hover) and (min-width: 721px) {
  tbody tr:hover {
    background: color-mix(in srgb, var(--surface-2) 75%, transparent);
  }
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr.clickable {
  cursor: pointer;
}

tbody tr.clickable:hover {
  background: var(--surface-2);
}

td.right,
th.right {
  text-align: right;
  white-space: nowrap;
}

td.actions {
  white-space: nowrap;
  text-align: right;
}

td.actions .btn {
  margin-left: 6px;
  vertical-align: middle;
}

/* --------------------------------------------------------------- элементы */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

/* Цветной статус — с точкой впереди: цвет узнаётся и там, где слово не прочитано. */
.badge-ok::before,
.badge-work::before,
.badge-wait::before,
.badge-danger::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 1px;
}

.badge-ok {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--ok);
}

.badge-work {
  background: color-mix(in srgb, var(--work) 12%, transparent);
  border-color: transparent;
  color: var(--work);
}

.badge-wait {
  background: color-mix(in srgb, var(--warn) 15%, transparent);
  border-color: transparent;
  color: var(--warn);
}

.badge-danger {
  background: color-mix(in srgb, var(--danger) 13%, transparent);
  border-color: transparent;
  color: var(--danger);
}

.progress {
  height: 6px;
  min-width: 70px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 20px;
  padding-top: 12px;
}

/* Счётчики этапа идут одной строкой и переносятся, если не влезли: на телефоне
   три метки в узкой ячейке иначе растянули бы карточку. */
.counters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Плитки сводки. От `.fields` отличаются размером числа: сводку читают с расстояния
   вытянутой руки, а не вчитываются в неё, — поэтому число крупное, а подпись мелкая.
   Сетка та же (auto-fit), поэтому на телефоне плитки встают в одну колонку сами. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding-top: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.stat-value {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  /* Длинная сумма («1 234 567,00 ₽») не должна разрывать плитку на телефоне. */
  overflow-wrap: anywhere;
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
}

.stat-hint {
  font-size: 12px;
  color: var(--muted);
}

.stat-danger {
  border-color: var(--danger);
}

.stat-danger .stat-value {
  color: var(--danger);
}

.stat-warn {
  border-color: var(--warn);
}

.stat-warn .stat-value {
  color: var(--warn);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.field-label {
  font-size: 12px;
  color: var(--muted);
}

.field-value {
  font-weight: 500;
}

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, filter 0.12s;
}

.btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(20, 30, 24, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  background: var(--accent);
}

.btn-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

a.btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding-top: 12px;
}

.form {
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.input {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.input input,
.input select,
.input textarea {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
  min-height: 38px;
}

.input textarea {
  resize: vertical;
}

.input input:focus,
.input select:focus,
.input textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -1px;
}

/* --------------------------------------------------------------- сообщения */

.note,
.empty,
.loading {
  margin: 12px 0;
  color: var(--muted);
  font-size: 14px;
}

.empty,
.loading {
  padding: 16px;
  text-align: center;
}

.note-error {
  color: var(--danger);
}

.note-ok {
  color: var(--ok);
}

.note-warn {
  color: var(--warn);
}

/* Кнопки под списком строк заявки: «+ Ещё позиция» и «+ Баллон БМК» в один ряд. */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Выбор позиции поиском: подсказки раскрываются под полем, в потоке формы. */
.picker-list {
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.picker-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 11px;
  cursor: pointer;
}

.picker-item:last-child {
  border-bottom: 0;
}

.picker-item:hover,
.picker-item.active {
  background: var(--accent-soft);
}

.picker-item.chosen {
  font-weight: 600;
}

.picker-build {
  color: var(--accent);
}

.picker-meta {
  font-size: 12px;
  color: var(--muted);
}

.picker-empty {
  padding: 9px 11px;
  font-size: 14px;
  color: var(--muted);
}

/* Конструктор БМК: шесть параметров ровной сеткой — три в ряд, на телефоне два. */
.bmk-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 560px) {
  .bmk-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Конструктор БМК: собранная маркировка и характеристики, как в КП. */
.bmk-result {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.bmk-marking {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.bmk-result .note {
  margin: 6px 0;
}

.bmk-chars {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

/* Этап заказа в цехе у менеджера: полоса и под ней «Этап 3 из 10: Намотка». */
.order-stage {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  font-size: 13px;
}

/* Строки новой заявки: позиция, количество и крестик в ряд, под ними — что скажет склад.
   Ряд не переносится на телефоне: количество узкое, а крестик должен стоять у своей строки. */
.order-lines {
  display: grid;
  gap: 10px;
}

.order-line {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.order-line-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px auto;
  gap: 8px;
  align-items: end;
}

.order-line .note {
  margin: 0;
  font-size: 13px;
}

.form-error {
  color: var(--danger);
  font-size: 14px;
  margin: 4px 0 0;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
  max-width: 380px;
  animation: toast-in 0.2s ease;
}

.toast-ok {
  border-left: 3px solid var(--ok);
}

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast-info {
  border-left: 3px solid var(--work);
}

.toast-link {
  cursor: pointer;
}

/* Счётчик на пункте меню: сколько заявок ждёт ответа. */
.nav-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: auto;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

.nav-count[hidden] {
  display: none;
}

/* На вкладке телефона, плитке «Ещё» и в узкой панели подписи нет — счётчик садится на
   угол значка. */
.side-item,
.tab,
.tile {
  position: relative;
}

.tab .nav-count,
.tile .nav-count {
  position: absolute;
  top: 2px;
  left: calc(50% + 6px);
  margin: 0;
}

@media (min-width: 901px) and (max-width: 1280px) {
  .side-item .nav-count {
    position: absolute;
    top: 2px;
    right: 2px;
    margin: 0;
  }
}

.toast.leaving {
  opacity: 0;
  transition: opacity 0.3s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* --------------------------------------------------------------- модальное окно */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 17, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
  width: min(560px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
}

.modal-body > .form {
  padding-top: 0;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------- меню действий

   Кнопка «⋯» в строке таблицы и то, что она открывает: на широком экране — меню под
   кнопкой, на телефоне — шторку снизу. Пункты одинаковые, разметку строит ui.js. */

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
}

.btn-icon:hover:not(:disabled),
.btn-icon[aria-expanded='true'] {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.menu {
  position: fixed;
  z-index: 60;
  min-width: 230px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 38px rgba(15, 20, 17, 0.18), 0 2px 8px rgba(15, 20, 17, 0.08);
  animation: menu-in 0.12s ease-out;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.menu-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.menu-item .icon {
  margin-top: 1px;
  color: var(--muted);
}

.menu-item:hover:not(:disabled),
.menu-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.menu-item:disabled {
  cursor: not-allowed;
  color: var(--muted);
}

.menu-danger,
.menu-danger .icon {
  color: var(--danger);
}

.menu-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.menu-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}

.icon-gap {
  width: 18px;
  flex: 0 0 18px;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 20, 17, 0.42);
  animation: fade-in 0.16s ease-out;
}

.sheet-overlay.leaving {
  opacity: 0;
  transition: opacity 0.16s;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.sheet {
  width: min(560px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-up 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

.sheet-grip {
  width: 38px;
  height: 5px;
  margin: 8px auto 2px;
  border-radius: 3px;
  background: var(--border);
}

.sheet-head {
  padding: 8px 20px 4px;
}

.sheet-head p {
  margin: 2px 0 0;
  font-size: 13px;
}

.sheet-body {
  padding: 8px 12px;
  overflow-y: auto;
}

.sheet-body > .who {
  padding: 8px 10px 12px;
}

.sheet-menu {
  display: flex;
  flex-direction: column;
}

.sheet-menu .menu-item,
.sheet-menu .side-action {
  padding: 13px 10px;
  font-size: 16px;
}

.sheet-menu .side-action {
  color: var(--text);
}

.sheet-menu .menu-item .icon,
.sheet-menu .side-action .icon {
  width: 20px;
  height: 20px;
}

.sheet-foot {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
}

.sheet-foot .btn {
  width: 100%;
  padding: 11px;
  font-size: 15px;
}

.sheet-group + .sheet-group {
  margin-top: 14px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 4px 0;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
}

.tile .icon {
  color: var(--muted);
}

.tile.active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.tile.active .icon {
  color: var(--accent);
}

/* --------------------------------------------------------------- вход */

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(520px, 100%);
}

.login-card h1 {
  margin-bottom: 2px;
}

/* Логин и пароль в столбик: на узком экране строка из двух полей и кнопки не помещается. */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 18px 0 0;
}

.login-form input {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.login-form input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -1px;
}

.login-form .btn {
  margin-top: 2px;
}

/* Переключение «вход ⇄ регистрация» и кнопки, выглядящие ссылкой.
   Кнопка, а не <a>: никуда не ведёт, а переключает экран — ссылка сбивала бы с толку
   и не работала бы с клавиатуры так, как ожидается от действия. */
.login-switch {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.linklike {
  font: inherit;
  font-size: inherit;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.linklike:hover {
  text-decoration-thickness: 2px;
}

.linklike:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Форма регистрации: полей больше, чем у входа, и каждому нужна подпись. */
.register-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 18px 0 0;
}

.register-form .btn {
  margin-top: 4px;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Демонстрационный вход. Всего блока нет, когда на сервере снят DEMO_MODE. */
.login-demo {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.login-hint {
  margin: 14px 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.demo-password {
  margin: 0 0 10px;
}

.demo-password input {
  font: inherit;
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.demo-password input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -1px;
}

.login-accounts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 6px;
}

.account {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.account:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.account-name {
  font-size: 14px;
  font-weight: 500;
}

.account-role {
  font-size: 12px;
  color: var(--muted);
}

/* --------------------------------------------------------------- песочница */

/* Демо для посетителей сайта студии: не форма входа, а приглашение попробовать.
   «С чего начать» — пять ролей с подсказкой, что в каждой нажать; остальные сотрудники
   свёрнуты, чтобы список из двенадцати человек не встречал посетителя первым. */
.sandbox-card {
  width: min(560px, 100%);
}

.sandbox-eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.sandbox-subtitle {
  margin: 20px 0 8px;
  font-size: 15px;
}

.sandbox-tries {
  display: grid;
  gap: 6px;
}

.sandbox-try {
  width: 100%;
  padding: 10px 12px;
}

.sandbox-all {
  margin-top: 14px;
}

.sandbox-all > summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--accent);
}

.sandbox-all .login-demo {
  margin-top: 4px;
  padding-top: 0;
  border-top: 0;
}

.sandbox-foot {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.sandbox-foot a {
  color: var(--accent);
}

/* --------------------------------------------------------------- витрина */

/* Витрина — это не экран входа, а страница о системе: рассказ, снимки экранов,
   демонстрационная дверь и подвал. Оформление у неё своё и живёт отдельно от
   рабочего интерфейса: там плотность и таблицы, здесь воздух и крупный текст.
   Переменные — общие, поэтому тёмная тема достаётся витрине даром.

   Снимки экранов ниже (.shot и всё, что внутри) — это разметка, а не картинки:
   в поставке нет ни одного файла изображения, а внешние ресурсы интерфейсу
   запрещены. Зато они не устаревают и работают в обеих темах. */

.showcase {
  --wrap: 1060px;
  --ink: color-mix(in srgb, var(--text) 78%, transparent);
  background: var(--surface);
  color: var(--text);
}

.showcase-wrap {
  width: min(var(--wrap), 100%);
  margin: 0 auto;
  padding: 0 24px;
}

/* Разделы вспоминаются по имени, поэтому ссылки в шапке ведут якорями. Отступ
   сверху — чтобы липкая шапка не накрывала заголовок раздела при переходе. */
.showcase section {
  scroll-margin-top: 64px;
}

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

.showcase-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  /* Сплошной фон, а не «матовое стекло»: с ним Safari на iPhone при прокрутке оставлял
     полосу от прошлого кадра — та же беда, из-за которой уехали нижние вкладки. */
  background: var(--surface);
}

.showcase-nav-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 52px;
}

.showcase-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.showcase-logo {
  width: 22px;
  height: 22px;
  color: var(--accent);
  flex: none;
}

.showcase-nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: auto;
  font-size: 13.5px;
}

.showcase-nav-links a {
  color: var(--ink);
  text-decoration: none;
}

.showcase-nav-links a:hover {
  color: var(--accent);
}

.showcase-nav-demo {
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
}

.showcase-nav-demo:hover {
  filter: brightness(1.08);
}

/* ---------------------------------------------------------- первый экран */

.showcase-hero {
  padding: clamp(56px, 9vw, 104px) 0 clamp(40px, 6vw, 72px);
  text-align: center;
  background: radial-gradient(
      120% 100% at 50% 0%,
      color-mix(in srgb, var(--accent-soft) 70%, transparent),
      transparent 62%
    ),
    var(--surface);
}

.showcase-eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.showcase-title {
  margin: 14px 0 0;
  font-size: clamp(34px, 6.4vw, 62px);
  line-height: 1.06;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.showcase-lead {
  margin: 20px auto 0;
  max-width: 640px;
  font-size: clamp(16px, 2.1vw, 20px);
  line-height: 1.5;
  color: var(--ink);
}

.showcase-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

.showcase-btn {
  display: inline-block;
  padding: 11px 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}

.showcase-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.showcase-btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}

.showcase-btn.primary:hover {
  color: var(--surface);
  filter: brightness(1.08);
}

.showcase-hero-note {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.showcase-hero-shot {
  margin-top: clamp(32px, 5vw, 56px);
}

/* ---------------------------------------------------------- числа */

.showcase-numbers {
  padding: clamp(28px, 4vw, 44px) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.showcase-numbers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
}

.showcase-number b {
  display: block;
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.showcase-number span {
  display: block;
  margin-top: 5px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
}

/* ---------------------------------------------------------- разделы */

.showcase-section {
  padding: clamp(56px, 8vw, 96px) 0;
}

.showcase-section:nth-of-type(even) {
  background: var(--bg);
}

.showcase-h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.14;
  font-weight: 600;
  letter-spacing: -0.025em;
  text-align: center;
}

.showcase-sub {
  margin: 14px auto 0;
  max-width: 620px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  text-align: center;
}

/* Путь заявки: семь шагов подряд. Сетка, а не список в столбик — иначе на широком
   экране семь коротких строк выглядят потерянными. */
.showcase-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px 28px;
  margin: clamp(28px, 4vw, 44px) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: none;
}

.showcase-step {
  display: flex;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.showcase-step-number {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.showcase-step b {
  font-size: 15px;
  font-weight: 600;
}

.showcase-step p {
  margin: 3px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

/* ---------------------------------------------------------- возможности */

.showcase-features {
  display: flex;
  flex-direction: column;
  gap: clamp(48px, 7vw, 88px);
  margin-top: clamp(40px, 6vw, 72px);
}

.showcase-feature {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: clamp(24px, 4vw, 56px);
}

/* Развороты чередуются: текст то слева, то справа. Порядок меняется только на
   широком экране — в один столбец текст всегда идёт первым. */
.showcase-feature.flip .showcase-feature-text {
  order: 2;
}

.showcase-icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.showcase-feature-text h3 {
  margin: 12px 0 0;
  font-size: clamp(21px, 2.8vw, 28px);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.showcase-feature-text p {
  margin: 12px 0 0;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
}

.showcase-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: clamp(48px, 7vw, 80px);
}

.showcase-card {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.showcase-card b {
  display: block;
  margin-top: 12px;
  font-size: 16px;
  font-weight: 600;
}

.showcase-card p {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}

/* ---------------------------------------------------------- снимки экранов */

.shot {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 30, 24, 0.05), 0 18px 44px rgba(20, 30, 24, 0.09);
  overflow: hidden;
  text-align: left;
}

.showcase-hero-shot .shot {
  max-width: 860px;
  margin: 0 auto;
}

.shot-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.shot-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--border);
}

.shot-title {
  margin-left: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.shot-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.shot-order-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.shot-order-number {
  font-size: 14px;
  font-weight: 600;
}

.shot-order-days {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.shot-order-days.ok {
  color: var(--ok);
}

.shot-order-days.warn {
  color: var(--warn);
}

.shot-order-client {
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--muted);
}

/* Полоса этапов: доля пройденного маршрута. Тот же приём, что на рабочих экранах. */
.shot-track {
  height: 5px;
  margin-top: 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.shot-track-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.shot-order-stage {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink);
}

.shot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}

.shot-row-name {
  flex: 1;
}

.shot-row-qty {
  color: var(--muted);
  white-space: nowrap;
}

.shot-mark {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  white-space: nowrap;
}

.shot-mark.ok {
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
  background: var(--accent-soft);
  color: var(--ok);
}

.shot-mark.warn {
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--warn);
}

.shot-mark.bad {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}

.shot-foot {
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.shot-task b {
  font-size: 14px;
}

.shot-task span {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.shot-counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.shot-count {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
}

.shot-count b {
  display: block;
  font-size: 18px;
  font-weight: 600;
}

.shot-count span {
  font-size: 11.5px;
  color: var(--muted);
}

.shot-count.ok b {
  color: var(--ok);
}

.shot-count.warn b {
  color: var(--warn);
}

.shot-verdict {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.shot-serial {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.shot-serial-sub {
  margin-top: -6px;
  font-size: 12.5px;
  color: var(--muted);
}

.shot-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.shot-step-name {
  width: 104px;
  flex: none;
  font-weight: 500;
}

.shot-step-who {
  flex: 1;
  color: var(--ink);
}

.shot-step-when {
  color: var(--muted);
  font-size: 12px;
}

/* ---------------------------------------------------------- дверь */

.showcase-demo {
  border-top: 1px solid var(--border);
}

/* Дверь витрины: тот же демонстрационный вход, что на рабочей установке, только
   вписанный в карточку по центру страницы. Правила самого входа не дублируются —
   здесь снимается лишь черта, которая отделяла его от формы логина. */
.showcase-door {
  width: min(720px, 100%);
  margin: clamp(24px, 4vw, 36px) auto 0;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.showcase-door .login-demo {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.showcase-door .login-hint {
  margin-top: 0;
}

.showcase-door .login-form {
  margin-top: 0;
}

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

.showcase-footer {
  padding: clamp(40px, 6vw, 64px) 0 28px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: 13.5px;
}

.showcase-footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 28px;
}

.showcase-col b {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
}

.showcase-col a {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  text-decoration: none;
}

.showcase-col a:hover {
  color: var(--accent);
}

.showcase-col p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.showcase-col-brand .showcase-brand {
  margin-bottom: 10px;
}

/* Адрес рабочей установки — то, ради чего сотрудник уходит с витрины: выделен
   цветом, чтобы не потеряться среди прочих ссылок подвала. */
.showcase-work a {
  color: var(--accent);
  font-weight: 500;
}

.showcase-footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: clamp(28px, 4vw, 40px);
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------------------------------------------------------- узкий экран */

/* Телефон: развороты складываются в один столбец, шапка теряет часть ссылок —
   на 360 точках они всё равно не помещаются, а кнопка демонстрации важнее. */
@media (max-width: 780px) {
  .showcase-feature {
    grid-template-columns: 1fr;
  }

  .showcase-feature.flip .showcase-feature-text {
    order: 0;
  }

  .showcase-nav-links a:not(.showcase-nav-work) {
    display: none;
  }
}

@media (max-width: 520px) {
  .showcase-wrap {
    padding: 0 16px;
  }

  .showcase-nav-links {
    display: none;
  }

  .shot-step-name {
    width: 88px;
  }

  .showcase-footer-bottom {
    flex-direction: column;
  }
}

/* --------------------------------------------------------------- сотрудники */

/* Аватар, ФИО и логин в одной ячейке: логин мельче и тише — он служебный, а ищут
   человека глазами по фамилии. */
.staff-person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.staff-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.staff-name {
  font-weight: 500;
}

.staff-login {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.staff-login-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.staff-email {
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Над списком: поиск и переключатель «все / активные / отключённые». */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 4px var(--pad) 12px;
}

.search-input {
  flex: 1 1 260px;
  min-width: 0;
  min-height: 38px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.search-input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -1px;
  background: var(--surface);
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.segment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.segment.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 20, 17, 0.1);
}

.locked {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--muted);
  cursor: help;
}

.segment-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- роли */

/* Форма роли длинная: название, десяток экранов, десяток разделов. Блоки с заголовками
   разбивают её на три понятные части, иначе получается стена полей. */
.form-block {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.form-block h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* Экраны — галочками в две-три колонки: их около десятка, в столбик было бы длинно. */
.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 6px;
}

.check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 2px 8px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.check:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.check input {
  grid-row: span 2;
  align-self: center;
}

.check-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.check-hint {
  grid-column: 2;
  font-size: 12px;
  color: var(--muted);
}

/* Права: раздел, его описание и выпадающий список уровня. */
.perms {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.perm > span:first-child {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Права в таблице — метками: так видно набор роли одним взглядом, а «none» не
   показывается вовсе, иначе половина строки была бы про отсутствие прав. */
.perm-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* --------------------------------------------------------------- приглашения */

/* Код переписывают с экрана и диктуют — поэтому моноширинный и крупный. */
.invite-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 26px;
  letter-spacing: 2px;
  text-align: center;
  margin: 8px 0;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--accent-soft);
  user-select: all;
}

.invite-known {
  margin: 0;
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--accent-soft);
  font-size: 13px;
}

.invite-code-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  user-select: all;
}

/* --------------------------------------------------------------- паспорт изделия */

.passport-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px 0;
}

.passport-serial {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
}

.timeline {
  list-style: none;
  margin: 14px 0 0;
  padding: 0 16px 4px 28px;
  border-left: 2px solid var(--border);
  margin-left: 20px;
}

.timeline li {
  position: relative;
  padding-bottom: 14px;
}

.timeline li::before {
  content: '';
  position: absolute;
  left: -35px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

.timeline .stage-name {
  font-weight: 500;
}

.timeline .stage-meta {
  font-size: 13px;
  color: var(--muted);
}

/* --------------------------------------------------------------- узкий экран */

/* Ноутбук: панель сворачивается до полосы со значками. Таблица заявок с восемью
   колонками при полной панели на 1280 точках уже не влезала, и кнопки уезжали за край.
   Названия разделов — во всплывающей подсказке (`title`). */
@media (min-width: 901px) and (max-width: 1280px) {
  .shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .sidebar {
    align-items: center;
    padding: 14px 10px;
  }

  .sidebar-brand {
    padding: 2px 0;
  }

  .brand-text,
  .side-group-title,
  .side-item span,
  .side-action span,
  .who-text {
    display: none;
  }

  .side-nav {
    align-items: center;
  }

  .side-group {
    align-items: center;
  }

  .side-group + .side-group {
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  .side-item,
  .side-action {
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .side-user {
    align-items: center;
  }

  .who {
    padding: 4px 0;
  }

  .content {
    padding: 20px;
  }
}

@media (max-width: 900px) {
  /* Боковая панель уступает место верхней строке и нижним вкладкам. */
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  /* Фон у закреплённых полос — сплошной, без «матового стекла». Safari на iPhone при
     прокрутке длинной страницы перерисовывает полосу с `backdrop-filter` не вместе со
     страницей: верхняя часть экрана остаётся от прошлого кадра, и нижние вкладки
     оказываются посреди страницы. Со сплошным фоном этого не происходит. Красоты
     меньше, зато меню стоит там, где ему положено. */
  .topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .topbar-title {
    flex: 1;
    min-width: 0;
    font-size: 17px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-me {
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
  }

  /* Вкладки внизу: до пяти равных ячеек, значок над подписью. Панель не прокручивается
     вбок никогда — лишние разделы уходят в «Ещё». */
  /* Сообщения поднимаются над вкладками: иначе «Новая заявка на производство»
     ложится прямо на меню и закрывает его на те десять секунд, что висит. */
  .toasts {
    left: 12px;
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom));
  }

  .toast {
    max-width: none;
  }

  .tabbar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    /* Своим слоем: тогда полосу двигает не пересчёт страницы, а сам браузер, и при
       быстрой прокрутке она не отстаёт от неё. См. пояснение у .topbar выше. */
    transform: translateZ(0);
    will-change: transform;
  }

  .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 0;
    padding: 4px 2px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .tab span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tab.active {
    color: var(--accent);
  }

  .content {
    padding: 16px 14px calc(88px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 720px) {
  :root {
    --pad: 16px;
  }

  /* Плитки сводки — по две в ряд: по одной на всю ширину они растягивали экран
     директора на три прокрутки, а читают их одним взглядом. */
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat {
    padding: 12px 14px;
  }

  .stat-value {
    font-size: 19px;
  }

  /* Плитка без пары — во всю ширину: так ряд не выглядит недостроенным, а длинная
     сумма не переносит «₽» на новую строку. */
  .stats > .stat:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  /* Шапка карточки на телефоне: главная кнопка во всю ширину, остальные — в «⋯». */
  .card-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .card-actions > .btn:first-child {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
  }

  .card-actions > .btn:only-child {
    grid-column: 1 / -1;
  }

  .card-actions.with-more > .btn:not(:first-child):not(.card-more) {
    display: none;
  }

  .card-actions .card-more {
    display: inline-grid;
    width: 46px;
    height: auto;
    border-color: var(--border);
    color: var(--text);
  }


  /* --------------------------------------------------------------- таблицы как карточки

     На телефоне таблица шире экрана: чтобы дотянуться до кнопки действия, пришлось бы
     смахивать содержимое вбок. Поэтому та же разметка показывается блоками — строка
     становится карточкой, у каждого значения появляется подпись колонки из data-label,
     а кнопки уходят вниз во всю ширину. Разметка одна, переключает её только CSS. */

  .table-wrap {
    overflow-x: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  /* Шапка не нужна: подписи переехали к самим значениям. */
  thead {
    display: none;
  }

  tbody tr {
    padding: 14px var(--pad);
    border-bottom: 1px solid var(--line);
  }

  tbody tr:last-child {
    border-bottom: none;
  }

  td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border-bottom: none;
    text-align: right;
  }

  td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 13px;
    color: var(--muted);
    text-align: left;
  }

  /* Ячейки карточки — без боковых полей таблицы: поле задаёт сама карточка. */
  td:first-child,
  td:last-child {
    padding-left: 0;
    padding-right: 0;
  }

  /* У колонки без заголовка подписи нет — не оставляем пустое место. */
  td:not([data-label])::before {
    display: none;
  }

  td.right {
    text-align: right;
  }

  /* Действия — отдельным рядом внизу карточки, кнопки во всю ширину, чтобы попадать
     пальцем без прицеливания. */
  td.actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }

  td.actions .btn {
    margin-left: 0;
    width: 100%;
    padding: 10px 13px;
  }

  /* На телефоне у кнопки должна быть видимая граница: без неё «Отменить» и «Карточка»
     читаются как обычный текст и в них не целятся пальцем. */
  td.actions .btn-ghost {
    border-color: var(--border);
    color: var(--text);
  }

  /* Метка состояния — не кнопка: она не должна растягиваться на всю ширину карточки. */
  td.actions .badge {
    justify-self: center;
  }

  /* Первая колонка — заголовок карточки: крупно, без подписи, слева. Так карточка
     читается как в мобильном приложении — «кто или что» сверху, подробности под ним. */
  tbody tr {
    position: relative;
  }

  tbody td:first-child {
    justify-content: flex-start;
    text-align: left;
    font-size: 15px;
    font-weight: 600;
    padding-bottom: 6px;
  }

  tbody td:first-child::before {
    display: none;
  }

  /* Колонка, где только «⋯», не занимает ряд внизу: кнопка встаёт в правый верхний
     угол карточки, как меню у письма в почте. */
  td.actions-menu {
    position: absolute;
    top: 8px;
    right: 10px;
    display: block;
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
  }

  tr:has(> td.actions-menu) > td:first-child {
    padding-right: 44px;
  }

  td.actions .btn-icon,
  td.actions-menu .btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
  }

  /* Главное действие во всю ширину, «⋯» рядом с ним. */
  td.actions-split {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  td.actions-split .badge {
    justify-self: start;
    align-self: center;
  }

  td.actions-split .btn-icon {
    border-color: var(--border);
    color: var(--text);
    height: auto;
  }

  td.actions-split > .btn:only-child:not(.btn-icon) {
    grid-column: 1 / -1;
  }

  td.actions-split > .btn-icon:only-child {
    grid-column: 2;
    width: 44px;
  }

  /* Карточка сотрудника: имя с аватаром сверху, под ним одной строкой роль,
     подразделение и метки. Подписи «Роль», «Доступ» здесь не нужны — по самим
     значениям и так понятно, что есть что, а карточка выходит вдвое короче. */
  .staff-list tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 14px 16px;
  }

  .staff-list tbody td {
    display: inline-flex;
    width: auto;
    padding: 0;
    text-align: left;
  }

  .staff-list tbody td::before {
    display: none;
  }

  .staff-list tbody td:first-child {
    width: 100%;
    padding: 0 44px 4px 0;
  }

  .staff-list td[data-label='Роль'] {
    font-size: 13px;
    align-items: center;
    gap: 6px;
  }

  .staff-list td[data-label='Вход'] .staff-email {
    font-size: 12px;
  }

    /* Поиск над списком — во всю ширину, переключатель под ним растягивается тоже. */
  .list-toolbar {
    padding: 12px 14px 4px;
  }

  .search-input {
    flex-basis: 100%;
    font-size: 16px; /* меньше 16 точек iPhone увеличивает страницу при вводе */
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
    justify-content: center;
  }

  /* Диалог на телефоне выезжает снизу, как шторка: до кнопок достаёт большой палец. */
  .overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheet-up 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .modal-foot .btn {
    flex: 1;
    padding: 11px;
    font-size: 15px;
  }

  /* Полоса прогресса растягивается на всю ширину карточки. */
  .progress {
    min-width: 120px;
    flex: 1;
  }
}

/* --------------------------------------------------------------- поля на телефоне

   Safari на iPhone увеличивает страницу, когда палец ставит курсор в поле с текстом
   мельче 16 точек, — и обратно уже не уменьшает. У заказчика так и вышло: пароль
   демонстрации был полем в 15 точек, после него всё приложение осталось увеличенным,
   страница «гуляла» вправо-влево, и так в каждом разделе — страница-то одна.
   Поэтому на сенсорных экранах поля — ровно 16 точек. `:root` поднимает правило над
   `.input input` и `.login-form input`, не прибегая к !important. */
@media (max-width: 900px), (pointer: coarse) {
  :root :is(input, select, textarea) {
    font-size: 16px;
  }
}


/* --------------------------------------------------------------- уведомления на телефон */

/*
 * Полоска «Включите уведомления» над содержимым экрана. Она не всплывает и не мигает:
 * предложение, а не тревога. Закрыть её можно крестиком — до конца рабочего дня
 * (см. web/push.js), потому что уведомления заказчик просил у всех, и полоска должна
 * вернуться, если человек так и не включил их.
 */
.push-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  font-size: 14px;
}

.push-banner svg {
  flex: none;
  color: var(--accent);
}

.push-text {
  flex: 1;
  min-width: 0;
}

.push-banner .btn {
  flex: none;
}

.push-close {
  flex: none;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}

.push-close:hover {
  color: var(--text);
}

@media (max-width: 520px) {
  /* На телефоне подпись переносится, а кнопка встаёт под неё: иначе строка выдавливает
     содержимое вбок — та же беда, из-за которой переделывали меню. */
  .push-banner {
    flex-wrap: wrap;
    margin: 10px 12px 0;
  }

  .push-text {
    flex: 1 1 100%;
    order: -1;
  }
}

/* --------------------------------------------------------------- номера изделий */

/*
 * Форма «Номера»: по блоку на изделие. Блоки разделены линией, а не карточками:
 * их бывает десять и больше, и десять карточек в окне превращаются в лестницу.
 */
.serial-unit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.serial-unit:first-of-type {
  border-top: 0;
}

.serial-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* «Кто делал» — подпись, а не заголовок: ОТК смотрит на неё краем глаза. */
.serial-made {
  font-size: 13px;
  color: var(--muted);
}

/* Свёрнутые блоки карточки заказа — расчёт доставки и обезжиривание. Заказ открывают ради содержимого,
   а не ради перевозки, поэтому по умолчанию он занимает одну строку. Раскрытый —
   отделяется рамкой, чтобы поля расчёта не смешались с полями заказа. */
.delivery-quote,
.fold-block {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-2);
}

.delivery-quote > summary,
.fold-block > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.delivery-quote > summary::-webkit-details-marker,
.fold-block > summary::-webkit-details-marker {
  display: none;
}

/* Свой треугольник: встроенный маркер в разных браузерах выглядит по-разному, а этот
   одинаков и поворачивается вместе с блоком. */
.delivery-quote > summary::before,
.fold-block > summary::before {
  content: '▸';
  display: inline-block;
  width: 16px;
  color: var(--muted);
}

.delivery-quote[open] > summary::before,
.fold-block[open] > summary::before {
  content: '▾';
}

.delivery-quote[open] > summary,
.fold-block[open] > summary {
  margin-bottom: 4px;
}

/* Галочка в форме. `input()` рисует «подпись сверху, поле снизу» — для флажка это даёт
   большой пустой квадрат во всю ширину. Здесь они встают в строку, флажком вперёд. */
.input.input-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.input.input-check input[type='checkbox'] {
  order: -1;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent, currentColor);
}

/* Переписка по заказу. Лента растёт вниз, как любой разговор, и ограничена по высоте:
   иначе сотня сообщений вытолкнула бы состав заказа за нижний край окна. Сообщение
   нельзя ни изменить, ни удалить — поэтому в ленте нет ни кнопок, ни меню. */
.comments .feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.feed-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feed-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.feed-author {
  font-weight: 600;
}

/* Время — справа и мелко: в разговоре важно, кто и что сказал, а не в какую минуту. */
.feed-time {
  margin-left: auto;
  white-space: nowrap;
}

/* Перенос по словам и сохранённые переводы строк: люди пишут списками и в столбик. */
.feed-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comments .form {
  margin-top: 10px;
}

/* Значок «по заказу идёт разговор» в строке списка: значок и число, без слов. */
.comments-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.comments-badge .icon {
  flex: 0 0 auto;
}

/* Строка разговора в списке: значок и последняя реплика.
   Текст обычного цвета, а не приглушённого: рядом в ячейке и без того хватает серых
   подробностей, а сообщение — то, ради чего строку читают. Три строки и многоточие:
   вопрос «на каком этапе? сроки горят» помещается целиком даже в узкой колонке, а
   длинный ответ не растягивает таблицу — его видно в подсказке и в карточке. */
.last-comment {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 5px;
  font-size: 13px;
  color: var(--text);
}

.last-comment .icon {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--accent);
}

.last-comment-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

/* Отметка ожидания в карточке заказа: метка и кнопка «Дождались» в одну строку. */
.mark-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.fold-block h4 {
  margin: 12px 0 6px;
}
