:root {
  --red: #C01506;
  --red-dark: #9F072C;
  --red-tint: #FCEBEA;
  --ink: #111111;
  --text: #3F434B;
  --muted: #5B5F69;
  --line: #DDE1EA;
  --line-strong: #A9AFBA;
  --bg: #F1F3F8;
  --white: #FFFFFF;
  --dark: #111111;
  --dark-text: #C9CCD3;
  --panel: #1F3A68;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: #E4E7EE;
  color: var(--ink);
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, a { font-family: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

/* Приложението: на телефон заема целия екран, на компютър е колона в средата */
.app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 560px) {
  body { padding: 24px 0; }
  .app { height: calc(100dvh - 48px); max-height: 900px; border-radius: 24px; box-shadow: 0 12px 40px rgba(17, 17, 17, 0.12); }
}

/* Горна лента */
.top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  min-height: 56px;
}
.icon-btn {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px; border: 1px solid var(--line); background: var(--white);
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.brand { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.brand-co { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--red); }
.demo { display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 6px; background: var(--ink); color: var(--white); font-size: 10px; letter-spacing: 0.04em; }
.brand-title { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 359px) { .brand-title { font-size: 14px; } .step-label { font-size: 12px; } }
.step-label { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.progress { margin: 0 16px; height: 6px; border-radius: 3px; background: var(--line); }
.progress-bar { height: 6px; border-radius: 3px; background: var(--red); width: 0; transition: width 0.25s ease; }

/* Съдържание */
.main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 20px 16px 24px; }
.screen { display: flex; flex-direction: column; gap: 16px; }
h1 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 800; }
h2 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 800; }
h3 { margin: 0; font-size: 19px; font-weight: 800; }
.lead { margin: -6px 0 0; font-size: 15px; line-height: 1.5; color: var(--text); }
h1 + .lead { margin-top: -4px; font-size: 16px; }
.small { font-size: 13px; line-height: 1.5; color: var(--muted); margin: 0; }
.center { text-align: center; align-self: center; }
.label { font-size: 14px; font-weight: 700; }
.muted { color: var(--muted); font-weight: 600; }

.hero-illustration { border-radius: 20px; background: var(--dark); padding: 20px; display: flex; justify-content: center; }
.hero-illustration svg { width: 100%; max-width: 300px; height: auto; }
.perks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.perks li { display: flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 600; }
.perk-ic { width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--red-tint); color: var(--red); display: flex; align-items: center; justify-content: center; }

/* Карти за избор */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 16px; min-height: 140px; min-width: 0;
  border-radius: var(--radius); border: 2px solid var(--line); background: var(--white);
  text-align: left; cursor: pointer; color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.card[aria-pressed="true"] { border-color: var(--red); background: var(--red-tint); }
.card:focus-visible, .primary:focus-visible, .ghost-btn:focus-visible, .link-btn:focus-visible, .step-btn:focus-visible, .icon-btn:focus-visible, .switch-row:focus-visible, .acc-btn:focus-visible, .dash-btn:focus-visible, .sheet-btn:focus-visible {
  outline: 3px solid var(--ink); outline-offset: 2px;
}
.card-t { display: block; font-size: 16px; font-weight: 700; line-height: 1.25; }
.card-s { display: block; font-size: 13px; line-height: 1.35; color: var(--muted); margin-top: 2px; }
.card-row { flex-direction: row; align-items: center; gap: 16px; min-height: 84px; padding: 14px 16px; }
.card-row .card-t { font-size: 17px; }
.card-radio { flex-direction: row; align-items: center; justify-content: space-between; min-height: 60px; padding: 0 18px; font-size: 18px; font-weight: 700; }
.radio-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); display: flex; align-items: center; justify-content: center; }
.card-radio[aria-pressed="true"] .radio-dot { border-color: var(--ink); }
.card-radio[aria-pressed="true"] .radio-dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.card-var { align-items: center; gap: 2px; padding: 10px 4px; min-height: 76px; text-align: center; }
.v-l { font-size: 13px; font-weight: 700; }
.v-k { font-size: 17px; font-weight: 800; white-space: nowrap; }
.v-s { font-size: 11px; font-weight: 600; color: var(--muted); }
.card-mini { min-height: 48px; padding: 8px; align-items: center; justify-content: center; text-align: center; font-size: 14px; font-weight: 700; gap: 0; }
.card-mini small { font-size: 12px; font-weight: 600; color: var(--muted); }

.mini-compass { position: relative; width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; }
.mini-compass svg { transform: rotate(var(--rot)); }
.mc-n { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 800; color: var(--muted); background: inherit; padding: 0 2px; }
.card .mc-n { background: var(--white); }
.card[aria-pressed="true"] .mc-n { background: var(--red-tint); }

/* Площ */
.panel-box { border-radius: var(--radius); background: var(--white); border: 1px solid var(--line); padding: 12px; display: flex; justify-content: center; }
.area-svg { width: 100%; max-width: 300px; height: auto; font-family: Manrope, sans-serif; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field > .label { font-size: 14px; font-weight: 700; }
.stepper { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; gap: 8px; align-items: center; }
.step-btn {
  width: 52px; height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--white);
  font-size: 26px; font-weight: 700; cursor: pointer; padding: 0; touch-action: manipulation;
}
.step-btn:active { background: var(--red-tint); }
.step-field { display: flex; align-items: center; min-width: 0; height: 56px; border-radius: 14px; border: 2px solid var(--ink); background: var(--white); padding: 0 12px; }
.step-field:focus-within { border-color: var(--red); }
.step-field input { flex: 1; width: 100%; min-width: 0; border: none; outline: none; background: transparent; font-size: 22px; font-weight: 800; color: var(--ink); text-align: center; padding: 0; }
.step-field span { font-size: 16px; font-weight: 600; color: var(--muted); }
.total-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-radius: 14px; background: var(--red-tint); font-size: 15px; font-weight: 600; }
.total-row strong { font-size: 20px; font-weight: 800; }
.note-box { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 14px; background: var(--white); border: 1px solid var(--line); font-size: 14px; line-height: 1.5; color: var(--text); }
.note-box p { margin: 0; }
.note-box strong { color: var(--ink); }

.link-btn { align-self: flex-start; min-height: 44px; padding: 0; border: none; background: transparent; font-size: 15px; font-weight: 700; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.dash-btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; border-radius: 14px; border: 2px dashed var(--ink); background: transparent; font-size: 15px; font-weight: 700; cursor: pointer; }

/* Резултат */
#fitBlock { display: flex; flex-direction: column; gap: 16px; }
.hero-card { border-radius: 20px; background: var(--dark); color: var(--bg); padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.hc-pre { font-size: 14px; font-weight: 600; color: var(--dark-text); }
.hc-num { font-size: 44px; line-height: 1.05; font-weight: 800; color: var(--white); }
.hc-sub { font-size: 15px; font-weight: 600; }
.hc-note { margin-top: 8px; padding-top: 8px; border-top: 1px solid #3A3A3A; font-size: 12px; line-height: 1.45; color: var(--dark-text); }
.block { display: flex; flex-direction: column; gap: 8px; }
.white-card { border-radius: 20px; background: var(--white); border: 1px solid var(--line); padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.white-card.center { align-items: center; padding: 16px; }
.white-card.left { width: 100%; text-align: left; gap: 4px; }
.roof-draw { width: 100%; display: flex; justify-content: center; }
.roof-draw svg { display: block; max-width: 100%; height: auto; }
.flat-toggle { width: 100%; }
.price { font-size: 30px; line-height: 1.15; font-weight: 800; margin-top: -8px; }
.chosen { font-size: 14px; font-weight: 600; margin-top: -8px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats > div { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 12px; background: var(--bg); min-width: 0; }
.st-l { font-size: 11px; font-weight: 700; color: var(--muted); }
.st-v { font-size: 16px; font-weight: 800; }
.st-u { font-size: 11px; color: var(--muted); }
.cover { padding: 12px; border-radius: 12px; background: var(--red-tint); font-size: 14px; line-height: 1.45; font-weight: 600; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 0 2px; border: none; background: transparent; text-align: left; cursor: pointer; }
.sw-t { display: block; font-size: 15px; font-weight: 700; }
.sw-s { display: block; font-size: 13px; color: var(--muted); }
.switch { width: 52px; height: 32px; flex: none; border-radius: 16px; background: var(--line-strong); padding: 3px; display: flex; transition: background 0.15s; }
.switch span { width: 26px; height: 26px; border-radius: 50%; background: var(--white); transition: transform 0.15s; }
.switch-row[aria-pressed="true"] .switch { background: var(--ink); }
.switch-row[aria-pressed="true"] .switch span { transform: translateX(20px); }
.acc-btn { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 2px; border: none; border-top: 1px solid var(--line); background: transparent; font-size: 15px; font-weight: 700; cursor: pointer; }
.acc-sign { font-size: 20px; }
.bd-list { display: flex; flex-direction: column; margin-top: -4px; }
.bd-item { border-bottom: 1px solid var(--line); }
.bd-head {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 2px;
  border: none; background: transparent; text-align: left; cursor: pointer;
}
.bd-head:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.bd-txt { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.bd-t { font-size: 15px; font-weight: 700; }
.bd-s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-v { font-size: 15px; font-weight: 800; white-space: nowrap; }
.bd-chev { width: 10px; height: 10px; flex: none; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg) translate(-2px, -2px); transition: transform 0.15s; }
.bd-head[aria-expanded="true"] .bd-chev { transform: rotate(225deg) translate(-2px, -2px); }
.bd-body { display: flex; flex-direction: column; gap: 10px; padding: 2px 0 16px; }
.ln { display: flex; gap: 10px; align-items: center; }
.ln-img { width: 44px; height: 44px; flex: none; border-radius: 10px; object-fit: cover; background: var(--bg); border: 1px solid var(--line); }
.ln-noimg { display: block; }
.ln-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ln-name { font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--ink); }
a.ln-name { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.ln-calc { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bd-note { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text); }
.bd-sub { margin: 4px 0 0; font-size: 13px; font-weight: 700; }
.bd-parts { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; line-height: 1.4; }
.bd-parts a { color: var(--ink); }
.bd-change { align-self: flex-start; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 2px solid var(--red); background: var(--white); color: var(--red); font-size: 14px; font-weight: 800; cursor: pointer; }
.bd-change:active { background: var(--red-tint); }
.bd-total { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 2px 6px; font-size: 15px; font-weight: 700; }
.bd-total strong { font-size: 18px; font-weight: 800; }

/* Намерете покрива си */
.auto-card { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--white); border: 2px solid var(--red); }
.auto-txt { display: flex; flex-direction: column; gap: 4px; }
.auto-txt strong { font-size: 16px; font-weight: 800; }
.auto-txt span { font-size: 14px; line-height: 1.45; color: var(--text); }
.auto-ok { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 14px; background: var(--red-tint); font-size: 14px; line-height: 1.45; font-weight: 600; }
.roof-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 12px; margin: 0 -4px; padding: 2px 4px 8px; }
.addr-form { display: flex; flex-direction: column; gap: 6px; }
.addr-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.addr-row input { height: 52px; min-width: 0; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--white); padding: 0 14px; font-size: 16px; color: var(--ink); }
.addr-row input:focus { outline: 2px solid var(--red); border-color: var(--red); }
.addr-go { height: 52px; padding: 0 18px; border-radius: 12px; border: none; background: var(--ink); color: var(--white); font-size: 15px; font-weight: 800; cursor: pointer; }
.addr-go:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.roof-status { margin: 0; font-size: 14px; line-height: 1.45; font-weight: 600; min-height: 0; }
.roof-status:empty { display: none; }
.roof-status.err { color: var(--red); }
.roof-result { display: flex; flex-direction: column; gap: 10px; }
.roof-img-wrap { border-radius: 14px; overflow: hidden; background: #2B2F36; aspect-ratio: 640 / 400; }
.roof-img-wrap img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: crosshair; }
.seg { min-height: 64px; padding: 10px 14px; gap: 12px; }
.seg-letter { width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--red); color: var(--white); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.seg-main { display: flex; flex-direction: column; min-width: 0; }
.seg .card-t { font-size: 15px; }
.g-attr { margin: 0; font-family: Roboto, Arial, sans-serif; font-size: 12px; font-weight: 400; color: #5E5E5E; }
.g-note .g-attr { display: block; margin-top: 2px; }
#roofSheet .primary { flex: none; margin-top: 4px; }

/* Избор от каталога */
.sheet-tall { height: 88%; max-height: 88%; overflow: hidden; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line-strong); background: var(--white); font-size: 14px; font-weight: 700; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--white); }
.pick-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 8px; margin: 0 -4px; padding: 2px 4px 8px; }
.pick {
  display: flex; flex: none; align-items: center; gap: 10px; width: 100%; padding: 10px; min-height: 72px;
  border-radius: 14px; border: 2px solid var(--line); background: var(--white); text-align: left; cursor: pointer;
}
.pick[aria-pressed="true"] { border-color: var(--red); background: var(--red-tint); }
.pick:focus-visible, .chip:focus-visible, .bd-change:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.pick-img { width: 56px; height: 56px; flex: none; border-radius: 10px; object-fit: cover; background: var(--bg); border: 1px solid var(--line); }
.pick-noimg { display: block; }
.pick-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.pick-t { font-size: 14px; font-weight: 700; line-height: 1.3; }
.pick-m { font-size: 12px; color: var(--muted); line-height: 1.35; }
.pick-h { font-size: 12px; font-weight: 700; color: var(--ink); }
.pick-r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.pick-p { font-size: 14px; font-weight: 800; white-space: nowrap; }
.pick-b { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; padding: 2px 6px; border-radius: 6px; background: var(--ink); color: var(--white); white-space: nowrap; }
.fine { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

/* Запитване */
.dark-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 14px; background: var(--dark); color: var(--bg); }
.dc-pre { font-size: 13px; color: var(--dark-text); }
.dc-main { font-size: 17px; font-weight: 800; }
#leadForm { display: flex; flex-direction: column; gap: 16px; }
#leadForm input[type="text"], #leadForm input[type="tel"] {
  height: 52px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--white);
  padding: 0 14px; font-size: 17px; color: var(--ink); width: 100%;
}
#leadForm input:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: var(--red); }
#leadForm input[aria-invalid="true"] { border-color: var(--red); }
.err { font-size: 13px; font-weight: 600; color: var(--red); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 13px; line-height: 1.5; color: var(--text); cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--ink); }

/* Благодарим */
.thanks { display: flex; flex-direction: column; gap: 18px; align-items: center; text-align: center; padding-top: 32px; }
.thanks-ic { width: 88px; height: 88px; border-radius: 50%; background: var(--red-tint); color: var(--red); display: flex; align-items: center; justify-content: center; }

/* Долна лента */
.bottom { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.primary {
  width: 100%; height: 56px; border-radius: 14px; border: none; background: var(--red); color: var(--white);
  font-size: 17px; font-weight: 800; cursor: pointer; touch-action: manipulation;
}
.primary:active { background: var(--red-dark); }
.primary:disabled { opacity: 0.45; cursor: default; }
.ghost-btn { min-height: 48px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--ink); background: transparent; font-size: 15px; font-weight: 700; color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; }

/* Долни листове: споделяне и компас */
.sheet-wrap { position: absolute; inset: 0; background: rgba(17, 17, 17, 0.55); display: flex; align-items: flex-end; z-index: 10; }
.sheet { width: 100%; background: var(--white); border-radius: 22px 22px 0 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; max-height: 92%; overflow-y: auto; }
.sheet-btn { min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; font-weight: 700; color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; text-decoration: none; }

.compass { position: relative; width: 220px; height: 220px; margin: 8px auto; }
.compass-dial { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--line); background: var(--bg); transition: transform 0.12s linear; }
.cd { position: absolute; font-size: 18px; font-weight: 800; color: var(--muted); }
.cd-n { top: 8px; left: 50%; transform: translateX(-50%); color: var(--red); }
.cd-s { bottom: 8px; left: 50%; transform: translateX(-50%); }
.cd-e { right: 12px; top: 50%; transform: translateY(-50%); }
.cd-w { left: 12px; top: 50%; transform: translateY(-50%); }
.compass-arrow { position: absolute; left: 50%; top: 50%; width: 40px; height: 120px; transform: translate(-50%, -50%); }
.compass-read { margin: 0; text-align: center; font-size: 18px; font-weight: 800; min-height: 27px; }

@media (max-width: 350px) {
  h1 { font-size: 25px; }
  h2 { font-size: 21px; }
  .card { padding: 12px; }
  .hc-num { font-size: 38px; }
  .stats > div { padding: 8px 6px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
