:root {
  --brand: #262626;        /* фон логотипа и меню */
  --brand-2: #333333;
  --red: #d9261c;          /* красный из логотипа */
  --red-hover: #b81f17;
  --red-soft: #fdecea;
  --text: #1c1c1e;
  --text-2: #5f5e5a;
  --text-3: #8a8983;
  --line: #e7e5df;
  --bg: #f6f5f2;
  --white: #ffffff;
  --hover: #faf9f7;
  --tag-bg: #f1efe8;
  --ok-bg: #e3f3ea;
  --border-hover: #cfccc4;
  --seg-on: var(--brand);
  color-scheme: light;
  --ok: #1d7a4c;
  --radius: 8px;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 14px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Поля и кнопки */
label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
input, select {
  width: 100%; height: 36px; padding: 0 10px; font: inherit; color: var(--text);
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
}
input:focus, select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
button {
  height: 36px; padding: 0 14px; font: inherit; cursor: pointer; white-space: nowrap;
  background: var(--white); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
}
button:hover { border-color: var(--border-hover); }
button.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 500; }
button.primary:hover { background: var(--red-hover); }
button.link { border: none; background: none; color: var(--red); padding: 0; height: auto; }
button.icon { width: 32px; height: 32px; padding: 0; color: var(--text-3); border-color: transparent; background: none; font-size: 16px; }
button.icon:hover { color: var(--red); background: var(--red-soft); }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* Экран входа */
.auth { min-height: 100vh; background: var(--brand); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.auth img { width: 180px; margin-bottom: 24px; }
.auth .card { width: 100%; max-width: 340px; }
.auth .field { margin-bottom: 12px; }
.auth button.primary { width: 100%; margin-top: 6px; }
.auth .langs { margin-top: 20px; }

/* Каркас */
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--brand); color: #b4b2a9; display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { display: block; padding: 0 4px 20px; }
.sidebar .logo img { width: 140px; display: block; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 2px;
  color: #d3d1c7; text-decoration: none; border-radius: var(--radius);
}
.nav a:hover { background: var(--brand-2); color: #fff; }
.nav a.active { background: var(--brand-2); color: #fff; box-shadow: inset 3px 0 0 var(--red); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .bottom { margin-top: auto; border-top: 1px solid #3a3a3a; padding-top: 14px; }
.sidebar .user { color: #fff; font-size: 13px; padding: 0 4px; }
.sidebar .user .muted { color: #888780; font-size: 12px; }
.sidebar .bottom button.link { color: #d3d1c7; font-size: 13px; padding: 8px 4px 0; }
.sidebar .bottom button.link:hover { color: #fff; }
.langs { display: inline-flex; background: var(--brand-2); border-radius: var(--radius); padding: 3px; margin: 12px 4px 0; }
.langs button { height: 26px; padding: 0 12px; border: none; background: none; color: #b4b2a9; font-size: 12px; border-radius: 6px; }
.langs button.on { background: var(--red); color: #fff; }
.main { padding: 28px 32px 48px; max-width: 1100px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head .actions { display: flex; gap: 8px; }

/* Карточки и таблицы */
.card { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; }
.table th { font-weight: 500; color: var(--text-3); font-size: 12px; text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--hover); }
.table input { height: 32px; }
.table th.num, .table td.num { text-align: right; }
.empty { color: var(--text-3); padding: 24px 0; text-align: center; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--tag-bg); color: var(--text-2); }
.tag.red { background: var(--red-soft); color: var(--red-hover); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }

/* Формы в строку */
.row { display: grid; gap: 10px; align-items: end; }
.row-new { grid-template-columns: 160px minmax(0, 1fr) auto; }
.row-base { grid-template-columns: minmax(0, 1fr) 110px auto; }
.row-manual { grid-template-columns: minmax(0, 1fr) 110px 130px 110px auto; }
.row-material { grid-template-columns: 140px minmax(0, 1fr) 110px 140px auto; }
.row-user { grid-template-columns: minmax(0, 1fr) 150px 150px 150px auto; }
.row-settings { grid-template-columns: 180px 180px auto; }
.segment { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; margin-bottom: 14px; }
.segment button { height: 28px; border: none; background: none; border-radius: 6px; color: var(--text-2); }
.segment button.on { background: var(--seg-on); color: #fff; }

/* Итоги */
.totals { margin-left: auto; max-width: 360px; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; color: var(--text-2); }
.totals div span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; font-size: 18px; font-weight: 600; color: var(--text); }

/* Статистика */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }
.stat b { display: block; font-size: 26px; font-weight: 600; margin-top: 4px; }

/* Диалог и уведомления */
dialog { border: none; border-radius: 12px; padding: 24px; background: var(--white); color: var(--text); width: min(420px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20, 20, 20, .45); }
dialog .field { margin-bottom: 12px; }
dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--brand); color: #fff; padding: 10px 18px; border-radius: var(--radius); opacity: 0; pointer-events: none; transition: .2s; z-index: 10; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: var(--red); }
.print-head { display: none; }

/* Телефон */
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .sidebar .logo { padding: 0; }
  .sidebar .logo img { width: 90px; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
  .nav a { padding: 8px 10px; font-size: 13px; }
  .sidebar .bottom { margin: 0; border: none; padding: 0; width: 100%; display: flex; align-items: center; justify-content: space-between; }
  .main { padding: 20px 14px 40px; }
  .row-new, .row-base, .row-manual, .row-material, .row-user, .row-settings { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
}

/* Печать калькуляции */
@media print {
  body { background: #fff; }
  .sidebar, .no-print, .page-head .actions, button.icon { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; max-width: none; }
  .card { border: none; padding: 0; }
  .print-head { display: flex; justify-content: space-between; align-items: center; background: var(--brand); padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-head img { width: 110px; }
  .table input { border: none; padding: 0; height: auto; }
}

/* Таблица калькуляции: фиксированные колонки, «Позиция» забирает свободное место */
#items { table-layout: fixed; min-width: 760px; }
#items th:nth-child(1) { width: 36px; }
#items th:nth-child(3) { width: 104px; }
#items th:nth-child(4) { width: 90px; }
#items th:nth-child(5) { width: 120px; }
#items th:nth-child(6) { width: 110px; }
#items th:nth-child(7) { width: 120px; }
#items th:nth-child(8) { width: 44px; }
.table-wrap { overflow-x: auto; }

/* Ряды полей: гибкая раскладка, переносится на узких экранах */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row > div { flex: 1 1 130px; min-width: 0; }
.row > div:has(input[name="name"]) { flex: 3 1 220px; }
.row > div:has(select[name="material_id"]) { flex: 4 1 260px; }
.row > button { flex: none; }
.row-settings > div { flex: 0 1 180px; }

/* Язык и тема рядом */
.prefs { display: flex; align-items: center; gap: 8px; margin: 12px 4px 0; }
.prefs .langs { margin: 0; }
.auth .prefs { margin-top: 20px; }
.theme-btn { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; background: var(--brand-2); border: none; color: #d3d1c7; border-radius: var(--radius); }
.theme-btn:hover { color: #fff; border: none; }
.theme-btn svg { width: 17px; height: 17px; }
.mat-pick { flex: 4 1 280px !important; }

/* Тёмная тема (на печать не влияет — печать всегда светлая) */
@media screen {
  [data-theme="dark"] {
    color-scheme: dark;
    --text: #ecebe8;
    --text-2: #b4b2a9;
    --text-3: #8f8d86;
    --line: #34343a;
    --bg: #141414;
    --white: #1f1f21;
    --hover: #27272a;
    --tag-bg: #2c2c2f;
    --ok-bg: #173226;
    --ok: #5cc98f;
    --red-soft: #3b1714;
    --border-hover: #4a4a50;
    --seg-on: #3a3a3f;
  }
  [data-theme="dark"] input, [data-theme="dark"] select { background: #18181a; }
  [data-theme="dark"] .tag.red { color: #f08a82; }
  [data-theme="dark"] .sidebar { border-right: 1px solid var(--line); }
}

/* Панель фильтров */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.toolbar input { flex: 2 1 240px; }
.toolbar select { flex: 1 1 180px; width: auto; }
.table tr.group td { background: var(--bg); color: var(--text-2); font-weight: 600; font-size: 12px; letter-spacing: .02em; padding-top: 10px; }

/* Выбор позиции с поиском */
.picker { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.picker-bar { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
.picker-bar select { flex: 0 1 230px; width: auto; }
.picker-bar input { flex: 1 1 auto; }
.pk-list { max-height: 300px; overflow-y: auto; }
.pk-item { display: flex; width: 100%; height: auto; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 12px; text-align: left; border: none; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--white); white-space: normal; }
.pk-item:hover { background: var(--hover); border-color: var(--line); }
.pk-item.on { background: var(--red-soft); box-shadow: inset 3px 0 0 var(--red); }
.pk-name { display: flex; flex-direction: column; gap: 2px; }
.pk-name small { color: var(--text-3); font-size: 11px; }
.pk-meta { color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pk-list .empty { padding: 20px; }
.pk-foot { padding: 6px 12px; border-top: 1px solid var(--line); background: var(--bg); }
.pick-row { margin-top: 12px; }
.pick-row .pick-chosen { flex: 4 1 280px; align-self: center; }
.pick-row .pick-qty { flex: 0 1 120px; }
@media (max-width: 800px) {
  .picker-bar { flex-direction: column; }
  .picker-bar select { flex: none; width: 100%; }
}

/* Вкладки проекта */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -6px 0 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--text-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--red); font-weight: 500; }
.tabs .count { display: inline-block; min-width: 18px; padding: 0 5px; font-size: 11px; line-height: 18px; text-align: center; border-radius: 9px; background: var(--tag-bg); color: var(--text-2); }
button.danger { color: var(--red); border-color: var(--red-soft); }
button.danger:hover { background: var(--red-soft); border-color: var(--red); }
.empty-state { text-align: center; padding: 48px 20px; }

/* Маржа и НДС проекта */
.calc-settings { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.calc-setting { display: flex; flex-direction: column; gap: 6px; }
.calc-setting .label { font-size: 12px; color: var(--text-2); }
.calc-setting label { margin: 0; }
.margin-box { display: flex; align-items: center; gap: 6px; }
.margin-box span { font-size: 18px; color: var(--text-2); }
.margin-box input { width: 90px; font-size: 16px; font-weight: 600; text-align: center; }
.switch { display: inline-flex; align-items: center; gap: 10px; height: 36px; padding: 0 14px 0 4px; border-radius: 18px; }
.switch .knob { width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch.on .knob { background: var(--ok); }
.switch.on .knob::after { transform: translateX(18px); }
.switch .switch-text { font-weight: 500; }

/* Формы клиента и проекта */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
textarea { width: 100%; padding: 8px 10px; font: inherit; color: var(--text); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); resize: vertical; }
textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
[data-theme="dark"] textarea { background: #18181a; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.client-links { display: inline-flex; gap: 10px; }
.btn-link { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.btn-link:hover { border-color: var(--border-hover); }

/* Фото */
.photos-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.photos-head h2 { margin: 0; }
.upload-btn { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; margin: 0; background: var(--red); color: #fff; border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 500; }
.upload-btn:hover { background: var(--red-hover); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 8px; }
.gallery figure { position: relative; margin: 0; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .ph-del { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.55); color: #fff; }
.gallery .ph-del:hover { background: var(--red); color: #fff; }
.gallery .empty { grid-column: 1 / -1; }
.print-only { display: none; }
@media print {
  .print-only { display: block; margin-bottom: 10px; }
  .tabs, .calc-settings { display: none !important; }
}

/* Узкий экран: колонка не растягивается широкими таблицами (они прокручиваются внутри себя) */
@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .main, .sidebar { min-width: 0; }
  .calc-settings { gap: 16px; }
  .page-head { flex-wrap: wrap; }
}
.tabs { overflow-y: hidden; scrollbar-width: thin; }

/* Маржа каждой позиции */
#items { min-width: 880px; }
#items th:nth-child(7) { width: 92px; }
#items th:nth-child(8) { width: 120px; }
#items th:nth-child(9) { width: 44px; }
.item-margin { display: inline-flex; align-items: center; gap: 3px; }
.item-margin span { color: var(--text-3); }
.item-margin input { width: 58px; text-align: center; padding: 0 4px; }
.item-margin.own input { border-color: var(--red); background: var(--red-soft); font-weight: 600; }
.calc-setting button.link { align-self: flex-start; font-size: 12px; margin-top: 2px; }
@media print { .item-margin input { width: auto; background: none !important; border: none; } }

/* ---------- Коммерческое предложение: редактор ---------- */
.offer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 0; }
.offer-bar .primary { margin-left: auto; }
.of-sec h2 { margin-bottom: 14px; }
.of-req-preview { display: flex; gap: 16px; align-items: center; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.of-req-preview img { width: 110px; background: #262626; padding: 8px 10px; border-radius: 8px; }
.of-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.of-slot { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.of-slot-img { aspect-ratio: 16 / 10; border: 2px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--bg); }
.of-slot-img img { width: 100%; height: 100%; object-fit: contain; }
.of-slot-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.of-slot-actions .icon { margin-left: auto; }
.upload-btn.small { height: 32px; font-size: 13px; padding: 0 10px; }
.of-rows input { height: 32px; }
label.check { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 0 8px; font-size: 14px; color: var(--text); cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--red); }

/* ---------- Коммерческое предложение: документ (A4) ---------- */
.offer-wrap { overflow-x: auto; padding-bottom: 8px; }
.offer-sheet {
  width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; color: #1c1c1e;
  box-shadow: 0 2px 14px rgba(0,0,0,.12); padding: 0 16mm 14mm; box-sizing: border-box;
  font-family: "Segoe UI", Arial, sans-serif; font-size: 11pt; line-height: 1.45;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.of-head { background: #262626; margin: 0 -16mm; padding: 9mm 0 6mm; text-align: center; }
.of-head img { width: 64mm; display: block; margin: 0 auto; }
.of-byline { color: #e9e7e1; font-size: 10pt; letter-spacing: .06em; margin-top: 1mm; font-weight: 600; }
.of-req { text-align: center; font-size: 8.5pt; color: #444; border-bottom: 1px solid #d0cec8; padding: 4mm 0 3mm; line-height: 1.5; }
.of-meta { display: flex; justify-content: space-between; align-items: flex-end; margin: 5mm 0 4mm; font-size: 10.5pt; }
.of-to { display: inline-block; min-width: 60mm; border-bottom: 1px solid #555; padding: 0 2mm; }
.of-title { text-align: center; color: #b71c1c; font-size: 15pt; font-weight: 700; margin: 2mm 0 4mm; letter-spacing: .02em; }
.of-intro { white-space: pre-wrap; margin: 0 0 3mm; }
.of-list { margin: 0 0 4mm; padding-left: 7mm; }
.of-list li { margin-bottom: 1mm; }
.of-imgs { display: grid; gap: 6mm; margin: 4mm 0 5mm; }
.of-imgs-1 { grid-template-columns: 1fr; }
.of-imgs-2 { grid-template-columns: 1fr 1fr; }
.of-imgs-3 { grid-template-columns: 1fr 1fr 1fr; }
.of-img { margin: 0; text-align: center; break-inside: avoid; }
.of-img img { width: 100%; max-height: 60mm; object-fit: contain; display: block; margin: 0 auto; }
.of-img-empty { height: 45mm; border: 1.5px dashed #b8b6b0; border-radius: 2mm; display: flex; align-items: center; justify-content: center; color: #9a9893; font-size: 9pt; }
.of-img figcaption { font-size: 9pt; color: #555; margin-top: 2mm; }
.of-h2 { color: #b71c1c; font-size: 12.5pt; font-weight: 700; margin: 5mm 0 2.5mm; }
.of-table { width: 100%; border-collapse: collapse; font-size: 10pt; break-inside: avoid; }
.of-table th { background: #ecebe7; font-weight: 600; text-align: left; }
.of-table th, .of-table td { border: 1px solid #bdbbb5; padding: 2mm 2.5mm; vertical-align: top; }
.of-table td.num { text-align: right; white-space: nowrap; }
.of-table .of-sum td { background: #f6f5f2; }
.of-total { margin: 4mm 0 2mm; font-size: 11pt; }
.of-sign { margin-top: 9mm; break-inside: avoid; }
.of-sign-row { display: flex; justify-content: space-between; gap: 8mm; margin-top: 5mm; flex-wrap: wrap; }

@media print {
  @page { size: A4; margin: 0; }
  body.printing-offer .sidebar, body.printing-offer .page-head, body.printing-offer .tabs,
  body.printing-offer .offer-bar, body.printing-offer .print-head, body.printing-offer .toast { display: none !important; }
  body.printing-offer .layout { display: block; }
  body.printing-offer .main { padding: 0; max-width: none; }
  body.printing-offer .offer-wrap { overflow: visible; padding: 0; }
  body.printing-offer .offer-sheet { box-shadow: none; margin: 0; }
}
.form-grid > div:has(#of-title) { grid-column: 1 / -1; }
.of-table th { white-space: nowrap; }

/* КП: новый логотип (фон #121212) и способы оплаты */
.of-head { background: #121212; padding: 7mm 0 6mm; }
.of-head img { width: 70mm; }
.of-req-preview img { background: #121212; width: 130px; padding: 6px; }
.of-paysec { break-inside: avoid; }
.of-pay { display: flex; gap: 14mm; margin: 2mm 0 2mm; }
.of-pay figure { margin: 0; text-align: center; }
.of-pay img { width: 34mm; height: 34mm; display: block; image-rendering: pixelated; border: 1px solid #e2e0da; padding: 1.5mm; background: #fff; }
.of-pay figcaption { margin-top: 2mm; font-weight: 700; font-size: 11pt; }
.of-pay-edit { gap: 24px; margin-top: 12px; }
.of-pay-edit img { width: 120px; height: 120px; }
.doc-lang { align-items: center; }
/* Логотипы Click и Payme под QR-кодами */
.of-pay figcaption { display: flex; justify-content: center; }
.of-pay img.pay-logo { width: auto; height: 7mm; max-width: 34mm; border: none; padding: 0; background: none; image-rendering: auto; object-fit: contain; }
.of-pay-edit img.pay-logo { height: 26px; max-width: 120px; }

/* КП: кнопки сохранения и отправки */
.of-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.offer-bar .of-actions .primary { margin-left: 0; }
.of-actions label.check { margin: 0 6px 0 0; font-size: 13px; }
.send-dlg h2 { margin-bottom: 4px; }
.send-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.send-list button { width: 100%; text-align: left; height: auto; min-height: 40px; white-space: normal; padding: 8px 14px; }
.send-dlg textarea { margin-bottom: 4px; }
.send-dlg .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
@media print { body.printing-offer #dialog, body.printing-offer #toast { display: none !important; } }
/* КП компактнее, чтобы обычное предложение помещалось на один лист без уменьшения */
.offer-sheet { font-size: 10.5pt; line-height: 1.4; padding: 0 14mm 10mm; }
.of-head { margin: 0 -14mm; padding: 5mm 0 4mm; }
.of-head img { width: 56mm; }
.of-req { padding: 2.5mm 0 2mm; font-size: 8pt; }
.of-meta { margin: 3.5mm 0 2.5mm; }
.of-title { font-size: 14pt; margin: 1mm 0 3mm; }
.of-imgs { gap: 5mm; margin: 3mm 0 3mm; }
.of-img img { max-height: 50mm; }
.of-img-empty { height: 34mm; }
.of-img figcaption { margin-top: 1mm; font-size: 8.5pt; }
.of-h2 { font-size: 12pt; margin: 3.5mm 0 2mm; }
.of-table { font-size: 9.5pt; }
.of-table th, .of-table td { padding: 1.3mm 2.2mm; }
.of-total { margin: 3mm 0 1mm; }
.of-list { margin-bottom: 2.5mm; }
.of-list li { margin-bottom: .5mm; }
.of-pay img { width: 28mm; height: 28mm; }
.of-pay img.pay-logo { height: 6mm; }
.of-sign { margin-top: 6mm; }
.of-sign-row { margin-top: 4mm; }

/* КП: банковские реквизиты рядом с QR-кодами */
.of-pay-grid { display: flex; gap: 6mm; align-items: stretch; margin-top: 1.5mm; }
.of-bank { flex: 1 1 auto; border: 1px solid #d6d4ce; border-radius: 2mm; padding: 2.5mm 3.5mm; }
.of-qr { flex: none; border: 1px solid #d6d4ce; border-radius: 2mm; padding: 2.5mm 3.5mm; }
.of-pay-sub { font-weight: 700; font-size: 9.5pt; margin-bottom: 1.5mm; color: #1c1c1e; }
.of-bank table { border-collapse: collapse; width: 100%; font-size: 9pt; }
.of-bank th { text-align: left; font-weight: 400; color: #6b6a66; padding: .6mm 3mm .6mm 0; white-space: nowrap; vertical-align: top; width: 1%; }
.of-bank td { padding: .6mm 0; color: #1c1c1e; }
.of-qr .of-pay { gap: 6mm; margin: 0; }
.of-qr .of-pay img:not(.pay-logo) { width: 26mm; height: 26mm; }

/* КП: № и дата слева, «Кому» справа; исполнитель под подписью */
.of-meta { align-items: flex-start; }
.of-meta-left { line-height: 1.5; }
.of-regno { font-weight: 600; }
.of-meta-right { text-align: right; padding-top: 1mm; }
.of-exec { margin-top: 5mm; font-size: 9pt; color: #444; line-height: 1.5; }

/* КП: таблица с ценой за единицу и НДС по строкам */
.of-table { table-layout: auto; font-size: 9pt; }
.of-table th { white-space: normal; line-height: 1.25; vertical-align: bottom; }
.of-table .c-no { width: 7mm; }
.of-table .c-unit { width: 13mm; }
.of-table .c-qty { width: 13mm; }
.of-table .c-money { width: 22mm; text-align: right; }
.of-table.with-vat .c-money { width: 21mm; }
.of-table td.num { text-align: right; white-space: nowrap; }
.of-table .of-grand td { background: #262626; color: #fff; border-color: #262626; font-size: 10pt; padding-top: 2mm; padding-bottom: 2mm; }
.of-table .of-grand .of-note { font-weight: 400; color: #d3d1c7; font-size: 8.5pt; }
/* «Кому»: название клиента сразу после слова, без большого отступа */
.of-meta-right { text-align: left; max-width: 95mm; }
.of-to { min-width: 0; display: inline; padding: 0 1mm; border-bottom: 1px solid #555; }

/* Печать готовой страницы A4 (то же, что в PDF) */
#print-page { display: none; }
@media print {
  body.printing-page > *:not(#print-page) { display: none !important; }
  body.printing-page { margin: 0; padding: 0; background: #fff; }
  body.printing-page #print-page { display: block; margin: 0; padding: 0; }
  body.printing-page #print-page img { display: block; width: 210mm; height: 297mm; object-fit: fill; margin: 0; }
}
