/**
 * v2-layout.css — Layout canónico: container, header, cards, footer, grids, secciones
 * Absorbe: header-unificado, layout de styles.css, v2-ui.css layout parts
 */

/* ============================================
   APP SHELL — RAÍZ ESTRUCTURAL
   ============================================ */

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  width: 100%;
}

.app-sidebar {
  background: var(--v2-bg-subtle);
  border-right: 1px solid var(--v2-border-light);
  padding: var(--v2-space-5);
}

.sidebar-brand {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--v2-primary);
}

.app-main {
  display: flex;
  flex-direction: column;
  padding: var(--v2-space-5);
  padding-top: var(--v2-space-5);
}

/* Evitar doble padding vertical: el padding lo controla app-main */
.app-main .v2-container {
  margin-top: 0;
  padding-top: 0;
}

.app-header {
  margin-bottom: var(--v2-space-4);
}

/* Compactar header existente */
.app-header .header {
  padding: 12px 18px;
  border-radius: var(--v2-radius-lg);
}

/* ============================================
   APP HEADER — COMPACT MODE (Sprint 1.1)
   ============================================ */

.app-header .header {
  padding: 8px 12px !important;             /* antes 16/20, bajar más */
  border-radius: var(--v2-radius-lg);
}

.app-header .header h1,
.app-header .header .header-title {
  font-size: 1.0em !important;
  margin: 0 !important;
  line-height: 1.05 !important;
}

.app-header .header .header-subtitle-text,
.app-header .header .header-subtitle {
  font-size: 0.8em !important;
  margin: 0 !important;
  line-height: 1.05 !important;
}

/* Reducir paddings internos del "header-table" */
.app-header .header .header-table-cell {
  padding: 2px 8px !important;
}

.app-header .header .header-table-row:nth-child(1) .header-table-cell {
  padding-top: 0 !important;
  padding-bottom: 1px !important;
}

.app-header .header .header-table-row:nth-child(2) .header-table-cell {
  padding-top: 1px !important;
  padding-bottom: 0 !important;
}

/* Acciones: menos "aire" */
.app-header .header .header-acciones {
  gap: 4px !important;
}

.app-header .header .btn-header-volver {
  padding: 3px 10px !important;
  font-size: 0.78em !important;
}

.app-content {
  flex: 1;
  display: block;
}

@media (max-width: 992px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--v2-border-light);
  }
}

/* ============================================
   APP FOOTER — ULTRA COMPACT
   ============================================ */

.app-main > footer.app-footer {
  padding: 8px 12px !important;
  border-radius: var(--v2-radius-lg) !important;
  font-size: 0.72em !important;
  line-height: 1.15 !important;
}

.app-main > footer.app-footer .version-info { margin-bottom: 4px !important; }
.app-main > footer.app-footer .copyright { font-size: 0.95em !important; }
.app-main > footer.app-footer .license { margin-top: 3px !important; }

/* ============================================
   CONTAINER
   ============================================ */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.v2-container {
  width: 100%;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  gap: var(--v2-gap);
}

/* Neutralizar márgenes verticales de hijos directos */
.v2-container > .v2-card,
.v2-container > .content-wrapper {
  margin-top: 0;
  margin-bottom: 0;
}

/* Contenido principal: no comprimir por flex; min-width:0 obligatorio para overflow/scroll en hijos */
.v2-container > .content-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.content-wrapper { display: block; padding-bottom: 24px; }
.content-wrapper > .v2-card { margin-bottom: var(--v2-gap); }
.content-wrapper > .v2-card:last-child { margin-bottom: 0; }

/* ============================================
   CARDS V2
   ============================================ */
.v2-card {
  background: var(--v2-bg);
  border-radius: var(--v2-radius-md);
  padding: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
  margin-top: 0;
  margin-bottom: 0;
}

.v2-card-header { margin-bottom: 18px; }
.v2-card-title {
  margin: 0 0 8px;
  color: var(--v2-text);
  font-size: 1.4em;
  font-weight: 600;
}
.v2-card-desc { margin: 0; color: var(--v2-text-muted); }
.v2-card-body { padding: var(--v2-space-4); }

/* Separación canónica para cards con espacio inferior */
.v2-card.v2-card--spacing-bottom { margin-bottom: 2rem; }

.v2-tabs-card { padding: 15px 24px; }

/* ============================================
   HEADER (unificado)
   ============================================ */
.header {
  background: white;
  border-radius: var(--v2-radius-xl);
  padding: 30px;
  position: relative;
  text-align: left;
}

/* Solo aplicar flex al contenedor principal, NO al indicador NI a la tabla */
.header > div:not(.indicador-conexion-container):not(.header-table) {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  color: var(--v2-primary);
  font-size: 2.5em;
  margin: 0;
  line-height: 1.1;
}

.header .header-subtitle {
  color: var(--v2-primary);
  font-size: 1.3em;
  margin: 0;
  font-weight: 500;
}

.header .header-description {
  color: var(--v2-text-muted);
  font-size: 0.85em;
  margin-top: 5px;
}

/* Estructura de tabla header: filas x 2 columnas (75% / 25%) */
.header-table {
  display: table;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}
.header-table-row { display: table-row; }
.header-table-cell {
  display: table-cell;
  vertical-align: middle;
  padding: 4px 12px;
}

.header-table-row:nth-child(1) .header-table-cell { padding-top: 0; padding-bottom: 2px; }
.header-table-row:nth-child(2) .header-table-cell { padding-top: 2px; padding-bottom: 2px; }

.header-table-cell.col-1 { width: 75%; text-align: left; vertical-align: middle; }
.header-table-cell.col-2 { width: 25%; text-align: right; vertical-align: middle; }

.header-table-cell.empty {
  padding: 0 !important; height: 0 !important; min-height: 0 !important;
  line-height: 0 !important; font-size: 0 !important;
}

.header-title { margin: 0; line-height: 1.1; }

.header-subtitle-text {
  font-size: 1.5em;
  margin: 0; padding: 0;
  color: var(--v2-primary);
  font-weight: 500;
  line-height: 1.1;
}

/* Nombre de usuario */
.header-table-cell.col-2 .header-usuario-nombre {
  font-weight: bold;
  color: var(--v2-primary);
  font-size: 1.1em;
  margin: 0; padding: 0;
  white-space: nowrap;
  line-height: 1.2;
  display: inline-block;
  text-align: right;
}
.header-usuario-nombre {
  font-weight: bold;
  color: var(--v2-primary);
  font-size: 1.1em;
  margin: 0;
  white-space: nowrap;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* Info y fila de usuario */
.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 200px;
  text-align: right;
}
.header-usuario-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  justify-content: flex-end;
}
.header-usuario-row {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.header-flex-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Acciones del header */
.header-acciones {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  margin: 0;
}
.header-table-cell.col-2 .header-acciones {
  flex-wrap: wrap;
  padding: 0;
}

/* Botones de header */
.btn-header-volver {
  padding: 5px 12px;
  font-size: 0.85em;
  text-decoration: none;
}
.btn-header-sincronizar { display: none; }
.btn-header-cerrar-sesion {
  background: var(--v2-danger);
  color: white;
  padding: 5px 12px;
  font-size: 0.85em;
  border: none;
  border-radius: var(--v2-radius-md);
  cursor: pointer;
}

/* Indicador de conexión */
.indicador-conexion {
  position: fixed;
  top: 10px; right: 10px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--v2-shadow-md);
  transition: all var(--v2-transition-base);
}

/* Posición de indicador dentro del header */
.header .indicador-conexion-container {
  position: absolute;
  bottom: -80px !important; right: 31px !important;
  z-index: 10;
  pointer-events: none !important;
}
.header-acciones .indicador-conexion-container {
  position: static !important; bottom: auto !important; right: auto !important;
  pointer-events: auto !important;
  display: inline-flex; align-items: center; margin-left: 12px;
}
.header .indicador-conexion-container #indicador-conexion {
  display: inline-block; visibility: visible; opacity: 1;
  font-size: 0.85em; padding: 5px 10px;
  border-radius: 12px; font-weight: bold;
  box-shadow: 0 2px 3px rgba(0,0,0,0.2);
}

/* ============================================
   SECCIONES DE CONTENIDO
   ============================================ */
.content-section {
  display: none;
  background: white;
  border-radius: var(--v2-radius-xl);
  padding: 30px;
  box-shadow: var(--v2-shadow-lg);
}
.content-section.active { display: block; }

/* ============================================
   SECCIÓN DIVIDERS Y TITLES
   ============================================ */
.v2-section-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 25px 0;
  border: none;
}
.v2-section-title {
  margin: 0 0 var(--v2-space-3);
  font-size: 1rem;
  font-weight: 600;
  color: var(--v2-text);
}

/* Utilidades Classic: leyenda, readonly, bloques */
.v2-leyenda-muted { color: var(--v2-text-muted); font-size: 0.9em; }
.v2-input-readonly { background: var(--v2-bg-subtle); min-height: 38px; }
.v2-display-field { min-height: 38px; }
.v2-observaciones-block { background: var(--v2-bg-subtle); padding: var(--v2-space-3); border-radius: var(--v2-radius-md); border-left: 4px solid var(--v2-primary); }
.v2-form-panel { background: var(--v2-bg-subtle); padding: var(--v2-space-4); border-radius: var(--v2-radius-md); margin-bottom: var(--v2-space-4); border: 1px solid var(--v2-border); }
.v2-state--empty.v2-state--padding { padding: 24px; }
.v2-hidden { display: none; }
.v2-form-grid--one { grid-template-columns: 1fr; }
.v2-mb-4 { margin-bottom: var(--v2-space-4); }
.v2-mt-2 { margin-top: var(--v2-space-2); }
.v2-mt-1 { margin-top: var(--v2-space-1, 4px); }
.v2-mt-4 { margin-top: var(--v2-space-4, 20px); }
.v2-card--nested { margin-bottom: var(--v2-space-4); }
.v2-card-header--actions { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--v2-space-2); }
.v2-panel-inline { display: block; }
.v2-label { font-weight: 600; color: var(--v2-text); margin-bottom: 4px; display: block; }
.v2-alert-block { margin-bottom: var(--v2-space-4); padding: var(--v2-space-3); border-radius: var(--v2-radius-md); }
.v2-checkbox-row { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.v2-checkbox { margin: 0; flex-shrink: 0; width: 18px; height: 18px; cursor: pointer; }
.v2-checkbox-label { margin: 0; font-weight: 500; cursor: pointer; line-height: 1.4; flex: 1; }
.v2-leyenda-indent { margin-top: 4px; margin-left: 26px; display: block; }
.v2-section-title--sm { margin-bottom: 12px; font-size: 0.95em; }
.v2-result-resumen { padding: var(--v2-space-4); background: var(--v2-bg-subtle); border-radius: var(--v2-radius-md); border: 1px solid var(--v2-border); }
.v2-result-resumen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--v2-space-3); }
.v2-text-success { color: var(--v2-success, #28a745); }
.v2-text-danger { color: var(--v2-danger, #dc3545); }

/* ============================================
   FOOTER
   ============================================ */
.app-footer {
  text-align: center;
  color: var(--v2-text-muted);
  font-size: 0.85em;
}
.v2-container > footer.app-footer {
  width: 100%; max-width: none; margin-left: 0; margin-right: 0;
}
.app-footer strong { color: var(--v2-primary); }
.app-footer .version-info { margin-bottom: 10px; }
.app-footer .copyright { color: var(--v2-text-lighter); font-size: 0.9em; }
.app-footer .license { color: var(--v2-text-lighter); font-size: 0.85em; margin-top: 5px; }

/* ============================================
   FORM GRIDS V2
   ============================================ */
.v2-form-grid { display: grid; gap: 20px; margin-bottom: 20px; }
.v2-form-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.v2-form-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Configuración — Preferencias de usuario: 2×2 estable (evita auto-fit 3+1 con sidebar expandido) */
.v2-form-grid--preferencias-usuario {
  grid-template-columns: repeat(2, minmax(min(100%, 240px), 1fr));
  gap: 12px;
  margin-bottom: 12px;
  align-items: start;
}
.v2-form-grid--preferencias-usuario > div {
  min-width: 0;
}
.v2-form-grid--preferencias-usuario .v2-input {
  width: 100%;
  min-width: 0;
}
/* Sidebar colapsado y viewport amplio: una fila de cuatro campos */
@media (min-width: 1200px) {
  html.sidebar-collapsed .v2-form-grid--preferencias-usuario {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
/* Viewport muy ancho: cuatro columnas aunque el sidebar esté expandido */
@media (min-width: 1536px) {
  .v2-form-grid--preferencias-usuario {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.v2-form-grid--30-70 { grid-template-columns: 3fr 7fr; }
.v2-form-grid--30-20-50 { grid-template-columns: 3fr 2fr 5fr; }
.v2-form-grid--30-40-30 { grid-template-columns: 3fr 4fr 3fr; }
.v2-form-grid--40-30-30 { grid-template-columns: 4fr 3fr 3fr; }
.v2-col-span-2 { grid-column: span 2; }
.v2-col-span-3 { grid-column: span 3; }

/* ============================================
   ACTIONS ROW
   ============================================ */
.v2-actions-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.v2-actions-row--transferencias { justify-content: flex-end; }
.v2-actions-row__spacer { flex: 1; }
.v2-actions-row--no-margin { margin-top: 0; }

.v2-actions-inline {
  display: flex; gap: 8px; flex-wrap: nowrap;
  justify-content: center; align-items: center; margin-top: 0;
}
.v2-actions-inline .btn,
.v2-actions-inline .v2-btn { min-width: 80px; white-space: nowrap; }

.v2-form-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.v2-form-actions--center { justify-content: center; margin: 18px 0 8px; }

.v2-header-row {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}
.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white; padding: 25px;
  border-radius: var(--v2-radius-xl);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
.stat-card h3 { font-size: 2.5em; margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; word-wrap: break-word; line-height: 1.2; }
.stat-card p { font-size: 1.1em; opacity: 0.9; }
.stat-card.valor-total { display: flex; flex-direction: column; justify-content: center; }
.stat-card.valor-total h3 { font-size: clamp(1em, min(2.5em, 8vw), 2.5em); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; }

/* ============================================
   LOGIN PAGE
   ============================================ */
/* ============================================
   LOGIN — CLASSIC (NEUTRAL)
   ============================================ */
body.login-v2-body {
  background: var(--v2-bg-subtle) !important;
}
.login-v2-page { min-height: 100vh; background: inherit; display: flex; flex-direction: column; }
.login-v2-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.login-v2-shell { width: 500px; max-width: 90%; }
.login-v2-stack {
  background: var(--v2-bg); border-radius: 16px; padding: 32px 36px;
  box-shadow: var(--v2-shadow-md) !important;
  border: 1px solid var(--v2-border-light);
}
.login-v2-stack .header { background: transparent; box-shadow: none; padding: 0; margin-bottom: 24px; text-align: center; }
.login-v2-stack .header-title { margin-bottom: 8px; }
.login-v2-stack .header-subtitle { margin-bottom: 0; }
.login-v2-stack .header-table { margin: 0 auto; }
.login-v2-stack .header-table-cell.col-1,
.login-v2-stack .header-table-cell.col-2 { text-align: center; width: 100%; display: block; }
.login-v2-stack .header-title,
.login-v2-stack .header-subtitle,
.login-v2-header .header-title,
.login-v2-header .header-subtitle { text-align: center; }
.login-v2-header { text-align: center; }
.login-v2-card { width: 100%; max-width: 600px; background: transparent; border-radius: 12px; box-shadow: none; padding: 0; }
.login-v2-title { margin: 0 0 16px; font-size: 1.2em; font-weight: 600; color: var(--v2-text); }
.login-brand-logo { display: flex; justify-content: center; margin-top: 12px; }
.login-v2-logo { width: 350px; height: 130px; max-width: 90%; object-fit: contain; display: block; margin: 0 auto; }
.login-v2-submit { width: 50%; margin: 12px auto 0; display: block; }

/* ============================================
   GESTOR V2 — Module Cards
   ============================================ */
.gestor-v2-intro-card {
  background: var(--v2-bg); border-radius: 12px; padding: 20px 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); margin-bottom: 24px;
}
.gestor-v2-intro-card h2 { margin: 0 0 6px; color: var(--v2-primary); font-size: 1.4em; }

.gestor-v2-grid {
  display: grid; grid-template-columns: repeat(auto-fit, 220px);
  column-gap: 20px; row-gap: 20px; justify-content: space-between;
}
.module-card {
  width: 220px; height: 220px; background: var(--v2-bg); border: 1px solid var(--v2-border-light);
  border-radius: 12px; padding: 18px; text-decoration: none; color: var(--v2-text);
  box-shadow: var(--v2-shadow-sm); transition: box-shadow 0.2s ease, transform 0.2s ease;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
}
.module-card:hover { box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12); transform: translateY(-3px); text-decoration: none; }
.module-icon {
  width: 48px; height: 48px; border-radius: 12px; background: var(--v2-bg-lighter);
  border: 1px dashed #d0d7de; margin: 4px 0 12px;
}
.module-card-title { font-weight: 600; margin-bottom: 6px; font-size: 17px; color: var(--v2-primary); }
.module-card-desc { font-size: 13px; font-weight: 400; color: var(--v2-text-muted); line-height: 1.4; }
.module-card-badge {
  display: inline-block; margin-top: auto; padding: 4px 10px;
  border-radius: 12px; background: var(--v2-bg-lighter); color: var(--v2-text-muted);
  font-size: 12px; font-weight: 600;
}
.card-disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

/* ============================================
   UTILITIES
   ============================================ */
.mt-2 { margin-top: var(--v2-space-2); }
.mt-4 { margin-top: var(--v2-space-4); }
.mb-2 { margin-bottom: var(--v2-space-2); }
.mb-4 { margin-bottom: var(--v2-space-4); }
.v2-row-align-end { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.v2-field-narrow { max-width: 520px; width: 100%; }
.v2-table-section { margin-top: 20px; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .container { max-width: 100%; padding: 0; }
  .header { padding: 20px; }
  .header h1 { font-size: 1.8em; }
  .header > div:not(.header-table) { flex-direction: column !important; align-items: flex-start !important; gap: 15px; }
  .header-right { width: 100%; align-items: flex-start !important; }
  .header-acciones { justify-content: flex-start !important; flex-wrap: wrap; }
  .header .indicador-conexion-container { position: relative !important; top: auto !important; right: auto !important; margin-bottom: 10px; }
  .header-usuario-row { flex-wrap: wrap; gap: 8px; }
  .breadcrumbs { padding: 10px 15px; font-size: 12px; margin-bottom: 15px; }
  .breadcrumbs ol { flex-wrap: wrap; }
  .content-section { padding: 20px; }
  .v2-form-grid--two, .v2-form-grid--three,
  .v2-form-grid--preferencias-usuario,
  .v2-form-grid--30-70, .v2-form-grid--30-20-50,
  .v2-form-grid--30-40-30, .v2-form-grid--40-30-30 { grid-template-columns: 1fr; }
  .v2-col-span-2, .v2-col-span-3 { grid-column: span 1; }
  .v2-actions-row { flex-direction: column; }
  .v2-actions-row__spacer { display: none; }
  .v2-actions-inline { flex-wrap: wrap; }
  .v2-field-narrow { max-width: 100%; }
  .v2-row-align-end { flex-direction: column; align-items: stretch; }
  .indicador-conexion { top: 5px; right: 5px; padding: 6px 12px; font-size: 12px; }
  .stat-card.valor-total h3 { font-size: clamp(0.9em, 6vw, 1.8em); }
  .app-footer { padding: 15px; font-size: 0.8em; }
  .gestor-v2-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); justify-content: center; }
  .module-card { width: 100%; height: 220px; }
}
@media (max-width: 480px) {
  .header { padding: 15px !important; }
  .header h1 { font-size: 1.5em !important; }
  .header p { font-size: 1em !important; }
  .content-section { padding: 10px; }
  .app-footer { padding: 10px; font-size: 0.75em; }
}

/* ============================================
   HEADER REFINEMENT — CLASSIC DENSITY
   ============================================ */

/* Usuario más pequeño y menos dominante */
.app-header .header .header-usuario-nombre {
  font-size: 0.82em !important;
  font-weight: 600 !important;
  color: var(--v2-text-muted) !important;
}

/* Título con mayor contraste */
.app-header .header .header-title,
.app-header .header h1 {
  color: var(--v2-primary-hover) !important;
  font-weight: 700 !important;
}

/* ============================================
   FOOTER — DOS FILAS REALES
   ============================================ */

/* Fila 1: version-info */
.app-main > footer.app-footer .version-info {
  margin-bottom: 4px !important;
}

/* Fila 2: copyright + license en línea */
.app-main > footer.app-footer .copyright,
.app-main > footer.app-footer .license {
  display: inline !important;
  margin: 0 !important;
}

/* Separador visual entre copyright y license */
.app-main > footer.app-footer .license::before {
  content: " · ";
}

/* ============================================
   NAV-TABS — COMPACT SUBNAV (Classic Shell)
   ============================================ */

/* La card que envuelve los tabs: más delgada, menos protagonista */
.v2-tabs-card {
  padding: 8px 12px !important;
  border-radius: var(--v2-radius-lg) !important;
}

/* Si hay margen raro, controlarlo como bloque subnav */
.v2-tabs-card {
  margin-top: 0 !important;
}

/* Ajuste general: los links/botones dentro de tabs suelen venir con padding grande.
   Reducimos sin conocer markup exacto: apuntamos a anchors/buttons dentro del bloque. */
.v2-tabs-card a,
.v2-tabs-card button {
  padding: 6px 10px !important;
  font-size: 0.82em !important;
  line-height: 1.1 !important;
}

/* Si el módulo usa listas tipo nav-tabs */
.v2-tabs-card .nav-tabs,
.v2-tabs-card ul.nav,
.v2-tabs-card ul {
  margin: 0 !important;
}

/* Separación sutil para que no "pegue" al contenido */
.v2-tabs-card + .content-wrapper {
  margin-top: 8px;
}

/* ============================================
   SIDEBAR v1 — TEXT LINKS (Classic)
   ============================================ */

.app-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--v2-space-4);
}

.sidebar-brand strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--v2-primary-hover);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.sidebar-link {
  display: block;
  padding: 8px 10px;
  border-radius: var(--v2-radius-md);
  color: var(--v2-text);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.1;
}

.sidebar-link:hover {
  background: var(--v2-bg-lighter);
  text-decoration: none;
}

.sidebar-link.is-active {
  background: var(--v2-primary-light);
  color: var(--v2-primary-hover);
  font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--v2-space-3);
  border-top: 1px solid var(--v2-border-light);
}

.sidebar-version {
  font-size: 0.8rem;
  color: var(--v2-text-muted);
}

/* ============================================
   CLASSIC — NEUTRAL BACKGROUND (post-login)
   ============================================ */

/* Fondo general neutro para toda la app */
body {
  background: var(--v2-bg-subtle) !important;
}

/* Sidebar: neutro, no "escuela" */
.app-sidebar {
  background: var(--v2-bg-lighter) !important;
}

/* Main: neutro y consistente */
.app-main {
  background: transparent !important;
}

/* Mantener cards blancas (ya lo están por --v2-bg) */
.v2-card {
  background: var(--v2-bg) !important;
}

/* Login: fondo neutro alineado con Classic */
body.login-v2-body {
  background: var(--v2-bg-subtle) !important;
}

/* ============================================
   SIDEBAR v2 — GROUPING + ACTIVE REFINED
   ============================================ */

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.sidebar-group:first-child {
  margin-top: 0;
}

.sidebar-group-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--v2-text-muted);
  margin: 2px 0 4px;
}

/* Links más sobrios */
.sidebar-link {
  padding: 8px 10px;
  border-radius: var(--v2-radius-md);
  color: var(--v2-text);
  text-decoration: none;
  font-size: 0.9rem;
}

/* Hover neutro */
.sidebar-link:hover {
  background: var(--v2-bg-subtle);
  text-decoration: none;
}

/* Active: más "anclado" */
.sidebar-link.is-active {
  background: #ffffff !important;
  border: 1px solid var(--v2-border-light);
  box-shadow: var(--v2-shadow-sm);
  color: var(--v2-primary-hover) !important;
  font-weight: 800;
}

/* ============================================
   HEADER — SUBTITLE ONLY (Classic)
   ============================================ */

/* Al usar solo una fila, el subtítulo pasa a ser "título" */
.app-header .header .header-subtitle-text {
  font-size: 1.0em !important;
  font-weight: 700 !important;
  color: var(--v2-primary-hover) !important;
}

/* Elimina spacing vertical innecesario del header-table */
.app-header .header .header-table {
  padding: 0 !important;
}

.app-header .header .header-table-cell {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* Opcional: ajustar alineación vertical de usuario/acciones */
.app-header .header .header-usuario-nombre {
  align-self: center;
}

/* ============================================
   ALIGN — HEADER TOP WITH SIDEBAR TOP
   ============================================ */

/* 1) El main no debe empujar el header hacia abajo más que la sidebar */
.app-main {
  padding-top: var(--v2-space-5) !important; /* asegura coherencia */
}

/* 2) El header no debe tener margen superior extra */
.app-header {
  margin-top: 0 !important;
}

/* 3) Si el primer elemento dentro del main (header card) trae margen colapsado, lo neutralizamos */
.app-header .header {
  margin-top: 0 !important;
}

/* Último recurso: quitar padding superior heredado del contenedor interno */
.app-main .v2-container {
  padding-top: 0 !important;
}
/* Prevent horizontal overflow caused by wide children inside grid/flex */
.app-main { min-width: 0; }
.app-content { min-width: 0; }

/* ============================================
   ACTIONS BAR — RIGHT ALIGNED (Classic Inventory)
   ============================================ */

.v2-actions-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--v2-space-3);
  margin-top: var(--v2-space-3);
  margin-bottom: var(--v2-space-4);
}



/* ============================================
   INVENTARIO POST-TABLE ACTIONS
   ============================================ */

.v2-actions-bar--post-table {
  display: flex;
  justify-content: flex-end;
  gap: var(--v2-space-3);
  margin-top: var(--v2-space-4);
}

