:root { --bg:#f4f5f7; --card:#fff; --text:#1d2330; --muted:#6b7280; --accent:#1f5eff; --warn:#b45309; --err:#b91c1c; --line:#e5e7eb; }
* { box-sizing: border-box; }
body { margin:0; font: 15px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif; background:var(--bg); color:var(--text); }
header { display:flex; justify-content:space-between; align-items:center; padding:10px 24px; background:#fff; border-bottom:1px solid var(--line); }
header .brand { font-weight:600; color:var(--text); text-decoration:none; }
header nav a { margin-left:16px; color:var(--accent); }
main { max-width:1400px; margin:24px auto; padding:0 16px; }
.columns { display:grid; grid-template-columns: minmax(300px, 560px) minmax(520px, 1fr); gap:24px; }
@media (max-width: 900px) { .columns { grid-template-columns:1fr; } }
.card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:20px 24px; margin-bottom:24px; }
.card.narrow { max-width:380px; margin:60px auto; }
h1 { font-size:20px; margin:0 0 14px; } h2 { font-size:18px; margin:0 0 10px; } h3 { font-size:15px; margin:18px 0 6px; }
fieldset { border:1px solid var(--line); border-radius:8px; margin:0 0 14px; padding:10px 14px 14px; min-width:0; }
legend { font-weight:600; padding:0 6px; } legend small { font-weight:400; color:var(--muted); }
label { display:block; margin:8px 0 0; font-size:13px; color:var(--muted); }
input[type=text], input:not([type]), input[type=password], input[type=date] { display:block; width:100%; margin-top:4px; padding:8px 10px; border:1px solid #cbd5e1; border-radius:6px; font-size:15px; color:var(--text); }
.radio-row label { display:inline-block; margin:6px 18px 6px 0; font-size:15px; color:var(--text); }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:0 12px; } .grid3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:0 12px; align-items:end; }
.hint { margin:10px 0 0; font-size:13px; color:var(--muted); }
button { margin-top:14px; padding:9px 18px; border:0; border-radius:6px; background:var(--accent); color:#fff; font-size:15px; cursor:pointer; }
button.secondary { background:#e5e7eb; color:var(--text); }
form.inline { display:inline-flex; gap:6px; align-items:center; } form.inline input { width:150px; margin:0; } form.inline button { margin:0; padding:6px 10px; font-size:13px; }
.big { display:flex; flex-wrap:wrap; gap:12px; margin:14px 0; }       /* мало места — срок и расстояние ниже цен */
.big > div { flex:1 1 110px; min-width:0; } .big > div:first-child { flex:3 1 360px; }
.big div { padding:12px 14px; background:#f8fafc; border-radius:8px; } .big .label { display:block; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; }
.big strong { display:block; font-size:19px; margin:2px 0; white-space:nowrap; }
.muted { color:var(--muted); } .small { font-size:13px; } .error { color:var(--err); font-weight:600; }
.note { background:#fffbeb; border-left:3px solid var(--warn); padding:6px 10px; margin:8px 0; font-size:14px; }
.warnings { padding-left:18px; } .warnings li { margin:6px 0; } .warnings li.blocking { color:var(--err); }
.result table, .card > table { display:block; overflow-x:auto; }
table { width:100%; border-collapse:collapse; font-size:14px; } th, td { text-align:left; padding:6px 8px; border-bottom:1px solid var(--line); } th { color:var(--muted); font-weight:600; }
table.small { font-size:13px; }
.check { display:flex; align-items:center; gap:6px; margin-top:20px; }
.card.narrow.wide { max-width:520px; }
.center { text-align:center; }
code { background:#f1f5f9; padding:2px 5px; border-radius:4px; }
.mt { margin-top:22px; }

/* Конструктор заказа */
.add-row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:10px; }
.add-row input { flex:1 1 260px; margin:0; }
.add-row button { margin:0; }
/* Позиции заказа — карточки (поля переносятся, не уезжают за край) */
#order-list { display:flex; flex-direction:column; gap:6px; min-width:0; }
.oi-row { border:1px solid var(--line); border-radius:8px; padding:5px 8px 5px 10px; background:#fafbfc; }
.oi-head { display:flex; align-items:flex-start; gap:6px; }
.oi-head .oi-qty, .oi-head button.del { margin-top:1px; }
.oi-toggle { flex:1 1 auto; min-width:0; display:flex; align-items:baseline; gap:6px; margin:0; padding:3px 0;
  background:none; color:var(--text); text-align:left; font-size:14px; cursor:pointer; }
.oi-arrow { flex:0 0 auto; color:var(--muted); font-size:11px; transition:transform .15s; }
.oi-row.open .oi-arrow { transform:rotate(90deg); }
.oi-title { flex:1 1 auto; min-width:0; line-height:1.3; }      /* наименование целиком, длинное — переносом */
.oi-model { color:var(--muted); font-size:13px; white-space:nowrap; }
.oi-nopnr { display:none; font-size:11px; color:var(--warn); border:1px solid currentColor; border-radius:10px; padding:0 6px; }
.oi-row.no-pnr .oi-nopnr { display:inline-block; }
.oi-qty { display:flex; align-items:center; flex:0 0 auto; }
.oi-qty button { margin:0; padding:2px 0; width:24px; font-size:15px; line-height:1.2; }
.oi-qty input.qty { display:inline-block; width:34px; margin:0 2px; padding:3px 1px; text-align:center; font-size:14px; }
.oi-more { padding:2px 0 4px 17px; }
.oi-fields { display:flex; flex-wrap:wrap; gap:8px 10px; margin-top:4px; }
.oi-fields label { display:flex; flex-direction:column; margin:0; font-size:11px; color:var(--muted); }
.oi-fields input.num { width:72px; margin:2px 0 0; padding:6px 8px; text-align:right; }
.oi-fields input.num:disabled { background:#eef2f7; color:#475569; }
.oi-row button.del { margin:0; padding:2px 0; width:24px; flex:0 0 auto; }
.order-empty { color:var(--muted); font-size:14px; }
.totals { font-weight:600; margin-top:10px; }
.order-detail summary { cursor:pointer; color:var(--accent); margin:6px 0; }

/* Выпадающий список каталога */
.eq-search-wrap { position:relative; flex:1 1 260px; }
.eq-search-wrap input { width:100%; margin:0; }
.dropdown { position:absolute; z-index:20; left:0; right:0; top:100%; margin-top:2px; background:#fff;
  border:1px solid #cbd5e1; border-radius:8px; box-shadow:0 6px 20px rgba(0,0,0,.12); max-height:320px; overflow-y:auto; }
.dd-item { display:grid; grid-template-columns:1fr auto; gap:0 10px; padding:8px 12px; cursor:pointer; border-bottom:1px solid var(--line); }
.dd-item:last-child { border-bottom:0; }
.dd-item:hover { background:#eff3ff; }
.dd-name { grid-column:1; font-size:14px; }
.dd-model { grid-column:2; grid-row:1; color:var(--accent); font-size:13px; font-weight:600; white-space:nowrap; }
.dd-dims { grid-column:1 / span 2; color:var(--muted); font-size:12px; }
.dd-empty { padding:10px 12px; color:var(--muted); font-size:14px; }

/* Узкий экран (телефон): поля позиции по 2 в ряд, без горизонтальной прокрутки */
html, body { max-width:100%; overflow-x:hidden; }
@media (max-width: 520px) {
  .oi-fields { gap:8px; }
  .oi-fields label { flex:1 1 44%; }
  .oi-fields input.num { width:100%; }
  header { flex-wrap:wrap; gap:4px 12px; }
}

.dd-wrap { position:relative; display:block; }
.dd-wrap input { width:100%; }

/* Раскладка по полу кузова */
.floor-wrap { overflow-x:auto; margin:6px 0; }
svg.floor { display:block; max-width:100%; height:auto; border-radius:4px; }
.legend { display:flex; flex-wrap:wrap; gap:6px 16px; margin:8px 0; font-size:13px; }
.legend-item { display:inline-flex; align-items:center; gap:6px; }
.legend .sw { width:12px; height:12px; border-radius:3px; display:inline-block; }

.veh-pick { display:block; margin:8px 0; font-size:13px; color:var(--muted); }
.veh-pick select { margin-left:6px; padding:5px 8px; border:1px solid #cbd5e1; border-radius:6px; font-size:14px; color:var(--text); }

/* Кнопки «Рассчитать» и «Сброс» */
.form-actions { display:flex; align-items:center; gap:12px; }
.btn-reset { display:inline-block; margin-top:14px; padding:9px 18px; border-radius:6px; background:#e5e7eb;
  color:var(--text); text-decoration:none; font-size:15px; }
.btn-reset:hover { background:#d8dbe0; }

/* Выгрузка у получателя */
.unload { display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px; margin:6px 0; }
.unload-sum { display:inline-flex; align-items:center; gap:4px; font-size:19px; font-weight:600; cursor:help; }
.unload-sum input { width:110px; font-size:18px; font-weight:600; padding:6px 8px; text-align:right; border:1px solid #cbd5e1; border-radius:6px; }
.unload-complex { display:inline-flex; align-items:center; gap:6px; font-size:14px; color:var(--text); margin:0; }
#unload-reset { font-size:13px; color:var(--accent); }
.unload + .note, .unload .note { margin-top:4px; }
.unload .muted.small { flex-basis:100%; margin:0; }

/* Расчёт через транспортные компании */
#carrier-quotes { margin:6px 0; }
.carrier-row { font-size:15px; margin:4px 0; }
.carrier-row b { font-weight:600; }
.price-table { border-collapse:collapse; margin:4px 0 2px; }
.price-table th { font-size:11px; font-weight:normal; color:var(--muted); text-align:left; padding:0 10px 2px 0; }
.price-table td { padding:2px 10px 2px 0; white-space:nowrap; vertical-align:baseline; }
.price-table td:last-child { white-space:normal; }      /* диапазон и пояснение — переносом, если колонка узкая */
.price-table strong { display:inline; font-size:19px; margin:0; }
.price-table .with-unload strong { color:var(--accent); }
.price-table .full-load strong { color:#2f9e44; }

/* Пусконаладка */
#pnr-box { margin-top: 18px; }
.pnr-summary { display:flex; flex-wrap:wrap; align-items:baseline; gap:6px 14px; margin:6px 0 10px; }
.pnr-summary strong { font-size:20px; color:var(--accent); }
.pnr-inputs { display:flex; flex-wrap:wrap; gap:8px 14px; align-items:flex-end; margin:8px 0; }
.pnr-inputs label { display:flex; flex-direction:column; font-size:13px; color:var(--muted); gap:3px; }
.pnr-inputs select { padding:6px 8px; border:1px solid #cbd5e1; border-radius:6px; font-size:14px; background:#fff; }
.pnr-inputs input { width:130px; padding:6px 8px; border:1px solid #cbd5e1; border-radius:6px; font-size:14px; }
.pnr-inputs button { margin-top:0; }
#pnr-lines td.num { text-align:right; white-space:nowrap; padding-right:10px; }
.pnr-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(260px, 1fr)); gap:8px 16px; margin-bottom:6px; }
.pnr-grid label { display:flex; flex-direction:column; font-size:13px; gap:3px; }
.pnr-grid input { padding:6px 8px; border:1px solid #cbd5e1; border-radius:6px; }
.pnr-shift { color: var(--warn); font-weight: 600; }
.pnr-inputs label.check { flex-direction:row; align-items:center; gap:6px; color:var(--text); }
.pnr-inputs input[type=checkbox] { width:auto; margin:0; padding:0; }
.oi-pnr { display:flex; align-items:center; gap:6px; margin-top:6px; font-size:13px; color:var(--text); }
.oi-pnr input { width:auto; margin:0; }

/* История расчётов: просмотр одного расчёта */
a.btn { display:inline-block; padding:8px 16px; border-radius:6px; background:var(--accent); color:#fff; text-decoration:none; }
.calc-view-head p { margin:6px 0; }
.calc-snapshot .print-only { display:block; }
.calc-snapshot .report-meta { color:var(--muted); font-size:13px; }

/* Инструкция */
.help { max-width:860px; margin-left:auto; margin-right:auto; }
.help-toc { display:flex; flex-wrap:wrap; gap:6px 8px; margin:4px 0 8px; }
.help-toc a { padding:4px 10px; border-radius:14px; background:#eef2ff; text-decoration:none; font-size:14px; }
.help-sec { border-top:1px solid var(--line); padding-top:6px; margin-top:14px; scroll-margin-top:12px; }
.help-sec h2 { margin:8px 0 6px; }
.help-sec h3 { margin:12px 0 4px; }
.help-sec ul, .help-sec ol { margin:4px 0; padding-left:20px; } .help-sec li { margin:3px 0; }
.help-lead { color:var(--muted); margin:2px 0 6px; }
.help-role { color:var(--muted); font-weight:400; font-size:13px; }
header nav a.nav-help { font-weight:600; }
@media print { body.pdf .help-sec { break-inside:auto; } body.pdf .help-sec h2 { break-after:avoid; } }

/* Прайс (/price/) */
.price { max-width:none; }
.price-tabs { display:flex; flex-wrap:wrap; align-items:center; gap:6px 16px; margin-bottom:12px; border-bottom:1px solid var(--line); padding-bottom:8px; }
.price-tabs a { text-decoration:none; color:var(--muted); padding:4px 2px; }
.price-tabs a.on { color:var(--text); font-weight:600; border-bottom:2px solid var(--accent); }
.price-build-btn { margin-left:auto; } .price-build-btn button { margin:0; }
.price-filters { display:flex; flex-wrap:wrap; gap:8px 12px; align-items:center; margin:8px 0 12px; }
.price-filters input:not([type]), .price-filters select { width:auto; min-width:220px; margin:0; display:inline-block; }
.price-filters button { margin:0; }
.price select { padding:7px 10px; border:1px solid #cbd5e1; border-radius:6px; font-size:15px; color:var(--text); background:#fff; }
.price-filters label.check { margin:0; font-size:14px; color:var(--text); white-space:nowrap; }   /* в одну линию с полями */
.price-table-edit { border-collapse:collapse; width:100%; font-size:13px; }
.price-table-edit th { position:sticky; top:0; background:#e8f1f8; text-align:left; padding:6px; font-size:12px; z-index:1; }
.price-table-edit td { border-bottom:1px solid var(--line); padding:4px 6px; vertical-align:top; }
.price-table-edit td[contenteditable]:focus { outline:2px solid var(--accent); background:#fff; }
.price-table-edit td[contenteditable]:hover { background:#f8fafc; }
.price-table-edit td.num { text-align:right; white-space:nowrap; }
.price-table-edit td.nowrap, .price-log td.nowrap { white-space:nowrap; }
.price-table-edit .pt-link { color:#1d4ed8; white-space:nowrap; }
.price-table-edit .pt-mark { color:#dc2626; font-weight:600; white-space:nowrap; }
.price-table-edit td.center { text-align:center; } .price-table-edit td.center input { width:auto; margin:0; }
.pt-sec td { background:#d7e9f5; font-weight:600; text-align:center; padding:6px; white-space:pre-line; }
.pt-secname { display:inline-block; min-width:200px; }
.pt-drag { cursor:grab; color:var(--muted); user-select:none; width:14px; }
.pt-item.changed td { background:#fffbe6; }
.pt-item.off td { color:#9ca3af; text-decoration:line-through; }
.pt-item.off td.center, .pt-item.off td.pt-drag { text-decoration:none; }
.pt-item.dragging { opacity:.4; }
.price-add { margin-top:14px; } .price-add summary { cursor:pointer; color:var(--accent); }
.price-add-form { display:flex; flex-wrap:wrap; gap:6px 12px; align-items:flex-end; margin:10px 0; }
.price-add-form label { margin:0; } .price-add-form input:not([type]), .price-add-form select { width:200px; }
.price-add-form button { margin:0; }
.price-toast { position:fixed; right:20px; bottom:20px; background:#065f46; color:#fff; padding:10px 14px; border-radius:8px; max-width:420px; z-index:9; }
.price-toast.bad { background:#b91c1c; }
.price-settings { max-width:760px; } .price-settings label { margin-top:10px; }
.price-settings textarea { width:100%; font:inherit; padding:8px; border:1px solid #cbd5e1; border-radius:6px; }
.foot-row { display:flex; gap:8px; margin:4px 0; } .foot-row input { flex:1; margin:0 !important; } .foot-row select { width:120px; }
.price-log .log-val { max-width:280px; overflow-wrap:anywhere; }
.price-log tr.undone td { color:#9ca3af; }
button.small { padding:3px 8px; font-size:12px; margin:0; }

/* Отчёт для печати / PDF */
.result-head { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.result-head button { margin-top:0; }
.print-only { display:none; }
@page { size: A4; margin: 12mm; }
@media print {
  body { background:#fff; }
  header nav, #calc-form, .no-print, .btn-reset, .pnr-inputs, #pnr-recalc, #unload-reset { display:none !important; }
  .print-only { display:block; }
  main { max-width:none; margin:0; padding:0; }
  .columns { display:block; }
  .card { border:none; padding:0; margin:0; box-shadow:none; }
  header { padding:0 0 6px; border-bottom:1px solid #999; }
  .report-meta { color:#444; font-size:12px; margin:2px 0 8px; }
  h2, h3 { break-after:avoid; }
  table, tr, .big > div, svg, .note, .carrier-row { break-inside:avoid; }
  .floor-wrap { overflow:visible; }
  a { color:inherit; text-decoration:none; }
  details > summary { list-style:none; }
  details > summary::-webkit-details-marker { display:none; }
}
/* PDF на сервере (WeasyPrint): только блок результата, таблицы — обычные таблицы */
@media print {
  body.pdf { font-size:12px; }
  body.pdf .result table, body.pdf .card > table { display:table; }
  body.pdf .brand { font-weight:600; }
  body.pdf .pdf-field { font-weight:600; }
  body.pdf .pdf-check { font-weight:400; }
  body.pdf .unload-complex { white-space:nowrap; width:auto; }
  /* у WeasyPrint гибкая раскладка подписей ошибается с шириной и переносит «×1» — в PDF обычными строками */
  body.pdf .legend { display:block; }
  body.pdf .legend-item { display:block; margin:3px 0; padding-left:18px; text-indent:-18px; }
  body.pdf .legend .sw { margin-right:6px; vertical-align:-1px; }
}
.check-inline { display:inline-flex; align-items:center; gap:6px; margin:0; } table.access select { margin:0; }
.check-actions { display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; margin:6px 0 10px; }
.check-actions form, .check-actions button { margin:0; }
.check-table { margin:6px 0 10px; } .check-table td { vertical-align:top; }
.price h2 { margin-top:22px; } .plan-cancel { margin-left:12px; } .ok-line { color:#065f46; }
.check-list { columns:2; margin:6px 0; } @media (max-width:700px) { .check-list { columns:1; } }
.new-status td:first-child { white-space:nowrap; width:120px; font-weight:600; }
.new-form fieldset { max-width:860px; } .new-form legend .check-inline { font-size:15px; color:var(--text); }
.new-form select { width:100%; margin-top:4px; }
.grid-dims { display:grid; grid-template-columns:repeat(4, 110px) 1fr; gap:0 12px; }
@media (max-width:700px) { .grid-dims { grid-template-columns:1fr 1fr; } }
.price-table-edit .iris-col { color:var(--muted); font-size:12px; text-align:right; white-space:nowrap; }
.price-table-edit th.iris-col { background:#eef2f7; }
.price-table-edit td.iris-diff, .iris-diff-x { background:#fef3c7; } .price-table-edit td.iris-below, .iris-below-x { background:#fee2e2; color:#b91c1c; font-weight:600; }
.iris-diff-x, .iris-below-x { padding:0 4px; border-radius:3px; }
.iris-upload { display:flex; flex-wrap:wrap; gap:8px 12px; align-items:center; margin:8px 0 12px; } .iris-upload button { margin:0; }
.check-table td.num, .check-table th.num { white-space:nowrap; text-align:right; }
.price-table-edit .iris-col a { color:inherit; text-decoration:none; border-bottom:1px dotted #9ca3af; }
.btn-link { display:inline-block; padding:3px 8px; font-size:12px; border-radius:6px; background:var(--accent); color:#fff; text-decoration:none; margin-right:4px; }
.auto-box { background:#f8fafc; border:1px solid var(--line); border-radius:8px; padding:8px 12px; margin:8px 0 4px; font-size:14px; }
.auto-box button { margin-left:6px; }
.nav-alert { display:inline-block; min-width:18px; padding:0 5px; border-radius:9px; background:#dc2626; color:#fff; font-size:11px; font-weight:600; line-height:18px; text-align:center; vertical-align:1px; }
