:root {
  --ink: #0a0a0a;
  --ink-2: #131313;
  --ink-3: #1b1b1b;
  --paper: #ffffff;
  --muted: #8c8b86;
  --soft: #cfcbc3;
  --line: rgba(255,255,255,.12);
  --line-2: rgba(255,255,255,.2);
  --red: #ef3b36;
  --red-soft: rgba(239,59,54,.16);
  --glow: radial-gradient(ellipse 50% 80% at 84% 0%, rgba(239,59,54,.13), transparent 67%);
  --mono: 'DM Mono', monospace;
  --pad: clamp(16px, 3vw, 48px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--ink); color: var(--paper); font-family: 'Manrope', Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body { background: var(--glow), var(--ink); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

.eyebrow { display: block; color: var(--red); font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
h1, h2, h3 { letter-spacing: -.04em; margin: 0; }
h1 em, h2 em { color: var(--red); font-style: normal; font-weight: 400; }

.btn { height: 42px; padding: 0 20px; border-radius: 999px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; transition: background .2s, color .2s, border-color .2s; }
.btn-main { background: var(--red); color: #fff; }
.btn-main:hover { background: #fff; color: var(--ink); }
.btn-line { border: 1px solid var(--line-2); }
.btn-line:hover { border-color: var(--red); }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line-2); font-size: 16px; }
.icon-btn:hover { border-color: var(--red); }

input[type=text], input[type=number], input[type=search], input[type=password], input[type=date], select, textarea {
  background: rgba(255,255,255,.05); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); }
select option { background: var(--ink-2); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--soft); }
.field > span { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--soft); cursor: pointer; }
.check input { accent-color: var(--red); width: 16px; height: 16px; }

/* --- Вход --- */
.lock { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.lock-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 18px; padding: 36px; border: 1px solid var(--line); border-radius: 6px; background: rgba(19,19,19,.8); }
.lock-logo { height: 54px; align-self: flex-start; }
.lock h1 { font-size: 40px; font-weight: 600; line-height: .95; }
.lock-err { color: var(--red); margin: 0; font-size: 13px; }

/* --- Шапка --- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px; padding: 12px var(--pad); background: rgba(10,10,10,.86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top-logo { height: 36px; }
.top-home { display: flex; }
/* Возврат на сайт: как кнопка «Назад» в шапке основного сайта */
.back-link { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--soft); font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap; transition: color .25s, border-color .25s; }
.back-link span { color: var(--red); font-size: 16px; }
.back-link b { font-weight: 500; }
.back-link:hover { color: var(--paper); border-color: var(--red); }
.lock-back { align-self: center; margin-top: 4px; }
.top-title { display: flex; flex-direction: column; }
.top-title .eyebrow { margin: 0 0 2px; }
.top-title b { font-weight: 500; font-size: 12px; color: var(--muted); }
.top-settings { margin-left: auto; display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 14px; border-radius: 999px; background: rgba(255,255,255,.05); border: 1px solid var(--line); font-family: var(--mono); font-size: 11px; color: var(--soft); }
.top-settings label { display: flex; align-items: center; gap: 6px; }
.top-settings input[type=number] { width: 64px; padding: 6px 8px; border-radius: 999px; font-family: var(--mono); font-size: 12px; }
.switch { cursor: pointer; }
.switch input { display: none; }
.switch span { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); }
.switch input:checked + span { background: var(--red-soft); border-color: rgba(239,59,54,.6); color: #fff; }
.cart-btn i { font-style: normal; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: rgba(0,0,0,.25); display: inline-grid; place-items: center; font-size: 11px; }

/* --- Категории и поиск --- */
.cats { display: flex; gap: 6px; padding: 18px var(--pad) 0; overflow-x: auto; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats button { flex: none; padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--soft); border: 1px solid var(--line); }
.cats button:hover { color: #fff; }
.cats button.active { color: #fff; background: var(--red-soft); border-color: rgba(239,59,54,.55); }
.cats button i { font-style: normal; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-left: 6px; }
.search-row { display: flex; align-items: center; gap: 14px; padding: 14px var(--pad); }
.search-row input { flex: 1; max-width: 520px; border-radius: 999px; padding: 11px 18px; }
.search-row .muted { font-family: var(--mono); font-size: 11px; }

/* --- Каталог --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; padding: 6px var(--pad) 60px; }
.group-title { grid-column: 1 / -1; margin: 18px 0 2px; font-size: 15px; font-weight: 600; letter-spacing: -.02em; color: var(--soft); display: flex; gap: 12px; align-items: center; }
.group-title:before { content: ''; width: 32px; height: 1px; background: var(--red); flex: none; }
.card { position: relative; text-align: left; display: flex; flex-direction: column; background: var(--ink-2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; transition: border-color .25s, transform .25s; }
.card:hover { border-color: rgba(239,59,54,.5); transform: translateY(-2px); }
/* Фото подготовлены в едином стиле: квадрат 600×600 на тёплом светлом фоне */
/* Квадрат через padding-top: aspect-ratio не работает на iOS ≤ 14 */
.card-img { position: relative; overflow: hidden; background: #efede9; }
.card-img:before { content: ''; display: block; padding-top: 100%; }
.card-img img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.card:hover .card-img img { transform: scale(1.04); }
.card-img .noimg { position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%); text-align: center; font-family: var(--mono); font-size: 10px; color: #999; text-transform: uppercase; }
.card-body { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-sku { font-size: 17px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.card-type { font-size: 12px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.tags span { font-family: var(--mono); font-size: 10px; padding: 3px 7px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--soft); }
.card-price { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: baseline; }
.card-price b { font-size: 18px; letter-spacing: -.03em; }
.card-price small { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.card-add { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: #fff; font-size: 20px; line-height: 1; display: grid; place-items: center; opacity: 0; transition: opacity .2s; }
.card:hover .card-add { opacity: 1; }
.empty { grid-column: 1 / -1; color: var(--muted); padding: 40px 0; }

/* --- Выдвижные панели --- */
.sheet { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50; display: flex; justify-content: flex-end; }
.sheet-back { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); animation: fade .2s; }
.sheet-panel { --pp: clamp(16px, 3vw, 36px); position: relative; width: min(760px, 100%); height: 100%; overflow-y: auto; overflow-x: hidden; background: var(--glow), var(--ink-2); border-left: 1px solid var(--line); padding: 28px var(--pp) 40px; animation: slide .28s cubic-bezier(.2,.8,.2,1); }
.kp-panel { width: min(1180px, 100%); }
.small-panel { width: min(520px, 100%); }
.sheet-close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); font-size: 22px; line-height: 1; z-index: 2; }
.sheet-close:hover { border-color: var(--red); }
.sheet h2 { font-size: clamp(26px, 4vw, 36px); font-weight: 600; margin-bottom: 18px; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }

/* --- Конфигуратор --- */
.cfg-top { display: grid; grid-template-columns: 220px 1fr; gap: 22px; margin-bottom: 22px; padding-right: 40px; }
.cfg-img { position: relative; background: #efede9; border-radius: 6px; overflow: hidden; }
.cfg-img:before { content: ''; display: block; padding-top: 100%; }
.cfg-img img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.cfg-top h2 { margin-bottom: 4px; }
.cfg-params { font-size: 12.5px; line-height: 1.55; color: var(--soft); margin-top: 10px; }
.cfg-note { margin-top: 8px; font-size: 12px; color: var(--red); }
.opt { padding: 14px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: start; }
.opt > b { font-family: var(--mono); font-size: 10px; font-weight: 400; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-top: 9px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 13px; color: var(--soft); }
.chips button:hover { color: #fff; border-color: rgba(255,255,255,.45); }
.chips button.on { background: var(--red); border-color: var(--red); color: #fff; }
.chips button:disabled { opacity: .3; cursor: not-allowed; }
.chips button small { font-family: var(--mono); font-size: 10px; opacity: .8; margin-left: 4px; }
.chips input { width: 120px; }
.chip-sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 4px; }
.cfg-sum { position: sticky; bottom: -40px; margin: 18px calc(-1 * var(--pp)) -40px; padding: 18px var(--pp) 24px; background: rgba(19,19,19,.96); border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 12px 20px; align-items: center; }
.cfg-name { grid-column: 1 / -1; font-size: 13px; color: var(--soft); line-height: 1.45; }
.cfg-price b { font-size: 28px; letter-spacing: -.04em; }
.cfg-price small { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 2px; }
.cfg-buy { display: flex; gap: 10px; align-items: center; }
.qty { display: flex; align-items: center; height: 42px; border: 1px solid var(--line-2); border-radius: 999px; }
.qty button { width: 36px; height: 100%; font-size: 18px; color: var(--soft); }
.qty button:hover { color: #fff; }
.qty input { width: 56px; border: 0 !important; background: none !important; text-align: center; padding: 0 !important; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
details.cfg-params summary { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); cursor: pointer; margin-bottom: 6px; }
details.cfg-params summary::-webkit-details-marker { color: var(--red); }

/* Панель КП внизу экрана — только на телефоне и планшете */
.dock { display: none; }

/* --- КП --- */
.kp-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-right: 48px; margin-bottom: 18px; }
.kp-head h2 { margin: 0; }
.kp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kp-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 16px 0 20px; border-top: 1px solid var(--line); }
.kp-meta .wide { grid-column: span 2; }
.kp-lines { border-top: 1px solid var(--line); }
.kp-row { display: grid; grid-template-columns: 26px 56px minmax(0, 1fr) 70px 96px 120px 130px 150px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kp-row.head { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.kp-row .n { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.kp-row .ph { width: 56px; height: 56px; border-radius: 4px; background: #efede9; display: grid; place-items: center; overflow: hidden; }
.kp-row .ph.none { background: transparent; border: 1px dashed var(--line-2); }
.kp-row .ph img { width: 100%; height: 100%; object-fit: cover; }
.kp-row textarea { width: 100%; resize: vertical; min-height: 64px; font-size: 13px; line-height: 1.4; scrollbar-width: thin; }
.kp-row input { width: 100%; text-align: right; }
.kp-row .unit { text-align: center; }
.kp-row .sum { text-align: right; font-weight: 600; white-space: nowrap; }
.kp-row .price-cell { position: relative; }
.kp-row .price-cell.manual input { border-color: rgba(239,59,54,.6); }
.kp-row .price-cell small { position: absolute; right: 4px; bottom: -14px; font-family: var(--mono); font-size: 9px; color: var(--red); cursor: pointer; }
.kp-row .tools { display: flex; gap: 2px; justify-content: flex-end; }
.kp-row .tools button { width: 26px; height: 26px; border-radius: 50%; color: var(--muted); }
.kp-row .tools button:hover { color: #fff; background: rgba(255,255,255,.08); }
.kp-empty { padding: 40px 0; color: var(--muted); text-align: center; }
.kp-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-top: 18px; flex-wrap: wrap; }
.kp-total { text-align: right; }
.kp-total .big { font-size: 34px; font-weight: 700; letter-spacing: -.04em; }
.kp-total .sub { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.7; }

.saved-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.saved-item div { flex: 1; min-width: 0; }
.saved-item b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-item small { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.saved-item button { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 12px; }
.settings-grid { display: grid; gap: 12px; }
.settings-grid h3 { font-size: 15px; margin-top: 10px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; z-index: 90; background: #fff; color: var(--ink); padding: 12px 20px; border-radius: 999px; font-size: 13px; font-weight: 600; transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Адаптив --- */
/* iPhone увеличивает страницу при фокусе на поле со шрифтом < 16px */
@media (max-width: 900px) { input, select, textarea { font-size: 16px !important; } }
@media (max-width: 900px) {
  .top { flex-wrap: wrap; gap: 10px 14px; }
  .top-title { display: none; }
  .top-settings { order: 3; margin-left: 0; width: 100%; justify-content: space-between; }
  .cart-btn { margin-left: auto; }
  .kp-meta { grid-template-columns: 1fr 1fr; }
  .kp-row { grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "ph name name" "qty price sum" "unit tools tools"; row-gap: 8px; }
  .kp-row.head { display: none; }
  .kp-row .n { display: none; }
  .kp-row .ph { grid-area: ph; }
  .kp-row .name { grid-area: name; }
  .kp-row .unit { grid-area: unit; text-align: left; font-size: 12px; color: var(--muted); }
  .kp-row .qty { grid-area: qty; padding-left: 4px; padding-right: 4px; text-align: center; }
  .kp-row .price-cell { grid-area: price; }
  .kp-row .sum { grid-area: sum; align-self: center; }
  .kp-row .tools { grid-area: tools; }
}
@media (max-width: 900px) {
  .dock:not([hidden]) { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; align-items: center; gap: 12px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(19,19,19,.96); border-top: 1px solid var(--line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  .dock div { flex: 1; min-width: 0; }
  .dock b { display: block; font-size: 18px; letter-spacing: -.03em; }
  .dock small { font-family: var(--mono); font-size: 10px; color: var(--muted); }
  body.has-dock .grid { padding-bottom: 100px; }
  body.has-dock .toast { bottom: 90px; }
}
@media (max-width: 600px) {
  .back-link { height: 34px; padding: 0 12px; }
  /* Каталог списком: фото слева, данные справа */
  .grid { grid-template-columns: 1fr; gap: 0; padding-top: 0; }
  .group-title { margin: 16px 0 4px; }
  .card { flex-direction: row; align-items: center; gap: 12px; padding: 10px 0; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
  .card:hover { transform: none; }
  .card-img { width: 84px; flex: none; border-radius: 6px; }
  .card-body { padding: 0; min-width: 0; gap: 4px; }
  .card-sku { font-size: 15px; }
  .card-type { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card-price { justify-content: flex-start; gap: 6px; padding: 2px 44px 0 0; }
  .card-price b { font-size: 15px; }
  .card-add { top: auto; bottom: 12px; right: 0; opacity: 1; width: 32px; height: 32px; }
  .tags span:nth-child(n+5) { display: none; }
  /* Карточка модели: фото на всю ширину, параметры строками с прокруткой */
  #cfg .sheet-close { background: rgba(10,10,10,.7); }
  .cfg-top { gap: 14px; margin-bottom: 8px; }
  .cfg-img { margin: -28px calc(-1 * var(--pp)) 0; border-radius: 0; }
  .cfg-img:before { padding-top: 82%; }
  .opt { padding: 10px 0; }
  .opt .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: calc(-1 * var(--pp)); padding-right: var(--pp); }
  .opt .chips::-webkit-scrollbar { display: none; }
  .opt .chips > * { flex: none; }
  .cfg-buy { justify-content: space-between; }
  .cfg-buy .btn { flex: 1; }
  .top-settings { padding-left: 10px; gap: 6px; }
  .top-settings input[type=number] { width: 54px; }
  .cfg-top { grid-template-columns: 1fr; padding-right: 0; }
  .opt { grid-template-columns: 1fr; gap: 6px; }
  .opt > b { padding-top: 0; }
  .cfg-sum { padding-top: 14px; padding-bottom: 20px; grid-template-columns: 1fr; }
  .kp-meta { grid-template-columns: 1fr; }
  .kp-meta .wide { grid-column: auto; }
  .lock-card { padding: 24px; }
}

/* ============ Документ КП для печати / PDF ============ */
.print { display: none; }
@page { size: A4; margin: 12mm 0; }
@page :first { margin: 0 0 12mm; }
@media print {
  html, body { background: #fff !important; }
  body > *:not(.print) { display: none !important; }
  .print { display: block; }
}
.doc { width: 210mm; color: #111; font-family: 'Manrope', Arial, sans-serif; font-size: 9.5pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; background: #fff; }
.doc-head { background: #0a0a0a; color: #fff; padding: 11mm 14mm 9mm; position: relative; overflow: hidden; }
.doc-head:before { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: radial-gradient(ellipse 55% 120% at 92% 10%, rgba(239,59,54,.35), transparent 65%); }
.doc-head > * { position: relative; }
.doc-head-row { display: flex; justify-content: space-between; align-items: flex-start; }
.doc-head img { height: 15mm; }
.doc-contacts { text-align: right; font-family: 'DM Mono', monospace; font-size: 7.5pt; line-height: 1.7; color: #cfcbc3; }
.doc-kicker { margin-top: 9mm; font-family: 'DM Mono', monospace; font-size: 7.5pt; letter-spacing: .12em; text-transform: uppercase; color: #ef3b36; display: flex; align-items: center; gap: 3mm; }
.doc-kicker:before { content: ''; width: 10mm; height: 1px; background: #ef3b36; }
.doc-head h1 { font-size: 25pt; line-height: 1; font-weight: 700; letter-spacing: -.04em; margin-top: 2.5mm; }
.doc-head h1 em { color: #ef3b36; font-style: normal; font-weight: 400; }
.doc-info { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4mm; padding: 6mm 14mm; border-bottom: .3mm solid #e6e4df; }
.doc-info div span { display: block; font-family: 'DM Mono', monospace; font-size: 6.5pt; letter-spacing: .1em; text-transform: uppercase; color: #8c8b86; margin-bottom: 1mm; }
.doc-info div b { font-weight: 600; font-size: 9.5pt; }
.doc-body { padding: 5mm 14mm 0; }
.doc table { width: 100%; border-collapse: collapse; }
.doc thead th { font-family: 'DM Mono', monospace; font-weight: 400; font-size: 6.5pt; letter-spacing: .08em; text-transform: uppercase; color: #8c8b86; text-align: left; padding: 2mm 1.5mm; border-bottom: .4mm solid #0a0a0a; }
.doc tbody td { padding: 2mm 1.5mm; border-bottom: .2mm solid #e6e4df; vertical-align: middle; }
.doc tbody tr { page-break-inside: avoid; break-inside: avoid; }
.doc td.num, .doc th.num { text-align: right; white-space: nowrap; }
.doc td.c, .doc th.c { text-align: center; }
.doc td.i { font-family: 'DM Mono', monospace; color: #8c8b86; font-size: 7.5pt; width: 6mm; }
.doc td.ph { width: 16mm; }
.doc td.ph div { width: 14mm; height: 14mm; background: #efede9; border-radius: 1mm; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.doc td.ph img { width: 100%; height: 100%; object-fit: cover; }
.doc td.nm { line-height: 1.35; }
.doc td.nm b { display: block; font-weight: 700; }
.doc td.nm small { color: #6b6a66; font-size: 8pt; }
.doc td.sum { font-weight: 700; }
.doc-total { display: flex; justify-content: flex-end; padding: 5mm 0 0; page-break-inside: avoid; }
.doc-total table { width: 80mm; }
.doc-total td { padding: 1.4mm 0; border: none !important; }
.doc-total tr.grand td { border-top: .4mm solid #0a0a0a !important; padding-top: 2.5mm; font-size: 14pt; font-weight: 700; letter-spacing: -.02em; }
.doc-total tr.grand td:last-child { color: #ef3b36; }
.doc-terms { margin: 7mm 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; page-break-inside: avoid; }
.doc-terms.single { grid-template-columns: 1fr; }
.doc-terms.single ul { columns: 2; column-gap: 8mm; }
.doc-terms h4 { font-family: 'DM Mono', monospace; font-weight: 400; font-size: 6.5pt; letter-spacing: .1em; text-transform: uppercase; color: #ef3b36; margin: 0 0 2mm; }
.doc-terms ul { margin: 0; padding-left: 4mm; line-height: 1.55; }
.doc-terms p { margin: 0; line-height: 1.55; white-space: pre-line; }
.doc-sign { margin-top: 8mm; padding: 5mm 0 10mm; border-top: .3mm solid #e6e4df; display: flex; justify-content: space-between; align-items: flex-end; page-break-inside: avoid; }
.doc-sign p { margin: 0; line-height: 1.6; }
.doc-sign b { font-size: 10.5pt; }
.doc-sign .site { font-family: 'DM Mono', monospace; font-size: 7.5pt; color: #ef3b36; letter-spacing: .06em; text-transform: uppercase; }

/* Длина по таблице производства: выпадающий список */
.len-pick { display: flex; flex-direction: column; gap: 6px; }
.len-pick select { width: 100%; max-width: 340px; height: 44px; border-radius: 999px; padding: 0 16px; font-size: 15px; cursor: pointer; }
.len-pick small { font-size: 11px; }

/* ============ Паспорт изделия (вариант A — строгий светлый лист) ============ */
.pp-btn { margin-top: 12px; height: 36px; }
.pp-check { font-size: 12px; padding: 0 6px; white-space: nowrap; }
@page pp { size: A4; margin: 0; }
@page pp:first { margin: 0; }
.pp { --pp-ink: #121212; --pp-soft: #5b5853; --pp-muted: #8c8b86; --pp-line: #e3e0da; --pp-tint: #f6f4f0; --pp-red: #e6332e;
  color: var(--pp-ink); font-family: 'Manrope', Arial, sans-serif; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pp-page { page: pp; width: 210mm; height: 297mm; background: #fff; position: relative; overflow: hidden; padding: 46px 52px 70px;
  display: flex; flex-direction: column; break-after: page; page-break-after: always; }
.pp-page:last-child { break-after: auto; page-break-after: auto; }
.pp-mono { font-family: 'DM Mono', monospace; text-transform: uppercase; letter-spacing: .08em; }
.pp h1 { margin: 0; font-size: 40px; line-height: 1; letter-spacing: -.04em; font-weight: 800; }
.pp-h { margin: 0 0 10px; font-size: 14px; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.pp-h i { font-style: normal; font-family: 'DM Mono', monospace; font-size: 10px; color: var(--pp-red); }
.pp p { margin: 0; font-size: 11.5px; line-height: 1.55; color: var(--pp-soft); }
.pp-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; border-bottom: 3px solid var(--pp-red); }
.pp-head img { height: 34px; }
.pp-head span { font-size: 9px; color: var(--pp-muted); }
.pp-title { display: grid; grid-template-columns: 1fr 250px; gap: 26px; margin-top: 24px; }
.pp-kind { font-size: 10px; color: var(--pp-red); margin-bottom: 10px; }
.pp-photo { border-radius: 10px; background: var(--pp-tint); height: 250px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pp-photo img { max-width: 100%; max-height: 250px; }
.pp-lead { margin: 14px 0 16px !important; font-size: 12px !important; }
.pp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pp-chips span { padding: 6px 11px; border-radius: 999px; border: 1px solid var(--pp-line); font-size: 11px; font-weight: 700; white-space: nowrap; }
.pp-kpbox { border: 1.5px solid var(--pp-red); border-radius: 10px; padding: 12px 14px; background: #fdf3f2; margin-top: 18px; }
.pp-kpbox b { display: block; font-size: 12px; margin-bottom: 4px; }
.pp-kpbox span { font-size: 10.5px; color: var(--pp-soft); line-height: 1.5; }
.pp-block { margin-top: 18px; }
.pp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.pp-table { width: 100%; border-collapse: collapse; font-size: 10.5px; align-self: start; }
.pp-table td { padding: 6px 8px; border-bottom: 1px solid var(--pp-line); vertical-align: top; line-height: 1.4; }
.pp-table td:first-child { color: var(--pp-muted); width: 38%; }
.pp-table td:last-child { font-weight: 600; }
.pp-table tr:nth-child(odd) td { background: var(--pp-tint); }
.pp-draws { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pp-draws.n1 { grid-template-columns: 1fr; } .pp-draws.n2 { grid-template-columns: 1fr 1fr; } .pp-draws.n3 { grid-template-columns: repeat(3, 1fr); }
.pp-draws div { border: 1px solid var(--pp-line); border-radius: 8px; padding: 8px; height: 150px; display: flex; align-items: center; justify-content: center; background: #fff; }
.pp-draws.n1 div, .pp-draws.n2 div { height: 210px; }
.pp-draws img { max-width: 100%; max-height: 100%; }
.pp-ksp { width: 100%; height: auto; display: block; }
.pp-ksp .c0 { fill: rgba(230,51,46,.15); stroke: #e6332e; stroke-width: 1.6; }
.pp-ksp .c90 { fill: none; stroke: #8c8b86; stroke-width: 1.2; stroke-dasharray: 4 3; }
.pp-note { font-size: 9px; color: var(--pp-muted); margin-top: 6px; line-height: 1.4; }
.pp-eacrow { display: flex; gap: 14px; align-items: center; }
.pp-eac { display: inline-flex; align-items: center; justify-content: center; height: 26px; padding: 0 8px; border: 2px solid var(--pp-ink); font-weight: 800; font-size: 15px; letter-spacing: .06em; color: var(--pp-ink); flex: none; }
.pp-sign { display: grid; grid-template-columns: 1.3fr 1fr .6fr; gap: 18px; margin-top: 18px; font-size: 9.5px; color: var(--pp-muted); }
.pp-sign div { border-top: 1px solid var(--pp-ink); padding-top: 5px; }
.pp-foot { position: absolute; left: 52px; right: 52px; bottom: 26px; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--pp-line); padding-top: 10px; font-size: 8.5px; line-height: 1.5; color: var(--pp-muted); }
.pp-foot b { color: var(--pp-soft); font-weight: 600; }
.pp-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pp-btns .pp-btn { margin-top: 0; }
.kp-row .tools button.pp-row { width: auto; padding: 0 9px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 11px; color: var(--soft); }
.kp-row .tools button.pp-row:hover { border-color: var(--red); color: #fff; }
.pp h1.long { font-size: 30px; line-height: 1.05; }
/* Safari: лист ниже A4 на поля и колонтитулы браузера, всё плотнее */
.pp.safe .pp-page { width: auto; height: 262mm; padding: 30px 36px 56px; }
.pp.safe h1 { font-size: 32px; } .pp.safe h1.long { font-size: 26px; }
.pp.safe .pp-title { margin-top: 16px; grid-template-columns: 1fr 210px; gap: 20px; }
.pp.safe .pp-photo { height: 200px; } .pp.safe .pp-photo img { max-height: 200px; }
.pp.safe .pp-lead { margin: 10px 0 12px !important; }
.pp.safe .pp-kpbox { margin-top: 12px; padding: 9px 12px; }
.pp.safe .pp-block { margin-top: 12px; }
.pp.safe .pp-table td { padding: 4px 7px; }
.pp.safe .pp-draws div { height: 120px; } .pp.safe .pp-draws.n1 div, .pp.safe .pp-draws.n2 div { height: 160px; }
.pp.safe .pp-ksp { max-height: 170px; }
.pp.safe .pp-foot { left: 36px; right: 36px; bottom: 16px; }

/* Курс $: ЦБ + 1 ₽, ручной курс подсвечен */
.rate-box { display: flex; flex-direction: column; gap: 2px; padding: 2px 0; }
.rate-box label { display: flex; align-items: center; gap: 6px; }
.top-settings .rate-box input[type=number] { width: 78px; }
.rate-meta { display: flex; gap: 8px; align-items: center; font-family: var(--mono); font-size: 9px; letter-spacing: .02em; color: var(--muted); white-space: nowrap; }
.rate-meta button { padding: 0; font-family: var(--mono); font-size: 9px; color: var(--red); text-decoration: underline; text-underline-offset: 2px; }
.rate-meta button:hover { color: #fff; }
.rate-box.manual input { border-color: var(--red) !important; background: rgba(239,59,54,.18) !important; color: #fff; }
.rate-box.manual #rateInfo { color: #ff8a86; }
@media (max-width: 600px) { .rate-meta { white-space: normal; flex-wrap: wrap; } }
