/* ===== Sidebar Navigation ===== */
.sidebar {
    width: 56px;
    background: #008ecf;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    flex-shrink: 0;
    z-index: 40;
    height: 100vh;
    position: sticky;
    top: 0;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}
.sidebar-link {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.15s ease;
    cursor: pointer;
    text-decoration: none;
    border: none;
    background: transparent;
}
.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
}
.sidebar-link.active {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}
.sidebar-icon {
    width: 21px;
    height: 21px;
}
.sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

/* ===== Top Nav Tabs ===== */
.nav-tab {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 9999px;
    color: #6b7280;
    transition: all 0.15s ease;
    text-decoration: none;
}
.nav-tab:hover {
    color: #1f2937;
    background: #f3f4f6;
}
.nav-tab.active {
    color: #008ecf;
    background: rgba(0, 142, 207, 0.08);
}

/* ===== Filter Bar ===== */
.filter-group-v2 {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.filter-label-v2 {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.filter-input-v2 {
    font-size: 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 12px;
    color: #1f2937;
    transition: all 0.15s ease;
    outline: none;
}
.filter-input-v2:focus {
    border-color: #008ecf;
    box-shadow: 0 0 0 3px rgba(0, 142, 207, 0.15);
}

/* Granularity toggle */
.gran-btn-v2 {
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 600;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    border-right: 1px solid #e5e7eb;
}
.gran-btn-v2:last-child {
    border-right: none;
}
.gran-btn-v2:hover {
    background: #f9fafb;
}
.gran-btn-v2.active {
    background: #008ecf;
    color: #fff;
}

/* ===== Date presets ===== */
.date-preset {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    color: #6b7280;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.15s ease;
}
.date-preset:hover {
    background: rgba(0, 142, 207, 0.06);
    color: #008ecf;
    border-color: rgba(0, 142, 207, 0.3);
}
.date-preset.active {
    background: #008ecf;
    color: #fff;
    border-color: #008ecf;
}

/* ===== Period browser ===== */
.period-type-btn {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    border-right: 1px solid #e5e7eb;
}
.period-type-btn:last-child {
    border-right: none;
}
.period-type-btn:hover {
    background: #f9fafb;
}
.period-type-btn.active {
    background: #008ecf;
    color: #fff;
}
.period-nav-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: transparent;
}
.period-nav-btn:hover {
    background: #f3f4f6;
    color: #374151;
}
.period-pill {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    white-space: nowrap;
    color: #4b5563;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.period-pill:hover {
    background: rgba(0, 142, 207, 0.06);
    color: #008ecf;
    border-color: rgba(0, 142, 207, 0.3);
}
.period-pill.active {
    background: #008ecf;
    color: #fff;
    border-color: #008ecf;
}
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ===== Custom Multiselect ===== */
.ms-trigger-v2 {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    font-size: 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #1f2937;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    min-width: 100px;
}
.ms-trigger-v2:hover {
    border-color: #d1d5db;
}
.ms-trigger-v2.open {
    border-color: #008ecf;
    box-shadow: 0 0 0 3px rgba(0, 142, 207, 0.15);
}
.ms-trigger-v2 .ms-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    max-width: 150px;
}
.ms-chevron {
    width: 16px;
    height: 16px;
    color: #9ca3af;
    margin-left: auto;
    flex-shrink: 0;
}
.ms-trigger-v2 .ms-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 9999px;
    background: #008ecf;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 0 6px;
}

.ms-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 50;
    min-width: 240px;
    max-height: 360px;
    overflow: hidden;
}
.ms-dropdown .ms-search {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    background: #f9fafb;
    border: none;
    border-bottom: 1px solid #e5e7eb;
    color: #1f2937;
    outline: none;
}
.ms-dropdown .ms-search::placeholder {
    color: #9ca3af;
}
.ms-dropdown .ms-search:focus {
    background: #fff;
}
.ms-dropdown .ms-actions {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
    background: rgba(249, 250, 251, 0.5);
}
.ms-dropdown .ms-action-btn {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: transparent;
}
.ms-dropdown .ms-action-btn:hover {
    color: #008ecf;
    background: rgba(0, 142, 207, 0.06);
}
.ms-dropdown .ms-options {
    overflow-y: auto;
    max-height: 260px;
    padding: 4px 0;
}
.ms-dropdown .ms-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    transition: all 0.1s ease;
}
.ms-dropdown .ms-option:hover {
    background: #f9fafb;
}
.ms-dropdown .ms-option.selected {
    color: #111827;
    background: rgba(0, 142, 207, 0.04);
}
.ms-dropdown .ms-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.ms-dropdown .ms-option.selected .ms-checkbox {
    border-color: #008ecf;
    background: #008ecf;
}
.ms-dropdown .ms-check-icon {
    display: none;
}
.ms-dropdown .ms-option.selected .ms-check-icon {
    display: block;
    color: #fff;
}

/* Inactive users divider & group */
.ms-inactive-divider {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.1s ease;
    border-top: 1px solid #f3f4f6;
    margin-top: 4px;
}
.ms-inactive-divider:hover {
    background: #f9fafb;
}
.ms-inactive-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.ms-option-inactive {
    opacity: 0.7;
}

/* ===== KPI Cards ===== */
.kpi-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.kpi-card .kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin-top: 4px;
}
.kpi-card .kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.kpi-card .kpi-sub {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
}
.kpi-comparisons {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.kpi-cmp {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
}
.kpi-cmp-positive { color: #059669; }
.kpi-cmp-negative { color: #dc2626; }
.kpi-cmp-neutral { color: #9ca3af; }
.kpi-cmp-arrow { font-size: 10px; }
.kpi-cmp-pct { font-weight: 700; }
.kpi-cmp-diff { color: #6b7280; font-weight: 400; }
.kpi-cmp-label { color: #9ca3af; font-weight: 400; font-size: 10px; }

/* ===== Charts ===== */
.chart-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    min-width: 0;
}
.chart-card .chart-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 16px;
}

/* ===== Table header tooltip ===== */
.th-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 9999px;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 9px;
    font-weight: 700;
    margin-left: 3px;
    vertical-align: middle;
    cursor: help;
    flex-shrink: 0;
}
th[title] {
    cursor: help;
}

/* ===== Data Table ===== */
.data-table {
    width: 100%;
    font-size: 14px;
}
.data-table thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 12px;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    user-select: none;
}
.data-table thead th:hover {
    color: #374151;
}
.data-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
}
.data-table tbody tr {
    cursor: pointer;
    transition: background 0.1s ease;
}
.data-table tbody tr:hover {
    background: #f9fafb;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Status badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}
.badge-new { background: #dcfce7; color: #15803d; }
.badge-contacted { background: #dbeafe; color: #1d4ed8; }
.badge-followup { background: #fef9c3; color: #854d0e; }
.badge-hot { background: #ffedd5; color: #c2410c; }
.badge-lost { background: #fee2e2; color: #b91c1c; }
.badge-to-contracting { background: #f3e8ff; color: #7c3aed; }
.badge-postponed { background: #f3f4f6; color: #4b5563; }
.badge-pending { background: #f3f4f6; color: #6b7280; }
.badge-contracting { background: #e0e7ff; color: #4338ca; }
.badge-commissions { background: #d1fae5; color: #059669; }

/* ===== Slide-over animation ===== */
#lead-detail-panel {
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
}
#lead-detail-overlay.open #lead-detail-panel {
    transform: translateX(0);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    justify-content: center;
}
.pagination button {
    padding: 4px 12px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    color: #4b5563;
    background: #fff;
    cursor: pointer;
}
.pagination button:hover:not(:disabled) {
    background: #f3f4f6;
}
.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination button.active {
    background: #008ecf;
    color: #fff;
    border-color: #008ecf;
}

/* ===== Section headers ===== */
.section-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 16px;
}

/* ===== Leaderboard ===== */
.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s ease;
}
.leaderboard-row:hover {
    background: #f9fafb;
}
.leaderboard-rank {
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}

/* ===== Loading spinner ===== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #008ecf;
    border-radius: 9999px;
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Scrollbar styling ===== */
.ms-options::-webkit-scrollbar {
    width: 6px;
}
.ms-options::-webkit-scrollbar-track {
    background: transparent;
}
.ms-options::-webkit-scrollbar-thumb {
    background-color: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}
.ms-options::-webkit-scrollbar-thumb:hover {
    background-color: rgba(148, 163, 184, 0.5);
}

/* Legacy compatibility */
.filter-input {
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 4px 8px;
    outline: none;
}
.filter-input:focus {
    border-color: #008ecf;
    box-shadow: 0 0 0 3px rgba(0, 142, 207, 0.15);
}
