/* ============================================================
   FLUXLABS CRM — Design System & Complete Styles
   ============================================================ */

/* ---------- CSS Custom Properties (Theming) ---------- */
:root {
    /* Core palette */
    --primary: #6C5CE7;
    --primary-light: #a29bfe;
    --primary-dark: #4834d4;
    --accent: #00cec9;
    --accent-light: #81ecec;

    /* Semantic */
    --success: #00b894;
    --success-light: #55efc4;
    --warning: #fdcb6e;
    --warning-dark: #e17055;
    --danger: #ff6b6b;
    --danger-light: #fab1a0;
    --info: #74b9ff;

    /* Surfaces — dark mode default */
    --bg-body: #0a0a1a;
    --bg-sidebar: #0f0f23;
    --bg-surface: #151528;
    --bg-card: #1a1a36;
    --bg-card-hover: #222248;
    --bg-input: #1e1e3a;
    --bg-modal: #181833;

    /* Borders */
    --border: rgba(255,255,255,0.06);
    --border-light: rgba(255,255,255,0.1);

    /* Text */
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f0f23;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 20px rgba(108,92,231,0.15);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4,0,0.2,1);
}

/* Light theme */
[data-theme="light"] {
    --bg-body: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-input: #f1f5f9;
    --bg-modal: #ffffff;
    --border: rgba(0,0,0,0.08);
    --border-light: rgba(0,0,0,0.12);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --shadow-glow: 0 0 20px rgba(108,92,231,0.08);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width var(--transition-slow), transform var(--transition-slow);
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.2rem; color: #fff;
    flex-shrink: 0;
}

.brand-text {
    font-weight: 700; font-size: 1.25rem;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    position: relative;
    font-weight: 500;
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(108,92,231,0.15), rgba(0,206,201,0.08));
    color: var(--primary-light);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 24px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.nav-item .material-icons-round { font-size: 1.35rem; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    min-width: 20px;
    text-align: center;
}

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; color: #fff;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-weight: 600; font-size: 0.88rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem; color: var(--text-muted);
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

/* ---------- Top Bar ---------- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
}

.menu-toggle {
    display: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.menu-toggle:hover { background: var(--bg-card); }

.search-box {
    flex: 1;
    max-width: 480px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 16px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.12);
}

.search-box .material-icons-round {
    color: var(--text-muted); font-size: 1.2rem;
}

.search-box input {
    flex: 1; border: none; background: transparent;
    padding: 10px 0; outline: none;
    font-size: 0.9rem;
}

.search-box input::placeholder { color: var(--text-muted); }

.topbar-actions {
    display: flex; align-items: center; gap: 4px; margin-left: auto;
}

.topbar-btn {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    position: relative;
}

.topbar-btn:hover { background: var(--bg-card); }

.notif-dot {
    position: absolute; top: 8px; right: 8px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    display: none;
}

.notif-dot.show { display: block; }

/* ---------- Content Area ---------- */
.content-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.section { display: none; animation: fadeIn 0.3s ease; }
.section.active { display: block; }

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

/* ---------- Section Headers ---------- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.section-title span {
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn .material-icons-round { font-size: 1.1rem; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 2px 8px rgba(108,92,231,0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(108,92,231,0.4);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
}

.btn-secondary:hover { background: var(--bg-card-hover); }

.btn-success {
    background: linear-gradient(135deg, var(--success), #00a884);
    color: #fff;
}

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

.btn-danger:hover { background: #e55656; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); }

.btn-sm { padding: 7px 14px; font-size: 0.82rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

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

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

.stat-icon.purple { background: rgba(108,92,231,0.15); color: var(--primary-light); }
.stat-icon.green  { background: rgba(0,184,148,0.15); color: var(--success-light); }
.stat-icon.blue   { background: rgba(116,185,255,0.15); color: var(--info); }
.stat-icon.orange { background: rgba(253,203,110,0.15); color: var(--warning); }
.stat-icon.red    { background: rgba(255,107,107,0.15); color: var(--danger); }
.stat-icon.cyan   { background: rgba(0,206,201,0.15); color: var(--accent-light); }

.stat-info { flex: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; }
.stat-change { font-size: 0.78rem; color: var(--success); margin-top: 4px; }
.stat-change.down { color: var(--danger); }

/* ---------- Table ---------- */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.table-title { font-weight: 700; font-size: 1rem; }

.table-filters {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.filter-btn:hover, .filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 12px 20px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    transition: background var(--transition-fast);
}

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

tbody td {
    padding: 14px 20px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

/* ---------- Badges / Tags ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary { background: rgba(108,92,231,0.15); color: var(--primary-light); }
.badge-success { background: rgba(0,184,148,0.15); color: var(--success-light); }
.badge-warning { background: rgba(253,203,110,0.15); color: var(--warning); }
.badge-danger  { background: rgba(255,107,107,0.15); color: var(--danger-light); }
.badge-info    { background: rgba(116,185,255,0.15); color: var(--info); }
.badge-muted   { background: rgba(100,116,139,0.15); color: var(--text-muted); }

.priority-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.priority-dot.high   { background: var(--danger); }
.priority-dot.medium { background: var(--warning); }
.priority-dot.low    { background: var(--success); }

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.12);
}

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

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-check {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.88rem; cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-overlay.open {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1.15rem; font-weight: 700; }

.modal-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.modal-close:hover { background: var(--bg-card); }
.modal-close .material-icons-round { font-size: 1.2rem; }

.modal-body { padding: 24px; }

.modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    bottom: 24px; right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 300;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    animation: toastIn 0.4s cubic-bezier(0.4,0,0.2,1);
    pointer-events: auto;
    font-size: 0.9rem;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--info); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ---------- Kanban Board (Tasks) ---------- */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.kanban-column {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.kanban-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.kanban-col-title {
    font-weight: 700;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kanban-col-count {
    width: 24px; height: 24px;
    background: var(--bg-input);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
}

.kanban-col-body {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: 60vh;
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.kanban-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.kanban-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.kanban-card-subject {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(108,92,231,0.12);
    color: var(--primary-light);
    margin-bottom: 8px;
    display: inline-block;
}

.kanban-card-deadline {
    display: flex; align-items: center; gap: 4px;
}

.kanban-card-deadline .material-icons-round { font-size: 0.85rem; }

.kanban-card-deadline.overdue { color: var(--danger); }
.kanban-card-deadline.soon { color: var(--warning); }

.kanban-card-assignee {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; color: #fff;
}

/* ---------- Planning Calendar ---------- */
.planning-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

.planning-day-header {
    background: var(--bg-card);
    padding: 10px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.planning-day {
    background: var(--bg-surface);
    min-height: 100px;
    padding: 8px;
    position: relative;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.planning-day:hover { background: var(--bg-card); }
.planning-day.other-month { opacity: 0.3; }
.planning-day.today { background: rgba(108,92,231,0.08); }

.planning-day-num {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.planning-day.today .planning-day-num {
    color: var(--primary-light);
    font-weight: 700;
}

.planning-event {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.planning-event.task   { background: rgba(108,92,231,0.2); color: var(--primary-light); }
.planning-event.meet   { background: rgba(0,206,201,0.2); color: var(--accent-light); }
.planning-event.deadline { background: rgba(255,107,107,0.2); color: var(--danger-light); }

.planning-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.planning-month {
    font-size: 1.2rem;
    font-weight: 700;
    min-width: 200px;
}

/* ---------- Leads Pipeline ---------- */
.leads-pipeline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.lead-stage {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-height: 200px;
}

.lead-stage-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lead-stage-title {
    font-weight: 700;
    font-size: 0.88rem;
}

.lead-stage-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lead-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lead-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.lead-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.lead-card-company {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.lead-card-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--success);
}

.lead-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.lead-card-source {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(116,185,255,0.12);
    color: var(--info);
}

/* ---------- Chat ---------- */
.chat-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    height: calc(100vh - var(--topbar-height) - 80px);
    overflow: hidden;
}

.chat-sidebar {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.chat-sidebar-header h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.chat-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
}

.chat-search .material-icons-round { font-size: 1rem; color: var(--text-muted); }

.chat-search input {
    flex: 1; border: none; background: transparent;
    padding: 8px 0; outline: none; font-size: 0.85rem;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-contact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border);
}

.chat-contact:hover { background: var(--bg-card-hover); }
.chat-contact.active { background: rgba(108,92,231,0.1); }

.chat-contact-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; color: #fff;
    flex-shrink: 0;
}

.chat-contact-info { flex: 1; overflow: hidden; }

.chat-contact-name {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat-contact-preview {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat-contact-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.chat-main {
    display: flex;
    flex-direction: column;
}

.chat-main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.chat-main-name { font-weight: 700; font-size: 0.95rem; }
.chat-main-status { font-size: 0.78rem; color: var(--success); }

.chat-main-actions {
    margin-left: auto;
    display: flex; gap: 4px;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    display: flex;
    gap: 10px;
    max-width: 70%;
}

.chat-msg.sent {
    margin-left: auto;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.chat-msg-bubble {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.chat-msg.sent .chat-msg-bubble {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
}

.chat-msg-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.chat-msg.sent .chat-msg-time { text-align: right; }

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.chat-input-area input {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    font-size: 0.9rem;
    transition: border-color var(--transition-fast);
}

.chat-input-area input:focus {
    border-color: var(--primary);
}

.chat-send-btn {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    transition: all var(--transition-fast);
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 12px rgba(108,92,231,0.4);
}

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    color: var(--text-muted);
}

.chat-empty .material-icons-round { font-size: 3rem; opacity: 0.3; }

/* ---------- Files ---------- */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.file-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.file-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.file-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.8;
}

.file-icon.pdf  { color: var(--danger); }
.file-icon.doc  { color: var(--info); }
.file-icon.img  { color: var(--success); }
.file-icon.xls  { color: #27ae60; }
.file-icon.zip  { color: var(--warning); }
.file-icon.other { color: var(--text-muted); }

.file-name {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    margin-bottom: 20px;
}

.file-upload-zone:hover {
    border-color: var(--primary);
    background: rgba(108,92,231,0.04);
}

.file-upload-zone .material-icons-round {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.file-upload-zone p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.file-upload-zone span {
    color: var(--primary-light);
    font-weight: 600;
}

/* ---------- Meetings ---------- */
.meetings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.meeting-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-normal);
}

.meeting-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.meeting-time-box {
    width: 64px;
    text-align: center;
    flex-shrink: 0;
}

.meeting-date {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-light);
}

.meeting-month {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.meeting-info { flex: 1; }

.meeting-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

.meeting-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.meeting-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.meeting-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.meeting-meta .material-icons-round { font-size: 0.95rem; }

.meeting-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-meet {
    background: linear-gradient(135deg, var(--accent), #00a8a3);
    color: #fff;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast);
}

.btn-meet:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,206,201,0.3);
}

/* ---------- Settings ---------- */
.settings-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
}

.settings-nav {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    align-self: start;
    position: sticky;
    top: calc(var(--topbar-height) + 24px);
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.settings-nav-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.settings-nav-item.active { background: rgba(108,92,231,0.12); color: var(--primary-light); }
.settings-nav-item .material-icons-round { font-size: 1.15rem; }

.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
}

.settings-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all var(--transition-fast);
    position: relative;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--primary); }

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 0.82rem;
    font-weight: 500;
}

.tag-remove {
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    transition: background var(--transition-fast);
}

.tag-remove:hover { background: var(--danger); color: #fff; }

/* ---------- Empty State ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state .material-icons-round {
    font-size: 4rem;
    color: var(--text-muted);
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.88rem;
    color: var(--text-muted);
    max-width: 400px;
    margin-bottom: 20px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .settings-grid { grid-template-columns: 1fr; }
    .settings-nav { position: static; }
    .chat-layout { grid-template-columns: 220px 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .sidebar.open { transform: translateX(0); }

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

    .menu-toggle { display: flex; }

    .content-area { padding: 16px; }

    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

    .kanban-board { grid-template-columns: 1fr; }

    .chat-layout {
        grid-template-columns: 1fr;
        height: calc(100vh - var(--topbar-height) - 48px);
    }

    .chat-sidebar { display: none; }
    .chat-sidebar.active { display: flex; }

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

    .leads-pipeline { grid-template-columns: 1fr; }

    .meeting-card { flex-direction: column; align-items: flex-start; }

    .table-container { overflow-x: auto; }
}

/* ---------- Dashboard Recent Activity ---------- */
.activity-list {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.activity-icon .material-icons-round { font-size: 1rem; }

.activity-text {
    font-size: 0.88rem;
    line-height: 1.5;
}

.activity-text strong { font-weight: 600; }

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---------- Dashboard Grid ---------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

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

.progress-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.6s ease;
}

/* ---------- Task Detail View ---------- */
.task-detail {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
}

.task-detail-main { display: flex; flex-direction: column; gap: 16px; }

.task-detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.detail-field-label { color: var(--text-muted); font-weight: 500; }
.detail-field-value { font-weight: 600; }

@media (max-width: 768px) {
    .task-detail { grid-template-columns: 1fr; }
}

/* ---------- View Toggler ---------- */
.view-toggle {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-toggle-btn {
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.view-toggle-btn .material-icons-round { font-size: 1rem; }

.view-toggle-btn:hover { color: var(--text-primary); }

.view-toggle-btn.active {
    background: var(--primary);
    color: #fff;
}

/* ---------- Utility ---------- */
.text-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
