:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #182027;
  --muted: #69747f;
  --line: #d9dee3;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --shadow: 0 12px 28px rgba(24, 32, 39, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button[data-apply-platform] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button[data-apply-platform="ozon"] {
  background: #1f6feb;
  border-color: #1f6feb;
}

button[data-apply-platform="all"] {
  background: #37424c;
  border-color: #37424c;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 19px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.topbar p,
.muted,
small {
  color: var(--muted);
}

.muted,
small {
  font-size: 11px;
  line-height: 1.3;
}

.tiny {
  font-size: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-width: 260px;
}

.source-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #e2e7eb;
  border-radius: 999px;
  background: #f8fafb;
  color: #56616c;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.actions button {
  padding: 7px 9px;
  font-size: 12px;
}

.bulk-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid #d3dce3;
  border-bottom: 0;
  background: #f8fafb;
}

.bulk-status {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-width: 0;
}

.bulk-status strong {
  font-size: 13px;
}

.bulk-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.bulk-controls button {
  padding: 6px 9px;
  font-size: 12px;
}

.bulk-controls [data-bulk-platform="ozon"] {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}

.bulk-controls [data-bulk-platform="wb"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.bulk-controls [data-bulk-platform="all"] {
  background: #37424c;
  border-color: #37424c;
  color: #fff;
}

.bulk-controls .amount-input {
  width: 72px;
}

.bulk-controls .bulk-off {
  background: #fdf3f2;
  border-color: #f1c7c2;
  color: var(--danger);
  font-weight: 700;
}

.bulk-controls .bulk-off:disabled {
  background: #fff;
  color: var(--muted);
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 14px 24px 24px;
}

.toolbar,
.panel,
.details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.journal-panel {
  display: block;
}

.mass-search-panel {
  max-width: 520px;
}

.journal-panel p {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

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

.journal-actions {
  display: flex;
  justify-content: flex-end;
}

.journal-actions button {
  min-width: 92px;
}

.journal-items {
  display: grid;
  gap: 7px;
}

.journal-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.journal-item strong,
.journal-item span,
.journal-item time {
  display: block;
}

.journal-item strong {
  font-size: 13px;
}

.journal-item span,
.journal-item time {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.journal-item time {
  text-align: right;
}

.journal-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

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

.journal-pager button:disabled {
  cursor: default;
  opacity: 0.45;
}

.backup-panel {
  display: block;
}

.backup-panel p {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.backup-actions {
  display: flex;
  justify-content: flex-end;
  margin: 10px 0;
}

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

.backup-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.backup-item strong,
.backup-item span,
.backup-item small {
  display: block;
}

.backup-item span {
  color: #37424c;
  font-size: 12px;
  margin-top: 2px;
}

.backup-buttons {
  display: flex;
  gap: 7px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  text-decoration: none;
  font-size: 13px;
}

.button-link:hover {
  border-color: var(--accent);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 18px 24px;
  background: rgba(24, 32, 39, 0.36);
}

.modal-panel {
  width: min(880px, 100%);
  max-height: calc(100vh - 80px);
  overflow: auto;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(24, 32, 39, 0.22);
}

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

.modal-head button {
  flex: 0 0 auto;
}

.has-modal {
  overflow: hidden;
}

.toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.toolbar input[type="search"] {
  flex: 1;
  min-width: 240px;
}

.toolbar #openMassSearch {
  flex: 0 0 auto;
}

.mass-search-panel textarea {
  width: 100%;
  min-height: 240px;
  resize: vertical;
  font: inherit;
}

.mass-search-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

input,
select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 9px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.panel {
  min-width: 0;
  overflow: hidden;
  padding: 12px;
  background: #f5f7f8;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid #d3dce3;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #fff;
}

.stock-edit {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stock-edit input[type="number"] {
  width: 110px;
}

.warehouses {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 9px 14px;
  margin-bottom: 10px;
  border: 1px solid #d3dce3;
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(24, 32, 39, 0.04);
}

.warehouse-block {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px;
  border: 1px solid #e5e9ed;
  border-radius: 8px;
  background: #fff;
}

.warehouse-title {
  font-size: 14px;
  line-height: 1;
}

.warehouse-title-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.warehouse-title-select input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.warehouse-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.warehouse-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  max-width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.warehouse-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.warehouse-check input {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.warehouse-check span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.warehouse-off {
  padding: 4px 7px;
  border-color: #fecaca;
  background: #fff7f7;
  color: #b91c1c;
  font-size: 12px;
  line-height: 1.1;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: #f8fafb;
}

th:nth-child(1) {
  width: 20%;
}

th:nth-child(2) {
  width: 7%;
}

th:nth-child(3) {
  width: 5%;
}

th:nth-child(4),
th:nth-child(5) {
  width: 19%;
}

th:nth-child(6),
th:nth-child(7) {
  width: 12%;
}

th:nth-child(8) {
  width: 6%;
  min-width: 52px;
  max-width: 68px;
}

th:nth-child(8),
td:nth-child(8) {
  padding-left: 4px;
  padding-right: 4px;
}

tr.is-selected {
  background: #edf8f6;
}

.title-cell {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.row-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
}

.row-select input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.history-list {
  display: grid;
  gap: 4px;
}

.history-row {
  font-size: 10px;
  line-height: 1.25;
}

.history-status {
  font-weight: 800;
}

.history-row.is-on .history-status {
  color: #0f766e;
}

.history-row.is-off .history-status {
  color: var(--danger);
}

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

.frame-off-badge {
  display: inline-flex;
  margin-top: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fdecea;
  color: var(--danger);
  font-size: 10px;
  font-weight: 800;
}

tr.is-frame-off td {
  background: #fff7f6;
}

.frame-toggle {
  min-width: 0;
  padding: 5px 3px;
  font-size: 10px;
  line-height: 1.1;
  font-weight: 700;
}

.frame-toggle.is-disable {
  border-color: #f1c7c2;
  background: #fdf3f2;
  color: var(--danger);
}

.frame-toggle.is-enable {
  border-color: #bfe0dc;
  background: #e9f5f3;
  color: #0a5c56;
}

.article-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  margin-top: 4px;
}

.article-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  max-width: 100%;
  min-height: 17px;
  padding: 1px 3px;
  border: 1px solid #e2e7eb;
  border-radius: 5px;
  background: #f8fafb;
  color: #56616c;
  font-size: 10px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.article-name {
  min-width: 0;
}

.article-stock {
  flex: 0 0 auto;
  color: #0f766e;
  font-weight: 800;
}

.badge-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(28px, 1fr));
  gap: 4px;
  max-width: 74px;
}

.link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: #e9f5f3;
  color: #0a5c56;
  font-size: 11px;
  font-weight: 700;
}

.badge.screen {
  background: #eef2ff;
  color: #3730a3;
}

.section-row td {
  padding: 8px 10px;
  background: #eef1f3;
  color: #37424c;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.section-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-select input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.row-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.row-actions button {
  min-width: 0;
  padding: 5px 3px;
  font-size: 10px;
  line-height: 1.1;
}

.row-control {
  display: grid;
  gap: 5px;
}

.amount-input {
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 28px;
  padding: 4px 3px;
  text-align: center;
  font-size: 12px;
}

.warehouse-row-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.warehouse-row-actions button {
  min-width: 0;
  padding: 5px 3px;
  border-color: #dbeafe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
}

.details {
  max-height: none;
  overflow: auto;
}

.details-summary {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.details-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.cards {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.product {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  background: #eef1f3;
}

.product span,
.product small {
  display: block;
  margin-top: 3px;
}

.product p {
  margin-top: 5px;
  color: #37424c;
  font-size: 12px;
  line-height: 1.35;
}

.pending-actions {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 50;
  width: min(560px, calc(100vw - 28px));
  padding: 12px 14px;
  transform: translateX(-50%);
  border: 1px solid #f0b429;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow), 0 0 0 4px rgba(240, 180, 41, 0.16);
}

.pending-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.pending-head strong {
  color: #9a5f00;
  font-size: 12px;
  font-weight: 800;
}

.pending-head button {
  padding: 5px 10px;
  border-color: #f1c7c2;
  color: var(--danger);
  font-size: 12px;
}

.pending-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pending-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-color: #d7dee4;
  border-radius: 50%;
  background: #fff;
  color: #4b5563;
  font-size: 18px;
  line-height: 1;
}

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

.pending-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

@keyframes pendingPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(180, 83, 9, 0.35);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(180, 83, 9, 0);
  }
}

.pending-count {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #b45309;
  color: #fff;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  animation: pendingPulse 1s ease-in-out infinite;
}

.pending-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.pending-confirm,
.pending-cancel {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
}

.pending-confirm {
  border-color: #0f766e;
  background: #0f766e;
  color: #fff;
}

.pending-cancel {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.pending-confirm:hover,
.pending-cancel:hover {
  color: #fff;
  filter: brightness(1.05);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #173b36;
  color: #fff;
  box-shadow: var(--shadow);
}

.toast.is-error {
  background: var(--danger);
}

.is-busy {
  cursor: progress;
}

.is-busy button {
  pointer-events: none;
  opacity: 0.65;
}

@media (max-width: 760px) {
  .pending-card {
    flex-wrap: wrap;
  }

  .pending-label {
    order: 3;
    flex-basis: 100%;
  }

  .topbar,
  .panel-head,
  .toolbar,
  .bulk-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-title {
    min-width: 0;
  }

  .actions {
    justify-content: flex-start;
  }

  .bulk-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
  }

  .bulk-controls .amount-input,
  .bulk-controls #clearSelection {
    grid-column: 1 / -1;
    width: 100%;
  }

  .modal {
    padding: 14px;
  }

  .modal-panel {
    max-height: calc(100vh - 28px);
  }

  .modal-head {
    flex-direction: column;
    align-items: stretch;
  }

  .backup-item,
  .journal-item,
  .backup-buttons {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .journal-item time {
    text-align: left;
  }

  main,
  .topbar {
    padding-inline: 14px;
  }

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

  .warehouse-option {
    white-space: normal;
  }

  .table-wrap {
    overflow: visible;
  }

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

  thead {
    display: none;
  }

  tr {
    border-bottom: 1px solid var(--line);
  }

  tr:not(.section-row) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    padding: 10px;
  }

  td {
    padding: 0;
    border-bottom: 0;
  }

  tr:not(.section-row) td:first-child,
  tr:not(.section-row) td:nth-child(8) {
    grid-column: 1 / -1;
  }

  tr:not(.section-row) td:not(:first-child)::before {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
    text-transform: uppercase;
  }

  tr:not(.section-row) td:nth-child(2)::before {
    content: "Линейки";
  }

  tr:not(.section-row) td:nth-child(3)::before {
    content: "Размер";
  }

  tr:not(.section-row) td:nth-child(4)::before {
    content: "Ozon";
  }

  tr:not(.section-row) td:nth-child(5)::before {
    content: "WB";
  }

  tr:not(.section-row) td:nth-child(6)::before {
    content: "Остаток Ozon";
  }

  tr:not(.section-row) td:nth-child(7)::before {
    content: "Остаток WB";
  }

  tr:not(.section-row) td:nth-child(8)::before {
    content: "Обновление";
  }

  tr:not(.section-row) td:nth-child(6),
  tr:not(.section-row) td:nth-child(7) {
    padding: 8px;
    border: 1px solid #bfdbfe;
    border-radius: 7px;
    background: #eff6ff;
  }

  tr:not(.section-row) td:nth-child(6)::before,
  tr:not(.section-row) td:nth-child(7)::before {
    color: #1d4ed8;
  }

  .badge-list,
  .article-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
  }

  .article-list {
    align-items: stretch;
    grid-auto-rows: minmax(30px, auto);
  }

  .article-chip {
    min-height: 30px;
    height: 100%;
    align-items: center;
    font-size: 10px;
    line-height: 1.15;
  }

  .row-actions button,
  .amount-input {
    min-height: 42px;
    font-size: 15px;
  }

  .amount-input {
    height: 42px;
  }

  .section-row td {
    padding: 9px 10px;
  }
}

/* ─── Навигация страниц (Остатки / Отгрузки) ─── */
.page-nav {
  display: inline-flex;
  gap: 4px;
  margin: 8px 0 0;
  padding: 3px;
  background: #eef1f3;
  border-radius: 8px;
}

.page-tab {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
}

.page-tab.is-active {
  background: #fff;
  color: var(--accent-strong);
  box-shadow: var(--shadow);
}

.page-tab:not(.is-active):hover {
  color: var(--text);
}

/* ─── Вкладка «Отгрузки» ─── */
.ship-main {
  padding: 18px 24px 48px;
}

.ship-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.ship-head h2 {
  margin: 0;
  font-size: 18px;
}

.ship-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.ship-toolbar select {
  min-width: 200px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 8px;
}

.ship-count {
  font-weight: 700;
}

.ship-mode {
  margin-left: auto;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fdecea;
  color: var(--danger);
}

.ship-section-title {
  margin: 22px 0 8px;
  font-size: 15px;
  font-weight: 800;
}

.ship-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 12px 0;
}

.ship-actions .primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-strong);
}

.ship-stickers {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.ship-sticker {
  width: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  text-align: center;
}

.ship-sticker img {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.ship-sticker small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  word-break: break-all;
}

.ship-banner {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin: 10px 0;
}

.ship-banner.warn {
  background: #fff7e6;
  color: #92400e;
  border: 1px solid #f3d999;
}

.ship-banner.err {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f1c7c2;
}

/* Своя таблица отгрузок: не наследует fixed-проценты таблицы остатков,
   заданные ширины служебных колонок, «Товар» гибкий но не гигантский, всё влезает. */
.ship-tbl {
  table-layout: fixed;     /* строгие ширины колонок из <colgroup>, текст переносится внутри */
  width: 100%;
}

.ship-tbl th,
.ship-tbl td {
  padding: 7px 12px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ship-tbl th:first-child,
.ship-tbl td:first-child {
  padding-left: 16px;
}

/* сброс процентных ширин th из таблицы остатков — ширины берём из <colgroup> */
.ship-tbl thead th {
  width: auto !important;
}

.ship-name-col {
  white-space: normal;
  text-align: left;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.ship-tbl .ship-art {
  white-space: normal;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.ship-tbl .ship-price {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ─── Мобильная версия: строки-карточки (столбцы уходят вниз) ─── */
@media (max-width: 720px) {
  .ship-tbl thead { display: none; }
  .ship-tbl, .ship-tbl tbody, .ship-tbl tr, .ship-tbl td { display: block; width: auto; }
  .ship-tbl tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin: 0 0 10px;
    padding: 6px 10px;
    background: #fff;
  }
  .ship-tbl td {
    border: none !important;
    background: transparent !important;
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    white-space: normal;
    max-width: none;
    min-width: 0;
  }
  .ship-tbl td::before {
    content: attr(data-label) !important;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    flex: 0 0 auto;
    text-transform: none !important;
    width: auto !important;
  }
  .ship-tbl td.ship-cb-col { justify-content: flex-start; }
  .ship-tbl td.ship-cb-col::before { content: "Выбрать" !important; }
  .ship-tbl td.ship-name-col { font-weight: 700; }
  .ship-tbl td.ship-act-col::before { content: "" !important; }
  .ship-tbl .ship-row-actions { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; }
}

.ship-status {
  display: inline-block;
  padding: 2px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ship-status.st-green {
  background: #e9f5f3;
  color: #0a5c56;
}

.ship-status.st-blue {
  background: #e8efff;
  color: #1d4ed8;
}

.ship-status.st-red {
  background: #fdecea;
  color: var(--danger);
}

.ship-result {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.ship-result-head {
  margin-bottom: 8px;
  font-size: 13px;
}

.ship-row-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.ship-tbl td.ship-act-col { overflow: visible; }

.ship-row-actions button {
  white-space: nowrap;
  padding: 5px 8px;
}

/* ─── Админка: токены маркетплейсов ─── */
.admin-main {
  max-width: 780px;
  margin: 0 auto;
  padding: 18px 16px;
}

.admin-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0 8px;
}

.admin-field {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--panel);
}

.admin-field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.admin-hint {
  color: var(--muted);
  font-size: 12px;
  margin-left: 8px;
}

.admin-status {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

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

.admin-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-badge.is-on {
  background: #e9f5f3;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.admin-badge.is-off {
  background: #fdecea;
  color: var(--danger);
}

.admin-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-input {
  flex: 1 1 260px;
  min-width: 0;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.admin-input:focus {
  border-color: var(--accent);
  outline: none;
}

.admin-clear {
  color: var(--danger);
}

@media (max-width: 560px) {
  .admin-row .admin-input { flex: 1 1 100%; }
  .admin-row button { flex: 1 1 auto; }
}

/* ─── Mobile sign-in ─── */
.login-page {
  min-height: 100dvh;
  background:
    linear-gradient(145deg, rgba(15, 118, 110, 0.12), transparent 45%),
    var(--bg);
}

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.login-card {
  width: min(100%, 420px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 18px;
  border-radius: 13px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
}

.login-eyebrow {
  margin-bottom: 5px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card h1 { font-size: 28px; }
.login-copy { margin-top: 8px; color: var(--muted); line-height: 1.45; }
.login-form { display: grid; gap: 16px; margin-top: 26px; }
.login-field { display: grid; gap: 7px; }
.login-field label { font-size: 13px; font-weight: 750; }
.login-form input {
  width: 100%;
  min-height: 50px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 92px; }
.password-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  min-height: 40px;
  border: 0;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 750;
}
.login-submit {
  min-height: 50px;
  margin-top: 2px;
  border-color: var(--accent-strong);
  border-radius: 10px;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 800;
}
.login-submit:disabled { opacity: 0.65; }
.login-error { padding: 10px 12px; border-radius: 9px; background: #fdecea; color: var(--danger); font-size: 13px; }
.login-help { margin-top: 18px; color: var(--muted); font-size: 12px; text-align: center; }
.mobile-logout { color: var(--muted); font-size: 12px; font-weight: 700; text-decoration: none; }
.warehouse-mobile-toggle { display: none; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  html { scroll-padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  body {
    min-width: 320px;
    overflow-x: hidden;
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
    -webkit-text-size-adjust: 100%;
  }

  button,
  input,
  select,
  textarea { font-size: 16px; }

  button,
  .button-link,
  .check { min-height: 44px; }

  .topbar {
    gap: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
  }

  .topbar-title { display: grid; grid-template-columns: 1fr auto; width: 100%; gap: 8px 10px; }
  .topbar-title h1 { align-self: center; font-size: 18px; }
  .topbar-title .source-status { grid-column: 1 / -1; }
  .mobile-logout { align-self: center; min-height: 44px; display: inline-flex; align-items: center; padding-inline: 8px; }

  .page-nav {
    position: fixed;
    z-index: 50;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
    padding: 7px max(10px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -8px 24px rgba(24, 32, 39, 0.08);
    backdrop-filter: blur(14px);
  }

  .page-tab {
    display: grid;
    place-items: center;
    min-height: 50px;
    padding: 6px;
    border-radius: 9px;
    font-size: 12px;
    line-height: 1.1;
  }

  .page-tab.is-active { background: #e9f5f3; box-shadow: none; }

  .actions {
    width: calc(100vw - 24px);
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 1px 0 5px;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  .actions::-webkit-scrollbar { display: none; }
  .actions > * { flex: 0 0 auto; scroll-snap-align: start; }

  main,
  .ship-main,
  .admin-main { padding: 12px max(10px, env(safe-area-inset-right)) 20px max(10px, env(safe-area-inset-left)); }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
  }
  .toolbar #search { grid-column: 1 / -1; min-height: 48px; }
  .toolbar button,
  .toolbar select { width: 100%; min-height: 44px; }
  .toolbar .check { justify-content: center; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
  .toolbar .check input { width: 20px; height: 20px; }

  .panel { border-radius: 12px; overflow: hidden; }
  .panel-head { padding: 13px 12px; }
  .panel-head h2 { font-size: 17px; }
  .bulk-panel { gap: 10px; padding: 12px; }
  .bulk-status { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
  .bulk-controls { gap: 7px; }
  .bulk-controls button,
  .bulk-controls .amount-input { min-height: 46px; }
  .bulk-controls #bulkOff { grid-column: span 2; }
  .warehouses { padding-inline: 12px; }
  .warehouse-mobile-toggle {
    display: block;
    width: calc(100% - 24px);
    min-height: 44px;
    margin: 0 12px 12px;
    border-color: #cdd6dc;
    background: #f8fafb;
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 800;
  }
  .warehouses:not(.is-open) { display: none; }

  tr:not(.section-row) {
    margin: 10px;
    padding: 12px;
    gap: 12px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(24, 32, 39, 0.04);
  }

  tr:not(.section-row).is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12); }
  tr:not(.section-row) td { min-width: 0; }
  tr:not(.section-row) td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  tr:not(.section-row) td[data-label="Товар"] { grid-column: 1 / -1; padding-bottom: 9px; border-bottom: 1px solid #edf0f2; }
  tr:not(.section-row) td[data-label="Товар"]::before { display: none; }
  tr:not(.section-row) td[data-label="Ozon"],
  tr:not(.section-row) td[data-label="WB"] { padding: 9px; border: 1px solid; border-radius: 9px; }
  tr:not(.section-row) td[data-label="Ozon"] { border-color: #bfdbfe; background: #eff6ff; }
  tr:not(.section-row) td[data-label="WB"] { border-color: #bbf7d0; background: #f0fdf4; }
  tr:not(.section-row) td[data-label="Ozon"]::before { color: #1d4ed8; }
  tr:not(.section-row) td[data-label="WB"]::before { color: #15803d; }
  tr:not(.section-row) td[data-label="Статус"],
  tr:not(.section-row) td[data-label="Действия"] { grid-column: 1 / -1; }
  tr:not(.section-row) td[data-label="Статус"] { padding-top: 3px; }
  tr:not(.section-row) td[data-label="Действия"] { padding-top: 9px; border-top: 1px solid #edf0f2; }

  .title-cell { align-items: flex-start; }
  .select-target { width: 22px; height: 22px; flex: 0 0 22px; }
  .link { min-height: 34px; padding: 0; font-size: 16px; text-align: left; }
  .row-control { gap: 8px; }
  .row-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .row-actions button,
  .warehouse-row-actions button,
  .amount-input { min-height: 46px; padding: 7px 5px; font-size: 13px; }
  .amount-input { height: 46px; }

  .article-chip { min-height: 36px; padding: 6px; font-size: 11px; }
  .badge-list,
  .article-list { gap: 5px; }

  .modal { align-items: flex-end; padding: 0; }
  .modal-panel {
    width: 100%;
    max-width: none;
    max-height: 90dvh;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
  }
  .modal-head { flex-direction: row; align-items: flex-start; gap: 8px; }
  .modal-head button,
  .details-head button { min-height: 44px; }
  .details { inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) calc(72px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .toast { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: none; }
  .pending-actions { bottom: calc(76px + env(safe-area-inset-bottom)); }

  .login-page { padding-bottom: 0; }
  .login-card { padding: 24px 20px; border-radius: 16px; }
  .admin-input,
  .admin-row button { min-height: 46px; }
}

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