:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1d2733; --muted: #6b7785; --line: #e3e8ee;
  --brand: #1f4e79; --brand-2: #2e7d5b; --accent: #e8f1fa; --warn: #b26a00; --err: #b3261e;
  --r: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { color: var(--muted); font-size: 13px; }
.price-info { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; flex-wrap: wrap; justify-content: flex-end; }

.btn { border: 1px solid var(--brand); background: #fff; color: var(--brand); padding: 9px 16px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; transition: .15s; }
.btn:hover { background: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: #173d60; }
.btn.ghost { border-color: var(--line); color: var(--ink); }
.btn.big { font-size: 18px; padding: 14px 34px; border-radius: 12px; }

main { max-width: 1200px; margin: 0 auto; padding: 28px; }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.start .hero { background: linear-gradient(135deg, #1f4e79, #2e7d5b); color: #fff; border-radius: 20px; padding: 64px 56px; }
.hero h1 { font-size: 40px; max-width: 720px; }
.hero p { font-size: 18px; max-width: 680px; opacity: .92; margin-bottom: 28px; }
.hero .btn.primary { background: #fff; color: var(--brand); border-color: #fff; }
.hero-points { display: flex; gap: 32px; list-style: none; padding: 0; margin: 36px 0 0; opacity: .95; flex-wrap: wrap; }
.hero-points b { font-size: 22px; }

.wizard { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.wizard-main, .card, .live { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.wizard-main { padding: 24px 28px; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.step { border: 0; background: var(--bg); color: var(--muted); padding: 7px 12px; border-radius: 20px; font: inherit; font-size: 13px; cursor: pointer; }
.step.done { color: var(--brand-2); }
.step.on { background: var(--brand); color: #fff; }
.step-body { min-height: 360px; }
.field { margin-bottom: 20px; }
.field label, .flabel { display: block; font-weight: 600; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; padding: 9px 14px; border-radius: 9px; font: inherit; cursor: pointer; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--accent); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.range { display: flex; gap: 14px; align-items: center; }
.range input[type=range] { flex: 1; accent-color: var(--brand); }
.num, select, dialog input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.num { width: 96px; }
select { min-width: 280px; }
.switch { display: flex !important; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { display: none; }
.switch span { width: 40px; height: 22px; border-radius: 11px; background: #cfd6de; position: relative; transition: .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--brand-2); }
.switch input:checked + span::after { left: 21px; }
.wizard-nav { display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 18px; }
.wizard-nav #btnPrev { margin-right: auto; }

.live { padding: 22px; position: sticky; top: 84px; }
.live-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.live-total { font-size: 30px; font-weight: 800; color: var(--brand); margin: 4px 0; }
.live-m2 { color: var(--muted); margin-bottom: 16px; }
.bar { display: grid; grid-template-columns: 132px 1fr 64px; gap: 8px; align-items: center; font-size: 12px; margin: 5px 0; }
.bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar i { display: block; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bar b { text-align: right; font-weight: 600; }
.bar.wide { grid-template-columns: 200px 1fr 120px; font-size: 14px; margin: 8px 0; }

.result-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 24px 28px; margin-bottom: 20px; flex-wrap: wrap; }
.total { font-size: 44px; font-weight: 800; color: var(--brand); }
.sub { color: var(--muted); margin-bottom: 10px; }
.badge { display: inline-block; padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.badge.ok { background: #e3f4ea; color: var(--brand-2); }
.badge.warn { background: #fdf0dc; color: var(--warn); }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.result-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 20px; }
.card { padding: 22px 24px; }
.totals { width: 100%; border-collapse: collapse; margin-top: 16px; }
.totals td { padding: 6px 0; border-top: 1px solid var(--line); }
.totals td:last-child { text-align: right; white-space: nowrap; }
.totals .sum td { font-weight: 800; font-size: 18px; color: var(--brand); }
.chosen { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.chosen dt { color: var(--muted); }
.chosen dd { margin: 0; font-weight: 600; }
.details summary { cursor: pointer; font-weight: 700; }
.lines { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13px; }
.lines th, .lines td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.lines td:nth-child(n+2), .lines th:nth-child(n+2) { text-align: right; white-space: nowrap; }
.lines .sec td { background: var(--bg); font-weight: 700; }

a.btn { text-decoration: none; display: inline-block; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 0 28px; }
.foot a { color: var(--brand); }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: 460px; padding: 14px 18px; border-radius: 10px; color: #fff; background: var(--brand-2); box-shadow: 0 8px 24px rgba(0,0,0,.18); white-space: pre-line; z-index: 20; }
.toast.err { background: var(--err); }

dialog { border: 0; border-radius: 14px; padding: 24px; width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog input { width: 100%; margin: 8px 0 16px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* КП для печати / PDF */
.kp { display: none; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .kp { display: block; color: #111; font-size: 12px; }
  .kp-head { display: flex; justify-content: space-between; border-bottom: 3px solid var(--brand); padding-bottom: 10px; margin-bottom: 18px; }
  .kp-company { font-size: 18px; font-weight: 800; color: var(--brand); }
  .kp-date { text-align: right; color: #555; }
  .kp h1 { font-size: 20px; }
  .kp h2 { font-size: 15px; margin-top: 22px; }
  .kp-total { font-size: 30px; font-weight: 800; color: var(--brand); margin: 6px 0 10px; }
  .kp-total span { font-size: 14px; color: #555; font-weight: 400; margin-left: 10px; }
  .kp-opts { color: #333; line-height: 1.7; }
  .kp-table { width: 100%; border-collapse: collapse; }
  .kp-table th { background: var(--brand); color: #fff; text-align: left; padding: 6px 8px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kp-table td { padding: 5px 8px; border-bottom: 1px solid #ddd; }
  .kp-table td:not(:first-child), .kp-table th:not(:first-child) { text-align: right; white-space: nowrap; }
  .kp-table.small { font-size: 10.5px; }
  .kp-table tr { break-inside: avoid; }
  .kp-table .sum td { font-weight: 800; font-size: 14px; border-top: 2px solid var(--brand); }
  .kp-note { color: #666; margin-top: 16px; font-size: 11px; }
}

@media (max-width: 900px) {
  .wizard, .result-grid { grid-template-columns: 1fr; }
  .live { position: static; }
  .hero { padding: 36px 24px !important; }
  .hero h1 { font-size: 28px; }
  .top { flex-direction: column; align-items: flex-start; padding: 12px 16px; }
  main { padding: 16px; }
}
