:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  --text: #121212;
  --muted: #6d6d68;
  --line: #e4e4df;
  --accent: #111111;
  --radius: 20px;
  --shadow: 0 18px 50px rgba(0,0,0,.07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 44px);
  background: rgba(244,244,242,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(0,0,0,.05);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: #111;
  font-weight: 900;
}
.brand h1 { margin: 0; font-size: 1rem; letter-spacing: .08em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: .78rem; }

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 28px auto 56px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .75fr);
  gap: 22px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.form-panel { padding: clamp(20px, 4vw, 34px); }
.quote-panel { padding: 24px; }
.quote-sticky { position: sticky; top: 98px; }

h2, h3, h4, p { margin-top: 0; }
h2 { margin-bottom: 24px; font-size: clamp(1.7rem, 4vw, 2.4rem); }
h3 { margin: 3px 0 0; font-size: 1.08rem; }
h4 { margin-bottom: 14px; }
.eyebrow {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  font-weight: 800;
}
.section-head, .section-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}
.section-title-row { margin-bottom: 16px; }
.divider { height: 1px; background: var(--line); margin: 28px 0; }

.grid { display: grid; gap: 15px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: .83rem; font-weight: 700; }
.field small { font-weight: 500; color: var(--muted); }
input, select {
  width: 100%;
  border: 1px solid #d8d8d2;
  background: white;
  border-radius: 12px;
  padding: 12px 13px;
  outline: none;
  transition: .2s ease;
}
input:focus, select:focus { border-color: #111; box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 42px; }
.input-suffix span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-weight: 900; }

.link-button, .icon-button {
  border: 0;
  background: transparent;
  color: var(--text);
}
.link-button { text-decoration: underline; text-underline-offset: 3px; font-size: .82rem; }
.icon-button { font-size: 1.8rem; line-height: 1; }

.btn {
  border-radius: 12px;
  padding: 11px 14px;
  border: 1px solid transparent;
  font-weight: 800;
  transition: .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: #111; color: white; }
.btn-secondary { background: white; border-color: #d9d9d4; color: #111; }
.btn-ghost { background: transparent; border-color: #d4d4cf; }

.advanced-card {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
}
.advanced-card summary { cursor: pointer; font-weight: 800; }
.details-grid { margin-top: 16px; }

.quote-meta {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: .82rem;
  margin-bottom: 18px;
  min-height: 18px;
}
.breakdown { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 0; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; }
.row span { color: var(--muted); }
.total-base { margin-top: 4px; padding-top: 12px; border-top: 1px dashed #d9d9d4; }
.total-base span, .total-base strong { color: var(--text); font-weight: 900; }
.multiplier-chip {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 17px 0;
  padding: 8px 10px;
  background: #eeeeea;
  border-radius: 999px;
  font-size: .8rem;
}
.price-card {
  background: #111;
  color: white;
  border-radius: 18px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.price-card span { opacity: .7; font-size: .83rem; }
.price-card strong { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1.05; letter-spacing: -.04em; }
.price-card small { opacity: .6; }
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.metrics div { background: var(--surface-2); border-radius: 12px; padding: 11px; }
.metrics span { display: block; color: var(--muted); font-size: .7rem; margin-bottom: 5px; }
.metrics strong { font-size: .86rem; }
.quote-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }
.quote-actions .btn-primary { grid-column: 1 / -1; }
.save-note { color: var(--muted); font-size: .72rem; text-align: center; margin: 14px 0 0; }

.modal {
  width: min(720px, calc(100% - 24px));
  border: 0;
  padding: 0;
  background: transparent;
}
.modal::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(3px); }
.modal-card { background: white; border-radius: 20px; padding: 24px; max-height: 86vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.saved-list { display: grid; gap: 9px; }
.saved-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.saved-item strong { display: block; font-size: .88rem; }
.saved-item small { color: var(--muted); }
.delete-button { border: 0; background: #fff; border: 1px solid #ddd; border-radius: 9px; padding: 7px 9px; }
.empty { color: var(--muted); font-size: .86rem; padding: 10px 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: #111;
  color: white;
  padding: 11px 15px;
  border-radius: 999px;
  transition: .2s ease;
  z-index: 50;
  font-weight: 700;
  font-size: .85rem;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; width: min(760px, calc(100% - 20px)); margin-top: 14px; }
  .quote-panel { order: -1; }
  .quote-sticky { position: static; }
}

@media (max-width: 560px) {
  .topbar { padding: 12px 14px; }
  .topbar .btn { padding: 9px 10px; font-size: .76rem; }
  .brand p { display: none; }
  .app-shell { width: calc(100% - 14px); }
  .form-panel, .quote-panel { border-radius: 16px; padding: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .section-title-row { align-items: start; flex-direction: column; gap: 8px; }
  .metrics { grid-template-columns: 1fr; }
  .quote-actions { grid-template-columns: 1fr; }
  .quote-actions .btn-primary { grid-column: auto; }
}



/* V2 — cotizaciones e historial */
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.grid-3 { grid-template-columns: 1.2fr 1.2fr .6fr; }
.field-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.45;
}
.quote-title-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}
.quote-number-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .03em;
}
.quote-number-badge.saved { background: #111; color: #fff; border-color: #111; }
.history-modal { width: min(820px, calc(100% - 24px)); }
.history-search { margin-bottom: 16px; }
.history-list { max-height: 55vh; overflow: auto; padding-right: 3px; }
.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.history-main { min-width: 0; }
.history-topline { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.history-topline strong { font-size: .88rem; }
.history-topline span { color: var(--muted); font-size: .74rem; white-space: nowrap; }
.history-client { margin-top: 5px; font-weight: 850; }
.history-main small { display: block; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-price { margin-top: 8px; font-weight: 900; }
.history-actions { display: flex; flex-direction: column; gap: 7px; }
.btn-small { padding: 7px 10px; font-size: .78rem; }
.print-only { display: none; }
.client-document {
  width: min(820px, 100%);
  margin: 0 auto;
  color: #111;
  background: white;
}
.client-doc-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding-bottom: 24px;
  border-bottom: 2px solid #111;
}
.client-doc-brand { display: flex; gap: 12px; align-items: center; }
.client-doc-brand strong { display: block; font-size: 1.1rem; letter-spacing: .08em; }
.client-doc-brand span { display: block; color: #666; font-size: .82rem; margin-top: 3px; }
.client-doc-number { font-size: .9rem; font-weight: 900; }
.client-doc-meta, .client-doc-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 22px 0;
  border-bottom: 1px solid #ddd;
}
.client-doc-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.client-doc-meta span, .client-doc-details span {
  display: block;
  color: #777;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}
.client-doc-meta strong, .client-doc-details strong { font-size: 1rem; }
.client-doc-total { margin-top: 26px; padding: 22px; border: 2px solid #111; border-radius: 14px; }
.client-doc-total span { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 7px; }
.client-doc-total strong { display: block; font-size: 2.3rem; line-height: 1.05; }
.client-doc-note { margin: 24px 0 0; color: #777; font-size: .76rem; }

@media (max-width: 700px) {
  .grid-3 { grid-template-columns: 1fr; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { padding: 9px 9px; font-size: .72rem; }
  .history-item { grid-template-columns: 1fr; }
  .history-actions { flex-direction: row; }
}
@media print {
  @page { size: A4; margin: 16mm; }
  body { background: white; color: #111; }
  body > *:not(#clientPrint) { display: none !important; }
  #clientPrint { display: block !important; width: 100%; margin: 0; }
  .client-doc-header { padding-top: 0; }
  .client-doc-total { break-inside: avoid; }
}
