/* ============================================================
   NoraCRM — Premium Purple Enterprise Theme
   Brand palette matched to NoraCRM logo
   ============================================================ */

:root {
    --crm-primary: #9333ea;
    --crm-primary-hover: #7e22ce;
    --crm-primary-light: #a855f7;
    --crm-primary-deep: #5b21b6;
    --crm-primary-soft: #f5f0fe;
    --crm-primary-muted: #ede9fe;
    --crm-primary-rgb: 147, 51, 234;
    --crm-primary-gradient: linear-gradient(135deg, #5b21b6 0%, #9333ea 55%, #a855f7 100%);
    --crm-sidebar-active: linear-gradient(135deg, #6d28d9 0%, #9333ea 100%);
    --crm-sidebar-active-hover: linear-gradient(135deg, #5b21b6 0%, #7e22ce 100%);
    --crm-sidebar-active-soft: #f5f0fe;
    --crm-sidebar-active-shadow: 0 4px 18px rgba(147, 51, 234, 0.38), 0 2px 6px rgba(91, 33, 182, 0.22);
    --crm-success: #059669;
    --crm-success-soft: #ecfdf5;
    --crm-danger: #dc2626;
    --crm-warning: #d97706;
    --crm-bg: #f8f6fc;
    --crm-surface: #ffffff;
    --crm-text: #1e1b4b;
    --crm-text-secondary: #4c4585;
    --crm-text-muted: #8b85a8;
    --crm-border: #e8e4f3;
    --crm-border-light: #f3f0fa;
    --crm-shadow-sm: 0 1px 2px rgba(30, 27, 75, 0.05);
    --crm-shadow: 0 1px 3px rgba(30, 27, 75, 0.07);
    --crm-shadow-md: 0 4px 6px -1px rgba(30, 27, 75, 0.08);
    --crm-radius: 10px;
    --crm-radius-lg: 12px;
    --crm-sidebar-width: 256px;
    --crm-header-height: 64px;
    --crm-transition: 0.2s ease;
}

/* ---- Base ---- */
body.crm-theme {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    background-color: var(--crm-bg) !important;
    color: var(--crm-text);
    -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */
body.crm-theme #page-topbar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: var(--crm-sidebar-width) !important;
    height: var(--crm-header-height) !important;
    background: var(--crm-surface) !important;
    border-bottom: 1px solid var(--crm-border) !important;
    box-shadow: none !important;
    z-index: 1002;
}

body.crm-theme .navbar-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100%;
    height: var(--crm-header-height) !important;
    padding: 0 24px !important;
    background: transparent !important;
    margin: 0 !important;
}

body.crm-theme .crm-header-right { margin-left: auto; }

body.crm-theme .navbar-brand-box { display: none !important; }

body.crm-theme #vertical-menu-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--crm-border);
    background: var(--crm-surface);
    color: var(--crm-text-secondary);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
}

body.crm-theme .crm-header-left { display: flex; align-items: center; gap: 8px; }

body.crm-theme .crm-header-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--crm-text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    position: relative;
    transition: var(--crm-transition);
    text-decoration: none;
}

body.crm-theme .crm-header-icon:hover {
    background: var(--crm-bg);
    color: var(--crm-primary);
}

body.crm-theme .crm-notif-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--crm-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.crm-theme .crm-header-search {
    flex: 1;
    max-width: 420px;
    margin: 0 20px;
}

body.crm-theme .crm-search-wrap { position: relative; }

body.crm-theme .crm-search-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--crm-text-muted);
    font-size: 18px;
    pointer-events: none;
}

body.crm-theme .crm-search-wrap input {
    width: 100%;
    height: 40px;
    padding: 0 16px 0 42px;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    background: var(--crm-bg);
    font-size: 14px;
    color: var(--crm-text);
    outline: none;
    transition: var(--crm-transition);
}

body.crm-theme .crm-search-wrap input:focus {
    background: var(--crm-surface);
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(var(--crm-primary-rgb), 0.14);
}

body.crm-theme .crm-header-right { display: flex; align-items: center; gap: 4px; }

body.crm-theme .crm-user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 4px 4px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--crm-transition);
}

body.crm-theme .crm-user-btn:hover { background: var(--crm-bg); }

body.crm-theme .crm-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--crm-primary-gradient);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.crm-theme .crm-user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--crm-text);
}

body.crm-theme .crm-user-role {
    font-size: 12px;
    color: var(--crm-text-muted);
    display: block;
}

body.crm-theme .crm-chevron-down { color: var(--crm-text-muted); }

body.crm-theme #page-header-user-dropdown {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* ---- Sidebar ---- */
body.crm-theme .vertical-menu {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: var(--crm-sidebar-width) !important;
    height: 100vh !important;
    background: linear-gradient(180deg, #ffffff 0%, #fcfbff 100%) !important;
    border-right: 1px solid var(--crm-border) !important;
    box-shadow: none !important;
    z-index: 1001;
}

body.crm-theme .crm-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--crm-border);
    min-height: var(--crm-header-height);
    background: linear-gradient(180deg, #ffffff 0%, #faf8ff 100%);
}

body.crm-theme .crm-sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

body.crm-theme .crm-sidebar-brand img {
    object-fit: contain;
}

body.crm-theme .crm-sidebar-brand .crm-sidebar-logo {
    display: block;
    width: auto;
    height: 40px;
    max-width: 100%;
}

body.crm-theme .crm-sidebar-brand .crm-sidebar-icon {
    display: none;
    width: 36px;
    height: 36px;
    object-fit: cover;
    object-position: left center;
}

body.crm-theme .crm-sidebar-brand span {
    display: none;
}

body.crm-theme #sidebar-menu { padding: 12px 8px 24px; }

body.crm-theme #sidebar-menu #side-menu > li,
body.crm-theme #sidebar-menu .sub-menu > li {
    padding: 2px 6px;
}

body.crm-theme #sidebar-menu .menu-title {
    color: var(--crm-text-muted) !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 12px 6px !important;
}

body.crm-theme #sidebar-menu ul li a {
    color: var(--crm-text-secondary) !important;
    padding: 10px 14px !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    display: flex !important;
    align-items: center;
    gap: 10px;
    transition: background-color var(--crm-transition), color var(--crm-transition), box-shadow var(--crm-transition);
    margin-bottom: 2px;
}

body.crm-theme #sidebar-menu ul li a i {
    font-size: 18px !important;
    width: 20px;
    text-align: center;
    color: inherit !important;
}

body.crm-theme #sidebar-menu ul li a span { color: inherit !important; }

body.crm-theme #sidebar-menu ul li a:hover:not(.active) {
    background: var(--crm-primary-soft) !important;
    color: var(--crm-primary-deep) !important;
}

body.crm-theme #sidebar-menu ul li.mm-active > a,
body.crm-theme #sidebar-menu ul li > a.active,
body.crm-theme #sidebar-menu .sub-menu li.mm-active > a,
body.crm-theme #sidebar-menu .sub-menu li a.active {
    background: var(--crm-sidebar-active) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    border-radius: 10px !important;
    box-shadow: var(--crm-sidebar-active-shadow) !important;
}

body.crm-theme #sidebar-menu ul li.mm-active > a:hover,
body.crm-theme #sidebar-menu ul li > a.active:hover,
body.crm-theme #sidebar-menu .sub-menu li.mm-active > a:hover,
body.crm-theme #sidebar-menu .sub-menu li a.active:hover {
    background: var(--crm-sidebar-active-hover) !important;
    color: #ffffff !important;
}

body.crm-theme #sidebar-menu ul li.mm-active > a i,
body.crm-theme #sidebar-menu ul li > a.active i,
body.crm-theme #sidebar-menu ul li.mm-active > a span,
body.crm-theme #sidebar-menu ul li > a.active span,
body.crm-theme #sidebar-menu .sub-menu li.mm-active > a i,
body.crm-theme #sidebar-menu .sub-menu li a.active i,
body.crm-theme #sidebar-menu .sub-menu li.mm-active > a span,
body.crm-theme #sidebar-menu .sub-menu li a.active span {
    color: #ffffff !important;
}

body.crm-theme #sidebar-menu .sub-menu {
    background: transparent !important;
    padding-left: 4px;
}

body.crm-theme #sidebar-menu .sub-menu li a {
    padding: 8px 14px 8px 28px !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    border-radius: 8px !important;
}

body.crm-theme #sidebar-menu .has-arrow::after { color: var(--crm-text-muted) !important; }
body.crm-theme #sidebar-menu ul li.mm-active > a.has-arrow::after,
body.crm-theme #sidebar-menu .sub-menu li.mm-active > a.has-arrow::after,
body.crm-theme #sidebar-menu ul li > a.active.has-arrow::after,
body.crm-theme #sidebar-menu .sub-menu li a.active.has-arrow::after {
    color: #ffffff !important;
}

/* ---- Main Content ---- */
body.crm-theme .main-content {
    margin-left: var(--crm-sidebar-width) !important;
    margin-right: 0 !important;
    margin-top: var(--crm-header-height) !important;
    background: var(--crm-bg);
    min-height: calc(100vh - var(--crm-header-height));
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: visible !important;
}

body.crm-theme .page-content {
    padding: 24px !important;
    padding-bottom: 32px !important;
    flex: 1 0 auto;
}

body.crm-theme .footer {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 56px;
    margin-top: auto;
    flex-shrink: 0;
    background: var(--crm-surface) !important;
    border-top: 1px solid var(--crm-border);
    color: var(--crm-text-muted);
    font-size: 13px;
    padding: 16px 24px !important;
    display: flex;
    align-items: center;
}

body.crm-theme .footer .container-fluid {
    width: 100%;
    padding: 0;
}

body.crm-theme .footer .row {
    width: 100%;
    margin: 0;
    align-items: center;
}

body.crm-theme .crm-footer-text {
    font-weight: 500;
    color: var(--crm-text-secondary);
}

body.crm-theme.vertical-collpsed .footer {
    right: auto !important;
}

/* ---- Page Title ---- */
body.crm-theme .page-title-box {
    background: transparent;
    padding: 0 0 20px;
}

body.crm-theme .page-title-box h4 {
    font-size: 22px;
    font-weight: 600;
    color: var(--crm-text);
}

body.crm-theme .breadcrumb-item a { color: var(--crm-text-muted); text-decoration: none; }
body.crm-theme .breadcrumb-item.active { color: var(--crm-text-secondary); }

/* ---- Dashboard ---- */
.crm-dash-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
    padding: 28px 32px;
    background: linear-gradient(135deg, #ffffff 0%, #faf8ff 55%, #f5f0fe 100%);
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    box-shadow: var(--crm-shadow-sm);
    position: relative;
    overflow: hidden;
}

.crm-dash-hero::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(var(--crm-primary-rgb), 0.14) 0%, transparent 70%);
    pointer-events: none;
}

.crm-dash-hero-content { position: relative; z-index: 1; }

.crm-dash-greeting {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: var(--crm-primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.crm-dash-hero h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--crm-text);
    margin: 0 0 8px;
    letter-spacing: -0.02em;
    text-transform: capitalize;
}

.crm-dash-hero p {
    font-size: 14px;
    color: var(--crm-text-muted);
    margin: 0;
    max-width: 520px;
}

.crm-dash-hero-meta { position: relative; z-index: 1; flex-shrink: 0; }

.crm-dash-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.crm-dash-header h4 {
    font-size: 24px;
    font-weight: 600;
    color: var(--crm-text);
    margin: 0 0 4px;
}

.crm-dash-header p { font-size: 14px; color: var(--crm-text-muted); margin: 0; }

.crm-dash-date {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--crm-text-secondary);
    box-shadow: var(--crm-shadow-sm);
}

.crm-dash-date i { font-size: 18px; color: var(--crm-primary); }

.crm-stat-card {
    position: relative;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: 14px;
    padding: 22px 24px;
    box-shadow: var(--crm-shadow-sm);
    transition: transform var(--crm-transition), box-shadow var(--crm-transition), border-color var(--crm-transition);
    height: 100%;
    min-height: 130px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    overflow: hidden;
}

.crm-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(var(--crm-primary-rgb), 0.1);
    border-color: #ddd6fe;
}

.crm-stat-accent {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 14px 0 0 14px;
}

.crm-stat-card--blue .crm-stat-accent { background: var(--crm-primary); }
.crm-stat-card--green .crm-stat-accent { background: var(--crm-success); }
.crm-stat-card--purple .crm-stat-accent { background: var(--crm-primary-deep); }

.crm-stat-card .stat-info { padding-left: 8px; }

.crm-stat-card .stat-info h6 {
    font-size: 12px;
    font-weight: 600;
    color: var(--crm-text-muted);
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.crm-stat-card .stat-info .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--crm-text);
    margin: 0 0 4px;
    line-height: 1;
}

.crm-stat-card .stat-hint {
    font-size: 12px;
    color: var(--crm-text-muted);
}

.crm-stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.crm-stat-card .stat-icon.blue { background: var(--crm-primary-soft); color: var(--crm-primary); }
.crm-stat-card .stat-icon.green { background: var(--crm-success-soft); color: var(--crm-success); }
.crm-stat-card .stat-icon.purple { background: var(--crm-primary-soft); color: var(--crm-primary-deep); }

.crm-panel-card,
.crm-chart-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    box-shadow: var(--crm-shadow-sm);
    height: 100%;
}

.crm-panel-card { padding: 22px 24px 24px; }
.crm-chart-card { padding: 22px 24px 16px; }

.crm-chart-card--tall { min-height: 100%; }

.crm-panel-card-head,
.crm-chart-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 18px;
}

.crm-panel-card-head h6,
.crm-chart-card-head h6 {
    font-size: 16px;
    font-weight: 600;
    color: var(--crm-text);
    margin: 0 0 4px;
}

.crm-panel-card-head p,
.crm-chart-card-head p {
    font-size: 13px;
    color: var(--crm-text-muted);
    margin: 0;
}

.crm-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--crm-text);
    margin: 28px 0 16px;
}

.crm-status-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: var(--crm-shadow-sm);
    transition: transform var(--crm-transition), box-shadow var(--crm-transition), border-color var(--crm-transition);
    cursor: pointer;
    height: 100%;
    min-height: 96px;
}

.crm-status-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--crm-primary-rgb), 0.08);
    border-color: #ddd6fe;
}

.crm-status-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.crm-status-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.crm-status-count {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.crm-status-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--crm-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crm-status-card--blue { border-left: 3px solid var(--crm-primary); }
.crm-status-card--blue .crm-status-icon { background: var(--crm-primary-soft); color: var(--crm-primary); }
.crm-status-card--blue .crm-status-count { color: var(--crm-primary); }

.crm-status-card--green { border-left: 3px solid #059669; }
.crm-status-card--green .crm-status-icon { background: #ecfdf5; color: #059669; }
.crm-status-card--green .crm-status-count { color: #059669; }

.crm-status-card--orange { border-left: 3px solid #d97706; }
.crm-status-card--orange .crm-status-icon { background: #fffbeb; color: #d97706; }
.crm-status-card--orange .crm-status-count { color: #d97706; }

.crm-status-card--purple { border-left: 3px solid var(--crm-primary-deep); }
.crm-status-card--purple .crm-status-icon { background: var(--crm-primary-soft); color: var(--crm-primary-deep); }
.crm-status-card--purple .crm-status-count { color: var(--crm-primary-deep); }

.crm-status-card--teal { border-left: 3px solid #0891b2; }
.crm-status-card--teal .crm-status-icon { background: #ecfeff; color: #0891b2; }
.crm-status-card--teal .crm-status-count { color: #0891b2; }

.crm-status-card--rose { border-left: 3px solid #e11d48; }
.crm-status-card--rose .crm-status-icon { background: #fff1f2; color: #e11d48; }
.crm-status-card--rose .crm-status-count { color: #e11d48; }

.crm-status-card--indigo { border-left: 3px solid var(--crm-primary-light); }
.crm-status-card--indigo .crm-status-icon { background: var(--crm-primary-muted); color: var(--crm-primary-light); }
.crm-status-card--indigo .crm-status-count { color: var(--crm-primary-light); }

.crm-status-card--amber { border-left: 3px solid #ca8a04; }
.crm-status-card--amber .crm-status-icon { background: #fefce8; color: #ca8a04; }
.crm-status-card--amber .crm-status-count { color: #ca8a04; }

.crm-status-card .status-label { font-size: 13px; font-weight: 500; color: var(--crm-text-muted); margin-bottom: 8px; }
.crm-status-card .status-value { font-size: 26px; font-weight: 700; color: var(--crm-primary); margin: 0; }

#leadPipelineChart {
    min-height: 260px;
}

.crm-pipeline-chart-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.crm-pipeline-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--crm-border-light);
    max-height: 220px;
    overflow-y: auto;
}

.crm-pipeline-legend-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--crm-text-secondary);
    min-width: 0;
}

.crm-pipeline-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 3px;
}

.crm-pipeline-legend-label {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.crm-pipeline-legend-count {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--crm-text);
    min-width: 18px;
    text-align: right;
}

@media (max-width: 576px) {
    .crm-pipeline-legend {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 991px) {
    .crm-dash-hero {
        flex-direction: column;
        align-items: flex-start;
        padding: 22px 20px;
    }

    .crm-dash-hero h2 { font-size: 24px; }
}

/* ---- Cards ---- */
body.crm-theme .card {
    background: var(--crm-surface) !important;
    border: 1px solid var(--crm-border) !important;
    border-radius: var(--crm-radius-lg) !important;
    box-shadow: var(--crm-shadow-sm) !important;
}

body.crm-theme .card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--crm-border) !important;
    padding: 16px 20px !important;
    font-weight: 600;
}

body.crm-theme .card-body { padding: 20px !important; }

/* ---- Buttons ---- */
body.crm-theme .btn {
    border-radius: 8px !important;
    font-weight: 500 !important;
    font-size: 14px !important;
    padding: 8px 16px !important;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

body.crm-theme .btn-primary {
    background: var(--crm-primary-gradient) !important;
    border-color: var(--crm-primary) !important;
    box-shadow: none !important;
}

body.crm-theme .btn-primary:hover {
    background: var(--crm-sidebar-active-hover) !important;
    border-color: var(--crm-primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--crm-primary-rgb), 0.28) !important;
}

body.crm-theme .btn-success {
    background-color: var(--crm-success) !important;
    border-color: var(--crm-success) !important;
}

body.crm-theme .btn-danger {
    background-color: var(--crm-danger) !important;
    border-color: var(--crm-danger) !important;
}

/* ---- Table Action Buttons (View / Edit / Delete) ---- */
body.crm-theme #datatable td,
body.crm-theme .table-responsive .table td {
    vertical-align: middle !important;
}

body.crm-theme #datatable td form,
body.crm-theme .table-responsive .table td form {
    display: inline-block;
    margin: 2px 1px;
}

body.crm-theme #datatable td .btn,
body.crm-theme #datatable td a.btn,
body.crm-theme .table-responsive .table td .btn,
body.crm-theme .table-responsive .table td a.btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 32px;
    padding: 6px 12px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
    border-radius: 8px !important;
    border: 1px solid transparent !important;
    box-shadow: none !important;
    white-space: nowrap;
    text-decoration: none !important;
}

body.crm-theme #datatable td .btn i,
body.crm-theme .table-responsive .table td .btn i {
    font-size: 14px;
    line-height: 1;
}

body.crm-theme #datatable td .btn:hover,
body.crm-theme #datatable td a.btn:hover,
body.crm-theme .table-responsive .table td .btn:hover,
body.crm-theme .table-responsive .table td a.btn:hover {
    transform: translateY(-1px);
}

/* View */
body.crm-theme #datatable td .btn-info,
body.crm-theme .table-responsive .table td .btn-info,
body.crm-theme #datatable td a.crm-btn-view,
body.crm-theme .table-responsive .table td a.crm-btn-view {
    background: var(--crm-primary-soft) !important;
    color: var(--crm-primary) !important;
    border-color: #d8b4fe !important;
}

body.crm-theme #datatable td .btn-info:hover,
body.crm-theme .table-responsive .table td .btn-info:hover,
body.crm-theme #datatable td a.crm-btn-view:hover,
body.crm-theme .table-responsive .table td a.crm-btn-view:hover {
    background: var(--crm-primary) !important;
    color: #ffffff !important;
    border-color: var(--crm-primary) !important;
    box-shadow: 0 4px 12px rgba(var(--crm-primary-rgb), 0.28) !important;
}

/* Edit */
body.crm-theme #datatable td button.btn-success,
body.crm-theme .table-responsive .table td button.btn-success,
body.crm-theme #datatable td .crm-btn-edit,
body.crm-theme .table-responsive .table td .crm-btn-edit {
    background: var(--crm-primary-muted) !important;
    color: var(--crm-primary-deep) !important;
    border-color: #c4b5fd !important;
}

body.crm-theme #datatable td button.btn-success:hover,
body.crm-theme .table-responsive .table td button.btn-success:hover,
body.crm-theme #datatable td .crm-btn-edit:hover,
body.crm-theme .table-responsive .table td .crm-btn-edit:hover {
    background: var(--crm-primary-deep) !important;
    color: #ffffff !important;
    border-color: var(--crm-primary-deep) !important;
    box-shadow: 0 4px 12px rgba(91, 33, 182, 0.28) !important;
}

/* Delete */
body.crm-theme #datatable td .btn-danger,
body.crm-theme .table-responsive .table td .btn-danger,
body.crm-theme #datatable td .delete-btn,
body.crm-theme .table-responsive .table td .delete-btn,
body.crm-theme #datatable td .crm-btn-delete,
body.crm-theme .table-responsive .table td .crm-btn-delete {
    background: #fef2f2 !important;
    color: #dc2626 !important;
    border-color: #fca5a5 !important;
}

body.crm-theme #datatable td .btn-danger:hover,
body.crm-theme .table-responsive .table td .btn-danger:hover,
body.crm-theme #datatable td .delete-btn:hover,
body.crm-theme .table-responsive .table td .delete-btn:hover,
body.crm-theme #datatable td .crm-btn-delete:hover,
body.crm-theme .table-responsive .table td .crm-btn-delete:hover {
    background: #dc2626 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.28) !important;
}

/* Quotation / success links */
body.crm-theme #datatable td a.btn-success:not(.crm-btn-view),
body.crm-theme .table-responsive .table td a.btn-success:not(.crm-btn-view) {
    background: #ecfdf5 !important;
    color: #059669 !important;
    border-color: #6ee7b7 !important;
}

body.crm-theme #datatable td a.btn-success:not(.crm-btn-view):hover,
body.crm-theme .table-responsive .table td a.btn-success:not(.crm-btn-view):hover {
    background: #059669 !important;
    color: #ffffff !important;
    border-color: #059669 !important;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.28) !important;
}

/* Sales order / warning */
body.crm-theme #datatable td .btn-warning,
body.crm-theme .table-responsive .table td .btn-warning,
body.crm-theme #datatable td .crm-btn-sales,
body.crm-theme .table-responsive .table td .crm-btn-sales {
    background: #fffbeb !important;
    color: #d97706 !important;
    border-color: #fcd34d !important;
}

body.crm-theme #datatable td .btn-warning:hover,
body.crm-theme .table-responsive .table td .btn-warning:hover,
body.crm-theme #datatable td .crm-btn-sales:hover,
body.crm-theme .table-responsive .table td .crm-btn-sales:hover {
    background: #d97706 !important;
    color: #ffffff !important;
    border-color: #d97706 !important;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.28) !important;
}

body.crm-theme .crm-action-group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

/* ---- Forms ---- */
body.crm-theme .form-control,
body.crm-theme .form-select,
body.crm-theme select.form-control {
    border: 1px solid var(--crm-border) !important;
    border-radius: 8px !important;
    padding: 9px 14px !important;
    font-size: 14px !important;
    min-height: 40px;
    background-color: var(--crm-surface) !important;
}

body.crm-theme .form-control:focus,
body.crm-theme .form-select:focus {
    border-color: var(--crm-primary) !important;
    box-shadow: 0 0 0 3px rgba(var(--crm-primary-rgb), 0.14) !important;
}

body.crm-theme .form-label {
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--crm-text-secondary) !important;
    margin-bottom: 6px !important;
}

body.crm-theme #filterForm {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--crm-shadow-sm);
}

/* ============================================================
   DataTables — preserve #datatable id & full functionality
   ============================================================ */
body.crm-theme .crm-table-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-lg);
    box-shadow: var(--crm-shadow-sm);
    padding: 0;
    overflow: visible;
}

body.crm-theme .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--crm-radius-lg);
}

body.crm-theme #datatable {
    width: 100% !important;
    margin-bottom: 0 !important;
}

body.crm-theme .dataTables_wrapper {
    width: 100%;
    padding: 16px;
    overflow: visible;
}

body.crm-theme .dataTables_wrapper .row:first-child,
body.crm-theme .dataTables_wrapper .row:last-child {
    align-items: center;
    margin-bottom: 12px;
}

body.crm-theme table.dataTable,
body.crm-theme .table {
    border-collapse: separate !important;
    border-spacing: 0;
}

body.crm-theme table.dataTable thead th,
body.crm-theme .table thead th {
    background: var(--crm-bg) !important;
    color: var(--crm-text-secondary) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--crm-border) !important;
    border-top: none !important;
    padding: 12px 16px !important;
    white-space: nowrap;
    vertical-align: middle;
}

body.crm-theme table.dataTable tbody td,
body.crm-theme .table tbody td {
    padding: 12px 16px !important;
    font-size: 14px;
    color: var(--crm-text);
    border-bottom: 1px solid var(--crm-border-light) !important;
    vertical-align: middle;
}

body.crm-theme table.dataTable tbody tr:hover,
body.crm-theme .table tbody tr:hover {
    background: var(--crm-primary-soft) !important;
}

body.crm-theme table.dataTable.no-footer { border-bottom: 1px solid var(--crm-border) !important; }

body.crm-theme .dataTables_length label,
body.crm-theme .dataTables_filter label,
body.crm-theme .dataTables_info {
    font-size: 13px;
    color: var(--crm-text-muted);
    margin: 0;
}

body.crm-theme .dataTables_filter input {
    border: 1px solid var(--crm-border) !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    margin-left: 8px;
    font-size: 14px;
}

body.crm-theme .dataTables_length select {
    border: 1px solid var(--crm-border) !important;
    border-radius: 8px !important;
    padding: 4px 8px !important;
    margin: 0 6px;
}

body.crm-theme .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    border: 1px solid var(--crm-border) !important;
    padding: 4px 10px !important;
    margin: 0 2px !important;
    font-size: 13px !important;
    background: var(--crm-surface) !important;
    color: var(--crm-text-secondary) !important;
}

body.crm-theme .dataTables_paginate .paginate_button.current {
    background: var(--crm-primary) !important;
    border-color: var(--crm-primary) !important;
    color: #fff !important;
}

body.crm-theme .dataTables_paginate .paginate_button:hover {
    background: var(--crm-primary-soft) !important;
    border-color: var(--crm-primary) !important;
    color: var(--crm-primary) !important;
}

/* ---- Modals ---- */
body.crm-theme .modal-content {
    border: 1px solid var(--crm-border) !important;
    border-radius: var(--crm-radius-lg) !important;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15) !important;
}

body.crm-theme .modal-header { border-bottom: 1px solid var(--crm-border) !important; padding: 18px 24px !important; }
body.crm-theme .modal-body { padding: 24px !important; }
body.crm-theme .modal-footer { border-top: 1px solid var(--crm-border) !important; padding: 16px 24px !important; }

/* ---- Dropdowns ---- */
body.crm-theme .dropdown-menu {
    border: 1px solid var(--crm-border) !important;
    border-radius: var(--crm-radius) !important;
    box-shadow: var(--crm-shadow-md) !important;
    padding: 6px !important;
}

body.crm-theme .dropdown-item {
    border-radius: 6px !important;
    padding: 8px 12px !important;
    font-size: 14px;
}

body.crm-theme .dropdown-item:hover { background: var(--crm-bg) !important; }

body.crm-theme .success-message,
body.crm-theme .add-message { color: var(--crm-success) !important; font-weight: 500; }
body.crm-theme .error-message { color: var(--crm-danger) !important; font-weight: 500; }

body.crm-theme .page-content .table-responsive {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-lg);
    box-shadow: var(--crm-shadow-sm);
    padding: 16px;
    overflow-x: auto !important;
}

body.crm-theme table.dataTable thead th,
body.crm-theme .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* ---- Login ---- */
.crm-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at top right, rgba(var(--crm-primary-rgb), 0.12) 0%, transparent 42%),
        radial-gradient(circle at bottom left, rgba(91, 33, 182, 0.1) 0%, transparent 38%),
        var(--crm-bg);
    padding: 24px;
}

.crm-login-card {
    width: 100%;
    max-width: 420px;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-lg);
    box-shadow: 0 12px 40px rgba(30, 27, 75, 0.1);
    overflow: hidden;
}

.crm-login-brand {
    text-align: center;
    padding: 32px 24px 24px;
    border-bottom: 1px solid var(--crm-border);
    background: linear-gradient(180deg, #ffffff 0%, #faf8ff 100%);
}

.crm-login-brand img {
    width: auto;
    height: auto;
    max-width: min(280px, 100%);
    margin-bottom: 16px;
}
.crm-login-brand h5 { display: none; }
.crm-login-brand p { font-size: 14px; color: var(--crm-text-muted); margin: 0; }
.crm-login-body { padding: 28px 28px 32px; }
.crm-login-copy { font-size: 13px; }

/* ---- Collapsed Sidebar ---- */
body.crm-theme.vertical-collpsed .vertical-menu { width: 70px !important; }
body.crm-theme.vertical-collpsed .main-content { margin-left: 70px !important; }
body.crm-theme.vertical-collpsed #page-topbar { left: 70px !important; }
body.crm-theme.vertical-collpsed .crm-sidebar-brand .crm-sidebar-logo { display: none; }
body.crm-theme.vertical-collpsed .crm-sidebar-brand .crm-sidebar-icon { display: block; }
body.crm-theme.vertical-collpsed .crm-sidebar-brand span { display: none; }
body.crm-theme.vertical-collpsed #vertical-menu-btn { display: inline-flex !important; }

/* ---- Responsive ---- */
@media (max-width: 992px) {
    body.crm-theme #page-topbar { left: 0 !important; }
    body.crm-theme .main-content { margin-left: 0 !important; }
    body.crm-theme #vertical-menu-btn { display: inline-flex !important; }
    body.crm-theme .footer { right: auto !important; left: auto !important; }
}

@media (max-width: 576px) {
    body.crm-theme .page-content { padding: 16px; }
    .crm-stat-card .stat-info .stat-value { font-size: 22px; }
}

/* ---- Leads list tables ---- */
.crm-leads-section { margin-bottom: 28px; }
.crm-leads-section:last-child { margin-bottom: 0; }

.crm-leads-table-wrap {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-lg);
    box-shadow: var(--crm-shadow-sm);
    overflow: hidden;
}

.crm-leads-table-wrap .dataTables_wrapper { padding: 16px; }

body.crm-theme .crm-leads-table-wrap .table-responsive {
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
}

.crm-leads-table thead th { white-space: nowrap; }

.crm-leads-table tbody tr.crm-lead-row { cursor: pointer; }

.crm-lead-link {
    color: var(--crm-primary) !important;
    font-weight: 500;
    text-decoration: none;
}

.crm-lead-link:hover { text-decoration: underline; }

.crm-cell-truncate {
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.crm-leads-table .col-actions { white-space: nowrap; width: 1%; }

.crm-leads-table .col-actions .btn {
    padding: 4px 10px;
    font-size: 12px;
    margin-right: 4px;
}

.crm-leads-table .col-amount {
    font-weight: 600;
    white-space: nowrap;
}

.crm-leads-table .col-sr {
    width: 56px;
    text-align: center;
}

.crm-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.crm-badge--status { background: var(--crm-primary-soft); color: var(--crm-primary); }
.crm-badge--priority-high { background: #fef2f2; color: #dc2626; }
.crm-badge--priority-medium { background: #fffbeb; color: #d97706; }
.crm-badge--priority-low { background: #ecfdf5; color: #059669; }
.crm-badge--default { background: var(--crm-bg); color: var(--crm-text-secondary); }

.crm-leads-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--crm-text-muted);
    font-size: 14px;
}

/* ---- Brand accents ---- */
body.crm-theme ::selection {
    background: rgba(var(--crm-primary-rgb), 0.18);
    color: var(--crm-text);
}

body.crm-theme a:not(.btn):not(.dropdown-item):not(.crm-lead-link) {
    color: var(--crm-primary);
}

body.crm-theme a:not(.btn):not(.dropdown-item):hover {
    color: var(--crm-primary-hover);
}

body.crm-theme .page-link {
    color: var(--crm-primary) !important;
}

body.crm-theme .page-item.active .page-link {
    background: var(--crm-primary-gradient) !important;
    border-color: var(--crm-primary) !important;
}
