/* =========================================================
   ESTILOS · Cotizador de toldos y pérgolas
   El color de marca (--cell) se cambia desde "Ajustes > Marca"
   ========================================================= */
:root {
  --cell: #2F5D50;                                        /* color de marca */
  --cell-dark: color-mix(in srgb, var(--cell) 70%, #000);
  --cell-soft: color-mix(in srgb, var(--cell) 8%, #fff);
  --sun: #F2B705;
  --paper: #FBFCFD;
  --ink: #0F1B2A;
  --mute: #5B6B7C;
  --line: #D8DEE6;
  --ok: #2E7D5B;
  --warn: #B4541A;
  --f: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box }
html, body { margin: 0 }
body { font-family: var(--f); color: var(--ink); background: var(--paper); font-size: 16px; line-height: 1.45 }
button, input, select, textarea { font: inherit; color: inherit }
img { max-width: 100% }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px }

/* ---------- cabecera y navegación ---------- */
.top { background: var(--cell); color: #fff; padding: 14px clamp(16px, 4vw, 48px); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none }
.brand-logo { width: 40px; height: 40px; display: grid; place-items: center; flex: none }
.brand-logo img { max-height: 40px; max-width: 40px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px }
.brand-mark { width: 32px; height: 32px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 6px rgba(242, 183, 5, .25); display: block }
.brand b { font-stretch: 115%; font-weight: 800; font-size: 1.1rem; display: block; line-height: 1.1 }
.brand small { display: block; font-size: .78rem; opacity: .75 }
.nav { display: flex; gap: 4px; flex-wrap: wrap }
.nav a { color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: .92rem; opacity: .8 }
.nav a:hover { opacity: 1; background: rgba(255, 255, 255, .1) }
.nav a[aria-current=page] { opacity: 1; background: rgba(255, 255, 255, .16); font-weight: 600 }
.nav .badge { background: var(--sun); color: var(--ink); border-radius: 10px; padding: 0 7px; font-size: .75rem; font-weight: 700; margin-left: 4px }

/* ---------- botones ---------- */
.btn { border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; font-size: .95rem }
.btn-sun { background: var(--sun); color: var(--ink) }
.btn-sun:hover { filter: brightness(1.05) }
.btn-cell { background: var(--cell); color: #fff }
.btn-cell:hover { background: var(--cell-dark) }
.btn-line { background: #fff; border: 1px solid var(--line); color: var(--ink) }
.btn-line:hover { border-color: var(--cell) }
.btn-ghost { background: rgba(255, 255, 255, .12); color: #fff }
.btn-ghost:hover { background: rgba(255, 255, 255, .2) }
.btn-sm { padding: 6px 10px; font-size: .85rem }
.btn-wa { background: #1FA855; color: #fff }
.btn-wa:hover { background: #188C46 }

/* ---------- layout cotizador ---------- */
.wrap { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; min-height: calc(100vh - 68px) }
.form { padding: 28px clamp(16px, 3vw, 36px); border-right: 1px solid var(--line); background: #fff }
.out { padding: 28px clamp(16px, 4vw, 56px); min-width: 0 }
@media (max-width: 880px) { .wrap { grid-template-columns: 1fr } .form { border-right: 0; border-bottom: 1px solid var(--line) } }

h1 { font-stretch: 120%; font-weight: 800; font-size: 1.6rem; line-height: 1.1; margin: 0 0 6px }
.lead { color: var(--mute); margin: 0 0 24px; font-size: .95rem; max-width: 60ch }
fieldset { border: 0; margin: 0 0 22px; padding: 0 }
legend { font-weight: 700; font-size: 1rem; margin-bottom: 10px; padding: 0; display: flex; align-items: center; gap: 8px }
legend i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; background: var(--cell); color: #fff; font-size: .75rem; display: inline-grid; place-items: center }
label { display: block; font-size: .85rem; color: var(--mute); margin: 10px 0 4px }
input[type=text], input[type=number], input[type=email], input[type=tel], select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff }
input:focus, select:focus, textarea:focus { border-color: var(--cell); outline: none; box-shadow: 0 0 0 3px var(--cell-soft) }
input[type=color] { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 3px; background: #fff }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden }
.seg button { flex: 1; border: 0; background: #fff; padding: 9px 6px; cursor: pointer; font-size: .88rem }
.seg button + button { border-left: 1px solid var(--line) }
.seg button[aria-pressed=true] { background: var(--cell); color: #fff; font-weight: 600 }
input[type=range] { width: 100%; accent-color: var(--cell) }
.range-val { float: right; font-weight: 700; color: var(--ink) }
.photo-drop { border: 1px dashed var(--line); border-radius: 8px; padding: 12px; display: flex; gap: 12px; align-items: center; cursor: pointer; font-size: .88rem; color: var(--mute) }
.photo-drop:hover { border-color: var(--cell) }
.photo-drop img { width: 64px; height: 48px; object-fit: cover; border-radius: 4px }
.photo-drop input { display: none }
.from-lead { background: #FFF6DB; color: #6B4E00; border-radius: 8px; padding: 10px 12px; font-size: .88rem; margin-bottom: 18px }

/* ---------- resultado ---------- */
.quote-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px }
.quote-head h2 { margin: 0; font-stretch: 115%; font-size: 1.25rem }
.quote-meta { color: var(--mute); font-size: .85rem }
.state-pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 600; background: var(--line) }
.st-borrador { background: #E9EDF2; color: var(--mute) }
.st-enviado { background: #E3EEFA; color: #1F5A99 }
.st-visto { background: #FFF1C9; color: #7A5900 }
.st-aceptado { background: #DDF2E7; color: var(--ok) }
.st-rechazado { background: #F7E1D6; color: var(--warn) }

.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: center; background: var(--cell); color: #fff; border-radius: 16px; padding: clamp(18px, 3vw, 32px); position: relative; overflow: hidden }
@media (max-width: 1100px) { .hero { grid-template-columns: 1fr } }
.scene { position: relative; background: var(--cell-dark); border-radius: 10px; padding: 8px; min-height: 180px; display: grid; place-items: center }
.scene svg { width: 100%; height: auto; display: block; max-height: 260px }
.roof-cap { font-size: .78rem; opacity: .7; margin-top: 8px; display: flex; justify-content: space-between; gap: 8px }
/* piezas del dibujo de la terraza */
.sc-wall { fill: rgba(255, 255, 255, .07) }
.sc-floor { fill: rgba(255, 255, 255, .13) }
.sc-door { fill: rgba(0, 0, 0, .18) }
.sc-man { fill: rgba(255, 255, 255, .62) }
.sc-bar, .sc-post, .sc-shine { stroke-linecap: round }
.sc-post { stroke: rgba(255, 255, 255, .55) }
.sc-slab { fill: rgba(255, 255, 255, .28) }
.sc-frame { fill: none; stroke-linejoin: round }
.sc-lama { stroke: rgba(0, 0, 0, .25); stroke-width: .6 }
.sc-side { opacity: .55 }
.sc-glass { fill: rgba(190, 228, 255, .22); stroke: rgba(255, 255, 255, .75); stroke-width: 1.2 }
.sc-shine { stroke: rgba(255, 255, 255, .55) }
.sc-led { fill: #FFE9A3; filter: drop-shadow(0 0 3px #FFD25A) }
.sc-heat { fill: #E8763A }
/* elección de producto y accionamiento (botones en rejilla) */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px }
.choices.two { grid-template-columns: 1fr 1fr }
.choices button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 9px 10px; cursor: pointer; font-size: .86rem; text-align: left; line-height: 1.25 }
.choices button small { display: block; color: var(--mute); font-size: .74rem; margin-top: 2px }
.choices button:hover { border-color: var(--cell) }
.choices button[aria-pressed=true] { background: var(--cell); border-color: var(--cell); color: #fff; font-weight: 600 }
.choices button[aria-pressed=true] small { color: rgba(255, 255, 255, .8) }
.row.r3 { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)) }
.extras { display: flex; flex-direction: column; gap: 8px }
.extras .check { font-size: .9rem; color: var(--ink); margin: 0 }
.extras .check small { color: var(--mute) }
.hint { font-size: .8rem; color: var(--mute); margin: 6px 0 0 }
.sunglow { position: absolute; right: -60px; top: -60px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, rgba(242, 183, 5, .55), transparent 65%); pointer-events: none }
.big { font-stretch: 125%; font-weight: 800; font-size: clamp(2.4rem, 5vw, 3.6rem); line-height: 1; margin: 4px 0 2px }
.big small { font-size: .4em; font-weight: 600; font-stretch: 100%; opacity: .8 }
.hero p { margin: 0; opacity: .85 }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 22px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .18) }
.hero-stats div { font-size: .8rem; opacity: .85 }
.hero-stats b { display: block; font-size: 1.25rem; font-weight: 700; opacity: 1; color: var(--sun) }
#hsPerk { font-size: 1.05rem; line-height: 1.25; margin-bottom: 2px }

.cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; margin-top: 28px }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr } }
h3 { font-size: 1rem; margin: 0 0 10px }
table { width: 100%; border-collapse: collapse; font-size: .92rem }
td, th { padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left }
.breakdown td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums }
td small { display: block; color: var(--mute); font-size: .8rem }
tr.sub td { border-bottom: 0; padding-top: 12px; color: var(--mute) }
tr.total td { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 800; font-size: 1.1rem; padding-top: 12px }
.saving { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: #fff }
.kv { display: flex; justify-content: space-between; padding: 6px 0; font-size: .92rem; gap: 12px }
.kv b { font-variant-numeric: tabular-nums; white-space: nowrap }
.note { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: .85rem; background: #FFF6DB; color: #6B4E00 }
.note.warn { background: #FBE9DF; color: var(--warn) }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px }
.fine { color: var(--mute); font-size: .78rem; margin-top: 18px; max-width: 70ch }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: .92rem; opacity: 0; transition: .25s; pointer-events: none; z-index: 50 }
.toast.show { opacity: 1; transform: translateX(-50%) }

/* ---------- diálogo de ajustes ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; max-width: 560px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(15, 27, 42, .3) }
dialog::backdrop { background: rgba(15, 27, 42, .5) }
.dlg-h { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center }
.dlg-h h3 { margin: 0 }
.tabs { display: flex; gap: 4px; padding: 12px 22px 0; border-bottom: 1px solid var(--line) }
.tabs button { border: 0; background: none; padding: 10px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--mute) }
.tabs button[aria-selected=true] { border-color: var(--cell); color: var(--ink); font-weight: 600 }
.dlg-b { padding: 8px 22px 20px; max-height: 62vh; overflow: auto }
.dlg-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px }
.x { background: none; border: 0; font-size: 1.4rem; cursor: pointer; line-height: 1 }

/* ---------- panel de presupuestos ---------- */
.page { padding: 28px clamp(16px, 4vw, 56px); max-width: 1280px; margin: 0 auto }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin: 20px 0 28px }
.kpis div { padding: 16px 18px; font-size: .85rem; color: var(--mute) }
.kpis div + div { border-left: 1px solid var(--line) }
.kpis b { display: block; font-size: 1.6rem; color: var(--ink); font-stretch: 115%; font-weight: 800; font-variant-numeric: tabular-nums }
@media (max-width: 760px) { .kpis { grid-template-columns: 1fr 1fr } .kpis div:nth-child(3) { border-left: 0 } .kpis div:nth-child(n+3) { border-top: 1px solid var(--line) } }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px }
.filters button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 12px; cursor: pointer; font-size: .85rem }
.filters button[aria-pressed=true] { background: var(--cell); border-color: var(--cell); color: #fff }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px }
.list { min-width: 760px }
.list th { font-size: .8rem; color: var(--mute); font-weight: 600; padding: 12px 14px; background: var(--cell-soft) }
.list td { padding: 12px 14px; vertical-align: middle }
.list tr:last-child td { border-bottom: 0 }
.list .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap }
.list select { width: auto; padding: 5px 8px; font-size: .85rem }
.follow { color: var(--warn); font-size: .8rem; font-weight: 600; display: block; margin-top: 2px }
.row-actions { display: flex; gap: 6px; justify-content: flex-end }
.list td:first-child, .list td:last-child { white-space: nowrap }
.section-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 36px 0 12px }
.section-h h2 { margin: 0; font-size: 1.2rem; font-stretch: 115% }
.empty-state { padding: 28px; text-align: center; color: var(--mute) }

/* ---------- web pública (captación) ---------- */
.pub-hero { background: var(--cell); color: #fff; padding: clamp(36px, 7vw, 80px) clamp(16px, 5vw, 64px) clamp(120px, 14vw, 160px); position: relative; overflow: hidden }
.pub-hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); max-width: 16ch; margin: 0 0 12px }
.pub-hero p { max-width: 52ch; opacity: .85; margin: 0; font-size: 1.05rem }
.pub-hero .sunglow { width: 380px; height: 380px; right: -120px; top: -140px }
.pub-card { max-width: 980px; margin: -100px auto 40px; background: #fff; border-radius: 16px; box-shadow: 0 18px 50px rgba(15, 27, 42, .14); display: grid; grid-template-columns: 1fr 1fr; position: relative; overflow: hidden }
@media (max-width: 820px) { .pub-card { grid-template-columns: 1fr; margin: -100px 16px 40px } }
.pub-in, .pub-res { padding: clamp(20px, 3vw, 36px) }
.pub-res { background: var(--cell-soft); display: flex; flex-direction: column }
.pub-bill { font-stretch: 125%; font-weight: 800; font-size: 2.6rem; line-height: 1; margin: 6px 0 }
.pub-range { font-stretch: 115%; font-weight: 800; font-size: 1.7rem; line-height: 1.1 }
.pub-res .kv { border-bottom: 1px solid var(--line) }
.pub-form { margin-top: auto; padding-top: 20px }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: .8rem; color: var(--mute) }
.check input { margin-top: 3px }
.done { text-align: center; padding: 24px 8px }
.done b { display: block; font-size: 1.3rem; margin-bottom: 6px; font-stretch: 115% }
.pub-foot { text-align: center; color: var(--mute); font-size: .85rem; padding: 0 16px 40px }
.demo-bar { background: var(--ink); color: #fff; font-size: .85rem; padding: 8px 16px; text-align: center }
.demo-bar a { color: var(--sun) }

/* ---------- PDF (solo impresión) ---------- */
#pdf { display: none }
@page { size: A4; margin: 0 }
@media print {
  body > *:not(#pdf) { display: none !important }
  body { background: #fff }
  #pdf { display: block }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact }
  .scene svg { max-height: none }
}
.pdf-page { width: 210mm; min-height: 297mm; padding: 16mm 16mm 14mm; position: relative; page-break-after: always; break-after: page; display: flex; flex-direction: column; font-size: 10.5pt }
.pdf-page:last-child { page-break-after: auto; break-after: auto }
.pdf-cover { background: var(--cell); color: #fff; padding: 0 }
.pdf-cover .in { padding: 18mm 16mm 0; flex: 1; display: flex; flex-direction: column }
.pdf-brand { display: flex; align-items: center; gap: 12px }
.pdf-brand img { max-height: 48px; max-width: 120px; background: #fff; border-radius: 8px; padding: 4px }
.pdf-brand b { font-stretch: 115%; font-size: 15pt; display: block }
.pdf-cover h1 { font-size: 34pt; max-width: 12ch; margin: 22mm 0 6mm; line-height: 1.02 }
.pdf-cover .who { font-size: 12pt; opacity: .9 }
.pdf-cover .photo { margin: 10mm 0 0; height: 78mm; border-radius: 10px; overflow: hidden; background: var(--cell-dark); padding: 10px }
.pdf-cover .photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; display: block }
.pdf-cover .photo { display: grid; place-items: center }
.pdf-cover .photo .scene-pdf { width: 100%; height: 100% }
.pdf-cover .photo .scene-pdf svg { width: 100%; height: 100%; max-height: none; animation: none }
.pdf-cover .stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--sun); color: var(--ink); margin-top: auto; padding: 8mm 16mm }
.pdf-cover .stats div { font-size: 9pt }
.pdf-cover .stats b { display: block; font-size: 17pt; font-stretch: 115% }
.pdf-h { display: flex; justify-content: space-between; align-items: center; padding-bottom: 6mm; margin-bottom: 8mm; border-bottom: 2px solid var(--cell); font-size: 9pt; color: var(--mute) }
.pdf-h b { color: var(--ink); font-size: 11pt }
.pdf-page h2 { font-stretch: 115%; font-size: 18pt; margin: 0 0 4mm; color: var(--cell) }
.pdf-page h3 { font-size: 11pt; margin: 8mm 0 3mm }
.pdf-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10mm }
.pdf-foot { margin-top: auto; padding-top: 6mm; border-top: 1px solid var(--line); font-size: 8.5pt; color: var(--mute); display: flex; justify-content: space-between; gap: 8px }
.pdf-cond { font-size: 9.5pt; line-height: 1.5; padding-left: 5mm }
.pdf-cond li { margin-bottom: 2mm }
.sign { display: grid; grid-template-columns: 1fr 1fr; gap: 10mm; margin-top: 12mm }
.sign > div { font-size: 9pt; color: var(--mute) }
.sign .box { border: 1px solid var(--line); border-radius: 6px; height: 30mm; margin-bottom: 2mm }

/* PDF del sector: la página 2 lleva desglose largo + ficha técnica; se compacta para que quepa en A4 */
.pdf-page { height: 297mm; overflow: hidden }
.pdf-page .breakdown { font-size: 9.5pt }
.pdf-page .breakdown td { padding: 1.6mm 0 }
.pdf-page .breakdown tr.sub td { padding-top: 2.5mm }
.pdf-page .breakdown tr.total td { padding-top: 2.5mm; font-size: 12pt }
.pdf-page .kv { padding: 1.1mm 0; font-size: 9pt }
.pdf-page .pdf-two h3 { margin: 6mm 0 2mm }
.pdf-cover .stats { gap: 4mm }
.pdf-cover .stats b { font-size: 15pt }
