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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --bg-dark: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f1f5f9;
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────── */
.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    font-size: 20px;
    font-weight: 700;
}

.logo span {
    color: var(--primary-light);
}

.logo-subtitle {
    font-size: 11px;
    color: #94a3b8;
    letter-spacing: 2px;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
    font-weight: 500;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #94a3b8;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 2s infinite;
}

.dot.online {
    background: var(--success);
    animation: none;
}

.dot.offline {
    background: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ─── Main Content ───────────────────────── */
.main {
    margin-left: 240px;
    flex: 1;
    padding: 24px;
    max-width: calc(100vw - 240px);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* ─── Cards & Stats ──────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ─── Tables ─────────────────────────────── */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.table tr:hover {
    background: #f8fafc;
}

/* ─── Buttons ────────────────────────────── */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

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

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

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: #f8fafc;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

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

/* ─── Upload ─────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-card);
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}

.upload-zone input[type="file"] {
    display: none;
}

/* ─── Status Badges ──────────────────────── */
.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending { background: #fef3c7; color: #92400e; }
.status-running, .status-analyzing { background: #dbeafe; color: #1e40af; }
.status-completed, .status-success { background: #d1fae5; color: #065f46; }
.status-failed, .status-error { background: #fee2e2; color: #991b1b; }
.status-queued { background: #f3e8ff; color: #6b21a8; }
.status-conflict { background: #fef3c7; color: #92400e; }
.status-migrado { background: #d1fae5; color: #065f46; }
.status-importado { background: #dbeafe; color: #1e40af; }
.status-pendiente { background: #fef3c7; color: #92400e; }

/* ─── Assistant ───────────────────────────── */
.count-pill {
    display: inline-block;
    background: var(--bg-hover, #f1f5f9);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    margin: 2px 2px 2px 0;
    color: var(--text-muted);
    white-space: nowrap;
}

.count-pill.muted { opacity: 0.55; }

.chat-msg {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    max-width: 90%;
}

.chat-msg.user {
    background: var(--primary);
    color: #fff;
    margin: 6px 0 6px auto;
}

.chat-msg.bot {
    background: var(--bg-hover, #f1f5f9);
    border: 1px solid var(--border);
    color: var(--text);
    margin: 6px auto 6px 0;
}

.chat-msg.loading { display: flex; align-items: center; gap: 8px; }

/* ─── Progress Bar ───────────────────────── */
.progress {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ─── Conflict Display ───────────────────── */
.conflict-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-card);
}

.conflict-values {
    display: flex;
    gap: 12px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.conflict-value {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 13px;
}

.conflict-reasoning {
    font-size: 13px;
    color: var(--text-muted);
    margin: 8px 0;
    white-space: pre-wrap;
}

.conflict-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ─── Toast Notifications ────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--info);
    padding: 14px 20px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 14px;
    min-width: 280px;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ─── Loading ────────────────────────────── */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
}

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

/* ─── Responsive ─────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .sidebar .logo, .sidebar .logo-subtitle, .sidebar-footer, .nav-item span:not(.nav-icon) {
        display: none;
    }
    .main {
        margin-left: 60px;
        max-width: calc(100vw - 60px);
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ─── Miscellaneous ──────────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.field input, .field select, .field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}

.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
