/* ===================================
   oon.one CRM - Design System v2
   Unified styling across all modules
   =================================== */

:root {
    --sidebar-width: 240px;
    --sidebar-collapsed: 0px;
    --topbar-height: 56px;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-rgb: 37, 99, 235;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #3b82f6;
    --sidebar-hover: #334155;
    --bg-light: #f1f5f9;
    --border-color: #e2e8f0;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --info: #0891b2;
    --info-light: #ecfeff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===================================
   SIDEBAR
   =================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--sidebar-active);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.sidebar-toggle-close {
    display: none;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    list-style: none;
    margin: 0;
}

.sidebar-divider {
    padding: 12px 20px 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    font-weight: 600;
}

.sidebar-item {
    list-style: none;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.sidebar-item.active .sidebar-link {
    color: #fff;
    background: rgba(59, 130, 246, 0.12);
    border-left-color: var(--sidebar-active);
}

.sidebar-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--sidebar-active);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.sidebar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
}

.sidebar-user-email {
    font-size: 0.7rem;
    color: var(--sidebar-text);
}

/* ===================================
   TOPBAR
   =================================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin 0.3s ease;
}

.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    display: none;
    padding: 6px;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* === Topbar Search === */
.topbar-search {
    position: relative;
    display: flex;
    align-items: center;
}

.topbar-search i {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.topbar-search input {
    padding-left: 32px;
    width: 220px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-light);
    font-size: 0.85rem;
    transition: all var(--transition-normal);
}

.topbar-search input:focus {
    width: 300px;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
    border-color: var(--primary);
}

.topbar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

/* === Breadcrumb (NEW) === */
.crm-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0 0;
    margin-bottom: -8px;
    font-size: 0.82rem;
}

.crm-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.crm-breadcrumb a:hover {
    color: var(--primary);
}

.crm-breadcrumb .separator {
    color: var(--border-color);
    font-size: 0.7rem;
}

.crm-breadcrumb .current {
    color: var(--text-primary);
    font-weight: 600;
}

/* === Notification Bell (NEW) === */
.notification-bell {
    position: relative;
    background: none;
    border: none;
    padding: 6px 8px;
    font-size: 1.15rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.notification-bell:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--danger);
    color: #fff;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: notifPulse 2s infinite;
}

@keyframes notifPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/* === Notification Dropdown (NEW) === */
.notification-panel {
    position: absolute;
    top: calc(var(--topbar-height) - 4px);
    right: 80px;
    width: 360px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    z-index: 1100;
    display: none;
    animation: slideDown 0.2s ease;
}

.notification-panel.show {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification-panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notification-panel-header h6 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
}

.notification-panel-body {
    max-height: 380px;
    overflow-y: auto;
}

.notification-item {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.notification-item:hover {
    background: var(--bg-light);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item.unread {
    background: var(--primary-light);
}

.notification-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.notification-icon.ni-task {
    background: var(--info-light);
    color: var(--info);
}

.notification-icon.ni-deal {
    background: var(--success-light);
    color: var(--success);
}

.notification-icon.ni-offer {
    background: var(--warning-light);
    color: var(--warning);
}

.notification-icon.ni-alert {
    background: var(--danger-light);
    color: var(--danger);
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.notification-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ===================================
   PAGE CONTENT
   =================================== */
.page-content {
    padding: 24px;
}

/* ===================================
   GLOBAL BUTTON SYSTEM (NEW)
   =================================== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 1px 3px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 3px 8px rgba(var(--primary-rgb), 0.35);
}

.btn-success {
    box-shadow: 0 1px 3px rgba(22, 163, 74, 0.3);
}

.btn-success:hover {
    box-shadow: 0 3px 8px rgba(22, 163, 74, 0.35);
}

.btn-outline-primary {
    border-width: 1.5px;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.btn-icon.btn-sm {
    width: 30px;
    height: 30px;
}

/* ===================================
   CARDS
   =================================== */
.stat-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 8px 0 2px;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 4px;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* === CRM Card === */
.crm-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    transition: box-shadow var(--transition-normal);
}

.crm-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.crm-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crm-card-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.crm-card-body {
    padding: 20px;
}

.crm-card-body.p-0 {
    padding: 0;
}

/* ===================================
   PIPELINE KANBAN
   =================================== */
/* Dashboard: fixed-width cards that wrap (never shrink below min); as many per row as fit. Adjust 30rem/40rem to taste. */
.dashboard-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(30rem, 40rem));
    gap: 1rem;
    justify-content: start;
}
.dashboard-card-item { min-width: 0; }
.dashboard-card-item > .crm-card { height: 100%; }

.pipeline-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    /* UAT-021: bound the board height so each column body scrolls internally
       and the column headers stay pinned while scrolling/dragging. */
    height: calc(100vh - 170px);
    min-height: 320px;
}

.pipeline-column {
    min-width: 280px;
    max-width: 320px;
    flex: 1;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
}

.pipeline-column-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background: #fff;
}

.pipeline-column-header .badge {
    font-size: 0.7rem;
}

.pipeline-column-body {
    padding: 8px;
    flex: 1;
    overflow-y: auto;
    min-height: 100px;
}

.pipeline-card {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-color);
    cursor: grab;
    transition: all var(--transition-fast);
}

.pipeline-card:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    border-color: var(--primary);
}

.pipeline-card.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.pipeline-card .deal-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.pipeline-card .deal-company {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.pipeline-card .deal-value {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.95rem;
}

.pipeline-card .deal-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===================================
   ACTIVITY TIMELINE
   =================================== */
.activity-timeline {
    position: relative;
    padding-left: 32px;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.activity-item {
    position: relative;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #fff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.activity-item:hover {
    border-color: rgba(var(--primary-rgb), 0.3);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.activity-item::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 16px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--border-color);
}

.activity-item .activity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.activity-item .activity-type {
    font-size: 0.8rem;
    font-weight: 600;
}

.activity-item .activity-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.activity-item .activity-subject {
    font-weight: 600;
    font-size: 0.9rem;
}

.activity-item .activity-desc {
    font-size: 0.85rem;
    color: #475569;
    margin-top: 4px;
}

.activity-item .activity-footer {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ===================================
   TASK LIST
   =================================== */
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.task-item:hover {
    background: #f8fafc;
}

.task-item:last-child {
    border-bottom: none;
}

.task-item.task-done {
    opacity: 0.6;
}

.task-item.task-done .task-title {
    text-decoration: line-through;
}

.task-item .task-check {
    margin-top: 2px;
    cursor: pointer;
}

.task-item .task-check input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.task-item .task-content {
    flex: 1;
}

.task-item .task-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.task-item .task-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.task-item .task-overdue {
    color: var(--danger);
    font-weight: 600;
}

/* ===================================
   CUSTOMER DETAIL
   =================================== */
.customer-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.customer-avatar {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
}

.customer-info h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
}

.customer-info .customer-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 4px;
}

/* ===================================
   DATA TABLE OVERRIDES
   =================================== */
.crm-card table.dataTable {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.crm-card .dataTables_wrapper {
    padding: 12px 0;
}

.crm-card .dataTables_filter input {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
}

/* ===================================
   GLOBAL TOAST SYSTEM (NEW)
   =================================== */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-height) + 12px);
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.crm-toast {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 420px;
    pointer-events: auto;
    animation: toastIn 0.35s ease;
}

.crm-toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

.crm-toast.toast-success {
    border-left-color: var(--success);
}

.crm-toast.toast-warning {
    border-left-color: var(--warning);
}

.crm-toast.toast-danger {
    border-left-color: var(--danger);
}

.crm-toast.toast-info {
    border-left-color: var(--info);
}

.crm-toast .toast-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.crm-toast.toast-success .toast-icon {
    background: var(--success-light);
    color: var(--success);
}

.crm-toast.toast-warning .toast-icon {
    background: var(--warning-light);
    color: var(--warning);
}

.crm-toast.toast-danger .toast-icon {
    background: var(--danger-light);
    color: var(--danger);
}

.crm-toast.toast-info .toast-icon {
    background: var(--info-light);
    color: var(--info);
}

.crm-toast .toast-message {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.crm-toast .toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
    transition: color var(--transition-fast);
}

.crm-toast .toast-close:hover {
    color: var(--text-primary);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* ===================================
   GLOBAL SEARCH OVERLAY (NEW)
   =================================== */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    backdrop-filter: blur(4px);
}

.search-overlay.show {
    display: flex;
}

.search-box {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: searchIn 0.25s ease;
    overflow: hidden;
}

@keyframes searchIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.search-box-input {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.search-box-input i {
    font-size: 1.2rem;
    color: var(--primary);
}

.search-box-input input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.search-box-input .search-shortcut {
    background: var(--bg-light);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-result-group {
    padding: 8px 0;
}

.search-result-group-label {
    padding: 6px 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.search-result-item {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.search-result-item:hover,
.search-result-item.focused {
    background: var(--primary-light);
}

.search-result-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    background: var(--bg-light);
    color: var(--text-secondary);
}

.search-result-text {
    flex: 1;
}

.search-result-title {
    font-size: 0.88rem;
    font-weight: 600;
}

.search-result-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.search-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

/* ===================================
   CONTEXT LINKS & BADGES (NEW)
   Cross-module connection indicators
   =================================== */
.entity-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.entity-link:hover {
    background: var(--primary);
    color: #fff;
}

.entity-link.el-success {
    background: var(--success-light);
    color: var(--success);
}

.entity-link.el-success:hover {
    background: var(--success);
    color: #fff;
}

.entity-link.el-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.entity-link.el-warning:hover {
    background: var(--warning);
    color: #fff;
}

/* === Status Badges (Enhanced) === */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.sb-active {
    background: var(--success-light);
    color: var(--success);
}

.status-badge.sb-pending {
    background: var(--warning-light);
    color: var(--warning);
}

.status-badge.sb-closed {
    background: var(--bg-light);
    color: var(--text-muted);
}

.status-badge.sb-danger {
    background: var(--danger-light);
    color: var(--danger);
}

/* ===================================
   QUICK-VIEW PANEL (NEW)
   Slide-in context panel
   =================================== */
.quick-view-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    background: #fff;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.quick-view-panel.show {
    transform: translateX(0);
}

.quick-view-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.quick-view-header h6 {
    margin: 0;
    font-weight: 700;
}

.quick-view-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.quick-view-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

.quick-view-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1090;
    display: none;
}

.quick-view-overlay.show {
    display: block;
}

/* ===================================
   UTILITY CLASSES
   =================================== */
.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background: var(--primary-light) !important;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.8rem;
}

.category-badge.cat-a {
    background: #dcfce7;
    color: var(--success);
}

.category-badge.cat-b {
    background: #dbeafe;
    color: var(--primary);
}

.category-badge.cat-c {
    background: #fef3c7;
    color: var(--warning);
}

.category-badge.cat-d {
    background: var(--bg-light);
    color: var(--text-secondary);
}

/* === Section Header (NEW) === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header .section-count {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 700;
}

/* === Info Cards (NEW) === */
.info-row {
    display: flex;
    align-items: baseline;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    width: 140px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.info-value {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* === Tabs (Enhanced) === */
.crm-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.crm-tab {
    padding: 10px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.crm-tab:hover {
    color: var(--primary);
}

.crm-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.crm-tab .tab-count {
    background: var(--bg-light);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.7rem;
}

.crm-tab.active .tab-count {
    background: var(--primary-light);
    color: var(--primary);
}

/* ===================================
   FORM ENHANCEMENTS
   =================================== */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: #475569;
    margin-bottom: 4px;
}

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-toggle-close {
        display: block;
    }

    .sidebar-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .page-content {
        padding: 16px;
    }

    .pipeline-board {
        padding-bottom: 8px;
    }

    .pipeline-column {
        min-width: 260px;
    }

    .quick-view-panel {
        width: 100%;
    }

    .notification-panel {
        right: 12px;
        width: calc(100vw - 24px);
    }

    .search-box {
        margin: 0 16px;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.sidebar-overlay.active {
    display: block;
}

/* === Scrollbar === */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

/* === Animations === */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.crm-card {
    animation: fadeIn 0.3s ease;
}

.stat-card {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Staggered loading for dashboard cards */
.stat-card:nth-child(1) {
    animation-delay: 0s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.05s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.15s;
}

.stat-card:nth-child(5) {
    animation-delay: 0.2s;
}

/* === Print === */
@media print {

    .sidebar,
    .topbar,
    .sidebar-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .page-content {
        padding: 0 !important;
    }
}

/* ===================================
   LOGIN SCREEN
   =================================== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    animation: fadeIn 0.4s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.login-logo i {
    font-size: 1.8rem;
    color: #fff;
}

.login-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-header p {
    font-size: 0.9rem;
    margin-bottom: 0;
}

.login-card .form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: #475569;
}

.login-card .input-group-text {
    background: #f8fafc;
    border-color: var(--border-color);
    color: var(--text-muted);
}

.login-card .form-control {
    border-color: var(--border-color);
    padding: 10px 14px;
}

.login-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.login-card .btn-primary {
    padding: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    transition: background 0.2s;
}

.login-card .btn-primary:hover {
    background: var(--primary-dark);
}

.login-card .btn-primary:disabled {
    background: var(--text-muted);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px);
    }
}

.login-card .alert-danger {
    animation: shake 0.5s ease;
}

/* ===================================
   LEADS PAGE
   =================================== */
#leadsTabs .nav-link {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    border: 1px solid transparent;
    padding: 8px 16px;
    transition: all var(--transition-fast);
}

#leadsTabs .nav-link:hover {
    color: var(--primary);
    background: var(--primary-light);
}

#leadsTabs .nav-link.active {
    color: var(--primary);
    background: #fff;
    border-color: var(--border-color) var(--border-color) #fff;
}

#leadsTabs .badge {
    font-size: 0.65rem;
    vertical-align: middle;
}

#leadAppTab .card {
    transition: all 0.2s ease;
    border-radius: var(--radius-md);
}

#leadModal .nav-pills .nav-link {
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

#leadModal .nav-pills .nav-link.active {
    background: var(--primary);
    color: #fff;
}

#leadModal .form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

#leadAppImportModal .card-body .form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ============================================================
   Sidebar-Collapse (Desktop, icons-only) + Breadcrumb-Redesign
   ============================================================ */

/* Nur width/margin/opacity animieren -> fluessig, kein Ruckeln */
.sidebar { transition: transform 0.3s ease, width 0.22s ease; }
.main-content { transition: margin-left 0.22s ease; }
.sidebar-link { position: relative; }
.sidebar-link span,
.sidebar-brand-text,
.sidebar-user-info,
.sidebar-divider span { transition: opacity 0.12s ease; }

/* Desktop-Collapse-Button in der Topbar */
#sidebarCollapseBtn { color: var(--text-secondary); font-size: 1.15rem; text-decoration: none; padding: 4px 8px; border: none; background: none; }
#sidebarCollapseBtn:hover { color: var(--primary); }
#sidebarCollapseBtn i { transition: transform 0.2s ease; display: inline-block; }

@media (min-width: 992px) {
  html.sidebar-collapsed { --sidebar-width: 72px; }
  html.sidebar-collapsed .sidebar { overflow: hidden; }
  html.sidebar-collapsed .sidebar-nav { overflow-x: hidden; }
  html.sidebar-collapsed .sidebar-link { justify-content: center; padding-left: 0; padding-right: 0; }
  html.sidebar-collapsed .sidebar-link i { margin: 0; }
  html.sidebar-collapsed .sidebar-link span { opacity: 0; position: absolute; left: 100%; pointer-events: none; }
  html.sidebar-collapsed .sidebar-brand-text,
  html.sidebar-collapsed .sidebar-user-info,
  html.sidebar-collapsed .sidebar-divider span { display: none; }
  /* Logo + Avatar behalten ihre Groesse (kein Schrumpfen durch Flex) */
  .sidebar-brand-icon, .sidebar-user-avatar { flex-shrink: 0; }
  html.sidebar-collapsed .sidebar-brand, html.sidebar-collapsed .sidebar-user { gap: 0; }
  html.sidebar-collapsed .sidebar-header { justify-content: center; padding-left: 0; padding-right: 0; }
  html.sidebar-collapsed .sidebar-user { justify-content: center; }
  html.sidebar-collapsed .sidebar-divider { text-align: center; }
  html.sidebar-collapsed #sidebarCollapseBtn i { transform: rotate(180deg); }
}

/* Breadcrumb als dezente Eyebrow-Zeile UEBER dem Titel */
.crm-breadcrumb {
  padding: 0;
  margin: 0 0 12px 0;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.2;
}
.crm-breadcrumb a { color: var(--text-muted); text-decoration: none; transition: color 0.15s ease; display: inline-flex; align-items: center; }
.crm-breadcrumb a:hover { color: var(--primary); }
.crm-breadcrumb .separator { color: var(--border-color); display: inline-flex; align-items: center; }
.crm-breadcrumb .separator i { font-size: 0.62rem; }
.crm-breadcrumb .current { color: var(--text-secondary); font-weight: 600; }

/* === Sales Flow Bar (Stufe 2) === */
.flow-bar { border: 1px solid var(--border-color); border-radius: 12px; background: #fff; padding: 14px 16px; margin-bottom: 20px; }
.flow-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.flow-title { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.flow-count { font-size: 0.78rem; color: var(--text-muted); }
.flow-steps { display: flex; align-items: flex-start; }
.flow-stage { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.flow-conn { flex: 1; height: 2px; background: var(--border-color); margin-top: 17px; }
.flow-conn.done { background: var(--success); }
.flow-dot { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; background: var(--bg-light); color: var(--text-muted); border: 1px solid var(--border-color); }
.flow-label { font-size: 0.74rem; margin-top: 6px; color: var(--text-muted); line-height: 1.2; }
.flow-sub { font-size: 0.68rem; color: var(--text-muted); margin-top: 1px; }
.flow-stage.done .flow-dot { background: var(--success-light); color: var(--success); border-color: var(--success); }
.flow-stage.done .flow-label { color: #334155; font-weight: 500; }
.flow-stage.active .flow-dot { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.flow-stage.active .flow-label { color: var(--primary); font-weight: 600; }
.flow-stage.active .flow-sub { color: var(--primary); }
.flow-stage.pending .flow-dot { opacity: 0.7; }
.flow-stage.skipped .flow-dot { background: transparent; border-style: dashed; opacity: 0.5; }
.flow-stage.skipped .flow-label, .flow-stage.skipped .flow-sub { opacity: 0.5; text-decoration: line-through; }
.flow-stage.lost .flow-dot { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.flow-stage.lost .flow-label, .flow-stage.lost .flow-sub { color: var(--danger); font-weight: 600; }
.flow-origin { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-color); font-size: 0.78rem; color: var(--text-muted); }
.flow-origin-label { color: var(--text-muted); }
.flow-node { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 7px; background: var(--bg-light); color: #334155; text-decoration: none; font-weight: 500; }
a.flow-node:hover { background: var(--primary-light); color: var(--primary); }
.flow-node.current { background: var(--primary-light); color: var(--primary); }
.flow-sep { font-size: 0.7rem; color: var(--text-muted); }
@media (max-width: 640px) { .flow-label, .flow-sub { font-size: 0.66rem; } .flow-dot { width: 30px; height: 30px; } }

/* === Sales Companion (Stufe 4) === */
.companion-fab { position: fixed; right: 24px; bottom: 24px; width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff; border: none; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); font-size: 1.3rem; z-index: 1060; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.companion-fab:hover { background: var(--primary-dark); }
/* UAT-018: keep the Sales Assistant FAB clear of the open cart summary. */
body.cart-open .companion-fab { display: none; }
.companion-badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 0.72rem; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.companion-panel { position: fixed; right: 24px; bottom: 88px; width: 360px; max-width: calc(100vw - 48px); max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--border-color); border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18); z-index: 1061; display: none; }
.companion-panel.open { display: block; }
.comp-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border-color); position: sticky; top: 0; background: #fff; }
.comp-title { font-weight: 600; font-size: 0.95rem; }
.comp-body { padding: 12px 16px; }
.comp-group { margin-bottom: 14px; }
.comp-group-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 8px; }
.comp-gap { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--bg-light); }
.comp-gap:last-child { border-bottom: none; }
.comp-gap-label { font-size: 0.85rem; color: #b45309; }
.comp-clean, .comp-empty { text-align: center; padding: 28px 12px; color: var(--text-muted); }
.comp-clean i { font-size: 2rem; color: var(--success); display: block; margin-bottom: 8px; }
.comp-empty i { font-size: 2rem; display: block; margin-bottom: 8px; }
