:root {
    --bg-base: #0b0d14;
    --bg-surface: rgba(22, 25, 37, 0.65);
    --bg-panel: rgba(30, 34, 48, 0.7);
    --primary: #4f46e5;
    --primary-hover: #6366f1;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #3b82f6;

    --sidebar-width: 260px;
    --topbar-height: 60px;
}

[data-theme="light"] {
    --bg-base: #f1f5f9;
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-panel: rgba(255, 255, 255, 0.9);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.08) 0%, transparent 40%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4 { color: var(--text-main); font-weight: 500; }
.text-muted { color: var(--text-muted); font-size: 0.9rem; }
.text-center { text-align: center; }

/* Utilities */
.hidden { display: none !important; }
.w-full { width: 100%; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Glassmorphism Classes */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--glass-shadow);
}

.card {
    padding: 1.5rem;
}

/* Topbar */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--topbar-height);
    background: rgba(11, 13, 20, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    z-index: 100;
}

[data-theme="light"] .topbar {
    background: rgba(255, 255, 255, 0.85);
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.topbar-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.simulated-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    background: var(--bg-panel);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.simulated-user select {
    background: transparent;
    color: var(--text-main);
    border: none;
    outline: none;
    font-family: inherit;
    cursor: pointer;
}
.simulated-user select option { background: var(--bg-base); }

.user-profile img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--primary);
}

/* App Container (Sidebar + Main) */
.app-container {
    display: flex;
    padding-top: var(--topbar-height);
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    height: calc(100vh - var(--topbar-height));
    background: rgba(22, 25, 37, 0.3);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    overflow-y: auto;
}

[data-theme="light"] .sidebar {
    background: rgba(255, 255, 255, 0.5);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.nav-links li:not(.section-title) {
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    border-right: 3px solid transparent;
}

.nav-links li:not(.section-title):hover,
.nav-links li.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-links li.active {
    border-right-color: var(--primary);
    background: linear-gradient(90deg, rgba(79,70,229,0) 0%, rgba(79,70,229,0.1) 100%);
}

.nav-links .section-title {
    padding: 1rem 1.5rem 0.3rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    max-width: 100%;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view.active {
    display: block;
}

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

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

.view-header h2 { font-size: 1.8rem; margin-bottom: 0.3rem; }

/* Dashboard Grids */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    padding: 1.5rem;
    border-radius: 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
}

.stat-card h4 { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.5rem; }
.stat-card .val { font-size: 2rem; font-weight: 700; color: var(--primary); }

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-success { background: var(--accent-success); color: white; }
.btn-success:hover { filter: brightness(1.1); }

.btn-danger { background: var(--accent-danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background: rgba(255,255,255,0.05); }

.btn-large { padding: 1rem; font-size: 1.1rem; }
.icon-btn { background: transparent; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }
.icon-btn:hover { color: var(--text-main); }

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

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th { color: var(--text-muted); font-weight: 500; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
}

.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="datetime-local"], select, textarea {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-family: inherit;
    transition: border-color 0.2s;
}

[data-theme="light"] input, [data-theme="light"] select, [data-theme="light"] textarea {
    background: rgba(0, 0, 0, 0.03);
}

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

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

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

.modal-content {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

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

.modal-footer {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed rgba(99, 102, 241, 0.4);
    text-align: center;
    padding: 4rem 2rem;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
}
.alert-info { background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.3); color: #60a5fa; }

/* Grid 2 */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* CRM Grid */
.crm-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 2rem;
    align-items: start;
}

.lead-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}

.tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    margin-bottom: 0.5rem;
}

.lead-placa {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-family: monospace;
    letter-spacing: 2px;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.lead-details {
    max-height: 50vh;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.detail-item {
    background: rgba(0,0,0,0.2);
    padding: 0.8rem;
    border-radius: 8px;
}

.detail-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.detail-item span {
    font-weight: 500;
}

/* Contact Types Radio Cards */
.contact-types {
    display: flex;
    gap: 1rem;
}

.radio-card {
    flex: 1;
    text-align: center;
    padding: 1rem 0.5rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-card input { display: none; }
.radio-card i { display: block; font-size: 1.5rem; margin-bottom: 0.5rem; color: var(--text-muted); }

.radio-card:has(input:checked) {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}
.radio-card:has(input:checked) i { color: var(--primary); }

[data-theme="light"] .radio-card {
    background: transparent;
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    min-height: 60vh;
}

.kanban-col {
    min-width: 280px;
    width: 280px;
    background: var(--bg-panel);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.col-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.col-header h3 { font-size: 1rem; }
.col-header .count {
    background: rgba(255,255,255,0.1);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.8rem;
}

.col-body {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.kanban-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 8px;
    cursor: grab;
    transition: transform 0.2s;
}
.kanban-card:active { cursor: grabbing; }

.kanban-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.2); }

.kanban-card h4 { margin-bottom: 0.3rem; font-size: 0.95rem; }
.kanban-card p { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.kanban-card .meta { 
    display: flex; 
    justify-content: space-between; 
    font-size: 0.75rem; 
    color: var(--text-muted);
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 0.5rem;
}

.drag-over {
    background: rgba(255,255,255,0.1);
}
