/* =========================================================
   ESTILOS · Cotizador de carpintería a medida
   El color de marca (--cell) se cambia desde "Ajustes > Marca"
   ========================================================= */
:root {
  --cell: #234E3C;                                        /* color de marca */
  --cell-dark: color-mix(in srgb, var(--cell) 70%, #000);
  --cell-soft: color-mix(in srgb, var(--cell) 8%, #fff);
  --oak: #E3A857;                                         /* acento: roble claro */
  --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 }
[hidden] { display: none !important }
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(--oak); 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: 28px; height: 34px; border-radius: 4px; display: block; box-shadow: 0 0 0 5px rgba(227, 168, 87, .25);
  background: radial-gradient(circle at 78% 52%, rgba(0, 0, 0, .45) 0 2px, transparent 2.5px), repeating-linear-gradient(92deg, rgba(90, 50, 20, .14) 0 2px, transparent 2px 6px), var(--oak) }
.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(--oak); 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-oak { background: var(--oak); color: var(--ink) }
.btn-oak: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 }
.form .check { font-size: .9rem; color: var(--ink); margin: 10px 0 0; cursor: pointer }
.form .check input { width: 16px; height: 16px; accent-color: var(--cell) }
.set-h { grid-column: 1 / -1; margin: 18px 0 -4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--cell) }
.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 } }
.stage { position: relative; background: var(--cell-dark); border-radius: 10px; padding: 14px }
.stage-cap { font-size: .78rem; opacity: .7; margin-top: 8px; display: flex; justify-content: space-between; gap: 8px }
/* alzado: cada pieza va en % dentro de una escena de proporción 1,6 (ver renderElev en core.js) */
.elev { position: relative; width: 100%; aspect-ratio: 1.6; overflow: hidden }
.elev > span { position: absolute; display: block }
.elev .floor { left: 0; right: 0; height: 2px; background: rgba(255, 255, 255, .3) }
.elev .elev-empty { inset: 0; display: grid; place-items: center; font-size: .85rem; opacity: .7; text-align: center }
.fr { background-color: var(--fin); background-image: var(--grain); border: 1px solid rgba(0, 0, 0, .3); border-radius: 2px; transform-origin: bottom; animation: pop .35s ease both }
.fr::after { content: ''; position: absolute; background: var(--hdl); border-radius: 2px }
.fr.h-top::after { left: 34%; right: 34%; top: 9%; height: 3px; max-height: 12% }
.fr.h-bot::after { left: 34%; right: 34%; bottom: 9%; height: 3px }
.fr.h-l::after { left: 9%; top: 44%; width: 3px; height: 14% }
.fr.h-r::after { right: 9%; top: 44%; width: 3px; height: 14% }
.fr.h-gola::after { left: 0; right: 0; top: 0; height: 4px; background: rgba(0, 0, 0, .55); border-radius: 0 }
.fr.h-none::after { display: none }
.fr.knob::after { right: 9%; top: 49%; width: 6px; height: 6px; border-radius: 50% }
.fr.knob.long::after { width: 14%; height: 3px; border-radius: 2px }
.elev .ct { background: var(--ct, var(--fin)); border: 1px solid rgba(0, 0, 0, .35); border-radius: 1px }
.elev .ct.fin { background-color: var(--fin); background-image: var(--grain) }
.elev .plinth { background: rgba(0, 0, 0, .35) }
.elev .led { background: linear-gradient(180deg, rgba(255, 233, 160, .85), rgba(255, 233, 160, 0)); border-top: 2px solid #FFF1C4 }
.elev .back { background-color: var(--fin); background-image: linear-gradient(rgba(0, 0, 0, .35), rgba(0, 0, 0, .35)), var(--grain); border: 1px solid rgba(0, 0, 0, .3) }
.elev .shelf { background-color: var(--fin); background-image: var(--grain); box-shadow: 0 1px 0 rgba(0, 0, 0, .35) }
.elev .jamb { background-color: var(--fin); background-image: linear-gradient(rgba(0, 0, 0, .18), rgba(0, 0, 0, .18)), var(--grain); border: 1px solid rgba(0, 0, 0, .3) }
.elev .hole { background: rgba(0, 0, 0, .45) }
.elev .rail { background: rgba(255, 255, 255, .6); border-radius: 2px }
@keyframes pop { from { transform: scaleY(.2); opacity: 0 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .fr { animation: none !important } }
.glow { position: absolute; right: -60px; top: -60px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, rgba(227, 168, 87, .45), 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; min-width: 0 }
.hero-stats b { display: block; font-size: 1.25rem; font-weight: 700; opacity: 1; color: var(--oak) }

.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 }
.plan { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 14px 0 10px; background: var(--line); gap: 2px }
.plan span { display: block; min-width: 6px }
.p1 { background: var(--oak) } .p2 { background: var(--cell) } .p3 { background: var(--ok) }
.plan-cap { display: grid; gap: 4px; font-size: .82rem; color: var(--mute); margin-bottom: 10px }
.plan-cap span { display: flex; align-items: center; gap: 8px }
.plan-cap i { width: 10px; height: 10px; border-radius: 3px; flex: none }
.plan-cap b { color: var(--ink); margin-left: auto; white-space: nowrap }
.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 .glow { 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(--oak) }

/* ---------- 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 }
  .fr { animation: none !important }
}
.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 .elev-wrap { width: min(100%, 116mm) }
.pdf-cover .stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--oak); 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-page .breakdown td { padding: 1.7mm 0 }
.pdf-page .breakdown small { display: inline; margin-left: 2mm; font-size: 8pt }
.pdf-page .breakdown tr.total td { padding-top: 3mm }
.pdf-page .kv { padding: 1.2mm 0; font-size: 9.5pt }
.pdf-page .plan-cap { font-size: 9pt }
.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 }
