* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 12px;
  color: #1f2937;
  background: #e5e7eb;
  margin: 0;
  padding: 0;
}

/* ---------- Toolbar (no imprimible) ---------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #2f3b52;
  color: #fff;
  padding: 10px 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar input[type="text"] {
  padding: 6px 8px;
  border: none;
  border-radius: 3px;
  min-width: 220px;
}

.toolbar button {
  padding: 6px 14px;
  border: none;
  border-radius: 3px;
  background: #4a90e2;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

.toolbar button:hover {
  background: #357abd;
}

.toolbar-button {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 3px;
  background: #fff;
  color: #2f3b52;
  text-decoration: none;
  font-size: 12px;
}

.toolbar-button:hover {
  background: #e8e8e8;
}

.estado {
  padding: 6px 16px;
  font-size: 12px;
  color: #333;
}

.estado.error {
  color: #b00020;
  font-weight: bold;
}

/* ---------- Hoja tamaño estándar A4, alto ajustado al contenido ---------- */
.hoja {
  background: #fff;
  width: 210mm;
  min-height: 297mm;
  margin: 20px auto;
  padding: 8mm 10mm;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.15);
}

/* ---------- Encabezado repetible (va dentro del <thead> de la tabla,
   por lo que el navegador lo reimprime en cada página automáticamente) ---------- */
.tabla-inventario .fila-empresa th {
  border: none;
  border-bottom: 2px solid #1e3a5f;
  padding: 0 0 5px;
  background: #fff;
  vertical-align: top;
  font-weight: normal;
}

.empresa-nombre,
.empresa-direccion,
.celda-meta span {
  display: block;
}

.celda-empresa {
  text-align: left;
}

.empresa-nombre {
  font-size: 13px;
  font-weight: bold;
  color: #1e3a5f;
}

.empresa-direccion,
.celda-meta span {
  font-size: 9.5px;
}

.celda-meta {
  text-align: right;
  white-space: normal;
  width: 30%;
  min-width: 145px;
  overflow: visible !important;
  clip-path: none;
}

.meta-contenido {
  display: block;
  width: 170px;
  min-width: 170px;
  max-width: 170px;
  margin-left: auto;
  margin-right: 0;
  min-height: 42px;
  overflow: visible;
  position: relative;
  z-index: 2;
  text-align: right;
  white-space: nowrap;
}

.meta-linea {
  display: block;
  width: 100%;
  white-space: nowrap;
  font-size: 9px;
}

.tabla-inventario .fila-subtitulo th {
  border: none;
  background: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: normal;
  color: #1e3a5f;
  padding: 5px 0 8px;
}

.tabla-inventario .fila-columnas th {
  background: #f1f5f9;
  color: #1f2937;
  font-weight: bold;
  text-align: left;
}

/* ---------- Tabla principal ---------- */
.tabla-inventario {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}

.tabla-inventario th,
.tabla-inventario td {
  border: 1px solid #000;
  padding: 2px 4px;
  overflow: hidden;
  text-overflow: clip;
}

.tabla-inventario thead th {
  height: auto;
  max-height: none;
  line-height: 11px;
  white-space: normal;
  overflow: visible;
}

.tabla-inventario tbody td {
  height: 18px;
  max-height: 18px;
  line-height: 13px;
  white-space: nowrap;
}

.col-codigo   { width: 9%; }
.col-descripcion { width: 21.4%; }
.col-um       { width: 7%;  text-align: center; }
.col-ubicacion{ width: 13%; }
.col-stock    { width: 11%; text-align: right; }
.col-fisica   { width: 11%; text-align: right; }
.col-observacion { width: 27.6%; }

.tabla-inventario tbody td:nth-child(5),
.tabla-inventario tbody td:nth-child(6) {
  text-align: right;
}

.tabla-inventario tbody td:nth-child(3) {
  text-align: center;
}

.sin-datos {
  text-align: center !important;
  font-style: italic;
  color: #666;
  padding: 20px !important;
}

.separador-pagina {
  display: table-row;
}

.separador-pagina td {
  height: 0;
  padding: 0;
  border: 0;
}

.fila-total td {
  font-weight: bold;
  border-top: 2px solid #000;
}

/* ---------- Pie: filtros + resumen ---------- */
.pie {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  font-size: 10px;
}

.filtros h4 {
  margin: 0 0 4px 0;
  font-size: 11px;
}

.tabla-filtros {
  border-collapse: collapse;
}

.tabla-filtros th,
.tabla-filtros td {
  border: 1px solid #999;
  padding: 2px 8px;
  font-size: 10px;
}

.resumen {
  text-align: right;
  min-width: 220px;
}

.resumen p {
  margin: 2px 0;
}

.totales-linea {
  font-weight: bold;
  border-top: 1px solid #000;
  padding-top: 4px;
}

/* ---------- Impresión ---------- */
@media print {
  body {
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .hoja {
    box-shadow: none;
    margin: 0;
    width: 210mm;
    min-height: 297mm;
    padding: 8mm 10mm;
  }

  @page {
    size: A4 portrait;
    margin: 0;
  }

  .tabla-inventario {
    page-break-inside: auto;
  }

  .tabla-inventario tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .separador-pagina {
    break-before: page;
    page-break-before: always;
  }

  thead {
    display: table-header-group;
  }
}
