/* ============================================================
   LAYOUT COMÚN DE HERRAMIENTAS
============================================================ */

body { font-family: var(--sans); }

.topbar {
  background: var(--tinta);
  color: var(--papel-2);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .back {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #B8C7D8;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background 0.12s, color 0.12s;
}
.topbar .back:hover { background: rgba(255,255,255,0.08); color: var(--papel-2); }
.topbar-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  flex: 1;
}
.topbar-title .folio-num { color: var(--terracota); margin-right: 6px; }
.topbar-indicadores {
  font-family: var(--mono);
  font-size: 11px;
  color: #9DB4CC;
  letter-spacing: 0.02em;
}
@media (max-width: 600px) {
  .topbar-indicadores { display: none; }
}

.layout {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 49px);
}

.panel-form {
  flex: 1 1 480px;
  max-width: 560px;
  min-width: 420px;
}
.panel-preview {
  flex: 1 1 600px;
  min-width: 0;
}

.panel-form {
  background: var(--papel);
  padding: 32px 40px 80px;
  border-right: 1px solid var(--linea);
  overflow-y: auto;
}
.form-header h1 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--tinta);
  margin: 0 0 6px;
}
.form-header p {
  font-size: 13.5px;
  color: var(--texto-suave);
  margin: 0 0 6px;
  max-width: 440px;
}

.grid-2 { display: flex; gap: 16px; }
.grid-2 > .field { flex: 1 1 0; min-width: 0; }
.grid-3 { display: flex; gap: 16px; }
.grid-3 > .field { flex: 1 1 0; min-width: 0; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 26px;
  flex-wrap: wrap;
}
.aviso-legal {
  font-size: 11.5px;
  color: var(--texto-suave);
  margin-top: 14px;
  line-height: 1.5;
}

.panel-preview {
  background: var(--papel-2);
  padding: 32px 40px 80px;
  overflow-y: auto;
}
.preview-sticky { position: sticky; top: 16px; }
.preview-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}
.preview-header h2 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--tinta);
  margin: 0;
}
.preview-header .hint {
  font-size: 11.5px;
  color: var(--texto-suave);
}

.aviso-imm {
  background: var(--rojo-suave);
  color: var(--rojo);
  font-size: 12.5px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.tarjetas {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}
.tarjetas > .tarjeta { flex: 1 1 0; min-width: 0; }
@media (max-width: 1100px) {
  .tarjetas { flex-direction: column; }
}
.tarjeta {
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tarjeta-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tarjeta-valor {
  font-size: 19px;
  font-weight: 600;
  color: #0f172a;
}
.tarjeta-azul { background: #E3ECF4; }
.tarjeta-azul .tarjeta-label { color: var(--tinta); }
.tarjeta-roja { background: var(--rojo-suave); }
.tarjeta-roja .tarjeta-label { color: var(--rojo); }
.tarjeta-verde { background: var(--verde-suave); }
.tarjeta-verde .tarjeta-label { color: var(--verde); }

.tabla-detalle {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-bottom: 24px;
}
.tabla-detalle tr { border-bottom: 1px solid var(--linea); }
.tabla-detalle td { padding: 7px 2px; }
.tabla-detalle td.label { color: var(--texto-suave); }
.tabla-detalle td.valor { text-align: right; font-family: var(--mono); }
.tabla-detalle td.valor.negativo { color: var(--rojo); }
.tabla-detalle tr.total td { font-weight: 700; color: var(--tinta); border-top: 2px solid var(--tinta); border-bottom: none; }

.folio-watermark {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--linea);
  text-align: right;
  letter-spacing: 0.08em;
  margin-top: 30px;
}

@media (max-width: 980px) {
  .layout { flex-direction: column; }
  .panel-form { flex: 1 1 auto; max-width: none; min-width: 0; border-right: none; border-bottom: 1px solid var(--linea); }
  .panel-preview { flex: 1 1 auto; }
  .preview-sticky { position: static; }
  .grid-2, .grid-3 { flex-direction: column; }
}

/* ============================================================
   Tablas de tipo "hoja de cálculo" (usadas en Previred y LRE)
============================================================ */
.hoja {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--blanco);
}
.hoja thead th {
  background: var(--tinta);
  color: var(--papel-2);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding: 9px 8px;
  text-align: left;
  position: sticky;
  top: 0;
}
.hoja tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--linea);
}
.hoja tbody tr:nth-child(even) { background: var(--papel-2); }
.hoja input, .hoja select {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--sans);
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 2px;
}
.hoja input.mono, .hoja td.mono { font-family: var(--mono); }
.hoja input:focus, .hoja select:focus { border-color: var(--tinta); background: var(--blanco); }
.hoja .col-accion { text-align: center; width: 38px; }
.hoja .btn-fila-borrar {
  border: none;
  background: transparent;
  color: var(--rojo);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 6px;
}
.hoja .btn-fila-borrar:hover { background: var(--rojo-suave); border-radius: 3px; }

.tabla-wrap {
  border: 1px solid var(--linea);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 60vh;
}

.toolbar-tabla {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  flex-wrap: wrap;
}

.contador-filas {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--texto-suave);
}

.callout {
  background: var(--blanco);
  border: 1px solid var(--linea);
  border-left: 3px solid var(--tinta);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--texto-suave);
  margin: 16px 0;
}
.callout b { color: var(--texto); }
.callout.callout-terracota { border-left-color: var(--terracota); }
.callout.callout-verde { border-left-color: var(--verde); }

.dropzone {
  border: 1.5px dashed var(--linea);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--texto-suave);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  background: var(--blanco);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--tinta); background: #FBFCFE; }
.dropzone strong { color: var(--tinta); }
.dropzone input { display: none; }

.log-consola {
  font-family: var(--mono);
  font-size: 12px;
  background: #0F1B26;
  color: #BFD9E8;
  border-radius: var(--radius);
  padding: 14px 16px;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.6;
}
.log-consola .ok { color: #6EE7B7; }
.log-consola .warn { color: #FBBF24; }
.log-consola .err { color: #FCA5A5; }
.log-consola .info { color: #93C5FD; }

.page-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 32px 90px;
}
.page-header h1 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--tinta);
  margin: 0 0 8px;
}
.page-header p {
  font-size: 14px;
  color: var(--texto-suave);
  max-width: 640px;
  margin: 0;
}

.stepper {
  display: flex;
  gap: 4px;
  margin: 26px 0 8px;
}
.step-pill {
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 2px;
  background: var(--papel-2);
  color: var(--texto-suave);
  border: 1px solid var(--linea);
}
.step-pill.activo { background: var(--tinta); color: var(--papel-2); border-color: var(--tinta); }
.step-pill.hecho { background: var(--verde-suave); color: var(--verde); border-color: var(--verde-suave); }
