/* ==========================================================================
   TributoVE - Sistema de Diseño Institucional (Paleta Azul Marino & Cobalto)
   - Sidebar: #05045E (Fondo) | #373990 (Activo) | #B8B9D6 (Inactivo)
   - Acento Primario: #0D1188 | Superficie Clara: #F4F5F8 / #FFFFFF / #E4E6F1
   - Semánticos: #F6A623 (Ámbar) | #65B741 (Esmeralda) | #B86B35 (Terracota) | #D8C83A (Mostaza) | #E05252 (Coral)
   ========================================================================== */

:root, [data-bs-theme="light"] {
  --tv-bg: #F4F5F8;
  --tv-bg-gradient: none;
  --tv-surface: #FFFFFF;
  --tv-surface-subtle: #ECEEF5;
  --tv-surface-hover: #E4E6F1;
  --tv-border: #E4E6F1;
  --tv-border-hover: #0D1188;
  --tv-border-subtle: #ECEEF5;

  /* Acento Primario */
  --tv-primary: #0D1188;
  --tv-primary-hover: #05045E;
  --tv-primary-soft: #E4E6F1;
  --tv-lime: #0D1188;
  --tv-lime-hover: #05045E;
  --tv-lime-text: #FFFFFF;
  --tv-emerald: #65B741;
  --tv-emerald-dark: #EAF6E5;
  --tv-amber: #F6A623;
  --tv-terracotta: #B86B35;
  --tv-mustard: #D8C83A;
  --tv-danger: #E05252;

  /* Sidebar */
  --tv-sidebar-bg: #05045E;
  --tv-sidebar-active: #373990;
  --tv-sidebar-text: #B8B9D6;

  /* Textos de alta legibilidad */
  --tv-text: #0C0B4E;
  --tv-text-muted: #646782;
  --tv-text-dim: #8A8D9F;

  /* Sombras neutras y suaves */
  --tv-shadow-card: none;
  --tv-shadow-lime: 0 1px 2px rgba(12, 11, 78, 0.08);
  --tv-glow-emerald: none;

  --tv-sidebar-width: 265px;
  --tv-navbar-height: 64px;
  --tv-radius-card: 0px;
  --tv-radius-pill: 0px;
}

[data-bs-theme="dark"] {
  --tv-bg: #080924;
  --tv-bg-gradient: none;
  --tv-surface: #0E1036;
  --tv-surface-subtle: #15184A;
  --tv-surface-hover: #1E215E;
  --tv-border: #25286B;
  --tv-border-hover: #4A4EC4;
  --tv-border-subtle: #1A1D52;

  /* Acento en Modo Oscuro */
  --tv-primary: #373990;
  --tv-primary-hover: #484AB0;
  --tv-primary-soft: rgba(55, 57, 144, 0.28);
  --tv-lime: #373990;
  --tv-lime-hover: #484AB0;
  --tv-lime-text: #FFFFFF;
  --tv-emerald: #65B741;
  --tv-emerald-dark: rgba(101, 183, 65, 0.16);
  --tv-amber: #F6A623;
  --tv-terracotta: #B86B35;
  --tv-mustard: #D8C83A;
  --tv-danger: #E05252;

  /* Sidebar */
  --tv-sidebar-bg: #05045E;
  --tv-sidebar-active: #373990;
  --tv-sidebar-text: #B8B9D6;

  /* Textos */
  --tv-text: #F4F5F8;
  --tv-text-muted: #B8B9D6;
  --tv-text-dim: #8A8D9F;

  /* Sombras neutras mate */
  --tv-shadow-card: none;
  --tv-shadow-lime: none;
  --tv-glow-emerald: none;

  --tv-sidebar-width: 265px;
  --tv-navbar-height: 64px;
  --tv-radius-card: 0px;
  --tv-radius-pill: 0px;
}

/* Base Body y Jerarquía Tipográfica Ejecutiva */
html, body {
  overflow-x: clip;
  max-width: 100%;
  overscroll-behavior-x: none;
}
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--tv-bg);
  background-image: none;
  color: var(--tv-text);
  min-height: 100vh;
  font-size: 0.95rem;
  line-height: 1.5;
  letter-spacing: -0.008em;
  margin: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--tv-text);
}

.kpi-value, .table-dashboard td, .bcv-rate-value, code {
  font-variant-numeric: tabular-nums;
}

/* Scrollbar limpia */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--tv-border);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--tv-text-dim);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}
a:hover {
  color: var(--tv-primary);
}

.text-lime {
  color: var(--tv-primary) !important;
}
[data-bs-theme="dark"] .text-lime {
  color: #4cc392 !important;
}

/* ==========================================================================
   LAYOUT DEL PANEL
   ========================================================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.app-sidebar {
  width: var(--tv-sidebar-width);
  background: var(--tv-sidebar-bg, #05045E);
  border-right: 1px solid rgba(184, 185, 214, 0.14);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  transition: transform 0.25s ease-in-out, background-color 0.2s ease;
}

.app-content {
  flex: 1;
  margin-left: var(--tv-sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
  background: transparent;
  transition: margin-left 0.25s ease-in-out;
}
.app-content > main {
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}
body:has(.modulo-stage) .app-wrapper,
body:has(.modulo-stage) .app-content {
  height: 100dvh;
  overflow: hidden;
}
body:has(.modulo-stage) .app-content > main {
  min-height: 0;
}

@media (min-width: 992px) {
  body.sidebar-collapsed .app-sidebar {
    transform: translateX(-100%);
  }
  body.sidebar-collapsed .app-content {
    margin-left: 0;
  }
  body:not(.sidebar-collapsed) #sidebarToggle {
    display: none;
  }
}

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .app-sidebar.show {
    transform: translateX(0);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  }
  .app-content {
    margin-left: 0;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1035;
  }
  .sidebar-backdrop.show {
    display: block;
  }
}

/* Cabecera del Sidebar (Exacto al PDF: TributoVE / Gestión fiscal · Venezuela) */
.sidebar-user-header {
  height: var(--tv-navbar-height, 64px);
  min-height: var(--tv-navbar-height, 64px);
  max-height: var(--tv-navbar-height, 64px);
  padding: 0 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(184, 185, 214, 0.14);
  box-sizing: border-box;
}
.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 0;
  background: var(--tv-sidebar-active, #373990);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.sidebar-user-name {
  font-weight: 800;
  font-size: 1rem;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.75rem;
  color: #B8B9D6;
}

/* Buscador en Sidebar */
.sidebar-search-box {
  margin: 0.65rem 0.9rem 0.65rem;
  position: relative;
}
.sidebar-search-box input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(184, 185, 214, 0.22);
  border-radius: 0;
  padding: 0.42rem 2rem 0.42rem 2rem;
  font-size: 0.82rem;
  color: #FFFFFF;
  outline: none;
  transition: border-color 0.15s ease;
}
.sidebar-search-box input::placeholder {
  color: #B8B9D6;
}
.sidebar-search-box input:focus {
  border-color: #B8B9D6;
  background: rgba(55, 57, 144, 0.45);
}
.sidebar-search-box .search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: #B8B9D6;
  font-size: 0.82rem;
}
.sidebar-search-box .shortcut-tag {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  color: #B8B9D6;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 0;
  font-weight: 600;
  border: 1px solid rgba(184, 185, 214, 0.22);
}

/* Secciones Desplegables de Navegación (Menús 1, 2, 3 y 4) */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0.75rem 1rem;
}

.sidebar-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: #B8B9D6;
  padding: 0.6rem 0.65rem 0.35rem;
}

.sidebar-menu-group {
  margin-bottom: 0.35rem;
  border-bottom: 1px solid rgba(184, 185, 214, 0.12);
  padding-bottom: 0.25rem;
}
.sidebar-menu-group:last-of-type {
  border-bottom: 0;
}
.sidebar-menu-group summary.sidebar-dropdown-toggle {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-radius: 0;
  padding: 0.55rem 0.65rem;
  margin-bottom: 2px;
  color: #B8B9D6;
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  transition: background-color 0.15s ease, color 0.15s ease;
  user-select: none;
}
.sidebar-menu-group summary.sidebar-dropdown-toggle::-webkit-details-marker {
  display: none;
}
.sidebar-menu-group summary.sidebar-dropdown-toggle:hover {
  background-color: rgba(55, 57, 144, 0.45);
  color: #FFFFFF;
}
.sidebar-menu-group .sidebar-chevron {
  font-size: 0.72rem;
  transition: transform 0.2s ease;
}
.sidebar-menu-group[open] .sidebar-chevron {
  transform: rotate(180deg);
  color: #FFFFFF;
}
.sidebar-submenu {
  padding-left: 0.2rem;
  padding-bottom: 0.2rem;
}

/* Items de Navegación (Paleta Azul Marino & Índigo) */
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.52rem 0.75rem;
  border-radius: var(--tv-radius-pill);
  color: #B8B9D6;
  font-weight: 500;
  font-size: 0.88rem;
  transition: background-color 0.15s ease, color 0.15s ease;
  margin-bottom: 2px;
}
.sidebar-nav .nav-link i {
  font-size: 0.98rem;
  color: #B8B9D6;
}
.sidebar-nav .nav-link:hover {
  background-color: rgba(55, 57, 144, 0.55);
  color: #FFFFFF;
}
.sidebar-nav .nav-link:hover i {
  color: #FFFFFF;
}

/* ITEM ACTIVO: Azul Índigo #373990 con texto blanco */
.sidebar-nav .nav-link.active {
  background-color: #373990 !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}
.sidebar-nav .nav-link.active i {
  color: #ffffff !important;
}

/* Pie del Sidebar */
.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(184, 185, 214, 0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #04034B;
  color: #B8B9D6;
}
.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.82rem;
  color: #FFFFFF;
}
.app-sidebar .btn-logout,
.app-sidebar a[href*="logout"],
.app-sidebar button[title*="Salir"] {
  color: #E05252 !important;
}
.brand-dots {
  display: inline-flex;
  gap: 3px;
}
.brand-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--tv-primary);
}

/* ==========================================================================
   NAVBAR SUPERIOR (Línea 1 Compacta y Clara - Altura Sincronizada con Sidebar)
   ========================================================================== */
.app-navbar {
  height: var(--tv-navbar-height, 64px);
  min-height: var(--tv-navbar-height, 64px);
  max-height: var(--tv-navbar-height, 64px);
  background: var(--tv-surface);
  border-bottom: 1px solid var(--tv-border);
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-sizing: border-box;
  flex-wrap: nowrap;
}

.navbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--tv-text);
}
.navbar-breadcrumb .nav-icon-box {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--tv-primary-soft);
  border: 1px solid var(--tv-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tv-primary);
  font-size: 0.9rem;
}
.navbar-breadcrumb .breadcrumb-item.active {
  color: var(--tv-text);
  font-weight: 700;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-circle-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--tv-border);
  background: var(--tv-surface-subtle);
  color: var(--tv-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.9rem;
  padding: 0;
}
.action-circle-btn:hover {
  background: var(--tv-surface-hover);
  color: var(--tv-text);
  border-color: var(--tv-primary);
}

/* ==========================================================================
   TARJETAS Y CONTROLES DEL PANEL (Sobrios, Claros y Fáciles de Usar)
   ========================================================================== */
.card-dashboard {
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: var(--tv-radius-card);
  box-shadow: var(--tv-shadow-card);
  padding: 1.25rem;
}

.card-kpi {
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: var(--tv-radius-card);
  padding: 1rem 1.25rem;
  box-shadow: var(--tv-shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}
.card-kpi .kpi-label {
  font-size: 0.78rem;
  color: var(--tv-text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.card-kpi .kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--tv-text);
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
  line-height: 1.15;
}
.card-kpi .kpi-trend {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--tv-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.card-kpi .trend-up { color: var(--tv-emerald); }
.card-kpi .trend-neutral { color: var(--tv-text-muted); }
.card-kpi .trend-warn { color: #d97706; }

/* Banner de Empresa Activa (Sin resplandores ni degradados neón) */
.active-company-banner {
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-left: 4px solid var(--tv-primary);
  border-radius: var(--tv-radius-card);
  padding: 1.1rem 1.35rem;
  box-shadow: var(--tv-shadow-card);
}
.company-banner-identity {
  flex: 1 1 auto;
}
.company-banner-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--tv-primary);
}
.company-active-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tv-primary);
  display: inline-block;
  flex-shrink: 0;
}
.company-banner-title {
  font-size: 1.24rem;
  line-height: 1.25;
  color: var(--tv-text);
  letter-spacing: -0.015em;
}
.company-banner-rif {
  font-size: 0.82rem;
  color: var(--tv-text-muted);
  font-weight: 600;
  background: var(--tv-surface-subtle);
  border: 1px solid var(--tv-border);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.company-switcher-form {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  flex: 1 1 210px;
  max-width: 100%;
}
.company-switcher-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tv-text-muted);
  white-space: nowrap;
  margin: 0;
}
.company-banner-select {
  height: 36px;
  min-width: 180px;
  max-width: 260px;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  text-overflow: ellipsis;
}
.company-banner-btns .btn {
  height: 36px;
  white-space: nowrap;
  font-size: 0.82rem;
  padding: 0 0.95rem;
}
@media (min-width: 992px) {
  .company-banner-actions {
    justify-content: flex-end;
    flex-shrink: 0;
  }
  .company-switcher-form {
    flex: 0 1 auto;
  }
}

/* Tarjetas de Módulos (Claras y Directas) */
.module-card-launch {
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: 10px;
  padding: 0.95rem 1.05rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  text-decoration: none;
  color: var(--tv-text);
}
.module-card-launch:hover {
  border-color: var(--tv-primary);
  background: var(--tv-surface-subtle);
  color: var(--tv-text);
}
.module-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--tv-primary-soft);
  color: var(--tv-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}
[data-bs-theme="dark"] .module-card-icon {
  color: #5cd6a5;
}
.module-card-launch:hover .module-card-icon {
  background: var(--tv-primary);
  color: #ffffff;
}

/* Píldoras de Filtro */
.filter-pill-btn {
  background: var(--tv-surface-subtle);
  border: 1px solid var(--tv-border);
  color: var(--tv-text-muted);
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.filter-pill-btn:hover {
  color: var(--tv-text);
  border-color: var(--tv-primary);
  background: var(--tv-surface-hover);
}
.filter-pill-btn.active,
.filter-pill-btn[aria-selected="true"] {
  background: var(--tv-primary);
  color: #ffffff;
  border-color: var(--tv-primary);
  font-weight: 600;
  box-shadow: none;
}

/* Tablas del Panel */
.table-dashboard {
  width: 100%;
  color: var(--tv-text);
  border-collapse: separate;
  border-spacing: 0;
}
.table-dashboard thead th {
  background: var(--tv-surface-subtle);
  color: var(--tv-text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--tv-border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.table-dashboard tbody td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--tv-border-subtle);
  font-size: 0.86rem;
  vertical-align: middle;
}
.table-dashboard tbody tr:hover {
  background-color: var(--tv-surface-hover);
}

.table-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  background: var(--tv-primary-soft);
  color: var(--tv-primary);
  border: 1px solid var(--tv-border);
  flex-shrink: 0;
}
[data-bs-theme="dark"] .table-avatar {
  color: #6ee7b7;
}

/* Badges de Estado Sobrios */
.badge-dash-ok {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  font-size: 0.73rem;
  font-weight: 600;
}
[data-bs-theme="dark"] .badge-dash-ok {
  background: rgba(22, 163, 74, 0.2);
  color: #86efac;
  border-color: rgba(22, 163, 74, 0.35);
}

.badge-dash-lime {
  background: var(--tv-primary-soft);
  color: var(--tv-primary);
  border: 1px solid rgba(13, 17, 136, 0.25);
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  font-size: 0.73rem;
  font-weight: 600;
}
[data-bs-theme="dark"] .badge-dash-lime {
  color: #B8B9D6;
  border-color: rgba(184, 185, 214, 0.28);
}

.badge-dash-prog {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  font-size: 0.73rem;
  font-weight: 600;
}
[data-bs-theme="dark"] .badge-dash-prog {
  background: rgba(217, 119, 6, 0.2);
  color: #fcd34d;
  border-color: rgba(217, 119, 6, 0.35);
}

.badge-dash-dim {
  background: var(--tv-surface-subtle);
  color: var(--tv-text-muted);
  border: 1px solid var(--tv-border);
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  font-size: 0.73rem;
  font-weight: 500;
}

/* Botones Principales y Secundarios (Sin brillo neón) */
.btn-dash-primary {
  background: var(--tv-primary);
  color: #ffffff !important;
  font-weight: 600;
  border-radius: var(--tv-radius-pill);
  padding: 0.48rem 1rem;
  border: 1px solid var(--tv-primary);
  box-shadow: none;
  transition: background-color 0.15s ease;
}
.btn-dash-primary:hover {
  background: var(--tv-primary-hover);
  border-color: var(--tv-primary-hover);
  color: #ffffff !important;
}

.btn-dash-secondary {
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  color: var(--tv-text);
  border-radius: var(--tv-radius-pill);
  padding: 0.48rem 0.95rem;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn-dash-secondary:hover {
  background: var(--tv-surface-hover);
  border-color: var(--tv-primary);
  color: var(--tv-text);
}

/* Formularios */
.form-control, .form-select {
  background-color: var(--tv-surface) !important;
  border: 1px solid var(--tv-border) !important;
  color: var(--tv-text) !important;
  border-radius: 8px !important;
}
.form-control {
  padding: 0.5rem 0.75rem !important;
}
.form-select {
  padding: 0.5rem 2.25rem 0.5rem 0.75rem !important;
}
.form-select.form-select-sm {
  padding: 0.35rem 2rem 0.35rem 0.75rem !important;
}
.form-control:focus, .form-select:focus {
  border-color: var(--tv-primary) !important;
  box-shadow: 0 0 0 2px rgba(13, 17, 136, 0.15) !important;
}

/* Matriz Responsiva con Columna Empresa Fija */
.table-scroll-region {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  border-radius: 0 0 var(--tv-radius-card) var(--tv-radius-card);
}
.table-scroll-region:focus-visible {
  outline: 2px solid var(--tv-primary);
  outline-offset: -2px;
}
.table-dashboard-sticky thead th {
  position: sticky;
  top: 0;
  background: var(--tv-surface-subtle);
  z-index: 2;
}
.table-dashboard-sticky th.sticky-col,
.table-dashboard-sticky td.sticky-col {
  position: sticky;
  left: 0;
  background: var(--tv-surface);
  z-index: 3;
  border-right: 1px solid var(--tv-border);
}
.table-dashboard-sticky thead th.sticky-col {
  background: var(--tv-surface-subtle);
  z-index: 4;
}
.table-dashboard-sticky tbody tr:hover td.sticky-col {
  background: var(--tv-surface-hover);
}

/* Compatibilidad general de textos en modo claro y oscuro */
[data-bs-theme="light"] .text-white {
  color: var(--tv-text) !important;
}
[data-bs-theme="light"] .text-white-50 {
  color: var(--tv-text-muted) !important;
}

.card-custom {
  background: var(--tv-surface) !important;
  border: 1px solid var(--tv-border) !important;
  border-radius: var(--tv-radius-card) !important;
  box-shadow: var(--tv-shadow-card) !important;
  color: var(--tv-text) !important;
}

/* Contención de Scroll para Diálogos Nativos */
html:has(dialog:modal) {
  overflow: hidden;
  scrollbar-gutter: stable;
}
dialog:modal {
  overscroll-behavior: contain;
}

/* ==========================================================================
   WIDGET DE TASA OFICIAL BCV EN NAVBAR (Diseño Limpio y Proporcionado)
   ========================================================================== */
.bcv-nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 34px;
  padding: 0 0.75rem;
  font-size: 0.78rem;
  border-radius: 8px;
  background: var(--tv-surface-subtle);
  border: 1px solid var(--tv-border);
  color: var(--tv-text);
  white-space: nowrap;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.bcv-nav-trigger:hover,
.bcv-nav-trigger:focus {
  border-color: var(--tv-primary);
  background: var(--tv-surface-hover);
  color: var(--tv-text);
}
.bcv-nav-trigger .bcv-sep {
  color: var(--tv-border);
  margin: 0 0.1rem;
}

.bcv-dropdown-card {
  width: 345px;
  max-width: calc(100vw - 24px);
  padding: 1rem 1.1rem !important;
  border-radius: 14px !important;
  background: var(--tv-surface) !important;
  border: 1px solid var(--tv-border) !important;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12) !important;
}

.bcv-rate-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.bcv-rate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: var(--tv-surface-subtle);
  border: 1px solid var(--tv-border-subtle);
}

.bcv-rate-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.bcv-currency-tag {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--tv-primary-soft);
  color: var(--tv-primary);
  font-weight: 800;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
[data-bs-theme="dark"] .bcv-currency-tag {
  color: #6ee7b7;
}

.bcv-rate-title {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--tv-text);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bcv-rate-sub {
  font-size: 0.7rem;
  color: var(--tv-text-muted);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bcv-rate-value {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--tv-text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: right;
  flex-shrink: 0;
  padding-left: 0.5rem;
}

/* ==========================================================================
   ANIMACIONES DE CARGA DE BOTONES, MÓDULOS Y TRANSICIONES SOBRIAS
   ========================================================================== */
@keyframes tv-spin {
  to { transform: rotate(360deg); }
}
@keyframes tv-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes tv-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
@keyframes tv-progress-bar {
  0%   { width: 0%; opacity: 1; }
  55%  { width: 72%; opacity: 1; }
  100% { width: 94%; opacity: 0.9; }
}

/* Barra superior fina de navegación */
#tv-top-loader {
  position: fixed;
  top: 0;
  left: 0;
  height: 2.5px;
  width: 0%;
  background: var(--tv-primary);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: width 0.25s ease, opacity 0.2s ease;
}
#tv-top-loader.is-active {
  opacity: 1;
  animation: tv-progress-bar 1.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Estado de carga en botones (Spinner integrado sin saltos) */
.tv-btn-loading {
  position: relative !important;
  pointer-events: none !important;
  opacity: 0.82 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.45rem !important;
}
.tv-btn-spinner {
  width: 0.88em;
  height: 0.88em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: tv-spin 0.65s linear infinite;
  flex-shrink: 0;
}
.tv-spin-icon {
  display: inline-block;
  animation: tv-spin 0.7s linear infinite;
}

/* Transición sutil de entrada para vistas y tarjetas */
.tv-fade-in {
  animation: tv-fade-up 0.22s ease-out both;
}

/* Overlay y Skeleton de carga para el iframe de cada módulo */
.modulo-stage {
  position: relative;
  min-height: calc(100vh - 64px);
}
.modulo-loader-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--tv-bg);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: opacity 0.24s ease, visibility 0.24s ease;
}
.modulo-loader-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.tv-loader-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1rem;
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--tv-text);
  width: fit-content;
}
.tv-skeleton-box {
  background: linear-gradient(90deg, var(--tv-surface) 25%, var(--tv-surface-hover) 50%, var(--tv-surface) 75%);
  background-size: 800px 100%;
  animation: tv-shimmer 1.25s infinite linear;
  border: 1px solid var(--tv-border);
  border-radius: 10px;
}

.nav-pill-group {
  display: inline-flex;
  align-items: center;
  height: 34px;
  border: 1px solid var(--tv-border);
  border-radius: 999px;
  background: var(--tv-surface-subtle);
  max-width: 100%;
}
.nav-pill-group > .dropdown {
  display: flex;
  align-items: center;
  min-width: 0;
}
.nav-pill-group .bcv-nav-trigger {
  height: 32px;
  border: 0 !important;
  border-radius: 999px 0 0 999px !important;
  background: transparent !important;
  padding: 0 0.65rem;
}
.nav-pill-group .nav-pill-emp {
  border-left: 1px solid var(--tv-border);
  min-width: 0;
}
.nav-pill-group .nav-pill-emp > .btn {
  height: 32px;
  border: 0 !important;
  border-radius: 0 999px 999px 0 !important;
  background: transparent !important;
  padding: 0 0.7rem !important;
  box-shadow: none !important;
}
.nav-pill-group .bcv-nav-trigger:hover,
.nav-pill-group .nav-pill-emp > .btn:hover {
  background: var(--tv-surface-hover) !important;
}

.navbar-actions > .dropdown > .btn,
.navbar-actions > .btn,
.navbar-actions > a.btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
}

@media (max-width: 767.98px) {
  .app-navbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 48px 32px;
    align-items: center;
    gap: 0;
    height: auto;
    min-height: 80px;
    max-height: none;
    padding: 0;
  }
  .navbar-left,
  .navbar-actions,
  .nav-pill-group {
    display: contents;
  }
  #sidebarToggle {
    grid-column: 1;
    grid-row: 1;
    margin-left: 0.6rem;
    margin-right: 0.45rem;
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0;
  }
  .navbar-breadcrumb {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    padding-right: 0.45rem;
  }
  .navbar-breadcrumb .breadcrumb-item.active {
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem !important;
    line-height: 1.2 !important;
  }
  .nav-more-drop {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    margin-right: 0.6rem;
    flex-shrink: 0;
  }
  .action-circle-btn.nav-more-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    justify-content: center;
  }
  .nav-pill-group .nav-pill-emp {
    grid-column: 1 / 3;
    grid-row: 2;
    position: relative;
    min-width: 0;
    height: 32px;
    display: flex;
    align-items: center;
    background: var(--tv-surface-subtle);
    border-top: 1px solid var(--tv-border);
    border-left: 0;
    padding-left: 0.6rem;
  }
  .nav-pill-group .nav-pill-emp > .btn {
    width: 100%;
    height: 100% !important;
    min-width: 0;
    overflow: hidden;
    justify-content: flex-start;
    gap: 0.3rem !important;
    padding: 0 0.4rem 0 0 !important;
    border: 0 !important;
    background: transparent !important;
    font-size: 0.74rem !important;
    font-weight: 600 !important;
    color: var(--tv-text) !important;
  }
  .nav-pill-group .nav-pill-emp .text-truncate {
    display: block;
    min-width: 0;
    flex: 0 1 auto;
    text-align: left;
    max-width: 100% !important;
  }
  .nav-pill-group .nav-pill-emp .dropdown-menu {
    left: 6px !important;
    right: auto !important;
    top: calc(100% + 2px) !important;
    width: calc(100vw - 12px) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 12px) !important;
    transform: none !important;
    box-shadow: none !important;
  }
  .nav-bcv-drop {
    grid-column: 3;
    grid-row: 2;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    background: var(--tv-surface-subtle);
    border-top: 1px solid var(--tv-border);
    padding-right: 0.6rem;
    padding-left: 0.4rem;
    flex-shrink: 0;
  }
  .nav-bcv-drop .bcv-nav-trigger {
    height: 100%;
    border: 0 !important;
    background: transparent !important;
    padding: 0 !important;
    font-size: 0.74rem;
    gap: 0.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tv-fade-in,
  #tv-top-loader.is-active,
  .tv-btn-spinner,
  .tv-spin-icon,
  .tv-skeleton-box {
    animation: none !important;
  }
}

.dropdown-item.active,
.dropdown-item:active {
  background-color: var(--tv-primary, #0D1188) !important;
  color: #ffffff !important;
}

/* Diseño cuadrado y plano sin sombras ni border-radius en toda la plataforma */
html:root:root body *,
html:root:root body *::before,
html:root:root body *::after {
  border-radius: 0 !important;
  box-shadow: none !important;
}
html:root:root body input[type="radio"],
html:root:root body .rounded-circle,
html:root:root body .rounded-full,
html:root:root body .brand-dots span,
html:root:root body .tv-btn-spinner,
html:root:root body .spinner-border,
html:root:root body .spinner-grow {
  border-radius: 50% !important;
}
