/* ================================================================
   style.css — Sistema de Gestión de Ventas Jahnissi / Mi Fibra
   Mobile-First | CSS Grid/Flexbox | Sin frameworks externos
   ================================================================ */

/* ── Google Fonts: Inter ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ================================================================
   DESIGN TOKENS (Variables CSS)
   Centraliza todos los valores de diseño del sistema.
   ================================================================ */
:root {
    /* Paleta Primaria: Azul Corporativo */
    --color-primary:        #1a56db;
    --color-primary-dark:   #1e429f;
    --color-primary-darker: #1a3a8a;
    --color-primary-light:  #ebf5ff;
    --color-primary-200:    #bfdbfe;

    /* Peligro/Error: Carmesí (uso estrictamente restringido) */
    --color-danger:         #c81e1e;
    --color-danger-dark:    #9b1c1c;
    --color-danger-light:   #fde8e8;

    /* Estados */
    --color-success:        #057a55;
    --color-success-light:  #def7ec;
    --color-warning:        #c27803;
    --color-warning-light:  #fdf6b2;
    --color-info:           #1c64f2;
    --color-info-light:     #e1effe;

    /* Fondos y superficies */
    --color-bg:             #f4f6f9;
    --color-surface:        #ffffff;
    --color-surface-2:      #f9fafb;
    --color-border:         #e5e7eb;
    --color-border-focus:   #1a56db;

    /* Tipografía */
    --color-text:           #111827;
    --color-text-secondary: #374151;
    --color-text-muted:     #6b7280;
    --color-text-light:     #9ca3af;

    /* Sidebar */
    --sidebar-bg:           #1a2e62;
    --sidebar-bg-hover:     #243577;
    --sidebar-bg-active:    #1a56db;
    --sidebar-width:        225px;
    --sidebar-text:         #c7d2fe;
    --sidebar-text-active:  #ffffff;

    /* Espaciado Optimizado (Densidad Ejecutiva) */
    --space-1:  3px;
    --space-2:  6px;
    --space-3:  10px;
    --space-4:  14px;
    --space-5:  18px;
    --space-6:  22px;
    --space-8:  28px;
    --space-10: 36px;
    --space-12: 44px;

    /* Tipografía Compacta */
    --font-family:    'Inter', system-ui, -apple-system, sans-serif;
    --font-size-xs:   0.72rem;   /* ~11.5px */
    --font-size-sm:   0.8125rem; /* 13px */
    --font-size-base: 0.875rem;  /* 14px */
    --font-size-lg:   1.05rem;   /* ~16.8px */
    --font-size-xl:   1.18rem;   /* ~19px */
    --font-size-2xl:  1.35rem;   /* ~21.6px */
    --font-size-3xl:  1.65rem;   /* ~26.4px */

    /* Bordes y sombras */
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --radius-xl:  20px;
    --radius-full: 9999px;

    --shadow-xs:  0 1px 2px  rgba(0,0,0,0.05);
    --shadow-sm:  0 1px 4px  rgba(0,0,0,0.08);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:  0 10px 30px rgba(0,0,0,0.10);
    --shadow-xl:  0 20px 60px rgba(0,0,0,0.15);

    /* Transiciones */
    --transition-fast:   all 0.15s ease;
    --transition-base:   all 0.25s ease;
    --transition-slow:   all 0.4s ease;

    /* Topbar (móvil) */
    --topbar-height: 60px;
}

/* ================================================================
   RESET Y BASE
   ================================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size:   var(--font-size-base);
    color:       var(--color-text);
    background:  var(--color-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

/* ================================================================
   LAYOUT PRINCIPAL: Sidebar + Main
   ================================================================ */
.app-body {
    background: var(--color-bg);
    min-height: 100vh;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition-base);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity var(--transition-base);
}

/* Branding */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-5);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.brand-logo svg {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    color: #fff;
    font-size: var(--font-size-lg);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.brand-sub {
    color: var(--sidebar-text);
    font-size: var(--font-size-xs);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Usuario en sidebar (Movido al footer) */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(255,255,255,0.05);
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.user-info .badge {
    align-self: flex-start;
    margin-top: 2px;
    font-size: 10px;
    padding: 2px 6px;
    opacity: 0.9;
}

/* Navegación */
.sidebar-nav {
    flex: 1;
    padding: 10px;
    margin-top: 4px;
}

.sidebar-nav ul {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Nav Headers para agrupar ítems (Ex MÓDULO FINANCIERO) */
.nav-header {
    margin: 22px 0 8px 12px;
    font-size: 11px;
    font-weight: 700;
    color: var(--sidebar-text);
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    user-select: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}

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

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    text-decoration: none;
}

.nav-link:hover svg { 
    opacity: 1; 
    transform: translateX(4px); 
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-weight: 600;
    border-left: 3px solid #60a5fa;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.nav-link.active svg { 
    opacity: 1; 
    color: #60a5fa;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: rgba(0,0,0,0.15);
    border-top: 1px solid rgba(255,255,255,0.05);
}

.logout-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-text);
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.logout-link svg {
    width: 18px;
    height: 18px;
}

.logout-link:hover {
    background: var(--color-danger);
    color: #fff;
    transform: scale(1.05);
}

/* ================================================================
   CONTENIDO PRINCIPAL
   ================================================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* TOPBAR (solo visible en móvil) */
.topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-height);
    background: var(--sidebar-bg);
    align-items: center;
    padding: 0 var(--space-4);
    gap: var(--space-3);
    box-shadow: var(--shadow-md);
}

.topbar-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
}

.topbar-toggle span {
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    display: block;
    transition: var(--transition-base);
}

.topbar-title {
    color: #fff;
    font-size: var(--font-size-base);
    font-weight: 600;
}

/* Área de contenido de la página */
.page-content {
    flex: 1;
    padding: 16px 20px;
}

/* ================================================================
   TIPOGRAFÍA DE PÁGINAS
   ================================================================ */
.page-title {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin-top: 2px;
}

.page-header, .dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-2);
}

.card-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 14px 16px;
}

.mt-4 { margin-top: 16px; }

/* ================================================================
   STATS CARDS (Dashboard)
   ================================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

@media (min-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.stat-card {

    background: #ffffff;
    border-radius: var(--radius-lg);
    border: none;
    border-left: 4px solid var(--stat-color, var(--color-primary));
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
    transition: var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--stat-bg, var(--color-primary-light));
    color: var(--stat-color, var(--color-primary));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
}

.stat-card .stat-icon svg {
    width: 22px;
    height: 22px;
}

.stat-number {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
    font-weight: 500;
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    min-height: 120px;
}

@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ================================================================
   BOTONES
   ================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    border: 2px solid transparent;
    transition: var(--transition-fast);
    white-space: nowrap;
    user-select: none;
    line-height: 1.4;
    text-decoration: none;
}

.btn:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

/* Primario: azul corporativo */
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(26,86,219,0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    box-shadow: 0 4px 16px rgba(26,86,219,0.4);
    transform: translateY(-1px);
    text-decoration: none;
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(26,86,219,0.3);
}

/* Peligro: carmesí (solo para acciones destructivas) */
.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-danger-dark);
    border-color: var(--color-danger-dark);
}

/* Advertencia / Subsanación: ámbar cálido */
.btn-warning {
    background: #d97706;
    color: #ffffff;
    border-color: #d97706;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
}

.btn-warning:hover:not(:disabled) {
    background: #b45309;
    border-color: #b45309;
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.4);
    transform: translateY(-1px);
    color: #ffffff;
    text-decoration: none;
}

.btn-warning:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
}

/* Éxito / Excel: verde hoja de cálculo */
.btn-excel, .btn-success {
    background: #057a55;
    color: #ffffff;
    border-color: #057a55;
    box-shadow: 0 2px 8px rgba(5, 122, 85, 0.3);
}

.btn-excel:hover:not(:disabled), .btn-success:hover:not(:disabled) {
    background: #046c4e;
    border-color: #046c4e;
    box-shadow: 0 4px 16px rgba(5, 122, 85, 0.4);
    transform: translateY(-1px);
    color: #ffffff;
    text-decoration: none;
}

.btn-excel:active:not(:disabled), .btn-success:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(5, 122, 85, 0.3);
}

/* Outline */
.btn-outline {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-surface-2);
    border-color: var(--color-text-muted);
    text-decoration: none;
}

/* Secundario: gris */
.btn-secondary {
    background: #e2e8f0;
    color: #475569;
    border-color: #e2e8f0;
}
.btn-secondary:hover:not(:disabled) {
    background: #cbd5e1;
    color: #334155;
}

/* Outline Primary */
.btn-outline-primary {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-outline-primary:hover:not(:disabled) {
    background: var(--color-primary);
    color: #fff;
}

/* Tamaños */
.btn-xs  { padding: 3px 8px; font-size: 11px; border-radius: var(--radius-sm); font-weight: 600; gap: 3px; line-height: 1.3; }
.btn-sm  { padding: var(--space-2) var(--space-3); font-size: var(--font-size-xs); }
.btn-lg  { padding: var(--space-4) var(--space-6); font-size: var(--font-size-base); }
.btn-full { width: 100%; }

/* Estado deshabilitado/cargando */
.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ================================================================
   FORMULARIOS
   ================================================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.form-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
}

.form-label-required::after {
    content: ' *';
    color: var(--color-danger);
}

.form-section-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-4);
    margin-top: var(--space-2);
}

/* Inputs */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: var(--space-4);
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
    flex-shrink: 0;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

/* Input con ícono: desplaza el texto */
.input-wrapper .form-input {
    padding-left: calc(var(--space-4) * 2 + 18px);
}

.form-input::placeholder { color: var(--color-text-light); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}

.form-input.is-invalid,
.form-select.is-invalid {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(200,30,30,0.1);
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: var(--space-8);
}

.form-select-sm {
    padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
    font-size: var(--font-size-xs);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: -4px;
}

.toggle-password {
    position: absolute;
    right: var(--space-4);
    background: none;
    border: none;
    color: var(--color-text-muted);
    padding: 0;
    display: flex;
    align-items: center;
}

.toggle-password svg { width: 18px; height: 18px; }
.toggle-password:hover { color: var(--color-primary); }

/* Zone de carga de archivos */
.file-upload-zone {
    position: relative;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-2);
    transition: var(--transition-base);
    overflow: hidden;
    cursor: pointer;
    min-height: 100px;
}

.file-upload-zone:hover,
.file-upload-zone.drag-over {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.file-upload-zone.has-file {
    border-color: var(--color-success);
    background: var(--color-success-light);
    border-style: solid;
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.file-upload-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-5);
    color: var(--color-text-muted);
    pointer-events: none;
    text-align: center;
}

.file-upload-ui svg { color: var(--color-primary); opacity: 0.6; }
.file-upload-text { font-size: var(--font-size-sm); color: var(--color-text-secondary); }
.file-upload-hint { font-size: var(--font-size-xs); color: var(--color-text-muted); }

.file-preview {
    display: none;
    padding: var(--space-3) var(--space-4);
    background: rgba(255,255,255,0.7);
    border-top: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
    color: var(--color-success);
    font-weight: 500;
    gap: var(--space-2);
    align-items: center;
    pointer-events: none;
}

.file-upload-zone.has-file .file-preview { display: flex; }
.file-upload-zone.has-file .file-upload-ui { opacity: 0.4; }

/* Acciones del formulario */
.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-3);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-4);
    flex-wrap: wrap;
}

/* ================================================================
   SPINNER DE CARGA
   ================================================================ */
.spinner-ring {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-ring.dark {
    border-color: rgba(26,86,219,0.2);
    border-top-color: var(--color-primary);
}

/* Spinner visible en botones outline (que tienen fondo claro/transparente) */
.btn-outline-primary .spinner-ring,
.btn-secondary .spinner-ring {
    border-color: rgba(26,86,219,0.2);
    border-top-color: var(--color-primary);
}
.btn-outline-primary:hover:not(:disabled) .spinner-ring {
    border-color: rgba(255,255,255,0.3);
    border-top-color: #fff;
}

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

.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-8);
}

.spinner-container .spinner-ring.dark { width: 28px; height: 28px; border-width: 3px; }

/* ================================================================
   TABLA & CONTENEDORES RESPONSIVE
   ================================================================ */
.table-responsive,
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    display: block;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
}

.table-responsive::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar {
    height: 9px;
}

.table-responsive::-webkit-scrollbar-track,
.table-wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 6px;
}

.table-responsive::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 6px;
    border: 2px solid #f1f5f9;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.table-backoffice {
    min-width: 800px;
    width: 100%;
}
.table-backoffice td, .table-backoffice th {
    white-space: normal !important;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
    white-space: nowrap;
}

.table th {
    padding: 8px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: var(--color-surface-2);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

.table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    vertical-align: middle;
}

.table tr:hover td { background: rgba(241, 245, 249, 0.6); }
.table tr:last-child td { border-bottom: none; }

.table-empty {
    text-align: center;
    color: var(--color-text-muted);
    font-style: italic;
    padding: var(--space-6) !important;
}

/* ================================================================
   BADGES (Estados y Roles)
   ================================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-borrador           { background: var(--color-surface-2);     color: var(--color-text-muted); border: 1px solid var(--color-border); }
.badge-pendiente_cliente  { background: var(--color-warning-light); color: var(--color-warning); }
.badge-revision           { background: var(--color-info-light);    color: var(--color-info);    }
.badge-rechazada_interna  { background: var(--color-danger-light);  color: var(--color-danger-dark); border: 1px solid rgba(200, 30, 30, 0.2); }
.badge-enviada_a_mi_fibra { background: #f3e8ff;                   color: #7e22ce; border: 1px solid rgba(126, 34, 206, 0.2); }
.badge-rechazada_operador { background: var(--color-danger-light);  color: var(--color-danger-dark); border: 1px solid rgba(200, 30, 30, 0.2); }
.badge-instalada          { background: var(--color-primary-light); color: var(--color-primary-dark); border: 1px solid rgba(26, 86, 219, 0.2); }
.badge-completado         { background: var(--color-success-light); color: var(--color-success); border: 1px solid rgba(5, 122, 85, 0.2); }
.badge-admin            { background: var(--color-primary-light); color: var(--color-primary); }
.badge-supervisor       { background: #fef3c7; color: #b45309; border: 1px solid rgba(180, 83, 9, 0.25); font-weight: 700; }
.badge-vendedor         { background: var(--color-surface-2);     color: var(--color-text-muted); border: 1px solid var(--color-border); }
.badge-activo           { background: var(--color-success-light); color: var(--color-success); }
.badge-inactivo         { background: var(--color-danger-light);  color: var(--color-danger);  }
.badge-info             { background: var(--color-info-light);    color: var(--color-info);    }
.badge-alta_nueva       { background: var(--color-primary-light); color: var(--color-primary); }
.badge-porta            { background: var(--color-warning-light); color: var(--color-warning); }

/* Indicadores de rendimiento de supervisor */
.conversion-bar-container {
    width: 100%;
    min-width: 100px;
    height: 8px;
    background: var(--color-surface-2);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 4px;
    border: 1px solid var(--color-border);
}

.conversion-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-initials {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 700;
    font-size: var(--font-size-xs);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ================================================================
   ALERTAS
   ================================================================ */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: var(--space-4);
    border-left: 4px solid transparent;
}

.alert-danger  { background: var(--color-danger-light);  color: var(--color-danger-dark); border-color: var(--color-danger); }
.alert-success { background: var(--color-success-light); color: var(--color-success);     border-color: var(--color-success); }
.alert-warning { background: var(--color-warning-light); color: var(--color-warning);     border-color: var(--color-warning); }

/* ================================================================
   MAPA INTERACTIVO (Leaflet)
   ================================================================ */
.map-panel {
    display: flex;
    flex-direction: column;
}

.map-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border);
}

.coords-display {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    background: var(--color-surface);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    font-family: 'Courier New', monospace;
}

.coords-label { color: var(--color-primary); font-weight: 700; }

#map, .map-container, #portalMap, .portal-map {
    height: 380px;
    min-height: 360px;
    width: 100%;
    z-index: 1;
    background: #e2e8f0;
    position: relative;
}

.map-hint {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    background: var(--color-surface-2);
    border-top: 1px solid var(--color-border);
}

/* ================================================================
   LAYOUT DE 2 COLUMNAS: FORMULARIO DE VENTA
   Mobile-first: 1 columna por defecto, 2 columnas en desktop
   ================================================================ */
.venta-form-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-5);
    align-items: start;
}

/* Formulario dentro del panel */
.venta-form {
    padding: var(--space-5);
}

.form-panel {
    overflow: visible;
}

/* ================================================================
   MODAL
   ================================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    animation: fadeIn 0.2s ease;
}

.modal-container {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.25s ease;
}

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

.modal-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.modal-close:hover { background: var(--color-danger-light); color: var(--color-danger); }

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-2);
}

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

/* ================================================================
   LINKS DE DOCUMENTOS EN TABLA
   ================================================================ */
.doc-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    background: var(--color-primary-light);
    color: var(--color-primary);
    transition: var(--transition-fast);
}

.doc-link:hover {
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
}

.docs-cell { display: flex; flex-wrap: wrap; gap: var(--space-1); }

/* ================================================================
   SELECT DE ESTADO (tabla ventas)
   ================================================================ */
.estado-select {
    padding: 4px 28px 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    font-size: var(--font-size-xs);
    font-weight: 600;
    background-color: var(--color-surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 12px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: var(--transition-fast);
}

.estado-select:focus { outline: none; border-color: var(--color-primary); }

/* Acciones en tabla */
.table-actions { display: flex; gap: var(--space-2); align-items: center; }

/* ================================================================
   PÁGINA DE LOGIN
   ================================================================ */
.login-body {
    background: linear-gradient(135deg, #0f1d5c 0%, #1a56db 50%, #0e3a9e 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
}

/* Círculos decorativos de fondo */
.login-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.login-bg-circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    animation: float 8s ease-in-out infinite;
}

.login-bg-circle--1 { width: 500px; height: 500px; top: -150px; right: -100px; animation-delay: 0s; }
.login-bg-circle--2 { width: 300px; height: 300px; bottom: -50px; left: -80px; animation-delay: -3s; }
.login-bg-circle--3 { width: 200px; height: 200px; top: 50%;   left: 30%;  animation-delay: -6s; }

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50%       { transform: translateY(-20px) scale(1.03); }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
}

/* Brand en login */
.login-brand {
    text-align: center;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto var(--space-4);
    filter: drop-shadow(0 8px 24px rgba(0,0,0,0.3));
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 8px 24px rgba(0,0,0,0.3)); }
    50%       { filter: drop-shadow(0 8px 36px rgba(26,86,219,0.6)); }
}

.login-brand-name {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
}

.login-brand-sub {
    font-size: var(--font-size-sm);
    color: rgba(255,255,255,0.65);
    margin-top: var(--space-1);
}

/* Card de login (glassmorphism) */
.login-card {
    width: 100%;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: 0 25px 60px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.2);
    animation: slideUp 0.4s ease;
}

.login-card-header {
    margin-bottom: var(--space-6);
}

.login-card-header h2 {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.login-card-header p {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin-top: var(--space-1);
}

.login-form .form-group { margin-bottom: var(--space-4); }
.login-form .btn-primary { margin-top: var(--space-2); }

.login-footer-text {
    color: rgba(255,255,255,0.5);
    font-size: var(--font-size-xs);
    text-align: center;
}

/* ================================================================
   RESPONSIVE: Tablet (≥ 640px)
   ================================================================ */
@media (min-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ================================================================
   RESPONSIVE: Desktop (≥ 1024px)
   ================================================================ */
@media (min-width: 1024px) {
    /* Sidebar fijo en desktop */
    .sidebar {
        transform: none !important;
    }

    /* Main siempre desplazado por el sidebar */
    .main-content {
        margin-left: var(--sidebar-width);
        transition: margin-left 0.3s ease;
    }
    
    .sidebar {
        transition: width 0.3s ease;
    }

    /* Colapsado */
    html.sidebar-collapsed .sidebar {
        width: 80px;
    }
    html.sidebar-collapsed .main-content {
        margin-left: 80px;
    }
    html.sidebar-collapsed .brand-text,
    html.sidebar-collapsed .sidebar-title,
    html.sidebar-collapsed .nav-text,
    html.sidebar-collapsed .user-info {
        display: none;
    }
    html.sidebar-collapsed .sidebar-nav ul li a {
        justify-content: center;
        padding: 12px 0;
        font-size: 0;
    }
    html.sidebar-collapsed .nav-header {
        display: none;
    }
    html.sidebar-collapsed .sidebar-nav ul li a i,
    html.sidebar-collapsed .sidebar-nav ul li a svg {
        margin-right: 0;
    }
    html.sidebar-collapsed .sidebar-brand {
        padding: var(--space-5) 0;
        justify-content: center;
        flex-direction: column;
        gap: 12px;
    }
    html.sidebar-collapsed #desktopSidebarToggle {
        margin: 0 !important;
    }
    html.sidebar-collapsed .sidebar-footer {
        justify-content: center;
    }
    html.sidebar-collapsed .user-avatar {
        margin: 0;
    }
    html.sidebar-collapsed #desktopSidebarToggle svg {
        transform: rotate(180deg);
    }
    
    .topbar { display: none; }

    /* Stats: 5 columnas en desktop */
    .stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    /* ── LAYOUT CLAVE: 2 columnas para el formulario de venta ──
       Mapa (izquierda, fijo) | Formulario (derecha, scrollable)
       ──────────────────────────────────────────────────────── */
    .venta-form-layout {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-6);
        align-items: start;
    }

    /* En desktop el mapa se hace más alto */
    #map.map-container {
        height: 480px;
    }

    /* Formulario de venta pegajoso en desktop */
    .form-panel {
        position: sticky;
        top: var(--space-5);
        max-height: calc(100vh - 80px);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--color-border) transparent;
    }
}

/* ================================================================
   RESPONSIVE: Mobile (≤ 1023px)
   ================================================================ */
@media (max-width: 1023px) {
    /* Sidebar oculto fuera de pantalla */
    .sidebar {
        transform: translateX(-100%);
    }

    /* Mostrar topbar en móvil */
    .topbar {
        display: flex;
    }

    .main-content {
        margin-left: 0;
    }

    .page-content {
        padding: var(--space-4);
    }

    /* Sidebar visible cuando está abierto */
    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-overlay.is-visible {
        display: block;
        opacity: 1;
    }

    /* Login */
    .login-card {
        padding: var(--space-6);
    }

    /* Dashboard header apilado */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Modal ocupa más espacio en móvil */
    .modal-container {
        max-width: 100%;
        margin: 0 var(--space-2);
    }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; justify-content: center; }
    .login-card { padding: var(--space-5); }
}

/* ================================================================
   UTILIDADES
   ================================================================ */
.text-center { text-align: center; }
.text-muted  { color: var(--color-text-muted); }
.font-mono   { font-family: 'Courier New', monospace; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ================================================================
   MÓDULO DE COBERTURA (HÍBRIDO PWA: BOTTOM SHEET / SLIDE-OVER)
   ================================================================ */

/* Banner de Cobertura en Formulario de Venta */
.coverage-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: linear-gradient(135deg, #ebf5ff 0%, #e1effe 100%);
    border: 1px solid var(--color-primary-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-5);
}

.coverage-banner-content {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.coverage-banner-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(26, 86, 219, 0.25);
}

.coverage-banner-text strong {
    color: var(--color-primary-darker);
    font-size: var(--font-size-sm);
    display: block;
}

.coverage-banner-text p {
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    margin: 0;
}

/* Modal Overlay Base */
.coverage-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: flex-end; /* Móvil: Bottom Sheet desde abajo */
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.coverage-modal-overlay.is-visible {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

/* Modal Container Base (Bottom Sheet para Móvil) */
.coverage-modal-container {
    background: var(--color-surface);
    width: 100%;
    height: 94vh; /* Ocupa el 94% de la pantalla en celular */
    max-height: 94vh;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.coverage-modal-overlay.is-visible .coverage-modal-container {
    transform: translateY(0);
}

/* Handle táctil para celular */
.coverage-drag-handle {
    width: 44px;
    height: 5px;
    background: #cbd5e1;
    border-radius: var(--radius-full);
    margin: 8px auto 4px auto;
    flex-shrink: 0;
    cursor: grab;
    transition: background 0.2s ease;
}

.table tbody tr {
    transition: background-color 0.2s ease;
}
.table-hover tbody tr:hover {
    background-color: #f8fafc; /* color-bg-hover */
}

.coverage-drag-handle:active {
    cursor: grabbing;
    background: #94a3b8;
}

/* Header del Visor */
.coverage-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 10px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    flex-shrink: 0;
    gap: var(--space-3);
}

.coverage-modal-title-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-primary);
}

.coverage-modal-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
    line-height: 1.2;
}

.coverage-modal-subtitle {
    font-size: 11px;
    color: var(--color-text-muted);
    margin: 2px 0 0 0;
}

.coverage-modal-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-external {
    font-size: var(--font-size-xs);
    padding: 4px 10px;
    color: var(--color-primary);
    border-color: var(--color-primary-200);
    background: var(--color-primary-light);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
}

.btn-external:hover {
    background: var(--color-primary);
    color: #fff;
}

.coverage-modal-close {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.coverage-modal-close:hover {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border-color: var(--color-danger-light);
}

/* Body & Iframe */
.coverage-modal-body {
    flex: 1;
    position: relative;
    background: #f8fafc;
    overflow: hidden;
    touch-action: pan-x pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
}

.coverage-loading-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    background: var(--color-surface);
    z-index: 2;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    transition: opacity var(--transition-fast);
}

.coverage-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: #ffffff;
    touch-action: pan-x pan-y pinch-zoom;
}

.coverage-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-2);
    flex-shrink: 0;
    gap: 10px;
}

.coverage-footer-tip {
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.2;
}

.coverage-fallback-banner {
    position: absolute;
    bottom: var(--space-4);
    left: var(--space-4);
    right: var(--space-4);
    background: #ffffff;
    border: 1px solid var(--color-primary-200);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    z-index: 10;
}

.coverage-fallback-banner p {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

/* ================================================================
   TRANSFORMACIÓN EN PC / DESKTOP (Slide-Over Panel)
   ================================================================ */
@media (min-width: 1024px) {
    .coverage-modal-overlay {
        align-items: stretch;
        justify-content: flex-end; /* Entra desde la derecha */
    }

    .coverage-modal-container {
        width: min(650px, 90vw); /* Ancho lateral optimizado en PC */
        height: 100vh;
        max-height: 100vh;
        border-radius: 20px 0 0 20px;
        transform: translateX(100%);
    }

    .coverage-modal-overlay.is-visible .coverage-modal-container {
        transform: translateX(0);
    }

    .coverage-drag-handle {
        display: none; /* Ocultar handle de móvil en PC */
    }
}

@media (max-width: 640px) {
    .coverage-banner {
        flex-direction: column;
        align-items: stretch;
    }
    .coverage-banner-content {
        margin-bottom: var(--space-2);
    }
    .coverage-banner .btn {
        width: 100%;
    }
}

/* ================================================================
   PANEL DATOS DEL CLIENTE — Flujo Híbrido
   ================================================================ */
.client-panel {
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    border: 1.5px solid var(--color-border);
    transition: border-color 0.2s;
}

.client-panel-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.client-panel-icon {
    width: 44px;
    height: 44px;
    background: var(--color-primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    flex-shrink: 0;
}

.client-panel-header strong {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    display: block;
}

.client-panel-header p {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin: 0;
}

.client-panel-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

@media (max-width: 640px) {
    .client-panel-fields {
        grid-template-columns: 1fr;
    }
}

/* ── Selector de Modo (Tarjetas Radio) ────────────────────────── */
.flow-mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

@media (max-width: 640px) {
    .flow-mode-selector {
        grid-template-columns: 1fr;
    }
}

.flow-mode-option {
    position: relative;
    cursor: pointer;
}

.flow-mode-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.flow-mode-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    background: var(--color-surface-2);
}

.flow-mode-option:hover label,
.flow-mode-option.selected label {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.flow-mode-option input[type="radio"]:checked + label {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.flow-mode-icon {
    font-size: 1.75rem;
    line-height: 1;
}

.flow-mode-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.flow-mode-desc {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* ── Panel de Link Generado ───────────────────────────────────── */
.link-result-panel {
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fd 100%);
    border: 1.5px solid var(--color-primary-200);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    animation: slideDownFade 0.3s ease;
}

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

.link-result-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    color: var(--color-primary-dark);
}

.link-result-header strong {
    font-size: 0.875rem;
    font-weight: 600;
}

.link-input-group {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    flex-wrap: wrap;
}

.link-input-group .form-input {
    flex: 1;
    min-width: 0;
    font-size: 0.8125rem;
    background: #fff;
    color: var(--color-text-secondary);
    cursor: text;
}

.link-result-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin: 0;
}

.btn-delete-user { background: var(--color-danger); color: white; border: none; }
.btn-delete-user:hover { background: #b91c1c; }

/* ================================================================
   RESPONSIVO PARA KANBAN
   ================================================================ */
@media (max-width: 1023px) {
    .kanban-page {
        display: none !important;
    }
    .mobile-kanban-warning {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        min-height: 50vh;
        padding: 40px 20px;
        background: var(--color-surface);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-sm);
        margin-top: 20px;
    }
    .mobile-kanban-warning .warning-icon {
        width: 64px;
        height: 64px;
        color: var(--color-warning);
        margin-bottom: 20px;
    }
}

.btn-success {
    background: var(--color-success);
    color: #fff;
    border: none;
}

.btn-success:hover {
    background: #046c4e;
}

/* ── Acciones del Panel ───────────────────────────────────────── */
.client-panel-actions #generateLinkContainer {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* ================================================================
   PORTAL CLIENTE — Página pública (sin sidebar)
   ================================================================ */
.portal-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1a56db 100%);
    min-height: 100vh;
}

.portal-wrapper {
    max-width: 680px;
    margin: 0 auto;
    padding: var(--space-4) var(--space-3) var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* ── Header del Portal ─────────────────────────────────────────── */
.portal-header {
    padding-top: var(--space-2);
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.portal-brand-name {
    display: block;
    font-size: 1.125rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}

.portal-brand-sub {
    display: block;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
}

/* ── Bienvenida ─────────────────────────────────────────────────── */
.portal-welcome {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-5);
    border: none;
    background: rgba(255,255,255,0.97);
}

.portal-welcome-icon {
    font-size: 2.25rem;
    line-height: 1;
    flex-shrink: 0;
}

.portal-welcome-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 var(--space-1);
}

.portal-welcome-msg {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0 0 var(--space-2);
    line-height: 1.6;
}

.portal-tipo-badge {
    margin-top: var(--space-2);
}

/* ── Secciones del formulario del portal ──────────────────────── */
.portal-section {
    background: rgba(255,255,255,0.97);
    border: none;
}

.portal-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* ── Botón de Envío ─────────────────────────────────────────────── */
.portal-submit-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

.portal-submit-btn {
    width: 100%;
    max-width: 400px;
    justify-content: center;
    font-size: 1rem;
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-xl);
    background-color: #ffffff !important;
    color: var(--color-primary) !important;
    font-weight: 700;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.portal-submit-btn:hover {
    background-color: #f8fafc !important;
    transform: translateY(-2px);
}

.portal-submit-note {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.75);
    margin: 0;
    text-align: center;
}

/* ── Footer del portal ─────────────────────────────────────────── */
.portal-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    color: rgba(255,255,255,0.6);
    font-size: 0.75rem;
    padding-bottom: var(--space-4);
}

/* ── Estados: Éxito, Error, Usado ──────────────────────────────── */
.portal-success-wrapper,
.portal-error-wrapper,
.portal-used-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.portal-success-card,
.portal-error-card {
    max-width: 480px;
    width: 100%;
    text-align: center;
    padding: var(--space-8) var(--space-6);
    background: rgba(255,255,255,0.97);
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.portal-success-icon {
    color: var(--color-success);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-success-light);
    width: 100px;
    height: 100px;
    border-radius: 50%;
}

.portal-error-icon {
    color: var(--color-danger);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-danger-light);
    width: 88px;
    height: 88px;
    border-radius: 50%;
}

.portal-success-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-success);
    margin: 0;
}

.portal-success-msg {
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin: 0;
}

.portal-brand-footer {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* ── Badges adicionales ─────────────────────────────────────────── */
.badge-alta_nueva {
    background: #dbeafe;
    color: #1e40af;
}

.badge-porta {
    background: #fef3c7;
    color: #92400e;
}

/* Margin bottom helper */
.mb-3 {
    margin-bottom: var(--space-3);
}

/* ================================================================
   KPI CARDS — Panel Supervisor
   ================================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

@media (min-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.kpi-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: none;
    padding: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    position: relative;
    overflow: hidden;
    transition: var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-card--alert {
    background: #fef2f2;
}

.kpi-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.kpi-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.kpi-subtext {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Conversion progress bar */
.conversion-bar-container {
    width: 100%;
    max-width: 120px;
    height: 6px;
    background: var(--color-border);
    border-radius: 999px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.conversion-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
}

/* Supervisor analytics table */
.supervisor-table th {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    font-weight: 600;
}

/* Avatar initials badge */
.avatar-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: var(--font-size-sm);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Supervisor badge */
.badge-supervisor {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: inline-block;
}

.badge-jefe-ventas {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: inline-block;
}

.badge-backoffice {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: inline-block;
}

.badge-vendedor {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: inline-block;
}

/* ================================================================
   CRM KANBAN BOARD STYLES
   ================================================================ */
.kanban-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    position: relative;
}

.kanban-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    background: var(--color-surface);
    padding: 18px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.page-main-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text);
    margin: 0;
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin: 4px 0 0 0;
}

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

.kanban-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.kanban-search-box .search-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.kanban-search-box input {
    padding: 8px 32px 8px 36px;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    background: var(--color-surface-2);
    font-size: 0.875rem;
    min-width: 240px;
    outline: none;
    transition: var(--transition-fast);
}

.kanban-search-box input:focus {
    border-color: var(--color-primary);
    background: #fff;
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.btn-clear-search {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

/* Stats Pill Bar */
.kanban-stats-bar {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 8px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
}

.stat-pill .stat-label {
    color: var(--color-text-muted);
    font-weight: 500;
}

.stat-pill .stat-val {
    font-weight: 800;
    color: var(--color-text);
    background: var(--color-surface-2);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-nuevo      { background: #64748b; }
.dot-interesado { background: #3b82f6; }
.dot-escalado   { background: #f59e0b; }
.dot-instalado  { background: #10b981; }
.dot-cerrado    { background: #059669; }
.dot-perdido    { background: #ef4444; }

/* ═══ BOARD CONTAINER ═══ */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(6, minmax(280px, 1fr));
    gap: 16px;
    overflow-x: auto; /* Scroll horizontal accesible */
    padding-bottom: 12px;
    align-items: start; /* Las columnas se adaptan a su contenido */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.kanban-board::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.kanban-column {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xs);
    transition: var(--transition-base);
}

.kanban-column:focus-within {
    border-color: #cbd5e1;
}

.kanban-column-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    border-top-left-radius: var(--radius-lg);
    user-select: none;
    -webkit-user-select: none;
    border-top-right-radius: var(--radius-lg);
    border-top: 3px solid transparent;
}

.header-nuevo      { border-top-color: #94a3b8; }
.header-interesado { border-top-color: #64748b; }
.header-escalado   { border-top-color: #f59e0b; }
.header-instalado  { border-top-color: #0ea5e9; }
.header-cerrado    { border-top-color: #16a34a; }
.header-perdido    { border-top-color: #dc2626; }

.column-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.column-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.indicator-nuevo      { background: #94a3b8; }
.indicator-interesado { background: #64748b; }
.indicator-escalado   { background: #f59e0b; }
.indicator-instalado  { background: #0ea5e9; }
.indicator-cerrado    { background: #16a34a; }
.indicator-perdido    { background: #dc2626; }

.column-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.badge-count {
    background: #f1f5f9;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.btn-add-column-card {
    background: #f1f5f9;
    color: var(--color-text-secondary);
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-add-column-card:hover {
    background: var(--color-primary);
    color: #fff;
}

.kanban-cards-container {
    padding: 12px;
    overflow-y: auto; /* Scroll interno para cada columna */
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 2000px; /* Aproximadamente 8 tarjetas (cada tarjeta alta mide ~250px) */
    min-height: 120px;
}

.kanban-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 10px;
    color: #94a3b8;
    font-size: 0.8125rem;
    gap: 6px;
}

/* ═══ KANBAN CARD ═══ */
.kanban-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    user-select: none;
}

.kanban-card:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.09);
    border-color: #cbd5e1;
    transform: translateY(-2px);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card.card-locked {
    cursor: default;
    background: #fafafa;
    border-style: dashed;
    opacity: 0.92;
}

.kanban-card.card-locked:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
}

.badge-tipo {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

.badge-tipo.alta {
    background: #dbeafe;
    color: #1e40af;
}

.badge-tipo.porta {
    background: #fef3c7;
    color: #92400e;
}

.card-id {
    font-weight: 700;
    color: #94a3b8;
}

.badge-locked {
    background: #f1f5f9;
    color: #64748b;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.card-client-name {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    line-height: 1.25;
}

.card-plan-info,
.card-location {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: #475569;
}

.card-plan-info svg,
.card-location svg {
    color: var(--color-primary);
    flex-shrink: 0;
}

.card-footer-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 6px;
    border-top: 1px solid #f1f5f9;
    font-size: 0.75rem;
    color: #64748b;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.card-btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: var(--transition-fast);
}

.card-btn-icon.btn-wa {
    background: #25d366;
    color: #ffffff;
}

.card-btn-icon.btn-call {
    background: #e2e8f0;
    color: #1e293b;
}

.card-btn-icon:hover {
    transform: scale(1.08);
}

.card-btn-action {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

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

.card-btn-action.btn-complete {
    background: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
    margin-left: auto;
}

.card-btn-action.btn-complete:hover {
    background: var(--color-primary-dark);
}

/* Sortable drag styles */
.kanban-card-ghost {
    opacity: 0.35;
    background: #e2e8f0 !important;
    border: 2px dashed #94a3b8 !important;
}

.kanban-card-chosen {
    box-shadow: 0 14px 28px rgba(0,0,0,0.16) !important;
    border-color: var(--color-primary) !important;
}

.kanban-card-dragging {
    opacity: 0.95;
    transform: rotate(2deg) scale(1.03);
}

/* ═══ LEAD DETAIL MODAL ═══ */
.lead-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.lead-detail-block {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 14px;
}

.lead-detail-block.full-width {
    grid-column: 1 / -1;
}

.block-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
    margin: 0 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #e2e8f0;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    padding: 4px 0;
}

.dt-lbl {
    color: #64748b;
    font-weight: 500;
}

.dt-val {
    color: #0f172a;
    font-weight: 600;
    text-align: right;
}

.btn-link-map {
    color: var(--color-primary);
    text-decoration: underline;
    font-size: 0.8125rem;
    font-weight: 600;
}

.obs-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px;
    font-size: 0.875rem;
    color: #334155;
    margin: 0;
    line-height: 1.5;
}

.lead-files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.file-thumb-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: center;
}

.thumb-lbl {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
}

.thumb-img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.audio-file-box {
    grid-column: 1 / -1;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.audio-player {
    width: 100%;
    height: 38px;
}

.alert-lost-box {
    background: #fef2f2;
    border-color: #fecaca;
}

/* ════════════════════════════════════════════════════════════
   BADGES DE ROLES Y ESTADOS CORPORATIVOS
   ════════════════════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
}

.badge-admin {
    background: rgba(147, 51, 234, 0.12);
    color: #7e22ce;
    border: 1px solid rgba(147, 51, 234, 0.3);
}

.badge-jefe, .badge-jefe-ventas {
    background: rgba(79, 70, 229, 0.12);
    color: #4338ca;
    border: 1px solid rgba(79, 70, 229, 0.3);
}

.badge-supervisor {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
    border: 1px solid rgba(37, 99, 235, 0.3);
}

.badge-backoffice {
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
    border: 1px solid rgba(217, 119, 6, 0.3);
}

.badge-vendedor {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-activo {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
}

.badge-inactivo {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.badge-revision {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

.badge-completado {
    background: rgba(16, 185, 129, 0.15);
    color: #065f46;
}

.badge-rechazada_interna {
    background: rgba(239, 68, 68, 0.15);
    color: #991b1b;
}

.badge-info {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
}

.badge-alta_nueva, .badge-alta-nueva {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
}

.badge-porta, .badge-portabilidad {
    background: rgba(99, 102, 241, 0.12);
    color: #4338ca;
}

/* ════════════════════════════════════════════════════════════
   COMPONENTES GERENCIALES & AVATARS
   ════════════════════════════════════════════════════════════ */
.avatar-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.1);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.conversion-bar-container {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 4px;
}

.conversion-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.4s ease;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
}

/* ════════════════════════════════════════════════════════════
   SISTEMA UNIVERSAL DE MODALES Y OVERLAYS
   ════════════════════════════════════════════════════════════ */
.modal-backdrop,
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    box-sizing: border-box;
}

/* SweetAlert2 siempre por encima de cualquier modal o backdrop */
.swal2-container {
    z-index: 100000 !important;
}

.modal-backdrop.active,
.modal-backdrop.is-visible,
.modal-backdrop.show,
.modal-overlay.active,
.modal-overlay.is-visible,
.modal-overlay.show,
.modal-backdrop[style*="display: flex"],
.modal-backdrop[style*="display:flex"],
.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display:flex"] {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.modal,
.modal-container {
    background: var(--color-surface, #ffffff);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--color-border, #e2e8f0);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 10000;
    animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal.modal-sm { max-width: 400px; }
.modal.modal-md { max-width: 560px; }
.modal.modal-lg { max-width: 800px; }

.modal.coverage-modal {
    max-width: 950px;
    width: 95vw;
    height: 85vh;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
    background: var(--color-surface, #ffffff);
}

.modal-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.modal-title,
.modal-header h3,
.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text, #0f172a);
    margin: 0;
}

.modal-subtitle {
    font-size: 0.8125rem;
    color: var(--color-text-muted, #64748b);
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--color-text-muted, #64748b);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm, 6px);
    transition: all 0.15s ease;
}

.modal-close:hover {
    color: var(--color-danger, #ef4444);
    background: rgba(239, 68, 68, 0.08);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body.coverage-body {
    padding: 0;
    flex: 1;
    min-height: 350px;
    overflow: hidden;
}

.modal-body.coverage-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--color-border, #e2e8f0);
    background: var(--color-surface-2, #f8fafc);
}

/* ════════════════════════════════════════════════════════════
   JERARQUÍA CORPORATIVA Y ÁRBOL DE USUARIOS
   ════════════════════════════════════════════════════════════ */
.tree-row-admin {
    border-left: 3px solid #3b82f6;
}

.tree-row-jefe {
    background: rgba(245, 158, 11, 0.03);
    border-left: 3px solid #f59e0b;
}

.tree-row-supervisor {
    background: rgba(99, 102, 241, 0.04);
    border-left: 3px solid #6366f1;
}

.tree-row-vendedor {
    border-left: 3px solid #cbd5e1;
}

.tree-row-vendedor.is-subordinate {
    border-left: 3px solid rgba(99, 102, 241, 0.35);
    background: rgba(248, 250, 252, 0.7);
}

.tree-node {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree-node.level-0 {
    padding-left: 0;
}

.tree-node.level-1 {
    padding-left: 14px;
}

.tree-node.level-2 {
    padding-left: 26px;
}

.tree-connector {
    font-family: monospace;
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    user-select: none;
    flex-shrink: 0;
}

.tree-user-info {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

.tree-user-name {
    font-weight: 600;
    font-size: 12.5px;
    color: var(--color-text, #0f172a);
    display: flex;
    align-items: center;
    gap: 5px;
}

.tree-subtext {
    font-size: 10.5px;
    color: var(--color-text-muted, #64748b);
    line-height: 1.1;
}

.tree-team-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.1);
    color: #4338ca;
}

.btn-delete-user {
    color: var(--color-danger, #ef4444);
    border-color: rgba(239, 68, 68, 0.3);
    transition: all 0.2s ease;
}

.btn-delete-user:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
    transform: scale(1.06);
}

/* ════════════════════════════════════════════════════════════
   SELECTOR DE MODO DE REGISTRO & ENVÍO DE LINK AL CLIENTE
   ════════════════════════════════════════════════════════════ */
.mode-selector-wrapper {
    background: #ffffff;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-lg, 12px);
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.mode-selector-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.mode-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.mode-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    user-select: none;
}

.mode-card:hover {
    border-color: #93c5fd;
    background: #f0f7ff;
}

.mode-card.selected {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.mode-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mode-card-icon {
    font-size: 26px;
    line-height: 1;
    flex-shrink: 0;
}

.mode-card-body {
    flex: 1;
}

.mode-card-name {
    font-size: 14.5px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
}

.mode-card.selected .mode-card-name {
    color: #1d4ed8;
}

.mode-card-desc {
    font-size: 12px;
    color: #64748b;
    margin: 0;
    line-height: 1.35;
}

.mode-card-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mode-card.selected .mode-card-check {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

/* Badges de Estados CRM Modernos - ESTANDARIZACIÓN */
/* 1. GRIS / NEUTRO */
.badge-nuevo, .badge-interesado, .badge-borrador, .badge-vendedor {
    background: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
}

/* 2. NARANJA / ÁMBAR */
.badge-revision, .badge-escalado, .badge-pendiente_cliente, .badge-enviada_a_mi_fibra {
    background: #fffbeb !important;
    color: #d97706 !important;
    border: 1px solid #fde68a !important;
}

.badge-escalado_mifibra {
    background: #eff6ff !important;
    color: #2563eb !important;
    border: 1px solid #bfdbfe !important;
}

/* 3. ROJO / PELIGRO */
.badge-rechazada_interna, .badge-rechazada_operador, .badge-perdido, .badge-inactivo {
    background: #fef2f2 !important;
    color: #dc2626 !important;
    border: 1px solid #fecaca !important;
}

/* 4. AZUL / CELESTE */
.badge-instalado, .badge-instalada {
    background: #e0f2fe !important;
    color: #0ea5e9 !important;
    border: 1px solid #bae6fd !important;
}

/* 5. VERDE / ÉXITO */
.badge-completado, .badge-cerrado, .badge-activo {
    background: #dcfce7 !important;
    color: #16a34a !important;
    border: 1px solid #bbf7d0 !important;
}

/* ================================================================
   BOTONES FLOTANTES SCROLL HORIZONTAL KANBAN
   ================================================================ */
.kanban-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    opacity: 0.6;
    transition: all 0.3s ease;
    color: var(--color-primary);
}

.kanban-scroll-btn:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
    background: var(--color-primary);
    color: white;
}

.kanban-scroll-left {
    left: -10px;
}

.kanban-scroll-right {
    right: -10px;
}

/* Ocultar en móvil si es necesario */
@media (max-width: 1024px) {
    .kanban-scroll-btn {
        display: none;
    }
    .hide-mobile-kanban {
        display: none !important;
    }
}

/* ================================================================
   BOTONERA KANBAN (REORGANIZADA MÓDULO 3)
   ================================================================ */
.card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
}

.card-actions-primary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.card-actions-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-actions-right {
    display: flex;
    align-items: center;
}

.card-actions-danger-row {
    display: flex;
    width: 100%;
    margin-top: 4px;
}

.btn-complete-primary {
    background: var(--color-primary);
    color: white !important;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    border: none;
    box-shadow: 0 2px 4px rgba(26,86,219,0.3);
    transition: var(--transition-fast);
}

.btn-complete-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(26,86,219,0.4);
}

.btn-delete-full {
    width: 100%;
    background: transparent;
    color: var(--color-danger) !important;
    border: 1px solid var(--color-danger);
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    transition: var(--transition-fast);
    cursor: pointer;
}

.btn-delete-full:hover {
    background: var(--color-danger-light);
}

