/* ==========================================================================
   Dysart Capital - Enterprise CRM Theme
   Inspired by HubSpot, Pipedrive, Salesforce Lightning
   ========================================================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 64px;
    --crm-primary: #0176d3;
    --crm-primary-hover: #014486;
    --crm-accent: #1b96ff;
    --crm-success: #2e844a;
    --crm-warning: #fe9339;
    --crm-danger: #ea001e;
    --crm-radius: 10px;
    --crm-radius-lg: 14px;
    --crm-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --crm-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --crm-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --crm-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --crm-bg: #f4f6f9;
    --crm-surface: #ffffff;
    --crm-border: #e2e8f0;
    --crm-text: #1a202c;
    --crm-text-muted: #64748b;
    --crm-sidebar-bg: #0f172a;
    --crm-sidebar-text: #94a3b8;
    --crm-sidebar-active: #ffffff;
    --crm-sidebar-hover: rgba(255, 255, 255, 0.06);
    --crm-sidebar-active-bg: rgba(1, 118, 211, 0.2);
}

[data-bs-theme="dark"] {
    --crm-bg: #0b1120;
    --crm-surface: #111827;
    --crm-border: #1e293b;
    --crm-text: #f1f5f9;
    --crm-text-muted: #94a3b8;
    --crm-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --crm-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --crm-sidebar-bg: #020617;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: var(--crm-bg);
    color: var(--crm-text);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ---- Layout Wrapper ---- */
.crm-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.crm-body {
    display: flex;
    flex: 1;
    margin-top: var(--topbar-height);
}

.crm-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 1.5rem;
    min-height: calc(100vh - var(--topbar-height));
    transition: margin-left var(--crm-transition);
    max-width: 100%;
}

.sidebar-collapsed .crm-main {
    margin-left: var(--sidebar-collapsed-width);
}

/* ---- Top Bar ---- */
.crm-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--crm-surface);
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 1040;
    box-shadow: var(--crm-shadow);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--crm-text);
    font-weight: 700;
    font-size: 1.125rem;
    margin-left: 0.5rem;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--crm-primary), var(--crm-accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.125rem;
}

.topbar-search {
    flex: 1;
    max-width: 480px;
    margin: 0 2rem;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box .global-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    box-shadow: var(--crm-shadow-lg, 0 12px 32px rgba(15, 23, 42, 0.12));
    background: var(--crm-surface);
}

.search-box i {
    position: absolute;
    left: 14px;
    color: var(--crm-text-muted);
    font-size: 0.875rem;
}

.search-box input {
    padding-left: 2.5rem;
    padding-right: 4rem;
    border-radius: 50px;
    border: 1px solid var(--crm-border);
    background: var(--crm-bg);
    height: 40px;
    font-size: 0.875rem;
    transition: border-color var(--crm-transition), box-shadow var(--crm-transition);
}

.search-box input:focus {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(1, 118, 211, 0.15);
    background: var(--crm-surface);
}

.search-kbd {
    position: absolute;
    right: 12px;
    font-size: 0.6875rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--crm-border);
    color: var(--crm-text-muted);
    font-family: inherit;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--crm-text-muted);
    transition: all var(--crm-transition);
}

.btn-icon:hover {
    background: var(--crm-bg);
    color: var(--crm-text);
}

.theme-toggle .theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-toggle .theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-toggle .theme-icon-light { display: inline; }

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--crm-danger);
    border-radius: 50%;
    border: 2px solid var(--crm-surface);
}

.notification-dropdown {
    width: 340px;
    padding: 0;
    border: 1px solid var(--crm-border);
    box-shadow: var(--crm-shadow-lg);
}

.notification-dropdown .dropdown-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--crm-border);
    font-weight: 600;
}

.notification-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--crm-border);
    transition: background var(--crm-transition);
}

.notification-item:hover { background: var(--crm-bg); }

.notification-item.unread {
    background: rgba(27, 150, 255, 0.06);
}

.notification-item-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.notification-item-link:hover {
    color: inherit;
}

.notification-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-dropdown .dropdown-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--crm-border);
}

.btn-profile {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 4px 8px 4px 4px;
    border: 1px solid var(--crm-border);
    border-radius: 50px;
    background: var(--crm-surface);
    transition: all var(--crm-transition);
}

.btn-profile:hover { background: var(--crm-bg); }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--crm-primary), #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.profile-info {
    text-align: left;
    line-height: 1.2;
}

.profile-name {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--crm-text);
}

.profile-role {
    display: block;
    font-size: 0.6875rem;
    color: var(--crm-text-muted);
}

#sidebarMobileToggle { display: none; }

/* ---- Sidebar ---- */
.crm-sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: var(--crm-sidebar-bg);
    z-index: 1030;
    transition: width var(--crm-transition);
    overflow: hidden;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-inner::-webkit-scrollbar { width: 4px; }
.sidebar-inner::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.sidebar-nav { padding: 1rem 0.75rem; flex: 1; }

.nav-section { margin-bottom: 1.5rem; }

.nav-section-title {
    display: block;
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--crm-transition);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    color: var(--crm-sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--crm-transition);
    white-space: nowrap;
    position: relative;
}

.sidebar-nav .nav-link i {
    font-size: 1.125rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
    background: var(--crm-sidebar-hover);
    color: var(--crm-sidebar-active);
}

.sidebar-nav .nav-link.active {
    background: var(--crm-sidebar-active-bg);
    color: #60a5fa;
}

.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--crm-accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-nav .nav-link.disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* Collapsed Sidebar */
.sidebar-collapsed .crm-sidebar { width: var(--sidebar-collapsed-width); }
.sidebar-collapsed .nav-section-title,
.sidebar-collapsed .nav-label { display: none; }
.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; padding: 0.75rem; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1025;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--crm-text);
}

.page-header .breadcrumb {
    margin: 0;
    font-size: 0.8125rem;
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---- Cards ---- */
.crm-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-lg);
    box-shadow: var(--crm-shadow);
    transition: box-shadow var(--crm-transition);
}

.crm-card:hover { box-shadow: var(--crm-shadow-md); }

.crm-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.crm-card-header h5 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.35;
}

.crm-card-header h5 i {
    flex-shrink: 0;
    margin-top: 0.1em;
}

.crm-card-header h5 .me-2 {
    margin-right: 0 !important;
}

.crm-card-header > .form-select,
.crm-card-header > select {
    flex-shrink: 0;
    width: auto !important;
    min-width: 8.5rem;
    max-width: 11rem;
}

.crm-card-body { padding: 1.25rem; }

/* ---- KPI Cards ---- */
.kpi-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--crm-shadow);
    transition: transform var(--crm-transition), box-shadow var(--crm-transition);
    height: 100%;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--crm-shadow-md);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.kpi-icon.primary { background: rgba(1, 118, 211, 0.12); color: var(--crm-primary); }
.kpi-icon.success { background: rgba(46, 132, 74, 0.12); color: var(--crm-success); }
.kpi-icon.warning { background: rgba(254, 147, 57, 0.12); color: var(--crm-warning); }
.kpi-icon.info { background: rgba(27, 150, 255, 0.12); color: var(--crm-accent); }

.kpi-label {
    font-size: 0.8125rem;
    color: var(--crm-text-muted);
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--crm-text);
}

.kpi-change {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.375rem;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.kpi-change.up { color: var(--crm-success); }
.kpi-change.down { color: var(--crm-danger); }

/* ---- Status Badges ---- */
.badge-status {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 50px;
    text-transform: capitalize;
}

.badge-status-new { background: rgba(1, 118, 211, 0.12); color: #0176d3; }
.badge-status-called { background: rgba(99, 102, 241, 0.12); color: #6366f1; }
.badge-status-unreachable { background: rgba(254, 147, 57, 0.12); color: #c2700a; }
.badge-status-invalid { background: rgba(234, 0, 30, 0.1); color: #ea001e; }
.badge-status-awaiting-proposal { background: rgba(46, 132, 74, 0.12); color: #2e844a; }
.badge-status-completed { background: rgba(5, 150, 105, 0.18); color: #047857; }
.badge-priority-high { background: rgba(234, 0, 30, 0.1); color: #ea001e; }
.badge-priority-medium { background: rgba(254, 147, 57, 0.12); color: #c2700a; }
.badge-priority-low { background: rgba(100, 116, 139, 0.12); color: #64748b; }

[data-bs-theme="dark"] .badge-status-awaiting-proposal { color: #4ade80; }
[data-bs-theme="dark"] .badge-status-completed { color: #34d399; }
[data-bs-theme="dark"] .badge-status-invalid { color: #f87171; }

/* ---- Tables ---- */
.table-card .dataTables_wrapper { padding: 0; }

.table-card .dataTables_filter input,
.table-card .dataTables_length select {
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    padding: 0.375rem 0.75rem;
    background: var(--crm-surface);
    color: var(--crm-text);
}

.crm-table {
    margin: 0 !important;
    font-size: 0.875rem;
}

.crm-table thead th {
    background: var(--crm-bg);
    border-bottom: 2px solid var(--crm-border) !important;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--crm-text-muted);
    padding: 0.875rem 1rem !important;
    white-space: nowrap;
}

.crm-table tbody td {
    padding: 0.875rem 1rem !important;
    vertical-align: middle;
    border-color: var(--crm-border) !important;
    color: var(--crm-text);
}

.crm-table tbody tr { transition: background var(--crm-transition); }
.crm-table tbody tr:hover { background: var(--crm-bg); }

.table-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.table-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--crm-primary), #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.table-actions {
    display: flex;
    gap: 0.25rem;
}

.table-actions .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.875rem;
}

/* ---- Buttons ---- */
.btn-crm-primary {
    background: var(--crm-primary);
    border-color: var(--crm-primary);
    color: #fff;
    font-weight: 500;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: all var(--crm-transition);
}

.btn-crm-primary:hover {
    background: var(--crm-primary-hover);
    border-color: var(--crm-primary-hover);
    color: #fff;
}

.btn-crm-outline {
    border: 1px solid var(--crm-border);
    background: var(--crm-surface);
    color: var(--crm-text);
    font-weight: 500;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: all var(--crm-transition);
}

.btn-crm-outline:hover {
    background: var(--crm-bg);
    border-color: var(--crm-text-muted);
    color: var(--crm-text);
}

/* ---- Filters Bar ---- */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--crm-border);
    background: var(--crm-bg);
}

.filters-bar .filter-item {
    flex: 0 0 auto;
    width: 12.5rem;
    max-width: 100%;
}

.filters-bar .filter-item .form-select {
    width: 100%;
    margin: 0;
}

/* ---- Lead Detail ---- */
.lead-profile-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
}

.lead-avatar-lg {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--crm-primary), #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    flex-shrink: 0;
}

.lead-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--crm-text-muted);
    margin-bottom: 0.375rem;
}

.lead-meta-item i { color: var(--crm-primary); }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.info-item label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--crm-text-muted);
    margin-bottom: 0.25rem;
}

.info-item span {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--crm-text);
}

/* ---- Activity Timeline ---- */
.activity-timeline { position: relative; padding-left: 2rem; }

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--crm-border);
}

.activity-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.activity-item:last-child { padding-bottom: 0; }

.activity-dot {
    position: absolute;
    left: -2rem;
    top: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    background: var(--crm-surface);
    border: 2px solid var(--crm-border);
    z-index: 1;
}

.activity-dot.email { border-color: var(--crm-primary); color: var(--crm-primary); }
.activity-dot.call { border-color: var(--crm-success); color: var(--crm-success); }
.activity-dot.note { border-color: var(--crm-warning); color: var(--crm-warning); }
.activity-dot.meeting { border-color: #6366f1; color: #6366f1; }
.activity-dot.status { border-color: var(--crm-accent); color: var(--crm-accent); }

.activity-item h6 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.activity-item p {
    font-size: 0.8125rem;
    color: var(--crm-text-muted);
    margin-bottom: 0.25rem;
}

.activity-item small { font-size: 0.75rem; color: var(--crm-text-muted); }

/* ---- Pipeline ---- */
.pipeline-stages {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.pipeline-stage {
    flex: 1;
    min-width: 120px;
    text-align: center;
    padding: 0.75rem;
    border-radius: 8px;
    background: var(--crm-bg);
    border: 2px solid transparent;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--crm-text-muted);
    transition: all var(--crm-transition);
}

.pipeline-stage.active {
    border-color: var(--crm-primary);
    background: rgba(1, 118, 211, 0.08);
    color: var(--crm-primary);
}

.pipeline-stage.completed {
    background: rgba(46, 132, 74, 0.08);
    color: var(--crm-success);
}

.lead-profile-header .fs-3 {
    white-space: nowrap;
}

.investment-cell {
    white-space: nowrap;
}

/* ---- Inline status select ---- */
.status-inline-select {
    min-width: 140px;
    max-width: 180px;
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

/* ---- Kanban board ---- */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    min-height: 420px;
}

.kanban-column {
    flex: 0 0 260px;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--crm-border);
    background: rgba(1, 118, 211, 0.04);
}

.kanban-count {
    background: var(--crm-border);
    color: var(--crm-text-muted);
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
}

.kanban-cards {
    padding: 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    flex: 1;
}

.kanban-card {
    display: block;
    padding: 0.875rem;
    background: var(--crm-bg);
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all var(--crm-transition);
}

.kanban-card:hover {
    border-color: var(--crm-primary);
    box-shadow: 0 2px 8px rgba(1, 118, 211, 0.12);
    color: inherit;
}

.kanban-card-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.kanban-card-company {
    font-size: 0.8125rem;
    color: var(--crm-text-muted);
    margin-bottom: 0.625rem;
}

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}

.kanban-card-value {
    font-weight: 600;
    color: var(--crm-primary);
}

.kanban-card-owner {
    color: var(--crm-text-muted);
    max-width: 50%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.view-toggle .btn.active {
    background: var(--crm-primary);
    color: #fff;
    border-color: var(--crm-primary);
}

.table-highlight {
    background: rgba(1, 118, 211, 0.08) !important;
    outline: 2px solid var(--crm-primary);
    outline-offset: -2px;
}

/* ---- Settings ---- */
.settings-nav .nav-link {
    color: var(--crm-text-muted);
    font-weight: 500;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    transition: all var(--crm-transition);
}

.settings-nav .nav-link:hover,
.settings-nav .nav-link.active {
    background: rgba(1, 118, 211, 0.08);
    color: var(--crm-primary);
}

.settings-section { display: none; }
.settings-section.active { display: block; }

/* ---- Chart containers ---- */
.chart-container { min-height: 300px; }

/* ---- Select2 Dark Mode Fix ---- */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
    background: var(--crm-surface);
    border-color: var(--crm-border);
    color: var(--crm-text);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown {
    background: var(--crm-surface);
    border-color: var(--crm-border);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted {
    background: var(--crm-primary);
}

[data-bs-theme="dark"] div.dt-container .dt-paging .dt-paging-button.current {
    background: var(--crm-primary) !important;
    border-color: var(--crm-primary) !important;
    color: #fff !important;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length select {
    background: var(--crm-surface);
    color: var(--crm-text);
    border-color: var(--crm-border);
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--crm-text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .crm-main { margin-left: 0; }
    .sidebar-collapsed .crm-main { margin-left: 0; }

    .crm-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .sidebar-mobile-open .crm-sidebar {
        transform: translateX(0);
    }

    .sidebar-mobile-open .sidebar-overlay { display: block; }

    #sidebarToggle { display: none; }
    #sidebarMobileToggle { display: inline-flex; }

    .sidebar-collapsed .nav-section-title,
    .sidebar-collapsed .nav-label {
        display: block;
    }
}

@media (max-width: 767.98px) {
    .crm-main { padding: 1rem; }
    .page-header h1 { font-size: 1.25rem; }
    .kpi-value { font-size: 1.375rem; }
}

@media (max-width: 575.98px) {
    .topbar-search { display: none !important; }
    .filters-bar .filter-item {
        flex: 1 1 calc(50% - 0.375rem);
        width: auto;
        min-width: 0;
    }
}
