/* ==============================================================================
   styles.css - Estilos Premium para Naturelek CRM
   Dominio: naturelek.aitordorronsoro.es
   Diseño: Verde Esmeralda Sostenible, Tipografía Outfit & Plus Jakarta Sans,
           Árbol Jerárquico, Red Circular Concéntrica y Mapa de Expansión de España
   ============================================================================== */

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

:root {
  --primary-color: #0e3025;
  --primary-hover: #092019;
  --primary-light: #e6f4ea;
  --nature-emerald: #059669;
  --nature-glow: #10b981;
  --nature-dark: #064e3b;
  --accent-cyan: #06b6d4;
  --accent-gold: #d97706;
  --accent-bronze: #c07a50;
  --bg-gradient: linear-gradient(135deg, #0e2b22 0%, #173f32 50%, #0c241c 100%);
  --surface-bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --danger-color: #ef4444;
  --danger-dark: #dc2626;
  --warning-color: #f59e0b;
  --success-color: #10b981;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --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);
  --shadow-xl: 0 20px 35px -10px rgba(0, 0, 0, 0.25);
  --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
   ============================================================================== */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: var(--bg-gradient);
}

.login-card {
  background: #ffffff;
  border-radius: 28px;
  padding: 3rem 2.4rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.brand-name {
  font-family: var(--font-heading);
  font-size: 2.3rem;
  font-weight: 800;
  color: #0e3025;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.brand-name .brand-leaf {
  color: #10b981;
}

.brand-subtitle {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-bronze);
  letter-spacing: 2px;
  margin-top: 4px;
  text-transform: uppercase;
}

.lock-icon-wrapper {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0fdf4;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.lock-icon-svg {
  width: 36px;
  height: 36px;
  color: #059669;
}

.login-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 700;
  color: #0e3025;
  margin-bottom: 0.4rem;
}

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

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: none;
}

.login-form .form-group {
  margin-bottom: 1.25rem;
}

.input-styled {
  width: 100%;
  padding: 0.9rem 1.1rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-main);
  background: #ffffff;
  transition: all 0.2s ease;
  outline: none;
}

.input-styled:focus {
  border-color: #059669;
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.15);
}

.btn-primary-submit {
  width: 100%;
  padding: 1rem;
  background: #0e3025;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(14, 48, 37, 0.25);
}

.btn-primary-submit:hover {
  background: #144234;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(14, 48, 37, 0.35);
}

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

.back-link {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}

.back-link:hover {
  color: #059669;
}

/* ==============================================================================
   CRM MAIN LAYOUT & HEADER
   ============================================================================== */
.crm-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #f1f5f9;
}

.crm-header {
  background: #092019;
  color: #ffffff;
  padding: 0.85rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
  z-index: 40;
}

.crm-brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  letter-spacing: -0.3px;
}

.crm-brand-badge {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

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

.btn-secondary-head {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e2e8f0;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

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

.btn-logout {
  background: #dc2626;
  color: #ffffff;
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: #b91c1c;
}

/* ==============================================================================
   BARRA PRINCIPAL DE MODOS (CLIENTES VS SOCIOS Y EQUIPO)
   ============================================================================== */
.main-mode-bar {
  background: #0e3025;
  display: flex;
  padding: 0 1.75rem;
  border-bottom: 2px solid #059669;
  gap: 0.5rem;
}

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

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

.main-mode-btn.active {
  color: #ffffff;
  background: rgba(5, 150, 105, 0.25);
  border-bottom-color: #10b981;
}

/* ==============================================================================
   SUB-NAV BAR (SERVICIOS CLIENTES & PESTAÑAS EQUIPO)
   ============================================================================== */
.service-nav-bar {
  background: #143d31;
  display: flex;
  padding: 0.35rem 1.75rem;
  gap: 0.5rem;
  overflow-x: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.service-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #cbd5e1;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  transition: all 0.2s ease;
}

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

.service-tab-btn.active {
  background: #ffffff;
  color: #0e3025;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.service-counter-badge {
  background: rgba(0, 0, 0, 0.2);
  color: #ffffff;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 12px;
}

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

/* ==============================================================================
   SUB-BARRA DE ACCIONES (TABLA CLIENTES Y TABLA SOCIOS)
   ============================================================================== */
.crm-subbar {
  background: #ffffff;
  padding: 0.85rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 1rem;
}

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

.tab-btn {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: #0e3025;
  color: #ffffff;
  border-color: #0e3025;
}

.tab-counter {
  background: rgba(0,0,0,0.08);
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  font-size: 0.75rem;
}

.tab-btn.active .tab-counter {
  background: rgba(255,255,255,0.2);
  color: #ffffff;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sort-select {
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.btn-filter-toggle {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

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

.btn-add-client {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  border: none;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 3px 8px rgba(5, 150, 105, 0.25);
  transition: all 0.2s ease;
}

.btn-add-client:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* ==============================================================================
   FILTROS DESPLEGABLES
   ============================================================================== */
.filter-panel {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.75rem;
  display: none;
  animation: slideDown 0.25s ease-out;
}

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

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

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

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-input, .filter-select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
  background: #ffffff;
}

.filter-input:focus, .filter-select:focus {
  border-color: #059669;
}

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

/* ==============================================================================
   DASHBOARD / INICIO MÉTRICAS
   ============================================================================== */
.dashboard-container {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.renewal-banner {
  background: #ecfdf5;
  border: 1.5px solid #a7f3d0;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.global-search-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  position: relative;
}

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

.global-search-label {
  font-weight: 700;
  color: #0e3025;
  font-size: 1rem;
}

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

.global-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 380px;
  overflow-y: auto;
  z-index: 50;
  margin-top: 4px;
}

.search-result-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}

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

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.kpi-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.kpi-primary::before { background: #0e3025; }
.kpi-energia::before { background: #eab308; }
.kpi-telefonia::before { background: #8b5cf6; }
.kpi-seguros::before { background: #0284c7; }
.kpi-ingresos::before { background: #10b981; }
.kpi-danger::before { background: #ef4444; }

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

.kpi-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

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

.kpi-stat {
  text-align: center;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: #0e3025;
  display: block;
}

.kpi-sublabel {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-divider {
  width: 1px;
  height: 36px;
  background: var(--border-color);
}

.kpi-footer-breakdown {
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border-color);
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}

.text-green { color: #059669 !important; }
.text-red { color: #dc2626 !important; }

/* Chart Cards */
.chart-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

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

.chart-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: #0e3025;
}

.chart-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.chart-legend {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

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

.legend-box.green { background: #059669; }
.legend-box.blue { background: #0284c7; }
.legend-box.purple { background: #7c3aed; }
.legend-box.red { background: #ef4444; }

.chart-wrapper {
  min-height: 220px;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding-top: 1rem;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.bar-stack {
  width: 100%;
  max-width: 38px;
  height: 160px;
  display: flex;
  flex-direction: column-reverse;
  background: #f1f5f9;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}

.bar-segment {
  width: 100%;
  transition: height 0.4s ease;
}

.bar-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ==============================================================================
   TABLAS DE DATOS (CLIENTES Y SOCIOS)
   ============================================================================== */
.crm-content {
  padding: 1.75rem;
  flex: 1;
}

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

.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.db-table th {
  background: #f8fafc;
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: #475569;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.db-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.db-table tr:hover {
  background: #f0fdf4;
}

.table-badge {
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-block;
}

.table-badge.activo { background: #dcfce7; color: #15803d; }
.table-badge.eliminado { background: #fee2e2; color: #b91c1c; }

.table-actions-cell {
  display: flex;
  gap: 0.35rem;
}

.btn-icon-action {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon-action:hover {
  background: #e2e8f0;
}

/* Celdas expandibles */
.socios-td-clip {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.socios-expand-btn {
  background: #059669;
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==============================================================================
   SECCIÓN EQUIPO: SUB-PESTAÑAS Y VISTAS
   ============================================================================== */
.team-view-container {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.team-nav-switcher {
  display: flex;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 0.4rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  gap: 0.4rem;
  flex-wrap: wrap;
}

.team-nav-btn {
  flex: 1;
  min-width: 180px;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.team-nav-btn:hover {
  background: #f1f5f9;
  color: #0e3025;
}

.team-nav-btn.active {
  background: #0e3025;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(14, 48, 37, 0.25);
}

.team-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  background: #ffffff;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.team-stats-ribbon {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.team-stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
}

.stat-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.stat-dot.green { background: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.6); }
.stat-dot.red { background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }
.stat-dot.cyan { background: #06b6d4; }

/* ==============================================================================
   1. VISTA RED CIRCULAR CONCÉNTRICA (NO PIRÁMIDE)
   ============================================================================== */
.circular-network-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.circular-canvas-container {
  width: 100%;
  height: 620px;
  position: relative;
  background: radial-gradient(circle at center, #ffffff 0%, #f8fafc 70%, #f1f5f9 100%);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.circular-canvas-container svg {
  width: 100%;
  height: 100%;
  user-select: none;
}

.network-controls-overlay {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10;
}

.btn-canvas-ctrl {
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-canvas-ctrl:hover {
  background: #0e3025;
  color: #ffffff;
}

.network-legend-overlay {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* ==============================================================================
   2. VISTA ÁRBOL JERÁRQUICO (SEGÚN LA 4ª CAPTURA DE PANTALLA)
   ============================================================================== */
.tree-view-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  overflow-x: auto;
}

.tree-top-toolbar {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.btn-tree-tool {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tree-tool:hover {
  background: #0369a1;
}

.btn-tree-tool.secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border-color);
}

.btn-tree-tool.secondary:hover {
  background: #e2e8f0;
}

/* Estructura CSS del Árbol (Org Chart) */
.org-tree {
  display: flex;
  justify-content: center;
  padding: 1rem 0;
}

.org-tree ul {
  padding-top: 24px;
  position: relative;
  display: flex;
  justify-content: center;
  list-style-type: none;
}

.org-tree li {
  float: left;
  text-align: center;
  list-style-type: none;
  position: relative;
  padding: 24px 8px 0 8px;
}

/* Líneas conectores en rojo como en la captura 4 */
.org-tree li::before, .org-tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 2px solid #ef4444;
  width: 50%;
  height: 24px;
}

.org-tree li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid #ef4444;
}

.org-tree li:only-child::after, .org-tree li:only-child::before {
  display: none;
}

.org-tree li:only-child {
  padding-top: 0;
}

.org-tree li:first-child::before, .org-tree li:last-child::after {
  border: 0 none;
}

.org-tree li:last-child::before {
  border-right: 2px solid #ef4444;
  border-radius: 0 6px 0 0;
}

.org-tree li:first-child::after {
  border-radius: 6px 0 0 0;
}

.org-tree ul ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 2px solid #ef4444;
  width: 0;
  height: 24px;
}

/* Tarjeta / Viñeta del Distribuidor (Exacta a la captura 4) */
.distributor-node-card {
  display: inline-block;
  background: #ffffff;
  border: 1.5px solid #ef4444;
  border-radius: 6px;
  width: 140px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  transition: all 0.2s ease;
  position: relative;
  cursor: pointer;
}

.distributor-node-card.active-green {
  border-color: #059669;
}

.distributor-node-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.15);
}

.dist-header-bar {
  padding: 0.35rem 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
  background: #dc2626; /* Rojo = inactivo */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.distributor-node-card.active-green .dist-header-bar {
  background: #059669; /* Verde = activo */
}

.dist-body-bar {
  padding: 0.4rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
  background: #ffffff;
}

.dist-pe-value {
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
}

.dist-action-pill {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #0284c7;
  color: #ffffff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.distributor-node-card:hover .dist-action-pill {
  display: flex;
}

/* ==============================================================================
   3. VISTA MAPA DE EXPANSIÓN (ESPAÑA INTERACTIVO)
   ============================================================================== */
.map-view-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.75rem;
}

@media (max-width: 1024px) {
  .map-view-card {
    grid-template-columns: 1fr;
  }
}

.map-canvas-wrapper {
  background: radial-gradient(circle at center, #ffffff 0%, #f8fafc 80%, #f1f5f9 100%);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  position: relative;
  min-height: 580px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spain-svg-map {
  width: 100%;
  max-height: 560px;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.06));
}

.province-path {
  fill: #e2e8f0;
  stroke: #cbd5e1;
  stroke-width: 1.2;
  transition: all 0.25s ease;
  cursor: pointer;
}

.province-path:hover {
  fill: #a7f3d0;
  stroke: #059669;
}

.province-path.has-people {
  fill: #dcfce7;
  stroke: #10b981;
}

.province-path.selected {
  fill: #6ee7b7;
  stroke: #047857;
  stroke-width: 2;
}

/* Círculos Rojos para el Mapa de España */
.map-red-marker {
  fill: #ef4444;
  fill-opacity: 0.9;
  stroke: #ffffff;
  stroke-width: 2;
  cursor: pointer;
  transition: transform 0.2s, fill 0.2s;
}

.map-red-marker:hover {
  fill: #dc2626;
  transform: scale(1.2);
}

.map-pulse-ring {
  fill: none;
  stroke: #ef4444;
  stroke-width: 1.5;
  opacity: 0.7;
  animation: radarPulse 2s infinite ease-out;
  pointer-events: none;
}

@keyframes radarPulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.6); opacity: 0; }
}

.map-marker-text {
  fill: #ffffff;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* Panel Lateral de Estrategia de Expansión */
.map-strategy-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.strategy-kpi-box {
  background: #f8fafc;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
}

.strategy-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: #0e3025;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.coverage-progress-bar {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.coverage-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  border-radius: 5px;
  transition: width 0.6s ease;
}

.provinces-list-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.provinces-scrollable {
  max-height: 280px;
  overflow-y: auto;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.province-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}

.province-item-row:hover {
  background: #ecfdf5;
}

.province-item-row.active {
  background: #059669;
  color: #ffffff;
}

.province-item-row.active .province-badge {
  background: #ffffff;
  color: #059669;
}

.province-badge {
  background: #fee2e2;
  color: #dc2626;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
}

/* ==============================================================================
   VENTANAS MODALES
   ============================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(14, 48, 37, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop.open, .modal-backdrop.active {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: #0e3025;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #dc2626;
}

.modal-body {
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
  flex: 1;
}

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

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.form-section-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #059669;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1.5px solid #a7f3d0;
  padding-bottom: 0.35rem;
  margin: 1.25rem 0 0.85rem 0;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .form-grid-2, .form-grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ==============================================================================
   TOAST NOTIFICACIONES
   ============================================================================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #0e3025;
  color: #ffffff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 600;
  animation: toastIn 0.3s ease;
  pointer-events: auto;
  border-left: 4px solid #10b981;
}

.toast.error {
  border-left-color: #ef4444;
}

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