/**
 * NEXUS UI - Sistema de Diseño Adaptativo
 * Tema claro profesional + Modo nocturno
 * Toggle automático según preferencia del sistema
 */

/* ═══════════════════════════════════════════════════════════════
   FUENTES
   ═══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ═══════════════════════════════════════════════════════════════
   VARIABLES - TEMA AZUL MARINO CORPORATIVO (Por defecto)
   ═══════════════════════════════════════════════════════════════ */
:root {
    /* Fondos */
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-elevated: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-input: #ffffff;
    --bg-hover: #fff4ed; /* Naranja muy claro para hover */

    /* Acentos - Azul Marino */
    --accent-primary: #1e3a8a;
    --accent-primary-hover: #1e40af;
    --accent-secondary: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);

    /* Texto */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Bordes */
    --border-color: #e2e8f0;
    --border-focus: var(--accent-primary);

    /* Estados */
    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.1);
    --success-border: rgba(5, 150, 105, 0.2);
    --error: #dc2626;
    --error-bg: rgba(220, 38, 38, 0.1);
    --error-border: rgba(220, 38, 38, 0.2);
    --info: #0284c7;
    --info-bg: rgba(2, 132, 199, 0.1);
    --warning: #d97706;

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 0 3px rgba(37, 99, 235, 0.15);

    /* Dimensiones */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transiciones */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: 150ms var(--ease-out);
    --transition-normal: 250ms var(--ease-out);
    --transition-theme: 200ms ease;

    /* Toggle específico */
    --toggle-bg: #e2e8f0;
    --toggle-dot: #ffffff;
    --icon-sun: #f59e0b;
    --icon-moon: #64748b;
}

/* ═══════════════════════════════════════════════════════════════
   VARIABLES - TEMA OSCURO
   ═══════════════════════════════════════════════════════════════ */
[data-theme="dark"] {
    --bg-body: #0a0c10;
    --bg-surface: #12151c;
    --bg-elevated: #1a1f2a;
    --bg-card: rgba(18, 21, 28, 0.95);
    --bg-input: #1a1f2a;
    --bg-hover: rgba(251, 146, 60, 0.08); /* Naranja suave para hover en dark */

    --accent-primary: #00d4ff;
    --accent-primary-hover: #00b8e6;
    --accent-secondary: #a78bfa;
    --accent-gradient: linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    --border-color: rgba(148, 163, 184, 0.1);
    --border-focus: var(--accent-primary);

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --success-border: rgba(16, 185, 129, 0.3);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.15);
    --error-border: rgba(239, 68, 68, 0.3);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.15);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 0 3px rgba(0, 212, 255, 0.2), 0 0 20px rgba(0, 212, 255, 0.1);

    --toggle-bg: #1e293b;
    --toggle-dot: #00d4ff;
    --icon-sun: #64748b;
    --icon-moon: #00d4ff;
}

/* ═══════════════════════════════════════════════════════════════
   VARIABLES - TEMA VERDE CORPORATIVO
   ═══════════════════════════════════════════════════════════════ */
[data-theme="green"] {
    /* Fondos */
    --bg-body: #f0fdf4;
    --bg-surface: #ffffff;
    --bg-elevated: #dcfce7;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-input: #ffffff;
    --bg-hover: #fff4ed; /* Naranja muy claro para hover */

    /* Acentos - Verde Corporativo */
    --accent-primary: #065f46;
    --accent-primary-hover: #047857;
    --accent-secondary: #10b981;
    --accent-gradient: linear-gradient(135deg, #065f46 0%, #10b981 100%);

    /* Texto */
    --text-primary: #064e3b;
    --text-secondary: #047857;
    --text-muted: #6ee7b7;
    --text-inverse: #ffffff;

    /* Bordes */
    --border-color: #a7f3d0;
    --border-focus: var(--accent-primary);

    /* Estados */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-border: rgba(16, 185, 129, 0.2);
    --error: #dc2626;
    --error-bg: rgba(220, 38, 38, 0.1);
    --error-border: rgba(220, 38, 38, 0.2);
    --info: #0284c7;
    --info-bg: rgba(2, 132, 199, 0.1);
    --warning: #d97706;

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(6, 95, 70, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(6, 95, 70, 0.07), 0 2px 4px -1px rgba(6, 95, 70, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(6, 95, 70, 0.08), 0 4px 6px -2px rgba(6, 95, 70, 0.04);
    --shadow-glow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

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

/* Deshabilitar transiciones durante cambio de tema para mayor velocidad */
html.theme-changing * {
    transition: none !important;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition-theme), color var(--transition-theme);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

/* Fondo sutil para tema oscuro */
[data-theme="dark"] body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 212, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 90% 100%, rgba(124, 58, 237, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* Grid sutil para tema oscuro */
[data-theme="dark"] body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 212, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 255, 0.015) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: -1;
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ═══════════════════════════════════════════════════════════════
   THEME SELECTOR
   ═══════════════════════════════════════════════════════════════ */
.theme-selector-wrapper {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.theme-selector-wrapper:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.theme-selector-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.theme-selector-label svg {
    color: var(--accent-primary);
    flex-shrink: 0;
}

.theme-selector {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 12px;
    min-width: 160px;
}

.theme-selector:hover {
    border-color: var(--accent-primary);
    background-color: var(--bg-surface);
}

.theme-selector:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.theme-selector option {
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════
   GLASS CARD
   ═══════════════════════════════════════════════════════════════ */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    position: relative;
    margin-bottom: 1.5rem;
    transition:
        background var(--transition-theme),
        border-color var(--transition-normal),
        box-shadow var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.glass-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: -1;
    pointer-events: none;
}

.glass-card:hover {
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] .glass-card:hover {
    border-color: rgba(0, 212, 255, 0.2);
}

/* ═══════════════════════════════════════════════════════════════
   STATUS BAR
   ═══════════════════════════════════════════════════════════════ */
.status-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.status-active {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-active::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1px solid var(--success);
    opacity: 0.4;
    animation: pulse-ring 2s ease-out infinite;
}

.status-inactive {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.6); opacity: 0; }
}

.status-text {
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════
   DEBUG BOX
   ═══════════════════════════════════════════════════════════════ */
.debug-box {
    background: var(--bg-elevated);
    padding: 1.25rem 1.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    border-left: 3px solid var(--accent-primary);
    transition: background var(--transition-theme);
}

[data-theme="dark"] .debug-box {
    background: rgba(0, 0, 0, 0.3);
}

.debug-box pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.8;
    color: var(--text-secondary);
}

.debug-title {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.6875rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.debug-title svg {
    width: 1rem;
    height: 1rem;
    opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════════
   SEARCH BOX
   ═══════════════════════════════════════════════════════════════ */
.search-box {
    padding: 3rem 2.5rem;
    text-align: center;
}

.search-box h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.875rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.search-box h1 svg {
    width: 2rem;
    height: 2rem;
    color: var(--accent-primary);
}

[data-theme="dark"] .search-box h1 svg {
    filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.4));
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 2.25rem;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

/* ═══════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════════════════════ */
.form-row {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 1rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group, .select-group {
    display: flex;
    flex-direction: column;
}

label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"], select {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background var(--transition-theme);
}

input[type="text"]:hover, select:hover {
    border-color: var(--text-muted);
}

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--shadow-glow);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    padding-right: 2.75rem;
}

select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════
   SEARCH MODE SELECTOR
   ═══════════════════════════════════════════════════════════════ */
.search-mode-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.search-mode-option {
    margin: 0;
}

.search-mode-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.search-mode-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.search-mode-card:hover {
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

.search-mode-option input[type="radio"]:checked + .search-mode-card {
    border-color: var(--accent-primary);
    background: var(--info-bg);
}

[data-theme="dark"] .search-mode-option input[type="radio"]:checked + .search-mode-card {
    background: rgba(0, 212, 255, 0.08);
    border-color: var(--accent-primary);
}

.search-mode-option input[type="radio"]:focus-visible + .search-mode-card {
    box-shadow: var(--shadow-glow);
}

.search-mode-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.search-mode-icon svg {
    width: 20px;
    height: 20px;
}

.search-mode-option input[type="radio"]:checked + .search-mode-card .search-mode-icon {
    background: var(--accent-gradient);
    color: white;
}

.search-mode-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.search-mode-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: color var(--transition-fast);
}

.search-mode-option input[type="radio"]:checked + .search-mode-card .search-mode-title {
    color: var(--accent-primary);
}

.search-mode-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Motor select hidden when exact mode */
.motor-select-group {
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.motor-select-group.hidden {
    opacity: 0.4;
    pointer-events: none;
}

/* Submit button mode variants */
button[type="submit"] .btn-icon-ia,
button[type="submit"] .btn-text-ia {
    display: inline-flex;
}

button[type="submit"] .btn-icon-exact,
button[type="submit"] .btn-text-exact {
    display: none;
}

button[type="submit"].mode-exact .btn-icon-ia,
button[type="submit"].mode-exact .btn-text-ia {
    display: none;
}

button[type="submit"].mode-exact .btn-icon-exact,
button[type="submit"].mode-exact .btn-text-exact {
    display: inline-flex;
}

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

    .search-mode-card {
        padding: 0.875rem 1rem;
    }

    .search-mode-icon {
        width: 36px;
        height: 36px;
    }

    .search-mode-icon svg {
        width: 18px;
        height: 18px;
    }

    .search-mode-title {
        font-size: 0.8125rem;
    }

    .search-mode-desc {
        font-size: 0.6875rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   BUTTON
   ═══════════════════════════════════════════════════════════════ */
button[type="submit"] {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--accent-gradient);
    color: var(--text-inverse);
    border: none;
    padding: 0.9375rem 2rem;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    overflow: hidden;
}

button[type="submit"] svg {
    flex-shrink: 0;
}

button[type="submit"]::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 50%);
}

button[type="submit"]:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

[data-theme="dark"] button[type="submit"]:hover:not(:disabled) {
    box-shadow: 0 8px 30px rgba(0, 212, 255, 0.25);
}

button[type="submit"]:active:not(:disabled) {
    transform: translateY(0);
}

button[type="submit"]:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════════════════ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.875rem;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error-border);
}

/* ═══════════════════════════════════════════════════════════════
   RESULTS
   ═══════════════════════════════════════════════════════════════ */
.results-container {
    padding: 0;
    overflow: visible;
    animation: none;
}

.results-container::before {
    display: none;
}

.results-header {
    padding: 1.125rem 1.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.625rem;
    color: var(--text-primary);
    background: var(--bg-elevated);
    transition: background var(--transition-theme);
}

.results-header > span,
.results-header > svg {
    display: contents;
}

.results-header-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

[data-theme="dark"] .results-header {
    background: rgba(0, 0, 0, 0.2);
}

.results-header svg:first-of-type {
    width: 1.125rem;
    height: 1.125rem;
    color: var(--accent-primary);
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   TABLE
   ═══════════════════════════════════════════════════════════════ */
.table-responsive {
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    max-height: 65vh;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th, td {
    padding: 0.9375rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

th {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--bg-elevated);
    white-space: nowrap;
    box-shadow: 0 2px 0 var(--border-color);
}

[data-theme="dark"] th {
    background: var(--bg-elevated);
}

tr:last-child td {
    border-bottom: none;
}

/* Zebra striping - filas alternadas */
tbody tr:nth-child(even) {
    background: var(--bg-elevated);
}

tbody tr:nth-child(odd) {
    background: var(--bg-surface);
}

tbody tr:hover {
    background: var(--bg-hover);
}

/* Borde naranja en hover - ambos temas */
tbody tr td:first-child {
    border-left: 2px solid transparent;
    transition: border-color var(--transition-fast);
}

tbody tr:hover td:first-child {
    border-left-color: #fb923c;
}

/* Zebra striping - tema oscuro con más contraste */
[data-theme="dark"] tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] tbody tr:nth-child(odd) {
    background: var(--bg-surface);
}

.descripcion-cell {
    max-width: 2000px; /* Aumentado para mejor visualización del texto largo */
    white-space: normal;
    word-wrap: break-word;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
    font-size: 0.8125rem; /* 13px - Tamaño reducido para mejor densidad */
    line-height: 1.4; /* Interlineado compacto */
}

.descripcion-cell:hover {
    color: var(--text-primary);
}

.fecha-cell {
    white-space: nowrap;
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ═══════════════════════════════════════════════════════════════
   ADVANCED GRID - Columna Item
   ═══════════════════════════════════════════════════════════════ */
.col-item {
    text-align: center !important;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    width: 50px;
    min-width: 50px;
    max-width: 50px;
}

th.col-item {
    padding: 0.9375rem 0.75rem;
}

td.col-item {
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-color);
}

[data-theme="dark"] td.col-item {
    background: rgba(0, 0, 0, 0.2);
}

/* ═══════════════════════════════════════════════════════════════
   ADVANCED GRID - Ordenamiento
   ═══════════════════════════════════════════════════════════════ */
th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 2rem;
}

th.sortable:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

[data-theme="dark"] th.sortable:hover {
    background: rgba(0, 212, 255, 0.05);
}

.sort-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

th.sortable:hover .sort-icon {
    opacity: 0.5;
}

th.sort-asc .sort-icon,
th.sort-desc .sort-icon {
    opacity: 1;
}

.sort-icon .sort-asc,
.sort-icon .sort-desc {
    opacity: 0.3;
    transition: opacity var(--transition-fast), color var(--transition-fast);
}

th.sort-asc .sort-icon .sort-asc {
    opacity: 1;
    color: var(--accent-primary);
}

th.sort-asc .sort-icon .sort-desc {
    opacity: 0.15;
}

th.sort-desc .sort-icon .sort-desc {
    opacity: 1;
    color: var(--accent-primary);
}

th.sort-desc .sort-icon .sort-asc {
    opacity: 0.15;
}

/* ═══════════════════════════════════════════════════════════════
   ADVANCED GRID - Redimensionado
   ═══════════════════════════════════════════════════════════════ */
.resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    transition: background var(--transition-fast);
    z-index: 10;
}

.resize-handle:hover,
th.resizing .resize-handle {
    background: var(--accent-primary);
}

body.resizing-columns {
    cursor: col-resize !important;
    user-select: none;
}

body.resizing-columns * {
    cursor: col-resize !important;
}

/* Tooltip de tamaño en tiempo real */
.resize-tooltip {
    position: fixed;
    background: #1e293b;
    color: #fff;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

[data-theme="dark"] .resize-tooltip {
    background: #0f172a;
    border: 1px solid rgba(0, 212, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 212, 255, 0.15);
}

/* ═══════════════════════════════════════════════════════════════
   ADVANCED GRID - Reordenamiento (Drag & Drop)
   ═══════════════════════════════════════════════════════════════ */
th.draggable {
    cursor: grab;
}

th.draggable:active {
    cursor: grabbing;
}

th.dragging {
    opacity: 0.5;
}

th.drag-ghost {
    background: var(--accent-primary) !important;
    color: var(--text-inverse);
}

th.drag-over {
    position: relative;
}

th.drag-over-left::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-primary);
    z-index: 20;
}

th.drag-over-right::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-primary);
    z-index: 20;
}

/* ═══════════════════════════════════════════════════════════════
   ADVANCED GRID - Búsqueda Local
   ═══════════════════════════════════════════════════════════════ */
.local-search-container {
    display: flex;
    align-items: center;
    position: relative;
    flex: 1;
    max-width: 300px;
    min-width: 190px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal), background var(--transition-theme);
}

.local-search-container:hover {
    border-color: var(--text-muted);
    box-shadow: var(--shadow-md);
}

.local-search-container:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow), var(--shadow-md);
}

.local-search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 0.875rem;
    flex-shrink: 0;
    pointer-events: none;
    color: var(--text-muted);
    transition: color var(--transition-normal), transform var(--transition-normal);
}

.local-search-container:focus-within .local-search-icon {
    color: var(--accent-primary);
    transform: scale(1.1);
}

.local-search-input {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0.25rem 0.6rem 0.45rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-primary);
    transition: color var(--transition-theme);
}

.local-search-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
    transition: color var(--transition-normal);
}

.local-search-container:focus-within .local-search-input::placeholder {
    color: transparent;
}

.local-search-input:focus {
    outline: none;
}

.local-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    margin-right: 0.35rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0.7;
    transition: all var(--transition-fast);
}

.local-search-clear:hover {
    background: var(--error-bg);
    color: var(--error);
    opacity: 1;
    transform: scale(1.15);
}

.local-search-count {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(124, 58, 237, 0.08));
    border: 1px solid rgba(37, 99, 235, 0.18);
    padding: 0.15rem 0.5rem;
    margin-right: 0.35rem;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    pointer-events: none;
    white-space: nowrap;
}

[data-theme="dark"] .local-search-container {
    background: var(--bg-elevated);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .local-search-container:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .local-search-container:focus-within {
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15), 0 2px 8px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .local-search-clear {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .local-search-clear:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

[data-theme="dark"] .local-search-count {
    color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(167, 139, 250, 0.1));
    border-color: rgba(0, 212, 255, 0.2);
}

[data-theme="dark"] .local-search-count {
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent-primary);
}

/* Highlight de filas filtradas */
tr.search-highlight {
    position: relative;
}

tr.search-highlight td:first-child {
    border-left: 3px solid var(--accent-primary) !important;
}

[data-theme="dark"] tr.search-highlight {
    background: rgba(0, 212, 255, 0.03);
}

/* Filas filtradas ocultas - con !important para que funcione en mobile card view */
tr.filtered-hidden {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   PAGINACIÓN
   ═══════════════════════════════════════════════════════════════ */
.pagination-container {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.pagination-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.pagination-btn:active:not(:disabled) {
    transform: translateY(0);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-btn svg {
    flex-shrink: 0;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-page {
    min-width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-page:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.pagination-page.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    font-weight: 600;
}

.pagination-ellipsis {
    color: var(--text-muted);
    padding: 0 0.25rem;
    user-select: none;
}

.pagination-info {
    margin-left: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: normal;
}

/* Responsive */
@media (max-width: 768px) {
    .local-search-container {
        max-width: 100%;
        order: 3;
        flex-basis: 100%;
        margin-top: 0.5rem;
    }
}

@media (max-width: 480px) {
    .local-search-container {
        min-width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════
   ADVANCED GRID - Exportación
   ═══════════════════════════════════════════════════════════════ */
.export-buttons {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.export-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--bg-hover);
}

.export-btn svg {
    flex-shrink: 0;
}

.export-btn.export-csv:hover {
    border-color: #059669;
    color: #059669;
}

.export-btn.export-excel:hover {
    border-color: #16a34a;
    color: #16a34a;
}

.export-btn.export-pdf:hover {
    border-color: #dc2626;
    color: #dc2626;
}

[data-theme="dark"] .export-btn {
    background: var(--bg-elevated);
    border-color: var(--border-color);
}

[data-theme="dark"] .export-btn:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

[data-theme="dark"] .export-btn.export-csv:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
    color: #10b981;
}

[data-theme="dark"] .export-btn.export-excel:hover {
    background: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
    color: #22c55e;
}

[data-theme="dark"] .export-btn.export-pdf:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

/* Responsive export buttons */
@media (max-width: 640px) {
    .export-buttons {
        margin-left: 0;
        width: 100%;
    }

    .export-btn {
        flex: 1;
        justify-content: center;
    }
}

/* ═══════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════ */
.badge {
    display: inline-block;
    padding: 0.3125rem 0.75rem;
    background: var(--info-bg);
    color: var(--accent-primary);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

[data-theme="dark"] .badge {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.estado-badge {
    padding: 0.3125rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.estado-default {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.estado-vigente {
    background: var(--success-bg);
    color: var(--success);
}

[data-theme="dark"] .estado-vigente {
    border: 1px solid var(--success-border);
}

.estado-adjudicado {
    background: var(--info-bg);
    color: var(--info);
}

[data-theme="dark"] .estado-adjudicado {
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.estado-cancelado {
    background: var(--error-bg);
    color: var(--error);
}

[data-theme="dark"] .estado-cancelado {
    border: 1px solid var(--error-border);
}

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════ */
.empty {
    padding: 4rem 2rem;
    text-align: center;
}

.empty-icon {
    margin-bottom: 1.25rem;
    position: relative;
    display: inline-block;
}

[data-theme="dark"] .empty-icon::before {
    content: '';
    position: absolute;
    inset: -15px;
    background: radial-gradient(ellipse at center, rgba(0, 212, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.empty-icon svg {
    width: 3rem;
    height: 3rem;
    color: var(--text-muted);
    opacity: 0.6;
    position: relative;
}

[data-theme="dark"] .empty-icon svg {
    color: var(--accent-primary);
    opacity: 0.5;
}

.empty h3 {
    font-size: 1.0625rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.empty p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    max-width: 380px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .container {
        padding: 1.5rem 1rem 3rem;
    }

    .theme-selector-wrapper {
        top: 1rem;
        right: 1rem;
    }

    .search-box {
        padding: 2.5rem 1.75rem;
    }

    .search-box h1 {
        font-size: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    th, td {
        padding: 0.875rem 1.25rem;
    }

    .descripcion-cell {
        max-width: 560px; /* Más espacio en tablet */
        font-size: 0.75rem; /* 12px en tablet */
    }
}

@media (max-width: 640px) {
    html {
        font-size: 15px;
    }

    .container {
        padding: 1rem 0.75rem 2.5rem;
    }

    .theme-selector-wrapper {
        top: 0.75rem;
        right: 0.75rem;
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }

    .theme-selector-label {
        font-size: 0.75rem;
    }

    .theme-selector-label span {
        display: none; /* Ocultar texto "Tema" en móvil */
    }

    .theme-selector {
        min-width: 130px;
        padding: 0.3rem 1.75rem 0.3rem 0.625rem;
        font-size: 0.75rem;
    }

    .glass-card {
        border-radius: var(--radius-md);
    }

    .search-box {
        padding: 2rem 1.25rem;
        padding-top: 2.5rem;
    }

    .search-box h1 {
        font-size: 1.25rem;
        flex-direction: column;
        gap: 0.625rem;
    }

    .search-box h1 svg {
        width: 1.75rem;
        height: 1.75rem;
    }

    .subtitle {
        font-size: 0.875rem;
        margin-bottom: 1.75rem;
    }

    input[type="text"], select, button[type="submit"] {
        padding: 0.8125rem 0.875rem;
    }

    th, td {
        padding: 0.75rem 1rem;
        font-size: 0.8125rem;
    }

    .descripcion-cell {
        max-width: 400px; /* Más espacio en móvil */
        font-size: 0.6875rem; /* 11px en móvil */
        line-height: 1.35;
    }

    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .estado-badge {
        font-size: 0.625rem;
        padding: 0.25rem 0.5rem;
    }

    .empty {
        padding: 3rem 1.5rem;
    }
}

@media (max-width: 400px) {
    .theme-toggle-label {
        display: none;
    }

    .theme-toggle {
        padding: 0.375rem;
    }

    .search-box h1 {
        font-size: 1.125rem;
    }

    .status-bar {
        font-size: 0.75rem;
        padding: 0.4375rem 0.75rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   CARD VIEW MÓVIL (< 640px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    /* Ocultar encabezados de tabla en móvil */
    .table-responsive thead {
        display: none !important;
    }

    /* Contenedor de tarjetas */
    .table-responsive {
        overflow-x: visible !important;
        max-height: none !important;
        padding: 0.5rem !important;
    }

    .table-responsive table {
        display: block !important;
        border: none !important;
    }

    tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important; /* Espacio entre tarjetas */
    }

    /* Tarjeta individual */
    tbody tr {
        display: flex !important;
        flex-direction: column !important;
        background: var(--bg-surface) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: var(--radius-lg) !important;
        padding: 1.25rem !important; /* Más padding para mejor lectura */
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06) !important;
        transition: all var(--transition-fast) !important;
        position: relative !important;
        overflow: hidden !important;
        margin-bottom: 0 !important;
    }

    tbody tr:hover {
        box-shadow: var(--shadow-md);
        border-color: var(--accent-primary);
        transform: translateY(-2px);
    }

    tbody tr::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        background: var(--accent-primary);
        opacity: 0;
        transition: opacity var(--transition-fast);
    }

    tbody tr:hover::before {
        opacity: 1;
    }

    /* Cada celda como fila en la tarjeta */
    tbody tr td {
        display: flex !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        padding: 0.875rem 0 !important; /* Más espacio vertical */
        border: none !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        gap: 1rem !important; /* Mayor separación entre etiqueta y valor */
    }

    tbody tr td:not(:last-child) {
        border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important; /* Divisor más sutil */
    }

    tbody tr td:last-child {
        padding-bottom: 0 !important;
    }

    tbody tr td:first-child {
        padding-top: 0 !important;
    }

    /* Etiquetas para cada campo */
    tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.025em;
        flex-shrink: 0;
        min-width: 90px;
    }

    /* URL Estado como primer elemento destacado */
    .url-estado-cell {
        order: -2;
        justify-content: center !important;
        padding: 0.875rem 0 !important;
        border-bottom: 2px solid var(--border-color) !important;
    }

    .url-estado-cell::before {
        display: none;
    }

    /* Expediente como header */
    tbody tr td:nth-child(2) {
        order: -1;
        font-size: 1rem;
        padding: 0.75rem 0 1rem 0 !important;
        border-bottom: 2px solid var(--border-color) !important;
    }

    tbody tr td:nth-child(2)::before {
        content: 'Expediente';
        font-size: 0.875rem;
        font-weight: 700;
        color: var(--accent-primary);
    }

    /* Descripción con más espacio */
    .descripcion-cell {
        flex-direction: column;
        align-items: flex-start !important;
        max-width: 100% !important;
        line-height: 1.5;
        font-size: 0.8125rem !important;
    }

    .descripcion-cell::before {
        margin-bottom: 0.375rem;
    }

    /* Estados con badges visuales */
    tbody tr td:nth-child(4) .estado-badge {
        font-size: 0.6875rem;
        padding: 0.375rem 0.625rem;
    }

    /* Fechas más compactas */
    tbody tr td:nth-child(5),
    tbody tr td:nth-child(6),
    tbody tr td:nth-child(7) {
        font-family: 'JetBrains Mono', monospace;
        font-size: 0.8125rem;
    }

    /* Zebra striping para tarjetas - colores alternados */
    tbody tr:nth-child(odd) {
        background: var(--bg-surface) !important;
    }

    tbody tr:nth-child(even) {
        background: var(--bg-elevated) !important;
    }

    /* Mejorar legibilidad en móvil */
    tbody tr td {
        font-size: 0.9375rem !important; /* 15px - tamaño óptimo para móvil */
        line-height: 1.6 !important;
    }

    tbody tr td::before {
        font-size: 0.6875rem !important; /* 11px - etiquetas más pequeñas */
        font-weight: 700 !important;
        color: var(--text-secondary) !important;
        letter-spacing: 0.05em !important;
    }

    /* Descripción con mejor legibilidad */
    .descripcion-cell {
        font-size: 0.875rem !important; /* 14px */
        line-height: 1.7 !important;
        color: var(--text-primary) !important;
    }

    /* Expediente más legible */
    .expediente-wrapper .badge {
        font-size: 0.8125rem !important; /* 13px */
        padding: 0.5rem 0.75rem !important;
        font-family: 'JetBrains Mono', 'Courier New', monospace !important;
        font-weight: 600 !important;
    }

    /* Estados con mejor contraste */
    .estado-badge {
        font-size: 0.75rem !important; /* 12px */
        font-weight: 600 !important;
        padding: 0.5rem 0.875rem !important;
        letter-spacing: 0.025em !important;
    }

    /* Fechas más legibles */
    .fecha-cell {
        font-family: 'JetBrains Mono', 'Courier New', monospace !important;
        font-size: 0.8125rem !important; /* 13px */
        font-weight: 500 !important;
    }

    /* Estilos específicos para modo oscuro */
    [data-theme="dark"] tbody tr:nth-child(even) {
        background: rgba(0, 0, 0, 0.3) !important;
    }

    [data-theme="dark"] tbody tr:nth-child(odd) {
        background: rgba(0, 0, 0, 0.2) !important;
    }

    [data-theme="dark"] tbody tr td:not(:last-child) {
        border-bottom-color: rgba(255, 255, 255, 0.08) !important;
    }

    /* Hover mejorado en mobile */
    tbody tr:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
        transform: translateY(-2px) !important;
        border-color: var(--accent-primary) !important;
    }

    [data-theme="dark"] tbody tr:hover {
        box-shadow: 0 4px 12px rgba(0, 212, 255, 0.15) !important;
    }

    /* Paginación responsive en móvil */
    .pagination-controls {
        gap: 0.5rem;
    }

    .pagination-btn span {
        display: none;
    }

    .pagination-btn {
        padding: 0.5rem;
        min-width: 2.25rem;
        justify-content: center;
    }

    .pagination-page {
        min-width: 2rem;
        height: 2rem;
        font-size: 0.8125rem;
    }

    .pagination-info {
        flex-basis: 100%;
        text-align: center;
        margin: 0.5rem 0 0 0;
        order: 3;
    }
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-elevated);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-elevated);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) var(--bg-elevated);
}

/* ═══════════════════════════════════════════════════════════════
   SELECTION
   ═══════════════════════════════════════════════════════════════ */
::selection {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

[data-theme="dark"] ::selection {
    background: rgba(0, 212, 255, 0.3);
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════
   FOCUS VISIBLE
   ═══════════════════════════════════════════════════════════════ */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */
@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.glass-card {
    animation: fade-in 0.35s var(--ease-out) backwards;
}

.search-box { animation-delay: 0.03s; }
.results-container { animation-delay: 0.06s; }
.debug-box { animation-delay: 0.09s; }


/* ═══════════════════════════════════════════════════════════════
   AI LOADING OVERLAY
   ═══════════════════════════════════════════════════════════════ */
.ai-loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

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

[data-theme="dark"] .ai-loader-overlay {
    background: rgba(10, 12, 16, 0.95);
}

/* Container principal */
.ai-loader-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

/* ═══════════════════════════════════════════════════════════════
   NEURAL BRAIN ANIMATION
   ═══════════════════════════════════════════════════════════════ */
.ai-brain-container {
    position: relative;
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Orbiting rings */
.ai-orbit {
    position: absolute;
    border: 2px solid transparent;
    border-radius: 50%;
    animation: ai-orbit-rotate linear infinite;
}

.ai-orbit:nth-child(1) {
    width: 100%;
    height: 100%;
    border-top-color: var(--accent-primary);
    border-bottom-color: var(--accent-secondary);
    animation-duration: 3s;
}

.ai-orbit:nth-child(2) {
    width: 80%;
    height: 80%;
    border-left-color: var(--accent-secondary);
    border-right-color: var(--accent-primary);
    animation-duration: 2.5s;
    animation-direction: reverse;
}

.ai-orbit:nth-child(3) {
    width: 60%;
    height: 60%;
    border-top-color: var(--accent-primary);
    border-bottom-color: rgba(124, 58, 237, 0.5);
    animation-duration: 2s;
}

@keyframes ai-orbit-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Neural nodes on orbits */
.ai-node {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--accent-primary), 0 0 40px var(--accent-primary);
    animation: ai-node-pulse 1.5s ease-in-out infinite;
}

.ai-orbit:nth-child(1) .ai-node { top: -5px; left: 50%; transform: translateX(-50%); }
.ai-orbit:nth-child(2) .ai-node { bottom: -5px; right: 10%; animation-delay: 0.3s; }
.ai-orbit:nth-child(3) .ai-node { top: 50%; left: -5px; transform: translateY(-50%); animation-delay: 0.6s; }

[data-theme="dark"] .ai-node {
    background: var(--accent-primary);
    box-shadow: 0 0 20px var(--accent-primary), 0 0 40px rgba(0, 212, 255, 0.5), 0 0 60px rgba(0, 212, 255, 0.3);
}

@keyframes ai-node-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* Central AI brain icon */
.ai-brain-core {
    position: relative;
    width: 70px;
    height: 70px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.4), 0 0 60px rgba(124, 58, 237, 0.2);
    animation: ai-core-pulse 2s ease-in-out infinite;
    z-index: 5;
}

[data-theme="dark"] .ai-brain-core {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.5), 0 0 80px rgba(167, 139, 250, 0.3);
}

.ai-brain-core svg {
    width: 36px;
    height: 36px;
    color: white;
    animation: ai-icon-float 3s ease-in-out infinite;
}

@keyframes ai-core-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 30px rgba(37, 99, 235, 0.4), 0 0 60px rgba(124, 58, 237, 0.2);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 50px rgba(37, 99, 235, 0.6), 0 0 100px rgba(124, 58, 237, 0.3);
    }
}

[data-theme="dark"] .ai-brain-core {
    animation-name: ai-core-pulse-dark;
}

@keyframes ai-core-pulse-dark {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 40px rgba(0, 212, 255, 0.5), 0 0 80px rgba(167, 139, 250, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 60px rgba(0, 212, 255, 0.7), 0 0 120px rgba(167, 139, 250, 0.4);
    }
}

@keyframes ai-icon-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* ═══════════════════════════════════════════════════════════════
   NEURAL NETWORK CONNECTIONS (Background)
   ═══════════════════════════════════════════════════════════════ */
.ai-neural-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.ai-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0;
    animation: ai-particle-float 4s ease-in-out infinite;
}

.ai-particle:nth-child(1) { left: 10%; top: 20%; animation-delay: 0s; }
.ai-particle:nth-child(2) { left: 80%; top: 15%; animation-delay: 0.5s; }
.ai-particle:nth-child(3) { left: 15%; top: 70%; animation-delay: 1s; }
.ai-particle:nth-child(4) { left: 85%; top: 75%; animation-delay: 1.5s; }
.ai-particle:nth-child(5) { left: 50%; top: 10%; animation-delay: 2s; }
.ai-particle:nth-child(6) { left: 30%; top: 85%; animation-delay: 2.5s; }
.ai-particle:nth-child(7) { left: 70%; top: 90%; animation-delay: 3s; }
.ai-particle:nth-child(8) { left: 5%; top: 50%; animation-delay: 3.5s; }

[data-theme="dark"] .ai-particle {
    background: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary);
}

@keyframes ai-particle-float {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.5);
    }
    20% {
        opacity: 0.8;
    }
    80% {
        opacity: 0.8;
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(1.2);
    }
}

/* Connection lines */
.ai-connection {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    opacity: 0.3;
    animation: ai-connection-pulse 3s ease-in-out infinite;
}

.ai-connection:nth-child(9) { width: 150px; left: 5%; top: 30%; transform: rotate(25deg); }
.ai-connection:nth-child(10) { width: 120px; right: 10%; top: 25%; transform: rotate(-15deg); animation-delay: 0.5s; }
.ai-connection:nth-child(11) { width: 180px; left: 8%; bottom: 35%; transform: rotate(-30deg); animation-delay: 1s; }
.ai-connection:nth-child(12) { width: 100px; right: 15%; bottom: 30%; transform: rotate(20deg); animation-delay: 1.5s; }

[data-theme="dark"] .ai-connection {
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    opacity: 0.4;
}

@keyframes ai-connection-pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.5; }
}

/* ═══════════════════════════════════════════════════════════════
   LOADING TEXT
   ═══════════════════════════════════════════════════════════════ */
.ai-loader-text {
    text-align: center;
}

.ai-loader-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.ai-loader-title span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ai-loader-status {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

/* Animated dots */
.ai-dots {
    display: inline-flex;
    gap: 3px;
}

.ai-dots span {
    width: 5px;
    height: 5px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: ai-dot-bounce 1.4s ease-in-out infinite;
}

.ai-dots span:nth-child(1) { animation-delay: 0s; }
.ai-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-dot-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ═══════════════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════════════ */
.ai-progress-container {
    width: 280px;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 0.5rem;
}

[data-theme="dark"] .ai-progress-container {
    background: rgba(255, 255, 255, 0.1);
}

.ai-progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    width: 0%;
    animation: ai-progress-indeterminate 2s ease-in-out infinite;
}

@keyframes ai-progress-indeterminate {
    0% { width: 0%; margin-left: 0%; }
    50% { width: 60%; margin-left: 20%; }
    100% { width: 0%; margin-left: 100%; }
}

/* ═══════════════════════════════════════════════════════════════
   LOADING TIPS
   ═══════════════════════════════════════════════════════════════ */
.ai-loader-tip {
    position: absolute;
    bottom: 15%;
    text-align: center;
    max-width: 400px;
    padding: 0 1.5rem;
}

.ai-loader-tip p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.ai-loader-tip .tip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--info-bg);
    color: var(--accent-primary);
    border-radius: 50%;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
}

[data-theme="dark"] .ai-loader-tip .tip-icon {
    background: rgba(0, 212, 255, 0.1);
}

/* Responsive */
@media (max-width: 640px) {
    .ai-brain-container {
        width: 140px;
        height: 140px;
    }

    .ai-brain-core {
        width: 55px;
        height: 55px;
    }

    .ai-brain-core svg {
        width: 28px;
        height: 28px;
    }

    .ai-loader-title {
        font-size: 1.25rem;
    }

    .ai-progress-container {
        width: 220px;
    }

    .ai-loader-tip {
        bottom: 10%;
    }
}

/* ═══════════════════════════════════════════════════════════════
   ADVANCED GRID - Selección de Filas
   ═══════════════════════════════════════════════════════════════ */

/* Columna de selección */
.col-select {
    text-align: center !important;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    padding: 0.5rem !important;
}

th.col-select {
    background: var(--bg-elevated);
}

[data-theme="dark"] th.col-select {
    background: var(--bg-elevated);
}

/* Checkbox personalizado */
.checkbox-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    width: 20px;
    height: 20px;
}

.checkbox-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    margin: 0;
    z-index: 2;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    background: var(--bg-surface);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.checkbox-wrapper:hover .checkmark {
    border-color: var(--accent-primary);
}

.checkbox-wrapper input[type="checkbox"]:checked ~ .checkmark {
    background: var(--accent-gradient);
    border-color: var(--accent-primary);
}

.checkmark::after {
    content: '';
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-wrapper input[type="checkbox"]:checked ~ .checkmark::after {
    display: block;
}

/* Estado indeterminado */
.checkbox-wrapper input[type="checkbox"]:indeterminate ~ .checkmark {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkbox-wrapper input[type="checkbox"]:indeterminate ~ .checkmark::after {
    display: block;
    left: 4px;
    top: 7px;
    width: 10px;
    height: 0;
    border: solid white;
    border-width: 0 0 2px 0;
    transform: rotate(0deg);
}

/* Master checkbox */
.master-checkbox .checkmark {
    background: var(--bg-elevated);
}

[data-theme="dark"] .checkmark {
    background: var(--bg-elevated);
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .checkbox-wrapper:hover .checkmark {
    border-color: var(--accent-primary);
}

[data-theme="dark"] .checkbox-wrapper input[type="checkbox"]:checked ~ .checkmark {
    background: var(--accent-gradient);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

/* Fila seleccionada */
tr.row-selected {
    background: var(--info-bg) !important;
}

tr.row-selected td {
    background: transparent !important;
}

tr.row-selected td.col-select {
    background: var(--info-bg) !important;
}

[data-theme="dark"] tr.row-selected {
    background: rgba(0, 212, 255, 0.08) !important;
}

[data-theme="dark"] tr.row-selected td.col-select {
    background: rgba(0, 212, 255, 0.08) !important;
}

/* Cursor clickeable en filas */
tbody tr {
    cursor: pointer;
}

tbody tr:active {
    background: var(--bg-hover);
}

/* ═══════════════════════════════════════════════════════════════
   Acciones de Selección (Contador + WhatsApp)
   ═══════════════════════════════════════════════════════════════ */
.selection-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    animation: selection-slide-in 0.3s var(--ease-out);
}

@keyframes selection-slide-in {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.selection-counter {
    font-size: 0.8125rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.selection-counter .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 0.375rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    margin-right: 0.25rem;
}

/* Botón WhatsApp */
.export-btn.export-whatsapp {
    background: #25D366;
    border-color: #25D366;
    color: white;
}

.export-btn.export-whatsapp:hover {
    background: #20BD5A;
    border-color: #20BD5A;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.selection-actions .export-btn.export-whatsapp {
    background: white;
    border-color: white;
    color: #25D366;
    padding: 0.375rem 0.75rem;
}

.selection-actions .export-btn.export-whatsapp:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Botón limpiar selección */
.selection-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.selection-clear:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.selection-clear svg {
    width: 12px;
    height: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .selection-actions {
        padding: 0.375rem 0.625rem;
        gap: 0.5rem;
    }

    .selection-counter {
        font-size: 0.75rem;
    }

    .selection-counter .count {
        min-width: 20px;
        height: 20px;
        font-size: 0.75rem;
    }

    .selection-actions .export-btn.export-whatsapp {
        padding: 0.3125rem 0.5rem;
        font-size: 0.6875rem;
    }

    .selection-actions .export-btn.export-whatsapp span {
        display: none;
    }
}

@media (max-width: 480px) {
    .col-select {
        width: 36px;
        min-width: 36px;
        max-width: 36px;
    }

    .checkbox-wrapper,
    .checkmark {
        width: 18px;
        height: 18px;
    }

    .checkmark::after {
        left: 5px;
        top: 1px;
        width: 4px;
        height: 9px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   FILTROS RÁPIDOS POR ESTADO
   ═══════════════════════════════════════════════════════════════ */
.quick-filters {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.quick-filters-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.25rem;
}

.quick-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.quick-filter-btn svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.quick-filter-btn:hover {
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

.quick-filter-btn:hover svg {
    opacity: 1;
}

/* Estado activo base */
.quick-filter-btn.active {
    border-color: var(--accent-primary);
    background: var(--info-bg);
    color: var(--accent-primary);
}

.quick-filter-btn.active svg {
    opacity: 1;
}

/* Colores por tipo de filtro */
.quick-filter-btn.filter-success:hover,
.quick-filter-btn.filter-success.active {
    border-color: var(--success);
    background: var(--success-bg);
    color: var(--success);
}

.quick-filter-btn.filter-info:hover,
.quick-filter-btn.filter-info.active {
    border-color: var(--info);
    background: var(--info-bg);
    color: var(--info);
}

.quick-filter-btn.filter-error:hover,
.quick-filter-btn.filter-error.active {
    border-color: var(--error);
    background: var(--error-bg);
    color: var(--error);
}

/* Tema oscuro */
[data-theme="dark"] .quick-filter-btn {
    background: var(--bg-elevated);
    border-color: var(--border-color);
}

[data-theme="dark"] .quick-filter-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .quick-filter-btn.active {
    background: rgba(0, 212, 255, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

[data-theme="dark"] .quick-filter-btn.filter-success.active {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
    color: #10b981;
}

[data-theme="dark"] .quick-filter-btn.filter-info.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
    color: #3b82f6;
}

[data-theme="dark"] .quick-filter-btn.filter-error.active {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
}

/* Badge contador en filtros */
.quick-filter-btn .filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 0.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    margin-left: 0.125rem;
}

.quick-filter-btn.active .filter-count {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 900px) {
    .quick-filters {
        order: 4;
        flex-basis: 100%;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border-color);
    }
}

@media (max-width: 640px) {
    .quick-filters {
        gap: 0.375rem;
    }

    .quick-filters-label {
        display: none;
    }

    .quick-filter-btn {
        padding: 0.3125rem 0.5rem;
        font-size: 0.6875rem;
    }

    .quick-filter-btn span {
        display: none;
    }

    .quick-filter-btn svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 400px) {
    .quick-filters {
        justify-content: center;
    }

    .quick-filter-btn {
        flex: 1;
        justify-content: center;
        max-width: 60px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   CONSULTAS DIRECTAS (En formulario de búsqueda)
   ═══════════════════════════════════════════════════════════════ */
.quick-access-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
}

.quick-access-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.quick-access-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.quick-access-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.quick-access-btn svg {
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.quick-access-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.quick-access-btn:hover svg {
    transform: scale(1.1);
}

/* Vigentes - Verde */
.quick-access-vigentes {
    border-color: var(--success);
    color: var(--success);
}

.quick-access-vigentes:hover {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.3);
}

/* Adjudicados - Azul */
.quick-access-adjudicados {
    border-color: var(--info);
    color: var(--info);
}

.quick-access-adjudicados:hover {
    background: var(--info);
    color: white;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.3);
}

/* Todos - Gris/Default */
.quick-access-todos {
    border-color: var(--text-muted);
    color: var(--text-secondary);
}

.quick-access-todos:hover {
    background: var(--text-secondary);
    color: white;
    box-shadow: 0 4px 15px rgba(71, 85, 105, 0.3);
}

/* Tema oscuro */
[data-theme="dark"] .quick-access-section {
    background: rgba(0, 0, 0, 0.2);
    border-color: var(--border-color);
}

[data-theme="dark"] .quick-access-btn {
    background: var(--bg-elevated);
}

[data-theme="dark"] .quick-access-vigentes {
    border-color: #10b981;
    color: #10b981;
}

[data-theme="dark"] .quick-access-vigentes:hover {
    background: #10b981;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

[data-theme="dark"] .quick-access-adjudicados {
    border-color: #3b82f6;
    color: #3b82f6;
}

[data-theme="dark"] .quick-access-adjudicados:hover {
    background: #3b82f6;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

[data-theme="dark"] .quick-access-todos:hover {
    background: var(--text-secondary);
    box-shadow: 0 4px 20px rgba(148, 163, 184, 0.3);
}

/* Responsive */
@media (max-width: 640px) {
    .quick-access-section {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.875rem;
    }

    .quick-access-label {
        font-size: 0.75rem;
    }

    .quick-access-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 400px) {
    .quick-access-buttons {
        width: 100%;
    }

    .quick-access-btn {
        flex: 1;
        justify-content: center;
        padding: 0.5rem;
    }

    .quick-access-btn span {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════
   COPY ICON - COLUMNA EXPEDIENTE
   ═══════════════════════════════════════════════════════════════ */
.expediente-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    position: relative;
}

.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.expediente-wrapper:hover .copy-btn {
    opacity: 0.5;
}

.copy-btn:hover {
    opacity: 1 !important;
    color: var(--accent-primary);
    background: var(--info-bg);
}

.copy-btn.copied {
    color: #16a34a;
}

.copy-tooltip {
    position: absolute;
    bottom: calc(100% + 0.35rem);
    left: 50%;
    transform: translateX(-50%) scale(0.85);
    background: #1e293b;
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    border-radius: 0.25rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 20;
}

.copy-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1e293b;
}

.copy-tooltip.visible {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

[data-theme="dark"] .copy-btn:hover {
    background: rgba(0, 212, 255, 0.1);
}

/* Dispositivos touch: el icono siempre visible (no hay hover) */
@media (hover: none) {
    .copy-btn {
        opacity: 0.4;
    }

    .copy-btn:active {
        opacity: 1;
        color: var(--accent-primary);
        background: var(--info-bg);
    }
}

/* Tablet (≤900px) */
@media (max-width: 900px) {
    .copy-btn {
        width: 1.375rem;
        height: 1.375rem;
    }

    .copy-btn svg {
        width: 12px;
        height: 12px;
    }
}

/* Móvil (≤640px) */
@media (max-width: 640px) {
    .expediente-wrapper {
        gap: 0.25rem;
    }

    .copy-btn {
        width: 1.25rem;
        height: 1.25rem;
    }

    .copy-btn svg {
        width: 11px;
        height: 11px;
    }

    .copy-tooltip {
        font-size: 0.625rem;
        padding: 0.2rem 0.45rem;
    }
}

/* Móvil pequeño (≤400px) */
@media (max-width: 400px) {
    .copy-btn {
        width: 1.125rem;
        height: 1.125rem;
    }

    .copy-btn svg {
        width: 10px;
        height: 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   COLUMNA URL ESTADO
   ═══════════════════════════════════════════════════════════════ */
.url-estado-header {
    width: 90px;
    text-align: center;
}

.url-estado-cell {
    text-align: center;
    width: 90px;
    padding: 0.75rem 0.5rem !important;
}

.url-estado-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    position: relative;
    overflow: hidden;
}

.url-estado-link::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.url-estado-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.5);
}

.url-estado-link:hover::before {
    opacity: 1;
}

.url-estado-link:active {
    transform: translateY(0);
}

.url-estado-link svg {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Animación de pulso sutil */
@keyframes url-pulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 2px 12px rgba(59, 130, 246, 0.5);
    }
}

.url-estado-link {
    animation: url-pulse 3s ease-in-out infinite;
}

.url-estado-link:hover {
    animation: none;
}

/* Tema verde corporativo */
[data-theme="green"] .url-estado-link {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

[data-theme="green"] .url-estado-link:hover {
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.5);
}

@keyframes url-pulse-green {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    }
    50% {
        box-shadow: 0 2px 12px rgba(16, 185, 129, 0.5);
    }
}

[data-theme="green"] .url-estado-link {
    animation: url-pulse-green 3s ease-in-out infinite;
}

/* Tema oscuro */
[data-theme="dark"] .url-estado-link {
    background: linear-gradient(135deg, #00d4ff 0%, #0284c7 100%);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
}

[data-theme="dark"] .url-estado-link:hover {
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.5);
}

@keyframes url-pulse-dark {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
    }
    50% {
        box-shadow: 0 2px 12px rgba(0, 212, 255, 0.5);
    }
}

[data-theme="dark"] .url-estado-link {
    animation: url-pulse-dark 3s ease-in-out infinite;
}

/* Responsive */
@media (max-width: 900px) {
    .url-estado-header {
        width: 70px;
    }

    .url-estado-cell {
        width: 70px;
        padding: 0.625rem 0.375rem !important;
    }

    .url-estado-link {
        width: 2rem;
        height: 2rem;
    }

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

@media (max-width: 640px) {
    .url-estado-header {
        width: 60px;
        font-size: 0.6875rem;
    }

    .url-estado-cell {
        width: 60px;
        padding: 0.5rem 0.25rem !important;
    }

    .url-estado-link {
        width: 1.75rem;
        height: 1.75rem;
    }

    .url-estado-link svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 400px) {
    .url-estado-header {
        width: 50px;
    }

    .url-estado-cell {
        width: 50px;
    }

    .url-estado-link {
        width: 1.5rem;
        height: 1.5rem;
    }

    .url-estado-link svg {
        width: 14px;
        height: 14px;
    }
}
