:root {
  --background: #F7F3E9;
  --surface: #FFFFFF;
  --surface-subtle: #FBF8F0;
  --text: #17251F;
  --text-muted: #64716A;
  --text-on-accent: #FFFFFF;
  --border: #D8D3C8;
  --border-strong: #8D938D;
  --brand: #B3261E;
  --primary: #235642;
  --primary-hover: #194433;
  --primary-subtle: #E7F0EB;
  --focus: #006D73;
  --success: #26734D;
  --error: #8E302B;
  --error-surface: #FFF1EF;
  --error-border: #C66D61;
  --warning: #80590B;
  --processing: #425B70;
  --disabled-text: #5E6661;
  --disabled-surface: #E4E1D8;
  --disabled-border: #C4C1B7;
  --marketplace-ozon: #1769FF;
  --cargo-01: #C1D7E7;
  --cargo-02: #E7D9B8;
  --cargo-03: #D2CAE4;
  --cargo-04: #E0C8BC;
  --cargo-05: #CBD5E9;
  --cargo-06: #D1DEC0;
  --cargo-07: #C4DDE5;
  --cargo-08: #D7DDB8;
  --cargo-09: #C2DDD6;
  --cargo-10: #D8CCE8;
  --cargo-11: #E9D0C1;
  --cargo-12: #E3CAD8;
  --radius-control: 7px;
}

* { box-sizing: border-box; }
html { background: var(--background); }
body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
button { font: inherit; }
button, a { touch-action: manipulation; }
html { -webkit-tap-highlight-color: color-mix(in srgb, var(--primary) 16%, transparent); }
button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex="0"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  padding: 9px 13px;
  border-radius: var(--radius-control);
  background: var(--text);
  color: var(--text-on-accent);
}
.skip-link:focus { transform: translateY(0); }

.app-bar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  background: var(--brand);
  color: var(--text-on-accent);
  font-weight: 750;
}
.brand-name { color: var(--brand); font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.app-divider { width: 1px; height: 24px; margin: 0 16px; background: var(--border); }
.tool-name { font-weight: 600; }
.marketplace-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.marketplace-badge > span { width: 7px; height: 7px; border-radius: 50%; background: var(--marketplace-ozon); }
.process-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.process-status > span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.process-status--ready > span { background: var(--primary); }
.process-status--success { color: var(--success); }
.process-status--success > span { background: var(--success); }
.process-status--processing { color: var(--processing); }
.process-status--processing > span { background: var(--processing); }
.process-status--error { color: var(--error); }
.process-status--error > span { background: var(--error); }

.workspace-shell {
  display: grid;
  grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
  min-height: calc(100vh - 60px);
}
.source-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px 20px;
  border-right: 1px solid var(--border);
  background: var(--surface-subtle);
}
.panel-heading, .files-heading, .result-heading, .manifest-intro, .supply-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.section-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
.panel-heading h1 { margin-bottom: 0; font-size: 20px; line-height: 1.25; letter-spacing: -.02em; }
.instructions { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); }
.instructions summary { padding: 9px 11px; color: var(--primary); cursor: pointer; font-weight: 600; }
.instructions[open] summary { border-bottom: 1px solid var(--border); }
.instructions-content { padding: 12px; color: var(--text-muted); font-size: 12px; }
.instructions-content h2 { margin-bottom: 8px; color: var(--text); font-size: 14px; font-weight: 600; }
.instructions-content ol { margin: 0; padding-left: 20px; }
.instructions-content li + li { margin-top: 5px; }
.instructions-content p { margin: 10px 0 0; color: var(--text); }
.file-count {
  min-width: 25px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.field-group { margin-top: 24px; }
.field-label { display: block; margin-bottom: 8px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.request-list { display: grid; gap: 14px; margin-top: 18px; }
.request-draft { padding: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-control); background: var(--surface); }
.request-draft-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.request-draft-heading h2 { margin-bottom: 0; font-size: 15px; }
.request-remove { margin: -7px -8px 0 0; }
.request-number-input { width: 100%; height: 40px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--text); font: inherit; }
.request-number-input:focus-visible { border-color: var(--focus); }
.request-draft .dropzone { min-height: 138px; margin-top: 12px; padding: 14px 10px; }
.request-draft .files-heading { margin-top: 14px; }
.add-request { width: 100%; margin-top: 14px; }
.marketplace-value {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
}
.ozon-mark {
  display: grid;
  width: 42px;
  height: 32px;
  place-items: center;
  border-radius: 5px;
  background: var(--marketplace-ozon);
  color: var(--text-on-accent);
  font-size: 10px;
  font-weight: 800;
}
.marketplace-value > span:nth-child(2) { min-width: 0; flex: 1; }
.marketplace-value strong, .marketplace-value small { display: block; }
.marketplace-value strong { font-size: 13px; }
.marketplace-value small { margin-top: 1px; color: var(--text-muted); font-size: 11px; }
.selected-mark { color: var(--success); font-weight: 800; }

.dropzone {
  display: flex;
  min-height: 164px;
  margin-top: 16px;
  padding: 18px 14px;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  text-align: center;
}
.dropzone--active { border-color: var(--primary); background: var(--primary-subtle); }
.dropzone--active { user-select: none; }
.dropzone-icon {
  display: grid;
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--primary);
  font-size: 20px;
}
.dropzone strong { font-size: 13px; }
.dropzone > span:not(.dropzone-icon) { margin-top: 2px; color: var(--text-muted); font-size: 12px; }
.dropzone .button { margin-top: 12px; }
.button {
  display: inline-flex;
  min-height: 40px;
  padding: 9px 14px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
}
.button--primary { width: 100%; border-color: var(--primary); background: var(--primary); color: var(--text-on-accent); }
.button--primary:hover:not(:disabled) { background: var(--primary-hover); }
.button--primary:disabled { border-color: var(--disabled-border); background: var(--disabled-surface); color: var(--disabled-text); cursor: not-allowed; }
.button--secondary { border-color: var(--border-strong); background: var(--surface); }
.button--secondary:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-subtle); }
.button--secondary:disabled { border-color: var(--disabled-border); background: var(--disabled-surface); color: var(--disabled-text); cursor: not-allowed; }
.button--quiet:disabled, .text-button:disabled, .icon-button:disabled { color: var(--disabled-text); cursor: not-allowed; }
.button--quiet { border-color: transparent; color: var(--text-muted); }
.button--quiet:hover:not(:disabled) { background: var(--surface-subtle); color: var(--text); }
.download-unavailable { align-self: center; color: var(--error); font-size: 12px; }
.text-button, .icon-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-weight: 650;
}
.text-button { padding: 3px 0; font-size: 12px; }
.icon-button { width: 34px; height: 34px; color: var(--text-muted); font-size: 20px; }
.icon-button:hover:not(:disabled) { color: var(--error); }
.source-message { min-height: 0; }
.inline-error {
  display: flex;
  gap: 8px;
  margin: 10px 0 0;
  padding: 9px 10px;
  border: 1px solid var(--error-border);
  border-radius: var(--radius-control);
  background: var(--error-surface);
  color: var(--error);
  font-size: 12px;
}
.inline-error span { font-weight: 800; }
.files-heading { margin-top: 20px; align-items: center; color: var(--text-muted); font-size: 12px; font-weight: 650; }
.file-list { margin: 8px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.source-file {
  display: flex;
  min-width: 0;
  min-height: 54px;
  padding: 9px 0;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--border);
}
.file-type {
  display: grid;
  flex: 0 0 32px;
  height: 34px;
  place-items: center;
  border-radius: 5px;
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 9px;
  font-weight: 800;
}
.file-details { min-width: 0; flex: 1; }
.file-details strong, .file-details small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-details strong { font-size: 12px; }
.file-details small { margin-top: 2px; color: var(--text-muted); font-size: 11px; }
.source-action { margin-top: auto; padding-top: 24px; }
.source-action .reset-button { width: 100%; margin-top: 6px; }
.source-action p { margin: 8px 0 0; color: var(--text-muted); font-size: 11px; text-align: center; }

.result-panel { min-width: 0; padding: 32px clamp(24px, 3vw, 48px) 64px; }
.empty-result {
  display: grid;
  min-height: calc(100vh - 156px);
  place-content: center;
  justify-items: center;
  color: var(--text-muted);
  text-align: center;
}
.empty-symbol {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 14px;
  place-items: center;
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 22px;
}
.empty-symbol--processing { color: var(--processing); }
.empty-symbol--error { border-color: var(--error-border); background: var(--error-surface); color: var(--error); }
.empty-result h2 { margin-bottom: 6px; color: var(--text); font-size: 18px; }
.empty-result p { max-width: 390px; margin-bottom: 0; font-size: 13px; }
.result-heading { align-items: flex-end; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.result-heading h2 { margin-bottom: 4px; font-size: 24px; font-weight: 600; line-height: 1.2; letter-spacing: -.025em; }
.result-heading h2, .empty-result h2, .manifest-intro h2 { text-wrap: balance; }
.result-heading p { margin-bottom: 0; color: var(--text-muted); font-size: 13px; }
.result-actions { display: flex; gap: 6px; flex-shrink: 0; }
.manifest-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(86px, .75fr)) minmax(155px, 1.35fr);
  margin: 0;
  border-bottom: 1px solid var(--border);
}
.manifest-summary div { padding: 18px 20px; }
.manifest-summary div + div { border-left: 1px solid var(--border); }
.manifest-summary div:not(.cargo-summary-cell) { display: flex; align-items: center; flex-direction: column; justify-content: center; text-align: center; }
.manifest-summary dt { color: var(--text-muted); font-size: 11px; font-weight: 650; }
.manifest-summary dd { margin: 2px 0 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.manifest-summary .cargo-summary-cell dd { margin-top: 5px; font-size: 12px; }
.cargo-summary { display: flex; margin: 0; padding: 0; flex-direction: column; gap: 2px; list-style: none; }
.cargo-summary li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.cargo-summary span { color: var(--text); font-weight: 600; }
.cargo-summary strong { white-space: nowrap; font-size: 13px; }
.article-summary {
  display: grid;
  grid-template-columns: minmax(180px, .8fr) minmax(0, 3.2fr);
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.article-summary-heading h2 { margin-bottom: 2px; font-size: 14px; }
.article-summary-heading p { margin-bottom: 0; color: var(--text-muted); font-size: 11px; }
.article-summary > ul { display: flex; margin: 0; padding: 0; flex-wrap: wrap; gap: 7px 18px; list-style: none; }
.article-summary li { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.article-summary code { color: var(--text); font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.article-summary li > span { color: var(--text-muted); }
.article-summary strong { font-size: 12px; font-variant-numeric: tabular-nums; }
.manifest-intro { margin-top: 30px; align-items: flex-end; }
.manifest-intro h2 { margin-bottom: 0; font-size: 18px; }
.manifest-intro > p { display: flex; align-items: center; gap: 7px; margin-bottom: 0; color: var(--text-muted); font-size: 12px; }
.legend-swatch { width: 26px; height: 13px; border: 1px solid var(--border-strong); background: var(--cargo-01); }
.manifest-document { margin-top: 12px; border-top: 1px solid var(--text); }
.manifest-request { padding-top: 18px; }
.manifest-request + .manifest-request { margin-top: 38px; border-top: 2px solid var(--text); }
.request-result-heading { padding-bottom: 2px; break-after: avoid-page; page-break-after: avoid; }
.request-result-heading h3 { margin-bottom: 0; font-size: 20px; font-weight: 600; letter-spacing: -.015em; }
.manifest-supply { padding-top: 24px; }
.manifest-request .manifest-supply + .manifest-supply { margin-top: 32px; border-top: 1px solid var(--border-strong); }
.supply-heading { align-items: flex-end; padding: 0 2px 12px; }
.supply-heading h3 { margin-bottom: 1px; font-family: Consolas, "Courier New", monospace; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.supply-heading > div > p { margin-bottom: 0; color: var(--text-muted); font-size: 13px; }
.supply-totals { margin-bottom: 0; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.table-scroll { max-width: 100%; overflow: visible; border: 1px solid var(--border); }
table { width: 100%; min-width: 830px; border-collapse: separate; border-spacing: 0; background: var(--surface); font-size: 13px; }
thead th {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text-muted);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .025em;
  white-space: nowrap;
}
tbody td { height: 43px; padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td:not(.gm-cell):not(.gm-type-cell) { background: var(--surface-subtle); }
.barcode-text, .gm-cell span { font-family: Consolas, "Courier New", monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cargo-place-number-cell { width: 112px; text-align: center; font-variant-numeric: tabular-nums; }
.barcode-text { min-width: 154px; color: var(--text); }
.product-barcode-cell, .barcode-text, .gm-cell-heading, .gm-cell, .gm-type-cell-heading, .gm-type-cell { text-align: left; }
.article-cell { min-width: 190px; text-align: center; font-weight: 600; overflow-wrap: anywhere; }
.quantity-cell { width: 140px; text-align: center; font-variant-numeric: tabular-nums; }
.gm-cell, .gm-type-cell { background: var(--gm-fill); }
.gm-cell { min-width: 145px; box-shadow: inset 4px 0 color-mix(in srgb, var(--gm-fill) 58%, var(--text)); }
.gm-cell span { font-weight: 600; }
.gm-type-cell { min-width: 120px; }

@media (max-width: 1100px) {
  .workspace-shell { grid-template-columns: 330px minmax(0, 1fr); }
  .source-panel { padding: 20px 16px; }
  .result-panel { padding: 24px 20px 56px; }
  .manifest-summary div { padding: 18px 12px; }
  .table-scroll { overflow-x: auto; }
}

@media (max-width: 820px) {
  .app-bar { padding: 0 16px; }
  .app-divider, .tool-name { display: none; }
  .workspace-shell { display: block; }
  .source-panel { border-right: 0; border-bottom: 1px solid var(--border); }
  .source-action { margin-top: 20px; }
  .result-panel { padding: 24px 16px 48px; }
  .empty-result { min-height: 320px; }
  .manifest-summary { grid-template-columns: 1fr 1fr; }
  .manifest-summary div:nth-child(odd) { border-left: 0; }
  .manifest-summary div:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .manifest-summary .cargo-summary-cell { grid-column: 1 / -1; border-left: 0; }
  .article-summary { grid-template-columns: 1fr; gap: 10px; }
}

@media (max-width: 560px) {
  .brand-name { display: none; }
  .marketplace-badge { margin-left: 10px; }
  .process-status { max-width: 125px; text-align: right; }
  .result-heading, .manifest-intro, .supply-heading { align-items: flex-start; flex-direction: column; }
  .result-actions { width: 100%; }
  .result-actions .button { flex: 1; }
  .manifest-intro > p { align-self: stretch; }
  .supply-heading { gap: 6px; }
  .manifest-summary div { padding: 14px 10px; }
}

@page {
  size: A4 landscape;
  margin: 8mm;
}

@media print {
  html, body { background: var(--surface); color: var(--text); }
  .skip-link, .app-bar, .source-panel, .result-actions { display: none !important; }
  .workspace-shell { display: block; min-height: 0; }
  .result-panel { padding: 0; }
  .manifest-summary, .supply-heading, thead, .gm-cell, .gm-type-cell {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .result-heading { padding-bottom: 6px; }
  .result-heading h2 { margin-bottom: 1px; font-size: 14pt; }
  .result-heading p { font-size: 8pt; }
  .manifest-summary div { padding: 6px 8px; }
  .manifest-summary dt { font-size: 7pt; }
  .manifest-summary dd { margin-top: 0; font-size: 12pt; }
  .manifest-summary .cargo-summary-cell dd { margin-top: 1px; font-size: 8pt; }
  .cargo-summary { gap: 0; }
  .cargo-summary strong { font-size: 8pt; }
  .article-summary { gap: 10px; padding: 6px 0; }
  .article-summary-heading h2 { margin-bottom: 0; font-size: 9pt; }
  .article-summary-heading p, .article-summary code, .article-summary strong { font-size: 7.5pt; }
  .article-summary > ul { gap: 2px 10px; }
  .manifest-intro { margin-top: 8px; }
  .manifest-intro h2 { font-size: 11pt; }
  .manifest-intro > p { font-size: 7.5pt; }
  .manifest-document { margin-top: 4px; }
  .manifest-request { padding-top: 5px; }
  .manifest-request + .manifest-request { margin-top: 10px; }
  .request-result-heading { padding-bottom: 0; break-after: avoid-page; page-break-after: avoid; }
  .request-result-heading h3 { font-size: 10pt; }
  .manifest-supply {
    padding-top: 7px;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }
  .manifest-supply + .manifest-supply { margin-top: 8px; }
  .supply-heading {
    padding: 0 1px 3px;
    break-after: avoid-page;
    page-break-after: avoid;
  }
  .section-kicker { margin-bottom: 1px; font-size: 7pt; }
  .supply-heading h3 { font-size: 10pt; }
  .supply-heading > div > p, .supply-totals { font-size: 7.5pt; }
  .table-scroll { overflow: visible; }
  table { width: 100%; min-width: 0; table-layout: auto; font-size: 8pt; }
  thead { display: table-header-group; }
  thead th { position: static; padding: 3px 5px; font-size: 7pt; }
  tbody tr { break-inside: avoid; page-break-inside: avoid; }
  tbody td { height: auto; padding: 3px 5px; }
  .cargo-place-number-cell, .quantity-cell { width: auto; }
  .barcode-text { min-width: 0; white-space: nowrap; }
  .article-cell, .gm-cell, .gm-type-cell { min-width: 0; }
}
