:root {
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --accent: #2563eb;
    --accent-light: #dbeafe;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: all .2s ease;
}

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

html, body { font-family: var(--font); font-size: 14px; color: var(--text-primary); background: var(--body-bg); min-height: 100vh; -webkit-font-smoothing: antialiased; }

/* Login Page */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%); position: relative; overflow: hidden; }
.login-wrapper::before { content: ''; position: absolute; width: 600px; height: 600px; background: radial-gradient(circle, rgba(37,99,235,.15), transparent 70%); top: -200px; right: -200px; }
.login-wrapper::after { content: ''; position: absolute; width: 400px; height: 400px; background: radial-gradient(circle, rgba(6,182,212,.1), transparent 70%); bottom: -100px; left: -100px; }
.login-card { background: rgba(255,255,255,.03); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,.08); border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 420px; position: relative; z-index: 1; }
.login-brand { text-align: center; margin-bottom: 36px; }
.login-brand .brand-icon { width: 56px; height: 56px; background: var(--accent); border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 24px; margin-bottom: 16px; }
.login-brand h1 { color: #fff; font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-brand p { color: rgba(255,255,255,.5); font-size: 13px; }
.login-card .form-label { color: rgba(255,255,255,.6); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.login-card .form-control { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); color: #fff; border-radius: 10px; padding: 12px 16px; font-size: 14px; transition: var(--transition); }
.login-card .form-control:focus { background: rgba(255,255,255,.08); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.2); color: #fff; }
.login-card .form-control::placeholder { color: rgba(255,255,255,.3); }
.login-card .btn-primary { width: 100%; padding: 12px; border-radius: 10px; font-weight: 600; font-size: 15px; background: var(--accent); border: none; transition: var(--transition); }
.login-card .btn-primary:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(37,99,235,.4); }
.login-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

/* Sidebar */
.crm-wrapper { display: flex; min-height: 100vh; }
.crm-sidebar { width: var(--sidebar-width); background: var(--sidebar-bg); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 1000; transition: transform .3s ease; }
.sidebar-brand { padding: 20px 20px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-icon { width: 40px; height: 40px; background: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; flex-shrink: 0; }
.brand-text { flex: 1; overflow: hidden; }
.brand-name { display: block; color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { display: block; color: var(--sidebar-text); font-size: 11px; }
.sidebar-toggle { background: none; border: none; color: var(--sidebar-text); font-size: 18px; cursor: pointer; padding: 4px; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: var(--sidebar-text); text-decoration: none; border-radius: 8px; margin-bottom: 2px; font-weight: 500; font-size: 13px; transition: var(--transition); }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.sidebar-nav .nav-link i { width: 20px; text-align: center; font-size: 15px; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.06); display: flex; align-items: center; gap: 10px; }
.user-info { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.user-details { overflow: hidden; }
.user-name { display: block; color: #e2e8f0; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; color: var(--sidebar-text); font-size: 11px; }
.btn-logout { background: rgba(255,255,255,.06); border: none; color: var(--sidebar-text); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; }
.btn-logout:hover { background: rgba(239,68,68,.15); color: #ef4444; }

/* Main Content */
.crm-main { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }
.crm-topbar { height: var(--topbar-height); background: var(--card-bg); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 100; }
.topbar-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-date { color: var(--text-secondary); font-size: 13px; }
.crm-content { flex: 1; padding: 24px; }

/* Cards */
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 20px; border: 1px solid var(--border-color); transition: var(--transition); }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 14px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-card .stat-label { color: var(--text-secondary); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }

.card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { background: transparent; border-bottom: 1px solid var(--border-color); padding: 16px 20px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }

/* Tables */
.table-responsive { border-radius: var(--radius); overflow: hidden; }
.table { margin-bottom: 0; }
.table thead th { background: #f8fafc; border-bottom: 2px solid var(--border-color); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); padding: 12px 16px; white-space: nowrap; }
.table tbody td { padding: 12px 16px; vertical-align: middle; border-color: var(--border-color); font-size: 13px; }
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: #f8fafc; }

/* Status badges */
.badge-status { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; display: inline-block; }

/* Buttons */
.btn { font-weight: 500; font-size: 13px; border-radius: var(--radius-sm); padding: 8px 16px; transition: var(--transition); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; transform: translateY(-1px); }
.btn-outline-primary { color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); }
.btn-action { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; font-size: 13px; }

/* Forms */
.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--border-color); padding: 9px 14px; font-size: 13px; transition: var(--transition); }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-label { font-weight: 500; font-size: 13px; margin-bottom: 4px; color: var(--text-primary); }

/* Filters */
.filter-bar { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; }
.filter-bar .form-control, .filter-bar .form-select { font-size: 12px; padding: 7px 12px; }

/* Timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 0; bottom: 0; width: 2px; background: var(--border-color); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before { content: ''; position: absolute; left: -23px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--border-color); }
.timeline-item.created::before { background: var(--success); }
.timeline-item.status::before { background: var(--warning); }
.timeline-item.note::before { background: var(--info); }
.timeline-item.call::before { background: #8b5cf6; }
.timeline-item.meeting::before { background: #ec4899; }
.timeline-item.followup::before { background: var(--warning); }
.timeline-item.assigned::before { background: #f97316; }
.timeline-date { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.timeline-text { font-size: 13px; color: var(--text-primary); }
.timeline-text strong { font-weight: 600; }

/* Import steps */
.import-steps { display: flex; gap: 0; margin-bottom: 32px; }
.import-step { flex: 1; text-align: center; position: relative; padding: 16px 8px 0; }
.import-step::before { content: ''; position: absolute; top: 28px; left: 0; right: 0; height: 3px; background: var(--border-color); }
.import-step:first-child::before { left: 50%; }
.import-step:last-child::before { right: 50%; }
.import-step .step-num { width: 36px; height: 36px; border-radius: 50%; background: var(--body-bg); border: 2px solid var(--border-color); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; position: relative; z-index: 1; color: var(--text-muted); margin-bottom: 8px; }
.import-step.active .step-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.import-step.done .step-num { background: var(--success); border-color: var(--success); color: #fff; }
.import-step .step-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); }
.import-step.active .step-label, .import-step.done .step-label { color: var(--text-primary); }

/* Mapping table */
.mapping-row { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--border-color); }
.mapping-row:last-child { border-bottom: none; }
.mapping-from { flex: 1; font-weight: 500; font-size: 13px; }
.mapping-arrow { color: var(--text-muted); }
.mapping-to { flex: 1; }

/* Stats colors */
.bg-blue-light { background: rgba(37,99,235,.1); color: var(--accent); }
.bg-green-light { background: rgba(16,185,129,.1); color: var(--success); }
.bg-orange-light { background: rgba(245,158,11,.1); color: var(--warning); }
.bg-red-light { background: rgba(239,68,68,.1); color: var(--danger); }
.bg-cyan-light { background: rgba(6,182,212,.1); color: var(--info); }
.bg-purple-light { background: rgba(139,92,246,.1); color: #8b5cf6; }
.bg-pink-light { background: rgba(236,72,153,.1); color: #ec4899; }
.bg-teal-light { background: rgba(20,184,166,.1); color: #14b8a6; }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state h5 { color: var(--text-secondary); margin-bottom: 8px; }

/* Lead detail */
.lead-detail-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 600; margin-bottom: 2px; }
.lead-detail-value { font-size: 14px; font-weight: 500; color: var(--text-primary); }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; }

/* Modal */
.modal-header { border-bottom: 1px solid var(--border-color); }
.modal-footer { border-top: 1px solid var(--border-color); }
.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lg); }

/* Responsive */
@media (max-width: 991.98px) {
    .crm-sidebar { transform: translateX(-100%); }
    .crm-sidebar.open { transform: translateX(0); }
    .crm-main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex !important; }
}
@media (min-width: 992px) {
    .sidebar-toggle { display: none !important; }
}
@media (max-width: 767.98px) {
    .crm-content { padding: 16px; }
    .stat-card .stat-value { font-size: 22px; }
}

/* Scrollbar */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

/* Loading spinner */
.spinner-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; z-index: 9999; }

/* Quick actions dropdown */
.dropdown-menu { border: 1px solid var(--border-color); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 4px; }
.dropdown-item { font-size: 13px; padding: 6px 12px; border-radius: 4px; }
.dropdown-item:hover { background: var(--body-bg); }
.dropdown-item i { width: 18px; }

/* File upload area */
.upload-area { border: 2px dashed var(--border-color); border-radius: var(--radius); padding: 48px 24px; text-align: center; transition: var(--transition); cursor: pointer; }
.upload-area:hover, .upload-area.dragover { border-color: var(--accent); background: var(--accent-light); }
.upload-area i { font-size: 42px; color: var(--text-muted); margin-bottom: 12px; }
.upload-area h5 { margin-bottom: 4px; }
.upload-area p { color: var(--text-muted); font-size: 13px; }

/* Preview table */
.preview-table { font-size: 12px; }
.preview-table th { font-size: 11px; }
