@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;800&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --color-primario:    #1a3a5c;
  --color-secundario:  #2d8c1e;
  --color-fondo:       #f0f2f5;
  --color-sidebar:     #111f2e;
  --color-texto:       #2c2c2c;
  --color-acento:      #c1622d;
  --color-alerta:      #a63d3d;
  --color-panel:       #eef1f6;
  --color-grid:        rgba(26,58,92,.08);
  --sidebar-ancho:     240px;
}
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--color-fondo);
  color: var(--color-texto);
  margin: 0;
  font-size: 0.925rem;
}
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f2f5;
}
.login-card {
  background: #fff;
  border-radius: 4px;
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
  border-top: 3px solid var(--color-primario);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo-img {
  max-width: 200px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 0.5rem;
}
.login-logo p {
  color: #6c757d;
  font-size: 0.8rem;
  margin: 0.4rem 0 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-ancho);
  background: var(--color-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}
.sidebar-header {
  padding: 1.3rem 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.marca-sub {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}
.marca-nombre {
  display: inline-block;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  text-transform: none;
  padding-bottom: 0.1rem;
  line-height: 1;
}
.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; min-height: 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}
.sidebar-nav a:hover, .sidebar-nav a.activo {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.sidebar-nav a.activo { border-left: 3px solid var(--color-secundario); }
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}
.sidebar-footer #nombre-usuario {
  color: rgba(255,255,255,0.8);
  font-weight: 600;
  display: block;
  margin-bottom: 0.5rem;
}
/* min-width: 0: un hijo flex no se encoge por debajo de su contenido; sin esto una
   tabla ancha ensanchaba la pagina entera (botones y columnas fuera de la ventana)
   en vez de desplazarse dentro de su .table-responsive. */
.main-content { margin-left: var(--sidebar-ancho); flex: 1; min-width: 0; padding: 1.5rem 2rem; }
/* Etiqueta que puede partirse en varias lineas (nombres largos de equipo). */
.badge-ajustable { white-space: normal; text-align: left; line-height: 1.3; }
/* Celdas de acciones (botones sueltos o en grupo): los botones van en una sola
   linea. Con .main-content en min-width: 0 la tabla ya no ensancha la pagina y el
   navegador angostaba esta columna, apilando los botones y estirando cada fila. */
.table td:has(> .btn), .table td:has(> .btn-group), .table td:has(> div > .btn) { white-space: nowrap; }
.table td > .d-flex:has(> .btn) { flex-wrap: nowrap !important; }
/* Tabla mas ancha que su recuadro (Maquinaria en laptop: los numeros de chasis y
   las 11 columnas no entran): la columna de acciones queda fija al borde derecho
   para que los botones se vean sin desplazar la tabla. */
@media (min-width: 768px) {
  .table-responsive > .table:has(tbody td:last-child .btn) > * > tr > :last-child {
    position: sticky; right: 0; z-index: 1;
    box-shadow: inset 0 0 0 9999px var(--bs-table-bg-state, var(--bs-table-bg-type, transparent)),
      inset 1px 0 0 #dee2e6, -6px 0 8px -6px rgba(0, 0, 0, 0.18);
  }
}
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.topbar h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-primario);
  margin: 0;
  letter-spacing: 0.01em;
}
.metricas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin-bottom: 1.5rem; }
.metrica-card {
  background: #fff; border-radius: 14px;
  padding: 2rem 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border-top: 4px solid var(--color-primario);
  text-align: center;
}
.metrica-card .numero {
  display: block;
  font-size: 3rem; font-weight: 800;
  color: var(--color-primario); line-height: 1;
  margin-bottom: 0.5rem;
}
.metrica-card .etiqueta {
  display: block;
  font-size: 0.78rem; color: #888;
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em;
}
.metrica-card.alerta { border-top-color: #dc3545; }
.metrica-card.alerta .numero { color: #dc3545; }
.metrica-card.ok     { border-top-color: #28a745; }
.metrica-card.ok .numero  { color: #28a745; }
.metrica-card.warn   { border-top-color: #e8a020; }
.metrica-card.warn .numero { color: #e8a020; }
.tabla-wrapper { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); overflow: hidden; }
.tabla-wrapper .tabla-header { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid #eee; }
.tabla-wrapper .tabla-header h5 { margin: 0; font-weight: 600; color: var(--color-primario); }
/* Grupo de filtros del encabezado: en pantallas angostas pasa a varias lineas. */
.tabla-wrapper .tabla-header > .d-flex { flex-wrap: wrap; }

/* ── Masthead de analisis (modulo Reportes) ─────────────── */
.masthead-reporte {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 1.1rem 1.5rem;
  margin-bottom: 1.25rem;
  border-radius: 10px;
  border-left: 4px solid var(--color-primario);
  background-color: var(--color-panel);
  background-image:
    repeating-linear-gradient(0deg, var(--color-grid) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(90deg, var(--color-grid) 0 1px, transparent 1px 24px);
}
.masthead-reporte .eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-acento);
  margin-bottom: 0.15rem;
}
.masthead-reporte h2 {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--color-primario);
  line-height: 1;
}
.masthead-reporte .timestamp {
  font-size: 0.78rem;
  color: #6b7686;
  white-space: nowrap;
}
.masthead-reporte .timestamp strong { color: var(--color-primario); font-weight: 600; }

/* ── Chart cards (modulo Reportes) ───────────────────────── */
.chart-card-header {
  background: #fff;
  border-bottom: 1px solid #eee;
  font-weight: 600;
  color: var(--color-primario);
  padding: 0.85rem 1.25rem;
}

/* ── Divisor hairline (modulo Reportes) ──────────────────── */
.divisor-hairline {
  height: 1px;
  background-color: rgba(26,58,92,.16);
  margin: 0.25rem 0 1.25rem;
}

/* ── Numeros tabulares (modulo Reportes) ─────────────────── */
.num-tabular { font-variant-numeric: tabular-nums; }

/* ── Entrada escalonada de tarjetas KPI (modulo Reportes) ── */
@keyframes tarjetaEntrada {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.metrica-card.entrada { animation: tarjetaEntrada 0.28s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .metrica-card.entrada { animation: none; }
  .metrica-card, .metrica-card:hover { transition: none; }
}

.badge-activa     { background: #d4edda; color: #155724; }
.badge-pausada    { background: #fff3cd; color: #856404; }
.badge-completada { background: #cce5ff; color: #004085; }
.badge-problema   { background: #f8d7da; color: #721c24; }
#mapa { height: 500px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
/* Leyenda bajo el mapa del dashboard (obras por estatus + almacenes por tipo) */
.mapa-leyenda { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; align-items: center; margin-top: 0.75rem; font-size: 0.82rem; color: #555; }
.mapa-leyenda .leyenda-grupo { font-weight: 600; color: #333; }
.mapa-leyenda .leyenda-pin { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: -1px; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.35); }
.mapa-leyenda .leyenda-pin.circulo  { border-radius: 50%; }
.mapa-leyenda .leyenda-pin.cuadrado { border-radius: 3px; }
/* Los avisos dejan pasar los clics (2026-10-14): un aviso persistente tapaba
   botones ("Reportar Avería", el pie de los modales) y el clic no llegaba. Solo
   la X de cerrar los recibe. Arriba al centro: a la derecha caia encima de
   "Reportar Avería" y abajo encima del pie de los modales (sus botones). */
#toast-container { position: fixed; top: .75rem; left: 50%; right: auto; bottom: auto; transform: translateX(-50%); z-index: 9999; width: min(380px, calc(100vw - 2rem)); pointer-events: none; }
#toast-container .toast { pointer-events: none; }
#toast-container .btn-close { pointer-events: auto; }

/* ── Hover en tarjetas ──────────────────────────────────── */
.metrica-card { transition: transform 0.15s, box-shadow 0.15s; }
.metrica-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.12); }

/* ── Barra superior y menu en pantallas angostas (< 992 px) ─────────────
   La barra, la hamburguesa y el boton de cerrar los genera layout.py; el
   comportamiento (aria-expanded, Escape, foco) esta en nucleo/sesion.ts. */
.barra-movil {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--color-sidebar);
  align-items: center;
  padding: 0 .75rem;
  gap: 0.6rem;
  z-index: 300;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.barra-movil-marca {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
  flex-shrink: 0;
}
.barra-movil-empresa {
  min-width: 0; margin-left: auto;
  color: rgba(255,255,255,.75); font-size: .82rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-hamburguesa {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.9);
  font-size: 1.45rem;
  width: 44px; height: 44px;
  line-height: 1;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-hamburguesa:hover { background: rgba(255,255,255,0.12); }
.btn-hamburguesa:focus-visible { background: rgba(255,255,255,0.12); outline: 2px solid #fff; outline-offset: -2px; }

/* Boton X dentro de la cabecera del menu (solo pantallas angostas) */
.btn-cerrar-sidebar {
  display: none;
  position: absolute;
  top: 0.8rem; right: 0.75rem;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 6px;
  color: rgba(255,255,255,0.75);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.btn-cerrar-sidebar:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ── Fondo oscuro detras del menu abierto ──────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 52px; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
}
.sidebar-overlay.activo { display: block; }

/* ── Soporte para modales apilados ──────────────────────── */
.modal-backdrop + .modal-backdrop { z-index: 1059; }

/* ── Centrar modales respecto al sidebar (solo con el menu fijo) ───────── */
@media (min-width: 992px) {
  .modal {
    left: var(--sidebar-ancho);
    width: calc(100% - var(--sidebar-ancho));
  }
}

/* ── Pantallas angostas: menu desplegable ───────────────── */
@media (max-width: 991.98px) {
  .barra-movil { display: flex; }

  /* Menu: arranca bajo la barra, fuera de la pantalla y fuera del orden de tabulacion */
  .sidebar {
    top: 52px;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
    width: min(var(--sidebar-ancho), 85vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.26s ease, visibility 0s linear 0.26s;
    z-index: 250;
  }
  .sidebar.sidebar-abierto { transform: translateX(0); visibility: visible; transition: transform 0.26s ease; }
  .sidebar-nav a { min-height: 44px; }
  .sidebar-header { position: relative; padding-right: 3.5rem; }
  .btn-cerrar-sidebar { display: inline-flex; }
  body.menu-movil-abierto { overflow: hidden; }

  /* Contenido a todo el ancho, bajo la barra */
  .main-content {
    margin-left: 0;
    padding: 1rem 1.25rem;
    padding-top: calc(52px + 1rem);
  }
  .topbar { margin-bottom: 1rem; gap: 0.5rem; flex-wrap: wrap; }
  #toast-container { top: calc(52px + .5rem); }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar.sidebar-abierto { transition: none; }
}

@media (max-width: 768px) {
  .topbar h1 { font-size: 1.1rem; }
  .metricas { grid-template-columns: 1fr; }
  #mapa { height: 280px; }
}
@media (max-width: 575.98px) {
  .main-content { padding: calc(52px + .75rem) .75rem 1rem; }
}

/* ── Esconder el menu para trabajar a pantalla completa (2026-10-14) ──── */
.sidebar-header { position: relative; }
.btn-esconder-menu {
  position: absolute; top: 1.15rem; right: .7rem;
  width: 30px; height: 30px; border: none; border-radius: 6px;
  background: transparent; color: rgba(255,255,255,.55);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.btn-esconder-menu:hover { background: rgba(255,255,255,.12); color: #fff; }
.btn-mostrar-menu {
  position: fixed; top: .85rem; left: .7rem; z-index: 150;
  width: 36px; height: 36px; border: 1px solid #d5dbe3; border-radius: 8px;
  background: #fff; color: var(--color-primario); font-size: 1.15rem;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(17,31,46,.12);
}
.btn-mostrar-menu:hover { background: var(--color-primario); color: #fff; border-color: var(--color-primario); }
@media (min-width: 992px) {
  html.menu-animado .sidebar { transition: transform .25s ease; }
  html.menu-animado .main-content { transition: margin-left .25s ease, padding-left .25s ease; }
  html.menu-oculto .sidebar { transform: translateX(-100%); }
  html.menu-oculto .main-content { margin-left: 0; padding-left: 3.75rem; }
  html.menu-oculto .modal { left: 0; width: 100%; }
  html.menu-oculto .btn-mostrar-menu { display: inline-flex; }
}
@media (max-width: 991.98px) {
  .btn-esconder-menu, .btn-mostrar-menu { display: none !important; }
}

/* ── Facturacion ───────────────────────────────────────── */
.login-marca { font-family: 'Playfair Display', serif; font-size: 2rem; font-weight: 800; color: var(--color-primario); }
.login-marca .bi { color: var(--color-secundario); }
.btn-primary { background: var(--color-primario); border-color: var(--color-primario); }
.btn-primary:hover, .btn-primary:focus { background: #142d48; border-color: #142d48; }
.doc-descripcion { max-width: 520px; }
.zona-arrastre { border: 2px dashed #c5ccd6; border-radius: 10px; padding: 1.5rem 1rem; text-align: center; cursor: pointer; color: #555; transition: background .15s, border-color .15s; }
.zona-arrastre .bi { font-size: 2rem; color: var(--color-primario); }
.zona-arrastre:hover, .zona-arrastre:focus-visible, .zona-arrastre.arrastrando { background: #eaf1fb; border-color: var(--color-primario); outline: none; }
.filtros-docs #filtro-texto { width: 220px; }
.filtros-docs #filtro-categoria { width: 260px; }
@media (max-width: 768px) {
  .topbar { flex-wrap: wrap; }
  .filtros-docs { width: 100%; flex-wrap: wrap; }
  .filtros-docs #filtro-texto, .filtros-docs #filtro-categoria { width: 100%; flex: 1 1 100%; }
}

/* ── Empresas ──────────────────────────────────────────── */
.empresa-activa { display: block; margin: .75rem 1rem 0; padding: .5rem .75rem; border-radius: 8px; background: rgba(255,255,255,.07); color: #fff; text-decoration: none; line-height: 1.25; }
.empresa-activa:hover { background: rgba(255,255,255,.14); color: #fff; }
.empresa-activa.sin-cambio, .empresa-activa.sin-cambio:hover { background: rgba(255,255,255,.07); cursor: default; }
.empresa-activa small { display: block; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.empresa-activa span { display: block; font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-empresas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.tarjeta-empresa { display: flex; flex-direction: column; gap: .35rem; text-align: left; padding: 1.1rem 1.25rem; background: #fff; border: 1px solid #e3e7ec; border-left: 4px solid var(--color-primario); border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.05); transition: box-shadow .15s, transform .15s; }
.tarjeta-empresa:hover { box-shadow: 0 6px 18px rgba(0,0,0,.1); transform: translateY(-1px); }
.tarjeta-empresa:focus-visible { outline: 2px solid var(--color-primario); outline-offset: 2px; }
.tarjeta-empresa.activa { border-left-color: var(--color-secundario); }
.te-nombre { font-weight: 700; color: var(--color-primario); font-size: 1.02rem; }
.te-rnc { color: #6c757d; font-size: .85rem; }
.te-etiquetas { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .25rem; }
.estado-vacio { grid-column: 1 / -1; text-align: center; color: #6c757d; padding: 3rem 1rem; background: #fff; border-radius: 10px; }
.estado-vacio .bi { font-size: 2.2rem; color: #c5ccd6; display: block; margin-bottom: .5rem; }
.metricas-5 { grid-template-columns: repeat(5, 1fr); }
.tabla-con-tabs { border-top-left-radius: 0; }
.sel-rol { min-width: 150px; }
@media (max-width: 1100px) { .metricas-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .metricas-5 { grid-template-columns: repeat(2, 1fr); } }
.fila-inactiva td { opacity: .55; }

/* ── Comprobantes ──────────────────────────────────────── */
.fila-enlace { cursor: pointer; }
.tabla-lineas td { padding: .35rem .5rem; }
.tabla-lineas .col-num { width: 120px; }
.tabla-lineas td:first-child { min-width: 220px; }
.tabla-lineas input[type=number] { text-align: right; }
.tabla-totales td { padding: .45rem 1rem; }
.tabla-totales .fila-total td { font-weight: 700; font-size: 1.15rem; color: var(--color-primario); border-top: 2px solid var(--color-primario); }
#agregar-producto { min-width: 260px; }
.linea-tiempo { list-style: none; padding-left: 1rem; margin: 0; border-left: 2px solid #dbe2ea; }
.linea-tiempo li { position: relative; padding: 0 0 .7rem .75rem; }
.linea-tiempo li::before { content: ""; position: absolute; left: -1.42rem; top: .35rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--color-primario); }
.linea-tiempo li:last-child::before { background: var(--color-secundario); }
.consentimiento { background: #f6f8fa; border-radius: 8px; padding: .75rem .75rem .75rem 2.2rem; }

/* ── Activacion DGII ───────────────────────────────────── */
.progreso-alta { height: .6rem; }
.progreso-alta .progress-bar { background: var(--color-secundario); }
.etapa-numero { display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; margin-right: .6rem; border-radius: 50%; background: var(--color-primario); color: #fff; font-size: .85rem; }
.paso-alta { display: flex; align-items: flex-start; gap: .85rem; padding: .8rem 1.25rem; }
.paso-icono { font-size: 1.15rem; margin-top: .1rem; }
.min-w-0 { min-width: 0; }

/* ── Caja ─────────────────────────────────────────────────────────────────── */
.tarjeta-caja { max-width: 380px; margin-top: 4rem; background: #fff; border-radius: 8px; padding: 1.5rem;
  border-top: 4px solid var(--color-primario); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.caja-resultados { position: absolute; z-index: 20; left: 0; right: 0; max-height: 320px; overflow-y: auto;
  box-shadow: 0 6px 16px rgba(0,0,0,.15); }
.caja-carrito .col-cant { width: 110px; }
.caja-carrito .col-desc { width: 90px; }
.caja-total { font-size: 1.75rem; font-weight: 700; color: var(--color-primario); }
.caja-cambio { font-size: 1.6rem; font-weight: 700; color: var(--color-secundario); }
.caja-impresion { position: fixed; width: 0; height: 0; border: 0; visibility: hidden; }

/* ── Configuracion fiscal ─────────────────────────────────────────────────── */
.logo-vista { width: 140px; height: 70px; background: #fff; overflow: hidden; }
.logo-vista img { max-width: 100%; max-height: 100%; }
.pasos-ambiente { display: flex; gap: .75rem; flex-wrap: wrap; }
.paso-ambiente { flex: 1 1 200px; border: 1px solid #dee2e6; border-radius: 8px; padding: .75rem 1rem; background: #fff; }
.paso-ambiente.actual { border: 2px solid var(--color-secundario); background: #f3faf1; }
.paso-ambiente .titulo { font-weight: 600; color: var(--color-primario); }
.datos-emisor dt { font-size: .75rem; color: #6c757d; font-weight: 600; }
.datos-emisor dd { margin-bottom: .5rem; }

/* ── Resumen ──────────────────────────────────────────────────────────────── */
.kpi-resumen { container-type: inline-size; background: #fff; border-radius: 8px; padding: 1rem 1.1rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.kpi-principal { border-top: 4px solid var(--color-primario); display: flex; flex-direction: column; justify-content: center; }
.kpi-titulo { font-size: .8rem; color: #6c757d; font-weight: 600; }
.kpi-hero { font-size: clamp(1.4rem, 11cqi, 2.6rem); font-weight: 700; color: var(--color-primario); line-height: 1.15; margin-top: .25rem; white-space: nowrap; }
.kpi-valor { font-size: clamp(.95rem, 11.5cqi, 1.2rem); font-weight: 600; color: var(--color-texto); margin-top: .25rem; white-space: nowrap; }
.resumen .tabla-wrapper h5 { font-weight: 700; color: var(--color-primario); font-size: 1.1rem; }
.kpi-detalle { font-size: .75rem; color: #6c757d; }
.alerta-resumen { font-size: .85rem; padding: .45rem .7rem; }
.grafico-dias .columna { fill: #2f6db0; }
.grafico-dias .columna.negativa { fill: #2f6db0; opacity: .45; }
.grafico-dias .eje-linea { stroke: #e9ecef; stroke-width: 1; }
.grafico-dias .eje-cero { stroke: #adb5bd; }
.grafico-dias .eje-texto { fill: #6c757d; font-size: 11px; }
.grafico-dias .zona { fill: transparent; cursor: default; }
.grafico-dias .zona:hover { fill: rgba(47,109,176,.06); }
.grafico-tooltip { position: fixed; z-index: 1080; pointer-events: none; background: #fff; color: var(--color-texto);
  border: 1px solid #dee2e6; border-radius: 6px; padding: .4rem .6rem; font-size: .8rem; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.barra-fila { margin-bottom: .65rem; }
.barra-pista { height: 8px; background: #eef2f7; border-radius: 4px; margin-top: .25rem; }
.barra-relleno { height: 100%; background: #2f6db0; border-radius: 4px; }

/* ── Inventario ───────────────────────────────────────────────────────────── */
.kpi-inv { container-type: inline-size; background: #fff; border: 0; border-radius: 8px; padding: 1rem 1.1rem; text-align: left;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); color: inherit; }
button.kpi-inv:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
button.kpi-inv.activo { outline: 2px solid #2f6db0; }
.kpi-inv.kpi-principal { border-top: 4px solid var(--color-primario); }
.inv-barra { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .85rem 1rem; border-bottom: 1px solid #e9ecef; }
.inv-estados .nav-link { padding: .3rem .8rem; font-size: .9rem; }
.inv-buscar { width: 240px; }
.inv-tabla th[data-orden] { cursor: pointer; user-select: none; white-space: nowrap; }
.inv-tabla th[data-orden]::after { content: ""; display: inline-block; width: 1em; }
.inv-tabla th[data-direccion="asc"]::after { content: " ▲"; font-size: .7em; }
.inv-tabla th[data-direccion="desc"]::after { content: " ▼"; font-size: .7em; }
.inv-tabla .fila-producto { cursor: pointer; }
.inv-mini { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex: 0 0 40px; background: #f1f3f5; }
.inv-mini-vacia { display: inline-flex; align-items: center; justify-content: center; color: #adb5bd; }
.inv-detalle { --bs-offcanvas-width: 460px; }
.det-foto { width: 120px; height: 120px; display: flex; align-items: center; justify-content: center;
  background: #f8f9fa; overflow: hidden; flex: 0 0 120px; font-size: 2rem; }
.det-foto img { width: 100%; height: 100%; object-fit: cover; }
.det-cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem .75rem; }
.det-cifra-titulo { font-size: .72rem; color: #6c757d; font-weight: 600; }
.det-cifra { font-weight: 600; }
.det-linea .linea-serie { fill: none; stroke: #2f6db0; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.det-linea .linea-cero { stroke: #e9ecef; stroke-width: 1; }
.det-linea .linea-punto { fill: #2f6db0; stroke: #fff; stroke-width: 2; }
.det-bloque { background: #f8f9fa; border-radius: 8px; padding: .75rem; }
.det-mov { padding: .45rem 0; border-bottom: 1px solid #f1f3f5; }
.conteo-col { width: 140px; }

/* ── Notas (Documentacion) ────────────────────────────────────────────────── */
.nota-markdown { line-height: 1.55; }
.nota-markdown h4 { color: var(--color-primario); font-weight: 700; }
.nota-markdown h5 { color: var(--color-primario); font-weight: 700; margin-top: 1.25rem; }
.nota-markdown li { margin-bottom: .25rem; }
.nota-markdown table { font-size: .9rem; }

/* Pulido visual (2026-10-18): nombre largo en tablas anchas sin partirlo palabra por palabra */
.col-nombre { min-width: 13rem; }
.col-texto { min-width: 10rem; }
/* Ventanas bajas (1366x768, 1024x768): el menu completo cabe sin desplazarse */
@media (min-width: 992px) and (max-height: 820px) {
  .sidebar-header { padding: .9rem 1.25rem .75rem; }
  .sidebar-nav { padding: .4rem 0; }
  .sidebar-nav a { padding: .5rem 1.25rem; }
  .sidebar-footer { padding: .6rem 1rem; }
}

/* ══ Responsive: patrones comunes (2026-10-19, ver docs/FRONTEND.md "Responsive") ══ */

/* Montos sin partir en dos lineas */
.table td.text-end, .table th.text-end { white-space: nowrap; }

/* Tablas anchas: siempre con desplazamiento lateral dentro de su recuadro, nunca de la pagina */
.table-responsive { -webkit-overflow-scrolling: touch; }
.tabla-ancha { overflow-x: auto; }
.tabla-ancha > .table > :not(caption) > tr > :first-child { position: sticky; left: 0; z-index: 1;
  box-shadow: inset 0 0 0 9999px var(--bs-table-bg-state, var(--bs-table-bg-type, var(--bs-table-bg))), inset -1px 0 0 #dee2e6; }

/* Pestanas con muchas opciones: se desplazan de lado sin partirse */
@media (max-width: 767.98px) {
  .nav-tabs, .nav-pills { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
  .nav-tabs .nav-link, .nav-pills .nav-link { white-space: nowrap; }
  .nav-tabs > .nav-item, .nav-pills > .nav-item, .nav-tabs > .nav-link, .nav-pills > .nav-link { flex-shrink: 0; }
}

/* Cabecera de la pagina y barras de filtros: se acomodan en varias lineas */
.topbar > .d-flex, .topbar > div:not(:first-child) { flex-wrap: wrap; }
@media (max-width: 575.98px) {
  .topbar { align-items: flex-start; }
  .topbar > .d-flex, .topbar > div:not(:first-child) { width: 100%; gap: .5rem !important; }
  /* Botones secundarios de la cabecera: solo el icono (el texto queda en title/aria-label) */
  .topbar .btn.solo-icono-movil .btn-texto { display: none; }
  .topbar .btn.solo-icono-movil > .bi { margin: 0 !important; }
  .topbar .btn.solo-icono-movil { min-width: 44px; }
  .topbar .btn[data-responsive]:not(.solo-icono-movil) { flex: 1 1 auto; }
  .tabla-wrapper .tabla-header { padding: .75rem; }
  .tabla-wrapper .tabla-header > .d-flex,
  .tabla-wrapper .tabla-header > div:not(:first-child) { width: 100%; }
}

/* Tamanos tactiles en celular */
@media (max-width: 575.98px) {
  .btn:not(.btn-close):not(.btn-link):not(.btn-ficha) { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .btn.d-block, .btn.w-100 { display: flex; }
  .form-control, .form-select { min-height: 40px; }
  .btn-close { width: 1.25rem; height: 1.25rem; padding: .6rem; }
  .form-check-input { width: 1.2em; height: 1.2em; }
  .nav-link { min-height: 40px; display: flex; align-items: center; }
}

/* Ventanas emergentes: pantalla completa en celular; los paneles laterales a todo el ancho */
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-sm) { width: 100vw; max-width: none; min-height: 100%; margin: 0; }
  .modal-dialog:not(.modal-sm) > .modal-content { min-height: 100vh; min-height: 100dvh; border: 0; border-radius: 0; }
  .modal-dialog:not(.modal-sm) .modal-header, .modal-dialog:not(.modal-sm) .modal-footer { border-radius: 0; }
  .modal-dialog:not(.modal-sm) .modal-footer { position: sticky; bottom: 0; background: #fff; z-index: 2; }
  .modal-footer { flex-wrap: wrap; }
  .offcanvas.offcanvas-end, .offcanvas.offcanvas-start { --bs-offcanvas-width: 100vw; width: 100vw !important; }
}

/* Listados en tarjetas en celular: <table class="tabla-tarjetas">; ui/responsive.ts pone
   data-label en cada celda con el texto de su encabezado. La primera celda es el titulo. */
@media (max-width: 575.98px) {
  .table-responsive:has(> .tabla-tarjetas) { overflow-x: visible; }
  .tabla-tarjetas { display: block; width: 100%; }
  .tabla-tarjetas > thead { display: none; }
  .tabla-tarjetas > tbody, .tabla-tarjetas > tfoot { display: block; }
  .tabla-tarjetas > tbody > tr, .tabla-tarjetas > tfoot > tr { display: block; padding: .6rem .85rem; border-bottom: 1px solid #e3e7ec; }
  .tabla-tarjetas > tbody > tr:last-child { border-bottom: 0; }
  .tabla-tarjetas > tbody > tr > td, .tabla-tarjetas > tfoot > tr > td {
    display: flow-root; border: 0; padding: .2rem 0; min-width: 0 !important; width: auto !important;
    text-align: right; white-space: normal; box-shadow: none;
  }
  .tabla-tarjetas > tbody > tr > td::before, .tabla-tarjetas > tfoot > tr > td::before {
    content: attr(data-label); float: left; max-width: 45%; margin-right: .75rem; text-align: left;
    font-size: .8rem; font-weight: 600; color: #6c757d; white-space: normal;
  }
  .tabla-tarjetas > tbody > tr > td[data-label=""]::before,
  .tabla-tarjetas > tbody > tr > td:not([data-label])::before,
  .tabla-tarjetas > tbody > tr > td:first-child::before { content: none; }
  .tabla-tarjetas > tbody > tr > td:first-child { text-align: left; font-weight: 600; padding-bottom: .35rem; }
  .tabla-tarjetas > tbody > tr > td:first-child > * { font-weight: normal; }
  .tabla-tarjetas > tbody > tr > td:first-child > strong, .tabla-tarjetas > tbody > tr > td:first-child > b,
  .tabla-tarjetas > tbody > tr > td:first-child > a, .tabla-tarjetas > tbody > tr > td:first-child > .btn-ficha { font-weight: 600; }
  .tabla-tarjetas > tbody > tr > td[colspan] { text-align: center; }
  .tabla-tarjetas > tbody > tr > td[colspan]::before { content: none; }
  .tabla-tarjetas > tbody > tr > td:empty { display: none; }
  /* Celda de acciones: botones juntos, a la derecha, pueden pasar a otra linea */
  .tabla-tarjetas td:has(> .btn), .tabla-tarjetas td:has(> .btn-group), .tabla-tarjetas td:has(> div > .btn) { white-space: normal; padding-top: .4rem; }
  .tabla-tarjetas td > .d-flex:has(> .btn) { flex-wrap: wrap !important; justify-content: flex-end; }
  .tabla-tarjetas > tbody > tr > td:first-child > .d-flex { justify-content: flex-start; }
  .tabla-tarjetas .form-control, .tabla-tarjetas .form-select { display: inline-block; width: 60%; min-width: 0 !important; }
  .tabla-tarjetas .input-group { display: inline-flex; width: 60%; }
  .tabla-tarjetas .input-group .form-control { width: 1%; }
}

/* Monitores grandes: el contenido no se estira de mas */
@media (min-width: 1600px) {
  .main-content:not(.caja) > :not(.modal):not(.offcanvas):not(script) { max-width: 1560px; margin-left: auto; margin-right: auto; }
}
@media (max-width: 575.98px) {
  .tabla-tarjetas > tbody > tr > td:first-child .form-control, .tabla-tarjetas > tbody > tr > td:first-child .form-select,
  .tabla-tarjetas > tbody > tr > td:first-child .input-group { width: 100%; }
}
/* Barras de filtros en celular: cada filtro ocupa la linea o se reparte con su par */
@media (max-width: 575.98px) {
  .inv-buscar, .cxc-buscar, .filtros-docs input[type=search], .filtros-docs input[type=text] { width: 100% !important; }
  :is(.inv-barra, .cxc-barra, .tabla-header) :is(.form-control, .form-select):not([type=checkbox]) { flex: 1 1 9rem; width: auto !important; min-width: 0; }
  :is(.inv-barra, .cxc-barra, .tabla-header) :is(input[type=search], input[type=text]) { flex-basis: 100%; }
  :is(.inv-barra, .cxc-barra) > * { max-width: 100%; }
  :is(.inv-barra, .cxc-barra) > .d-flex, :is(.inv-barra, .cxc-barra) > div:not(.form-check):not(.form-switch) { width: 100%; flex-wrap: wrap; }
}
/* Laptop: listados de muchas columnas (Compras, Inventario) caben sin desplazarse */
@media (min-width: 992px) and (max-width: 1499.98px) {
  .col-nombre { min-width: 11rem; }
  .col-texto { min-width: 8.5rem; }
  .inv-tabla > :not(caption) > * > * { padding-left: .4rem; padding-right: .4rem; }
}
@media (max-width: 575.98px) {
  .login-wrapper { padding: 1rem .75rem; }
  .login-card { padding: 2rem 1.25rem; }
}
/* Indicadores grandes (.metricas) compactos en celular y tablet vertical */
@media (max-width: 767.98px) {
  .metricas, .metricas-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .metrica-card { padding: .85rem .75rem; border-radius: 10px; }
  .metrica-card .numero { font-size: 1.9rem; margin-bottom: .25rem; }
  .metrica-card .etiqueta { font-size: .7rem; }
}
/* Cifras de los paneles laterales (Compras, Inventario): montos en una linea */
.det-cifra { white-space: nowrap; }
@media (max-width: 400px) { .det-cifras { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) {
  .btn:not(.btn-close):not(.btn-link):not(.btn-ficha) { min-width: 40px; }
}
