/* ── inSpace CRM — app.css ─────────────────────────────────────── */

/* ── Custom properties (design tokens) ───────────────────────── */
:root {
    --crm-font-sans:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --crm-font-mono:        'JetBrains Mono', 'Courier New', monospace;

    /* Backgrounds */
    --crm-body-bg:          #F8FAFC;
    --crm-card-bg:          #FFFFFF;
    --crm-raised-bg:        #F1F5F9;

    /* Sidebar (dark) */
    --crm-sidebar-bg:       #1E293B;
    --crm-sidebar-hover:    #334155;
    --crm-sidebar-text:     #CBD5E1;
    --crm-sidebar-muted:    #94A3B8;
    --crm-sidebar-border:   #334155;

    /* Top nav */
    --crm-topnav-bg:        #1E293B;

    /* Palette */
    --crm-primary:          #0EA5E9;
    --crm-primary-dark:     #0284C7;
    --crm-primary-light:    #E0F2FE;

    --crm-success:          #16A34A;
    --crm-success-bg:       #DCFCE7;
    --crm-warning:          #D97706;
    --crm-warning-bg:       #FEF3C7;
    --crm-danger:           #DC2626;
    --crm-danger-bg:        #FEE2E2;
    --crm-info:             #7C3AED;
    --crm-info-bg:          #EDE9FE;
    --crm-cyan:             #0891B2;
    --crm-cyan-bg:          #CFFAFE;

    /* Borders & text */
    --crm-border:           #E2E8F0;
    --crm-border-strong:    #CBD5E1;
    --crm-text:             #0F172A;
    --crm-text-secondary:   #475569;
    --crm-text-muted:       #94A3B8;

    /* Module accent colors */
    --m-contacts:           #0D9488;
    --m-pipeline:           #0EA5E9;
    --m-conversations:      #7C3AED;
    --m-campaigns:          #0891B2;
    --m-workflows:          #8B5CF6;
    --m-calendar:           #16A34A;
    --m-forms:              #D97706;
    --m-funnels:            #EC4899;
    --m-phone:              #0EA5E9;
    --m-reputation:         #EAB308;
    --m-payments:           #16A34A;
    --m-social:             #6366F1;
    --m-reports:            #64748B;
    --m-settings:           #64748B;

    /* Layout */
    --crm-topnav-h:         60px;
    --crm-sidebar-w:        240px;
    --crm-sidebar-w-mini:   64px;

    /* Radii */
    --radius-sm:            4px;
    --radius-md:            8px;
    --radius-lg:            12px;
}

/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--crm-font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--crm-text);
    background: var(--crm-body-bg);
    -webkit-font-smoothing: antialiased;
}
.font-mono { font-family: var(--crm-font-mono) !important; font-feature-settings: 'tnum'; }

/* ── App shell ────────────────────────────────────────────────── */
.crm-topnav {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--crm-topnav-h); z-index: 1030;
    background: var(--crm-topnav-bg);
    border-bottom: 1px solid var(--crm-sidebar-border);
    display: flex; align-items: center; padding: 0 20px; gap: 12px;
}
.crm-topnav .brand {
    display: flex; align-items: center; gap: 10px;
    color: white; font-weight: 600; font-size: 15px;
    letter-spacing: 0.02em; text-decoration: none;
}
.crm-topnav .brand img { height: 22px; width: auto; }
.crm-topnav .brand-sep { opacity: 0.3; font-weight: 300; margin: 0 2px; }
.crm-topnav .brand-label { font-weight: 500; font-size: 13px; letter-spacing: 0.04em; opacity: 0.85; }

.crm-account-switcher {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; background: rgba(255,255,255,0.05);
    border: 1px solid var(--crm-sidebar-border);
    border-radius: var(--radius-md); cursor: pointer;
    color: var(--crm-sidebar-text); font-size: 13px;
}
.crm-account-switcher:hover { background: var(--crm-sidebar-hover); }
.crm-account-switcher .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--crm-success); flex-shrink: 0;
}

.crm-topnav-icon {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md); color: var(--crm-sidebar-text);
    cursor: pointer; position: relative; font-size: 16px;
    background: transparent; border: none;
}
.crm-topnav-icon:hover { background: var(--crm-sidebar-hover); color: white; }
.crm-topnav-icon .badge-count {
    position: absolute; top: 4px; right: 4px;
    background: var(--crm-danger); color: white;
    font-size: 9px; font-weight: 700;
    padding: 1px 4px; border-radius: 10px;
    min-width: 16px; text-align: center;
    font-family: var(--crm-font-mono);
}

.crm-topnav-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: #0D9488; color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 12px; cursor: pointer;
    border: none; flex-shrink: 0;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.crm-sidebar {
    position: fixed; top: var(--crm-topnav-h); left: 0; bottom: 0;
    width: var(--crm-sidebar-w); background: var(--crm-sidebar-bg);
    overflow-y: auto; overflow-x: hidden;
    border-right: 1px solid var(--crm-sidebar-border);
    transition: width .2s ease; z-index: 1020;
    display: flex; flex-direction: column;
}
.crm-sidebar.collapsed { width: var(--crm-sidebar-w-mini); }

.crm-sidebar-group { padding: 14px 0 6px; }
.crm-sidebar-group-label {
    padding: 0 20px 6px;
    font-size: 10px; font-weight: 600; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--crm-sidebar-muted);
    white-space: nowrap; overflow: hidden;
    transition: opacity .2s;
}
.crm-sidebar.collapsed .crm-sidebar-group-label { opacity: 0; pointer-events: none; }

.crm-sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 20px; color: var(--crm-sidebar-text);
    text-decoration: none; font-size: 13.5px;
    cursor: pointer; border-left: 2px solid transparent;
    white-space: nowrap; overflow: hidden;
    transition: background .12s, color .12s;
}
.crm-sidebar-link:hover { background: var(--crm-sidebar-hover); color: white; }
.crm-sidebar-link.active {
    background: var(--crm-sidebar-hover); color: white;
    border-left-color: var(--crm-primary);
}
.crm-sidebar-link .nav-icon {
    width: 16px; font-size: 16px;
    display: inline-flex; justify-content: center; flex-shrink: 0;
}
.crm-sidebar-link.active .nav-icon { color: var(--crm-primary); }
.crm-sidebar-link .nav-label { transition: opacity .2s, width .2s; }
.crm-sidebar.collapsed .crm-sidebar-link .nav-label { opacity: 0; width: 0; }
.crm-sidebar.collapsed .crm-sidebar-link { justify-content: center; padding: 9px; }
.crm-sidebar.collapsed .crm-sidebar-group-label { display: none; }

.crm-sidebar-badge {
    margin-left: auto; font-size: 11px;
    font-family: var(--crm-font-mono);
    color: var(--crm-sidebar-muted);
    background: rgba(255,255,255,0.04);
    padding: 1px 7px; border-radius: 10px;
    transition: opacity .2s;
}
.crm-sidebar.collapsed .crm-sidebar-badge { display: none; }

.crm-sidebar-footer {
    margin-top: auto; padding: 16px 20px;
    font-size: 11px; color: #64748B;
    border-top: 1px solid var(--crm-sidebar-border);
}
.crm-sidebar.collapsed .crm-sidebar-footer { display: none; }

/* ── Main content area ────────────────────────────────────────── */
.crm-main {
    margin-top: var(--crm-topnav-h);
    margin-left: var(--crm-sidebar-w);
    padding: 24px 32px 48px;
    min-height: calc(100vh - var(--crm-topnav-h));
    background: var(--crm-body-bg);
    transition: margin-left .2s ease;
}
.crm-main.sidebar-collapsed { margin-left: var(--crm-sidebar-w-mini); }

/* Density variants */
body[data-density="compact"] .crm-table tbody td { padding: 7px 12px; font-size: 12.5px; }
body[data-density="compact"] .crm-card { padding: 14px; }
body[data-density="comfortable"] .crm-table tbody td { padding: 16px 14px; }
body[data-density="comfortable"] .crm-card { padding: 24px; }

/* ── Breadcrumb ───────────────────────────────────────────────── */
.crm-breadcrumb {
    font-size: 12px; color: var(--crm-text-secondary);
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 14px;
}
.crm-breadcrumb a { color: var(--crm-text-secondary); text-decoration: none; }
.crm-breadcrumb a:hover { color: var(--crm-primary); }
.crm-breadcrumb .sep { color: var(--crm-text-muted); }
.crm-breadcrumb .current { color: var(--crm-text); font-weight: 500; }

/* ── Page header ──────────────────────────────────────────────── */
.crm-page-header {
    display: flex; align-items: flex-start;
    justify-content: space-between; gap: 16px;
    margin-bottom: 20px;
}
.crm-page-header h1 {
    margin: 0 0 4px; font-size: 24px; font-weight: 600;
    letter-spacing: -0.01em; line-height: 1.2;
}
.crm-page-subtitle { font-size: 13px; color: var(--crm-text-secondary); margin: 0; }
.crm-page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Cards ────────────────────────────────────────────────────── */
.crm-card {
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.crm-card.p-0 { padding: 0; }
.crm-card-header {
    display: flex; align-items: center;
    justify-content: space-between; margin-bottom: 14px;
}
.crm-card-title {
    font-size: 15px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}
.crm-card-title i { color: var(--crm-text-secondary); }

/* ── Metric cards ─────────────────────────────────────────────── */
.crm-metric-card {
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
}
.crm-metric-label { font-size: 12px; color: var(--crm-text-secondary); font-weight: 500; }
.crm-metric-value {
    font-size: 28px; font-weight: 600; margin-top: 4px;
    letter-spacing: -0.02em; font-family: var(--crm-font-mono);
}
.crm-metric-delta {
    font-size: 12px; margin-top: 6px;
    font-family: var(--crm-font-mono);
    display: inline-flex; align-items: center; gap: 4px;
}
.crm-metric-delta.up { color: var(--crm-success); }
.crm-metric-delta.down { color: var(--crm-danger); }
.crm-metric-hint { color: var(--crm-text-muted); margin-left: 4px; }

/* ── Grids ────────────────────────────────────────────────────── */
.crm-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.crm-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.crm-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-crm-primary,
.btn-crm-secondary,
.btn-crm-danger,
.btn-crm-ghost {
    display: inline-flex; align-items: center;
    justify-content: center; gap: 6px;
    padding: 8px 14px; font-size: 13px; font-weight: 500;
    font-family: var(--crm-font-sans);
    border-radius: var(--radius-md); border: 1px solid transparent;
    cursor: pointer; text-decoration: none;
    line-height: 1.2; white-space: nowrap;
    transition: background .12s, border-color .12s, color .12s;
}
.btn-crm-primary { background: var(--crm-primary); color: white; }
.btn-crm-primary:hover { background: var(--crm-primary-dark); color: white; }
.btn-crm-secondary {
    background: white; color: var(--crm-text);
    border-color: var(--crm-border-strong);
}
.btn-crm-secondary:hover { background: var(--crm-raised-bg); border-color: var(--crm-border-strong); color: var(--crm-text); }
.btn-crm-danger { background: var(--crm-danger); color: white; }
.btn-crm-danger:hover { background: #B91C1C; color: white; }
.btn-crm-ghost { background: transparent; color: var(--crm-text-secondary); border-color: transparent; }
.btn-crm-ghost:hover { background: var(--crm-raised-bg); color: var(--crm-text); }

.btn-sm { padding: 5px 10px !important; font-size: 12px !important; }
.btn-xs { padding: 3px 8px !important; font-size: 11px !important; }

.btn-crm-icon {
    width: 34px; height: 34px; border-radius: var(--radius-md);
    background: transparent; border: 1px solid transparent;
    color: var(--crm-text-secondary);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 15px;
    transition: background .12s, color .12s;
}
.btn-crm-icon:hover { background: var(--crm-raised-bg); color: var(--crm-text); }
.btn-crm-icon.bordered { border-color: var(--crm-border); background: white; }

/* ── Inputs ───────────────────────────────────────────────────── */
.crm-input,
.crm-select,
.crm-textarea {
    width: 100%; padding: 8px 12px;
    font-size: 13px; font-family: var(--crm-font-sans);
    background: white; border: 1px solid var(--crm-border);
    border-radius: var(--radius-md); color: var(--crm-text);
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.crm-input:focus,
.crm-select:focus,
.crm-textarea:focus {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.12);
}
.crm-input::placeholder,
.crm-textarea::placeholder { color: var(--crm-text-muted); }
.crm-textarea { resize: vertical; padding: 10px 12px; height: auto; }

.crm-label {
    display: block; font-size: 12px; font-weight: 500;
    margin-bottom: 6px; color: var(--crm-text-secondary);
}
.crm-form-group { margin-bottom: 16px; }

.crm-search-wrap { position: relative; }
.crm-search-wrap i {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--crm-text-muted); pointer-events: none;
}
.crm-search-wrap .crm-input { padding-left: 34px; }

/* ── Badges ───────────────────────────────────────────────────── */
.crm-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; font-size: 11px; font-weight: 600;
    border-radius: 10px; line-height: 1.5; white-space: nowrap;
}
.crm-badge-success { background: var(--crm-success-bg); color: #14532D; }
.crm-badge-warning { background: var(--crm-warning-bg); color: #78350F; }
.crm-badge-danger  { background: var(--crm-danger-bg);  color: #7F1D1D; }
.crm-badge-info    { background: var(--crm-info-bg);    color: #4C1D95; }
.crm-badge-primary { background: var(--crm-primary-light); color: #0C4A6E; }
.crm-badge-cyan    { background: var(--crm-cyan-bg); color: #164E63; }
.crm-badge-neutral { background: #F1F5F9; color: #334155; }

.crm-badge-live .dot,
.live-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--crm-cyan); animation: crm-pulse 1.4s infinite;
    display: inline-block;
}

/* ── Table ────────────────────────────────────────────────────── */
.crm-table { width: 100%; border-collapse: collapse; }
.crm-table thead th {
    text-align: left; padding: 10px 16px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--crm-text-secondary);
    border-bottom: 1px solid var(--crm-border);
    background: var(--crm-raised-bg); white-space: nowrap;
}
.crm-table tbody td {
    padding: 12px 16px; font-size: 13.5px;
    border-bottom: 1px solid var(--crm-border);
    color: var(--crm-text); vertical-align: middle;
}
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-table tbody tr:hover td { background: var(--crm-raised-bg); }
.crm-table .name-cell {
    font-weight: 500; color: var(--crm-primary); cursor: pointer;
}
.crm-table .name-cell:hover { text-decoration: underline; }

.crm-table-sortable th { cursor: pointer; user-select: none; }
.crm-table-sortable th:hover { color: var(--crm-text); }
.sort-icon { font-size: 9px; color: var(--crm-primary); margin-left: 2px; }

/* ── Avatars ──────────────────────────────────────────────────── */
.crm-avatar,
.crm-avatar-sm,
.crm-avatar-lg {
    border-radius: 50%; display: inline-flex;
    align-items: center; justify-content: center;
    font-weight: 600; color: white; flex-shrink: 0;
}
.crm-avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.crm-avatar    { width: 32px; height: 32px; font-size: 11px; }
.crm-avatar-lg { width: 64px; height: 64px; font-size: 22px; }

/* ── Timeline ─────────────────────────────────────────────────── */
.crm-timeline { list-style: none; padding: 0; margin: 0; }
.crm-timeline li {
    position: relative; padding: 12px 0 12px 28px;
    border-bottom: 1px solid var(--crm-border);
}
.crm-timeline li:last-child { border-bottom: none; }
.crm-timeline .tdot {
    position: absolute; left: 4px; top: 16px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--crm-primary);
    border: 2px solid var(--crm-card-bg);
    box-shadow: 0 0 0 1px var(--crm-border);
}
.crm-timeline .tdot.sms   { background: var(--crm-primary); }
.crm-timeline .tdot.email { background: var(--crm-info); }
.crm-timeline .tdot.call  { background: var(--crm-success); }
.crm-timeline .tdot.note  { background: var(--crm-warning); }
.crm-timeline .tdot.appt  { background: var(--crm-cyan); }
.crm-timeline .tmeta  { font-size: 11px; color: var(--crm-text-muted); font-family: var(--crm-font-mono); }
.crm-timeline .ttitle { font-size: 13px; font-weight: 500; margin: 2px 0; }
.crm-timeline .tbody  { font-size: 13px; color: var(--crm-text-secondary); }

/* ── Tabs ─────────────────────────────────────────────────────── */
.crm-tabs {
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--crm-border);
    margin-bottom: 16px;
}
.crm-tab {
    padding: 8px 14px; font-size: 13px; font-weight: 500;
    color: var(--crm-text-secondary); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    background: none; border-top: none; border-left: none; border-right: none;
    transition: color .12s, border-color .12s;
}
.crm-tab:hover { color: var(--crm-text); }
.crm-tab.active { color: var(--crm-primary); border-bottom-color: var(--crm-primary); }

/* ── Bulk action bar ──────────────────────────────────────────── */
.crm-bulk-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; margin-bottom: 12px;
    background: #0C4A6E; color: white;
    border-radius: var(--radius-md); font-size: 13px;
}
.crm-bulk-bar .btn-crm-secondary { background: rgba(255,255,255,0.15); color: white; border-color: rgba(255,255,255,0.3); }
.crm-bulk-bar .btn-crm-secondary:hover { background: rgba(255,255,255,0.25); }
.crm-bulk-close { margin-left: auto; background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer; font-size: 16px; }

/* ── Empty state ──────────────────────────────────────────────── */
.crm-empty-state { text-align: center; padding: 48px 24px; }
.crm-empty-icon {
    width: 56px; height: 56px; margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center;
    background: var(--crm-raised-bg); border-radius: 50%;
    color: var(--crm-text-muted); font-size: 24px;
}
.crm-empty-title { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.crm-empty-desc { font-size: 13px; color: var(--crm-text-secondary); margin: 0 0 16px; }

/* ── Skeleton loading ─────────────────────────────────────────── */
.crm-skeleton {
    background: linear-gradient(90deg, var(--crm-raised-bg) 25%, var(--crm-border) 50%, var(--crm-raised-bg) 75%);
    background-size: 200% 100%;
    animation: crm-shimmer 1.4s infinite;
    border-radius: var(--radius-sm);
}
@keyframes crm-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Pipeline Kanban ──────────────────────────────────────────── */
.crm-kanban {
    display: flex; gap: 12px;
    overflow-x: auto; padding-bottom: 8px;
}
.crm-kanban-col {
    width: 280px; flex-shrink: 0;
    background: var(--crm-raised-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--crm-border);
    display: flex; flex-direction: column;
}
.crm-kanban-header {
    padding: 12px 14px;
}
.crm-kanban-body {
    padding: 8px; flex: 1;
    display: flex; flex-direction: column; gap: 8px;
    min-height: 300px;
}
.crm-opp-card {
    background: white; border: 1px solid var(--crm-border);
    border-radius: var(--radius-md); padding: 12px;
    cursor: pointer; transition: box-shadow .12s, transform .12s;
}
.crm-opp-card:hover {
    box-shadow: 0 4px 12px rgba(15,23,42,0.08);
    transform: translateY(-1px);
}

/* ── Inbox / Conversations ────────────────────────────────────── */
.crm-inbox-grid {
    display: grid;
    grid-template-columns: 300px 1fr 280px;
    height: calc(100vh - 240px);
    overflow: hidden;
}
.crm-inbox-thread { background: #FCFCFD; }
.crm-msg-bubble-in,
.crm-msg-bubble-out {
    max-width: 70%; border-radius: var(--radius-lg);
    padding: 10px 14px; font-size: 13.5px; line-height: 1.45;
}
.crm-msg-bubble-in {
    background: white; border: 1px solid var(--crm-border);
    color: var(--crm-text);
}
.crm-msg-bubble-out {
    background: var(--crm-primary); color: white;
}
.crm-msg-note {
    background: #FEF3C7; border: 1px solid #FDE68A;
    border-radius: var(--radius-md); padding: 10px 14px;
    max-width: 520px; margin: 8px auto;
}

/* ── Dropdown menus ───────────────────────────────────────────── */
.crm-dropdown {
    position: absolute; background: white;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(15,23,42,0.18);
    z-index: 1050; overflow: hidden;
}
.crm-dropdown-item {
    padding: 8px 14px; font-size: 13px; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    color: var(--crm-text);
    transition: background .1s;
}
.crm-dropdown-item:hover { background: var(--crm-raised-bg); }
.crm-dropdown-item.danger { color: var(--crm-danger); }
.crm-dropdown-item.danger:hover { background: var(--crm-danger-bg); }
.crm-dropdown-divider { height: 1px; background: var(--crm-border); margin: 4px 0; }
.crm-dropdown-header {
    padding: 14px 16px; border-bottom: 1px solid var(--crm-border);
    display: flex; align-items: center; gap: 10px;
}

/* ── Modals ───────────────────────────────────────────────────── */
.crm-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 2000; display: flex;
    align-items: center; justify-content: center; padding: 20px;
}
.crm-modal {
    background: white; border-radius: var(--radius-lg);
    display: flex; flex-direction: column;
    overflow: hidden; max-height: 90vh;
    box-shadow: 0 24px 60px rgba(15,23,42,0.3);
    animation: crm-fade-in .15s ease;
}
.crm-modal-sm  { width: 440px; max-width: 100%; }
.crm-modal-md  { width: 560px; max-width: 100%; }
.crm-modal-lg  { width: 760px; max-width: 100%; }
.crm-modal-xl  { width: 960px; max-width: 100%; }
.crm-modal-header {
    padding: 18px 22px; border-bottom: 1px solid var(--crm-border);
    display: flex; align-items: flex-start; gap: 12px;
}
.crm-modal-header h5 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; }
.crm-modal-subtitle { font-size: 12px; color: var(--crm-text-secondary); margin-top: 2px; }
.crm-modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.crm-modal-footer {
    padding: 14px 22px; border-top: 1px solid var(--crm-border);
    display: flex; gap: 8px; justify-content: flex-end;
}

/* ── Toasts ───────────────────────────────────────────────────── */
#crmToastContainer {
    position: fixed; bottom: 24px; right: 24px;
    z-index: 9999; display: flex; flex-direction: column; gap: 8px;
    min-width: 280px; max-width: 360px;
}
.crm-toast {
    background: var(--crm-card-bg); border: 1px solid var(--crm-border);
    border-radius: var(--radius-md); padding: 12px 14px;
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; box-shadow: 0 8px 20px rgba(15,23,42,0.12);
    animation: crm-slide-in .2s ease;
}

/* ── Auth layout ──────────────────────────────────────────────── */
.crm-auth-page {
    min-height: 100vh; background: var(--crm-body-bg);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.crm-auth-card {
    width: 100%; max-width: 420px;
    background: white; border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg); padding: 36px 32px;
    box-shadow: 0 4px 24px rgba(15,23,42,0.08);
}
.crm-auth-logo {
    text-align: center; margin-bottom: 28px;
}
.crm-auth-logo img { height: 32px; }
.crm-auth-title {
    font-size: 22px; font-weight: 600; margin: 0 0 6px;
    text-align: center;
}
.crm-auth-subtitle {
    font-size: 13px; color: var(--crm-text-secondary);
    text-align: center; margin: 0 0 28px;
}
.crm-auth-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 20px 0; color: var(--crm-text-muted); font-size: 12px;
}
.crm-auth-divider::before,
.crm-auth-divider::after {
    content: ''; flex: 1; height: 1px;
    background: var(--crm-border);
}
.crm-auth-footer {
    text-align: center; margin-top: 20px;
    font-size: 13px; color: var(--crm-text-secondary);
}
.crm-auth-footer a { color: var(--crm-primary); text-decoration: none; }
.crm-auth-footer a:hover { text-decoration: underline; }

/* ── Settings layout ──────────────────────────────────────────── */
.crm-settings-layout {
    display: grid; grid-template-columns: 220px 1fr; gap: 24px;
}
.crm-settings-nav { display: flex; flex-direction: column; gap: 2px; }
.crm-settings-nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; font-size: 13px; font-weight: 500;
    color: var(--crm-text-secondary); cursor: pointer;
    border-radius: var(--radius-md); text-decoration: none;
    transition: background .1s, color .1s;
}
.crm-settings-nav-item:hover { background: var(--crm-raised-bg); color: var(--crm-text); }
.crm-settings-nav-item.active { background: var(--crm-primary-light); color: var(--crm-primary); }

/* ── Filter panel ─────────────────────────────────────────────── */
.crm-filter-panel {
    border-left: 3px solid var(--crm-primary);
    margin-bottom: 16px;
}

/* ── Row dropdown (3-dots menu) ───────────────────────────────── */
.crm-row-menu { position: relative; display: inline-block; }
.crm-row-menu-dropdown {
    position: absolute; right: 0; top: 100%;
    margin-top: 4px; min-width: 180px;
    background: white; border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(15,23,42,0.14);
    z-index: 100; overflow: hidden;
}

/* ── Notification dropdown ────────────────────────────────────── */
.crm-notif-dropdown {
    top: calc(100% + 8px); right: 0; width: 380px;
}
.crm-notif-item {
    display: flex; gap: 12px; padding: 12px 16px;
    border-bottom: 1px solid var(--crm-border);
    cursor: pointer; position: relative;
    transition: background .1s;
}
.crm-notif-item:hover { background: var(--crm-raised-bg); }
.crm-notif-item.unread { background: rgba(14,165,233,0.04); }
.crm-notif-unread-dot {
    position: absolute; left: 6px; top: 20px;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--crm-primary);
}
.crm-notif-icon {
    width: 32px; height: 32px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ── Progress bar ─────────────────────────────────────────────── */
.crm-progress { height: 8px; background: var(--crm-raised-bg); border-radius: 4px; overflow: hidden; }
.crm-progress-bar { height: 100%; border-radius: 4px; transition: width .3s ease; }

/* ── Toggle switch ────────────────────────────────────────────── */
.crm-toggle {
    position: relative; display: inline-block; width: 40px; height: 22px;
}
.crm-toggle input { opacity: 0; width: 0; height: 0; }
.crm-toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--crm-border-strong); border-radius: 22px;
    transition: .2s;
}
.crm-toggle-slider:before {
    position: absolute; content: '';
    height: 16px; width: 16px; left: 3px; bottom: 3px;
    background: white; border-radius: 50%; transition: .2s;
}
.crm-toggle input:checked + .crm-toggle-slider { background: var(--crm-primary); }
.crm-toggle input:checked + .crm-toggle-slider:before { transform: translateX(18px); }

/* ── View toggle (board/list/forecast) ───────────────────────── */
.crm-view-toggle {
    display: inline-flex;
    border: 1px solid var(--crm-border); border-radius: var(--radius-md);
    overflow: hidden;
}
.crm-view-toggle .btn-crm-secondary { border-radius: 0; border: none; }
.crm-view-toggle .btn-crm-secondary:not(:first-child) { border-left: 1px solid var(--crm-border); }
.crm-view-toggle .btn-crm-primary { border-radius: 0; }

/* ── Workflow builder canvas ──────────────────────────────────── */
.crm-workflow-canvas {
    background: #0F172A; border-radius: var(--radius-lg);
    min-height: 500px; position: relative; overflow: hidden;
}

/* ── Utility helpers ──────────────────────────────────────────── */
.text-primary   { color: var(--crm-primary) !important; }
.text-success   { color: var(--crm-success) !important; }
.text-warning   { color: var(--crm-warning) !important; }
.text-danger    { color: var(--crm-danger) !important; }
.text-muted     { color: var(--crm-text-muted) !important; }
.text-secondary { color: var(--crm-text-secondary) !important; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes crm-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.45; transform: scale(1.35); }
}
@keyframes crm-slide-in {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: none; }
}
@keyframes crm-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
.crm-fade-in { animation: crm-fade-in .2s ease; }

/* ── Scrollbars ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--crm-border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--crm-text-muted); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1199px) {
    .crm-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 991px) {
    .crm-sidebar { width: var(--crm-sidebar-w-mini); }
    .crm-main    { margin-left: var(--crm-sidebar-w-mini); }
    .crm-grid-3  { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 767px) {
    .crm-grid-4, .crm-grid-3, .crm-grid-2 { grid-template-columns: 1fr; }
    .crm-main { padding: 16px; }
    .crm-page-header { flex-direction: column; align-items: stretch; }
    .crm-inbox-grid { grid-template-columns: 1fr; }
}
