/* Cotizador HACERK — mismos colores y tipografía que el sitio */
:root {
  --ink: #0e0d0c;
  --ink-2: #2a2724;
  --paper: #efeae2;
  --bg: #f4f1ec;
  --card-bg: #ffffff;
  --accent: #e8522a;
  --accent-dark: #c43f1b;
  --muted: #6b655e;
  --border: #ddd6cc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Archivo', Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  background: var(--ink);
  color: var(--paper);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand svg { width: 22px; height: 22px; flex: none; }
.brand b { font-stretch: 125%; font-weight: 800; font-size: 15px; letter-spacing: .08em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar .who { font-size: 13px; color: rgba(239,234,226,.7); }
.topbar .who::before { content: "●"; color: var(--accent); margin-right: 6px; font-size: 9px; vertical-align: 2px; }
.topbar .who:empty { display: none; }
@media (max-width: 560px) { .topbar { padding: 12px 14px; } .brand span, .topbar .who { display: none; } }
.brand span { font-size: 13px; color: rgba(239,234,226,.62); border-left: 1px solid rgba(239,234,226,.25); padding-left: 10px; }

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 540px) 1fr;
  gap: 20px;
  padding: 20px;
  align-items: start;
}

.panel { background: transparent; }

.form-panel {
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  padding-right: 6px;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .form-panel { max-height: none; overflow: visible; padding-right: 0; }
  .preview-panel { position: static; }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 13px;
  font-stretch: 112%;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink);
  margin: 0 0 12px;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 6px;
}

label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 10px;
}
label input, label select, label textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
}
label textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 12px; }
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
}

.hint { font-size: 11.5px; color: var(--muted); margin: 4px 0 0; line-height: 1.45; }

.btn {
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--ink);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #ebe6de; }
.btn-secondary:hover { background: #dfd8cd; }
.btn-ghost { background: transparent; color: var(--paper); border: 1px solid var(--accent); }
.btn-ghost:hover { background: var(--accent); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.submit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding: 4px 2px 30px;
}
.submit-row.left { justify-content: flex-start; padding-bottom: 6px; }
.file-btn { display: inline-flex; align-items: center; margin: 0; color: var(--ink); font-size: 13.5px; }
.file-btn input { display: none; }

/* Totales en vivo */
.totals-box { margin: 14px 0 0; border-top: 1px solid var(--border); padding-top: 10px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.totals-box dt { color: var(--muted); }
.totals-box dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals-box .grand { font-weight: 700; color: var(--ink); font-size: 15px; padding-top: 6px; border-top: 1px solid var(--border); }

/* Ítems */
#itemsTable { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.item-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 9px 7px;
  background: #fbfaf8;
}
.item-row1, .item-row2 { display: grid; gap: 6px; margin-bottom: 6px; }
.item-row1 { grid-template-columns: 1fr 2.2fr 0.6fr 0.6fr; }
.item-row2 { grid-template-columns: 2fr 1fr 1fr auto; align-items: center; }
@media (max-width: 560px) {
  .item-row1 { grid-template-columns: 1fr 1fr; }
  .item-row1 > div:nth-child(2) { grid-column: 1 / -1; order: 3; }
  .item-row2 { grid-template-columns: 1fr 1fr auto; }
  .item-row2 > div:first-child { grid-column: 1 / -1; }
}
.item-card input { padding: 7px 8px; font-size: 13px; font-family: inherit; border: 1px solid var(--border); border-radius: 5px; width: 100%; }
.item-card .field-label { display: block; font-size: 9.5px; color: var(--muted); text-transform: uppercase; margin-bottom: 2px; }
.item-card .item-total { display: block; font-size: 13px; text-align: right; padding-right: 4px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.item-card .btn-remove {
  background: #f6e3dc; color: var(--accent-dark); border: none; border-radius: 5px;
  width: 28px; height: 28px; cursor: pointer; font-size: 14px; line-height: 1;
}

/* Vista previa */
.preview-panel { position: sticky; top: 76px; }
.preview-host {
  background: #3a3632;
  border-radius: 8px;
  min-height: calc(100vh - 116px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  overflow: auto;
}
@media (max-width: 980px) { .preview-host { min-height: 180px; align-items: center; } }
.preview-placeholder { color: var(--paper); font-size: 13px; margin: auto; text-align: center; line-height: 1.5; }
.preview-placeholder .btn { margin-top: 10px; }
#pdfPreviewHost iframe {
  width: 100%;
  height: calc(100vh - 148px);
  border: none;
  background: #fff;
}

/* Modales */
.modal {
  position: fixed; inset: 0;
  background: rgba(14,13,12,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 12px;
}
.modal.hidden { display: none; }
button.hidden { display: none; }
.modal-content {
  background: #fff;
  border-radius: 8px;
  padding: 22px 24px;
  width: min(480px, 100%);
  max-height: 92vh;
  overflow-y: auto;
}
.modal-content h2 { margin-top: 0; font-size: 17px; font-stretch: 112%; }
.modal-content h3 { font-size: 14px; margin: 0 0 10px; }
.img-preview { margin: -4px 0 12px; }
.img-preview img { max-width: 160px; max-height: 70px; border: 1px solid var(--border); border-radius: 4px; padding: 4px; background: #fafafa; }
.logo-row { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

/* Firmantes */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.signers-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; max-height: 220px; overflow-y: auto; }
.signer-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px;
}
.signer-item .sig-thumb { width: 44px; height: 26px; object-fit: contain; border: 1px solid var(--border); border-radius: 3px; background: #fafafa; flex: none; }
.signer-item .signer-info { flex: 1; min-width: 0; }
.signer-item .signer-name { font-size: 13px; font-weight: 600; }
.signer-item .signer-meta { font-size: 11px; color: var(--muted); }
.signer-item .signer-actions { display: flex; gap: 4px; }
.signer-item button { font-size: 11px; padding: 5px 8px; border-radius: 4px; border: none; cursor: pointer; font-family: inherit; }
.signer-item .btn-edit { background: #ebe6de; }
.signer-item .btn-delete { background: #f6e3dc; color: var(--accent-dark); }
.signers-empty { font-size: 12.5px; color: var(--muted); padding: 6px 2px; }
