* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: clip;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-ui);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  min-width: 0;
}

button {
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
}

summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  cursor: pointer;
}

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

:is(a, button, input, select, textarea, summary):focus-visible {
  outline: 0;
  box-shadow: var(--focus);
}

#app,
.app-shell,
.main,
.panel,
.form-panel,
.table-wrap,
.receive-shell,
.receive-card,
.instruction-card,
.instruction-row {
  min-width: 0;
}

b,
strong,
p,
span,
td,
th,
button,
a,
input,
select,
textarea {
  overflow-wrap: anywhere;
}

.boot {
  display: grid;
  min-height: 100vh;
  gap: 16px;
  place-items: center;
  place-content: center;
}

.boot-mark {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0;
}

.boot-line {
  width: 180px;
  height: 4px;
  background: linear-gradient(90deg, var(--steel), var(--signal), var(--green));
}

.boot-fallback {
  padding: 24px;
}

.boot-fallback-card {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.boot-fallback-card .boot-mark {
  margin-bottom: 20px;
}

.boot-fallback-card h1 {
  margin: 0 0 12px;
  font-size: 24px;
  line-height: 1.15;
}

.boot-fallback-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.boot-fallback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.boot-fallback-actions button {
  border: 0;
  padding: 0 18px;
  background: var(--signal);
  color: var(--ink);
  font-weight: 800;
}

.boot-fallback-actions button + button {
  border: 1px solid var(--line);
  background: var(--panel-2);
}

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

.login-panel {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.brand {
  margin-bottom: 42px;
}

.login-panel h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
}

.login-panel p {
  max-width: 36rem;
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.55;
}

.login-art {
  position: relative;
  display: flex;
  min-height: 100vh;
  align-items: stretch;
  overflow: hidden;
  background: var(--ink-solid-bg);
  color: var(--ink-solid-ink);
}

.yard-map {
  position: absolute;
  inset: 0;
  opacity: .74;
  background:
    linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px) 0 0 / 54px 54px,
    linear-gradient(0deg, rgba(255,255,255,.1) 1px, transparent 1px) 0 0 / 54px 54px,
    radial-gradient(circle at 18% 28%, rgba(217,155,43,.36), transparent 18%),
    radial-gradient(circle at 82% 68%, rgba(40,115,95,.36), transparent 24%),
    linear-gradient(140deg, #10202f, #1b3345 55%, #26394a);
}

.route-rails {
  position: absolute;
  inset: 12% -10% auto 10%;
  height: 72%;
  border-left: 10px solid rgba(255,255,255,.26);
  border-bottom: 10px solid rgba(255,255,255,.26);
  transform: skewX(-12deg);
}

.route-rails::before,
.route-rails::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  background: var(--signal);
  border: 5px solid white;
  border-radius: 50%;
}

.route-rails::before {
  left: -16px;
  top: -8px;
}

.route-rails::after {
  right: 5%;
  bottom: -16px;
  background: var(--green);
}

.login-status {
  position: relative;
  align-self: flex-end;
  width: min(520px, calc(100% - 64px));
  margin: auto 32px 32px auto;
  padding: 28px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(16, 32, 47, .74);
  backdrop-filter: blur(10px);
}

.login-status h2 {
  margin: 0 0 18px;
  font-size: 24px;
}

.status-track {
  display: grid;
  gap: 12px;
}

.track-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) minmax(0, auto);
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,.16);
}

.track-row span {
  color: rgba(255,255,255,.72);
}

.track-row b {
  font-weight: 700;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 22px;
  color: white;
  background: var(--ink);
}

.sidebar .brand {
  margin-bottom: 30px;
}

.user-plate {
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  border-radius: var(--radius);
}

.user-plate b {
  display: block;
  margin-bottom: 4px;
}

.user-plate span {
  color: rgba(255,255,255,.68);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button,
.theme-toggle,
.logout {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: rgba(255,255,255,.78);
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 6px;
}

.nav button:hover,
.theme-toggle:hover,
.logout:hover {
  color: white;
  background: rgba(255,255,255,.1);
}

/* Активный пункт меню: золотая левая полоса 3px + золотой текст */
.nav button.active {
  color: var(--accent);
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}

.theme-toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.theme-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

[data-theme-icon="moon"] .theme-icon {
  background: var(--steel);
  box-shadow: inset -6px 0 0 var(--surface);
}

[data-theme-icon="sun"] .theme-icon {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 24%, transparent);
}

.logout {
  margin-top: auto;
}

.mobile-appbar,
.menu-backdrop,
.menu-toggle {
  display: none;
}

.main {
  min-width: 0;
  width: 100%;
  max-width: 2160px;
  margin-inline: auto;
  padding: 28px clamp(20px, 2.4vw, 48px);
}

.topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topline h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.08;
}

.topline p {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.toolbar,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
.filters .field { flex: 0 1 200px; min-width: 140px; }
.filters .field input, .filters .field select { min-height: 42px; }

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Дашборд: слева таблица (нужна ширина), справа столбики распределения */
@media (min-width: 1100px) {
  .dash-grid.grid.two { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
}

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

.stat-card,
.panel,
.table-wrap,
.form-panel,
.object-card,
.supplier-card,
.user-card,
.notice-card,
.instruction-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.stat-card {
  min-height: 116px;
  padding: 16px;
  text-align: left;
}

.stat-card b {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.stat-card strong {
  display: block;
  font-size: 34px;
  line-height: 1;
}

.stat-card span {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.stat-card.warning {
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
}

.stat-card.danger {
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
}

.panel,
.form-panel {
  padding: 18px;
}

.panel h2,
.form-panel h2,
.table-wrap h2,
.instruction-card h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.instruction-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.instruction-card {
  padding: 18px;
  min-width: 0;
  overflow: hidden;
}

.instruction-lead {
  max-width: 880px;
  margin: -4px 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

.instruction-shot {
  margin: 0 0 14px;
  min-width: 0;
}

.instruction-shot img {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  object-position: top left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.instruction-shot figcaption {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.instruction-rows {
  display: grid;
  gap: 8px;
}

.instruction-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .9fr);
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--steel-soft);
  border-radius: 6px;
  background: var(--surface);
  overflow-wrap: anywhere;
}

.instruction-row b {
  font-weight: 750;
}

.instruction-row div:last-child {
  color: var(--muted);
}

.report-stats {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-top: 16px;
}

.report-layout {
  margin-top: 16px;
}

.digest-panel pre {
  max-width: 100%;
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--steel-soft);
  border-radius: 6px;
  white-space: pre-wrap;
}

.report-group {
  display: grid;
  gap: 8px;
  margin: 8px 0 18px;
}

.report-group-row {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--steel-soft);
  border-radius: 6px;
}

.report-group-row span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.readiness-panel {
  margin-top: 16px;
}

.readiness-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.readiness-card.ready {
  border-color: color-mix(in srgb, var(--success) 36%, transparent);
}

.readiness-card.blocked {
  border-color: color-mix(in srgb, var(--danger) 34%, transparent);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.form-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
/* «Новый груз»: верхние поля (объект/поставщик/дата/приёмка) чуть шире, чтобы длинные названия были видны; при нехватке места ряд переносится (без гориз. прокрутки). */
.form-grid.compact[data-form="quick-shipment"] {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field span,
.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  min-width: 0;
  width: 100%;
  min-height: 44px;
  padding: 10px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px rgba(201, 138, 34, .30);
}

.btn {
  display: inline-flex;
  min-height: 44px;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--ink-solid-ink);
  background: var(--ink-solid-bg);
  border: 1px solid color-mix(in srgb, var(--ink-solid-ink) 16%, var(--ink-solid-bg));
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
}

.btn.secondary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line-strong);
}

.btn.signal {
  color: var(--accent-ink);
  background: var(--signal);
  border-color: var(--signal);
}

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

.btn.secondary:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong));
}

.btn.danger {
  color: #ffffff;
  background: var(--red);
  border-color: var(--red);
}

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

.ref-cell,
.shipment-title {
  display: inline-flex;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.ref-open {
  flex: 1 1 44px;
  min-width: 44px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-ref {
  display: inline-flex;
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.table-wrap {
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

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

th {
  color: var(--muted);
  background: var(--surface-3);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

/* Подсветка при наведении — только у кликабельных строк и только там, где есть курсор (на тач «залипает»). */
@media (hover: hover) {
  tr[data-open-shipment]:hover td {
    background: color-mix(in srgb, var(--surface-2) 45%, var(--surface));
  }
}

.status {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 3px 9px;
  color: var(--steel);
  background: var(--steel-soft);
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow-wrap: normal;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.status.received {
  color: var(--success);
  background: var(--success-bg);
}

.status.sent {
  color: var(--info);
  background: var(--info-bg);
}

.status.in_transit {
  color: var(--steel);
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.status.partially_received {
  color: var(--warning);
  background: var(--warning-bg);
}

.status.problem,
.status.overdue,
.status.missing,
.status.damaged {
  color: var(--danger);
  background: var(--danger-bg);
}

.status.overdue::before {
  border-radius: 2px;
}

.status.missing::before {
  border-radius: 0;
  transform: rotate(45deg);
}

.status.damaged::before {
  width: 10px;
  height: 10px;
  background:
    linear-gradient(135deg, transparent 43%, currentColor 45% 55%, transparent 57%),
    color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 2px;
}

.status.created,
.status.cancelled,
.status.expected,
.status.extra,
.status.neutral {
  color: var(--neutral);
  background: var(--neutral-bg);
}

/* «Отменено» отличается от прочих нейтральных не только текстом */
.status.cancelled {
  text-decoration: line-through;
}

.status.cancelled::before {
  width: 8px;
  height: 2px;
  border-radius: 0;
}

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

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  background: var(--surface);
  border-radius: var(--radius);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(360px, .9fr);
  gap: 16px;
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.detail-head > div:first-child {
  flex: 1 1 220px;
  min-width: 0;
}

.detail-head .toolbar {
  flex: 0 1 auto;
}

.detail-head h2 {
  margin: 0 0 6px;
  font-size: 24px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 18px;
}

.meta {
  min-height: 68px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 6px;
}

.meta span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.integration-origin {
  display: grid;
  gap: 3px;
  margin: -4px 0 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--steel);
  border-radius: 6px;
  background: var(--surface-2);
}

.integration-origin span {
  color: var(--muted);
}

.integration-audit {
  margin-top: 8px;
}

.integration-audit summary {
  min-height: 44px;
  color: var(--ink-2);
}

.audit-grid {
  display: grid;
  gap: 8px;
  padding-top: 8px;
}

.audit-grid div {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--steel) 14%, transparent);
  border-radius: 6px;
}

.audit-grid code {
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.part-list {
  display: grid;
  gap: 10px;
}

.part-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.print-page {
  background: var(--paper);
}

.print-main {
  padding: 24px;
}

.print-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 18px;
}

.print-brand {
  margin-bottom: 16px;
}

.qr-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  page-break-inside: avoid;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
}

.qr-label img {
  display: block;
  width: 130px;
  height: 130px;
}

.qr-label .qr-name {
  font-size: 12px;
  line-height: 1.25;
  font-weight: 700;
  overflow-wrap: break-word;
}

.qr-label .qr-qty {
  font-size: 11px;
  font-weight: 700;
  overflow-wrap: break-word;
}

.qr-label .qr-code {
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: break-word;
}

.qr-label .qr-obj {
  font-size: 10px;
  color: var(--muted);
  overflow-wrap: break-word;
}

.timeline {
  display: grid;
  gap: 10px;
}

.event {
  padding: 12px;
  border-left: 4px solid var(--steel);
  background: var(--surface-2);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 12px;
}

.object-card,
.supplier-card,
.user-card,
.notice-card {
  padding: 16px;
}

/* Единый порядок карточек (объекты/поставщики/пользователи): заголовок сверху, низ прижат к одной линии, кнопки в ряд во всю ширину */
.object-card, .supplier-card, .user-card { display: flex; flex-direction: column; }
.object-card-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.object-card-resp { display: flex; flex-direction: column; }
.card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-actions .btn { width: 100%; margin: 0; }
.supplier-card .card-actions { margin-top: auto; padding-top: 10px; }
.user-card > .user-edit { margin-top: auto; }
.notice-card { display: flex; flex-direction: column; }
.notice-card .card-actions { margin-top: auto; padding-top: 10px; }
.notice-head { min-width: 0; }
.notice-body { margin: 6px 0 2px; }
.badge-new { font-size: 11px; font-weight: 700; color: var(--info); white-space: nowrap; }
.badge-new::before { content: "\2022"; margin-right: 3px; }
.badge-new.danger { color: var(--danger); }
.badge-new.warning { color: var(--warning); }
.delivery-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.delivery-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--neutral-bg);
  color: var(--neutral);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.delivery-chip.ok { color: var(--success); background: var(--success-bg); border-color: transparent; }
.delivery-chip.bad { color: var(--danger); background: var(--danger-bg); border-color: transparent; }

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.check-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.check-item {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 4px 0;
  color: var(--ink);
}

.check-item input {
  width: auto;
  min-height: auto;
}

.receive-screen {
  min-height: 100vh;
  background: var(--bg);
}

.receive-shell {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 18px;
}

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

.receive-card h1 {
  margin: 0 0 10px;
  font-size: 28px;
}

.receive-meta {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 6px;
}

.radio-grid {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.radio-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  min-height: 60px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 800;
}

.radio-card input {
  width: 22px;
  height: 22px;
  min-height: 22px;
}

.radio-card:has(input:checked) {
  border-color: var(--signal);
  background: var(--warning-bg);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 36px));
}

.toast-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: space-between;
  padding: 12px 14px;
  color: var(--ink-solid-ink);
  background: var(--ink-solid-bg);
  border: 1px solid color-mix(in srgb, var(--ink-solid-ink) 16%, var(--ink-solid-bg));
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.toast-item.error {
  color: #ffffff;
  background: var(--red);
  border-color: var(--red);
}

.toast-close {
  flex: 0 0 auto;
  min-width: 32px;
  min-height: 32px;
  margin: -4px -6px -4px 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  opacity: .8;
}

.toast-close:hover {
  opacity: 1;
}

.network-badge {
  display: none !important;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 55;
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 7px 10px;
  color: var(--success);
  background: var(--success-bg);
  border: 1px solid color-mix(in srgb, var(--success) 36%, transparent);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
}

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

.delivery-list,
.receipt-history,
.correction-panel {
  margin-top: 14px;
}

.delivery-list {
  display: grid;
  gap: 8px;
}

.delivery-row {
  display: grid;
  grid-template-columns: minmax(100px, .7fr) minmax(110px, .8fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 10px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--steel-soft);
  border-radius: 6px;
  font-size: 13px;
}

.delivery-row b,
.delivery-row span {
  min-width: 0;
}

.delivery-row em {
  grid-column: 1 / -1;
  color: var(--muted);
  font-style: normal;
}

.correction-panel {
  padding: 14px;
  background: var(--warning-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 48%, transparent);
  border-radius: 6px;
}

.form-panel .form-grid .btn,
.correction-panel .btn,
.receive-card form .btn {
  justify-self: start;
}

.login-panel .btn {
  min-height: 48px;
}

.login-sso {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.login-sso-divider {
  position: relative;
  text-align: center;
  font-size: .85rem;
  color: var(--muted, #8a8f98);
}

.login-sso-divider::before,
.login-sso-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 22px);
  height: 1px;
  background: var(--line-strong, rgba(128, 128, 128, .3));
}

.login-sso-divider::before { left: 0; }
.login-sso-divider::after { right: 0; }

@media (max-width: 1280px) {
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .grid.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  body {
    background: var(--paper);
  }

  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-panel {
    min-height: auto;
    padding: 28px 18px;
  }

  .login-art {
    min-height: 340px;
  }

  .route-rails {
    inset: 14% 12% auto 14%;
    height: 62%;
  }

  .login-status {
    width: calc(100% - 32px);
    margin: auto 16px 16px;
    padding: 18px;
  }

  .track-row {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .track-row em {
    grid-column: 2;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  body.menu-lock {
    overflow: hidden;
  }

  .mobile-appbar {
    position: fixed;
    z-index: 55;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    height: 66px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow-sm);
  }

  .mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  .menu-toggle {
    position: relative;
    display: block;
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    padding: 0;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--ink-solid-ink) 16%, var(--ink-solid-bg));
    border-radius: 8px;
    background: var(--ink-solid-bg);
    box-shadow: var(--shadow-pop);
  }

  .menu-toggle span {
    position: absolute;
    right: 12px;
    display: block;
    height: 2px;
    background: var(--ink-solid-ink);
    border-radius: 999px;
    transform-origin: center;
    transition:
      top .22s ease,
      width .22s ease,
      opacity .18s ease,
      transform .28s cubic-bezier(.2, .8, .2, 1);
  }

  .menu-toggle span:nth-child(1) {
    top: 15px;
    width: 24px;
  }

  .menu-toggle span:nth-child(2) {
    top: 23px;
    width: 17px;
  }

  .menu-toggle span:nth-child(3) {
    top: 31px;
    width: 24px;
  }

  .menu-open .menu-toggle span:nth-child(1) {
    top: 23px;
    transform: rotate(45deg);
  }

  .menu-open .menu-toggle span:nth-child(2) {
    width: 0;
    opacity: 0;
    transform: translateX(10px);
  }

  .menu-open .menu-toggle span:nth-child(3) {
    top: 23px;
    transform: rotate(-45deg);
  }

  .menu-backdrop {
    position: fixed;
    z-index: 40;
    inset: 0;
    display: block;
    pointer-events: none;
    background: rgba(16, 32, 47, .38);
    opacity: 0;
    transition: opacity .24s ease;
  }

  .menu-open .menu-backdrop {
    pointer-events: auto;
    opacity: 1;
  }

  .sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(324px, calc(100vw - 28px));
    height: 100dvh;
    padding: 86px 16px 16px;
    border-left: 1px solid rgba(255,255,255,.12);
    box-shadow: -22px 0 44px rgba(16,32,47,.24);
    transform: translateX(calc(100% + 28px));
    visibility: hidden;
    pointer-events: none;
    transition:
      transform .3s cubic-bezier(.2, .8, .2, 1),
      visibility 0s linear .3s;
  }

  .menu-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition:
      transform .3s cubic-bezier(.2, .8, .2, 1),
      visibility 0s;
  }

  .sidebar .brand {
    display: none;
  }

  .user-plate {
    display: block;
    margin-bottom: 14px;
  }

  .nav {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .nav button {
    min-width: 0;
    min-height: 48px;
    padding: 11px 13px;
    text-align: left;
    font-size: 14px;
    line-height: 1.2;
  }

  .theme-toggle,
  .logout {
    min-height: 48px;
    padding: 11px 13px;
    text-align: left;
    font-size: 14px;
  }

  .logout {
    margin-top: auto;
  }

  .main {
    padding: 84px 14px 24px;
  }

  .topline {
    display: grid;
  }

  .form-grid,
  .form-grid.compact,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .instruction-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .table-wrap {
    overflow-x: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tr {
    margin-bottom: 10px;
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
  }

  .data-table td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }

  .data-table td:last-child {
    border-bottom: 0;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .part-row {
    grid-template-columns: 1fr;
  }

  .card-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .receive-shell {
    padding: 14px;
  }

  .receive-card {
    padding: 16px;
  }

  .radio-card {
    min-height: 60px;
  }
}

@media (max-width: 1100px) {
  .delivery-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .btn,
  input,
  select,
  textarea {
    min-height: 48px;
  }

  .form-panel .form-grid .btn,
  .correction-panel .btn,
  .receive-card form .btn {
    justify-self: stretch;
  }

  .delivery-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: white;
  }

  .no-print {
    display: none !important;
  }

  .qr-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.mt-4 {
  margin-top: var(--space-4);
}

.mini-bar {
  height: 8px;
  margin-top: 6px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
}

.mini-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
}

[data-theme="dark"] .mobile-appbar {
  border-color: var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}

[data-theme="dark"] .instruction-row,
[data-theme="dark"] .digest-panel pre,
[data-theme="dark"] .report-group-row,
[data-theme="dark"] .event,
[data-theme="dark"] .qr-label,
[data-theme="dark"] .empty {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--line);
}

[data-theme="dark"] .btn.danger {
  color: var(--accent-ink);
}

[data-theme="dark"] th {
  background: var(--surface-2);
}

[data-theme="dark"] td,
[data-theme="dark"] th {
  border-color: var(--line);
}

/* Сайдбар в тёмной теме — графит (#10202F), всегда тёмный */
[data-theme="dark"] .sidebar {
  color: var(--sidebar-text, #CBD3DB);
  background: var(--ink-solid-bg);
  border-right: 1px solid color-mix(in srgb, #ffffff 8%, transparent);
}

[data-theme="dark"] .nav button,
[data-theme="dark"] .theme-toggle,
[data-theme="dark"] .logout {
  color: var(--sidebar-text, #CBD3DB);
}

[data-theme="dark"] .nav button:hover,
[data-theme="dark"] .theme-toggle:hover,
[data-theme="dark"] .logout:hover {
  color: #ffffff;
  background: rgba(255,255,255,.08);
}

/* Активный пункт меню — золотой и в тёмной теме */
[data-theme="dark"] .nav button.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* --- Упрощённый интерфейс для не-технических пользователей (2026-06-30) --- */
.nav-main { font-size: 1.06rem; font-weight: 700; }
.nav-more { margin-top: 6px; }
.nav-more > summary { cursor: pointer; list-style: none; padding: 10px 14px; opacity: .9; font-weight: 600; border-radius: 10px; }
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary { gap: 10px; }
.nav-more > summary::after { content: "▸"; margin-left: auto; font-size: 12px; opacity: .55; }
.nav-more[open] > summary::after { content: "▾"; }
.nav-more > button { display: block; width: 100%; }

.new-cargo h2 { margin-bottom: 4px; }
.invoice-import { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; padding: 12px 14px; border: 1.5px dashed var(--line); border-radius: 12px; transition: border-color .15s, background .15s; }
.invoice-import.dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.invoice-drop-hint { font-size: 13px; }
.invoice-import .invoice-status { font-size: 13px; }
.cargo-rows { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.cargo-row { display: flex; gap: 8px; }
.cargo-row input:first-child { flex: 1; min-width: 0; }
.cargo-row input[name="cargoQty"] { width: 92px; flex: none; }
.cargo-row input[name="cargoUnit"] { width: 78px; flex: none; }
.more-fields { margin-top: 8px; }
.more-fields > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.btn-hero { font-size: 1.15rem; font-weight: 700; padding: 16px 22px; margin-top: 8px; }
.btn.full, button.btn.full { width: 100%; grid-column: 1 / -1; }
.more-fields.full { grid-column: 1 / -1; }

/* --- Переключатель проектов (2026-06-30) --- */
.proj-switch { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 12px; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.06); }
.proj-switch .proj-link { display: block; padding: 8px 12px; border-radius: 9px; color: inherit; text-decoration: none; font-size: 14px; opacity: .85; }
.proj-switch .proj-link:hover { background: rgba(255,255,255,.10); opacity: 1; }
.proj-switch .proj-link.active { background: rgba(217,155,43,.20); opacity: 1; font-weight: 700; cursor: default; }
.proj-switch .proj-link.all { opacity: .65; font-size: 13px; }

/* --- Единый низ сайдбара: тема · инструкция · настройки (выход внутри) 2026-06-30 --- */
.sidebar-bottom { margin-top: auto; display: grid; gap: 6px; }
.sidebar-bottom .theme-toggle { margin-top: 0; }
.nav-bottom {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: rgba(255, 255, 255, .78);
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.nav-bottom:hover { color: #fff; background: rgba(255, 255, 255, .1); }
[data-theme="dark"] .nav-bottom { color: var(--sidebar-text, #CBD3DB); }
[data-theme="dark"] .nav-bottom:hover { color: #fff; background: rgba(255, 255, 255, .08); }

/* === ОБЩИЙ ВЕРХНИЙ ХЕДЕР (по макету «Тёплый профессионал») 2026-06-30 === */
.proj-switch { display: none !important; }   /* переключатель переехал в хедер */
.app-shell { grid-template-rows: auto minmax(0, 1fr); }
.topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 11px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar .wordmark { font-size: 18px; white-space: nowrap; }
.topbar .menu-toggle { display: none; }
.tabs { display: flex; gap: 6px; margin-left: 6px; flex-wrap: wrap; }
.tabs .tab {
  font: inherit; font-size: 13px; font-weight: 500;
  color: var(--muted); background: transparent;
  border: 1px solid transparent; border-radius: 999px;
  padding: 7px 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.tabs .tab:hover { background: var(--surface-2); color: var(--text); }
.tabs .tab.active {
  color: var(--accent-ink); background: var(--accent);
  border-color: var(--accent); font-weight: 600;
}
.tabs .tab.tab-all { opacity: .82; }
.topbar .spacer { flex: 1; }
.topbar .icon-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 13px; color: var(--muted);
  background: transparent; border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.topbar .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.topbar .icon-btn.notif-bell { position: relative; border: 0; background: transparent; padding: 4px; }
.topbar .icon-btn.notif-bell:hover { background: transparent; color: var(--text); }
.topbar .icon-btn.notif-bell .nav-ic { width: 20px; height: 20px; }
.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
}
.topbar .icon-btn .theme-icon { width: 16px; height: 16px; }

/* Десктоп: фикс-вьюпорт — хедер сверху, сайдбар и контент скроллятся независимо */
@media (min-width: 821px) {
  .app-shell { height: 100vh; }
  .app-shell > .sidebar { grid-row: 2; grid-column: 1; position: static; top: auto; height: auto; min-height: 0; overflow: auto; }
  .app-shell > .main { grid-row: 2; grid-column: 2; min-height: 0; overflow: auto; justify-self: stretch; }
}

/* Мобайл: хедер фиксированный сверху, гамбургер виден, табы скроллятся */
@media (max-width: 820px) {
  .topbar {
    position: fixed; left: 0; right: 0; top: 0; z-index: 60;
    flex-wrap: nowrap; gap: 10px; padding: 9px 12px;
    backdrop-filter: blur(14px);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
  }
  .topbar .menu-toggle { display: block; order: -1; position: relative; width: 30px; height: 22px; flex: none; background: transparent; border: 0; }
  .topbar .wordmark { font-size: 16px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-left: 2px; }
  .tabs::-webkit-scrollbar { display: none; }
  .topbar .icon-btn .theme-toggle-label { display: none; }
  .main { padding-top: 70px; }
  .topbar { background: var(--chrome-bg); }
}

/* ===== ЕДИНЫЙ ДИЗАЙН — доводка (итерация 3, 2026-06-30) ===== */
/* «Синяя» графит-поверхность: верхнее меню = боковое. Светлая тема — чуть светлее, тёмная — как сейчас. */
:root, [data-theme="light"] { --chrome-bg: #1A3651; }
[data-theme="dark"] { --chrome-bg: #10202F; }

.sidebar { background: var(--chrome-bg) !important; }
[data-theme="dark"] .sidebar { background: var(--chrome-bg) !important; }
.topbar { background: var(--chrome-bg); border-bottom: 1px solid rgba(255,255,255,.08); color: rgba(255,255,255,.82); }

/* Хедер на синем: словомарк в одну линию, светлый текст, gold-пилюля активного */
.topbar .wordmark { display: inline-flex; align-items: baseline; gap: 7px; line-height: 1; }
.topbar .wordmark-name { color: #fff; }
.topbar .wordmark-suffix { color: rgba(255,255,255,.62); }
.topbar .tabs .tab { color: rgba(255,255,255,.72); }
.topbar .tabs .tab:hover { background: rgba(255,255,255,.10); color: #fff; }
.topbar .tabs .tab.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.topbar .icon-btn { color: rgba(255,255,255,.82); border-color: rgba(255,255,255,.18); }
.topbar .icon-btn:hover { background: rgba(255,255,255,.10); color: #fff; }

/* === Переключатель ПО ЦЕНТРУ хедера + полная пилюля + размер бок.меню как в AI-агенте (итерация 4) === */
.topbar .tabs {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin-left: 0;
}
.topbar .tabs .tab { border-radius: 999px !important; }
.nav button, .nav-more summary, .nav-more button { font-size: 15px; }
@media (max-width: 820px) {
  .topbar .tabs { position: static; transform: none; left: auto; top: auto; }
}


/* === Иконки бокового меню (Tabler, инлайн SVG) — итерация 5 === */
.nav-main, .nav-more > button, .sidebar-bottom .nav-bottom { display: flex; align-items: center; gap: 10px; }
.nav-ic { width: 18px; height: 18px; flex: 0 0 auto; }
.nav .nav-tx, .sidebar-bottom .nav-tx { min-width: 0; }


/* === Табы: одинаковая высота и центр текста (anchor == button) — итерация 6 === */
.topbar .tabs { align-items: center; }
.topbar .tabs .tab {
  min-height: 0 !important;
  min-width: 0 !important;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}


/* Кнопка темы в хедере — как таб-пилюли: текст, та же высота (~29px), ровная круглая обводка (итерация 7) */
.topbar .icon-btn {
  min-height: 0 !important;
  min-width: 0 !important;
  height: auto;
  padding: 7px 14px;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, .22) !important;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  font-size: 13px;
}


/* Светлая тема: кнопка переключения темы «загорается» жёлтым (итерация 9) */
[data-theme="light"] .topbar .icon-btn {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: var(--accent-ink) !important;
}
[data-theme="light"] .topbar .icon-btn:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
}
/* Edge-gap аудит (итерация 11): на узких десктопах (821-~1050px) центральные табы могли налезать
   на словомарк/кнопку темы. СОХРАНЯЕМ точное центрирование (absolute+translateX), но кепим ширину
   группы и разрешаем внутренний скролл — вместо наезда группа ужимается. */
@media (min-width: 821px) {
  .topbar .tabs { max-width: calc(100% - 420px); overflow-x: auto; overflow-y: hidden; }
  .topbar .tabs::-webkit-scrollbar { display: none; }
}

/* Кликабельная строка «Требует внимания» на дашборде → открывает карточку поставки */
.attention-table .attention-row { cursor: pointer; }
/* Любая строка-ссылка на карточку поставки: курсор и подсветка, чтобы было видно, что она кликабельна. */
.data-table tr[data-open-shipment] { cursor: pointer; }
@media (hover: hover) {
  .attention-table .attention-row:hover td { background: var(--surface-2); }
  .data-table tr[data-open-shipment]:hover td { background: var(--surface-2); }
}

/* «Требует внимания»: всё по одной линии, номер поставки — обычный текст без рамки */
.attention-table td { vertical-align: middle; }
.attention-table .attention-num { font-weight: 700; color: var(--text); overflow-wrap: anywhere; }

/* Реестровые таблицы на широких экранах: ширина колонок по содержимому.
   При нехватке места таблица прокручивается внутри своей карточки, а номер
   поставки, дата и статус не обрезаются и не рвутся по слогам. */
.attention-scroll { min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain; }
@media (min-width: 821px) {
  .attention-scroll .attention-table,
  .attention-scroll .report-table,
  .table-wrap .data-table {
    table-layout: auto;
    width: max-content;
    min-width: 100%;
  }
  .table-wrap .data-table td,
  .attention-scroll .data-table td { overflow-wrap: normal; word-break: normal; }
  .attention-scroll .attention-num,
  .data-table .attention-num,
  .data-table .ref-cell,
  .data-table .status,
  .data-table th { white-space: nowrap; }
  .data-table .ref-open { overflow: visible; text-overflow: clip; }
}

/* ЕДИНЫЙ СТИЛЬ ТАБЛИЦ (весь сайт): номера без рамок, кликабельные строки, ровное выравнивание */
.data-table td { vertical-align: middle; }
.data-table tbody tr[data-open-shipment] { cursor: pointer; }
@media (hover: hover) {
  .data-table tbody tr[data-open-shipment]:hover td { background: var(--surface-2); }
}
.ref-cell { display: inline-flex; align-items: center; gap: 6px; width: auto; max-width: 100%; }
.ref-open { flex: 0 1 auto; width: auto; min-width: 0; min-height: 0; border: 0; background: transparent; box-shadow: none; padding: 0; margin: 0; font: inherit; font-weight: 700; color: var(--text); text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref-open:hover { text-decoration: underline; }
.copy-ref { flex: 0 0 auto; width: auto; min-width: 0; min-height: 0; height: auto; border: 0; background: transparent; box-shadow: none; padding: 0 2px; color: var(--muted); cursor: pointer; font-size: 12px; line-height: 1; }
.copy-ref:hover { color: var(--text); background: transparent; }

/* Мобильные (фикс-шапка): при прокрутке к карточке поставки оставляем зазор под шапку. */
@media (max-width: 820px) {
  #shipment-detail { scroll-margin-top: 82px; }
}

/* ================= МОБИЛЬНАЯ ШАПКА: единый вид экосистемы (2026-07-06) ================= */
/* На десктопе переключатель проектов живёт в шапке, drawer-версия скрыта. */
.drawer-tabs { display: none; }

@media (max-width: 820px) {
  /* 1. Табы из шапки убираем: на телефоне они сжимались в кашу («бжо…») и наезжали на колокольчик.
        Переключатель проектов теперь в бургер-меню. */
  .topbar .tabs { display: none; }

  /* 2. Кнопка темы: возвращаем подпись (раньше схлопывалась в пустую пилюлю без текста). */
  .topbar .icon-btn .theme-toggle-label { display: inline; }

  /* 3. Бургер: геометрия полосок под фактическую кнопку 30x22 (легаси-координаты были под 48px). */
  .topbar .menu-toggle span { right: 3px; }
  .menu-toggle span:nth-child(1) { top: 2px; width: 24px; }
  .menu-toggle span:nth-child(2) { top: 10px; width: 17px; }
  .menu-toggle span:nth-child(3) { top: 18px; width: 24px; }
  .menu-open .menu-toggle span:nth-child(1) { top: 10px; transform: rotate(45deg); }
  .menu-open .menu-toggle span:nth-child(2) { width: 0; opacity: 0; transform: translateX(10px); }
  .menu-open .menu-toggle span:nth-child(3) { top: 10px; transform: rotate(-45deg); }

  /* 4. Drawer выезжает СЛЕВА — как в Agent (раньше выезжал справа: разнобой). */
  .sidebar {
    left: 0;
    right: auto;
    border-left: 0;
    border-right: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 22px 0 44px rgba(16, 32, 47, .24);
    transform: translateX(calc(-100% - 28px));
  }
  .menu-open .sidebar { transform: translateX(0); }

  /* 5. Переключатель проектов в drawer: крупные пилюли на всю ширину, активная — золотая. */
  .drawer-tabs { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
  .drawer-tabs .tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
  }
  .drawer-tabs .tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
}

/* Совсем узкие экраны: прячем суффикс SUPPLY, чтобы шапка оставалась одной строкой. */
@media (max-width: 420px) {
  .topbar .wordmark-suffix { display: none; }
}

/* ============ БУРГЕР И ШАПКА: доводка под фактические 44x44 (2026-07-06) ============ */
@media (max-width: 820px) {
  /* Кнопка реально 44x44 (глобальный тап-таргет), легаси рисовало тень-«коробку» — чистим всё. */
  .topbar .menu-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: transparent !important;
    border: 0 !important;
    border-radius: 10px;
    box-shadow: none !important;
    overflow: visible;
  }
  .topbar .menu-toggle:focus,
  .topbar .menu-toggle:active {
    background: transparent !important;
    box-shadow: none !important;
    outline: none;
  }
  /* Полоски: по центру кнопки 44x44, тёпло-белые (как словомарк на синем хроме). */
  .topbar .menu-toggle span { right: 10px; background: #F2EBE0; }
  .menu-toggle span:nth-child(1) { top: 14px; width: 24px; }
  .menu-toggle span:nth-child(2) { top: 21px; width: 17px; }
  .menu-toggle span:nth-child(3) { top: 28px; width: 24px; }
  .menu-open .menu-toggle span:nth-child(1) { top: 21px; transform: rotate(45deg); }
  .menu-open .menu-toggle span:nth-child(2) { width: 0; opacity: 0; transform: translateX(10px); }
  .menu-open .menu-toggle span:nth-child(3) { top: 21px; transform: rotate(-45deg); }

  /* Вырез iPhone (чёлка/Dynamic Island): шапка и контент уважают safe-area. */
  .topbar { padding-top: calc(9px + env(safe-area-inset-top, 0px)); }
  .main { padding-top: calc(70px + env(safe-area-inset-top, 0px)); }
  .sidebar { padding-top: calc(86px + env(safe-area-inset-top, 0px)); }

  /* Закрытый drawer не должен светить тенью из-за края экрана. */
  .app-shell:not(.menu-open) .sidebar { box-shadow: none; }
}

/* ====== Переключатель проектов в бургер-меню: свёрнут в одну пилюлю (2026-07-06) ======
   Показан только ТЕКУЩИЙ проект; тап раскрывает список, выбор — сворачивает.
   Цвета фиксированные (не из темы): меню всегда тёмное, вид одинаков в светлой и тёмной теме. */
.proj-dd { display: none; }
@media (max-width: 820px) {
  .proj-dd { display: block !important; margin: 0 0 16px; }
  .proj-dd summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 11px 14px;
    border-radius: 10px;
    background: #D99B2B;
    color: #241A0E;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .proj-dd summary::-webkit-details-marker { display: none; }
  .proj-dd summary::marker { content: ""; }
  .proj-dd .dt-chev { font-size: 11px; line-height: 1; transition: transform .18s ease; }
  .proj-dd[open] .dt-chev { transform: rotate(180deg); }
  .proj-dd .dt-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
  .proj-dd .dt-list .tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 11px 14px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 10px;
    background: rgba(255, 255, 255, .07);
    color: #F2EBE0;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
  }
  .proj-dd .dt-list .tab.active { background: #D99B2B; border-color: #D99B2B; color: #241A0E; }
}

/* ====== Файлы поставки в карточке: список + «доприкрепить» (2026-07-06) ====== */
.ship-docs { display: flex; flex-direction: column; gap: 6px; }
.ship-doc { color: var(--text); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.ship-doc:hover { text-decoration: underline; }
.ship-doc .muted { font-weight: 400; }
.ship-doc-attach { align-items: center; gap: 10px; flex-wrap: wrap; }
.ship-doc-attach select { min-height: 42px; }

/* ====== СнабКонтроль ДЕМО: один сервис, без переключателя проектов ====== */
.topbar .tabs { display: none !important; }
.proj-dd { display: none !important; }
.topbar .wordmark-suffix { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 11px; letter-spacing: .08em; }
