        :root {
            --primary: #c41e3a;
            --primary-dark: #a01830;
            --primary-light: #e8304a;
            --primary-glow: rgba(196, 30, 58, 0.35);
            --accent: #0ea5e9;
            --accent-glow: rgba(14, 165, 233, 0.3);
            --success: #10b981;
            --warning: #f59e0b;
            --glass-bg: rgba(255, 255, 255, 0.97);
            --glass-border: #e2e8f0;
            --glass-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
            --glass-shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.12);
            --text-primary: #1e293b;
            --text-secondary: #64748b;
            --text-tertiary: #94a3b8;
            --radius-sm: 12px;
            --radius-md: 16px;
            --radius-lg: 24px;
            --radius-xl: 32px;
            --transition-fast: 0.15s ease-out;
            --transition-normal: 0.2s ease-out;
        }

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

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            overflow: hidden;
            height: 100vh;
            background: #e2e8f0;
            -webkit-font-smoothing: antialiased;
        }

        /* ===== LOGIN OVERLAY ===== */
        .login-overlay {
            position: fixed;
            top: 0; left: 0; width: 100%; height: 100%;
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .login-overlay.hidden { display: none; }

        .login-card {
            background: white;
            border-radius: var(--radius-xl);
            padding: 48px;
            width: 400px;
            box-shadow: var(--glass-shadow-lg);
        }

        .login-card h1 {
            text-align: center;
            color: var(--primary);
            margin-bottom: 8px;
            font-size: 1.8rem;
        }

        .login-card p {
            text-align: center;
            color: var(--text-secondary);
            margin-bottom: 32px;
        }

        .login-card input {
            width: 100%;
            padding: 14px 18px;
            border: 2px solid #e2e8f0;
            border-radius: var(--radius-md);
            font-size: 1rem;
            margin-bottom: 16px;
            font-family: inherit;
            transition: var(--transition-fast);
        }

        .login-card input:focus {
            outline: none;
            border-color: var(--primary);
        }

        .login-card button {
            width: 100%;
            padding: 16px;
            background: var(--primary);
            color: white;
            border: none;
            border-radius: var(--radius-md);
            font-size: 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition-fast);
        }

        .login-card button:hover {
            background: var(--primary-dark);
        }

        .login-error {
            color: var(--primary);
            text-align: center;
            margin-bottom: 16px;
            font-size: 0.9rem;
        }

        .login-divider {
            display: flex;
            align-items: center;
            margin: 20px 0;
            color: #94a3b8;
            font-size: 0.85rem;
        }

        .login-divider::before,
        .login-divider::after {
            content: '';
            flex: 1;
            height: 1px;
            background: #e2e8f0;
        }

        .login-divider span {
            padding: 0 16px;
        }

        .sso-button {
            width: 100%;
            padding: 14px 16px;
            background: white !important;
            color: #1e293b !important;
            border: 2px solid #e2e8f0 !important;
            border-radius: var(--radius-md);
            font-size: 0.95rem;
            font-weight: 500;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            transition: all 0.2s ease;
        }

        .sso-button:hover {
            background: #f8fafc !important;
            border-color: #cbd5e1 !important;
            box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        }

        /* ===== MAP ===== */
        #fullscreen-map {
            position: fixed;
            top: 0; left: 0;
            width: 100%; height: 100%;
            z-index: 1;
        }

        .leaflet-container {
            background: linear-gradient(180deg, #dbeafe 0%, #e0f2fe 50%, #f0f9ff 100%) !important;
        }

        /* ===== COUNTRY LABELS ===== */
        .country-label {
            background: none !important;
            border: none !important;
        }

        .country-label-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            cursor: pointer;
            transition: transform 0.2s ease-out;
            padding: 8px 12px;
        }

        .country-label-content:hover { transform: scale(1.15); }

        .country-label-content .number {
            font-family: 'Inter', sans-serif;
            font-size: 1.5rem;
            font-weight: 800;
            color: #c41e3a;
            text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, 0 0 10px rgba(255,255,255,0.8);
        }

        .country-label-content .name {
            font-family: 'Inter', sans-serif;
            font-size: 0.65rem;
            font-weight: 600;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
        }

        /* ===== FLOATING HEADER ===== */
        .floating-header {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 1000;
            display: flex;
            align-items: center;
            gap: 20px;
            padding: 16px 28px;
            background: var(--glass-bg);
            border: 1px solid var(--glass-border);
            border-radius: 100px;
            box-shadow: var(--glass-shadow);
        }

        .floating-header .logo-text {
            font-size: 1.4rem;
            font-weight: 800;
            color: #cc1a1a;
            letter-spacing: 2px;
        }

        .floating-header .divider {
            width: 1px;
            height: 30px;
            background: linear-gradient(180deg, transparent, var(--text-tertiary), transparent);
        }

        .floating-header .stats {
            display: flex;
            gap: 24px;
        }

        .floating-header .stat {
            text-align: center;
        }

        .floating-header .stat-value {
            font-size: 1.25rem;
            font-weight: 800;
            color: #cc1a1a;
        }

        .floating-header .stat-label {
            font-size: 0.65rem;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            color: #64748b;
            font-weight: 600;
        }

        .floating-header .user-badge {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 16px;
            background: #f1f5f9;
            border-radius: 100px;
            cursor: pointer;
        }

        .floating-header .user-badge:hover {
            background: #e2e8f0;
        }

        .floating-header .user-badge .role {
            font-size: 0.7rem;
            padding: 2px 8px;
            background: var(--primary);
            color: white;
            border-radius: 100px;
            font-weight: 600;
        }

        .floating-header .user-badge .role.viewer {
            background: var(--accent);
        }

        /* ===== FLOATING PANEL ===== */
        .floating-panel {
            position: fixed;
            top: 100px;
            right: 20px;
            width: 340px;
            max-height: calc(100vh - 140px);
            z-index: 100;
            background: var(--glass-bg);
            border: 1px solid var(--glass-border);
            border-radius: var(--radius-xl);
            box-shadow: var(--glass-shadow-lg);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .panel-header {
            padding: 20px 24px;
            border-bottom: 1px solid rgba(0,0,0,0.06);
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: rgba(255,255,255,0.5);
        }

        .panel-header h3 {
            font-size: 0.9rem;
            font-weight: 700;
            color: var(--text-primary);
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .panel-header h3::before {
            content: '';
            width: 4px;
            height: 18px;
            background: var(--primary);
            border-radius: 2px;
        }

        .panel-content {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
        }

        /* ===== COUNTRY CARDS ===== */
        .country-card {
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 14px 16px;
            margin-bottom: 8px;
            background: white;
            border: 1px solid transparent;
            border-radius: var(--radius-md);
            cursor: pointer;
            transition: var(--transition-normal);
            position: relative;
        }

        .country-card::before {
            content: '';
            position: absolute;
            left: 0; top: 0; bottom: 0;
            width: 4px;
            background: var(--primary);
            transform: scaleY(0);
            transition: var(--transition-normal);
        }

        .country-card:hover {
            border-color: rgba(196, 30, 58, 0.2);
            transform: translateX(4px);
            box-shadow: 0 4px 20px rgba(196, 30, 58, 0.1);
        }

        .country-card:hover::before { transform: scaleY(1); }

        .country-card.global {
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
            color: white;
        }

        .country-card .flag { font-size: 2rem; }
        .country-card .info h4 { font-size: 0.9rem; font-weight: 600; }
        .country-card .info p { font-size: 0.75rem; color: var(--text-secondary); }
        .country-card.global .info p { color: rgba(255,255,255,0.7); }

        .country-card .arrow {
            margin-left: auto;
            opacity: 0;
            transform: translateX(-8px);
            transition: var(--transition-normal);
            color: var(--primary);
        }

        .country-card:hover .arrow { opacity: 1; transform: translateX(0); }

        /* ===== MODAL OVERLAY ===== */
        .modal-overlay {
            position: fixed;
            top: 0; left: 0;
            width: 100%; height: 100%;
            background: rgba(15, 23, 42, 0.7);
            z-index: 2000;
            display: flex;
            justify-content: center;
            align-items: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease-out;
        }

        .modal-overlay.active {
            opacity: 1;
            pointer-events: all;
        }

        /* ===== VISTA PARALELA (Todas las sociedades) ===== */
        .parallel-view {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #f1f5f9;
            z-index: 2500;
            display: none;
            flex-direction: column;
        }

        .parallel-view.active {
            display: flex;
        }

        .parallel-header {
            padding: 16px 32px;
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        }

        .parallel-header .back-btn {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 18px;
            background: rgba(255,255,255,0.15);
            border: none;
            border-radius: 10px;
            color: white;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .parallel-header .back-btn:hover {
            background: rgba(255,255,255,0.25);
        }

        .parallel-header h1 {
            font-size: 1.3rem;
            font-weight: 700;
        }

        .parallel-body {
            flex: 1;
            overflow: auto;
            padding: 30px;
        }

        .parallel-container {
            display: flex;
            gap: 24px;
            align-items: flex-start;
            min-width: max-content;
        }

        /* Columna Global (Grupo SRX) */
        .global-column {
            min-width: 200px;
            background: white;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 4px 20px rgba(0,0,0,0.08);
        }

        .global-column-header {
            background: var(--warning);
            color: white;
            padding: 16px 20px;
            text-align: center;
        }

        .global-column-header h2 {
            font-size: 1.1rem;
            font-weight: 700;
        }

        .global-column-body {
            padding: 0;
        }

        .global-dir-item {
            padding: 14px 20px;
            background: var(--warning);
            color: white;
            text-align: center;
            font-weight: 600;
            font-size: 0.9rem;
            border-top: 2px solid rgba(255,255,255,0.3);
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .global-dir-item:hover {
            filter: brightness(1.1);
        }

        /* Columna de Sociedad */
        .society-column {
            min-width: 180px;
            background: white;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 4px 20px rgba(0,0,0,0.08);
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .society-column:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 30px rgba(0,0,0,0.12);
        }

        .society-column-header {
            background: #3b82f6;
            color: white;
            padding: 20px 16px;
            text-align: center;
        }

        .society-column-header h3 {
            font-size: 1rem;
            font-weight: 700;
        }

        .society-column-header .flag {
            font-size: 1.5rem;
            margin-bottom: 6px;
            display: block;
        }

        .society-column-body {
            padding: 0;
        }

        .society-dir-item {
            padding: 10px 14px;
            background: var(--warning);
            color: white;
            text-align: center;
            font-weight: 600;
            font-size: 0.75rem;
            border-top: 2px solid rgba(255,255,255,0.3);
        }

        .society-dir-item.inactive {
            background: #cbd5e1;
            color: #64748b;
        }

        .society-dir-item.dg {
            background: #64748b;
        }

        /* Botón toggle vista en el header flotante */
        .view-toggle-btn {
            padding: 9px 16px;
            background: white;
            border: 2px solid var(--primary);
            border-radius: 100px;
            color: var(--primary);
            font-size: 0.82rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            gap: 6px;
            letter-spacing: 0.01em;
            white-space: nowrap;
        }
        .view-toggle-btn[style*="background"] {
            color: #ffffff !important;
            text-shadow: 0 1px 2px rgba(0,0,0,0.25);
            font-size: 0.82rem;
            font-weight: 700;
            letter-spacing: 0.01em;
        }
        .view-toggle-btn:hover {
            background: var(--primary);
            color: white;
            text-shadow: 0 1px 2px rgba(0,0,0,0.2);
        }

        /* ===== VISTA TABLA EMPLEADOS ===== */
        .empleados-tabla-view {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #f1f5f9;
            z-index: 2500;
            flex-direction: column;
        }

        .tabla-header {
            padding: 16px 32px;
            background: linear-gradient(135deg, #10b981 0%, #059669 100%);
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 20px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        }

        .tabla-header .back-btn {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 18px;
            background: rgba(255,255,255,0.15);
            border: none;
            border-radius: 10px;
            color: white;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .tabla-header .back-btn:hover {
            background: rgba(255,255,255,0.25);
        }

        .tabla-header h1 {
            font-size: 1.3rem;
            font-weight: 700;
            flex-shrink: 0;
        }

        .tabla-filters {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
            justify-content: flex-end;
        }

        .tabla-search {
            padding: 10px 16px;
            border: none;
            border-radius: 8px;
            font-size: 0.9rem;
            width: 250px;
            background: rgba(255,255,255,0.9);
        }

        .tabla-search:focus {
            outline: none;
            background: white;
        }

        .tabla-select {
            padding: 10px 16px;
            border: none;
            border-radius: 8px;
            font-size: 0.9rem;
            background: rgba(255,255,255,0.9);
            cursor: pointer;
        }

        .tabla-filters .tool-btn {
            padding: 10px 16px;
            border: none;
            border-radius: 8px;
            font-size: 0.9rem;
            cursor: pointer;
            background: rgba(255,255,255,0.9);
            transition: all 0.2s;
        }

        .tabla-filters .tool-btn:hover {
            background: white;
            transform: translateY(-1px);
        }

        .tabla-filters .btn-crear-empleado {
            background: #10b981;
            color: white;
            font-weight: 600;
        }

        .tabla-filters .btn-crear-empleado:hover {
            background: #059669;
        }

        .tabla-container {
            flex: 1;
            overflow: auto;
            padding: 20px 32px;
        }

        .empleados-table {
            width: 100%;
            border-collapse: collapse;
            background: white;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
        }

        .empleados-table thead {
            background: #1e293b;
            color: white;
            position: sticky;
            top: 0;
        }

        .empleados-table th {
            padding: 14px 16px;
            text-align: left;
            font-weight: 600;
            font-size: 0.85rem;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .empleados-table td {
            padding: 12px 16px;
            border-bottom: 1px solid #e2e8f0;
            font-size: 0.9rem;
            color: #334155;
        }

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

        .empleados-table .emp-name {
            font-weight: 600;
            color: #1e293b;
        }

        .empleados-table .emp-flag {
            margin-right: 6px;
        }

        .empleados-table .sin-asignar {
            color: #94a3b8;
            font-style: italic;
        }

        .empleados-table .sociedad-badge {
            display: inline-block;
            padding: 2px 6px;
            border-radius: 4px;
            font-size: 0.7rem;
            font-weight: 700;
            background: #3b82f6;
            color: white;
            margin-right: 6px;
            vertical-align: middle;
        }

        .empleados-table .nivel-badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 20px;
            font-size: 0.75rem;
            font-weight: 600;
            background: #e2e8f0;
            color: #475569;
        }

        .empleados-table .nivel-badge.responsable {
            background: #fef3c7;
            color: #b45309;
        }

        .empleados-table .nivel-badge.direccion {
            background: #fee2e2;
            color: #dc2626;
        }

        .tabla-footer {
            padding: 12px 32px;
            background: white;
            border-top: 1px solid #e2e8f0;
            font-size: 0.9rem;
            color: #64748b;
        }

        /* Dashboard Styles */
        .dashboard-view {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #f8fafc;
            z-index: 1000;
            display: flex;
            flex-direction: column;
        }

        .dashboard-header {
            background: linear-gradient(135deg, #f59e0b, #d97706);
            color: white;
            padding: 16px 32px;
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .dashboard-header h1 {
            font-size: 1.5rem;
            margin: 0;
        }

        .dashboard-header .back-btn {
            background: rgba(255, 255, 255, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.3);
            color: white;
            padding: 10px 20px;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            backdrop-filter: blur(4px);
        }

        .dashboard-header .back-btn:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: translateX(-3px);
        }

        .dashboard-content {
            flex: 1;
            overflow: hidden;
            padding: 0;
            display: flex;
            flex-direction: column;
        }

        /* Dashboard profesional */
        .dashboard-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            padding-bottom: 16px;
            border-bottom: 1px solid #e2e8f0;
        }

        .dashboard-header h2 {
            margin: 0;
            font-size: 1.5rem;
            color: #1e293b;
            font-weight: 600;
        }

        .dashboard-header .subtitle {
            font-size: 0.875rem;
            color: #64748b;
            margin-top: 4px;
        }

        .dashboard-grid {
            display: grid;
            grid-template-columns: repeat(12, 1fr);
            gap: 20px;
            max-width: 1800px;
            margin: 0 auto;
        }

        /* KPI Cards principales */
        .kpi-card {
            background: white;
            border-radius: 12px;
            padding: 24px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            border: 1px solid #e2e8f0;
            transition: all 0.2s ease;
        }

        .kpi-card:hover {
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }

        .kpi-card.clickable {
            cursor: pointer;
        }

        .kpi-card.clickable:hover {
            transform: translateY(-2px);
            border-color: #3b82f6;
        }

        .kpi-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 16px;
        }

        .kpi-title {
            font-size: 0.8rem;
            font-weight: 500;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .kpi-icon {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.25rem;
        }

        .kpi-icon.blue { background: #dbeafe; color: #2563eb; }
        .kpi-icon.green { background: #dcfce7; color: #16a34a; }
        .kpi-icon.amber { background: #fef3c7; color: #d97706; }
        .kpi-icon.purple { background: #f3e8ff; color: #9333ea; }
        .kpi-icon.red { background: #fee2e2; color: #dc2626; }
        .kpi-icon.slate { background: #f1f5f9; color: #475569; }

        .kpi-value {
            font-size: 2.5rem;
            font-weight: 700;
            color: #1e293b;
            line-height: 1;
            margin-bottom: 4px;
        }

        .kpi-value.small {
            font-size: 1.75rem;
        }

        .kpi-subtitle {
            font-size: 0.875rem;
            color: #64748b;
        }

        .kpi-trend {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 0.75rem;
            font-weight: 500;
            padding: 2px 8px;
            border-radius: 12px;
            margin-top: 8px;
        }

        .kpi-trend.positive { background: #dcfce7; color: #16a34a; }
        .kpi-trend.negative { background: #fee2e2; color: #dc2626; }
        .kpi-trend.neutral { background: #f1f5f9; color: #64748b; }

        /* Grid spans */
        .span-2 { grid-column: span 2; }
        .span-3 { grid-column: span 3; }
        .span-4 { grid-column: span 4; }
        .span-6 { grid-column: span 6; }
        .span-8 { grid-column: span 8; }
        .span-12 { grid-column: span 12; }

        /* Section card */
        .section-card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            border: 1px solid #e2e8f0;
            overflow: hidden;
        }

        .section-header {
            padding: 16px 20px;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .section-title {
            font-size: 0.95rem;
            font-weight: 600;
            color: #1e293b;
        }

        .section-badge {
            font-size: 0.7rem;
            font-weight: 500;
            padding: 4px 8px;
            border-radius: 6px;
            background: #f1f5f9;
            color: #64748b;
        }

        .section-content {
            padding: 16px 20px;
        }

        /* Pyramid chart for hierarchy - horizontal bars */
        .pyramid-chart {
            display: flex;
            flex-direction: column;
            gap: 8px;
            padding: 8px 0;
        }

        .pyramid-level {
            display: grid;
            grid-template-columns: 100px 1fr 70px;
            align-items: center;
            gap: 12px;
            padding: 6px 0;
            cursor: pointer;
            transition: all 0.2s;
        }

        .pyramid-level:hover {
            background: #f8fafc;
            border-radius: 6px;
        }

        .pyramid-level .label {
            font-size: 0.8rem;
            color: #475569;
            font-weight: 500;
            text-align: right;
        }

        .pyramid-level .bar-container {
            height: 24px;
            background: #e2e8f0;
            border-radius: 4px;
            overflow: hidden;
        }

        .pyramid-level .bar-fill {
            height: 100%;
            background: linear-gradient(90deg, #3b82f6, #60a5fa);
            border-radius: 4px;
            transition: width 0.3s ease;
        }

        .pyramid-level .stats {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 0.8rem;
        }

        .pyramid-level .count {
            font-weight: 700;
            color: #1e293b;
        }

        .pyramid-level .pct {
            color: #64748b;
        }

        /* Distribution bars */
        .dist-bars {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .dist-row {
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            padding: 8px;
            margin: -8px;
            border-radius: 8px;
            transition: background 0.15s;
        }

        .dist-row:hover {
            background: #f8fafc;
        }

        .dist-label {
            width: 100px;
            font-size: 0.85rem;
            color: #475569;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .dist-bar-wrapper {
            flex: 1;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .dist-bar {
            flex: 1;
            height: 28px;
            background: #f1f5f9;
            border-radius: 6px;
            overflow: hidden;
            position: relative;
        }

        .dist-bar-fill {
            height: 100%;
            border-radius: 6px;
            display: flex;
            align-items: center;
            padding-left: 12px;
            color: white;
            font-size: 0.8rem;
            font-weight: 600;
            transition: width 0.5s ease;
        }

        .dist-bar-fill.blue { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
        .dist-bar-fill.green { background: linear-gradient(90deg, #10b981, #34d399); }
        .dist-bar-fill.purple { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
        .dist-bar-fill.amber { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

        .dist-value {
            min-width: 50px;
            text-align: right;
            font-weight: 600;
            font-size: 0.9rem;
            color: #1e293b;
        }

        .dist-pct {
            min-width: 45px;
            text-align: right;
            font-size: 0.75rem;
            color: #64748b;
        }

        /* Mini stat list */
        .mini-stat-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .mini-stat-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 12px;
            background: #f8fafc;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.15s;
        }

        .mini-stat-item:hover {
            background: #f1f5f9;
            transform: translateX(4px);
        }

        .mini-stat-item .label {
            font-size: 0.85rem;
            color: #475569;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .mini-stat-item .value {
            font-weight: 600;
            color: #1e293b;
            font-size: 0.9rem;
        }

        /* Headcount Historico Table */
        .headcount-table-container {
            overflow-x: auto;
            margin-top: 8px;
        }

        .headcount-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.85rem;
        }

        .headcount-table th,
        .headcount-table td {
            padding: 10px 12px;
            text-align: right;
            border-bottom: 1px solid #e2e8f0;
        }

        .headcount-table th:first-child,
        .headcount-table td:first-child {
            text-align: left;
            position: sticky;
            left: 0;
            background: white;
            z-index: 1;
            font-weight: 500;
        }

        .headcount-table th {
            background: #f8fafc;
            font-weight: 600;
            color: #475569;
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            white-space: nowrap;
        }

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

        .headcount-table .total-row {
            background: #f1f5f9;
            font-weight: 600;
        }

        .headcount-table .total-row td {
            border-top: 2px solid #cbd5e1;
        }

        .headcount-variation {
            font-size: 0.7rem;
            margin-left: 4px;
        }

        .headcount-variation.positive {
            color: #10b981;
        }

        .headcount-variation.negative {
            color: #ef4444;
        }

        .headcount-tabs {
            display: flex;
            gap: 8px;
            margin-bottom: 16px;
        }

        .headcount-tab {
            padding: 8px 16px;
            border: 1px solid #e2e8f0;
            background: white;
            border-radius: 8px;
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.2s;
        }

        .headcount-tab:hover {
            background: #f8fafc;
        }

        .headcount-tab.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }

        .headcount-actions {
            display: flex;
            gap: 8px;
            margin-left: auto;
        }

        .btn-snapshot {
            padding: 8px 16px;
            background: #10b981;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .btn-snapshot:hover {
            background: #059669;
        }

        /* Progress ring */
        .progress-ring-container {
            display: flex;
            align-items: center;
            gap: 20px;
            padding: 16px 0;
        }

        .progress-ring {
            position: relative;
            width: 100px;
            height: 100px;
        }

        .progress-ring svg {
            transform: rotate(-90deg);
        }

        .progress-ring .bg {
            fill: none;
            stroke: #e2e8f0;
            stroke-width: 8;
        }

        .progress-ring .fg {
            fill: none;
            stroke-width: 8;
            stroke-linecap: round;
            transition: stroke-dashoffset 0.5s ease;
        }

        .progress-ring .fg.blue { stroke: #3b82f6; }
        .progress-ring .fg.green { stroke: #10b981; }

        .progress-ring .value {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 1.5rem;
            font-weight: 700;
            color: #1e293b;
        }

        .progress-info {
            flex: 1;
        }

        .progress-info .title {
            font-size: 0.9rem;
            font-weight: 500;
            color: #1e293b;
            margin-bottom: 4px;
        }

        .progress-info .desc {
            font-size: 0.8rem;
            color: #64748b;
        }

        /* Ratio display */
        .ratio-display {
            display: flex;
            align-items: stretch;
            gap: 2px;
            height: 40px;
            border-radius: 8px;
            overflow: hidden;
            margin: 16px 0;
        }

        .ratio-segment {
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 0.75rem;
            font-weight: 600;
            padding: 0 12px;
            min-width: 60px;
        }

        .ratio-segment.directivos { background: #3b82f6; }
        .ratio-segment.operativos { background: #10b981; }

        .ratio-legend {
            display: flex;
            justify-content: center;
            gap: 24px;
            margin-top: 8px;
        }

        .ratio-legend-item {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 0.8rem;
            color: #64748b;
        }

        .ratio-legend-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
        }

        .ratio-legend-dot.blue { background: #3b82f6; }
        .ratio-legend-dot.green { background: #10b981; }

        /* Alert cards */
        .alert-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .alert-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px;
            background: #fffbeb;
            border: 1px solid #fde68a;
            border-radius: 8px;
            font-size: 0.85rem;
            color: #92400e;
            cursor: pointer;
            transition: all 0.15s;
        }

        .alert-item:hover {
            background: #fef3c7;
        }

        .alert-item.success {
            background: #f0fdf4;
            border-color: #bbf7d0;
            color: #166534;
        }

        /* Dashboard detail panel */
        .dashboard-detail-panel {
            position: fixed;
            top: 0;
            right: -500px;
            width: 500px;
            height: 100%;
            background: white;
            box-shadow: -4px 0 24px rgba(0,0,0,0.15);
            z-index: 1100;
            display: flex;
            flex-direction: column;
            transition: right 0.3s ease;
        }

        .dashboard-detail-panel.active {
            right: 0;
        }

        .dashboard-detail-header {
            padding: 20px;
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .dashboard-detail-header h3 {
            margin: 0;
            font-size: 1.1rem;
            font-weight: 600;
        }

        .dashboard-detail-close {
            background: rgba(255,255,255,0.1);
            border: none;
            color: white;
            font-size: 1.25rem;
            cursor: pointer;
            padding: 8px;
            line-height: 1;
            border-radius: 8px;
            transition: background 0.15s;
        }

        .dashboard-detail-close:hover {
            background: rgba(255,255,255,0.2);
        }

        .dashboard-detail-content {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
        }

        .dashboard-detail-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.15s;
            margin-bottom: 4px;
        }

        .dashboard-detail-item:hover {
            background: #f1f5f9;
        }

        .dashboard-detail-item .avatar {
            width: 44px;
            height: 44px;
            border-radius: 10px;
            background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            color: #64748b;
            font-size: 0.9rem;
        }

        .dashboard-detail-item .info {
            flex: 1;
            min-width: 0;
        }

        .dashboard-detail-item .name {
            font-weight: 500;
            color: #1e293b;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .dashboard-detail-item .meta {
            font-size: 0.8rem;
            color: #64748b;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .dashboard-detail-count {
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 0.85rem;
            color: #64748b;
            margin-bottom: 16px;
            padding: 12px 16px;
            background: #f8fafc;
            border-radius: 8px;
        }

        .dashboard-detail-count strong {
            color: #1e293b;
            font-size: 1rem;
        }

        .dashboard-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(15, 23, 42, 0.4);
            backdrop-filter: blur(2px);
            z-index: 1050;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
        }

        .dashboard-overlay.active {
            opacity: 1;
            visibility: visible;
        }

        /* Responsive */
        @media (max-width: 1200px) {
            .span-3 { grid-column: span 4; }
            .span-4 { grid-column: span 6; }
            .span-6 { grid-column: span 12; }
            .span-8 { grid-column: span 12; }
        }

        @media (max-width: 768px) {
            .dashboard-grid {
                grid-template-columns: 1fr;
            }
            .span-2, .span-3, .span-4, .span-6, .span-8, .span-12 {
                grid-column: span 1;
            }
            .dashboard-detail-panel {
                width: 100%;
                right: -100%;
            }
        }

        .loading-cell {
            text-align: center;
            padding: 40px !important;
            color: #64748b;
        }

        .empleados-table th:last-child,
        .empleados-table td:last-child {
            text-align: center;
            width: 100px;
        }

        .btn-edit {
            padding: 6px 12px;
            background: #3b82f6;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 0.8rem;
            cursor: pointer;
            transition: all 0.2s;
        }

        .btn-edit:hover {
            background: #2563eb;
        }

        .btn-delete {
            padding: 6px 12px;
            background: #ef4444;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 0.8rem;
            cursor: pointer;
            transition: all 0.2s;
        }

        .btn-delete:hover {
            background: #dc2626;
        }

        /* ===== LISTA DE ASIGNACIONES ===== */
        .asignaciones-lista {
            margin-bottom: 16px;
            max-height: 200px;
            overflow-y: auto;
        }

        .asignacion-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 14px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            margin-bottom: 8px;
            flex-wrap: wrap;
            gap: 8px;
        }

        .asignacion-item:hover {
            background: #f1f5f9;
        }

        .asignacion-reporta-a {
            display: flex;
            align-items: center;
            gap: 8px;
            width: 100%;
            padding-top: 8px;
            border-top: 1px dashed #e2e8f0;
            margin-top: 4px;
        }

        .asignacion-reporta-a label {
            font-size: 0.75rem;
            color: #64748b;
            font-weight: 500;
        }

        .asignacion-reporta-a select {
            flex: 1;
            padding: 4px 8px;
            border: 1px solid #cbd5e1;
            border-radius: 4px;
            font-size: 0.8rem;
            background: white;
        }

        .asignacion-info {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
        }

        .asignacion-sociedad {
            font-weight: 700;
            color: white;
            background: #3b82f6;
            padding: 4px 10px;
            border-radius: 6px;
            font-size: 0.8rem;
            min-width: 50px;
            text-align: center;
        }

        .asignacion-estructura {
            font-weight: 500;
            color: #334155;
        }

        .asignacion-nivel {
            font-size: 0.75rem;
            color: #64748b;
            background: #e2e8f0;
            padding: 2px 8px;
            border-radius: 10px;
        }

        .asignacion-responsable {
            font-size: 0.7rem;
            color: #b45309;
            background: #fef3c7;
            padding: 2px 8px;
            border-radius: 10px;
            margin-left: 6px;
        }

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

        .asignacion-actions button {
            padding: 4px 8px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.75rem;
        }

        .btn-edit-asig {
            background: #e0f2fe;
            color: #0369a1;
        }

        .btn-edit-asig:hover {
            background: #bae6fd;
        }

        .btn-delete-asig {
            background: #fee2e2;
            color: #dc2626;
        }

        .btn-delete-asig:hover {
            background: #fecaca;
        }

        .asignacion-form {
            background: #f0fdf4;
            border: 1px solid #bbf7d0;
            border-radius: 8px;
            padding: 16px;
            margin-bottom: 16px;
        }

        .asignacion-form h4 {
            margin: 0 0 12px 0;
            color: #166534;
            font-size: 0.9rem;
        }

        .btn-add-asig {
            padding: 6px 14px;
            background: #22c55e;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.8rem;
            font-weight: 500;
        }

        .btn-add-asig:hover {
            background: #16a34a;
        }

        .btn-cancel-asig {
            padding: 6px 10px;
            background: #ef4444;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.8rem;
        }

        .no-asignaciones {
            text-align: center;
            padding: 20px;
            color: #94a3b8;
            font-style: italic;
        }

        /* ===== MODAL EDITAR EMPLEADO ===== */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 3000;
            display: none;
            align-items: center;
            justify-content: center;
        }

        .modal-overlay.active {
            display: flex;
        }

        .modal-content.modal-editar {
            background: white;
            border-radius: 16px;
            width: 600px;
            max-width: 95%;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
        }

        .modal-header {
            padding: 20px 24px;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-header h2 {
            margin: 0;
            font-size: 1.3rem;
            color: #1e293b;
        }

        .modal-close {
            background: none;
            border: none;
            font-size: 1.5rem;
            color: #64748b;
            cursor: pointer;
            padding: 4px 8px;
        }

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

        #form-editar-empleado {
            padding: 24px;
        }

        .foto-empleado-container {
            display: flex;
            align-items: center;
            gap: 16px;
            margin-bottom: 20px;
            padding-bottom: 20px;
            border-bottom: 1px solid #e2e8f0;
        }

        .foto-empleado-preview {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            background: #f1f5f9;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            border: 3px solid #e2e8f0;
        }

        .foto-empleado-preview img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .foto-placeholder {
            font-size: 2rem;
            opacity: 0.5;
        }

        .foto-empleado-actions {
            display: flex;
            gap: 8px;
        }

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

        .btn-foto:hover {
            background: #e2e8f0;
        }

        .btn-foto-delete {
            background: #fee2e2;
            color: #dc2626;
        }

        .btn-foto-delete:hover {
            background: #fecaca;
        }

        .form-row {
            display: flex;
            gap: 16px;
            margin-bottom: 16px;
        }

        .form-group {
            flex: 1;
        }

        .form-group label {
            display: block;
            margin-bottom: 6px;
            font-size: 0.85rem;
            font-weight: 600;
            color: #475569;
        }

        .form-group input,
        .form-group select {
            width: 100%;
            padding: 10px 14px;
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            font-size: 0.95rem;
            transition: all 0.2s;
        }

        .form-group input:focus,
        .form-group select:focus {
            outline: none;
            border-color: #3b82f6;
        }

        .form-divider {
            height: 1px;
            background: #e2e8f0;
            margin: 24px 0;
        }

        .form-actions {
            display: flex;
            justify-content: flex-end;
            gap: 12px;
            margin-top: 24px;
            padding-top: 20px;
            border-top: 1px solid #e2e8f0;
        }

        .btn-secondary {
            padding: 12px 24px;
            background: #f1f5f9;
            color: #475569;
            border: none;
            border-radius: 8px;
            font-size: 0.95rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }

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

        .btn-primary {
            padding: 12px 24px;
            background: #3b82f6;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 0.95rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }

        .btn-primary:hover {
            background: #2563eb;
        }

        /* ===== CANVAS EDITOR ===== */
        .canvas-editor {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #1e293b;
            z-index: 4000;
            display: none;
            flex-direction: column;
        }

        .canvas-editor.active {
            display: flex;
        }

        .canvas-header {
            padding: 12px 24px;
            background: #0f172a;
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid #334155;
        }

        .canvas-header .left {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .canvas-header .back-btn {
            padding: 8px 16px;
            background: #334155;
            border: none;
            border-radius: 8px;
            color: white;
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.2s;
        }

        .canvas-header .back-btn:hover {
            background: #475569;
        }

        .canvas-header h1 {
            font-size: 1.1rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .canvas-header .society-name {
            color: var(--accent);
        }

        .canvas-header .tools {
            display: flex;
            gap: 8px;
        }

        .canvas-header .tool-btn {
            padding: 8px 14px;
            background: #334155;
            border: none;
            border-radius: 8px;
            color: white;
            font-size: 0.8rem;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .canvas-header .tool-btn:hover {
            background: var(--primary);
        }

        .canvas-header .tool-btn.active {
            background: var(--primary);
        }

        .canvas-body {
            flex: 1;
            display: flex;
            overflow: hidden;
        }

        /* Panel izquierdo - Empleados */
        .canvas-sidebar {
            width: 280px;
            background: #0f172a;
            border-right: 1px solid #334155;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .canvas-sidebar-header {
            padding: 16px;
            border-bottom: 1px solid #334155;
        }

        .canvas-sidebar-header h3 {
            color: white;
            font-size: 0.85rem;
            font-weight: 600;
            margin-bottom: 12px;
        }

        .canvas-sidebar-search {
            width: 100%;
            padding: 10px 14px;
            background: #1e293b;
            border: 1px solid #334155;
            border-radius: 8px;
            color: white;
            font-size: 0.85rem;
        }

        .canvas-sidebar-search:focus {
            outline: none;
            border-color: var(--accent);
        }

        .canvas-sidebar-search::placeholder {
            color: #64748b;
        }

        .canvas-sidebar-content {
            flex: 1;
            overflow-y: auto;
            padding: 12px;
        }

        .canvas-emp-item {
            padding: 10px 12px;
            background: #1e293b;
            border: 1px solid #334155;
            border-radius: 8px;
            margin-bottom: 8px;
            cursor: grab;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .canvas-emp-item:hover {
            border-color: var(--accent);
            background: #334155;
        }

        .canvas-emp-item.dragging {
            opacity: 0.5;
            cursor: grabbing;
        }

        .canvas-emp-item .flag {
            font-size: 1.2rem;
        }

        .canvas-emp-item .info {
            flex: 1;
            min-width: 0;
        }

        .canvas-emp-item .name {
            color: white;
            font-size: 0.8rem;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .canvas-emp-item .puesto {
            color: #64748b;
            font-size: 0.7rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* Canvas principal */
        .canvas-main {
            flex: 1;
            position: relative;
            overflow: hidden;
        }

        .canvas-viewport {
            width: 100%;
            height: 100%;
            overflow: auto;
            position: relative;
        }

        .canvas-content {
            min-width: 2000px;
            min-height: 1500px;
            position: relative;
            background-image:
                radial-gradient(circle, #334155 1px, transparent 1px);
            background-size: 20px 20px;
        }

        /* SVG para líneas */
        .canvas-svg {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 1;
        }

        .canvas-svg line {
            stroke: #475569;
            stroke-width: 2;
        }

        .canvas-svg line.highlight {
            stroke: var(--accent);
            stroke-width: 3;
        }

        /* Nodos de estructura */
        .canvas-node {
            position: absolute;
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.3);
            cursor: move;
            z-index: 10;
            min-width: 180px;
            transition: box-shadow 0.2s;
        }

        .canvas-node:hover {
            box-shadow: 0 8px 30px rgba(0,0,0,0.4);
        }

        .canvas-node.drag-over {
            box-shadow: 0 0 0 3px var(--success), 0 8px 30px rgba(0,0,0,0.4);
        }

        .canvas-node.selected {
            box-shadow: 0 0 0 3px var(--accent), 0 8px 30px rgba(0,0,0,0.4);
        }

        .canvas-node-header {
            padding: 12px 16px;
            border-radius: 12px 12px 0 0;
            color: white;
            font-weight: 600;
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .canvas-node.direccion .canvas-node-header {
            background: var(--primary);
        }

        .canvas-node.area .canvas-node-header {
            background: var(--accent);
        }

        .canvas-node.departamento .canvas-node-header {
            background: var(--warning);
        }

        .canvas-node.subdepartamento .canvas-node-header {
            background: #8b5cf6;
        }

        .canvas-node.dg .canvas-node-header {
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        }

        .canvas-node-body {
            padding: 12px 16px;
        }

        .canvas-node-responsable {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            background: #f1f5f9;
            border-radius: 8px;
            margin-bottom: 8px;
        }

        .canvas-node-responsable .flag {
            font-size: 1rem;
        }

        .canvas-node-responsable .name {
            flex: 1;
            font-size: 0.8rem;
            font-weight: 600;
            color: #1e293b;
        }

        .canvas-node-responsable.empty {
            background: #fef2f2;
            border: 1px dashed #fca5a5;
        }

        .canvas-node-responsable.empty .name {
            color: #dc2626;
            font-weight: 500;
        }

        .canvas-node-stats {
            display: flex;
            justify-content: space-between;
            font-size: 0.7rem;
            color: #64748b;
        }

        .canvas-node-actions {
            display: flex;
            gap: 4px;
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px solid #e2e8f0;
        }

        .canvas-node-actions button {
            flex: 1;
            padding: 6px;
            background: #f1f5f9;
            border: none;
            border-radius: 6px;
            font-size: 0.7rem;
            cursor: pointer;
            transition: all 0.15s;
        }

        .canvas-node-actions button:hover {
            background: var(--primary);
            color: white;
        }

        /* Zoom controls */
        .canvas-zoom-controls {
            position: absolute;
            bottom: 20px;
            right: 20px;
            display: flex;
            gap: 4px;
            background: #0f172a;
            padding: 6px;
            border-radius: 10px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        }

        .canvas-zoom-controls button {
            width: 36px;
            height: 36px;
            background: #334155;
            border: none;
            border-radius: 8px;
            color: white;
            font-size: 1.1rem;
            cursor: pointer;
            transition: all 0.2s;
        }

        .canvas-zoom-controls button:hover {
            background: var(--primary);
        }

        .canvas-zoom-controls span {
            padding: 0 12px;
            color: white;
            font-size: 0.85rem;
            display: flex;
            align-items: center;
        }

        /* Mini mapa */
        .canvas-minimap {
            position: absolute;
            bottom: 20px;
            left: 20px;
            width: 150px;
            height: 100px;
            background: #0f172a;
            border-radius: 10px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
            overflow: hidden;
        }

        .canvas-minimap-content {
            width: 100%;
            height: 100%;
            position: relative;
        }

        .canvas-minimap-viewport {
            position: absolute;
            border: 2px solid var(--accent);
            background: rgba(14, 165, 233, 0.1);
        }

        /* ===== ORG PAGE (Full Screen) ===== */
        .org-page {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #f1f5f9;
            z-index: 3000;
            display: none;
            flex-direction: column;
        }

        .org-page.active {
            display: flex;
        }

        .org-page-header {
            padding: 20px 32px;
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 4px 20px rgba(0,0,0,0.15);
            z-index: 10;
        }

        .org-page-header .back-btn {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px 20px;
            background: rgba(255,255,255,0.15);
            border: none;
            border-radius: 12px;
            color: white;
            font-size: 0.9rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .org-page-header .back-btn:hover {
            background: rgba(255,255,255,0.25);
            transform: translateX(-3px);
        }

        .org-page-header .title {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .org-page-header .flag { font-size: 2.5rem; }
        .org-page-header h2 { font-size: 1.5rem; font-weight: 700; }
        .org-page-header p { opacity: 0.9; font-size: 0.85rem; }

        .org-page-header .stats {
            display: flex;
            gap: 12px;
        }

        .org-page-header .stat {
            text-align: center;
            padding: 10px 18px;
            background: rgba(255,255,255,0.2);
            border-radius: var(--radius-md);
        }

        .org-page-header .stat-value { font-size: 1.3rem; font-weight: 800; }
        .org-page-header .stat-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 1px; opacity: 0.8; }

        .org-page-header .header-actions {
            display: flex;
            gap: 12px;
            align-items: center;
        }

        .org-page-header .admin-btn {
            padding: 10px 18px;
            background: rgba(255,255,255,0.15);
            border: none;
            border-radius: 10px;
            color: white;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .org-page-header .admin-btn:hover {
            background: rgba(255,255,255,0.25);
        }

        .org-page-container {
            display: flex;
            flex: 1;
            overflow: hidden;
        }

        .org-page-body {
            flex: 1;
            overflow: auto;
            padding: 24px;
        }

        .modal-search {
            width: 100%;
            max-width: 400px;
            padding: 14px 20px 14px 48px;
            border: 2px solid #e2e8f0;
            border-radius: 100px;
            font-size: 0.9rem;
            font-family: inherit;
            margin-bottom: 24px;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: 16px center;
            background-size: 20px;
        }

        .modal-search:focus {
            outline: none;
            border-color: var(--primary);
        }

        /* ===== ORG TREE ===== */
        .org-tree {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 40px 20px;
            min-width: max-content;
        }

        .tree-level {
            display: flex;
            justify-content: center;
            gap: 24px;
            margin-bottom: 0;
            flex-wrap: nowrap;
            position: relative;
        }

        .tree-connector {
            width: 3px;
            height: 30px;
            background: linear-gradient(180deg, var(--primary), var(--primary-light));
            margin: 0 auto;
        }

        .tree-connector-h {
            height: 3px;
            background: linear-gradient(90deg, transparent, var(--primary), transparent);
            position: absolute;
            top: -15px;
            left: 50%;
            transform: translateX(-50%);
        }

        /* Tree Node Container */
        .tree-node {
            display: flex;
            flex-direction: column;
            align-items: center;
            position: relative;
        }

        .tree-node::before {
            content: '';
            position: absolute;
            top: -15px;
            width: 3px;
            height: 15px;
            background: var(--primary);
        }

        /* First tree-node (root) should not have connector */
        .org-tree > .tree-node::before {
            display: none;
        }

        /* Tree Children Container */
        .tree-children {
            display: flex;
            gap: 24px;
            position: relative;
            padding-top: 15px;
        }

        /* Nodos colapsados */
        .tree-children.collapsed {
            display: none !important;
        }

        /* Botón expandir/colapsar */
        .expand-toggle {
            position: absolute;
            top: 8px;
            right: 8px;
            background: rgba(255,255,255,0.9);
            border: 1px solid #e2e8f0;
            border-radius: 6px;
            width: 28px;
            height: 28px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            color: #64748b;
            transition: all 0.2s;
            z-index: 10;
        }

        .expand-toggle:hover {
            background: #f1f5f9;
            color: #1e293b;
        }

        .direction-card .expand-toggle {
            background: rgba(255,255,255,0.2);
            border-color: rgba(255,255,255,0.3);
            color: white;
        }

        .direction-card .expand-toggle:hover {
            background: rgba(255,255,255,0.3);
        }

        /* Barra expandir/colapsar en la parte inferior */
        .expand-bar {
            margin-top: 10px;
            padding: 8px 12px;
            background: rgba(0,0,0,0.08);
            border-radius: 8px;
            font-size: 0.75rem;
            font-weight: 600;
            color: #64748b;
            cursor: pointer;
            transition: all 0.2s;
        }

        .expand-bar:hover {
            background: rgba(0,0,0,0.15);
            color: #1e293b;
        }

        .direction-card .expand-bar {
            background: rgba(196, 30, 58, 0.15);
            color: var(--primary);
        }

        .direction-card .expand-bar:hover {
            background: rgba(196, 30, 58, 0.25);
        }

        .area-card .expand-bar {
            background: rgba(14, 165, 233, 0.15);
            color: var(--accent);
        }

        .area-card .expand-bar:hover {
            background: rgba(14, 165, 233, 0.25);
        }

        .dept-card .expand-bar {
            background: rgba(245, 158, 11, 0.15);
            color: #b45309;
        }

        .dept-card .expand-bar:hover {
            background: rgba(245, 158, 11, 0.25);
        }

        /* Horizontal line connecting siblings */
        .tree-children::before {
            content: '';
            position: absolute;
            top: 0;
            height: 3px;
            background: var(--primary);
        }

        /* Calculate width based on first and last child */
        .tree-children:not(.single)::before {
            left: calc(50% - 50%);
            right: calc(50% - 50%);
            width: auto;
        }

        /* Position horizontal line from first to last child center */
        .tree-children:not(.single) {
            position: relative;
        }

        .tree-children:not(.single)::before {
            left: 50px;
            right: 50px;
        }

        .tree-children > .tree-node::before {
            display: block;
        }

        /* Single child - only vertical line, no horizontal */
        .tree-children.single::before {
            display: none;
        }

        .tree-children.single > .tree-node::before {
            display: block;
        }

        /* Scrollable org tree container */
        .org-modal-body {
            flex: 1;
            overflow: auto;
            padding: 28px 32px;
        }

        .org-tree-container {
            min-width: 100%;
            display: flex;
            justify-content: center;
            overflow-x: auto;
            padding-bottom: 40px;
        }

        /* Director General Card */
        .tree-dg {
            padding: 20px 32px;
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
            color: white;
            border-radius: var(--radius-lg);
            text-align: center;
            box-shadow: 0 8px 32px rgba(30, 41, 59, 0.4);
            min-width: 260px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .tree-dg:hover {
            transform: translateY(-3px);
            box-shadow: 0 12px 40px rgba(30, 41, 59, 0.5);
        }

        .tree-dg h3 {
            font-size: 0.9rem;
            font-weight: 700;
            margin-bottom: 6px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .tree-dg .name {
            font-size: 1rem;
            font-weight: 600;
            color: var(--accent);
        }

        .tree-dg .count {
            font-size: 0.7rem;
            opacity: 0.7;
            margin-top: 4px;
        }

        /* DG Node - el nodo raíz con DG arriba */
        .dg-node {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .dg-node::before {
            display: none !important;
        }

        /* Direction Card */
        .direction-card {
            padding: 16px 20px;
            background: white;
            border: 2px solid var(--primary);
            border-radius: var(--radius-md);
            text-align: center;
            min-width: 200px;
            max-width: 260px;
            box-shadow: 0 4px 15px var(--primary-glow);
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
        }

        /* Tarjetas de Direcciones Generales principales (primer nivel): mismo tamaño */
        #org-tree > .tree-children > .tree-node > .direction-card {
            width: 220px;
            min-height: 120px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

        /* Contenedor con staff lateral */
        .tree-node-with-staff {
            display: flex;
            align-items: flex-start;
            gap: 20px;
        }

        .staff-sidebar {
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin-top: 15px;
        }

        .staff-card {
            padding: 10px 14px;
            background: #f8fafc;
            border: 1px dashed #94a3b8;
            border-radius: 8px;
            text-align: center;
            min-width: 140px;
            max-width: 160px;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
        }

        .staff-card:hover {
            background: #f1f5f9;
            border-color: #64748b;
            transform: translateX(3px);
        }

        .staff-title {
            font-size: 0.65rem;
            font-weight: 700;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.3px;
            margin-bottom: 4px;
        }

        .staff-responsable {
            font-size: 0.75rem;
            font-weight: 500;
            color: #334155;
            margin-bottom: 4px;
        }

        .staff-badge {
            display: inline-block;
            padding: 2px 8px;
            background: #e2e8f0;
            border-radius: 100px;
            font-size: 0.6rem;
            font-weight: 600;
            color: #64748b;
        }

        .direction-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px var(--primary-glow);
        }

        .direction-card h4 {
            font-size: 0.7rem;
            font-weight: 700;
            color: var(--primary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 8px;
        }

        .direction-card .name {
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 6px;
        }

        .direction-card .badge {
            display: inline-block;
            padding: 4px 12px;
            background: var(--primary);
            border-radius: 100px;
            font-size: 0.7rem;
            font-weight: 600;
            color: white;
        }

        /* Area Card */
        .area-card {
            padding: 14px 18px;
            background: white;
            border: 2px solid var(--accent);
            border-radius: var(--radius-md);
            text-align: center;
            min-width: 160px;
            max-width: 220px;
            box-shadow: 0 4px 15px var(--accent-glow);
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
        }

        .area-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 20px var(--accent-glow);
        }

        .area-card h4 {
            font-size: 0.75rem;
            font-weight: 700;
            color: var(--accent);
            margin-bottom: 6px;
        }

        .area-card .name {
            font-size: 0.8rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 4px;
        }

        .area-card .badge {
            display: inline-block;
            padding: 3px 10px;
            background: var(--accent);
            border-radius: 100px;
            font-size: 0.65rem;
            font-weight: 600;
            color: white;
        }

        /* Badge de headcount total (recursivo) */
        .badge-headcount {
            background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;
            box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
            font-size: 0.75rem !important;
            padding: 5px 14px !important;
            font-weight: 800 !important;
        }

        .badge-headcount .headcount-total {
            font-weight: 900;
            font-size: 0.9rem;
        }

        .direction-card .badge-headcount {
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
            box-shadow: 0 2px 4px rgba(30, 41, 59, 0.4);
            color: white;
        }

        /* Dept Card */
        .dept-card {
            padding: 12px 16px;
            background: white;
            border: 2px solid var(--warning);
            border-radius: var(--radius-sm);
            text-align: center;
            min-width: 140px;
            max-width: 180px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .dept-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 15px rgba(245, 158, 11, 0.2);
        }

        .dept-card h5 {
            font-size: 0.7rem;
            font-weight: 600;
            color: var(--warning);
            margin-bottom: 4px;
        }

        .dept-card .count {
            font-size: 0.65rem;
            color: var(--text-tertiary);
        }

        .dept-card .dept-name {
            font-size: 0.65rem;
            color: var(--text-secondary);
            margin-bottom: 4px;
        }

        /* Subdepto Card */
        .subdepto-card {
            padding: 12px 16px;
            background: white;
            border: 2px solid #8b5cf6;
            border-radius: var(--radius-sm);
            text-align: center;
            min-width: 140px;
            max-width: 180px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .subdepto-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 15px rgba(139, 92, 246, 0.2);
        }

        .subdepto-card h5 {
            font-size: 0.7rem;
            font-weight: 600;
            color: #8b5cf6;
            margin-bottom: 4px;
        }

        .subdepto-card .expand-bar {
            background: #f3e8ff;
            color: #8b5cf6;
        }

        .subdepto-card .expand-bar:hover {
            background: #ede9fe;
        }

        /* Lista de empleados en departamentos y áreas */
        .dept-empleados-list,
        .area-empleados-list {
            margin-top: 8px;
            max-height: 200px;
            overflow-y: auto;
        }

        .area-empleados-list .emp-item {
            color: var(--accent);
        }

        .area-empleados-list .emp-item.responsable {
            background: rgba(14, 165, 233, 0.15);
            color: var(--accent);
        }

        .area-empleados-list .emp-item.responsable:hover {
            background: rgba(14, 165, 233, 0.25);
        }

        .area-empleados-list .emp-badge-resp {
            background: var(--accent);
        }

        .emp-item {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 4px 8px;
            margin: 2px 0;
            border-radius: 6px;
            font-size: 0.7rem;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .emp-item:hover {
            background: rgba(0,0,0,0.05);
            color: var(--text-primary);
        }

        .emp-item.responsable {
            background: rgba(245, 158, 11, 0.15);
            font-weight: 600;
            color: #b45309;
        }

        .emp-item.responsable:hover {
            background: rgba(245, 158, 11, 0.25);
        }

        .emp-icon {
            flex-shrink: 0;
            font-size: 0.65rem;
        }

        .emp-name {
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .emp-badge-resp {
            font-size: 0.55rem;
            padding: 2px 5px;
            background: #f59e0b;
            color: white;
            border-radius: 4px;
            font-weight: 600;
        }

        .emp-badge-global {
            font-size: 0.5rem;
            padding: 1px 4px;
            background: #d97706;
            color: white;
            border-radius: 3px;
            font-weight: 600;
            margin-left: 4px;
        }

        .emp-empty {
            font-size: 0.65rem;
            color: var(--text-tertiary);
            font-style: italic;
            text-align: center;
            padding: 8px;
        }

        /* Lista de responsables en tarjetas */
        .responsables-list {
            display: flex;
            flex-direction: column;
            gap: 4px;
            margin: 8px 0;
        }

        .resp-name {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            background: rgba(245, 158, 11, 0.15);
            border-radius: 6px;
            font-size: 0.8rem;
            font-weight: 600;
            color: #b45309;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .resp-name:hover {
            background: rgba(245, 158, 11, 0.25);
            transform: translateX(2px);
        }

        .resp-icon {
            font-size: 0.9rem;
        }

        .sin-responsable {
            font-size: 0.75rem;
            color: #dc2626;
            font-style: italic;
        }

        /* Botón editar responsable en tarjetas */
        .edit-responsable-btn {
            position: absolute;
            top: 8px;
            right: 8px;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            border: none;
            background: rgba(255,255,255,0.9);
            color: var(--text-secondary);
            font-size: 0.75rem;
            cursor: pointer;
            opacity: 0;
            transition: all 0.2s ease;
            z-index: 10;
        }

        .direction-card:hover .edit-responsable-btn,
        .area-card:hover .edit-responsable-btn,
        .dept-card:hover .edit-responsable-btn,
        .subdepto-card:hover .edit-responsable-btn {
            opacity: 1;
        }

        .edit-responsable-btn:hover {
            background: var(--primary);
            color: white;
            transform: scale(1.1);
        }

        .direction-card, .area-card, .dept-card, .subdepto-card {
            position: relative;
        }

        .sin-responsable {
            color: var(--text-tertiary);
            font-style: italic;
            font-size: 0.75rem;
        }

        /* Modal seleccionar responsable */
        .select-responsable-modal {
            width: 400px;
            max-width: 95%;
            max-height: 80vh;
            background: white;
            border-radius: var(--radius-xl);
            overflow: hidden;
            transform: scale(0.9) translateY(30px);
            transition: all 0.3s ease;
        }

        .modal-overlay.active .select-responsable-modal {
            transform: scale(1) translateY(0);
        }

        .select-responsable-header {
            padding: 20px 24px;
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
            color: white;
        }

        .select-responsable-header h3 {
            font-size: 1rem;
            margin-bottom: 4px;
        }

        .select-responsable-header p {
            font-size: 0.8rem;
            opacity: 0.8;
        }

        .select-responsable-body {
            padding: 16px;
            max-height: 50vh;
            overflow-y: auto;
        }

        .responsable-option {
            padding: 12px 16px;
            border: 1px solid #e2e8f0;
            border-radius: var(--radius-sm);
            margin-bottom: 8px;
            cursor: pointer;
            transition: all 0.15s ease;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .responsable-option:hover {
            border-color: var(--primary);
            background: #fef2f2;
        }

        .responsable-option.selected {
            border-color: var(--success);
            background: #f0fdf4;
        }

        .responsable-option .flag {
            font-size: 1.2rem;
        }

        .responsable-option .info {
            flex: 1;
        }

        .responsable-option .name {
            font-weight: 600;
            color: var(--text-primary);
            font-size: 0.9rem;
        }

        .responsable-option .puesto {
            font-size: 0.75rem;
            color: var(--text-secondary);
        }

        .responsable-option .check {
            color: var(--success);
            font-weight: bold;
        }

        .select-responsable-footer {
            padding: 16px 24px;
            border-top: 1px solid #e2e8f0;
            display: flex;
            gap: 12px;
            justify-content: flex-end;
        }

        /* ===== ADMIN PANEL ===== */
        .org-modal-container {
            display: flex;
            flex: 1;
            overflow: hidden;
        }

        .org-modal-body {
            flex: 1;
            overflow: auto;
            padding: 28px 32px;
        }

        .admin-panel {
            width: 320px;
            background: #f8fafc;
            border-left: 1px solid #e2e8f0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .admin-panel.collapsed {
            width: 0;
            border: none;
        }

        .admin-panel-header {
            padding: 16px 20px;
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
            color: white;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .admin-panel-header h3 {
            font-size: 0.9rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .admin-panel-tabs {
            display: flex;
            border-bottom: 1px solid #e2e8f0;
            background: white;
        }

        .admin-tab {
            flex: 1;
            padding: 12px 8px;
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--text-secondary);
            background: none;
            border: none;
            border-bottom: 2px solid transparent;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .admin-tab:hover {
            color: var(--primary);
            background: #fef2f2;
        }

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

        .admin-panel-content {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
        }

        .admin-section {
            margin-bottom: 20px;
        }

        .admin-section-title {
            font-size: 0.7rem;
            font-weight: 700;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .admin-search {
            width: 100%;
            padding: 10px 14px;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            font-size: 0.85rem;
            margin-bottom: 12px;
        }

        .admin-search:focus {
            outline: none;
            border-color: var(--primary);
        }

        /* Estructura items en panel admin */
        .estructura-item {
            display: flex;
            align-items: center;
            padding: 10px 12px;
            background: white;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            margin-bottom: 8px;
            font-size: 0.8rem;
            transition: all 0.15s ease;
        }

        .estructura-item:hover {
            border-color: var(--primary);
            box-shadow: 0 2px 8px rgba(196, 30, 58, 0.1);
        }

        .estructura-item .tipo-badge {
            font-size: 0.6rem;
            padding: 2px 6px;
            border-radius: 4px;
            font-weight: 600;
            margin-right: 10px;
        }

        .estructura-item .tipo-badge.direccion {
            background: #fef2f2;
            color: var(--primary);
        }

        .estructura-item .tipo-badge.area {
            background: #ecfeff;
            color: var(--accent);
        }

        .estructura-item .tipo-badge.departamento {
            background: #fffbeb;
            color: var(--warning);
        }

        .estructura-item .tipo-badge.subdepartamento {
            background: #f3e8ff;
            color: #8b5cf6;
        }

        .estructura-item .nombre {
            flex: 1;
            font-weight: 500;
            color: var(--text-primary);
        }

        .estructura-item .toggle-btn {
            width: 40px;
            height: 22px;
            border-radius: 11px;
            border: none;
            cursor: pointer;
            position: relative;
            transition: all 0.2s ease;
        }

        .estructura-item .toggle-btn.activo {
            background: var(--success);
        }

        .estructura-item .toggle-btn.inactivo {
            background: #cbd5e1;
        }

        .estructura-item .toggle-btn::after {
            content: '';
            position: absolute;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            background: white;
            top: 2px;
            transition: all 0.2s ease;
            box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }

        .estructura-item .toggle-btn.activo::after {
            left: 20px;
        }

        .estructura-item .toggle-btn.inactivo::after {
            left: 2px;
        }

        /* Empleado items en panel admin */
        .empleado-item {
            display: flex;
            align-items: center;
            padding: 10px 12px;
            background: white;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            margin-bottom: 8px;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .empleado-item:hover {
            border-color: var(--primary);
            background: #fef2f2;
        }

        .empleado-item.asignado {
            opacity: 0.6;
        }

        .empleado-item .flag {
            font-size: 1.1rem;
            margin-right: 10px;
        }

        .empleado-item .info {
            flex: 1;
        }

        .empleado-item .nombre {
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--text-primary);
        }

        .empleado-item .puesto {
            font-size: 0.7rem;
            color: var(--text-secondary);
        }

        .empleado-item .asignar-btn {
            padding: 4px 10px;
            font-size: 0.7rem;
            background: var(--primary);
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            opacity: 0;
            transition: all 0.15s ease;
        }

        .empleado-item:hover .asignar-btn {
            opacity: 1;
        }

        .empleado-item .asignar-btn:hover {
            background: var(--primary-dark);
        }

        /* Toggle panel button */
        .toggle-admin-panel {
            position: absolute;
            right: 70px;
            top: 20px;
            padding: 10px 16px;
            background: rgba(255,255,255,0.2);
            border: none;
            border-radius: 8px;
            color: white;
            font-size: 0.8rem;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: all 0.2s ease;
        }

        .toggle-admin-panel:hover {
            background: rgba(255,255,255,0.3);
        }

        /* Drag and drop styles */
        .empleado-item.dragging {
            opacity: 0.5;
            transform: scale(0.95);
        }

        .estructura-item.drag-over {
            border-color: var(--success);
            background: #f0fdf4;
            box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
        }

        /* ===== WORKERS MODAL ===== */
        .workers-modal {
            width: 94%;
            max-width: 1200px;
            max-height: 92vh;
            background: white;
            border-radius: var(--radius-xl);
            box-shadow: var(--glass-shadow-lg);
            display: flex;
            flex-direction: column;
            transform: scale(0.9) translateY(30px);
            transition: all 0.3s ease;
            overflow: hidden;
        }

        .modal-overlay.active .workers-modal {
            transform: scale(1) translateY(0);
        }

        .workers-modal-header {
            padding: 24px 28px;
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
            color: white;
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .workers-modal-header .back-btn {
            padding: 10px 20px;
            background: rgba(255,255,255,0.15);
            border: none;
            border-radius: 100px;
            color: white;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            font-family: inherit;
        }

        .workers-modal-header .back-btn:hover {
            background: rgba(255,255,255,0.25);
        }

        .workers-modal-header h2 {
            font-size: 1.25rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .workers-modal-header .count {
            padding: 4px 14px;
            background: var(--primary);
            border-radius: 100px;
            font-size: 0.85rem;
        }

        .workers-modal-body {
            flex: 1;
            overflow-y: auto;
            padding: 24px 28px;
        }

        .workers-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 20px;
        }

        /* ===== WORKER CARD ===== */
        .worker-card {
            background: white;
            border: 1px solid #e2e8f0;
            border-radius: var(--radius-md);
            padding: 20px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .worker-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 25px rgba(0,0,0,0.1);
            border-color: var(--primary);
        }

        .worker-card .name {
            font-size: 1rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 8px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .worker-card .name .flag { font-size: 1.3rem; }

        .worker-card .position {
            color: var(--primary);
            font-size: 0.85rem;
            font-weight: 500;
            margin-bottom: 6px;
        }

        .worker-card .level {
            color: var(--text-tertiary);
            font-size: 0.8rem;
        }

        .worker-card.responsable {
            border-color: var(--success);
            background: linear-gradient(135deg, #f0fdf4 0%, white 100%);
        }

        .worker-card .responsable-badge {
            background: var(--success);
            color: white;
            font-size: 0.7rem;
            padding: 2px 8px;
            border-radius: 100px;
            font-weight: 600;
            margin-left: auto;
        }

        .worker-card .worker-actions {
            margin-top: 12px;
            padding-top: 12px;
            border-top: 1px solid #e2e8f0;
        }

        .btn-responsable {
            background: #f1f5f9;
            border: 1px solid #e2e8f0;
            color: var(--text-secondary);
            font-size: 0.8rem;
            padding: 6px 12px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
            font-family: inherit;
        }

        .btn-responsable:hover {
            background: var(--success);
            color: white;
            border-color: var(--success);
        }

        .btn-responsable.activo {
            background: #fef2f2;
            color: #dc2626;
            border-color: #fecaca;
        }

        .btn-responsable.activo:hover {
            background: #dc2626;
            color: white;
            border-color: #dc2626;
        }

        /* ===== CREATE/EDIT MODAL (Generic) ===== */
        .create-employee-modal {
            width: 450px;
            max-width: 95%;
            background: white;
            border-radius: var(--radius-xl);
            overflow: hidden;
            transform: scale(0.9) translateY(30px);
            transition: all 0.3s ease;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
        }

        .modal-overlay.active .create-employee-modal {
            transform: scale(1) translateY(0);
        }

        .create-employee-modal .modal-header {
            padding: 20px 24px;
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .create-employee-modal .modal-header h2 {
            margin: 0;
            font-size: 1.25rem;
            font-weight: 600;
        }

        .create-employee-modal .modal-header .close-btn {
            background: rgba(255,255,255,0.2);
            border: none;
            color: white;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            cursor: pointer;
            font-size: 1.2rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .create-employee-modal .modal-header .close-btn:hover {
            background: rgba(255,255,255,0.3);
        }

        .create-employee-modal form {
            padding: 24px;
        }

        .create-employee-modal .form-group {
            margin-bottom: 16px;
        }

        .create-employee-modal .form-group label {
            display: block;
            font-size: 0.8rem;
            font-weight: 600;
            color: #64748b;
            margin-bottom: 6px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .create-employee-modal .form-group input,
        .create-employee-modal .form-group select,
        .create-employee-modal .form-group textarea {
            width: 100%;
            padding: 10px 14px;
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            font-size: 0.95rem;
            transition: border-color 0.2s;
            background: white;
        }

        .create-employee-modal .form-group input:focus,
        .create-employee-modal .form-group select:focus,
        .create-employee-modal .form-group textarea:focus {
            outline: none;
            border-color: #6366f1;
        }

        .create-employee-modal .form-actions {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
            margin-top: 24px;
            padding-top: 16px;
            border-top: 1px solid #e2e8f0;
        }

        .create-employee-modal .btn-secondary {
            padding: 10px 20px;
            border: 2px solid #e2e8f0;
            background: white;
            color: #64748b;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 500;
        }

        .create-employee-modal .btn-primary {
            padding: 10px 24px;
            border: none;
            background: linear-gradient(135deg, #6366f1, #8b5cf6);
            color: white;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 600;
        }

        .create-employee-modal .btn-primary:hover {
            opacity: 0.9;
        }

        /* ===== EMPLOYEE MODAL ===== */
        .employee-modal {
            width: 400px;
            max-width: 95%;
            background: white;
            border-radius: var(--radius-xl);
            overflow: hidden;
            transform: scale(0.9) translateY(30px);
            transition: all 0.3s ease;
        }

        .modal-overlay.active .employee-modal {
            transform: scale(1) translateY(0);
        }

        .employee-modal-header {
            padding: 32px;
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            color: white;
            text-align: center;
            position: relative;
        }

        .employee-modal-header .close-btn {
            position: absolute;
            top: 16px;
            right: 16px;
            width: 36px;
            height: 36px;
            background: rgba(255,255,255,0.15);
            border: none;
            border-radius: 50%;
            color: white;
            font-size: 1.2rem;
            cursor: pointer;
        }

        .employee-modal-header .flag-badge {
            position: absolute;
            top: 16px;
            left: 16px;
            font-size: 1.8rem;
        }

        .employee-modal-header .avatar {
            width: 90px;
            height: 90px;
            background: rgba(255,255,255,0.15);
            border-radius: 50%;
            margin: 0 auto 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 2.5rem;
            border: 3px solid rgba(255,255,255,0.2);
            overflow: hidden;
        }

        .employee-modal-header .avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .employee-modal-header h3 { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
        .employee-modal-header .position { opacity: 0.9; font-size: 0.9rem; }

        .employee-modal-body { padding: 24px; }

        .employee-info {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
        }

        .employee-info-item {
            padding: 14px;
            background: #f8fafc;
            border-radius: var(--radius-sm);
        }

        .employee-info-item.full { grid-column: span 2; }

        .employee-info-item label {
            display: block;
            font-size: 0.65rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--text-tertiary);
            margin-bottom: 4px;
        }

        .employee-info-item span {
            font-size: 0.9rem;
            font-weight: 600;
            color: var(--text-primary);
        }

        .employee-modal-footer { padding: 0 24px 24px; }

        .employee-level {
            padding: 16px;
            background: #f8fafc;
            border-radius: var(--radius-sm);
            text-align: center;
        }

        .employee-level .badge {
            font-size: 1rem;
            font-weight: 700;
            color: var(--primary);
        }

        .employee-level .text {
            font-size: 0.65rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--text-tertiary);
            margin-top: 4px;
        }

        /* ===== ADMIN CONTROLS ===== */
        .admin-only { display: none !important; }
        body.is-admin .admin-only { display: flex !important; }
        body.is-admin .admin-only-block { display: block !important; }
        body.is-admin .admin-only-inline { display: inline-block !important; }
        .admin-only-salary { display: none !important; }
        body.can-see-salary .admin-only-salary { display: flex !important; }
        .superadmin-only { display: none !important; }
        body.is-superadmin .superadmin-only { display: flex !important; }

        .admin-fab {
            position: fixed;
            bottom: 100px;
            right: 30px;
            z-index: 500;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .admin-fab-btn {
            width: 56px;
            height: 56px;
            border-radius: 50%;
            border: none;
            background: var(--primary);
            color: white;
            font-size: 1.5rem;
            cursor: pointer;
            box-shadow: 0 4px 15px var(--primary-glow);
            transition: all 0.2s ease;
        }

        .admin-fab-btn:hover {
            transform: scale(1.1);
            box-shadow: 0 6px 20px var(--primary-glow);
        }

        .admin-fab-btn.secondary {
            background: var(--accent);
            box-shadow: 0 4px 15px var(--accent-glow);
        }

        .admin-toolbar {
            display: none;
            align-items: center;
            gap: 12px;
            padding: 12px 16px;
            background: #fef3c7;
            border-bottom: 1px solid #fcd34d;
        }

        body.is-admin .admin-toolbar {
            display: flex;
        }

        .admin-toolbar-label {
            font-size: 0.75rem;
            font-weight: 600;
            color: #92400e;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .admin-btn {
            padding: 8px 16px;
            background: white;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            font-size: 0.8rem;
            font-weight: 600;
            color: var(--text-primary);
            cursor: pointer;
            transition: all 0.15s ease;
            font-family: inherit;
        }

        .admin-btn:hover {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }

        .admin-btn.danger {
            border-color: #fecaca;
            color: #dc2626;
        }

        .admin-btn.danger:hover {
            background: #dc2626;
            color: white;
        }

        /* Edit Badge on Cards */
        .edit-badge {
            position: absolute;
            top: -8px;
            right: -8px;
            width: 24px;
            height: 24px;
            background: var(--warning);
            border-radius: 50%;
            display: none;
            align-items: center;
            justify-content: center;
            font-size: 0.7rem;
            color: white;
            cursor: pointer;
            box-shadow: 0 2px 6px rgba(0,0,0,0.2);
        }

        body.is-admin .edit-badge {
            display: flex;
        }

        /* Admin Panel Styles */
        .admin-panel {
            width: 420px;
            max-width: 95%;
            max-height: 90vh;
            background: white;
            border-radius: var(--radius-xl);
            overflow: hidden;
            transform: scale(0.9) translateY(30px);
            transition: all 0.3s ease;
        }

        .modal-overlay.active .admin-panel {
            transform: scale(1) translateY(0);
        }

        .admin-panel-header {
            padding: 24px;
            background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
            color: white;
        }

        .admin-panel-header h2 {
            font-size: 1.25rem;
            margin-bottom: 4px;
        }

        .admin-panel-header p {
            font-size: 0.85rem;
            opacity: 0.8;
        }

        .admin-panel-body {
            padding: 24px;
            max-height: 60vh;
            overflow-y: auto;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            font-size: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: var(--text-secondary);
            margin-bottom: 8px;
        }

        .form-group input,
        .form-group select,
        .form-group textarea {
            width: 100%;
            padding: 12px 16px;
            border: 2px solid #e2e8f0;
            border-radius: var(--radius-sm);
            font-size: 0.9rem;
            font-family: inherit;
            transition: border-color 0.15s ease;
        }

        .form-group input:focus,
        .form-group select:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: var(--primary);
        }

        .form-actions {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
            padding-top: 16px;
            border-top: 1px solid #e2e8f0;
        }

        .btn-primary {
            padding: 12px 24px;
            background: var(--primary);
            color: white;
            border: none;
            border-radius: var(--radius-sm);
            font-size: 0.9rem;
            font-weight: 600;
            cursor: pointer;
            font-family: inherit;
        }

        .btn-primary:hover {
            background: var(--primary-dark);
        }

        .btn-secondary {
            padding: 12px 24px;
            background: #f1f5f9;
            color: var(--text-primary);
            border: none;
            border-radius: var(--radius-sm);
            font-size: 0.9rem;
            font-weight: 600;
            cursor: pointer;
            font-family: inherit;
        }

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

        /* ===== REGION STATS ===== */
        .region-stats {
            position: fixed;
            bottom: 24px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 100;
            display: flex;
            gap: 12px;
        }

        .region-stat {
            padding: 16px 28px;
            background: var(--glass-bg);
            border: 1px solid var(--glass-border);
            border-radius: 100px;
            box-shadow: var(--glass-shadow);
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
        }

        .region-stat:hover {
            transform: translateY(-4px);
            box-shadow: var(--glass-shadow-lg);
        }

        .region-stat .icon { font-size: 1.5rem; }
        .region-stat .value { font-size: 1.25rem; font-weight: 800; color: var(--text-primary); }
        .region-stat .label { font-size: 0.7rem; color: var(--text-secondary); }

        .region-stat.toggle-global {
            padding: 12px 18px;
            background: rgba(99, 102, 241, 0.1);
            border: 1px solid rgba(99, 102, 241, 0.3);
        }
        .region-stat.toggle-global:hover {
            background: rgba(99, 102, 241, 0.2);
        }
        .region-stat.toggle-global.active {
            background: rgba(239, 68, 68, 0.15);
            border-color: rgba(239, 68, 68, 0.4);
        }
        .region-stat.toggle-global .value { font-size: 0.7rem; }

        .region-stat.global-hidden {
            opacity: 0.3;
            pointer-events: none;
        }

        /* ===== WATERMARK ===== */
        .watermark {
            position: fixed;
            bottom: 16px;
            left: 20px;
            z-index: 50;
            font-size: 0.95rem;
            color: var(--text-secondary);
            opacity: 0.85;
            font-weight: 600;
            background: rgba(255,255,255,0.9);
            padding: 10px 18px;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }

        /* ===== LOADING ===== */
        .loading {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 60px;
            color: var(--text-secondary);
        }

        .spinner {
            width: 40px;
            height: 40px;
            border: 3px solid #e2e8f0;
            border-top-color: var(--primary);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin { to { transform: rotate(360deg); } }

        /* (responsive rules moved to end of file) */

        /* ── Sección Económica / Drilldown ──────────────────────────── */
        .eco-section {
            background: white;
            border-radius: 12px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            border: 1px solid #e2e8f0;
            overflow: hidden;
        }

        .eco-header {
            padding: 16px 20px;
            background: linear-gradient(135deg, #0f172a, #1e3a5f);
            color: white;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        .eco-header-left {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .eco-title {
            font-size: 1rem;
            font-weight: 600;
        }

        .eco-breadcrumb {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 0.8rem;
            opacity: 0.85;
            flex-wrap: wrap;
        }

        .eco-breadcrumb-item {
            cursor: pointer;
            padding: 2px 8px;
            border-radius: 4px;
            transition: background 0.15s;
        }

        .eco-breadcrumb-item:hover {
            background: rgba(255,255,255,0.2);
        }

        .eco-breadcrumb-item.current {
            background: rgba(255,255,255,0.15);
            cursor: default;
        }

        .eco-breadcrumb-sep {
            opacity: 0.5;
        }

        .eco-back-btn {
            background: rgba(255,255,255,0.15);
            border: 1px solid rgba(255,255,255,0.3);
            color: white;
            padding: 6px 14px;
            border-radius: 6px;
            font-size: 0.8rem;
            cursor: pointer;
            transition: all 0.2s;
        }

        .eco-back-btn:hover {
            background: rgba(255,255,255,0.25);
        }

        .eco-table-wrap {
            overflow-x: auto;
        }

        .eco-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.875rem;
        }

        .eco-table th {
            background: #f8fafc;
            padding: 10px 16px;
            text-align: right;
            font-size: 0.72rem;
            font-weight: 600;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.4px;
            border-bottom: 2px solid #e2e8f0;
            white-space: nowrap;
        }

        .eco-table th:first-child { text-align: left; }

        .eco-table td {
            padding: 12px 16px;
            text-align: right;
            border-bottom: 1px solid #f1f5f9;
            color: #334155;
        }

        .eco-table td:first-child {
            text-align: left;
            font-weight: 500;
            color: #1e293b;
        }

        .eco-table tbody tr {
            transition: background 0.12s;
        }

        .eco-table tbody tr.drillable {
            cursor: pointer;
        }

        .eco-table tbody tr.drillable:hover {
            background: #f0f7ff;
        }

        .eco-table .total-row {
            background: #f8fafc;
            font-weight: 700;
            border-top: 2px solid #e2e8f0;
        }

        .eco-table .total-row td { color: #0f172a; }

        .eco-drill-icon {
            display: inline-block;
            margin-left: 6px;
            opacity: 0.4;
            font-size: 0.75rem;
            vertical-align: middle;
        }

        .eco-bar-bg {
            display: inline-block;
            width: 80px;
            height: 6px;
            background: #e2e8f0;
            border-radius: 3px;
            vertical-align: middle;
            margin-right: 8px;
        }

        .eco-bar-fill {
            display: block;
            height: 100%;
            border-radius: 3px;
            background: linear-gradient(90deg, #3b82f6, #60a5fa);
        }

        .eco-coste-val { color: #0369a1; font-weight: 600; }
        .eco-medio-val { color: #6d28d9; }

        .eco-loading {
            text-align: center;
            padding: 40px;
            color: #94a3b8;
            font-size: 0.9rem;
        }

        /* ── Chart containers ────────────────────────────────────────── */
        .chart-card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            border: 1px solid #e2e8f0;
            overflow: hidden;
        }

        .chart-header {
            padding: 14px 20px;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .chart-title {
            font-size: 0.9rem;
            font-weight: 600;
            color: #1e293b;
        }

        .chart-badge {
            font-size: 0.7rem;
            padding: 3px 8px;
            border-radius: 5px;
            background: #f1f5f9;
            color: #64748b;
        }

        .chart-body {
            padding: 16px 20px;
            position: relative;
            height: 200px;
        }

        .chart-body canvas {
            max-height: 180px;
        }

        /* ── KPI card rediseño ────────────────────────────────────────── */
        .kpi-card-new {
            background: white;
            border-radius: 12px;
            padding: 20px 24px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.08);
            border: 1px solid #e2e8f0;
            transition: all 0.2s ease;
            cursor: pointer;
        }

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

        .kpi-card-new .kpi-row {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 12px;
        }

        .kpi-card-new .kpi-label {
            font-size: 0.75rem;
            font-weight: 600;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .kpi-card-new .kpi-icon-lg {
            width: 42px;
            height: 42px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.4rem;
            flex-shrink: 0;
        }

        .kpi-card-new .kpi-val {
            font-size: 2.2rem;
            font-weight: 700;
            color: #0f172a;
            line-height: 1.1;
        }

        .kpi-card-new .kpi-val.small {
            font-size: 1.5rem;
        }

        .kpi-card-new .kpi-desc {
            font-size: 0.8rem;
            color: #94a3b8;
            margin-top: 4px;
        }

        .kpi-card-new .kpi-badge {
            display: inline-flex;
            align-items: center;
            gap: 3px;
            font-size: 0.72rem;
            font-weight: 600;
            padding: 3px 8px;
            border-radius: 20px;
            margin-top: 10px;
        }

        .kpi-badge.blue   { background: #dbeafe; color: #1d4ed8; }
        .kpi-badge.green  { background: #dcfce7; color: #15803d; }
        .kpi-badge.amber  { background: #fef3c7; color: #b45309; }
        .kpi-badge.violet { background: #ede9fe; color: #7c3aed; }
        .kpi-badge.slate  { background: #f1f5f9; color: #475569; }

        .dashboard-section-title {
            font-size: 0.7rem;
            font-weight: 700;
            color: #94a3b8;
            text-transform: uppercase;
            letter-spacing: 1px;
            grid-column: span 12;
            margin-bottom: -8px;
            margin-top: 8px;
        }

        /* ═══════════════════════════════════════════════════════
           DASHBOARD REWORK — Modern Light Design System
        ═══════════════════════════════════════════════════════ */

        /* Design tokens */
        :root {
            --bg:        #f8fafc;
            --card:      #ffffff;
            --border:    #e2e8f0;
            --primary:   #4f46e5;
            --primary-l: #eef2ff;
            --sky:       #0ea5e9;
            --sky-l:     #f0f9ff;
            --emerald:   #10b981;
            --emerald-l: #ecfdf5;
            --amber:     #f59e0b;
            --amber-l:   #fffbeb;
            --violet:    #8b5cf6;
            --violet-l:  #f5f3ff;
            --text:      #0f172a;
            --text-2:    #475569;
            --text-3:    #94a3b8;
        }

        /* Top header bar */
        .dash-header-bar {
            display: flex;
            align-items: center;
            gap: 16px;
            background: #ffffff;
            border-bottom: 1px solid var(--border);
            padding: 12px 24px;
            flex-shrink: 0;
        }
        .dash-back-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            background: none;
            border: 1px solid var(--border);
            color: var(--text-2);
            padding: 7px 14px;
            border-radius: 8px;
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.15s;
            white-space: nowrap;
        }
        .dash-back-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
        .dash-header-center {
            display: flex;
            align-items: center;
            gap: 8px;
            flex: 1;
        }
        .dash-header-name {
            font-weight: 700;
            font-size: 1rem;
            color: var(--text);
            letter-spacing: -0.01em;
        }
        .dash-header-sep { color: var(--text-3); }
        .dash-header-date {
            font-size: 0.85rem;
            color: var(--text-3);
        }
        .dash-header-right { margin-left: auto; }

        /* Tab Navigation */
        .dash-tabs-nav {
            display: flex;
            align-items: center;
            background: var(--card);
            border-bottom: 1px solid var(--border);
            padding: 0 24px;
            gap: 4px;
            position: sticky;
            top: 0;
            z-index: 9;
            flex-shrink: 0;
        }
        .dash-tab {
            padding: 13px 18px;
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--text-2);
            background: none;
            border: none;
            border-bottom: 2px solid transparent;
            cursor: pointer;
            transition: all 0.15s;
            margin-bottom: -1px;
            white-space: nowrap;
        }
        .dash-tab:hover { color: var(--primary); }
        .dash-tab.active {
            color: var(--primary);
            border-bottom-color: var(--primary);
            font-weight: 600;
        }
        #dash-tab-content {
            flex: 1;
            overflow: auto;
        }
        @keyframes fadeInUp {
            from { opacity: 0; transform: translateY(5px); }
            to   { opacity: 1; transform: translateY(0); }
        }
        .fade-in { animation: fadeInUp 0.18s ease-out; }

        /* Dashboard grid padding reset */
        .dashboard-grid { padding: 20px 24px; gap: 16px; }

        /* Updated card radius & shadows */
        .kpi-card-new {
            border-radius: 16px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
        }
        .section-card {
            border-radius: 16px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
        }
        .chart-card {
            border-radius: 16px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
        }
        .eco-section {
            border-radius: 16px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
        }

        /* Dist-bar color variants */
        .dist-bar-fill.indigo { background: linear-gradient(90deg, #4f46e5, #818cf8); }
        .dist-bar-fill.sky    { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }

        /* Eco header updated to light style */
        .eco-header {
            background: #f8fafc;
            color: var(--text);
            border-bottom: 1px solid var(--border);
        }
        .eco-title { color: var(--text); }
        .eco-breadcrumb { color: var(--text-2); }
        .eco-breadcrumb-item { color: var(--text-2); }
        .eco-breadcrumb-item:hover { background: var(--primary-l); color: var(--primary); }
        .eco-breadcrumb-item.current { background: var(--primary-l); color: var(--primary); font-weight: 600; }
        .eco-back-btn {
            background: white;
            border: 1px solid var(--border);
            color: var(--text-2);
        }
        .eco-back-btn:hover { background: var(--primary-l); border-color: var(--primary); color: var(--primary); }

        /* Eco cards drilldown */
        .eco-cards-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
            gap: 14px;
        }
        .eco-card {
            background: #f8fafc;
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 16px;
            transition: all 0.15s;
        }
        .eco-card.drillable { cursor: pointer; }
        .eco-card.drillable:hover {
            background: var(--primary-l);
            border-color: var(--primary);
            transform: translateY(-2px);
            box-shadow: 0 4px 16px rgba(79,70,229,0.12);
        }
        .eco-card-name {
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-weight: 600;
            font-size: 0.82rem;
            color: var(--text);
            margin-bottom: 10px;
            gap: 4px;
        }
        .eco-card-name svg { opacity: 0.3; flex-shrink: 0; transition: opacity 0.15s; }
        .eco-card.drillable:hover .eco-card-name svg { opacity: 0.8; }
        .eco-card-hc-val {
            font-size: 1.65rem;
            font-weight: 800;
            color: var(--sky);
            line-height: 1;
            letter-spacing: -0.02em;
        }
        .eco-card-hc-val span { font-size: 0.72rem; font-weight: 400; color: var(--text-3); }
        .eco-card-bar-bg {
            height: 4px;
            background: var(--border);
            border-radius: 2px;
            margin: 8px 0 4px;
            overflow: hidden;
        }
        .eco-card-bar-fill {
            height: 100%;
            border-radius: 2px;
            background: linear-gradient(90deg, var(--sky), #38bdf8);
            transition: width 0.4s ease;
        }
        .eco-card.drillable:hover .eco-card-bar-fill {
            background: linear-gradient(90deg, var(--primary), #818cf8);
        }
        .eco-card-pct-hc { font-size: 0.7rem; color: var(--text-3); margin-bottom: 8px; }
        .eco-card-sep { height: 1px; background: var(--border); margin: 8px 0; }
        .eco-card-coste {
            font-size: 1rem;
            font-weight: 700;
            color: var(--emerald);
            letter-spacing: -0.01em;
        }
        .eco-card-medio { font-size: 0.76rem; color: var(--text-2); margin-top: 2px; }
        .eco-card-medio span { color: var(--text-3); }
        .eco-card-pct-coste { font-size: 0.68rem; color: var(--text-3); margin-top: 2px; }
        .eco-card-leaf-hint { font-size: 0.7rem; color: var(--primary); margin-top: 8px; font-weight: 500; opacity: 0.8; }
        .eco-total-bar {
            display: flex;
            gap: 20px;
            align-items: center;
            padding: 10px 0 16px;
            font-size: 0.82rem;
            color: var(--text-2);
            flex-wrap: wrap;
            border-bottom: 1px solid var(--border);
            margin-bottom: 16px;
        }
        .eco-total-bar strong { color: var(--text); }

        /* Eco view toggle (Por Sociedad / Por Área) */
        .eco-view-toggle {
            display: flex;
            gap: 6px;
            padding: 16px 20px 4px;
        }
        .eco-vtoggle {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 6px 14px;
            border-radius: 20px;
            border: 1.5px solid var(--border);
            background: var(--card);
            color: var(--text-2);
            font-size: 0.78rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.15s;
        }
        .eco-vtoggle.active {
            background: var(--primary);
            border-color: var(--primary);
            color: white;
        }
        .eco-vtoggle:hover:not(.active) {
            border-color: var(--primary);
            color: var(--primary);
        }
        /* Flag emoji in eco cards */
        .eco-card-flag { font-size: 1.1em; margin-right: 3px; }
        /* Breadcrumb link style */
        .eco-breadcrumb-item.link { cursor: pointer; color: var(--primary); }
        .eco-breadcrumb-item.link:hover { text-decoration: underline; }

        /* Pyramid colored bars */
        .pyramid-level .bar-fill { background: var(--primary); }

        /* Chart body height override for tabs */
        .chart-body-tall { height: 260px !important; }

        /* ── SVG Icon system ── */
        .ico { display:inline-flex; align-items:center; justify-content:center; flex-shrink:0; }
        .ico svg { display:block; }
        button .ico, a .ico { pointer-events:none; }

/* ===== CHATBOT FAB ===== */
        /* Botón flotante */
        #chat-fab {
            position: fixed; bottom: 24px; right: 24px; z-index: 9000;
            width: 56px; height: 56px; border-radius: 50%;
            background: linear-gradient(135deg, #4f46e5, #7c3aed);
            border: none; cursor: pointer; box-shadow: 0 4px 20px rgba(79,70,229,.4);
            display: none; align-items: center; justify-content: center;
            font-size: 1.5rem; transition: transform .2s, box-shadow .2s;
        }
        #chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(79,70,229,.5); }
        #chat-fab.open { background: linear-gradient(135deg, #475569, #334155); }

        /* Panel del chat */
        #chat-panel {
            position: fixed; bottom: 92px; right: 24px; z-index: 9000;
            width: 700px; max-width: calc(100vw - 32px); height: 80vh; max-height: 800px;
            background: #fff; border-radius: 20px;
            box-shadow: 0 8px 40px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.08);
            display: none; flex-direction: column; overflow: hidden;
            border: 1px solid #e2e8f0;
        }
        #chat-panel.visible { display: flex; }

        /* Header */
        .chat-header {
            padding: 16px 20px; display: flex; align-items: center; gap: 10px;
            background: linear-gradient(135deg, #4f46e5, #7c3aed); color: white;
        }
        .chat-header-icon { font-size: 1.4rem; }
        .chat-header-info { flex: 1; }
        .chat-header-info strong { display: block; font-size: .9rem; }
        .chat-header-info span { font-size: .72rem; opacity: .8; }
        .chat-close-btn {
            background: rgba(255,255,255,.15); border: none; border-radius: 8px;
            color: white; width: 28px; height: 28px; cursor: pointer; font-size: .9rem;
            display: flex; align-items: center; justify-content: center;
        }
        .chat-close-btn:hover { background: rgba(255,255,255,.25); }

        /* Mensajes */
        #chat-messages {
            flex: 1; overflow-y: auto; padding: 16px; display: flex;
            flex-direction: column; gap: 12px; min-height: 200px;
            background: #f8fafc;
        }
        .chat-msg { display: flex; gap: 8px; align-items: flex-end; }
        .chat-msg.user { flex-direction: row-reverse; }
        .chat-bubble {
            max-width: 88%; padding: 10px 14px; border-radius: 16px;
            font-size: .85rem; line-height: 1.55; word-break: break-word;
        }
        .chat-msg.bot .chat-bubble {
            background: #fff; color: #0f172a;
            border: 1px solid #e2e8f0; border-bottom-left-radius: 4px;
            box-shadow: 0 1px 4px rgba(0,0,0,.06);
        }
        .chat-msg.user .chat-bubble {
            background: linear-gradient(135deg, #4f46e5, #7c3aed); color: white;
            border-bottom-right-radius: 4px;
        }
        .chat-avatar {
            width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
            display: flex; align-items: center; justify-content: center; font-size: .9rem;
            background: #eef2ff; color: #4f46e5;
        }
        .chat-msg.user .chat-avatar { background: #4f46e5; color: white; }
        .chat-typing { display: flex; gap: 4px; padding: 8px 0 4px; }
        .chat-typing span {
            width: 7px; height: 7px; border-radius: 50%; background: #94a3b8;
            animation: chatDot 1.2s infinite;
        }
        .chat-typing span:nth-child(2) { animation-delay: .2s; }
        .chat-typing span:nth-child(3) { animation-delay: .4s; }
        @keyframes chatDot { 0%,80%,100%{transform:scale(.6);opacity:.4} 40%{transform:scale(1);opacity:1} }

        /* Input */
        .chat-input-row {
            display: flex; gap: 8px; padding: 12px 14px;
            border-top: 1px solid #e2e8f0; background: #fff;
        }
        #chat-input {
            flex: 1; border: 1.5px solid #e2e8f0; border-radius: 12px;
            padding: 8px 12px; font-size: .85rem; outline: none; resize: none;
            font-family: inherit; line-height: 1.4; max-height: 100px; overflow-y: auto;
            transition: border-color .15s;
        }
        #chat-input:focus { border-color: #4f46e5; }
        #chat-send-btn {
            width: 38px; height: 38px; border-radius: 12px; border: none; cursor: pointer;
            background: linear-gradient(135deg, #4f46e5, #7c3aed); color: white;
            font-size: 1rem; display: flex; align-items: center; justify-content: center;
            flex-shrink: 0; transition: opacity .15s; align-self: flex-end;
        }
        #chat-send-btn:disabled { opacity: .4; cursor: default; }
        #chat-send-btn:not(:disabled):hover { opacity: .88; }

        /* ═══════════════════════════════════════════════════════
           RESPONSIVE — Mobile & Tablet
        ═══════════════════════════════════════════════════════ */

        /* Hamburger toggle button (hidden on desktop) */
        .hamburger-btn {
            display: none;
            background: none;
            border: none;
            cursor: pointer;
            padding: 4px;
            color: var(--text-primary);
        }
        .hamburger-btn svg { display: block; }

        /* Panel toggle fab & close btn (hidden on desktop) */
        .panel-toggle-fab { display: none; }
        .panel-close-btn {
            display: none;
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-secondary);
            padding: 4px;
            border-radius: 6px;
        }
        .panel-close-btn:hover { background: #f1f5f9; }

        /* Nav buttons wrapper for collapse */
        .header-nav-buttons {
            display: contents;
        }

        /* ── Tablet (≤1200px) ── */
        @media (max-width: 1200px) {
            .floating-header {
                padding: 12px 20px;
                gap: 12px;
            }
            .floating-header .stats { gap: 14px; }
            .view-toggle-btn {
                padding: 7px 12px;
                font-size: 0.75rem;
            }
            .floating-panel {
                width: 280px;
            }
            .parallel-body { padding: 20px; }
            .parallel-container { gap: 16px; }
            .workers-modal-body { padding: 16px 20px; }
            .workers-grid {
                grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
                gap: 14px;
            }
        }

        /* ── Mobile (≤768px) ── */
        @media (max-width: 768px) {
            /* Body scroll fix for dashboard */
            body.dashboard-open { overflow: hidden; }

            /* --- Floating Header --- */
            .floating-header {
                top: 0;
                left: 0;
                right: 0;
                width: 100%;
                border-radius: 0;
                padding: 10px 16px;
                gap: 10px;
                transform: none;
                flex-wrap: wrap;
                z-index: 1001;
            }
            .floating-header .logo-text { font-size: 1.1rem; }
            .floating-header .divider { display: none; }
            .floating-header .stats { display: none; }
            .floating-header .user-badge {
                padding: 6px 10px;
                font-size: 0.8rem;
            }
            .floating-header .user-badge .role {
                font-size: 0.65rem;
                padding: 1px 6px;
            }

            /* Hamburger visible on mobile */
            .hamburger-btn {
                display: flex;
                align-items: center;
                margin-left: auto;
            }

            /* Collapsible nav buttons */
            .header-nav-buttons {
                display: none;
                width: 100%;
                flex-direction: column;
                gap: 6px;
                padding-top: 8px;
                border-top: 1px solid var(--glass-border);
            }
            .header-nav-buttons .nav-divider {
                display: none;
            }
            .header-nav-buttons.open {
                display: flex;
            }
            .header-nav-buttons .view-toggle-btn {
                width: 100%;
                justify-content: center;
                padding: 10px 14px;
                font-size: 0.85rem;
                border-radius: 10px;
            }

            /* --- Floating Panel (countries) --- */
            .floating-panel {
                top: auto;
                bottom: 0;
                right: 0;
                left: 0;
                width: 100%;
                max-height: 55vh;
                border-radius: 24px 24px 0 0;
                transition: transform 0.3s ease;
            }
            .floating-panel.mobile-hidden {
                transform: translateY(100%);
                pointer-events: none;
            }
            .panel-close-btn {
                display: flex;
                align-items: center;
                justify-content: center;
            }
            /* Fab para reabrir el panel */
            .panel-toggle-fab {
                display: flex;
                align-items: center;
                justify-content: center;
                position: fixed;
                bottom: 16px;
                left: 16px;
                z-index: 100;
                width: 44px;
                height: 44px;
                border-radius: 50%;
                background: white;
                border: 1px solid #e2e8f0;
                box-shadow: 0 2px 12px rgba(0,0,0,0.12);
                cursor: pointer;
                color: var(--text-secondary);
                transition: opacity 0.2s;
            }
            .panel-toggle-fab.hidden { opacity: 0; pointer-events: none; }

            /* --- Region Stats (bottom bar) --- */
            .region-stats {
                display: none;
            }

            /* --- Map adjustments --- */
            #fullscreen-map { top: 56px; height: calc(100vh - 56px); }

            /* --- Dashboard View --- */
            .dashboard-view {
                padding-top: 0;
            }
            .dash-header-bar {
                padding: 10px 12px;
                gap: 10px;
                flex-wrap: wrap;
            }
            .dash-back-btn {
                padding: 6px 10px;
                font-size: 0.8rem;
            }
            .dash-header-name { font-size: 0.9rem; }
            .dash-header-date { display: none; }
            .dash-header-sep { display: none; }

            /* Dashboard tabs: horizontal scroll */
            .dash-tabs-nav {
                padding: 0 8px;
                gap: 0;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                scrollbar-width: none;
            }
            .dash-tabs-nav::-webkit-scrollbar { display: none; }
            .dash-tab {
                padding: 10px 14px;
                font-size: 0.8rem;
                flex-shrink: 0;
            }

            /* Dashboard grid: single column */
            .dashboard-grid {
                grid-template-columns: 1fr;
                padding: 12px;
                gap: 12px;
            }
            .span-2, .span-3, .span-4, .span-6, .span-8, .span-12 {
                grid-column: span 1;
            }
            .dashboard-section-title {
                grid-column: span 1;
            }

            /* KPI cards */
            .kpi-card { padding: 16px; }
            .kpi-card-new { padding: 16px; }

            /* Eco cards */
            .eco-cards-grid {
                grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
                gap: 10px;
            }
            .eco-header {
                padding: 12px 14px;
                flex-wrap: wrap;
                gap: 8px;
            }
            .eco-breadcrumb {
                flex-wrap: wrap;
                gap: 4px;
            }
            .eco-view-toggle { padding: 10px 14px 4px; }
            .eco-total-bar {
                flex-wrap: wrap;
                gap: 10px;
                font-size: 0.75rem;
            }

            /* Dashboard detail panel (slide-in) — fullscreen on mobile */
            .dashboard-detail-panel {
                width: 100%;
                right: -100%;
                top: 48px;
                height: calc(100% - 48px);
                z-index: 9999;
            }
            .dashboard-detail-header {
                padding: 14px 16px;
            }
            .dashboard-detail-header h3 {
                font-size: 0.95rem;
            }
            .dashboard-detail-close {
                width: 40px;
                height: 40px;
                font-size: 1.5rem;
                display: flex;
                align-items: center;
                justify-content: center;
                background: rgba(255,255,255,0.2);
            }

            /* --- Tables: horizontal scroll --- */
            .tabla-container,
            .empleados-table-wrapper {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
            }
            .empleados-table {
                min-width: 700px;
            }
            .empleados-table th,
            .empleados-table td {
                padding: 10px 12px;
                font-size: 0.8rem;
                white-space: nowrap;
            }
            .tabla-footer {
                padding: 10px 16px;
                font-size: 0.8rem;
                flex-wrap: wrap;
                gap: 8px;
            }

            /* --- Parallel View --- */
            .parallel-header {
                padding: 12px 16px;
                flex-wrap: wrap;
                gap: 10px;
            }
            .parallel-header h1 { font-size: 1rem; }
            .parallel-body {
                padding: 16px;
            }
            .parallel-container {
                flex-direction: column;
                min-width: unset;
                gap: 16px;
            }
            .society-column,
            .global-column {
                min-width: unset;
                width: 100%;
            }

            /* --- Org Page (Society organigrama) --- */
            .org-page-header {
                padding: 10px 12px;
                flex-wrap: wrap;
                gap: 8px;
            }
            .org-page-header .back-btn {
                padding: 6px 12px;
                font-size: 0.75rem;
                border-radius: 8px;
                order: 1;
            }
            .org-page-header .title {
                gap: 8px;
                order: 3;
                width: 100%;
                justify-content: center;
            }
            .org-page-header .flag { font-size: 1.3rem; }
            .org-page-header h2 { font-size: 0.95rem; }
            .org-page-header p { font-size: 0.7rem; display: none; }
            .org-page-header .stats {
                display: none;
            }
            .org-page-header .header-actions {
                gap: 6px;
                order: 2;
                margin-left: auto;
            }
            .org-page-header .admin-btn {
                padding: 6px 10px;
                font-size: 0.7rem;
                border-radius: 6px;
            }
            /* Admin panel: stack below org tree */
            .org-page-container {
                flex-direction: column;
            }
            .admin-panel {
                width: 100% !important;
                border-left: none;
                border-top: 1px solid #e2e8f0;
                max-height: 50vh;
            }
            .admin-panel.collapsed {
                max-height: 0;
                border: none;
            }
            .org-page-body {
                padding: 12px;
                min-height: 40vh;
            }
            .modal-search {
                max-width: 100%;
                padding: 10px 16px 10px 40px;
                background-size: 16px;
                background-position: 12px center;
                font-size: 0.85rem;
            }

            /* --- Canvas / Organigrama Editor View --- */
            .canvas-header {
                padding: 10px 12px;
                flex-wrap: wrap;
                gap: 8px;
            }
            .canvas-header .left { gap: 8px; }
            .canvas-header .back-btn {
                padding: 6px 12px;
                font-size: 0.8rem;
            }
            .canvas-header h1 { font-size: 0.9rem; }
            .canvas-header .tools { flex-wrap: wrap; gap: 4px; }
            .canvas-header .tool-btn {
                padding: 6px 10px;
                font-size: 0.75rem;
            }
            .canvas-body {
                flex-direction: column;
            }
            .canvas-sidebar {
                width: 100% !important;
                max-width: none;
                border-right: none;
                border-bottom: 1px solid #334155;
                max-height: 30vh;
            }

            /* --- Workers Modal --- */
            .workers-modal {
                width: 100%;
                max-width: 100%;
                height: 100vh;
                max-height: 100vh;
                border-radius: 0;
            }
            .workers-modal-header {
                padding: 16px;
                flex-wrap: wrap;
                gap: 10px;
            }
            .workers-modal-header h2 { font-size: 1rem; }
            .workers-modal-body { padding: 12px; }
            .workers-grid {
                grid-template-columns: 1fr;
                gap: 12px;
            }

            /* --- Employee Detail Modal --- */
            .employee-modal {
                width: 100% !important;
                max-width: 100% !important;
                height: 100vh;
                max-height: 100vh;
                border-radius: 0 !important;
            }

            /* --- Create Employee Modal --- */
            .create-employee-modal {
                width: 100% !important;
                max-width: 100% !important;
                height: 100vh;
                max-height: 100vh;
                border-radius: 0 !important;
            }

            /* --- Edit Modal --- */
            .modal-content.modal-editar {
                width: 100%;
                max-width: 100%;
                max-height: 100vh;
                border-radius: 0;
            }

            /* --- Select Responsable Modal --- */
            .select-responsable-modal {
                width: 100% !important;
                max-width: 100% !important;
                max-height: 90vh;
                border-radius: 12px 12px 0 0 !important;
            }

            /* --- Admin Panel --- */
            .admin-panel {
                width: 100% !important;
                max-width: 100% !important;
                height: 100vh;
                max-height: 100vh;
                border-radius: 0 !important;
            }

            /* --- Chat Panel --- */
            #chat-panel {
                width: 100%;
                max-width: 100%;
                bottom: 0;
                right: 0;
                left: 0;
                border-radius: 20px 20px 0 0;
                max-height: 85vh;
            }
            #chat-messages {
                max-height: 50vh;
            }
            #chat-fab {
                bottom: 16px;
                right: 16px;
                width: 50px;
                height: 50px;
            }

            /* --- Login --- */
            .login-card {
                width: calc(100% - 32px);
                padding: 32px 24px;
            }

            /* --- Headcount table pivot --- */
            .headcount-pivot-wrapper {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
            }

            /* --- Tabla Empleados header/filters --- */
            .tabla-header {
                padding: 12px 16px;
                flex-wrap: wrap;
                gap: 10px;
            }
            .tabla-header h1 {
                font-size: 1rem;
                width: 100%;
            }
            .tabla-filters {
                flex-wrap: wrap;
                gap: 8px;
                width: 100%;
            }
            .tabla-search {
                width: 100%;
            }
            .tabla-select {
                flex: 1;
                min-width: 120px;
            }
            .tabla-filters .tool-btn {
                flex: 1;
                min-width: 100px;
                font-size: 0.8rem;
                padding: 8px 12px;
                text-align: center;
                justify-content: center;
            }
            .tabla-container {
                padding: 12px;
            }

            /* --- Chart containers --- */
            .chart-body,
            .chart-body-tall {
                height: 200px !important;
            }

            /* --- Headcount historic table --- */
            .headcount-table-wrapper {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
            }
        }

        /* ── Small phones (≤480px) ── */
        @media (max-width: 480px) {
            .floating-header {
                padding: 8px 12px;
            }
            .floating-header .logo-text { font-size: 1rem; }
            .eco-cards-grid {
                grid-template-columns: 1fr 1fr;
            }
            .eco-card { padding: 12px; }
            .eco-card-hc-val { font-size: 1.3rem; }
            .kpi-card { padding: 14px; }
            .dash-tab { padding: 8px 10px; font-size: 0.75rem; }
            .workers-grid {
                grid-template-columns: 1fr;
            }
            .chat-bubble {
                max-width: 92%;
                font-size: 0.82rem;
            }
        }
