:root {
  --accent:      #0B2D6E;
  --accent-mid:  #1A4BAF;
  --accent-pale: #EBF0FA;
  --withdrawn:   #7A1A1A;
  --withdrawn-bg:#FDF2F2;
  --border:      #DDE3ED;
  --text:        #1A1A2E;
  --muted:       #6B7280;
  --price-color: #0B2D6E;
  --row-alt:     #F7F9FC;
  --font:        'Segoe UI', system-ui, Arial, sans-serif;
  
  /* Базовый размер: 16px = 1rem */
  font-size: 16px;
}

/* ── Сброс и базовые стили ─────────────────────────────────*/
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 0.8125rem;   /* 13px */
  color: var(--text);
  background: #F4F6F9;
  padding: 2.5rem 1.5rem; /* 40px 24px */
  line-height: 1.5;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 20px rgba(0,0,0,.08);
  padding: 2.5rem 3rem 3.5rem; /* 40px 48px 56px */
}

/* ── Шапка ─────────────────────────────────────────────────*/
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 1.75rem;   /* 28px */
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 1.75rem;
  gap: 1.5rem;
}

.logo-area {
  display: flex;
  align-items: center;
  min-width: 160px;
}

.logo-area img {
  height: 48px;
  width: auto;
  display: block;
}

.logo-placeholder {
  width: 160px;
  height: 48px;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.6875rem;    /* 11px */
  letter-spacing: .03em;
}

.approve {
  text-align: right;
  font-size: 0.71875rem;   /* 11.5px */
  color: var(--muted);
  line-height: 1.7;
}
.approve strong {
  color: var(--text);
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

/* ── Заголовок документа ───────────────────────────────────*/
.doc-title { margin-bottom: 1.75rem; }

.doc-title h1 {
  font-size: 1.25rem;      /* 20px */
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
  letter-spacing: -.01em;
}

.doc-title h2 {
  font-size: 0.875rem;     /* 14px */
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.doc-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.71875rem;   /* 11.5px */
  color: var(--muted);
}
.doc-meta span::before { content: '· '; color: var(--accent-mid); }

/* ── Разделы ───────────────────────────────────────────────*/
.section-block { margin-top: 2.25rem; }

.section-title {
  font-size: 0.8125rem;    /* 13px */
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 0 0 0.5rem;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 0;
}

.section-title.withdrawn {
  color: var(--withdrawn);
  border-color: var(--withdrawn);
}

.subsection-title {
  font-size: 0.75rem;      /* 12px */
  font-weight: 600;
  color: var(--accent-mid);
  padding: 0.75rem 0 0.375rem;
  margin-top: 0.25rem;
  letter-spacing: .01em;
}

.subsection-mid-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-mid);
  padding: 0.75rem 0 0 0;
  margin-top: 0.25rem;
  letter-spacing: .01em;
}

.subsection-title.withdrawn { color: var(--withdrawn); }
.subsection-mid-title.withdrawn { color: var(--withdrawn); }

/* ── Таблицы ───────────────────────────────────────────────*/
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78125rem;   /* 12.5px */
}

thead th {
  font-size: 0.6875rem;    /* 11px */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding: 0.4375rem 0.625rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: transparent;
}
thead th:last-child { text-align: right; }

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }

/* ── Оптимизированные сложные селекторы ───────────────────*/
/* Вместо :not(.desc-row):not(.group-note) используем класс-маркер */
tbody tr:is(.data-row, .product-row):nth-child(even) {
  background: var(--row-alt);
}

td {
  padding: 0.5rem 0.625rem;
  vertical-align: top;
}

td.num {
  width: 92px;
  color: var(--muted);
  font-size: 0.71875rem;   /* 11.5px */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.name {
  color: var(--text);
  white-space: normal;
}

td.price {
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
  color: var(--price-color);
  font-variant-numeric: tabular-nums;
  width: 150px;
}

/* Строка с описанием позиции */
tr.desc-row td {
  font-size: 0.6875rem;    /* 11px */
  color: var(--muted);
  padding: 0 0.625rem 0.5625rem 0.625rem;
  background: transparent !important;
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
}

/* Строка-разделитель внутри таблицы (подгруппа) */
tr.group-note td {
  font-size: 0.6875rem;    /* 11px */
  font-weight: 600;
  color: var(--accent-mid);
  background: var(--accent-pale) !important;
  padding: 0.3125rem 0.625rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  letter-spacing: .01em;
}

/* Строка-заголовок продуктовой группы */
tr.product-header td {
  font-weight: 600;
  color: var(--accent-mid);
  padding: 0.625rem 0.625rem 0.125rem;
  font-size: 0.78125rem;   /* 12.5px */
}

tr.product-desc td {
  font-size: 0.6875rem;    /* 11px */
  color: var(--muted);
  padding: 0 0.625rem 0.625rem 0.625rem;
  line-height: 1.65;
  border-bottom: 1px solid var(--border);
}

/* Цена в строке-описании */
tr.desc-row td.price-inline {
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
  color: var(--price-color);
  font-variant-numeric: tabular-nums;
  vertical-align: top;
  padding: 0 0.625rem 0.5625rem 0.625rem;
  font-size: 0.6875rem;    /* 11px */
}

/* ── Блоки для разделов 7 и 8 с длинным описанием ─────────*/
.section-item {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.section-item-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--row-alt);
}

.section-item-header .item-num {
  font-size: 0.71875rem;   /* 11.5px */
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.section-item-header .item-price {
  font-size: 0.8125rem;    /* 13px */
  font-weight: 700;
  color: var(--price-color);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.section-item-body {
  padding: 0.625rem 0.75rem 0.75rem;
  font-size: 0.71875rem;   /* 11.5px */
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ── Сноски ────────────────────────────────────────────────*/
.fnote {
  font-size: 0.6875rem;    /* 11px */
  color: var(--muted);
  margin-top: 0.375rem;
  padding: 0.4375rem 0.75rem;
  background: #f9f9f9;
  border-radius: 4px;
  line-height: 1.6;
}

.fnote.warn {
  background: var(--withdrawn-bg);
}

/* ── Примечания ────────────────────────────────────────────*/
.notes-block {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1.5px solid var(--border);
}

.notes-block h3 {
  font-size: 0.8125rem;    /* 13px */
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 1rem;
}

.notes-list {
  list-style: none;
  counter-reset: note;
}

.notes-list li {
  counter-increment: note;
  display: flex;
  gap: 0.625rem;
  font-size: 0.71875rem;   /* 11.5px */
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 0.5625rem;
}

.notes-list li::before {
  content: counter(note) '.';
  min-width: 20px;
  color: var(--accent-mid);
  font-weight: 600;
  flex-shrink: 0;
  padding-top: 1px;
}

.notes-list li b { color: var(--text); font-weight: 600; }

.notes-footer {
  margin-top: 1.25rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
  font-size: 0.71875rem;   /* 11.5px */
  font-weight: 600;
  color: var(--text);
  text-align: center;
  letter-spacing: .01em;
}

/* ── ПЕЧАТНАЯ ВЕРСИЯ ──────────────────────────────────────*/
@media print {
  /* Сброс фонов и теней */
  body {
    background: white;
    padding: 0;
    margin: 0;
  }
  
  .page {
    max-width: none;
    margin: 0;
    padding: 0.5cm;
    box-shadow: none;
    background: white;
    border-radius: 0;
  }
  
  /* Убираем цветные фоны, где возможно (экономия тонера) */
  .fnote,
  .notes-list li::before,
  tr.group-note td,
  .section-item-header {
    background: none !important;
  }
  
  /* Гарантируем чёрный текст для важных элементов */
  .approve strong,
  .doc-title h1,
  .doc-title h2,
  .section-title,
  .subsection-title,
  .notes-footer,
  .price,
  .item-price {
    color: black !important;
  }
  
  /* Цены — чёрные и жирные */
  td.price,
  .item-price,
  .price-inline {
    color: black !important;
    font-weight: 700;
  }
  
  /* Убираем подложку у чётных строк */
  tbody tr:is(.data-row, .product-row):nth-child(even) {
    background: none !important;
  }
  
  /* Убираем цветные границы */
  .header,
  .section-title,
  .notes-block,
  .notes-footer {
    border-color: #ccc !important;
  }
  
  /* Ссылки — обычный текст (без подчёркиваний, если не нужно) */
  a {
    text-decoration: none;
    color: black;
  }
  
  /* Убираем лишние отступы и фоны у блоков примечаний */
  .fnote,
  .fnote.warn {
    border: 1px solid #ddd;
    background: none;
    padding: 4px 8px;
  }
  
  /* Принудительно показываем все строки (избегаем разрыва внутри таблицы) */
  tr, td, th {
    page-break-inside: avoid;
  }
  
  /* Заголовок документа не разрывается */
  .doc-title {
    page-break-after: avoid;
  }
  
  /* Блоки не разрываются внутри */
  .section-block,
  .notes-block {
    page-break-inside: avoid;
  }
}