:root {
  color-scheme: light;
  --desk: #f5f6f8; --paper: #fff; --surface: #f8f9fb; --ink: #202833;
  --muted: #5c6877; --tertiary: #667180; --line: #e2e6eb; --line-strong: #bfc8d1;
  --green: #087f5b; --green-hover: #06694c; --green-soft: #eaf5f0;
  --ochre: #885a12; --ochre-soft: #fff8e9; --red: #a13c38; --red-soft: #fff2f0;
  --control: #f8f9fb; --focus: #087f5b; --radius: 6px; --surface-radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }
body { margin: 0; background: var(--desk); color: var(--ink); font: 14px/1.5 'Segoe UI', Arial, sans-serif; font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
.shell { max-width: 1600px; margin: 0 auto; padding: 0 32px 20px; }
.topbar, .identity, .toolbar, .actions, .section-heading, .cart-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar { min-height: 80px; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 16px 0; }
.brand { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 24px; line-height: 1.2; font-weight: 650; letter-spacing: -.8px; }
.brand > span:not(.stand-badge) { color: var(--muted); font-size: 12px; font-weight: 400; letter-spacing: 0; }
.stand-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; background: var(--surface); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; font-size: 11px; line-height: 1.25; font-weight: 500; letter-spacing: 0; }
.stand-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--ochre); flex: 0 0 auto; }
.identity { color: var(--muted); font-size: 12px; gap: 12px; justify-content: flex-end; }
.identity button { font-size: 12px; padding: 8px 12px; }
.stand-banner { margin-top: 12px; padding: 8px 12px; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); font-size: 12px; background: var(--paper); }
.feedback { margin-top: 16px; padding: 12px 16px; color: var(--green-hover); border: 1px solid #c9e6d7; border-radius: var(--radius); background: var(--green-soft); }
.feedback.error { border-color: #efd1ce; background: var(--red-soft); color: var(--red); }
main { margin-top: 24px; min-height: 480px; }
.app-layout { display: grid; grid-template-columns: 184px minmax(0,1fr); gap: 32px; align-items: start; }
.app-main, .app-layout > *, .work-view, .report-view { min-width: 0; }
.app-main > .page-heading, .page-heading { margin: 0 0 24px; }
.paper { background: var(--paper); border: 1px solid var(--line); border-radius: var(--surface-radius); padding: 24px; min-width: 0; }
.login { max-width: 440px; margin: 64px auto; padding: 32px; }
.login form { display: grid; gap: 16px; margin-top: 28px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.7px; font-weight: 650; text-wrap: balance; }
h2 { font-size: 20px; line-height: 1.3; letter-spacing: -.35px; font-weight: 600; }
h3 { font-size: 16px; line-height: 1.4; font-weight: 600; }
p { overflow-wrap: anywhere; }
p + p { margin-top: 8px; }
.subtitle { margin-top: 8px; color: var(--muted); max-width: 860px; font-size: 13px; line-height: 1.55; }
.eyebrow { margin-bottom: 8px; color: var(--tertiary); font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; }
.meta, small { font-size: 12px; line-height: 1.45; color: var(--muted); }
small { display: block; }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 500; min-width: 0; }
button, input, select, textarea { color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius); min-height: 44px; padding: 10px 12px; max-width: 100%; }
input, select, textarea { background: var(--control); min-width: 0; }
select { text-overflow: ellipsis; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--tertiary); }
button { background: var(--paper); font-weight: 600; cursor: pointer; line-height: 1.35; }
button:hover { background: var(--surface); border-color: #93a1af; }
button:active { background: #edf0f3; }
button.primary { background: var(--green); color: var(--paper); border-color: var(--green); }
button.primary:hover, button.primary:active { background: var(--green-hover); border-color: var(--green-hover); }
button.danger { color: var(--red); }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.toolbar { align-items: flex-end; margin: 20px 0; padding: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--surface-radius); gap: 16px; }
.toolbar label { min-width: 160px; }
.toolbar .search { flex: 1; min-width: 220px; }
.toolbar .actions { margin-left: auto; }
.workspace { display: grid; grid-template-columns: minmax(0,1.3fr) minmax(280px,1fr); gap: 20px; align-items: start; }
.workspace > * { min-width: 0; }
.section-heading { justify-content: space-between; margin-bottom: 20px; align-items: flex-start; }
.section-heading .meta { max-width: 600px; }
.cart-meta { margin: 12px 0 20px; color: var(--muted); font-size: 12px; gap: 8px; }
.pill { display: inline-flex; align-items: center; padding: 4px 8px; background: #eef1f4; color: var(--muted); border-radius: 6px; font-size: 11px; line-height: 1.4; font-weight: 500; }
.pill.ok { background: var(--green-soft); color: var(--green-hover); }
.pill.warn { background: var(--ochre-soft); color: var(--ochre); }
.pill.error { background: var(--red-soft); color: var(--red); }
.note { padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 16px 0; font-size: 13px; line-height: 1.5; }
.note.warning { background: var(--ochre-soft); border-color: #eeddb5; color: #765119; }
.note.error { background: var(--red-soft); border-color: #efd1ce; color: var(--red); }
.note .actions { margin-top: 12px; }
.note ul { margin: 8px 0; padding-left: 20px; }
.note p { margin-top: 4px; }
.empty, .loading, .report-empty, .report-loading { padding: 28px 20px; background: var(--surface); color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; }
.table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; line-height: 1.5; }
caption { text-align: left; font-weight: 600; font-size: 13px; margin-bottom: 12px; color: var(--muted); }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
th { color: var(--muted); font-size: 11px; line-height: 1.4; background: var(--surface); font-weight: 600; white-space: normal; }
td strong, td small { display: block; }
td strong { font-weight: 600; }
td small { margin-top: 4px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
td.numeric, th.numeric, td[data-label='Сумма'], td[data-label='Сумма выбранных строк'], td[data-label='Минимальная сумма'], td[data-label='Цена'], td[data-label='Количество'], td[data-label='Заказано'], td[data-label='В документе'], td[data-label='Разница цены'], td[data-label='Разница количества'], td[data-label='Повышение цен'], td[data-label='Снижение цен'] { text-align: right; }
td.quantity { width: 128px; }
.quantity-input { width: 108px; font-size: 14px; text-align: right; }
.cart-panel .actions { margin-top: 20px; align-items: stretch; }
.cart-panel .actions button { flex: 1; }
.cart-panel { position: sticky; top: 20px; }
.cart-panel ul { padding-left: 20px; margin: 12px 0; }
.list-section, .preview { margin-top: 20px; }
.selected-row { background: var(--green-soft); }
.preview .summary { display: flex; flex-wrap: wrap; gap: 16px 32px; padding: 20px 0; margin: 4px 0 12px; border-bottom: 1px solid var(--line); }
.summary strong { font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -.5px; display: block; margin-top: 4px; }
.summary .warning-text, .warning-text { color: var(--ochre); }
.candidate-list { margin: 8px 0 0; padding-left: 16px; color: var(--muted); font-size: 12px; }
.preview td { min-width: 150px; }
.preview label { margin-top: 12px; }
.supplier-choice, .selection-reason { width: 100%; min-width: 0; }
.preparation-actions { margin: 20px 0 12px; align-items: stretch; }
.prepared-version { padding: 12px 0; border-bottom: 1px solid var(--line); }
.prepared-version > summary { font-weight: 600; }
.prepared-version table { margin-top: 16px; }
.work-sections { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; background: transparent; min-width: 0; }
.work-sections.sidebar { position: sticky; top: 24px; padding: 4px 0; }
.work-sections button { min-width: 0; min-height: 44px; border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: var(--radius); text-align: left; padding: 11px 12px; font-size: 13px; font-weight: 500; }
.work-sections button:hover { color: var(--ink); background: #eaedf1; }
.work-sections button.current { background: var(--green-soft); color: var(--green-hover); font-weight: 600; border-color: #d3e8dd; }
.order-context { display: flex; gap: 8px 20px; flex-wrap: wrap; align-items: center; padding: 12px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; }
.context-title { font-size: 13px; font-weight: 600; }
.section-title { margin-bottom: 20px; }
.invoice-workspace .section-heading { margin-bottom: 24px; }
.invoice-upload { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 12px 16px; margin: 20px 0; background: var(--surface); }
.invoice-upload > label, .invoice-workspace > label { max-width: 760px; margin: 16px 0; }
.invoice-upload .actions { margin: 16px 0; }
.invoice-upload summary { font-weight: 600; }
.invoice-upload input[type=file] { width: 100%; background: var(--paper); padding: 8px; }
input[type=file]::file-selector-button { border: 1px solid var(--line-strong); border-radius: 4px; background: var(--paper); padding: 6px 10px; margin-right: 12px; color: var(--ink); font: inherit; cursor: pointer; }
.template-links a, .invoice-version-context a { display: inline-flex; align-items: center; min-height: 44px; color: var(--green-hover); text-underline-offset: 3px; }
.invoice-version-context { padding: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 20px 0; }
.invoice-version-context > strong { font-size: 17px; font-weight: 600; }
.invoice-version-context > p { margin: 8px 0; }
.invoice-summary { display: flex; flex-wrap: wrap; gap: 16px 32px; margin: 20px 0; }
.price-effects { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.price-effects > span { width: 100%; color: var(--muted); font-size: 12px; }
.check-field { flex-direction: row; align-items: center; gap: 12px; min-height: 44px; font-size: 13px; color: var(--ink); width: fit-content; }
.check-field input { order: -1; width: 18px; height: 18px; min-height: 18px; padding: 0; accent-color: var(--green); flex: 0 0 auto; }
.invoice-activation { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 24px; }
.invoice-activation label { max-width: 760px; margin: 16px 0; }
.invoice-activation .meta { margin-top: 12px; }
.invoice-workspace td { min-width: 124px; }
.invoice-workspace th:first-child, .invoice-workspace td:first-child { width: 24%; }
details { margin-top: 8px; }
summary { cursor: pointer; min-height: 44px; padding: 11px 0; color: var(--green-hover); }
.readonly { margin-top: 16px; }
.report-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.report-header > div { min-width: 0; }
.report-filters { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; padding: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--surface-radius); margin: 20px 0; }
.report-filters label { flex: 1 1 160px; }
.report-filters input, .report-filters select { width: 100%; }
.report-filters button { flex: 0 0 auto; }
.report-kpis { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; margin: 24px 0; }
.report-kpi { min-width: 0; padding: 4px 16px 4px 0; border-right: 1px solid var(--line); }
.report-kpi:last-child { border-right: 0; }
.report-kpi > small, .report-kpi .metric-label { display: block; font-size: 12px; line-height: 1.45; color: var(--muted); font-weight: 400; }
.report-kpi > strong, .report-kpi .metric-value { display: block; font-size: 30px; font-weight: 600; line-height: 1.2; letter-spacing: -.7px; margin: 8px 0; overflow-wrap: anywhere; }
.report-kpi > p, .report-kpi .metric-detail { color: var(--tertiary); font-size: 12px; line-height: 1.45; }
.report-finance-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; margin: 24px 0; align-items: stretch; }
.report-finance { min-width: 0; margin: 0 !important; }
.report-finance > h2 { font-size: 17px; margin-bottom: 8px; }
.report-finance .table-wrap { margin-top: 20px; }
.report-finance table { font-size: 13px; }
.report-finance td, .report-finance th { padding: 12px 8px; }
.finance-money-group { padding: 20px 0 4px; border-top: 1px solid var(--line); }
.finance-money-group + .finance-money-group { margin-top: 20px; }
.finance-group-label { display: block; color: var(--muted); font-size: 12px; }
.finance-main-amount { display: block; margin: 8px 0 2px; font-size: clamp(26px,2.5vw,34px); line-height: 1.2; font-weight: 600; letter-spacing: -.7px; overflow-wrap: anywhere; }
.finance-amount-caption { display: block; color: var(--tertiary); font-size: 12px; }
.finance-price-effects { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin-top: 24px; }
.finance-price-effects small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.finance-price-effects strong { display: block; margin-top: 4px; font-size: 18px; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
.finance-status { display: inline-block; margin-top: 20px; padding: 4px 8px; border-radius: 4px; background: var(--surface); color: var(--muted); font-size: 11px; line-height: 1.5; }
.finance-status.needs-check { color: var(--ochre); background: var(--ochre-soft); }
.report-methods { margin: 20px 0; padding-top: 4px; padding-bottom: 4px; }
.report-methods > summary { color: var(--muted); font-size: 13px; font-weight: 500; }
.report-methods[open] { padding-bottom: 20px; }
.report-methods .report-warnings { margin-bottom: 0; padding-left: 20px; font-size: 12px; color: var(--muted); }
.report-methods .report-warnings li + li { margin-top: 8px; }
.report-section { margin: 20px 0; }
.report-section > .subtitle { margin-bottom: 20px; }
.report-section > h2 { margin-bottom: 8px; }
.report-totals { font-size: 14px; }
.report-totals td { font-weight: 600; }
.report-section .table-wrap { margin-top: 20px; }
.report-documents td, .report-issues td { min-width: 108px; }
.report-section button, .report-section a { white-space: normal; }
.report-finance .warning-text, .report-kpi .warning-text { color: var(--ochre); }
.report-loading { min-height: 180px; display: grid; align-content: center; justify-items: start; }
.report-empty { margin: 16px 0; }
.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; }
footer { color: var(--tertiary); font-size: 11px; line-height: 1.5; margin: 32px 0 0; border-top: 1px solid var(--line); padding: 16px 0 0; }
@media (max-width: 1279px) { .shell { padding-right: 24px; padding-left: 24px; } .app-layout { gap: 24px; } .workspace { grid-template-columns: 1fr; } .cart-panel { position: static; } }
@media (max-width: 1119px) {
  .app-layout { grid-template-columns: minmax(0,1fr); gap: 20px; }
  .work-sections, .work-sections.sidebar { position: static; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; padding: 0; }
  .work-sections button { text-align: center; padding: 10px 8px; }
  .app-main > .page-heading { margin-bottom: 20px; }
  .report-finance-grid { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 760px) {
  .shell { padding: 0 16px 20px; }
  .report-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px 16px; }
  .report-kpi:nth-child(even) { border-right: 0; }
  .report-header { display: block; }
  .report-header > .actions { margin-top: 16px; }
  .report-filters label { flex: 1 1 140px; }
  .paper { padding: 20px; }
}
@media (max-width: 600px) {
  .shell { padding: 0 12px 16px; }
  .topbar { min-height: 76px; padding: 16px 0; gap: 12px; align-items: flex-start; }
  .brand { font-size: 22px; gap: 8px; max-width: 190px; }
  .stand-badge { font-size: 10px; padding: 4px 6px; }
  .identity { max-width: 142px; gap: 6px; font-size: 11px; }
  main { margin-top: 20px; }
  .app-layout { gap: 20px; }
  .work-sections, .work-sections.sidebar { grid-template-columns: repeat(2,minmax(0,1fr)); }
  h1 { font-size: 25px; letter-spacing: -.5px; }
  h2 { font-size: 19px; }
  .paper { padding: 20px 16px; }
  .login { margin: 32px auto; padding: 24px 20px; }
  .subtitle { font-size: 13px; }
  .toolbar { padding: 16px; gap: 12px; }
  .toolbar label, .toolbar .search { min-width: 0; width: 100%; }
  .toolbar .actions { width: 100%; margin-left: 0; }
  .actions button { flex: 1 1 140px; }
  .order-context { gap: 8px; padding: 12px; }
  .order-context .context-title { width: 100%; }
  .report-filters { padding: 16px; gap: 12px; }
  .report-filters label { flex: 1 1 100%; width: 100%; }
  .report-filters button { width: 100%; }
  .report-kpis { gap: 20px 12px; margin: 20px 0; }
  .report-kpi { padding-right: 12px; }
  .report-kpi > strong, .report-kpi .metric-value { font-size: 28px; }
  .report-finance-grid { gap: 16px; margin: 20px 0; }
  .report-section { margin: 16px 0; }
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  caption { display: block; margin-bottom: 12px; }
  thead { display: none; }
  tbody tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 12px 0; background: var(--paper); }
  tbody tr:hover { background: var(--paper); }
  td, tbody tr:last-child td { display: grid; grid-template-columns: minmax(72px,.8fr) minmax(0,1.5fr); gap: 12px; border: 0; padding: 7px 0; width: 100%; min-width: 0 !important; text-align: left !important; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.5; overflow-wrap: anywhere; }
  td > div { min-width: 0; overflow-wrap: anywhere; }
  td strong { font-size: 13px; }
  td label { margin-top: 8px; }
  td.quantity, .invoice-workspace th:first-child, .invoice-workspace td:first-child { width: 100%; }
  .quantity-input { width: 100%; }
  .preview .summary { gap: 16px 24px; }
  .summary strong { font-size: 24px; }
  .note { padding: 12px; }
  .invoice-upload, .invoice-version-context { padding: 12px; }
  .invoice-summary { gap: 12px 24px; }
  .price-effects { gap: 8px 16px; }
  .invoice-workspace select, .invoice-upload select { width: 100%; }
  footer { margin-top: 24px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
