:root {
  --bg: #eef4f8;
  --card: #ffffff;
  --text: #172033;
  --muted: #65738a;
  --line: #d9e2ec;
  --brand: #155eef;
  --brand-dark: #0d3fa7;
  --green: #0f9f6e;
  --danger: #dc2626;
  --shadow: 0 18px 48px rgba(23, 32, 51, 0.12);
  --radius: 20px;
}

* { 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: radial-gradient(circle at top left, #dbeafe 0, transparent 34rem), var(--bg);
  color: var(--text);
  line-height: 1.5;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.site-header {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 18px 18px;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 18px;
  align-items: end;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 5vw, 4.2rem); letter-spacing: -0.06em; line-height: 0.94; }
h2 { margin-bottom: 0; font-size: 1.12rem; }
.subtitle { max-width: 720px; color: var(--muted); margin-bottom: 0; }
.eyebrow { margin-bottom: 6px; color: var(--brand); font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; }
.required { color: var(--danger); }
.hint { color: var(--muted); font-size: 0.9rem; margin: 10px 0 0; }

.header-card {
  background: linear-gradient(135deg, var(--brand), #1e293b);
  color: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.header-card span, .header-card small { display: block; opacity: 0.82; }
.header-card strong { display: block; font-size: 2rem; margin: 8px 0; }

.app-shell {
  max-width: 1180px;
  margin: 0 auto 42px;
  padding: 0 18px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(217, 226, 236, 0.78);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(23, 32, 51, 0.07);
  padding: 18px;
}
.form-panel, .saved-panel { grid-column: 1; }
.totals-panel { grid-column: 2; grid-row: 1 / span 3; position: sticky; top: 16px; }

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

form, .settings-grid { display: grid; gap: 14px; }
.grid { display: grid; gap: 14px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }

label { display: grid; gap: 7px; color: #334155; font-weight: 750; font-size: 0.9rem; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  color: var(--text);
  background: #fbfdff;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
textarea { resize: vertical; }
input:focus, textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(21, 94, 239, 0.12);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 15px;
  font-weight: 850;
  transition: transform .16s, box-shadow .16s, background .16s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(23, 32, 51, .12); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #172033; color: white; }
.btn-whatsapp { background: #16a34a; color: white; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-ghost { background: #eef4ff; color: var(--brand); }
.icon-btn {
  border: 0;
  width: 42px;
  min-height: 42px;
  border-radius: 50%;
  align-self: end;
  background: #fee2e2;
  color: #991b1b;
  font-size: 1.55rem;
  line-height: 1;
}

.item-table { display: grid; gap: 12px; }
.item-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.4fr) 82px 130px 110px 120px 44px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fbff;
}
.item-row label { font-size: 0.82rem; }
.line-total {
  display: grid;
  gap: 4px;
  min-height: 48px;
  align-content: center;
  padding: 8px 10px;
  background: white;
  border-radius: 14px;
  border: 1px dashed var(--line);
}
.line-total span { font-size: .72rem; color: var(--muted); font-weight: 800; }
.line-total strong { font-size: .98rem; }

.quote-badge {
  display: inline-flex;
  align-items: center;
  padding: 9px 11px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-weight: 850;
  font-size: 0.82rem;
}
.totals-list { margin: 18px 0; display: grid; gap: 8px; }
.totals-list div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #edf2f7; }
.totals-list dt { color: var(--muted); font-weight: 700; }
.totals-list dd { margin: 0; font-weight: 850; text-align: right; }
.grand-total { border: 0 !important; background: #eff6ff; padding: 16px !important; border-radius: 16px; align-items: center; }
.grand-total dt { color: var(--text); }
.grand-total dd { color: var(--brand); font-size: 1.55rem; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.status { min-height: 24px; color: var(--muted); font-weight: 750; margin: 14px 0 0; }
.status.success { color: #047857; }
.status.error { color: var(--danger); }

.saved-list { display: grid; gap: 10px; }
.saved-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: #fbfdff;
}
.saved-card h3 { margin: 0 0 4px; font-size: 1rem; }
.saved-card p { margin: 0; color: var(--muted); font-size: .9rem; }
.saved-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.saved-actions .btn { padding: 9px 11px; font-size: .85rem; }
.empty-state { color: var(--muted); margin-bottom: 0; }

.print-layout { display: none; }

@media (max-width: 980px) {
  .site-header, .app-shell { grid-template-columns: 1fr; }
  .totals-panel, .form-panel, .saved-panel { grid-column: auto; grid-row: auto; position: static; }
  .item-row { grid-template-columns: 1fr 92px 1fr; }
  .item-name, .line-total { grid-column: span 2; }
}

@media (max-width: 640px) {
  .site-header { padding-top: 22px; }
  .panel { padding: 15px; border-radius: 18px; }
  .two-col, .item-row, .action-grid, .saved-card { grid-template-columns: 1fr; }
  .item-name, .line-total { grid-column: auto; }
  .icon-btn { width: 100%; border-radius: 12px; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .panel-heading .btn { width: 100%; }
  .saved-actions { justify-content: stretch; }
  .saved-actions .btn { flex: 1; }
}

@media print {
  body { background: white; color: #111827; }
  .site-header, .app-shell { display: none !important; }
  .print-layout { display: block; max-width: 800px; margin: 0 auto; padding: 24px; }
  .print-header { display: flex; justify-content: space-between; gap: 28px; border-bottom: 3px solid #111827; padding-bottom: 18px; margin-bottom: 24px; }
  .print-header h1 { font-size: 2.2rem; letter-spacing: -0.03em; margin: 0 0 8px; }
  .print-meta { text-align: right; }
  .print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 20px; }
  .print-box { border: 1px solid #cbd5e1; border-radius: 10px; padding: 12px; }
  .print-box h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; color: #475569; margin: 0 0 8px; }
  .print-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
  .print-table th, .print-table td { border: 1px solid #cbd5e1; padding: 9px; text-align: left; }
  .print-table th { background: #f1f5f9; }
  .print-table td:nth-child(n+2), .print-table th:nth-child(n+2) { text-align: right; }
  .print-total-box { margin-left: auto; width: min(360px, 100%); display: grid; gap: 8px; }
  .print-total-box div { display: flex; justify-content: space-between; border-bottom: 1px solid #e2e8f0; padding-bottom: 6px; }
  .print-total-box .print-grand { font-size: 1.3rem; font-weight: 900; border: 2px solid #111827; padding: 12px; }
  .print-notes { margin-top: 26px; white-space: pre-line; }
}
