/* css/main.css - Sistema de Diseño "Donezo / Eye-Care Forest Slate" (Anti-Fatiga Visual) */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Paleta Anti-Fatiga Visual (Eye-Care Forest Slate) */
  --bg-app: #0D131A;              /* Fondo general descansado / carbón pizarra */
  --bg-sidebar: #131C27;          /* Barra lateral elegante */
  --bg-card: #182230;             /* Tarjetas y paneles principales */
  --bg-card-muted: #111823;       /* Fondos secundarios de inputs y chips */
  --bg-input: #111823;            /* Inputs limpios */
  --bg-input-focus: #141E2C;
  
  --border-color: rgba(255, 255, 255, 0.08); /* Bordes sutiles */
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-focus: #10B981;

  --text-primary: #F8FAFC;        /* Blanco tiza de alta legibilidad sin encandilar */
  --text-secondary: #94A3B8;      /* Gris intermedio suave */
  --text-muted: #64748B;          /* Gris tenue para subtítulos */
  
  /* Verde Bosque & Esmeralda (Acento Principal) */
  --accent-forest: #10B981;
  --accent-forest-dark: #064E3B;
  --accent-forest-light: #34D399;
  
  /* Verde Menta / Lima */
  --accent-mint: #34D399;
  --accent-mint-bg: rgba(16, 185, 129, 0.14);
  --accent-mint-text: #6EE7B7;
  --accent-lime: #A3E635;
  
  /* Estados Financieros */
  --accent-blue: #38BDF8;
  --accent-blue-bg: rgba(56, 189, 248, 0.12);
  --accent-rose: #F43F5E;
  --accent-rose-bg: rgba(244, 63, 94, 0.14);
  --accent-rose-text: #FDA4AF;
  --accent-amber: #F59E0B;
  --accent-amber-bg: rgba(245, 158, 11, 0.14);

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.45);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Ocultar flechas de inputs numéricos */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* =========================================================================
   LAYOUT PRINCIPAL: SIDEBAR + MAIN CONTENT
   ========================================================================= */
.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-app);
}

/* SIDEBAR VERTICAL */
.app-sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem 1.75rem 0.5rem;
}

.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.sidebar-logo-text {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-section-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 1.25rem 0.5rem 0.5rem 0.5rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-tab.active {
  background: var(--accent-mint-bg);
  color: var(--accent-mint-text);
  font-weight: 700;
  border-left: 3px solid var(--accent-forest);
}

.nav-tab-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.nav-tab-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.nav-tab.active .nav-tab-badge {
  background: var(--accent-forest);
  color: #064E3B;
  font-weight: 800;
}

/* WIDGET INFERIOR DE SIDEBAR */
.sidebar-promo-widget {
  background: linear-gradient(135deg, #064E3B 0%, #032E23 100%);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

.sidebar-promo-widget::before {
  content: "";
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.2) 0%, transparent 70%);
}

.sidebar-promo-title {
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1.2;
}

.sidebar-promo-sub {
  font-size: 0.7rem;
  color: #A7F3D0;
  line-height: 1.3;
}

.sidebar-promo-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.sidebar-promo-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* =========================================================================
   CONTENEDOR PRINCIPAL Y HEADER SUPERIOR
   ========================================================================= */
.app-main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

/* Barra de Búsqueda Superior */
.header-search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.45rem 1rem;
  width: 100%;
  max-width: 360px;
  transition: all 0.2s ease;
}

.header-search-bar:focus-within {
  background: #141E2C;
  border-color: var(--accent-forest);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.header-search-input {
  border: none !important;
  background: transparent !important;
  outline: none !important;
  font-size: 0.8rem !important;
  color: var(--text-primary) !important;
  width: 100%;
  box-shadow: none !important;
  padding: 0 !important;
}

.header-kbd-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--bg-card-muted);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.header-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.header-user-profile {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border-color);
}

.header-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #059669, #0284C7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* =========================================================================
   PANELES Y TARJETAS LIMPIAS (DARK FOREST SLATE)
   ========================================================================= */
.main-content {
  padding: clamp(1rem, 1.5vw, 1.75rem);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 1560px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.clean-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

/* Tarjetas KPI Superiores (5 Tarjetas en la fila 1) - Totalmente responsivas */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  width: 100%;
}

@media (min-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: clamp(0.55rem, 0.8vw, 0.95rem);
  }
}

/* Tarjeta KPI 1 - Hero Forest Green */
.kpi-card-hero {
  background: linear-gradient(135deg, #064E3B 0%, #032E23 100%);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--radius-xl);
  padding: 1.15rem 1rem;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 10px 25px -4px rgba(6, 78, 59, 0.4);
  position: relative;
  min-height: 142px;
  min-width: 0;
  overflow: hidden;
}

.kpi-card-hero .kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-card-hero .kpi-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #A7F3D0;
}

.kpi-card-hero .kpi-circle-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: all 0.2s;
}

.kpi-card-hero .kpi-circle-btn:hover {
  background: #FFFFFF;
  color: #064E3B;
}

.kpi-card-hero .kpi-value {
  font-size: clamp(1.2rem, 1.4vw, 1.65rem);
  font-weight: 800;
  color: #FFFFFF;
  margin: 0.35rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.02em;
}

.kpi-card-hero .kpi-tag {
  font-size: 0.7rem;
  color: #D1FAE5;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tarjetas KPI 2, 3, 4 - Dark Slate */
.kpi-card-white {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.15rem 1rem;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  min-height: 142px;
  min-width: 0;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.kpi-card-white:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.15);
}

.kpi-card-white .kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-card-white .kpi-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-card-white .kpi-circle-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--bg-card-muted);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.kpi-card-white .kpi-circle-btn:hover {
  background: var(--accent-forest);
  color: #064E3B;
  border-color: var(--accent-forest);
}

.kpi-card-white .kpi-value {
  font-size: clamp(1.2rem, 1.4vw, 1.65rem);
  font-weight: 800;
  color: var(--text-primary);
  margin: 0.35rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.02em;
}

.kpi-card-white .kpi-tag {
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================================
   SISTEMA DE BOTONES ELEGANTES REDONDEADOS
   ========================================================================= */
button {
  font-family: var(--font-sans);
  border: none;
  outline: none;
}

/* Botón Principal: Verde Esmeralda Redondeado (Pill) */
.btn-primary {
  background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
  color: #FFFFFF !important;
  border: 1px solid rgba(52, 211, 153, 0.4) !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  padding: 0.6rem 1.35rem !important;
  border-radius: var(--radius-full) !important;
  cursor: pointer !important;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.45rem !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45) !important;
}

.btn-primary:active {
  transform: translateY(0) !important;
}

/* Botón Secundario: Dark Slate con Borde Fino */
.btn-secondary {
  background: var(--bg-card-muted) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  padding: 0.55rem 1.15rem !important;
  border-radius: var(--radius-full) !important;
  cursor: pointer !important;
  box-shadow: var(--shadow-sm) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.4rem !important;
  transition: all 0.2s ease !important;
}

.btn-secondary:hover {
  background: #182230 !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  color: #FFFFFF !important;
  transform: translateY(-1px) !important;
}

/* Alternador de Clase (+ Otorgamiento / - Anulación) */
.btn-clase {
  background: var(--bg-card-muted) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border-color) !important;
  font-size: 0.78rem !important;
  font-weight: 700 !important;
  padding: 0.45rem 1.1rem !important;
  border-radius: var(--radius-full) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.btn-clase:hover {
  color: var(--text-primary) !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.btn-clase.active#btn-toggle-otorgamiento {
  background: linear-gradient(135deg, #059669, #047857) !important;
  color: #FFFFFF !important;
  border-color: #10B981 !important;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.35) !important;
}

.btn-clase.active#btn-toggle-anulacion {
  background: linear-gradient(135deg, #E11D48, #BE123C) !important;
  color: #FFFFFF !important;
  border-color: #F43F5E !important;
  box-shadow: 0 3px 10px rgba(225, 29, 72, 0.35) !important;
}

/* =========================================================================
   INPUTS Y SELECTS LIMPIOS
   ========================================================================= */
input, select, textarea {
  font-family: var(--font-sans);
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  padding: 0.6rem 0.85rem !important;
  border-radius: var(--radius-md) !important;
  font-size: 0.82rem !important;
  outline: none !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2) !important;
  transition: all 0.2s ease !important;
}

input:focus, select:focus, textarea:focus {
  background: var(--bg-input-focus) !important;
  border-color: var(--accent-forest) !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2) !important;
}

select {
  cursor: pointer;
}

select option {
  background: #111823;
  color: #F8FAFC;
}

.form-input {
  width: 100%;
}

/* =========================================================================
   TABLAS Y BADGES
   ========================================================================= */
.table-custom {
  width: 100%;
  text-align: left;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.table-custom th {
  padding: 0.75rem 0.85rem;
  background: var(--bg-card-muted);
  color: var(--text-secondary);
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table-custom td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.table-custom tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}

.badge-ok {
  background: var(--accent-mint-bg);
  color: var(--accent-mint-text);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-revisar {
  background: var(--accent-amber-bg);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-error {
  background: var(--accent-rose-bg);
  color: var(--accent-rose-text);
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.badge-otorgamiento {
  background: var(--accent-blue-bg);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.badge-anulacion {
  background: var(--accent-rose-bg);
  color: var(--accent-rose-text);
  border: 1px solid rgba(244, 63, 94, 0.25);
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: #0D131A;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #1E293B;
  border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* =========================================================================
   FILA 3 DEL DASHBOARD (Estado Contable + Conciliación + Período)
   ========================================================================= */
.dash-row-3 {
  display: grid;
  grid-template-columns: 1.4fr 1.2fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 1080px) {
  .dash-row-3 { grid-template-columns: 1fr; }
}

/* Widget Clientes Nuevos */
.clientes-nuevos-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.9rem;
  position: relative;
  overflow: hidden;
}
.clientes-nuevos-card::before {
  content: '';
  position: absolute;
  inset: -40% -30% auto auto;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.16) 0%, transparent 70%);
  pointer-events: none;
}
.clientes-nuevos-valor {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  margin-bottom: 0.4rem;
  transition: transform 0.3s ease;
}
.clientes-nuevos-card:hover .clientes-nuevos-valor { transform: scale(1.04); }

.cli-nuevos-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 64px;
  flex: 1;
  max-width: 170px;
}
.cli-nuevos-bar {
  flex: 1;
  min-height: 4px;
  border-radius: 4px 4px 2px 2px;
  background: rgba(148, 163, 184, 0.18);
  transition: height 0.5s cubic-bezier(.2,.8,.2,1), background 0.2s ease;
  cursor: default;
}
.cli-nuevos-bar.is-prev { background: rgba(56, 189, 248, 0.45); }
.cli-nuevos-bar.is-active {
  background: linear-gradient(180deg, #34D399 0%, #10B981 100%);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.45);
}
.cli-nuevos-bar:hover { background: rgba(148, 163, 184, 0.4); }
.cli-nuevos-bar.is-active:hover { background: #34D399; }

.cli-nuevos-prev {
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-color);
  padding-top: 0.55rem;
}
.cli-nuevos-prev strong { color: var(--text-secondary); }

/* =========================================================================
   MODO EDICIÓN DE NOMBRES DEL DASHBOARD
   ========================================================================= */
body.editando-nombres [data-label-key] {
  outline: 1px dashed rgba(56, 189, 248, 0.7);
  outline-offset: 2px;
  border-radius: 4px;
  cursor: text;
  background: rgba(56, 189, 248, 0.06);
  transition: background 0.15s ease, outline-color 0.15s ease;
}
body.editando-nombres [data-label-key]:hover {
  background: rgba(56, 189, 248, 0.14);
}
body.editando-nombres [data-label-key]:focus {
  outline: 2px solid #38BDF8;
  background: rgba(56, 189, 248, 0.18);
}
#btn-editar-nombres.activo {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.6);
  color: #bae6fd;
}

/* =========================================================================
   MÓDULO DE USUARIOS, ROLES Y PERMISOS GRANULARES
   ========================================================================= */
.badge-role-admin {
  background: rgba(147, 51, 234, 0.15);
  color: #C084FC;
  border: 1px solid rgba(147, 51, 234, 0.35);
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}
.badge-role-gestor {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}
.badge-role-auditor {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}
.badge-role-custom {
  background: rgba(148, 163, 184, 0.15);
  color: #CBD5E1;
  border: 1px solid rgba(148, 163, 184, 0.35);
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

.perm-tag {
  display: inline-block;
  font-size: 0.62rem;
  background: var(--bg-card-muted);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  margin: 0.1rem 0.15rem;
  font-family: var(--font-mono);
}
.perm-tag.is-active {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.3);
}

.perm-matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
}
.perm-group-card {
  background: var(--bg-card-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.perm-group-title {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}
.perm-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 0.2rem 0;
  transition: color 0.15s ease;
}
.perm-checkbox-row:hover {
  color: var(--text-primary);
}
.perm-checkbox-row input[type="checkbox"] {
  cursor: pointer;
  accent-color: #38BDF8;
  margin-top: 2px;
}
.perm-checkbox-row.sensible {
  color: #fca5a5;
}
.perm-checkbox-row.sensible:hover {
  color: #f87171;
}

.nav-tab.disabled-by-role {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(1);
}

.server-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.12);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.server-status-pill.offline {
  background: rgba(239, 68, 68, 0.12);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.3);
}
.server-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 8px #10B981;
}
.server-status-pill.offline .server-status-dot {
  background: #EF4444;
  box-shadow: 0 0 8px #EF4444;
}

/* Restricción de Controles Administrativos (+ Administrar, Reset, Escenarios de Prueba) */
.admin-only-control {
  display: none !important;
}

body.is-admin .admin-only-control {
  display: inline-block !important;
}

body.is-admin button.admin-only-control,
body.is-admin .btn-secondary.admin-only-control,
body.is-admin .btn-primary.admin-only-control {
  display: inline-flex !important;
  align-items: center;
  white-space: nowrap !important;
  flex-shrink: 0;
}



