/* ContaBean · hoja de estilos única. Pantallas densas, pensadas para leer cifras. */

:root {
  --fondo: #f6f5f1;
  --papel: #ffffff;
  --tinta: #1d2420;
  --tenue: #66706a;
  --linea: #dcdad2;
  --linea-suave: #ecebe5;
  --acento: #1f5a45;
  --acento-suave: #e4efe9;
  --alerta: #a4341f;
  --alerta-suave: #f8e7e2;
  --ambar: #8a5a00;
  --ambar-suave: #f7edd4;
}

* { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--tinta);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  line-height: 1.4;
}

a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- barra superior y navegación ---------- */
.barra {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.6rem 1.5rem;
  background: var(--acento);
  color: #fff;
}
.barra .marca { color: #fff; font-weight: 700; font-size: 1.15rem; letter-spacing: 0.01em; }
.barra .empresa { display: flex; gap: 0.75rem; align-items: baseline; flex: 1; min-width: 0; }
.barra .empresa strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra .numero-empresa { font-variant-numeric: tabular-nums; font-weight: 700; padding: 0.05rem 0.45rem; border-radius: 4px;
                         background: rgba(255, 255, 255, 0.16); color: #fff; }
.nombre-rut { font-size: 0.86rem; }
.separador-ingreso { display: flex; align-items: center; gap: 0.6rem; color: var(--tenue); margin: 0.9rem 0 0.6rem; }
.separador-ingreso::before, .separador-ingreso::after { content: ""; flex: 1; border-top: 1px solid var(--linea); }
.boton.boton-google { display: flex; align-items: center; justify-content: center; gap: 0.6rem; width: 100%;
                      background: #fff; color: #1f1f1f; border: 1px solid #dadce0; margin-bottom: 0.9rem; }
.boton.boton-google:hover { background: #f6f8fa; }
td.numero-empresa { font-weight: 600; font-variant-numeric: tabular-nums; width: 3.5rem; }
.lista-empresas .numero-empresa { display: inline-block; min-width: 2.2rem; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.barra .tenue { color: #cfe2d9; }
.barra .anio { display: flex; gap: 0.5rem; align-items: center; font-size: 0.9rem; }
.barra select { border: 0; }

.secciones {
  display: flex;
  gap: 0.25rem;
  padding: 0 1.25rem;
  background: var(--papel);
  border-bottom: 1px solid var(--linea);
  overflow-x: auto;
}
.secciones a {
  padding: 0.65rem 0.75rem;
  color: var(--tenue);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.secciones a:hover { color: var(--tinta); text-decoration: none; }
.secciones a.activa { color: var(--acento); border-bottom-color: var(--acento); font-weight: 600; }

main { padding: 1.25rem 1.5rem 3rem; max-width: 1400px; margin: 0 auto; }

/* ---------- encabezados y formularios ---------- */
.encabezado { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; margin-bottom: 0.75rem; }
h1 { font-size: 1.35rem; margin: 0; font-weight: 650; }
h2 { font-size: 0.8rem; margin: 1.5rem 0 0.5rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--tenue); font-weight: 600; }
.tarjeta h2 { margin-top: 0; }

.filtros { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-left: auto; }
.filtros label { display: flex; gap: 0.35rem; align-items: center; color: var(--tenue); font-size: 0.9rem; }

input, select, button {
  font: inherit;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--linea);
  border-radius: 6px;
  background: var(--papel);
  color: var(--tinta);
}
input[type="search"] { min-width: 16rem; }
select { max-width: 22rem; }
button { cursor: pointer; background: var(--acento); border-color: var(--acento); color: #fff; }
button[type="button"] { background: var(--papel); color: var(--acento); border-color: var(--linea); }
button:hover { filter: brightness(1.08); }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }

.tenue { color: var(--tenue); }
.nowrap { white-space: nowrap; }
p.tenue { margin: 0 0 0.6rem; font-size: 0.9rem; }

.aviso {
  padding: 0.6rem 0.9rem;
  background: var(--ambar-suave);
  border: 1px solid #e6d3a0;
  border-radius: 6px;
  color: var(--ambar);
}

.aviso.espejo { margin: 0 0 1rem; font-size: 0.9rem; }
.aviso a { color: inherit; text-decoration: underline; }
.tarjeta.gestion { max-width: 46rem; }
.tarjeta.gestion p { margin: 0 0 0.6rem; }
.tarjeta.gestion form { margin: 0; }

/* ---------- tarjetas de datos ---------- */
.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.tarjeta { background: var(--papel); border: 1px solid var(--linea); border-radius: 8px; padding: 1rem 1.1rem; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1.25rem; margin: 0; }
dt { color: var(--tenue); }
dd { margin: 0; }
dl.montos dd { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- tablas ---------- */
.tabla {
  width: 100%;
  border-collapse: collapse;
  background: var(--papel);
  border: 1px solid var(--linea);
  font-size: 0.93rem;
}
.tabla.angosta { width: auto; min-width: 28rem; }
.tabla th, .tabla td { padding: 0.32rem 0.6rem; text-align: left; vertical-align: top; }
.tabla thead { position: sticky; top: 0; }
.tabla thead th {
  background: #f0efe9;
  border-bottom: 1px solid var(--linea);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tenue);
  font-weight: 600;
  white-space: nowrap;
}
.tabla tbody tr { border-bottom: 1px solid var(--linea-suave); }
.tabla tbody tr:hover { background: #faf9f5; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla .codigo, .codigo { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.88rem; }
.tabla .vacio { padding: 1.5rem; text-align: center; color: var(--tenue); }
.tabla tr.apagada td { color: var(--tenue); }
.tabla tfoot td { border-top: 2px solid var(--linea); font-weight: 600; background: #f7f6f1; }
.tabla tfoot tr.final td { border-top: 1px solid var(--linea); }

/* Libros: cada comprobante o cuenta es un bloque con su subtotal */
.tabla.libro tbody.asiento tr { border-bottom: 0; }
.tabla.libro tbody.asiento { border-bottom: 1px solid var(--linea); }
.tabla.libro tr.subtotal td { font-weight: 600; padding-bottom: 0.6rem; }
.tabla.libro tr.subtotal td.num { border-top: 1px solid var(--linea); }
.tabla.libro tr.titulo-cuenta td { padding-top: 0.7rem; font-weight: 600; }
.tabla.ocho { font-size: 0.86rem; }
.tabla thead tr.grupos th { border-bottom: 0; padding-bottom: 0; text-align: center; }
.tabla thead tr.grupos th.grupo { border-left: 1px solid var(--linea); }
.tabla.ocho td:nth-child(5), .tabla.ocho td:nth-child(7), .tabla.ocho td:nth-child(9),
.tabla.ocho tr:not(.grupos) th:nth-child(4), .tabla.ocho tr:not(.grupos) th:nth-child(6), .tabla.ocho tr:not(.grupos) th:nth-child(8) { border-left: 1px solid var(--linea-suave); }

/* Plan de cuentas: sangría y peso según el nivel */
.tabla tr.nivel-0 td { font-weight: 700; background: var(--acento-suave); }
.tabla tr.nivel-1 td { font-weight: 650; }
.tabla tr.nivel-2 td { font-weight: 600; }
.tabla tr.nivel-1 .sangria { padding-left: 1.4rem; }
.tabla tr.nivel-2 .sangria { padding-left: 2.2rem; }
.tabla tr.nivel-3 .sangria { padding-left: 3rem; color: var(--tenue); }
.tabla tr.nivel-4 .sangria { padding-left: 3.8rem; }

.marca-estado {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--acento-suave);
  color: var(--acento);
  white-space: nowrap;
}
.marca-estado.anulado { background: #ecebe5; color: var(--tenue); }
.marca-estado.borrador { background: var(--ambar-suave); color: var(--ambar); }
.marca-estado.alerta { background: var(--alerta-suave); color: var(--alerta); }

/* ---------- libros de compras, ventas y retenciones ---------- */
.libro-documentos tr.nulo td { color: var(--tenue); font-style: italic; }
.libro-documentos tbody td { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.resumen-documentos { max-width: 60rem; }
.tabla.f29 { max-width: 52rem; }
.estado-resultados { max-width: 56rem; }
.aviso.cerrado { background: #ecebe5; border-color: var(--linea); color: var(--tinta); }
.revision { margin: 0 0 1rem; padding-left: 1.2rem; }
.revision li { margin: 0.3rem 0; }
.revision li.mal { color: var(--alerta); }
.revision li.bien { color: var(--acento); }
.estado-resultados tr.er-titulo td { padding-top: 0.9rem; font-weight: 700; letter-spacing: 0.03em; }
.estado-resultados tr.er-titulo-concepto td { padding-top: 0.5rem; font-weight: 600; }
.estado-resultados tr.er-cuenta td { color: var(--tenue); font-size: 0.88rem; padding-top: 0.1rem; padding-bottom: 0.1rem; }
.estado-resultados tr.er-cuenta td:nth-child(2) { padding-left: 1.5rem; }
.estado-resultados tr.er-subtotal td { font-weight: 600; border-top: 1px solid var(--linea); }
.estado-resultados tr.er-total td { font-weight: 700; font-size: 1.05rem; border-top: 2px solid var(--tinta); }
.config-resultado-form .error-general { margin-bottom: 0.75rem; }
.config-resultado-form .acciones { margin-top: 0.75rem; justify-content: flex-end; }
.config-resultado { table-layout: fixed; }
.config-resultado td { padding: 0.2rem 0.3rem; }
.config-resultado input, .config-resultado select { width: 100%; }
.config-resultado th:nth-child(1) { width: 4.5rem; }
.config-resultado th:nth-child(2) { width: 15rem; }
.config-resultado th:nth-child(4) { width: 9.5rem; }
.config-resultado th:nth-child(6) { width: 2.5rem; }
.config-resultado .borrar { border: 0; background: none; color: var(--tenue); font-size: 1.05rem; }
.tabla.f29 tr.informativo td { color: var(--tenue); }
.tabla.f29 tfoot td { font-size: 1.05rem; }
.aviso-linea { margin-left: 0.5rem; font-size: 0.85rem; color: var(--ambar); }

/* ---------- impresión ---------- */
@media print {
  html { font-size: 11px; }
  body { background: #fff; }
  .secciones, .filtros, .nuevo, .acciones, .aviso.espejo, #gestion, .tarjeta.gestion { display: none; }
  nav.pestanas { display: none; }
  /* El total va una vez, al final, y no repetido al pie de cada hoja. */
  .tabla tfoot { display: table-row-group; }
  .barra { display: none; }  /* el encabezado de la hoja va en el margen de la página (base.html) */
  main { padding: 0.5rem 0 0; max-width: none; }
  .tabla { border: 0; }
  .tabla thead { position: static; }
  .tabla thead th { background: none; border-bottom: 1px solid #000; }
  .tabla tbody.asiento { break-inside: avoid; }
  a { color: inherit; }
}

/* ---------- acciones y botones ---------- */
.acciones { display: flex; gap: 0.5rem; align-items: center; margin-left: auto; }
.encabezado .acciones a:not(.boton) { font-size: 0.9rem; margin-right: 0.5rem; }
a.boton {
  padding: 0.35rem 0.8rem; border-radius: 6px; background: var(--acento); color: #fff; border: 1px solid var(--acento);
}
a.boton:hover { text-decoration: none; filter: brightness(1.08); }
button.secundario { background: var(--papel); color: var(--acento); border-color: var(--linea); }
.nuevo { display: flex; gap: 0.4rem; align-items: center; margin: 0 0 0.6rem; }
.nuevo form { margin: 0; }
kbd {
  font: inherit; font-size: 0.8rem; padding: 0 0.3rem; border: 1px solid var(--linea); border-bottom-width: 2px;
  border-radius: 4px; background: var(--papel);
}

/* ---------- ingreso de comprobantes ---------- */
.editor-cabecera { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
.editor-cabecera label { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.78rem; color: var(--tenue); text-transform: uppercase; letter-spacing: 0.04em; }
.editor-cabecera input { font-size: 0.95rem; text-transform: none; letter-spacing: 0; }
.editor-cabecera label.crece { flex: 1 1 18rem; }
#f-numero { width: 6rem; text-align: right; }
.editor-documento { align-items: flex-end; }
.editor-documento select { font-size: 0.95rem; }
.editor-documento input.numero { width: 7rem; text-align: right; }
.editor-documento input.fecha { width: 8rem; }
.editor-documento #d-rut { width: 8.5rem; }
.editor-documento .nombre-doc { flex: 0 1 18rem; min-width: 8rem; align-self: center; padding-top: 1rem; font-size: 0.92rem;
                                color: var(--tinta); font-weight: 600; }
.editor-documento .montos { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: flex-end; flex-basis: 100%; }
.editor-documento input.monto { width: 8rem; text-align: right; font-variant-numeric: tabular-nums; }
.editor-documento label.marca { flex-direction: row; align-items: center; gap: 0.35rem; text-transform: none; letter-spacing: 0; font-size: 0.88rem; color: inherit; padding-bottom: 0.3rem; }
.editor-documento .tasa { text-transform: none; letter-spacing: 0; }
.editor-documento input.mal, .editor-documento select.mal { border-color: var(--alerta); background: var(--alerta-suave); }
.problemas.avisos li { color: var(--ambar); }
#f-fecha { width: 8rem; }

.tabla.editor { table-layout: fixed; }
.tabla.editor th, .tabla.editor td { padding: 0; vertical-align: middle; }
.tabla.editor thead th { padding: 0.3rem 0.45rem; }
.tabla.editor .col-n { width: 2.6rem; }
.tabla.editor .col-cuenta { width: 6.2rem; }
.tabla.editor .col-rut { width: 7.6rem; }
.tabla.editor .col-nombre-aux { width: 10.5rem; }
.tabla.editor .col-tipo { width: 3rem; }
.tabla.editor .col-num { width: 5.5rem; }
.tabla.editor .col-fecha { width: 6.4rem; }
.tabla.editor .col-centro { width: 8.5rem; }
.tabla.editor .col-monto { width: 7.8rem; }
.tabla.editor th:last-child { width: 2rem; }
.tabla.editor tbody tr { border-bottom: 1px solid var(--linea-suave); }
.tabla.editor tbody tr:hover { background: none; }
.tabla.editor input {
  width: 100%; border: 1px solid transparent; border-radius: 0; background: transparent; padding: 0.32rem 0.45rem;
}
.tabla.editor input:focus { outline: none; border-color: var(--acento); background: #fff; box-shadow: inset 0 0 0 1px var(--acento); }
.tabla.editor input.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla.editor input.mal, .editor-cabecera input.mal { border-color: var(--alerta); background: var(--alerta-suave); }
/* Centro de costo que la cuenta pide y falta: se ve, pero no impide grabar. */
.tabla.editor input.falta { border-color: var(--alerta); background: var(--alerta-suave); border-style: dashed; }
.tabla.editor td.solo-lectura {
  padding: 0.15rem 0.45rem; color: var(--tenue); font-size: 0.82rem; line-height: 1.15; overflow: hidden; overflow-wrap: anywhere;
}
/* El nombre del RUT se lee entero (en dos líneas si hace falta) y con el color del texto, no en gris. */
.tabla.editor td.solo-lectura.nombre-aux { color: var(--tinta); }
.tabla.editor td.solo-lectura.nombre-aux.provisorio, .editor-documento .nombre-doc.provisorio { color: var(--tenue); font-style: italic; }
/* Número de línea: lo pone el navegador, así se renumera solo al borrar. */
.tabla.editor tbody { counter-reset: linea; }
.tabla.editor tbody tr { counter-increment: linea; }
.tabla.editor td.n { padding: 0 0.45rem; text-align: right; }
.tabla.editor td.n::before { content: counter(linea); }
.tabla td.n { color: var(--tenue); font-variant-numeric: tabular-nums; font-size: 0.86rem; }
.tabla.editor tr:focus-within td.n { color: var(--acento); font-weight: 700; }
.tabla.editor tr.heredada input { color: var(--tenue); font-style: italic; }
.tabla.editor tr.con-error td:first-child { box-shadow: inset 3px 0 0 var(--alerta); }
.tabla.editor tr.sin-rut [data-campo="rut"]:not(:focus),
.tabla.editor tr.sin-doc [data-campo="tipo_doc"]:not(:focus),
.tabla.editor tr.sin-doc [data-campo="num_doc"]:not(:focus),
.tabla.editor tr.sin-doc [data-campo^="fecha"]:not(:focus) { background: #f7f6f1; }
.tabla.editor .borrar {
  width: 100%; padding: 0.2rem 0; border: 0; background: none; color: var(--tenue); font-size: 1.05rem; line-height: 1;
}
.tabla.editor .borrar:hover { color: var(--alerta); filter: none; }
.tabla.editor tfoot td { padding: 0.45rem 0.45rem; }
#t-diferencia { font-weight: 600; }
#t-diferencia.falta { color: var(--alerta); }
#t-diferencia.bien { color: var(--acento); }
#btn-contabilizar { opacity: 0.75; }
#btn-contabilizar.listo { opacity: 1; }

.sugerencias {
  position: absolute; z-index: 20; margin: 2px 0 0; padding: 0.2rem 0; list-style: none; min-width: 22rem; max-width: 34rem;
  background: var(--papel); border: 1px solid var(--linea); border-radius: 6px; box-shadow: 0 6px 18px rgb(0 0 0 / 0.14);
  font-size: 0.9rem;
}
.sugerencias li { display: flex; gap: 0.75rem; padding: 0.25rem 0.6rem; cursor: pointer; white-space: nowrap; }
.sugerencias li b { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 5.5rem; }
.sugerencias li span { overflow: hidden; text-overflow: ellipsis; color: var(--tenue); }
.sugerencias li.elegida, .sugerencias li:hover { background: var(--acento-suave); }
.sugerencias li.elegida span { color: var(--tinta); }

.problemas { margin: 0.75rem 0 0; padding: 0; list-style: none; font-size: 0.9rem; color: var(--alerta); }
.problemas li { padding: 0.15rem 0; }
.problemas li.enlace { cursor: pointer; }
.problemas li.enlace:hover { text-decoration: underline; }
.ayuda { margin-top: 1rem; font-size: 0.82rem; color: var(--tenue); line-height: 1.9; }

dialog { border: 1px solid var(--linea); border-radius: 10px; padding: 1.25rem 1.4rem; min-width: 24rem; box-shadow: 0 12px 40px rgb(0 0 0 / 0.25); }
dialog::backdrop { background: rgb(0 0 0 / 0.3); }
dialog h2 { margin: 0 0 0.9rem; font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--tinta); }
dialog label { display: flex; flex-direction: column; gap: 0.2rem; margin-bottom: 0.7rem; font-size: 0.85rem; color: var(--tenue); }
dialog .acciones { justify-content: flex-end; margin-top: 0.5rem; }
dialog button[type="button"] { background: var(--papel); color: var(--acento); border-color: var(--linea); }
.error { color: var(--alerta); margin: 0; min-height: 1.2rem; font-size: 0.85rem; }

/* ---------- mantención: plan de cuentas y auxiliares ---------- */
.tabla .col-acciones { text-align: right; white-space: nowrap; font-size: 0.82rem; }
.tabla .col-acciones a { margin-left: 0.7rem; font-weight: 400; }
.tabla tr:target td { background: var(--ambar-suave); }
.ficha { max-width: 40rem; background: var(--papel); border: 1px solid var(--linea); border-radius: 8px; padding: 1.1rem 1.3rem; }
.ficha > label, .ficha .par label { display: flex; flex-direction: column; gap: 0.2rem; margin-bottom: 0.8rem; font-size: 0.85rem; color: var(--tenue); }
.ficha input:not([type=checkbox]):not([type=radio]) { font-size: 1rem; }
.ficha input.codigo { max-width: 11rem; }
.ficha .par { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.ficha fieldset { border: 1px solid var(--linea); border-radius: 6px; margin: 0 0 0.9rem; padding: 0.5rem 0.8rem 0.6rem; }
.ficha legend { font-size: 0.85rem; color: var(--tenue); padding: 0 0.3rem; }
.ficha .opcion { display: flex; gap: 0.5rem; align-items: center; margin: 0.25rem 0; color: var(--tinta); }
.ficha dl { margin: 0 0 0.9rem; }
.ficha .ayuda { font-size: 0.8rem; }
.ficha .acciones { margin: 0.4rem 0 0; justify-content: flex-end; }
.ficha .error-general { margin: 0 0 0.9rem; }
.ficha input.con-error { border-color: var(--alerta); box-shadow: inset 0 0 0 1px var(--alerta); }
.error-campo { color: var(--alerta); font-size: 0.85rem; }
button.peligro { background: var(--papel); color: var(--alerta); border-color: var(--alerta); margin-right: auto; }
@media print { .col-acciones { display: none; } }

/* ---------- renumerar ---------- */
.nuevo .al-final { margin-left: auto; font-size: 0.9rem; }
.explicacion { max-width: 52rem; }
.aviso.listo { background: var(--verde-suave, #e6f2ec); border-color: var(--acento); color: var(--tinta); }
.tabla tr.elegida td { background: var(--ambar-suave); }
form.confirmar { display: flex; gap: 0.8rem; align-items: center; margin: 0 0 0.8rem; }
@media print { form.confirmar { display: none; } }

.acciones form { margin: 0; display: inline; }

/* ---------- ajustes del cuestionario ---------- */
.buscador-cuenta { min-width: 22rem; }
.firmas { display: flex; justify-content: space-around; gap: 3rem; margin: 4.5rem 0 1rem; text-align: center; font-size: 0.9rem; break-inside: avoid; }
.firmas div { min-width: 15rem; }
.firmas .linea { display: block; border-top: 1px solid var(--tinta); margin-bottom: 0.4rem; }
.firmas small { color: var(--tenue); }

a.boton.secundario { background: var(--papel); color: var(--acento); border-color: var(--linea); }

/* ---------- inventario y balance, pie legal ---------- */
.tabla.inventario tr.grupo td { font-weight: 600; background: transparent; border-bottom: none; padding-top: 0.5rem; }
.tabla.inventario tr.g1 td { padding-left: 1.6rem; } .tabla.inventario tr.g2 td { padding-left: 2.6rem; }
.tabla.inventario tr.g3 td { padding-left: 3.6rem; font-weight: 500; }
.tabla.inventario tr.cuenta td:first-child { padding-left: 4.8rem; }
.tabla.inventario tr.auxiliar td { font-size: 0.85rem; color: var(--tenue); border-bottom: none; padding-top: 0.1rem; padding-bottom: 0.1rem; }
.tabla.inventario tr.auxiliar td:first-child { padding-left: 6.4rem; width: 14rem; }
.pie-legal { margin-top: 2rem; font-size: 0.8rem; break-inside: avoid; }
.pie-legal p { margin: 0 0 1.2rem; }
.pie-legal .fecha-firma { text-align: center; }
.pie-legal .raya { display: inline-block; width: 14rem; border-bottom: 1px solid var(--tinta); }

/* ---------- foliado ---------- */
.hoja-folio { display: none; }
@media print {
  main.foliar > :not(.hoja-folio) { display: none; }
  .hoja-folio { display: flex; justify-content: space-between; align-items: flex-start; font-size: 9pt; line-height: 1.5; break-after: page; }
  .hoja-folio:last-child { break-after: auto; }
  .hoja-folio .folio { font-weight: 600; white-space: nowrap; }
}
.muestra-folio { display: flex; justify-content: space-between; max-width: 46rem; font-size: 0.9rem; }

/* ---------- registro del SII ---------- */
.carga-sii { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; align-items: center; margin-bottom: 0.8rem; }
.carga-sii label { display: flex; gap: 0.6rem; align-items: center; font-weight: 500; }
.carga-sii #resultado-sii { flex-basis: 100%; margin: 0; }
.filtro-estado { display: flex; gap: 1rem; margin: 0.6rem 0; font-size: 0.9rem; }
.filtro-estado a.actual { font-weight: 600; color: var(--tinta); text-decoration: none; }
@media print { .carga-sii, .filtro-estado { display: none; } }
.generar-sii { margin-bottom: 0.8rem; }
.generar-sii .filtros { margin-bottom: 0.6rem; flex-wrap: wrap; }
.generar-sii form.confirmar { margin: 0; }
.ficha.ancha { max-width: 46rem; }

/* ---------- parámetros ---------- */
.barra .enlace-parametros { margin-left: auto; color: inherit; opacity: 0.85; font-size: 0.9rem; text-decoration: none; }
.barra .anio + .enlace-parametros { margin-left: 1.2rem; }
.barra .enlace-parametros:hover { opacity: 1; text-decoration: underline; }
button.chico { padding: 0.15rem 0.6rem; font-size: 0.82rem; }
.tabla .col-acciones form { margin: 0; display: inline; }

.tabla + p.tenue { margin-top: 0.7rem; }

/* ---------- banco ---------- */
.cifras-banco dl { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1rem; margin: 0; }
.cifras-banco dt { color: var(--tenue); }
.cifras-banco dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.cifras-banco dl > :nth-last-child(-n+2) { border-top: 1px solid var(--linea); padding-top: 0.3rem; margin-top: 0.15rem; }
.cifras-banco .tarjeta:nth-child(2) dl > :nth-last-child(-n+2) { border-top: 0; padding-top: 0; margin-top: 0; }
.cifras-banco .tarjeta:nth-child(2) dt { color: inherit; }
.acciones-banco { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0.6rem 0; }
.acciones-banco form { margin: 0; }
.tabla .col-acciones select { max-width: 24rem; font-size: 0.85rem; }
@media print { .acciones-banco, .tabla .col-acciones { display: none; } }
.cifras-banco .contraste { margin: 0.6rem 0 0; font-size: 0.9rem; }
.cifras-banco .contraste.cuadra { color: var(--acento); }

/* ---------- comprobantes tipo ---------- */
.tipo-comprobante { margin-bottom: 0.6rem; padding: 0.6rem 0.9rem; }
.tipo-comprobante summary { display: flex; align-items: center; gap: 0.8rem; cursor: pointer; list-style: none; }
.tipo-comprobante summary::-webkit-details-marker { display: none; }
.tipo-comprobante summary .crece { flex: 1; }
.tipo-comprobante summary form { margin: 0; }
.tipo-comprobante .num-tipo { min-width: 2rem; font-variant-numeric: tabular-nums; color: var(--tenue); }
.tipo-comprobante[open] summary { margin-bottom: 0.6rem; }
.tipo-comprobante .eliminar-tipo { margin: 0.6rem 0 0; text-align: right; }
.nuevo .desde-tipo { display: inline-flex; gap: 0.4rem; margin: 0; }
.nuevo .desde-tipo select { max-width: 18rem; }
#dlg-tipos { width: min(34rem, 92vw); }
#dlg-tipos fieldset { border: 1px solid var(--linea); border-radius: 8px; margin: 0 0 0.8rem; padding: 0.6rem 0.9rem 0.3rem; }
#dlg-tipos legend { font-size: 0.85rem; color: var(--tinta); padding: 0 0.3rem; }
#dlg-tipos select { width: 100%; }
#dlg-tipos .error { color: var(--alerta, #b42318); }

/* ---------- ingreso, cuenta y usuarios ---------- */
.barra .usuario-barra { margin-left: auto; display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }
.barra .usuario-barra a { color: inherit; opacity: 0.85; text-decoration: none; }
.barra .usuario-barra a:hover { opacity: 1; text-decoration: underline; }
.barra .usuario-barra form { margin: 0; }
.barra .usuario-barra .enlace-parametros { margin-left: 0; }
.barra .usuario-barra button { background: transparent; color: inherit; border-color: rgb(255 255 255 / 0.4); }
.pagina-ingreso main { max-width: 26rem; margin: 12vh auto 0; }
.ficha.ingreso h1 { margin: 0 0 1rem; }
.pestanas, .pestanas-parametros { display: flex; gap: 1.2rem; border-bottom: 1px solid var(--linea); margin: 0 0 1rem; }
.pestanas a, .pestanas-parametros a { padding: 0.4rem 0; color: var(--tenue); text-decoration: none; border-bottom: 2px solid transparent; }
.pestanas a.activa, .pestanas-parametros a.activa { color: var(--tinta); border-bottom-color: var(--acento); }
.ficha fieldset { border: 1px solid var(--linea); border-radius: 8px; padding: 0.6rem 0.9rem; margin: 0 0 0.9rem; }
.ficha fieldset legend { padding: 0 0.3rem; font-size: 0.9rem; }
.ficha label.opcion { display: flex; flex-direction: row; align-items: baseline; gap: 0.5rem; margin: 0.25rem 0; color: var(--tinta); }
.ficha label.opcion input { width: auto; }
.ficha-ancha { max-width: 52rem; }
.lista-empresas { max-height: 16rem; overflow: auto; columns: 2 22rem; margin-top: 0.4rem; }
.lista-empresas label.opcion { break-inside: avoid; }
.acciones-fila { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-start; margin: 0.6rem 0; }
.acciones-fila form { margin: 0; }
.ficha-en-linea { display: inline; padding: 0; border: 0; background: none; }
.aviso-unico p { white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: 1rem; }
.aviso-unico { display: flex; flex-direction: column; gap: 0.6rem; align-items: flex-start; }
.lista-simple { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }
a.boton { display: inline-block; padding: 0.4rem 0.9rem; border-radius: 6px; background: var(--acento); color: #fff; text-decoration: none; }

/* ---------- auditoría ---------- */
.filtros-auditoria { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; margin: 0.8rem 0; }
.filtros-auditoria select { max-width: 16rem; }
.tabla-auditoria td { vertical-align: top; font-size: 0.88rem; }
.detalle-auditoria { max-width: 34rem; overflow-wrap: anywhere; }
.detalle-auditoria details summary { cursor: pointer; color: var(--tenue); font-size: 0.8rem; margin-top: 0.2rem; }
.detalle-auditoria pre { max-height: 20rem; overflow: auto; font-size: 0.75rem; background: var(--fondo-suave, #f6f6f4); padding: 0.5rem; border-radius: 6px; }
.tabla-auditoria tr.grupo-acceso td:nth-child(3) { color: var(--tenue); }
.encabezado .acciones form { display: inline; margin: 0; }
.historial-comprobante { font-size: 0.88rem; }

/* ---------- comprobantes impresos (uno por hoja) ---------- */
.hoja-comprobante { background: var(--papel); border: 1px solid var(--linea); border-radius: 8px; padding: 1.2rem 1.4rem;
                    margin: 0 0 1.5rem; max-width: 60rem; position: relative; }
.cabeza-comprobante { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--tinta);
                      padding-bottom: 0.4rem; margin-bottom: 0.6rem; }
.cabeza-comprobante h2 { margin: 0; text-transform: uppercase; letter-spacing: 0.06em; font-size: 1.1rem; color: var(--tinta); }
.numero-comprobante { font-size: 1.1rem; }
.datos-comprobante { display: grid; grid-template-columns: 7rem 1fr; gap: 0.2rem 0.8rem; margin: 0 0 0.8rem; }
.datos-comprobante dt { color: var(--tenue); }
.datos-comprobante dd { margin: 0; }
.lineas-impresas td { vertical-align: top; }
.lineas-impresas .detalle-linea { font-size: 0.82rem; color: var(--tenue); }
.firmas { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1.5rem; margin: 3.2rem 0 0.8rem; }
.firma { border-top: 1px solid var(--tinta); padding-top: 0.25rem; text-align: center; font-size: 0.85rem; }
.firma small { display: block; color: var(--tenue); }
.pie-comprobante { font-size: 0.78rem; margin: 0.6rem 0 0; }
.sello-anulado { position: absolute; top: 2.8rem; right: 1.4rem; border: 2px solid var(--alerta); color: var(--alerta);
                 padding: 0.1rem 0.6rem; transform: rotate(-8deg); text-transform: uppercase; font-weight: 700; margin: 0; }
.imprimir-varios { margin: 0 0 1rem; }
/* revisión de una importación (honorarios) */
.mal-texto { color: var(--alerta); }
.aviso-texto { color: var(--ambar); }
.tabla.libro tr.con-error td { background: var(--alerta-suave); }
@media print {
  .imprimir-varios { display: none; }
  main.impresion-comprobantes > .encabezado { display: none; }
  .hoja-comprobante { border: 0; border-radius: 0; padding: 0; margin: 0; max-width: none; break-after: page; }
  .hoja-comprobante:last-of-type { break-after: auto; }
  .firmas { break-inside: avoid; }
}

/* ---------- certificados de honorarios (uno por hoja) ---------- */
.hoja-certificado { background: var(--papel); border: 1px solid var(--linea); border-radius: 8px; padding: 1.4rem 1.6rem;
                    margin: 0 0 1.5rem; max-width: 52rem; display: grid; grid-template-columns: 1fr auto; gap: 0 1rem; }
.hoja-certificado > *:not(.empresa-certificado):not(.numero-certificado) { grid-column: 1 / -1; }
.empresa-certificado p, .numero-certificado p { margin: 0; }
.numero-certificado { text-align: right; }
.hoja-certificado h2 { text-align: center; text-transform: uppercase; letter-spacing: 0.05em; font-size: 1.05rem;
                       margin: 1.6rem 0 0.8rem; color: var(--tinta); }
.texto-certificado { line-height: 1.6; }
.hoja-certificado > * { min-width: 0; }
.tabla-certificado { width: 100%; table-layout: fixed; }
.tabla.tabla-certificado thead th { white-space: normal; vertical-align: bottom; }
.tabla-certificado th:first-child, .tabla-certificado td:first-child { width: 7.5rem; }
.tabla-certificado th.centro { text-align: center; }
.tabla-certificado tr.columnas th { font-weight: 400; color: var(--tenue); font-size: 0.8rem; }
.tabla-certificado tr.sin-factor td { color: var(--alerta); }
.pie-certificado { font-size: 0.85rem; margin-top: 1rem; }
.hoja-certificado .firmas { grid-template-columns: minmax(14rem, 18rem); justify-content: end; margin-top: 4rem; }
@media (max-width: 700px) {
  .hoja-certificado { display: block; padding: 1rem; }
  .numero-certificado { text-align: left; margin-top: 0.6rem; }
  .tabla.tabla-certificado { min-width: 40rem; }
}
.grilla-factores { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 0.6rem 1rem; }
.ficha.factores h2 { margin-top: 0; }
@media print {
  main.impresion-certificados > .encabezado, .no-imprimir { display: none; }
  .hoja-certificado { border: 0; border-radius: 0; padding: 0; margin: 0; max-width: none; break-after: page; font-size: 12px; }
  .hoja-certificado:last-of-type { break-after: auto; }
}

/* ---------- segundo factor ---------- */
.pagina-inscribir main { max-width: 52rem; }
.metodos-segundo-factor { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; margin: 1rem 0; }
.metodos-segundo-factor h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.metodos-segundo-factor .ficha { padding: 0; border: 0; background: none; box-shadow: none; max-width: none; }
.qr-autenticador { display: flex; justify-content: center; margin: 0.6rem 0; }
.qr-autenticador svg { width: 11rem; height: 11rem; image-rendering: pixelated; }
.clave-manual { font-size: 0.95rem; letter-spacing: 0.04em; user-select: all; }
.otros-caminos { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.salir-ingreso { margin-top: 1rem; text-align: center; }
.configurar-segundo-factor summary { cursor: pointer; color: var(--acento); margin: 0.4rem 0; }
.error-general.listo { background: var(--fondo-listo, #e7f3ec); color: inherit; }
.pagina-inscribir .ficha.ingreso { max-width: none; }

/* ---------- por RUT y documentos pendientes ---------- */
.desplazable { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.buscar-rut input[type=search] { min-width: 18rem; }
.tabla.pendientes td.vencido { color: var(--alerta); font-weight: 600; }
.tabla.pendientes tr.movimiento td { font-size: 0.85rem; color: var(--tenue); border-bottom: 0; }
.tabla.pendientes tr.movimiento td:first-child { padding-left: 1.4rem; }
.contacto-rut { margin-top: -0.4rem; }
h3 .codigo { color: var(--tenue); }
.solo-estrecho { display: none; }
@media (max-width: 700px) {
  .solo-ancho { display: none; }
  .solo-estrecho { display: table-cell; }
  .buscar-rut, .buscar-rut input[type=search] { width: 100%; min-width: 0; }
  .desplazable .tabla { font-size: 0.84rem; }
  .desplazable .tabla th, .desplazable .tabla td { padding: 0.3rem 0.3rem; }
  .desplazable .tabla th:first-child, .desplazable .tabla td:first-child { padding-left: 0.45rem; }
}
@media print {
  .solo-ancho { display: table-cell; }
  .solo-estrecho { display: none; }
  .desplazable { overflow: visible; }
}

/* ---------- centros de costo ---------- */
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lista-centros { margin: 0.8rem 0 1.4rem; max-width: 52rem; }
.fila-centro { display: grid; grid-template-columns: 3rem minmax(10rem, 1fr) auto 6rem auto 5.5rem; align-items: center;
               gap: 0.4rem 0.8rem; padding: 0.35rem 0.2rem; border-bottom: 1px solid var(--linea-suave); margin: 0; }
div.fila-centro { grid-template-columns: 3rem minmax(10rem, 1fr) auto 6rem; }
.fila-centro .codigo { min-width: 2.5rem; text-align: right; }
.fila-centro .nombre-centro { margin: 0; }
.fila-centro .nombre-centro input { width: 100%; }
.fila-centro .opcion { display: flex; gap: 0.3rem; align-items: center; margin: 0; }
.fila-centro .usos { min-width: 6rem; font-size: 0.85rem; }
.fila-centro.inactivo { opacity: 0.6; }
.fila-centro .error-general { grid-column: 1 / -1; margin: 0.2rem 0 0; }
@media (max-width: 700px) {
  .fila-centro { grid-template-columns: 2.5rem 1fr auto; }
  .fila-centro .usos { display: none; }
}
.fila-centro button.peligro { margin-right: 0; }

/* ---------- informes por centro de costo ---------- */
.pestanas.sub { margin-top: -0.4rem; font-size: 0.92rem; }
.tabla.mes-a-mes td, .tabla.mes-a-mes th { padding-left: 0.35rem; padding-right: 0.35rem; }
.tabla.mes-a-mes { font-size: 0.86rem; }
