/* =========================================================
   ESTILOS · Cotizador de piscinas
   El color de marca (--cell) se cambia desde "Ajustes > Marca"
   ========================================================= */
:root {
  --cell: #0D5C63;                                        /* color de marca */
  --cell-dark: color-mix(in srgb, var(--cell) 70%, #000);
  --cell-soft: color-mix(in srgb, var(--cell) 8%, #fff);
  --acc: #5ED6CF;                                         /* agua: acento para cifras y botones */
  --water: linear-gradient(90deg, #A9F0EE, #4CC9D6 40%, #1C8DB4 80%, #146E9A);
  --sand: #E9DEC6;
  --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(--acc); 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: 10px; background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .55), transparent 40%), var(--water); box-shadow: 0 0 0 5px rgba(94, 214, 207, .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(--acc); 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-acc { background: var(--acc); color: var(--ink) }
.btn-acc: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) }
.row3 { grid-template-columns: 1fr 1fr 1fr }
.seg button[hidden] { display: none }
.seg button:disabled { opacity: .45; cursor: not-allowed }
.hint { font-size: .8rem; color: var(--mute); margin: 6px 0 0 }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px }
.chip { margin: 0; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 20px; padding: 7px 12px; font-size: .86rem; color: var(--ink); cursor: pointer; background: #fff; user-select: none }
.chip input { accent-color: var(--cell); margin: 0 }
.chip:has(input:checked) { border-color: var(--cell); background: var(--cell-soft); font-weight: 600 }
.chip[hidden] { display: none }
.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 } }
/* vista en planta de la piscina */
.plan { position: relative; background: var(--cell-dark); border-radius: 10px; padding: 14px; min-height: 180px; display: grid; place-items: center }
.plan-site { --ph: 190px; position: relative; width: min(100%, calc(var(--ar, 2) * var(--ph))); aspect-ratio: var(--ar, 2); border-radius: 6px; container-type: inline-size;
  background: repeating-linear-gradient(0deg, transparent 0 13px, rgba(120, 100, 70, .12) 13px 14px), repeating-linear-gradient(90deg, transparent 0 13px, rgba(120, 100, 70, .12) 13px 14px), var(--sand);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35) }
.water { position: absolute; border-radius: 4px; background: radial-gradient(ellipse at 25% 35%, rgba(255, 255, 255, .35), transparent 45%), radial-gradient(ellipse at 70% 70%, rgba(255, 255, 255, .18), transparent 40%), var(--water);
  box-shadow: 0 0 0 3px #F7F2E7, inset 0 2px 8px rgba(0, 40, 60, .35); display: grid; place-items: center; transition: all .3s ease; overflow: hidden }
.water.free { border-radius: 46% 54% 40% 60% / 58% 44% 56% 42% }
.steps { position: absolute; border-radius: 999px 0 0 999px; background: repeating-radial-gradient(circle at 100% 50%, #B9F3F1 0 7px, #8FE1E6 7px 8px); box-shadow: -3px 0 0 #F7F2E7; transition: all .3s ease }
.depth { font-size: .72rem; font-weight: 700; color: #fff; background: rgba(8, 50, 70, .45); padding: 2px 8px; border-radius: 10px; white-space: nowrap }
.dim { position: absolute; font-size: .7rem; font-weight: 700; color: #5A4A30; line-height: 1; display: flex; align-items: center; justify-content: center; white-space: nowrap; transition: all .3s ease }
.dim-w { transform: translateY(calc(-100% - 5px)); border-top: 0; padding-bottom: 2px; background: linear-gradient(#5A4A30, #5A4A30) bottom / 100% 1px no-repeat }
.dim-h { transform: translateX(6px); width: 1px; background: #5A4A30 }
.dim-h b { position: absolute; left: 4px; top: 50%; transform: translateY(-50%) }
.plan-cap { font-size: .78rem; opacity: .7; margin-top: 8px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap }
.glow { position: absolute; right: -60px; top: -60px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, rgba(94, 214, 207, .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 }
.hero-stats b { display: block; font-size: 1.25rem; font-weight: 700; opacity: 1; color: var(--acc) }

.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 }
.hitos { display: flex; gap: 3px; height: 34px; margin: 12px 0 6px; border-radius: 6px; overflow: hidden }
.hitos span { display: grid; place-items: center; color: #fff; font-size: .78rem; font-weight: 700; min-width: 0 }
.hitos .h0 { background: var(--cell) } .hitos .h1 { background: color-mix(in srgb, var(--cell) 65%, #4CC9D6) } .hitos .h2 { background: #2FA7B8 }
.hitos-cap { display: flex; flex-direction: column; gap: 2px; font-size: .82rem; margin-bottom: 4px }
.hitos-cap div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0 }
.hitos-cap i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px }
.hitos-cap b { font-variant-numeric: tabular-nums; 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(--acc) }

/* ---------- 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 }
  .water, .steps, .dim { transition: 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 .plan-site { margin: 0 auto; --ph: 66mm }
.pdf-cover .stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--acc); 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 .hitos { height: 12mm }
/* en una piscina hay muchas partidas: en el PDF el desglose va compacto, con el detalle en la misma línea */
.pdf-page .breakdown { font-size: 9.5pt }
.pdf-page .breakdown td { padding: 1.6mm 0 }
.pdf-page .breakdown td small { display: inline; font-size: 8pt; margin-left: 2mm }
.pdf-page .breakdown tr.sub td { padding-top: 2mm }
.pdf-page .breakdown tr.total td { padding-top: 2.5mm; font-size: 12pt }
.pdf-page .pdf-two h3 { margin-top: 6mm }
.pdf-page .kv { padding: 1.2mm 0 }
.pdf-page .hitos-cap div { padding: 1mm 0 }
.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 }
