/* ============ Fuentes locales ============ */
@font-face { font-family: "Cormorant"; font-weight: 500; font-style: normal; font-display: swap; src: url("./fonts/cormorant-garamond-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Cormorant"; font-weight: 600; font-style: normal; font-display: swap; src: url("./fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Cormorant"; font-weight: 500; font-style: italic; font-display: swap; src: url("./fonts/cormorant-garamond-latin-500-italic.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 400; font-display: swap; src: url("./fonts/manrope-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 500; font-display: swap; src: url("./fonts/manrope-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 600; font-display: swap; src: url("./fonts/manrope-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 700; font-display: swap; src: url("./fonts/manrope-latin-700-normal.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --bg: #f7f2ea;
  --bg-deep: #efe7db;
  --paper: #fffdf9;
  --white: #ffffff;
  --ink: #1b1714;
  --ink-soft: #4b423b;
  --muted: #7a6f66;
  --line: #e6dccf;
  --line-strong: #d6c8b6;
  --forest: #173d34;
  --forest-2: #24594b;
  --forest-soft: #e8f0ec;
  --sage: #9bb3a6;
  --copper: #d7651f;
  --copper-deep: #b44f14;
  --copper-soft: #fbece1;
  --champagne: #c7a46a;
  --danger: #a3341a;
  --danger-soft: #fbe9e3;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(43, 31, 20, .05), 0 2px 8px rgba(43, 31, 20, .04);
  --shadow: 0 1px 2px rgba(43, 31, 20, .04), 0 18px 50px rgba(43, 31, 20, .09);
  --serif: "Cormorant", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-family: var(--sans);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(1200px 500px at 90% -10%, rgba(199,164,106,.13), transparent 60%),
    radial-gradient(900px 420px at -10% 0%, rgba(23,61,52,.06), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: 96px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.eyebrow {
  display: inline-block;
  color: var(--copper-deep);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

/* ============ Barra superior ============ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px;
  padding: 12px clamp(16px, 4vw, 48px);
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(247, 242, 234, .86);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; flex: none; }
.brand img { height: 38px; width: auto; display: block; }
.topbar-title { display: grid; gap: 1px; padding-left: 18px; border-left: 1px solid var(--line-strong); }
.topbar-title span { font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.topbar-title strong { font-family: var(--serif); font-size: 1.28rem; font-weight: 600; line-height: 1.1; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

/* ============ Botones ============ */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 999px;
  font-weight: 650; font-size: .92rem; letter-spacing: .005em;
  transition: background .18s, border-color .18s, color .18s, transform .12s, box-shadow .18s;
  white-space: nowrap;
}
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button:focus-visible, .tab:focus-visible, .stepper-btn:focus-visible, summary:focus-visible, .close-button:focus-visible {
  outline: 3px solid rgba(215, 101, 31, .35); outline-offset: 2px;
}
.button-primary { background: var(--forest); color: #fff; box-shadow: 0 6px 18px rgba(23,61,52,.22); }
.button-primary:hover { background: var(--forest-2); }
.button-outline { background: var(--white); border-color: var(--line-strong); color: var(--ink); }
.button-outline:hover { border-color: var(--forest); color: var(--forest); }
.button-ghost { background: transparent; color: var(--ink-soft); }
.button-ghost:hover { background: rgba(23,61,52,.06); color: var(--forest); }
.button-whatsapp { background: #1f8f55; color: #fff; }
.button-whatsapp:hover { background: #197a48; }
.button-small { min-height: 40px; padding: 0 16px; font-size: .86rem; }
.button-icon { width: 46px; padding: 0; }

/* ============ Espacio de trabajo ============ */
.workspace { width: min(1120px, 100%); margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 40px; }

.editor-hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  margin: 8px 0 22px;
}
.editor-hero h1 {
  margin: 6px 0 6px; font-family: var(--serif); font-weight: 500;
  font-size: clamp(2.1rem, 4.6vw, 3rem); line-height: 1; letter-spacing: -.01em;
}
.editor-hero p { margin: 0; color: var(--muted); max-width: 52ch; }
.doc-status { display: grid; justify-items: end; gap: 6px; text-align: right; }
.folio-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--white); border: 1px solid var(--line-strong);
  font-size: .8rem; font-weight: 700; letter-spacing: .04em; color: var(--forest);
}
.status-line { font-size: .8rem; color: var(--muted); }
.status-line.is-saved { color: var(--forest-2); }
.status-line.is-drive { color: var(--forest); font-weight: 650; }
.status-line a { color: inherit; }

/* ============ Pasos ============ */
#budgetForm { display: grid; gap: 14px; }
.form-step {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 28px);
  box-shadow: var(--shadow-sm);
}
.step-heading { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.step-number {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--sans); font-size: 1rem; font-weight: 700;
  color: var(--forest); background: var(--forest-soft);
  border: 1px solid rgba(23,61,52,.14);
}
.step-kicker { font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.step-heading h2 { margin: 2px 0 2px; font-family: var(--serif); font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.step-heading p { margin: 0; color: var(--muted); font-size: .9rem; }

.step-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.step-fields-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field-wide { grid-column: 1 / -1; }

.field { display: grid; gap: 7px; align-content: start; min-width: 0; }
.field-label { font-size: .82rem; font-weight: 650; color: var(--ink-soft); }
.field-label em { font-style: normal; font-weight: 500; color: var(--muted); margin-left: 4px; font-size: .76rem; }
.field-hint { font-size: .76rem; color: var(--muted); }
.field-hint.is-applied { color: var(--forest-2); font-weight: 600; }

input[type="text"], input[type="number"], input[type="date"], input[type="tel"], input[type="search"], textarea {
  width: 100%; min-height: 48px;
  padding: 11px 14px;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 1rem; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
input[type="date"] { min-width: 0; display: block; }
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #b0a497; }
input:focus, textarea:focus { outline: none; border-color: var(--forest); box-shadow: 0 0 0 3px rgba(23,61,52,.12); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field.is-invalid input, input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(163,52,26,.1); }
.field-error { font-size: .76rem; color: var(--danger); font-weight: 600; }

.input-affix { position: relative; display: flex; align-items: center; min-width: 0; }
.input-affix b {
  position: absolute; left: 14px; font-size: .8rem; font-weight: 700; color: var(--muted); pointer-events: none;
}
.input-affix input { padding-left: 50px; font-variant-numeric: tabular-nums; }
.input-affix-end b { left: auto; right: 14px; }
.input-affix-end input { padding-left: 14px; padding-right: 48px; }

/* ============ Distribución ============ */
.split-bar, .proposal-bar {
  display: flex; height: 10px; border-radius: 999px; overflow: hidden;
  background: var(--bg-deep); margin-bottom: 18px;
}
.seg { display: block; height: 100%; transition: width .35s cubic-bezier(.2,.8,.2,1); }
.seg + .seg { border-left: 2px solid var(--paper); }
.seg-initial { background: var(--forest); }
.seg-construction { background: var(--sage); }
.seg-delivery { background: var(--copper); }

.tranche-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.tranche {
  display: grid; gap: 12px; align-content: start;
  padding: 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--white);
}
.tranche-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .92rem; }
.tranche-head i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.tranche-initial .tranche-head i { background: var(--forest); }
.tranche-construction .tranche-head i { background: var(--sage); }
.tranche-delivery .tranche-head i { background: var(--copper); }
.twin-inputs { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr); gap: 8px; }
.twin-inputs input { font-weight: 650; }
.tranche.is-adjusted { border-color: rgba(215,101,31,.5); box-shadow: 0 0 0 3px rgba(215,101,31,.08); }
.tranche-note { margin: 0; font-size: .8rem; color: var(--muted); }
.mini-fields { display: grid; gap: 12px; }

.stepper { display: grid; grid-template-columns: 46px minmax(0,1fr) 46px; gap: 6px; }
.stepper input { text-align: center; font-weight: 700; }
.stepper-btn {
  border: 1px solid var(--line-strong); background: var(--paper); border-radius: var(--radius-sm);
  font-size: 1.3rem; line-height: 1; color: var(--forest);
}
.stepper-btn:hover { border-color: var(--forest); }

/* Casillas */
.check-card {
  position: relative; display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line-strong); background: var(--paper);
  cursor: pointer; transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.check-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box {
  flex: none; width: 24px; height: 24px; border-radius: 7px;
  border: 2px solid #9d8f80; background: var(--white);
  display: grid; place-items: center; transition: all .15s; margin-top: 1px;
}
.check-box svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; opacity: 0; transform: scale(.6); transition: all .15s; }
.check-copy { display: grid; gap: 2px; }
.check-copy strong { font-size: .92rem; }
.check-copy small { font-size: .78rem; color: var(--muted); }
.check-card:hover { border-color: var(--forest); }
.check-card:has(input:checked) { border-color: var(--forest); background: var(--forest-soft); }
.check-card input:checked + .check-box { background: var(--forest); border-color: var(--forest); }
.check-card input:checked + .check-box svg { opacity: 1; transform: scale(1); }
.check-card input:focus-visible + .check-box { box-shadow: 0 0 0 4px rgba(215,101,31,.35); }
.check-card-inline { margin-top: 14px; }

.adjust-note { margin: 14px 0 0; font-size: .82rem; color: var(--muted); min-height: 1.2em; }
.adjust-note strong { color: var(--copper-deep); }
.adjust-note.is-invalid { color: var(--danger); font-weight: 600; }

.balance-suggestion {
  margin-top: 12px; display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: 12px;
  background: var(--forest-soft); border: 1px solid rgba(23,61,52,.14);
}
.balance-suggestion strong { display: block; font-size: .95rem; color: var(--forest); }
.balance-suggestion p { margin: 2px 0 0; font-size: .84rem; color: var(--ink-soft); }
.balance-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--forest); position: relative; margin-top: 1px; }
.balance-icon::after { content: ""; position: absolute; left: 7px; top: 4px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.balance-suggestion.is-suggestion { background: var(--copper-soft); border-color: rgba(215,101,31,.3); }
.balance-suggestion.is-suggestion strong { color: var(--copper-deep); }
.balance-suggestion.is-suggestion .balance-icon { background: var(--copper); }
.balance-suggestion.is-suggestion .balance-icon::after { content: "!"; border: 0; transform: none; left: 0; right: 0; top: 1px; width: auto; height: auto; color: #fff; font-weight: 800; font-size: .8rem; text-align: center; }
.balance-suggestion.is-over { background: var(--danger-soft); border-color: rgba(163,52,26,.35); }
.balance-suggestion.is-over strong { color: var(--danger); }
.balance-suggestion.is-over .balance-icon { background: var(--danger); }
.balance-suggestion.is-over .balance-icon::after { content: "×"; border: 0; transform: none; left: 0; right: 0; top: -1px; width: auto; height: auto; color: #fff; font-weight: 700; font-size: 1rem; text-align: center; }

/* ============ Ajustes especiales ============ */
.optional-stack { display: grid; gap: 10px; }
.optional-section { border: 1px solid var(--line-strong); border-radius: 12px; background: var(--white); overflow: hidden; }
.optional-section summary {
  list-style: none; display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; cursor: pointer; min-height: 60px;
}
.optional-section summary::-webkit-details-marker { display: none; }
.summary-copy { display: grid; gap: 2px; flex: 1; }
.summary-copy strong { font-size: .98rem; }
.summary-copy small { font-size: .8rem; color: var(--muted); }
.active-badge {
  padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700;
  background: var(--copper-soft); color: var(--copper-deep); border: 1px solid rgba(215,101,31,.3);
}
.chevron { width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; margin: -4px 4px 0; }
.optional-section[open] .chevron { transform: rotate(-135deg); margin-top: 4px; }
.optional-section[open] summary { border-bottom: 1px solid var(--line); }
.optional-body { padding: 16px 18px 18px; display: grid; gap: 12px; }
.optional-body .check-card-inline { margin-top: 0; }

.extras-list { display: grid; gap: 10px; }
.extra-row {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) 46px; gap: 10px; align-items: end;
  padding: 12px; border-radius: 10px; background: var(--copper-soft); border: 1px solid rgba(215,101,31,.2);
}
.remove-extra {
  width: 46px; height: 48px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--white); color: var(--danger);
  display: grid; place-items: center;
}
.remove-extra:hover { border-color: var(--danger); }
.extras-empty { font-size: .86rem; color: var(--muted); padding: 4px 0; }

.custom-installments-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.custom-installments-toolbar strong { font-size: .86rem; color: var(--ink-soft); }
.custom-installments-list { display: grid; gap: 6px; max-height: 420px; overflow: auto; padding-right: 2px; }
.custom-installment-row {
  display: grid; grid-template-columns: minmax(0,1fr) 168px 42px; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper);
}
.custom-installment-row.is-customized { border-color: rgba(215,101,31,.45); background: var(--copper-soft); }
.custom-installment-copy { display: grid; gap: 1px; min-width: 0; }
.custom-installment-copy strong { font-size: .88rem; }
.custom-installment-copy small { font-size: .76rem; color: var(--muted); }
.custom-installment-amount { position: relative; display: flex; align-items: center; }
.custom-installment-amount b { position: absolute; left: 12px; font-size: .74rem; color: var(--muted); }
.custom-installment-amount input { min-height: 42px; padding-left: 44px; font-weight: 650; }
.reset-installment { height: 42px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--white); color: var(--forest); font-size: 1.1rem; }
.reset-installment:disabled { opacity: .3; cursor: default; }

/* ============ Finalizar ============ */
.finish-actions { display: grid; grid-template-columns: auto 1fr 1fr; gap: 10px; margin-top: 18px; }
.finish-note { margin: 12px 0 0; font-size: .8rem; color: var(--muted); }

.validation-message {
  padding: 14px 16px; border-radius: 12px;
  background: var(--danger-soft); border: 1px solid rgba(163,52,26,.3); color: var(--danger);
  font-size: .88rem; font-weight: 600;
}
.validation-message ul { margin: 6px 0 0; padding-left: 18px; font-weight: 500; }

/* ============ Vista previa ============ */
.preview-shell { margin-top: 40px; }
.preview-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.preview-hint { font-size: .8rem; color: var(--muted); }
.paper-frame { border-radius: 6px; box-shadow: var(--shadow); background: var(--white); overflow: hidden; }

.proposal {
  --p-pad: clamp(20px, 5vw, 56px);
  background: var(--white);
  padding: var(--p-pad);
  color: var(--ink);
  font-size: 14px;
  position: relative;
}
.proposal::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 5px;
  background: linear-gradient(90deg, var(--forest) 0 62%, var(--champagne) 62% 82%, var(--copper) 82%);
}
.proposal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 18px; border-bottom: 1px solid var(--line);
}
.proposal-header img { height: 46px; width: auto; }
.proposal-meta { display: grid; justify-items: end; gap: 2px; text-align: right; font-size: .78rem; color: var(--muted); }
.proposal-meta strong { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--forest); }

.proposal-title { padding: 30px 0 22px; }
.client-line { margin: 6px 0 0; font-family: var(--serif); font-size: 1.35rem; font-style: italic; font-weight: 500; color: var(--ink-soft); }
.proposal-title h2 {
  margin: 4px 0 0; font-family: var(--serif); font-weight: 500;
  font-size: clamp(2.2rem, 6vw, 3.3rem); line-height: 1; letter-spacing: -.01em; color: var(--forest);
}
.unit-facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 18px; }
.unit-fact { display: grid; gap: 1px; }
.unit-fact span { font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.unit-fact strong { font-size: 1rem; font-weight: 650; }

.proposal-total {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  padding: 20px 22px; border-radius: 10px;
  background: var(--forest); color: #fff; margin-bottom: 16px;
}
.proposal-total span { display: block; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.7); font-weight: 600; }
.proposal-total strong { display: block; font-family: var(--serif); font-size: clamp(1.9rem, 5vw, 2.5rem); font-weight: 600; line-height: 1.05; margin-top: 4px; font-variant-numeric: lining-nums; }
.proposal-total-dates { text-align: right; }
.proposal-total-dates strong { font-family: var(--sans); font-size: 1rem; font-weight: 650; }
.proposal-bar { height: 8px; margin-bottom: 14px; }
.proposal-bar .seg + .seg { border-left-color: var(--white); }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.summary-item { display: grid; gap: 3px; align-content: start; padding: 16px 16px 16px 0; min-width: 0; }
.summary-item + .summary-item { padding-left: 18px; border-left: 1px solid var(--line); }
.summary-kicker { display: flex; align-items: center; gap: 7px; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.summary-kicker b { color: var(--ink); }
.summary-kicker i { width: 8px; height: 8px; border-radius: 2px; display: block; flex: none; }
.summary-initial i { background: var(--forest); }
.summary-construction i { background: var(--sage); }
.summary-delivery i { background: var(--copper); }
.summary-item strong { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; line-height: 1.15; font-variant-numeric: lining-nums; }
.summary-item small { font-size: .78rem; color: var(--ink-soft); line-height: 1.35; }

.payment-plan { margin-top: 26px; }
.plan-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 10px; }
.plan-heading h3 { margin: 0; font-family: var(--serif); font-size: 1.55rem; font-weight: 600; }
.plan-total { text-align: right; }
.plan-total span { display: block; font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.plan-total strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.plan-total strong.is-ok { color: var(--forest); }
.plan-total strong.is-off { color: var(--danger); }

.schedule { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.schedule th {
  text-align: left; font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  font-weight: 700; padding: 8px 10px; border-bottom: 1.5px solid var(--ink);
}
.schedule td { padding: 9px 10px; border-bottom: 1px solid #efe8de; vertical-align: middle; font-size: .86rem; }
.schedule .col-n { width: 2.6rem; }
.schedule .col-amount, .schedule .col-acc, .schedule td.amount, .schedule td.acc { text-align: right; white-space: nowrap; }
.schedule .col-date, .schedule td.date { white-space: nowrap; }
.schedule td.num { color: var(--muted); font-size: .78rem; }
.schedule td.acc { color: var(--muted); font-size: .78rem; }
.schedule td.amount { font-weight: 650; }
.concept { display: flex; align-items: center; gap: 9px; }
.concept i { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--sage); }
.concept strong { font-weight: 600; }
.concept small { display: block; font-size: .72rem; color: var(--muted); }
.row-separation .concept i, .row-initial .concept i { background: var(--forest); }
.row-extra .concept i, .row-suggested .concept i { background: var(--copper); }
.row-delivery .concept i { background: var(--copper); width: 9px; height: 9px; border-radius: 2px; }
.row-separation td, .row-initial td { background: #f4f8f6; }
.row-extra td, .row-suggested td { background: #fdf4ee; }
.row-delivery td { background: #fbf1e8; border-bottom: 1.5px solid var(--ink); font-weight: 650; }
.row-custom .concept small { color: var(--copper-deep); font-weight: 600; }
.schedule-empty td { text-align: center; color: var(--muted); padding: 26px; }

.proposal-footer {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: end;
  margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line);
}
.proposal-notes strong { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--forest); }
.proposal-notes p { margin: 6px 0 0; font-size: .8rem; color: var(--ink-soft); white-space: pre-line; }
.proposal-notes .validity { font-weight: 650; color: var(--ink); }
.proposal-advisor { display: grid; justify-items: end; text-align: right; gap: 1px; }
.proposal-advisor span { font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.proposal-advisor strong { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.proposal-advisor small { font-size: .74rem; color: var(--muted); }

/* ============ Barra fija ============ */
.dock {
  position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 40; width: min(760px, calc(100% - 24px));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 8px 8px 16px; border-radius: 999px;
  background: rgba(255, 253, 249, .94); border: 1px solid var(--line-strong);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(43,31,20,.16);
}
.dock-status { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dock-status small { display: block; font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.dock-status strong { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dock-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--forest); box-shadow: 0 0 0 4px rgba(23,61,52,.12); flex: none; }
.dock-dot.is-off { background: var(--danger); box-shadow: 0 0 0 4px rgba(163,52,26,.14); }
.dock-pct { padding: 4px 10px; border-radius: 999px; background: var(--forest-soft); color: var(--forest); font-weight: 700; font-size: .8rem; }
.dock-pct.is-off { background: var(--danger-soft); color: var(--danger); }
.dock-actions { display: flex; gap: 6px; }
.dock .button { min-height: 44px; }
.dock #dockPdf { padding: 0 22px; }

/* ============ Biblioteca ============ */
.library {
  width: min(720px, calc(100% - 24px)); max-height: min(86vh, 820px);
  padding: 0; border: 1px solid var(--line-strong); border-radius: 18px;
  background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px rgba(27,23,20,.3);
}
.library::backdrop { background: rgba(27,23,20,.35); backdrop-filter: blur(3px); }
.library[open] { display: flex; flex-direction: column; }
.library-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 22px 8px; }
.library-head h2 { margin: 4px 0 0; font-family: var(--serif); font-size: 1.9rem; font-weight: 600; line-height: 1; }
.close-button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--white); font-size: 1.4rem; line-height: 1; color: var(--ink-soft); }
.library-tabs { display: flex; gap: 4px; padding: 8px 22px 0; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 10px 12px; font-weight: 650; font-size: .88rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.is-active { color: var(--forest); border-bottom-color: var(--forest); }
.library-panel { padding: 16px 22px 22px; overflow: auto; display: grid; gap: 12px; align-content: start; }
.library-help { margin: 0; font-size: .84rem; color: var(--muted); }
.library-list { display: grid; gap: 8px; }
.library-item {
  display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 12px; align-items: center;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--white);
}
.library-item.is-current { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(23,61,52,.08); }
.library-item-copy { min-width: 0; }
.library-item-copy strong { display: block; font-size: .96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-item-copy small { display: block; font-size: .78rem; color: var(--muted); }
.library-item-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.library-item .versions { grid-column: 1 / -1; display: grid; gap: 4px; padding-top: 6px; border-top: 1px dashed var(--line); }
.version-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .8rem; color: var(--ink-soft); }
.version-row a { color: var(--forest); font-weight: 650; }
.library-empty { text-align: center; padding: 28px 10px; color: var(--muted); font-size: .9rem; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--forest-soft); color: var(--forest); font-size: .7rem; font-weight: 700; margin-left: 6px; vertical-align: 1px; }
.pill-copper { background: var(--copper-soft); color: var(--copper-deep); }

/* ============ Mensajes ============ */
.toast {
  position: fixed; left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 74px); transform: translateX(-50%);
  z-index: 60; max-width: min(560px, calc(100% - 32px));
  padding: 12px 18px; border-radius: 12px;
  background: var(--forest); color: #fff; font-size: .88rem; font-weight: 600;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
}
.toast.is-error { background: var(--danger); }
.toast a { color: #fff; }
.busy { position: fixed; inset: 0; z-index: 70; background: rgba(247,242,234,.72); backdrop-filter: blur(3px); display: grid; place-items: center; }
.busy-card { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-radius: 14px; background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--forest-soft); border-top-color: var(--forest); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .step-fields-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tranche-grid { grid-template-columns: 1fr; }
  .finish-actions { grid-template-columns: 1fr 1fr; }
  .finish-actions #saveBudgetButton { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar { gap: 10px; }
  .brand img { height: 30px; }
  .topbar-title { display: none; }
  .topbar-actions .button span { display: none; }
  .topbar-actions .button { width: 44px; padding: 0; }
  .workspace { padding-top: 18px; }
  .editor-hero { flex-direction: column; align-items: flex-start; }
  .doc-status { justify-items: start; text-align: left; grid-auto-flow: column; align-items: center; }
  .step-heading { gap: 12px; }
  .step-number { width: 32px; height: 32px; font-size: .9rem; }
  .step-heading h2 { font-size: 1.4rem; }
  .step-fields, .step-fields-4 { grid-template-columns: 1fr 1fr; gap: 14px 12px; }
  .step-fields > .field:not(.field-wide):not(.field-wide-sm) { grid-column: auto; }
  .field-wide-sm { grid-column: 1 / -1; }
  .step-fields > label:has(#clientName), .step-fields > label:has(#clientPhone) { grid-column: 1 / -1; }
  .finish-actions { grid-template-columns: 1fr; }
  .custom-installment-row { grid-template-columns: minmax(0,1fr) 130px 40px; }
  .extra-row { grid-template-columns: 1fr 1fr 46px; }

  .proposal { font-size: 13px; }
  .proposal-header img { height: 34px; }
  .proposal-total { flex-direction: column; align-items: flex-start; }
  .proposal-total-dates { text-align: left; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-item, .summary-item + .summary-item { padding: 12px 0; border-left: 0; }
  .summary-item + .summary-item { border-top: 1px solid var(--line); }
  .schedule .col-acc, .schedule td.acc { display: none; }
  .proposal { --p-pad: 18px; }
  .schedule th, .schedule td { padding: 8px 4px; }
  .schedule td { font-size: .8rem; }
  .schedule .col-n { width: 1.5rem; }
  .schedule td.num { font-size: .7rem; }
  .concept { gap: 6px; }
  .concept small { display: none; }
  .proposal-footer { grid-template-columns: 1fr; }
  .proposal-advisor { justify-items: start; text-align: left; }
  .dock { padding-left: 14px; }
  .dock-status small { display: none; }
  .dock-status strong { font-size: .92rem; }
}
@media (max-width: 380px) {
  .dock-pct { display: none; }
}

/* ============ Impresión / PDF (tamaño Carta) ============ */
@page { size: letter; margin: 14mm 14mm 16mm; }
@media print {
  html, body { background: #fff !important; padding: 0 !important; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .editor, .dock, .preview-label, .toast, .busy, .library { display: none !important; }
  .workspace { padding: 0 !important; width: auto !important; }
  .preview-shell { margin: 0 !important; }
  .paper-frame { box-shadow: none !important; border-radius: 0 !important; overflow: visible !important; }
  .proposal { padding: 0 !important; font-size: 10.5pt; }
  .proposal::before { top: -4mm; height: 3px; }
  .proposal-header img { height: 40px; }
  .proposal-title { padding: 16px 0 12px; }
  .proposal-header { padding-bottom: 12px; }
  .unit-facts { margin-top: 10px; }
  .payment-plan { margin-top: 16px; }
  .plan-heading h3 { font-size: 17pt; }
  .proposal-footer { margin-top: 16px; padding-top: 12px; }
  .proposal-title h2 { font-size: 30pt; }
  .proposal-total { padding: 14px 18px; flex-direction: row; align-items: flex-end; }
  .proposal-total-dates { text-align: right; }
  .proposal-total > div:first-child strong { font-size: 24pt; }
  .proposal-total-dates strong { font-size: 11pt; }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .summary-item { padding: 12px 12px 12px 0; }
  .summary-item + .summary-item { padding-left: 14px; border-left: 1px solid var(--line); border-top: 0; }
  .summary-item strong { font-size: 17pt; }
  .schedule .col-acc, .schedule td.acc { display: table-cell !important; }
  .concept small { display: block !important; }
  .schedule thead { display: table-header-group; }
  .schedule tr { break-inside: avoid; page-break-inside: avoid; }
  .schedule td { padding: 3.2px 8px; font-size: 8.8pt; line-height: 1.3; }
  .schedule th { padding: 5px 8px; }
  .concept small { font-size: 7.5pt; }
  .schedule td.num, .schedule td.acc { font-size: 8pt; }
  .proposal-header, .proposal-title, .proposal-total, .summary-grid, .proposal-footer { break-inside: avoid; }
  .plan-heading { break-after: avoid; }
}
