/* styles.css - CRM Aitor Dorronsoro */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --primary-color: #274c40;
  --primary-hover: #1e3c32;
  --primary-light: #e8f0ec;
  --accent-color: #00b4d8;
  --bg-gradient: linear-gradient(135deg, #1d332c 0%, #2b4c41 50%, #172a24 100%);
  --surface-bg: #f8faf9;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --success-color: #10b981;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   PANTALLA DE LOGIN (SEGÚN DISEÑO ADJUNTO)
   ========================================================================== */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 2.8rem 2.2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

.brand-header {
  margin-bottom: 2rem;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 700;
  color: #1e3930;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  color: #c07a50;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-top: 4px;
}

.lock-icon-wrapper {
  margin: 1.2rem 0;
  font-size: 3.2rem;
  line-height: 1;
  display: inline-block;
}

.login-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  color: #274c40;
  margin-bottom: 0.3rem;
}

.login-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 1.8rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.input-styled {
  width: 100%;
  padding: 0.95rem 1.2rem;
  border: 1.5px solid #dcdfe4;
  border-radius: 12px;
  font-size: 1rem;
  font-family: var(--font-body);
  transition: all 0.2s ease;
  outline: none;
  background-color: #fafbfc;
}

.input-styled:focus {
  border-color: var(--primary-color);
  background-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(39, 76, 64, 0.12);
}

.btn-primary-submit {
  width: 100%;
  padding: 1rem;
  background-color: #2b4e43;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary-submit:hover {
  background-color: #1e3930;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(30, 57, 48, 0.25);
}

.back-link-wrapper {
  margin-top: 1.8rem;
}

.back-link {
  color: #4b635a;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.back-link:hover {
  color: #1e3930;
  text-decoration: underline;
}

.error-message {
  background-color: #fef2f2;
  color: #dc2626;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 1rem;
  display: none;
  border: 1px solid #fecaca;
}

/* ==========================================================================
   PANEL CRM (INTERFAZ DE BASE DE DATOS)
   ========================================================================== */
.crm-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #f1f5f9;
}

/* Header superior */
.crm-header {
  background-color: #1b2e27;
  color: #ffffff;
  padding: 0.9rem 1.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
}

.crm-brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
}

.crm-brand-badge {
  background: rgba(255,255,255,0.15);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  color: #a7f3d0;
}

.crm-user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #fca5a5;
}

/* Barra de pestañas y herramientas */
.crm-subbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.8rem 0 1.8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  padding: 0.75rem 1.4rem;
  border: none;
  background: none;
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--primary-color);
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.tab-counter {
  background-color: #e2e8f0;
  color: #475569;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 12px;
}

.tab-btn.active .tab-counter {
  background-color: var(--primary-color);
  color: #ffffff;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding-bottom: 0.75rem;
}

.sort-select {
  padding: 0.55rem 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  background-color: #f8fafc;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

.btn-add-client {
  background-color: #10b981;
  color: #ffffff;
  border: none;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.btn-add-client:hover {
  background-color: #059669;
  transform: translateY(-1px);
}

.btn-filter-toggle {
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-filter-toggle:hover {
  background-color: #e2e8f0;
}

/* Panel de Filtros Avanzados */
.filter-panel {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 1.2rem 1.8rem;
  display: none;
  animation: slideDown 0.25s ease-out;
}

.filter-panel.open {
  display: block;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-input, .filter-select {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  background-color: #f8fafc;
}

.filter-input:focus, .filter-select:focus {
  border-color: var(--primary-color);
  outline: none;
  background-color: #fff;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
  margin-top: 1rem;
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

/* Contenido Principal / Tabla Data Grid */
.crm-content {
  flex: 1;
  padding: 1.5rem 1.8rem;
  overflow-x: auto;
}

.table-container {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow-x: auto;
}

.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  text-align: left;
  white-space: nowrap;
}

.db-table th {
  background-color: #233e34;
  color: #ffffff;
  font-family: var(--font-heading);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 2px solid #162922;
  position: sticky;
  top: 0;
  z-index: 10;
}

.db-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.db-table tbody tr {
  transition: background-color 0.15s ease;
}

.db-table tbody tr:hover {
  background-color: #f8fafc;
}

/* Estilos de Insignias / Badges para Canales Comerciales */
.badge-channel {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
}

.badge-channel-naturelek {
  background-color: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.badge-channel-iner {
  background-color: #ffedd5;
  color: #c2410c;
  border-color: #fdba74;
}

.badge-channel-wakeup {
  background-color: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
}

.badge-channel-eraso {
  background-color: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.badge-channel-o2 {
  background-color: #e0f2fe;
  color: #0369a1;
  border-color: #7dd3fc;
}

.badge-channel-default {
  background-color: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

/* Selector de Menú de Servicios en la barra superior */
.service-nav-bar {
  background: #14241e;
  padding: 0.6rem 1.8rem;
  display: flex;
  gap: 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}

.service-tab-btn {
  background: rgba(255,255,255,0.08);
  color: #94a3b8;
  border: 1px solid rgba(255,255,255,0.12);
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.service-tab-btn:hover {
  background: rgba(255,255,255,0.18);
  color: #ffffff;
}

.service-tab-btn.active {
  background: #274c40;
  color: #ffffff;
  border-color: #10b981;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.service-counter-badge {
  background: rgba(255,255,255,0.15);
  color: #e2e8f0;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}

.service-tab-btn.active .service-counter-badge {
  background: #10b981;
  color: #ffffff;
}

/* ==========================================================================
   ESTILOS DEL DASHBOARD DE INICIO Y KPI CARDS
   ========================================================================== */
.dashboard-container {
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}

.kpi-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.2rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
}

.kpi-primary {
  border-left: 4px solid #10b981;
}

.kpi-energia {
  border-left: 4px solid #f59e0b;
}

.kpi-telefonia {
  border-left: 4px solid #3b82f6;
}

.kpi-seguros {
  border-left: 4px solid #8b5cf6;
}

.kpi-danger {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-left: 4px solid #ef4444;
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.kpi-title {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #475569;
}

.kpi-badge-danger {
  background: #ef4444;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.kpi-body {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  margin: 0.5rem 0;
  width: 100%;
}

.kpi-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
  text-align: center;
  display: block;
}

.kpi-sublabel {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 600;
  text-align: center;
  display: block;
  margin-top: 4px;
}

.kpi-divider {
  width: 1px;
  height: 34px;
  background: #e2e8f0;
  flex-shrink: 0;
}

.kpi-divider.red {
  background: #fca5a5;
}

.text-red {
  color: #dc2626 !important;
  text-align: center !important;
}


.kpi-footer-breakdown {
  margin-top: 0.8rem;
  padding-top: 0.6rem;
  border-top: 1px dashed #fca5a5;
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
}

/* ==========================================================================
   ESTILOS DE LA GRÁFICA DE BARRAS INTERACTIVA
   ========================================================================== */
.chart-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.chart-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: #0f172a;
  margin-bottom: 0.2rem;
}

.chart-desc {
  font-size: 0.85rem;
  color: #64748b;
}

.chart-controls {
  display: flex;
  gap: 0.8rem;
}

.chart-legend {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-box {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-box.green {
  background: #10b981;
}

.legend-box.red {
  background: #ef4444;
}

.legend-box.blue {
  background: #0284c7;
}

.legend-box.purple {
  background: #7c3aed;
}

/* Visualizador de Barras CSS/HTML */
.chart-wrapper {
  display: flex;
  align-items: flex-end;
  height: 260px;
  gap: 1rem;
  padding: 1.5rem 0.5rem 0.5rem 2.5rem;
  border-left: 2px solid #cbd5e1;
  border-bottom: 2px solid #cbd5e1;
  position: relative;
  margin-top: 1rem;
}

.chart-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.chart-bars-group {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  width: 100%;
  justify-content: center;
  height: 100%;
}

.bar-item {
  width: 45%;
  max-width: 24px;
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease;
  position: relative;
}

.bar-item.altas {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
}

.bar-item.bajas {
  background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
}

.bar-item.clientes {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
}

.bar-item.contratos {
  background: linear-gradient(180deg, #a78bfa 0%, #7c3aed 100%);
}

.bar-val {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 700;
  color: #334155;
}

.chart-label {
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  text-align: center;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  border: none;
  background: #f1f5f9;
  color: #475569;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-icon:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

.btn-icon.edit:hover {
  background-color: #dbeafe;
  color: #1d4ed8;
}

.btn-icon.toggle:hover {
  background-color: #fef3c7;
  color: #b45309;
}

/* MODAL DE ADICIÓN / EDICIÓN */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-backdrop.active,
.modal-backdrop.open {
  display: flex !important;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 850px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  background-color: #1b2e27;
  color: #ffffff;
  padding: 1.2rem 1.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.8;
}

.modal-close:hover {
  opacity: 1;
}

.modal-body {
  padding: 1.8rem;
}

.form-section-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: #274c40;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.4rem;
  margin-top: 1.2rem;
  margin-bottom: 1rem;
}

.form-section-title:first-child {
  margin-top: 0;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.modal-footer {
  padding: 1.2rem 1.8rem;
  background-color: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Animaciones */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mensajes Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.3s ease-out;
}

.toast.success {
  border-left: 4px solid #10b981;
}

.toast.error {
  border-left: 4px solid #ef4444;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   ESTILOS BOTONES HEADER, BANNER DE ALERTAS Y BUSCADOR GLOBAL INTELIGENTE
   ========================================================================== */
.btn-secondary-head {
  appearance: none;
  -webkit-appearance: none;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  outline: none;
  white-space: nowrap;
}

.btn-secondary-head:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.btn-secondary-head:active {
  transform: translateY(0);
}

/* Banner de Alerta de Renovaciones */
.renewal-banner {
  border-radius: 12px;
  padding: 1.1rem 1.4rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  animation: fadeIn 0.3s ease-out;
  transition: all 0.3s ease;
}

.renewal-banner.banner-warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 5px solid #f97316;
}

.renewal-banner.banner-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 5px solid #22c55e;
}

.renewal-banner.banner-info {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-left: 5px solid #0284c7;
}



.banner-content {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
}

.banner-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: #9a3412;
}

.banner-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.banner-item {
  font-size: 0.9rem;
  color: #7c2d12;
  background: rgba(255, 255, 255, 0.6);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  border: 1px solid #fed7aa;
}

.banner-close-btn {
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: #9a3412;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  padding: 0 4px;
}

.banner-close-btn:hover {
  opacity: 1;
}

/* Buscador Global Inteligente */
.global-search-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 1.4rem;
  margin-bottom: 1.8rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.global-search-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.global-search-label {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
}

.global-search-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.global-search-field {
  font-size: 1.05rem;
  padding: 1rem 1.2rem;
  border-color: #cbd5e1;
}

.global-search-field:focus {
  border-color: #00b4d8;
  box-shadow: 0 0 0 4px rgba(0, 180, 216, 0.15);
}

.global-search-results {
  margin-top: 1rem;
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.search-result-item {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: #ffffff;
}

.search-res-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.search-res-name {
  font-weight: 700;
  color: #0f172a;
  font-size: 0.95rem;
}

.search-res-details {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.search-res-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-service {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-service.energia { background: #dcfce7; color: #15803d; }
.badge-service.telefonia { background: #ffedd5; color: #c2410c; }
.badge-service.seguros { background: #e0f2fe; color: #0369a1; }

.badge-status {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-status.activo { background: #e0e7ff; color: #4338ca; }
.badge-status.eliminado { background: #fee2e2; color: #b91c1c; }

.search-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Styling Tarjeta KPI Ingresos */
.kpi-card.kpi-ingresos {
  border-top: 4px solid #16a34a;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}
.kpi-card.kpi-ingresos .kpi-title {
  color: #15803d;
}
.text-green {
  color: #16a34a !important;
}

/* ==========================================================================
   NUEVO MÓDULO DUAL (CLIENTES VS SOCIOS) Y GESTIÓN DE SOCIOS
   ========================================================================== */
.main-mode-bar {
  display: flex;
  background: #152922;
  border-bottom: 2px solid #274c40;
  padding: 0 1rem;
  gap: 0.5rem;
}

.main-mode-btn {
  padding: 0.9rem 1.6rem;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: #94a3b8;
  background: transparent;
  border: none;
  border-bottom: 4px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.main-mode-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.main-mode-btn.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border-bottom-color: #10b981;
}

/* Fila de Socio Firmado (Destacado Verde) */
tr.row-firmado {
  background-color: rgba(16, 185, 129, 0.14) !important;
  border-left: 4px solid #059669 !important;
}
tr.row-firmado:hover {
  background-color: rgba(16, 185, 129, 0.22) !important;
}

.btn-firmado-toggle {
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s ease;
}

.btn-firmado-toggle.firmado {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.btn-firmado-toggle.no-firmado {
  background: #e2e8f0;
  color: #64748b;
}

.btn-firmado-toggle.no-firmado:hover {
  background: #cbd5e1;
  color: #334155;
}

/* Badges de Color */
.badge-color {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.badge-color-verde { background: #16a34a; }
.badge-color-amarillo { background: #d97706; }
.badge-color-rojo { background: #dc2626; }
.badge-color-marron { background: #78350f; }

/* Badges de Estado del Sistema */
.badge-estado {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
}
.badge-estado-contactado { background: #e0f2fe; color: #0369a1; }
.badge-estado-presentacion { background: #fae8ff; color: #86198f; }
.badge-estado-cierre { background: #fef3c7; color: #b45309; }
.badge-estado-arranque { background: #ffedd5; color: #c2410c; }
.badge-estado-comenzado { background: #dcfce7; color: #15803d; }

/* Estilos de Ranking de Invitadores */
.ranking-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.ranking-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  transition: transform 0.2s;
}

.ranking-card-item:hover {
  transform: translateY(-2px);
  border-color: #10b981;
}

.ranking-user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ranking-position-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #047857;
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.ranking-position-badge.pos-1 { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); font-size: 1.1rem; }
.ranking-position-badge.pos-2 { background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%); }
.ranking-position-badge.pos-3 { background: linear-gradient(135deg, #b45309 0%, #78350f 100%); }

.ranking-name {
  font-weight: 700;
  color: #1e293b;
  font-size: 0.95rem;
}

.ranking-stats-badge {
  text-align: right;
}

.ranking-total-count {
  font-size: 1.1rem;
  font-weight: 800;
  color: #047857;
}

.ranking-subtext {
  font-size: 0.75rem;
  color: #64748b;
}

/* Gráfica de Socios Expandida con Valores Visibles */
#chart-socios-bars-container {
  height: 320px !important;
  display: flex !important;
  align-items: flex-end !important;
  gap: 1.5rem !important;
  padding: 1.5rem 1rem 0.5rem 1rem !important;
  overflow-x: auto !important;
}

.chart-col {
  flex: 1;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.chart-bars-group {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  width: 100%;
  justify-content: center;
  height: calc(100% - 30px);
}

.bar-item {
  width: 18px;
  border-radius: 4px 4px 0 0;
  position: relative;
  display: flex;
  justify-content: center;
  transition: height 0.3s ease;
}

.bar-val {
  position: absolute;
  top: -24px;
  font-size: 0.75rem;
  font-weight: 800;
  color: #1e293b;
  background: #ffffff;
  padding: 1px 5px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  white-space: nowrap;
}

.chart-month-label {
  margin-top: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
}

/* Modal de Importación de CSV / Excel */
.import-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s;
}

.import-dropzone:hover {
  border-color: #0284c7;
  background: #f0f9ff;
}

.import-preview-table-wrapper {
  max-height: 250px;
  overflow-y: auto;
  margin-top: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.import-preview-table th, .import-preview-table td {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  text-align: left;
  white-space: nowrap;
}

.import-preview-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: #334155;
  position: sticky;
  top: 0;
}



/* Celda de texto truncado con ellipsis para columnas de socios */
.socios-td-clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   CELDAS EXPANDIBLES (SU PORQUÉ / COMENTARIOS EN TABLA DE SOCIOS)
   ========================================================================== */
.expandable-cell {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
}

.cell-preview {
  font-size: 0.84rem;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
  display: inline-block;
  vertical-align: middle;
}

.btn-expand-text,
.btn-collapse-text {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
  vertical-align: middle;
}

.btn-expand-text {
  background: #0ea5e9;
  color: #ffffff;
}

.btn-expand-text:hover {
  background: #0284c7;
  transform: scale(1.15);
}

.btn-collapse-text {
  background: #64748b;
  color: #ffffff;
  margin-bottom: 6px;
  align-self: flex-end;
}

.btn-collapse-text:hover {
  background: #334155;
  transform: scale(1.15);
}

/* Panel flotante que despliega hacia abajo */
.cell-expanded-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 300;
  background: #1e293b;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  min-width: 220px;
  max-width: 320px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0,0,0,0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: fadeInDown 0.18s ease-out;
}

.expanded-panel-inner {
  display: flex;
  flex-direction: column;
}

.expanded-panel-text {
  font-size: 0.85rem;
  color: #e2e8f0;
  line-height: 1.6;
  white-space: normal;
  word-break: break-word;
  margin: 0;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
