/* ==========================================================================================================
   ESTRUCTURA NUEVA estilo Mercury (19-nov-2026, el usuario: "cambia absolutamente todo el diseño de la página,
   posiciones; pon a tu gusto todo con el diseño que te pasé" — referencia refero.design / mercury.com).
   PC (1100 px o más): MENÚ LATERAL FIJO a la izquierda con toda la navegación (Inicio, cada app abierta con sus
   módulos y sus páginas) y la cuenta abajo; el contenido ocupa el resto, con el título de la página arriba.
   La fila de botones de arriba ya no hace falta en PC (todo está en el lateral). En celular sigue la barra con ☰.
   Solo aplica con html.tema (_cabeza.html). Los datos del menú: principal/plantillas.py (MOD, ESPACIOS, permisos).
   ========================================================================================================== */
:root { --lat: 264px; }

@media screen and (min-width: 1100px) {
  /* ---------------------------------------------------------------- el lateral */
  html.tema .barra-superior { position: fixed !important; top: 0; left: 0; bottom: 0; width: var(--lat); z-index: 70;
    background: rgb(255 255 255 / 0.42) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
    border-right: 1px solid rgb(26 28 51 / 0.07) !important; border-bottom: 0 !important; overflow: visible; }
  html.tema body { padding-left: var(--lat); }
  html.tema .tb-fila { flex-direction: column; align-items: stretch; height: 100%; max-width: none; margin: 0; padding: 1.1rem 0.85rem 0.9rem; gap: 0.4rem; min-height: 0; }
  html.tema .tb-marca { padding: 0.15rem 0.35rem 0.9rem; flex-shrink: 0; }
  html.tema .tb-marca .marca-logo { box-shadow: none !important; }
  html.tema .tb-marca .marca-logo img { height: 2rem; }
  html.tema .tb-titulo { display: none; }

  /* la navegación: Inicio y cada app; la app actual queda abierta con sus módulos y páginas */
  html.tema .tb-menu { display: flex; flex-direction: column; gap: 0.1rem; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    margin: 0 -0.35rem; padding: 0 0.35rem; scrollbar-width: thin; }
  html.tema .tb-menu-cab { display: block; font-size: 0.72rem; font-weight: 500; color: #8A8FA3; padding: 0.6rem 0.65rem 0.35rem; letter-spacing: 0; text-transform: none; }
  html.tema .tb-item { width: 100%; color: #2C3048 !important; font-weight: 500; font-size: 0.9rem; padding: 0.5rem 0.65rem; border-radius: 0.65rem; background: transparent !important; }
  html.tema .tb-item:hover, html.tema .tb-grupo[open] > .tb-item { background-color: rgb(26 28 51 / 0.05) !important; color: #1A1C33 !important; }
  html.tema .tb-item.activo { background: #fff !important; color: #1A1C33 !important; box-shadow: 0 1px 2px rgb(26 28 51 / 0.08); }
  html.tema .tb-item.activo::after { display: none; }
  html.tema .tb-item .tb-ico { color: #5B6170; }
  html.tema .tb-item.activo .tb-ico { color: #040677; }
  html.tema .tb-item .tb-flecha { margin-left: auto; }
  html.tema .tb-menu .tb-panel { position: static; width: auto !important; background: transparent !important; box-shadow: none !important; border: 0 !important;
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important; padding: 0.15rem 0 0.5rem !important; border-radius: 0 !important; animation: none; }
  html.tema .tb-menu .tb-panel::before { display: none; }
  html.tema .tb-menu .tb-panel-cab { border: 0; margin: 0; padding: 0 0 0.2rem 2.35rem; }
  html.tema .tb-menu .tb-panel-cab strong { display: none; }
  html.tema .tb-menu .tb-resumen { background: transparent !important; color: #5B6170 !important; padding: 0.25rem 0; font-weight: 500; font-size: 0.8rem; }
  html.tema .tb-menu .tb-resumen:hover { color: #1A1C33 !important; }
  html.tema .tb-menu .tb-modulos { grid-template-columns: 1fr; gap: 0; }
  html.tema .tb-menu .tb-modulo { padding: 0; border-radius: 0.6rem; background: transparent !important; box-shadow: none !important; }
  html.tema .tb-menu .tb-modulo-cab { align-items: center; gap: 0.55rem; padding: 0.38rem 0.65rem 0.38rem 0.95rem; border-radius: 0.6rem; }
  html.tema .tb-menu .tb-modulo-cab:hover { background: rgb(26 28 51 / 0.05); }
  html.tema .tb-menu .tb-modulo-cab .tb-ico { width: 1.15rem; height: 1.15rem; background: transparent !important; color: #8A8FA3 !important; border-radius: 0; }
  html.tema .tb-menu .tb-modulo-cab .tb-ico svg { width: 1rem; height: 1rem; }
  html.tema .tb-menu .tb-modulo-cab strong { font-size: 0.86rem; font-weight: 500; color: #2C3048; }
  html.tema .tb-menu .tb-modulo-cab small { display: none; }
  html.tema .tb-menu .tb-modulo.activo > .tb-modulo-cab strong { color: #1A1C33; font-weight: 600; }
  html.tema .tb-menu .tb-modulo.activo > .tb-modulo-cab .tb-ico { color: #040677 !important; }
  html.tema .tb-menu .tb-paginas { flex-direction: column; flex-wrap: nowrap; gap: 0; margin: 0.05rem 0 0.3rem 2.1rem; padding-left: 0.6rem; border-left: 1px solid rgb(26 28 51 / 0.1); }
  html.tema .tb-menu .tb-paginas a { display: block; background: transparent !important; color: #5B6170 !important; font-weight: 500; font-size: 0.8rem;
    padding: 0.28rem 0.55rem; border-radius: 0.45rem; }
  html.tema .tb-menu .tb-paginas a:hover { background-color: rgb(26 28 51 / 0.05) !important; color: #1A1C33 !important; }
  html.tema .tb-menu .tb-paginas a.activa { color: #1A1C33 !important; background: #fff !important; box-shadow: 0 1px 2px rgb(26 28 51 / 0.08); }
  /* las páginas solo se ven en el módulo donde está la persona (el lateral no se vuelve una lista eterna) */
  html.tema .tb-menu .tb-modulo:not(.activo) .tb-paginas { display: none; }
  html.tema .tb-menu .tb-modulos.uno .tb-modulo .tb-paginas { display: flex; }

  /* la cuenta y las acciones, abajo del lateral */
  html.tema .tb-acciones { flex-wrap: wrap; margin: 0; padding-top: 0.75rem; border-top: 1px solid rgb(26 28 51 / 0.08); gap: 0.4rem; flex-shrink: 0; }
  html.tema .tb-reloj { display: none !important; }
  html.tema .tb-acciones .barra-cuenta { order: 10; flex: 1 1 100%; }
  html.tema .tb-acciones .barra-usuario { width: 100%; justify-content: flex-start; gap: 0.6rem; padding: 0.4rem 0.5rem !important; border-radius: 0.7rem; }
  html.tema .tb-acciones .barra-usuario:hover { background-color: rgb(26 28 51 / 0.05) !important; }
  html.tema .tb-usuario-txt { display: block !important; min-width: 0; text-align: left; }
  html.tema .tb-usuario-txt strong { display: block; font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.tema .tb-usuario-txt small { font-size: 0.74rem; color: #8A8FA3 !important; }
  html.tema .tb-usuario-txt strong, html.tema .barra-usuario strong { color: #1A1C33 !important; }
  html.tema .tb-acciones .barra-boton { width: 2.3rem; height: 2.3rem; padding: 0 !important; display: inline-grid; place-items: center; border-radius: 0.65rem !important; }
  /* sus menús abren hacia arriba */
  html.tema .tb-acciones .barra-panel, html.tema .tb-acciones .barra-panel.derecha { top: auto; bottom: calc(100% + 0.5rem); left: 0; right: auto; min-width: 15rem; }
  html.tema .tb-acciones .barra-cuenta .barra-panel { width: 100%; }

  /* la fila de botones de arriba ya está en el lateral */
  html.tema .menu-modulos { display: none !important; }

  /* --------------------------------------------------- el contenido: título de la página al estilo Mercury */
  html.tema header.bg-tinta > div.flex-wrap:has(h1), html.tema header.bg-tinta > .max-w-\[1400px\] { padding-top: 2.2rem !important; }
  html.tema header.bg-tinta h1 { font-size: 2.1rem !important; line-height: 1.15; }
  html.tema header.bg-tinta p.text-white\/60:has(+ h1) { display: block !important; font-size: 0.8rem; font-weight: 500; letter-spacing: 0 !important; text-transform: none !important; margin-bottom: 0.3rem; }
  html.tema header.bg-tinta p.text-white\/60:has(+ h1)::before { display: none; }
  html.tema header.bg-tinta { border-bottom: 0 !important; }
  html.tema header.bg-tinta > div:has(> nav.inline-flex.rounded) { padding-top: 1.6rem !important; }

  /* el Inicio: la portada con foto pasa a ser una tarjeta grande con esquinas redondeadas */
  html.tema .inicio-portada { margin: 1.25rem 1.5rem 0; border-radius: 22px; min-height: 23rem; }
  html.tema .inicio-portada-cont { padding-left: 2.5rem; padding-right: 2.5rem; }

  /* lo que flota abajo a la izquierda (asistente, decoración) se corre para no quedar debajo del lateral */
  html.tema .asis { left: calc(var(--lat) + 1rem); }
  html.tema .nv-capa, html.tema .nv-pueblo, html.tema .nv-suelo { left: var(--lat); }
  html.tema .nv-boton { left: calc(50% + var(--lat) / 2); }
}

/* celular: la fila vieja de botones sobra (todo está en el panel ☰ y en las páginas rehechas) */
@media screen and (max-width: 1099px) { html.tema .menu-modulos { display: none !important; } }
/* celular: nada puede ensanchar la página (si una tabla se sale, el panel ☰ quedaba fuera de la pantalla) */
@media screen and (max-width: 1099px) { html.tema, html.tema body { overflow-x: clip; } html.tema .tb-liviano svg { width: 1.1rem; height: 1.1rem; flex: none; } }
html.tema .tb-liviano svg { width: 1.1rem; height: 1.1rem; flex: none; color: #040677; }

/* ==========================================================================================================
   ESPACIOS PAREJOS (19-nov-2026, el usuario: "no está homogéneo, mucho vacío, lo de la derecha no está bien
   acomodado; dashboards y tablas impecables"). Un solo sistema para todas las páginas:
   - margen lateral del contenido 2rem, siempre alineado al borde del menú (no centrado con huecos a los lados);
   - el título y sus botones en una sola franja, botones a la derecha centrados con el título;
   - separación vertical entre bloques 1.25rem; entre tarjetas 1rem; relleno de tarjetas 1.25rem;
   - tablas compactas, números alineados a la derecha con cifras del mismo ancho, encabezado fijo al bajar.
   ========================================================================================================== */
@media screen and (min-width: 1100px) {
  html.tema [class*="max-w-[1400px]"], html.tema [class*="max-w-[900px]"], html.tema #tsy {
    max-width: 1520px !important; margin-left: 0 !important; margin-right: auto !important; padding-left: 2rem !important; padding-right: 2rem !important; }
  /* 20-nov-2026 (usuario: "mira el espacio que sobra a la derecha"): las páginas de TABLAS usan todo el ancho de la pantalla */
  html.tema body.ancho-completo [class*="max-w-[1400px]"], html.tema body.ancho-completo [class*="max-w-[900px]"] { max-width: none !important; }
  /* franja del título */
  html.tema header.bg-tinta > div:has(> nav.inline-flex.rounded) { padding-top: 1.25rem !important; }
  html.tema header.bg-tinta > div.flex-wrap:has(h1), html.tema header.bg-tinta > .max-w-\[1400px\]:has(h1) {
    padding-top: 1rem !important; padding-bottom: 1.25rem !important; align-items: center !important; column-gap: 1.5rem !important; row-gap: 0.75rem !important; }
  html.tema header.bg-tinta > div.flex-wrap:has(h1) > div:last-child { justify-content: flex-start; gap: 0.5rem !important; }
  html.tema header.bg-tinta > div:has(> nav.inline-flex.rounded) + div.flex-wrap:has(h1) { padding-top: 0.75rem !important; }
  html.tema header.bg-tinta h1 + p, html.tema header.bg-tinta h1 + * + p { margin-top: 0.25rem; font-size: 0.88rem; }
  /* filtros fijos */
  html.tema nav.sticky > div, html.tema nav.lg\:sticky > div { padding-top: 0.7rem !important; padding-bottom: 0.7rem !important; gap: 0.5rem !important; }
  /* cuerpo de la página */
  html.tema main[class*="max-w-"] { padding-top: 1.25rem !important; padding-bottom: 2.5rem !important; }
  html.tema main[class*="space-y-"] > * + * { margin-top: 1.25rem !important; }
  html.tema [class*="max-w-[1400px]"].mt-4, html.tema [class*="max-w-[1400px]"].pt-4 { margin-top: 0 !important; padding-top: 1rem !important; }
  html.tema #tsy { padding-top: 1.25rem !important; }
}
/* filtros: una sola barra corrida (el buscador ya no queda solo en otra fila a la derecha) */
html.tema nav.sticky .ml-auto, html.tema nav.lg\:sticky .ml-auto { margin-left: 0 !important; }
/* la burbuja de saludo del asistente se despide sola a los 8 s (el botón con su foto sigue ahí) */
@keyframes g-burbuja-sale { 0%, 88% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
html.tema .asis-burbuja { animation: g-burbuja-sale 8s ease forwards; }
/* tarjetas y rejillas (todas las pantallas) */
html.tema main .gap-4, html.tema main .gap-5, html.tema main .gap-6, html.tema main .gap-8 { gap: 1rem !important; }
html.tema main .bg-white.p-5, html.tema main .bg-white.p-6, html.tema main .bg-white.p-8, html.tema main .tarjeta { padding: 1.25rem 1.4rem !important; }
html.tema main section > h2, html.tema main .bg-white > h2, html.tema main .bg-white > div > h2 { font-size: 1.05rem !important; font-weight: 600 !important; letter-spacing: -0.01em; }
html.tema .dato { min-height: 100%; }
/* tablas */
html.tema main table, html.tema #tsy table { font-variant-numeric: tabular-nums; font-size: 0.84rem; }
html.tema main table th, html.tema main table td { padding: 0.55rem 0.75rem; vertical-align: middle; }
html.tema main table thead th { position: sticky; top: 0; z-index: 2; white-space: nowrap; }
html.tema main table td.text-right, html.tema main table th.text-right { font-variant-numeric: tabular-nums; }
html.tema main table tbody tr:last-child td { border-bottom: 0 !important; }
html.tema main .overflow-x-auto, html.tema main .overflow-auto { border-radius: 12px; }

/* ------------------------------------------------- el lateral no se imprime y el contenido usa toda la hoja */
@media print { html.tema body { padding-left: 0 !important; } }
