:root {
    --sidebar-width: 220px;
    --sidebar-collapsed-width: 74px;
    --sidebar-bg: #2d3349;
    --sidebar-text: #a2a5b9;
    --sidebar-active-bg: rgba(255,255,255,0.05);
    --sidebar-active-text: #ffffff;
    --sidebar-hover-bg: rgba(255,255,255,0.03);
    --sidebar-icon: #525672;
    --top-bar-bg: #ffffff;
    --body-bg: #eef0f8;
    --primary: #5d78ff;
    --success: #0abb87;
    --warning: #ffb822;
    --danger: #fd397a;
    --info: #2786f1;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    background: var(--body-bg);
    margin: 0;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease, transform 0.3s ease;
    display: flex;
    flex-direction: column;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }

.sidebar-logo {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo img, .sidebar-logo svg { height: 52px; margin-right: 8px; }
.sidebar-logo .logo-text { color: #fff; font-size: 18px; font-weight: 700; }

.sidebar-nav { flex: 1; padding: 10px 0; }

.sidebar-nav .nav-item { list-style: none; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    gap: 12px;
    white-space: nowrap;
    position: relative;
}
.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-active-text);
}
.sidebar-nav .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-left: 3px solid var(--primary);
    padding-left: 17px;
}
.sidebar-nav .nav-link i {
    font-size: 17px;
    width: 22px;
    text-align: center;
    color: var(--sidebar-icon);
    flex-shrink: 0;
}
.sidebar-nav .nav-link.active i,
.sidebar-nav .nav-link:hover i {
    color: var(--primary);
}
.sidebar-nav .nav-link .arrow {
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.2s;
}

.sidebar-nav .submenu {
    display: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.1);
}
.sidebar-nav .submenu.show { display: block; }
.sidebar-nav .submenu .nav-link {
    padding: 7px 20px 7px 54px;
    font-size: 12px;
}

.sidebar-flyout {
    position: fixed;
    z-index: 1200;
    min-width: 220px;
    max-width: 280px;
    background: #303652;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(17, 21, 35, 0.35);
    padding: 8px;
    display: none;
}

.sidebar-flyout.show {
    display: block;
}

.sidebar-flyout-title {
    color: #c9cde2;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 4px 8px 8px;
}

.sidebar-flyout-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-flyout-menu li + li {
    margin-top: 2px;
}

.sidebar-flyout-link {
    display: block;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    padding: 7px 10px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-flyout-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-active-text);
}

.sidebar-flyout-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.sidebar-collapse {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-collapse a {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-collapse a:hover { color: #fff; }

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}
.main-content.expanded { margin-left: var(--sidebar-collapsed-width); }

.sidebar.collapsed .sidebar-logo {
    justify-content: center;
    padding: 0 8px;
}

.sidebar.collapsed .sidebar-logo .logo-text {
    display: none;
}

.sidebar.collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
    font-size: 0;
}

.sidebar.collapsed .sidebar-nav .nav-link.active {
    padding-left: 0;
    border-left: none;
    box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar.collapsed .sidebar-nav .nav-link .arrow {
    display: none;
}

.sidebar.collapsed .sidebar-nav .nav-link.flyout-open {
    background: var(--sidebar-active-bg);
}

.sidebar.collapsed .sidebar-nav .submenu {
    display: none !important;
}

.sidebar.collapsed .sidebar-collapse {
    display: flex;
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .sidebar-collapse .collapse-label {
    display: none;
}

/* ── Top bar ── */
.top-bar {
    height: 60px;
    background: var(--top-bar-bg);
    border-bottom: 1px solid #e8ecfa;
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
}
.top-bar .page-title {
    font-size: 16px;
    font-weight: 600;
    color: #464457;
}
.top-bar .breadcrumb {
    font-size: 12px;
    margin: 0;
    padding: 0;
}
.top-bar .breadcrumb a { color: var(--primary); text-decoration: none; }
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.top-bar-right .timezone {
    font-size: 12px;
    color: #74788d;
}
.top-bar-right .user-name {
    font-size: 13px;
    color: #595d6e;
    font-weight: 500;
}

/* ── Page content ── */
.page-content {
    padding: 20px;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #464457;
    margin: 0;
}

/* ── Cards / Widgets ── */
.stat-card {
    border-radius: 4px;
    padding: 20px 18px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 4px;
    font-weight: 500;
}
.stat-card.blue { background: linear-gradient(135deg, #5893d4 0%, #416ea5 100%); }
.stat-card.teal { background: linear-gradient(135deg, #48b4a0 0%, #36917f 100%); }
.stat-card.green { background: linear-gradient(135deg, #0abb87 0%, #089e72 100%); }
.stat-card.dark-teal { background: linear-gradient(135deg, #30827a 0%, #256b64 100%); }

/* ── Tables ── */
.data-card {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 0 13px 0 rgba(82,63,105,0.05);
    overflow: hidden;
}
.data-card-header {
    padding: 15px 20px;
    border-bottom: 1px solid #ebedf2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.data-card-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #464457;
    margin: 0;
}
.data-card-body { padding: 0; }
.data-card-body .table { margin: 0; }

.table {
    font-size: 13px;
    width: 100%;
    border-collapse: collapse;
}
.table th {
    background: #f7f8fc;
    font-weight: 600;
    font-size: 12px;
    color: #595d6e;
    padding: 10px 15px;
    border-bottom: 1px solid #ebedf2;
    white-space: nowrap;
    cursor: pointer;
}
.table td {
    padding: 10px 15px;
    border-bottom: 1px solid #ebedf2;
    vertical-align: middle;
    color: #595d6e;
}
.leads-grid th,
.leads-grid td {
    border-right: 1px solid #ebedf2;
}
.leads-grid th:last-child,
.leads-grid td:last-child {
    border-right: 0;
}
.leads-grid .country-flag {
    font-size: 14px;
    line-height: 1;
    margin-right: 6px;
    vertical-align: baseline;
}
.leads-grid .ip-geo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    border-radius: 999px;
    background: #f2f4f9;
    font-size: 11px;
}
.leads-grid .reject-reason-cell {
    max-width: 220px;
}
.leads-grid .reject-reason-text {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.leads-grid-wide th,
.leads-grid-wide td {
    white-space: nowrap;
}
.leads-grid-wide th,
.leads-grid-wide td {
    padding: 8px 10px;
    font-size: 12px;
}
.lead-split-badge {
    display: none;
    margin-left: 6px;
    padding: 0 6px;
    border: 0;
    border-radius: 8px;
    font-size: 10px;
    line-height: 16px;
    background: #eef2ff;
    color: #3949ab;
    cursor: pointer;
    vertical-align: middle;
}
.lead-split-badge.is-visible { display: inline-block; }
.lead-split-child td:first-child { box-shadow: inset 3px 0 0 #3949ab; }
.table tbody tr:hover { background: #f7f8fc; }
.table tbody tr.failed-lead,
.table tbody tr.failed-lead > td,
.table tbody tr.failed-lead > th { background-color: #ffe8e8 !important; --bs-table-bg: #ffe8e8; --bs-table-accent-bg: #ffe8e8; box-shadow: none !important; }
.table tbody tr.failed-lead:hover,
.table tbody tr.failed-lead:hover > td,
.table tbody tr.failed-lead:hover > th { background-color: #ffd0d0 !important; --bs-table-bg: #ffd0d0; --bs-table-accent-bg: #ffd0d0; box-shadow: none !important; }
.table tbody tr.ftd-lead,
.table tbody tr.ftd-lead > td,
.table tbody tr.ftd-lead > th { background-color: #e6f9e6 !important; --bs-table-bg: #e6f9e6; --bs-table-accent-bg: #e6f9e6; box-shadow: none !important; }
.table tbody tr.ftd-lead:hover,
.table tbody tr.ftd-lead:hover > td,
.table tbody tr.ftd-lead:hover > th { background-color: #d4f0d4 !important; --bs-table-bg: #d4f0d4; --bs-table-accent-bg: #d4f0d4; box-shadow: none !important; }
.table .sort-icon { font-size: 10px; margin-left: 3px; color: #aaa; }

/* ── Status badges ── */
.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: lowercase;
}
.badge-active { background: #0abb87; color: #fff; }
.badge-pending { background: #ffb822; color: #111; }
.badge-inactive, .badge-paused { background: #bcc0ce; color: #fff; }
.badge-new { background: var(--primary); color: #fff; }
.badge-broker { background: #8950fc; color: #fff; }
.badge-sent { background: var(--info); color: #fff; }
.badge-deposited { background: #0abb87; color: #fff; }
.badge-rejected { background: var(--danger); color: #fff; }
.badge-duplicate { background: var(--danger); color: #fff; }

.badge-dist-count {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    background: var(--info);
    color: #fff;
}

/* ── Filter layout (30/70 split) ── */
.filter-row {
    display: flex;
    gap: 0;
    align-items: stretch;
}
.filter-row .filter-col {
    width: 24%;
    min-width: 240px;
    max-width: 300px;
    flex-shrink: 0;
    transition: width 0.3s, min-width 0.3s, opacity 0.3s, margin 0.3s;
    overflow: hidden;
}
.filter-row .filter-col.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    opacity: 0;
    margin-left: -1px;
}
.filter-row .content-col {
    flex: 1;
    min-width: 0;
}

/* ── Filter panel ── */
.filter-panel {
    background: #fff;
    border-radius: 0;
    border-right: 1px solid #ebedf2;
    box-shadow: 2px 0 8px rgba(82,63,105,0.04);
    padding: 14px 16px;
    margin-bottom: 0;
    min-height: 100%;
    font-size: 12px;
}
.filter-panel .mb-3 { margin-bottom: 0.6rem !important; }
.filter-panel h6 {
    font-size: 12px;
    font-weight: 700;
    color: #464457;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}
.filter-panel .form-label {
    font-size: 11px;
    font-weight: 600;
    color: #595d6e;
    margin-bottom: 3px;
}
.filter-panel .form-control-sm, .filter-panel .form-select-sm {
    font-size: 11px;
    padding: 4px 8px;
    background-color: #f4f5f8;
    border-color: #e2e5ec;
    border-radius: 4px;
}
.filter-panel .filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.filter-panel .filter-header h6 {
    margin-bottom: 0;
}
.filter-panel .filter-header .btn-group-sm .btn {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
}
.filter-panel .exclude-label {
    font-size: 10px;
    cursor: pointer;
    color: #999;
    text-align: right;
    display: block;
    margin-top: 2px;
}
.filter-panel .exclude-label input {
    margin-right: 3px;
}

/* Top action buttons (SHARE FILTERS, HIDE FILTER) */
.filter-actions-bar {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-bottom: 6px;
}
.filter-actions-bar .btn {
    font-size: 12px;
    padding: 5px 14px;
    font-weight: 500;
}

/* ── Group-by buttons ── */
.group-by-bar {
    text-align: center;
    margin-bottom: 15px;
}
.group-by-bar .btn-group .btn {
    padding: 8px 25px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.group-by-bar .btn-group .btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.group-by-bar .btn-group .btn:not(.active) {
    background: #fff;
    border-color: #dee2e6;
    color: #595d6e;
}

/* ── Country flag ── */
.country-flag {
    width: 20px;
    height: 14px;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
    border-radius: 2px;
    background: #ddd;
    font-size: 9px;
    text-align: center;
    line-height: 14px;
    color: #666;
    font-weight: 700;
}

/* ── Action buttons ── */
.btn-action {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: none;
    font-size: 14px;
    cursor: pointer;
}
.btn-action.settings { background: var(--primary); color: #fff; }
.btn-action.settings:hover { background: #4a68e0; }
.btn-action.delete { background: var(--danger); color: #fff; }
.btn-action.delete:hover { background: #e02b65; }
.btn-action.dropdown-toggle::after { display: none; }

/* ── Auth pages ── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2d3349 0%, #1a1e2e 100%);
}
.auth-card {
    background: #fff;
    border-radius: 8px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

/* ── Forms ── */
.form-container {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 0 13px 0 rgba(82,63,105,0.05);
    padding: 24px;
}
.form-label { font-weight: 600; color: #595d6e; font-size: 12px; }
.form-control, .form-select {
    font-size: 13px;
    border-color: #e2e5ec;
    border-radius: 4px;
    color: #595d6e;
}
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23595d6e' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 16px 12px !important;
    padding-right: 2.25rem !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.15rem rgba(93,120,255,0.2);
}
.form-control::placeholder { color: #adb5bd; }

/* ── Tabs ── */
.nav-tabs {
    border-bottom: 1px solid #ebedf2;
    gap: 0;
}
.nav-tabs .nav-link {
    font-size: 13px;
    font-weight: 500;
    color: #74788d;
    border: none;
    padding: 10px 18px;
    border-bottom: 2px solid transparent;
    border-radius: 0;
}
.nav-tabs .nav-link:hover { color: var(--primary); border-color: transparent; }
.nav-tabs .nav-link.active {
    color: var(--primary);
    font-weight: 600;
    border-bottom-color: var(--primary);
    background: none;
}
.nav-tabs .nav-link i { margin-right: 5px; }

/* ── Pagination ── */
.pagination { margin: 0; }
.page-link {
    font-size: 13px;
    color: #5d78ff;
    border-color: #ebedf2;
    padding: 6px 12px;
}
.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ── Buttons ── */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover { background: #4a68e0; border-color: #4a68e0; }

.btn-add {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-add:hover { background: #4a68e0; color: #fff; }

.btn-filter {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-filter:hover { background: #4a68e0; color: #fff; }

/* ── Show N records ── */
.records-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #595d6e;
}
.records-selector select {
    width: auto;
    display: inline-block;
    padding: 4px 8px;
    font-size: 13px;
}

/* ── Search bar ── */
.search-bar {
    position: relative;
    max-width: 350px;
}
.search-bar input {
    padding-left: 36px;
}
.search-bar i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
}

/* ── Breadcrumb ── */
.page-breadcrumb {
    font-size: 11px;
    margin-bottom: 8px;
}
.page-breadcrumb a { color: var(--primary); text-decoration: none; }
.page-breadcrumb span { color: #74788d; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }
    .sidebar.collapsed {
        width: var(--sidebar-width);
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .main-content.expanded { margin-left: 0; }
    .sidebar-flyout { display: none !important; }
}

/* ── Scrollbar ── */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ── Legacy table-container (used in many templates) ── */
.table-container {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 0 13px 0 rgba(82,63,105,0.05);
    overflow: hidden;
    margin-bottom: 15px;
}
.table-header {
    padding: 15px 20px;
    border-bottom: 1px solid #ebedf2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.table-header h6 {
    font-size: 14px;
    font-weight: 600;
    color: #464457;
    margin: 0;
}

/* ── Notification badge ── */
.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ── Alerts ── */
.alert { font-size: 13px; border-radius: 4px; }

/* ── Dropdown ── */
.dropdown-menu { font-size: 13px; }
.dropdown-item { padding: 6px 16px; }
.dropdown-item i { width: 16px; }

/* ── Icon tabs (Reports/Leads) ── */
.icon-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    border-bottom: 2px solid #ebedf2;
    margin-bottom: 10px;
}
.icon-tabs .icon-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    color: #74788d;
    text-decoration: none;
    font-size: 13px;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    cursor: pointer;
}
.icon-tabs .icon-tab:hover {
    color: var(--primary);
}
.icon-tabs .icon-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.icon-tabs .icon-tab i {
    font-size: 14px;
}
.icon-tabs .icon-tab .tab-label {
    font-size: 12px;
    font-weight: 500;
}
.icon-tabs .icon-tab.active .tab-label {
    font-weight: 600;
}

.stats-subtabs-wrap .stats-subtabs .btn-outline-secondary.active {
    color: #fff;
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ── Stat card mini (Reports page) ── */
.stat-card-mini {
    border-radius: 6px;
    padding: 14px 12px;
    color: #fff;
    min-width: 0;
}
.stat-card-mini-value {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}
.stat-card-mini-label {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 3px;
    font-weight: 500;
}
.stat-grey { background: #b0bec5; color: #fff; }
.stat-teal { background: #a8d8d0; color: #37474f; }

/* ── Details table compact ── */
#detailsTable { font-size: 11px; border-collapse: collapse; width: 100%; }
#detailsTable thead { background: #333333; }
#detailsTable th { font-size: 11px; font-weight: 500; white-space: nowrap; padding: 5px 6px; background: #333333; border-bottom: 1px solid rgba(255,255,255,0.35); cursor: pointer; color: #ffffff !important; text-transform: none; font-family: Roboto, sans-serif; }
#detailsTable th .bi-arrow-down-up { font-size: 9px; opacity: 0.5; }
#detailsTable td { padding: 3px 6px; white-space: nowrap; vertical-align: middle; border-bottom: 1px solid #ebedf2; color: #000000; font-size: 11px; }
#detailsTable tbody tr:hover { background-color: #f0f3ff !important; }
#detailsTable tbody tr.failed-lead,
#detailsTable tbody tr.failed-lead > td,
#detailsTable tbody tr.failed-lead > th { background-color: #ffe8e8 !important; --bs-table-bg: #ffe8e8; --bs-table-accent-bg: #ffe8e8; box-shadow: none !important; }
#detailsTable tbody tr.failed-lead:hover,
#detailsTable tbody tr.failed-lead:hover > td,
#detailsTable tbody tr.failed-lead:hover > th { background-color: #ffd0d0 !important; --bs-table-bg: #ffd0d0; --bs-table-accent-bg: #ffd0d0; box-shadow: none !important; }
#detailsTable tbody tr.ftd-lead,
#detailsTable tbody tr.ftd-lead > td,
#detailsTable tbody tr.ftd-lead > th { background-color: #e6f9e6 !important; --bs-table-bg: #e6f9e6; --bs-table-accent-bg: #e6f9e6; box-shadow: none !important; }
#detailsTable tbody tr.ftd-lead:hover,
#detailsTable tbody tr.ftd-lead:hover > td,
#detailsTable tbody tr.ftd-lead:hover > th { background-color: #d4f0d4 !important; --bs-table-bg: #d4f0d4; --bs-table-accent-bg: #d4f0d4; box-shadow: none !important; }
#brokerHistoryTable tbody tr.ftd-lead,
#brokerHistoryTable tbody tr.ftd-lead > td { background-color: #e6f9e6 !important; box-shadow: none !important; }
#brokerHistoryTable tbody tr.failed-lead,
#brokerHistoryTable tbody tr.failed-lead > td { background-color: #ffe8e8 !important; box-shadow: none !important; }
#detailsTable .form-check-input { margin: 0; width: 14px; height: 14px; }
/* Color legend popup */
.color-legend-popup { position: fixed; bottom: 60px; right: 20px; background: #fff; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); padding: 16px; z-index: 1050; min-width: 220px; display: none; }
.color-legend-popup.show { display: block; }
.color-legend-item { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 12px; }
.color-legend-item .color-block { width: 30px; height: 18px; border-radius: 3px; border: 1px solid #eee; }
/* Send to broker modal */
.bulk-action-modal .modal-body { max-height: 400px; overflow-y: auto; }

/* Broker history modal (frtrack-like sizing + request block) */
#brokerHistoryModal .modal-dialog {
    max-width: 1160px;
    width: calc(100vw - 96px);
}
#brokerHistoryModal .modal-content {
    border: 1px solid #dfe3ee;
    border-radius: 4px;
}
#brokerHistoryModal .modal-header {
    padding: 10px 14px;
    border-bottom: 1px solid #eceff6;
}
#brokerHistoryModal .modal-title {
    font-size: 14px;
    font-weight: 600;
    color: #3f4254;
}
#brokerHistoryModal .modal-body {
    padding: 10px 14px;
    max-height: 62vh;
}
#brokerHistoryModal .modal-footer {
    padding: 8px 14px;
    border-top: 1px solid #eceff6;
}
#brokerHistoryModal .btn-hide {
    min-width: 72px;
    font-size: 12px;
    font-weight: 500;
}

#brokerHistoryTable {
    font-size: 11px;
    margin-bottom: 0;
}
#brokerHistoryTable th {
    font-size: 11px;
    font-weight: 600;
    color: #3f4254;
    background: #f8f9fc;
    white-space: nowrap;
    padding: 6px 8px;
}
#brokerHistoryTable td {
    vertical-align: top;
    padding: 6px 8px;
    color: #181c32;
    line-height: 1.35;
}

.broker-history-response {
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 360px;
}

.broker-request-details {
    margin: 0;
}
.broker-request-details > summary {
    cursor: pointer;
    color: #3699ff;
    font-size: 11px;
    font-weight: 500;
    user-select: none;
    list-style: none;
}
.broker-request-details > summary::-webkit-details-marker {
    display: none;
}
.broker-request-details > summary::before {
    content: '\25b8';
    display: inline-block;
    margin-right: 5px;
    transition: transform 0.15s ease;
}
.broker-request-details[open] > summary::before {
    transform: rotate(90deg);
}
.broker-request-code {
    margin: 6px 0 0;
    padding: 7px 8px;
    border: 1px solid #e8ebf3;
    border-radius: 3px;
    background: #fbfcff;
    font-size: 11px;
    line-height: 1.3;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 430px;
}

/* ── Top bar breadcrumb line ── */
.top-bar {
    border-bottom: 1px solid #e8ecfa;
}

/* ── Page header (title + action btn) ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.page-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #464457;
    margin: 0;
}

/* ── Bar chart (Stats page) ── */
.bar-chart-section {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 0 13px 0 rgba(82,63,105,0.05);
    padding: 16px 20px;
}
.bar-chart-section.is-collapsed .bar-chart-body { display: none; }
.bar-chart-title {
    font-size: 13px;
    font-weight: 600;
    color: #464457;
    margin-bottom: 12px;
}
.bar-chart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.bar-chart-label {
    width: 80px;
    font-size: 11px;
    font-weight: 600;
    color: #595d6e;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}
.bar-chart-track {
    flex: 1;
    height: 22px;
    background: #eef0f8;
    border-radius: 3px;
    overflow: hidden;
}
.bar-chart-fill {
    height: 100%;
    background: linear-gradient(90deg, #5d78ff 0%, #48b4a0 100%);
    border-radius: 3px;
    min-width: 2px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    transition: width 0.3s ease;
}
.bar-chart-value {
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

/* Offers: vertical chart style close to legacy report */
.offers-chart {
    overflow-x: auto;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    padding: 10px 12px 6px;
    background: #fff;
}
.offers-chart-grid {
    height: 210px;
    /* всегда одна строка: если стран много (до 100) — график прокручивается вбок, а не переносится на таблицу */
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-width: 100%;
    width: max-content;
}
.offers-chart-col {
    flex: 1 0 38px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}
.offers-chart-value {
    font-size: 10px;
    color: #707684;
    margin-bottom: 3px;
    line-height: 1;
}
.offers-chart-bar-wrap {
    height: 160px;
    width: 22px;
    display: flex;
    align-items: flex-end;
    background: linear-gradient(to top, #f2f4f8 0%, #ffffff 100%);
    border: 1px solid #edf0f5;
    border-radius: 2px;
    overflow: hidden;
}
.offers-chart-bar {
    width: 100%;
    background: #98cfa0;
    border-top: 1px solid #7eb989;
    min-height: 2px;
}
.offers-chart-label {
    margin-top: 5px;
    font-size: 9px;
    color: #636a78;
    text-align: center;
    line-height: 1.1;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Expandable rows ── */
.expandable-row { cursor: pointer; }
.expandable-row:hover { background: #f2f4ff !important; }
.expand-toggle { width: 30px; text-align: center; }
.expand-arrow {
    font-size: 10px;
    transition: transform 0.2s;
    color: #aaa;
}
.expand-arrow.open { transform: rotate(90deg); color: var(--primary); }
.child-row { background: #fafbff; }
.child-row td { font-size: 12px; color: #74788d; border-bottom: 1px solid #f0f1f5; }

/* ── Grouping dropdown ── */
.grouping-dropdown {
    width: 160px;
    font-size: 12px;
    font-weight: 600;
    color: #464457;
    border-color: #dee2e6;
}

/* ── Column visibility dropdown ── */
.col-vis-item { transition: background .1s; }
.col-vis-item:hover { background: #f7f8fc; }

/* ── Sortable columns ── */
.stats-table th.sortable { cursor: pointer; user-select: none; }
.stats-table th.sortable:hover { color: var(--primary); }

/* ── Drill-down popup ── */
.drilldown-popup {
    background: #fff;
    border: 1px solid #e2e5ec;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 6px 0;
    min-width: 170px;
    max-height: 75vh;
    overflow-y: auto;
    z-index: 1050;
}
.drilldown-popup .dd-link {
    display: block;
    padding: 6px 16px;
    font-size: 12px;
    color: #464457;
    text-decoration: none;
    white-space: nowrap;
}
.drilldown-popup .dd-link:hover {
    background: #f2f4ff;
    color: var(--primary);
}
.drilldown-popup .dd-link.dd-disabled,
.drilldown-popup .dd-link.dd-disabled:hover {
    color: #b5b5c3;
    background: transparent;
    cursor: default;
    pointer-events: none;
}
.drilldown-popup .dd-link.dd-disabled i,
.drilldown-popup .dd-link.dd-disabled:hover i {
    color: #b5b5c3;
}
.drilldown-popup .dd-link i {
    width: 16px;
    margin-right: 8px;
    color: #74788d;
    font-size: 12px;
}
.drilldown-popup .dd-divider {
    height: 1px;
    background: #ebedf2;
    margin: 4px 0;
}

/* ── Breakdown toggle ── */
.breakdown-toggle { cursor: pointer; }
.breakdown-toggle:hover .breakdown-arrow { color: var(--primary); }
.breakdown-arrow {
    font-size: 10px;
    transition: transform 0.2s;
    color: #aaa;
}
.breakdown-arrow.bi-chevron-down { color: var(--primary); }

/* ── Drill-down sub-table ── */
.drilldown-container td { border-bottom: none !important; }
.drilldown-content .table { background: transparent; }
.drilldown-content .table th {
    background: #eef0f5;
    font-size: 11px !important;
    padding: 6px 10px;
}
.drilldown-content .table td {
    padding: 6px 10px;
    font-size: 12px;
    border-bottom-color: #f0f1f5;
}
.drilldown-content .table tfoot td {
    background: #e8eaf0;
    font-size: 11px;
}

/* ── Spinner for loading ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 1s linear infinite; }

/* ── Cell alignment ── */
.cell-align-top td { vertical-align: top; }
.cursor-pointer { cursor: pointer; }

/* ── Notification dropdown (bell) ── */
.notif-dropdown {
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    border: 1px solid #e2e5ec;
}
.notif-dropdown .notif-dropdown-body::-webkit-scrollbar { width: 4px; }
.notif-dropdown .notif-dropdown-body::-webkit-scrollbar-thumb { background: #d0d5e8; border-radius: 4px; }

/* ── Notification page empty state ── */
.notif-empty-state {
    text-align: center;
    padding: 40px 20px;
}
.notif-empty-state svg {
    opacity: 0.7;
}

/* ── Notification row unread highlight ── */
.notif-row[data-read="false"] {
    background: #f7f8fc;
}
.notif-row[data-read="false"]:hover {
    background: #eef0f8;
}

/* ── Toast notifications ── */
.frtrack-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.frtrack-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 320px;
    max-width: min(88vw, 380px);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(24px);
    transition: opacity .22s, transform .22s;
    box-shadow: 0 8px 20px rgba(25, 33, 56, .24);
    border: 1px solid rgba(255,255,255,.15);
}
.frtrack-toast-show {
    opacity: 1;
    transform: translateX(0);
}
.frtrack-toast-success { background: #0abb87; }
.frtrack-toast-error { background: #f24d7b; }
.frtrack-toast-warn { background: #ffb822; color: #2b2400; }
.frtrack-toast-info { background: #2786f1; }

.frtrack-toast-icon {
    font-size: 15px;
    margin-top: 1px;
}

.frtrack-toast-message {
    flex: 1;
    line-height: 1.35;
}

.frtrack-toast-close {
    border: none;
    background: transparent;
    color: inherit;
    opacity: .8;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    margin-top: -1px;
}

.frtrack-toast-close:hover {
    opacity: 1;
}

.fr-alert {
    border: none;
    box-shadow: 0 2px 10px rgba(38, 48, 70, .08);
}

.fr-alert-success {
    background: #ebfbf5;
    color: #0d6f53;
}

.fr-alert-error {
    background: #fff1f4;
    color: #a52e53;
}

.fr-alert-warn {
    background: #fff8e7;
    color: #8a6312;
}

.fr-alert-info {
    background: #edf4ff;
    color: #2e63ad;
}

.global-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 1200;
    background: transparent;
    opacity: 0;
    transition: opacity .18s ease;
    pointer-events: none;
}

.global-progress.show {
    opacity: 1;
}

.global-progress-bar {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #5d78ff 0%, #36a2eb 100%);
    transition: width .22s ease;
}

.fr-empty-state {
    padding: 20px 10px;
    text-align: center;
}

.fr-empty-icon {
    font-size: 24px;
    color: #a8b0c9;
    margin-bottom: 6px;
}

.fr-empty-title {
    font-size: 13px;
    font-weight: 600;
    color: #6a728b;
    margin-bottom: 12px;
}

.fr-empty-actions {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.fr-validation-feedback {
    display: block;
}

.sortable-log {
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
}

.sortable-log .log-sort-icon {
    margin-left: 3px;
    font-size: 9px;
    color: #b2b8cc;
    vertical-align: middle;
}

.sortable-log:hover .log-sort-icon,
.sortable-log.is-sorted .log-sort-icon {
    color: #5d79db;
}

.dashboard-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.layout-sync-badge {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid transparent;
}

.layout-sync-badge-sync {
    background: #edf4ff;
    color: #2f6fd1;
    border-color: #cfe0ff;
}

.layout-sync-badge-merge {
    background: #ecfff8;
    color: #0a9b73;
    border-color: #bdeee0;
}

.layout-sync-badge-tab {
    background: #fff7eb;
    color: #b06b1a;
    border-color: #ffe2bf;
}

/* ── Dashboard widgets ── */
.dashboard-widgets-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-rows: minmax(130px, auto);
    gap: 12px;
}

.dashboard-widget-slot {
    min-width: 0;
}

.dashboard-widget-slot.size-half {
    grid-column: span 6;
    grid-row: span 1;
}

.dashboard-widget-slot.size-wide {
    grid-column: span 12;
    grid-row: span 1;
}

.dashboard-widget-slot.size-tall {
    grid-column: span 6;
    grid-row: span 2;
}

@media (max-width: 1200px) {
    .dashboard-widget-slot.size-half,
    .dashboard-widget-slot.size-wide,
    .dashboard-widget-slot.size-tall {
        grid-column: span 12;
        grid-row: span 1;
    }
}

.dashboard-widgets-grid .dashboard-widget-card {
    min-height: 260px;
    transition: transform .24s ease, box-shadow .24s ease, opacity .2s ease;
}

.dashboard-widget-slot.size-tall .dashboard-widget-card {
    min-height: 500px;
}

.dashboard-widget-header {
    padding: 12px 14px;
}

.widget-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dashboard-widget-card {
    cursor: grab;
}

.dashboard-widget-card.widget-dragging {
    opacity: 0.55;
    cursor: grabbing;
}

.widget-drop-target .dashboard-widget-card {
    outline: 2px dashed var(--primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(93,120,255,.14);
}

.widget-ghost-preview {
    pointer-events: none;
    position: fixed;
    z-index: 99999;
    border-radius: 6px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 10px 28px rgba(17, 26, 44, .25);
    border: 1px solid #d7dcef;
    padding: 8px 12px;
    font-size: 12px;
    color: #464457;
}

.widget-animating {
    will-change: transform;
}

.widget-chart-wrap {
    position: relative;
    height: 220px;
}

.widget-donut-wrap {
    height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.widget-kpi {
    padding: 12px;
    border: 1px solid #ebedf2;
    border-radius: 8px;
    background: #f9fafe;
}

.widget-kpi-label {
    color: #74788d;
    font-size: 12px;
    margin-bottom: 4px;
}

.widget-kpi-value {
    color: #2d3349;
    font-size: 18px;
    font-weight: 700;
}

.widget-placeholder {
    border: 1px dashed #d6d9e3;
    background: #fafbff;
    color: #74788d;
    border-radius: 8px;
    padding: 14px;
}

.widget-modal-content .modal-body {
    background: #fbfcff;
}

.widget-catalog-title {
    font-size: 14px;
    font-weight: 600;
    color: #464457;
    margin-bottom: 10px;
}

.widget-catalog-list {
    display: grid;
    gap: 10px;
}

.widget-catalog-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px;
    border: 1px solid #e9ecf4;
    border-radius: 8px;
    background: #fff;
}

.widget-catalog-name {
    font-weight: 600;
    color: #2d3349;
}

.widget-catalog-desc {
    font-size: 12px;
    color: #74788d;
}

/* ── Dashboard customizer extras ── */
.dashboard-customizer-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.dashboard-customizer-layout.dashboard-edit-mode {
    grid-template-columns: minmax(0, 1fr) 320px;
}

@media (max-width: 1200px) {
    .dashboard-customizer-layout.dashboard-edit-mode {
        grid-template-columns: minmax(0, 1fr);
    }
}

.dashboard-customizer-layout .dashboard-widget-catalog-wrap {
    display: none;
}

.dashboard-customizer-layout.dashboard-edit-mode .dashboard-widget-catalog-wrap {
    display: block;
}

.dashboard-widget-catalog-card {
    position: sticky;
    top: 12px;
}

.dashboard-widget-catalog {
    display: grid;
    gap: 8px;
    max-height: 70vh;
    overflow-y: auto;
}

.layout-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #4b5165;
    background: #eef1f8;
    border: 1px solid #dde2ef;
}

.layout-source-badge.layout-source-user {
    background: #e9f6ee;
    color: #1f7a3d;
    border-color: #c5e7d1;
}

.layout-source-badge.layout-source-role {
    background: #fff4e2;
    color: #a06205;
    border-color: #f4dca4;
}

.layout-source-badge.layout-source-builtin {
    background: #eef1f8;
    color: #4b5165;
    border-color: #dde2ef;
}

.dashboard-role-default-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dashboard-role-default-control .form-select-sm {
    width: 130px;
}

.dashboard-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.dashboard-widget-title {
    outline: none;
}

.dashboard-widget-title.widget-title-editing {
    display: inline-block;
    padding: 2px 6px;
    margin-left: -6px;
    border-radius: 4px;
    border: 1px dashed var(--primary, #5d78ff);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(93, 120, 255, .12);
    min-width: 60px;
}

.dashboard-widget-title-badge {
    font-size: 10px;
    color: #a06205;
    background: #fff4e2;
    border: 1px solid #f4dca4;
    border-radius: 999px;
    padding: 1px 6px;
    margin-left: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-grid-edit .dashboard-widget-card {
    border: 1px dashed #c1c8df;
    cursor: grab;
}

.dashboard-grid-edit .dashboard-widget-card.widget-dragging {
    cursor: grabbing;
}

.dashboard-slot-editable .dashboard-widget-card .data-card-header {
    background: linear-gradient(180deg, rgba(93, 120, 255, .06), rgba(93, 120, 255, 0));
}

.dashboard-widget-hidden .dashboard-widget-card {
    opacity: 0.55;
    border-style: dashed;
}

.widget-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #5b6175;
    margin-bottom: 6px;
}

.widget-kpi-sub,
.widget-kpi-delta {
    font-size: 11px;
    color: #74788d;
    margin-top: 2px;
}

.widget-kpi-delta {
    font-weight: 600;
    color: #1f7a3d;
}

#dashboardEditToggle.active {
    background: #1f7a3d;
    border-color: #1f7a3d;
}

/* ── Theme toggle button ── */
.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #74788d;
    padding: 2px 4px;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.theme-toggle-btn:hover {
    color: var(--primary);
    background: rgba(93,120,255,0.08);
}

/* ═══════════════════════════════════════════════════
   DARK THEME
═══════════════════════════════════════════════════ */
[data-theme="dark"] {
    --body-bg: #1a1d2e;
    --top-bar-bg: #212438;
    color-scheme: dark;

    /* Bootstrap 5 CSS variable overrides */
    --bs-body-bg: #1a1d2e;
    --bs-body-color: #c8ccdf;
    --bs-border-color: #2b2f4a;
    --bs-border-color-translucent: rgba(43,47,74,0.7);
    --bs-secondary-color: #8a8fac;
    --bs-secondary-bg: #2a2d45;
    --bs-tertiary-bg: #1e2138;
    --bs-tertiary-color: #7c82a0;
    --bs-emphasis-color: #d4d7ea;
    --bs-heading-color: #d4d7ea;
    --bs-link-color: #7eb0ff;
    --bs-link-hover-color: #aaccff;
    --bs-code-color: #f28ab3;
    --bs-table-bg: transparent;
    --bs-table-striped-bg: #2a2d45;
    --bs-table-hover-bg: #2e3252;
    --bs-table-border-color: #2b2f4a;
    --bs-table-color: #c8ccdf;
    --bs-dropdown-bg: #252840;
    --bs-dropdown-border-color: #2b2f4a;
    --bs-dropdown-link-color: #c8ccdf;
    --bs-dropdown-link-hover-bg: #2e3252;
    --bs-dropdown-divider-bg: #2b2f4a;
    --bs-modal-bg: #252840;
    --bs-modal-border-color: #2b2f4a;
    --bs-modal-header-border-color: #2b2f4a;
    --bs-modal-footer-border-color: #2b2f4a;
    --bs-card-bg: #252840;
    --bs-card-border-color: #2b2f4a;
    --bs-card-cap-bg: #2a2d45;
    --bs-input-bg: #2a2d45;
    --bs-input-border-color: #363b5a;
    --bs-input-color: #d0d3e6;
    --bs-input-placeholder-color: #4e5370;
    --bs-input-focus-border-color: #5d78ff;
    --bs-nav-tabs-border-color: #2b2f4a;
    --bs-nav-tabs-link-active-bg: transparent;
    --bs-nav-tabs-link-active-color: #5d78ff;
    --bs-nav-tabs-link-active-border-color: #2b2f4a #2b2f4a transparent;
    --bs-pagination-bg: #252840;
    --bs-pagination-border-color: #2b2f4a;
    --bs-pagination-color: #5d78ff;
    --bs-pagination-hover-bg: #2e3252;
    --bs-pagination-hover-border-color: #2b2f4a;
    --bs-pagination-disabled-bg: #1e2138;
    --bs-pagination-disabled-border-color: #2b2f4a;
    --bs-list-group-bg: #252840;
    --bs-list-group-border-color: #2b2f4a;
    --bs-list-group-color: #c8ccdf;
    --bs-list-group-hover-bg: #2e3252;
    --bs-form-check-bg: #2a2d45;
    --bs-popover-bg: #252840;
    --bs-popover-border-color: #2b2f4a;
    --bs-tooltip-bg: #363b5a;
    --bs-tooltip-color: #fff;
    --bs-badge-color: #fff;
    --bs-progress-bg: #363b5a;
    --bs-alert-bg: transparent;
}

/* ── Body ── */
[data-theme="dark"] body {
    background: var(--body-bg);
    color: #c8ccdf;
}

/* ── Top bar ── */
[data-theme="dark"] .top-bar {
    background: var(--top-bar-bg);
    border-bottom-color: #2b2f4a;
}
[data-theme="dark"] .top-bar .page-title { color: #d4d7ea; }
[data-theme="dark"] .top-bar-right .timezone { color: #7c82a0; }
[data-theme="dark"] .top-bar-right .user-name { color: #c0c4d8; }
[data-theme="dark"] .theme-toggle-btn { color: #7c82a0; }
[data-theme="dark"] .theme-toggle-btn:hover { color: #c0c4d8; background: rgba(255,255,255,0.06); }

/* ── Data cards ── */
[data-theme="dark"] .data-card {
    background: #252840;
    box-shadow: 0 0 13px 0 rgba(0,0,0,0.25);
}
[data-theme="dark"] .data-card-header {
    border-bottom-color: #2b2f4a;
}
[data-theme="dark"] .data-card-header h3 { color: #c8ccdf; }

/* ── Table containers (legacy) ── */
[data-theme="dark"] .table-container {
    background: #252840;
    box-shadow: 0 0 13px 0 rgba(0,0,0,0.25);
}
[data-theme="dark"] .table-header {
    border-bottom-color: #2b2f4a;
}
[data-theme="dark"] .table-header h6 { color: #c8ccdf; }

/* ── Tables ── */
[data-theme="dark"] .table { color: #c8ccdf; }
[data-theme="dark"] .table th {
    background: #2a2d45;
    color: #8a8fac;
    border-bottom-color: #2b2f4a;
}
[data-theme="dark"] .table td {
    border-bottom-color: #2b2f4a;
    color: #c8ccdf;
}
[data-theme="dark"] .table tbody tr:hover { background: #2e3252; }

[data-theme="dark"] .table tbody tr.failed-lead,
[data-theme="dark"] .table tbody tr.failed-lead > td,
[data-theme="dark"] .table tbody tr.failed-lead > th {
    background-color: #3a1828 !important;
    --bs-table-bg: #3a1828;
    --bs-table-accent-bg: #3a1828;
    box-shadow: none !important;
}
[data-theme="dark"] .table tbody tr.failed-lead:hover,
[data-theme="dark"] .table tbody tr.failed-lead:hover > td,
[data-theme="dark"] .table tbody tr.failed-lead:hover > th {
    background-color: #4a2035 !important;
    --bs-table-bg: #4a2035;
    --bs-table-accent-bg: #4a2035;
    box-shadow: none !important;
}
[data-theme="dark"] .table tbody tr.ftd-lead,
[data-theme="dark"] .table tbody tr.ftd-lead > td,
[data-theme="dark"] .table tbody tr.ftd-lead > th {
    background-color: #1a3a20 !important;
    --bs-table-bg: #1a3a20;
    --bs-table-accent-bg: #1a3a20;
    box-shadow: none !important;
}
[data-theme="dark"] .table tbody tr.ftd-lead:hover,
[data-theme="dark"] .table tbody tr.ftd-lead:hover > td,
[data-theme="dark"] .table tbody tr.ftd-lead:hover > th {
    background-color: #244a30 !important;
    --bs-table-bg: #244a30;
    --bs-table-accent-bg: #244a30;
    box-shadow: none !important;
}

/* ── Details table ── */
[data-theme="dark"] #detailsTable td {
    color: #c8ccdf;
    border-bottom-color: #2b2f4a;
}
[data-theme="dark"] #detailsTable tbody tr:hover { background-color: #2e3252 !important; }
[data-theme="dark"] #detailsTable tbody tr.failed-lead,
[data-theme="dark"] #detailsTable tbody tr.failed-lead > td {
    background-color: #3a1828 !important;
    --bs-table-bg: #3a1828;
    --bs-table-accent-bg: #3a1828;
    box-shadow: none !important;
}
[data-theme="dark"] #detailsTable tbody tr.failed-lead:hover,
[data-theme="dark"] #detailsTable tbody tr.failed-lead:hover > td {
    background-color: #4a2035 !important;
    --bs-table-bg: #4a2035;
    --bs-table-accent-bg: #4a2035;
    box-shadow: none !important;
}
[data-theme="dark"] #detailsTable tbody tr.ftd-lead,
[data-theme="dark"] #detailsTable tbody tr.ftd-lead > td {
    background-color: #1a3a20 !important;
    --bs-table-bg: #1a3a20;
    --bs-table-accent-bg: #1a3a20;
    box-shadow: none !important;
}
[data-theme="dark"] #detailsTable tbody tr.ftd-lead:hover,
[data-theme="dark"] #detailsTable tbody tr.ftd-lead:hover > td {
    background-color: #244a30 !important;
    --bs-table-bg: #244a30;
    --bs-table-accent-bg: #244a30;
    box-shadow: none !important;
}

/* ── Leads grid extras ── */
[data-theme="dark"] .leads-grid .ip-geo-badge { background: #2e3252; }
[data-theme="dark"] .lead-split-badge { background: #2e3252; color: #9fa8da; }
[data-theme="dark"] .lead-split-child td:first-child { box-shadow: inset 3px 0 0 #9fa8da; }

/* ── Expandable rows ── */
[data-theme="dark"] .expandable-row:hover { background: #2e3252 !important; }
[data-theme="dark"] .child-row { background: #1e2138; }
[data-theme="dark"] .child-row td { color: #8a8fac; border-bottom-color: #2b2f4a; }

/* ── Forms ── */
[data-theme="dark"] .form-container {
    background: #252840;
    box-shadow: 0 0 13px 0 rgba(0,0,0,0.25);
}
[data-theme="dark"] .form-label { color: #8a8fac; }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #2a2d45;
    border-color: #363b5a;
    color: #d0d3e6;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #2a2d45;
    border-color: var(--primary);
    color: #d0d3e6;
    box-shadow: 0 0 0 0.15rem rgba(93,120,255,0.25);
}
[data-theme="dark"] .form-control::placeholder { color: #4e5370; }
[data-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238a8fac' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}
[data-theme="dark"] .form-check-input {
    background-color: #2a2d45;
    border-color: #363b5a;
}
[data-theme="dark"] .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}
[data-theme="dark"] .form-check-label { color: #c8ccdf; }
[data-theme="dark"] .form-text { color: #7c82a0; }

/* ── Input group ── */
[data-theme="dark"] .input-group-text {
    background: #2a2d45;
    border-color: #363b5a;
    color: #8a8fac;
}

/* ── Filter panel ── */
[data-theme="dark"] .filter-panel {
    background: #252840;
    border-right-color: #2b2f4a;
}
[data-theme="dark"] .filter-panel h6 { color: #8a8fac; }
[data-theme="dark"] .filter-panel .form-label { color: #8a8fac; }
[data-theme="dark"] .filter-panel .form-control-sm,
[data-theme="dark"] .filter-panel .form-select-sm {
    background-color: #2a2d45;
    border-color: #363b5a;
    color: #d0d3e6;
}
[data-theme="dark"] .filter-panel .exclude-label { color: #7c82a0; }

/* ── Dropdowns ── */
[data-theme="dark"] .dropdown-menu {
    background: #252840;
    border-color: #2b2f4a;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
[data-theme="dark"] .dropdown-item { color: #c8ccdf; }
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background: #2e3252;
    color: #fff;
}
[data-theme="dark"] .dropdown-item.text-danger { color: #f06292 !important; }
[data-theme="dark"] .dropdown-item.text-danger:hover { color: #f06292 !important; background: #3a1828; }
[data-theme="dark"] .dropdown-divider { border-color: #2b2f4a; }

/* ── Nav tabs ── */
[data-theme="dark"] .nav-tabs {
    border-bottom-color: #2b2f4a;
}
[data-theme="dark"] .nav-tabs .nav-link { color: #8a8fac; }
[data-theme="dark"] .nav-tabs .nav-link.active {
    color: var(--primary);
    background: none;
    border-bottom-color: var(--primary);
}
[data-theme="dark"] .nav-tabs .nav-link:hover {
    color: var(--primary);
    border-color: transparent;
}

/* ── Icon tabs ── */
[data-theme="dark"] .icon-tabs { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .icon-tabs .icon-tab { color: #8a8fac; }
[data-theme="dark"] .icon-tabs .icon-tab:hover { color: var(--primary); }
[data-theme="dark"] .icon-tabs .icon-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ── Pagination ── */
[data-theme="dark"] .page-link {
    background-color: #252840;
    border-color: #2b2f4a;
    color: var(--primary);
}
[data-theme="dark"] .page-link:hover {
    background-color: #2e3252;
    border-color: #2b2f4a;
    color: var(--primary);
}
[data-theme="dark"] .page-item.disabled .page-link {
    background-color: #1e2138;
    border-color: #2b2f4a;
    color: #4e5370;
}
[data-theme="dark"] .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ── Page header ── */
[data-theme="dark"] .page-header h1 { color: #d4d7ea; }
[data-theme="dark"] .page-breadcrumb span { color: #7c82a0; }

/* ── Group-by bar ── */
[data-theme="dark"] .group-by-bar .btn-group .btn:not(.active) {
    background: #252840;
    border-color: #363b5a;
    color: #c8ccdf;
}
[data-theme="dark"] .group-by-bar .btn-group .btn:not(.active):hover {
    background: #2e3252;
    color: #fff;
}

/* ── Bootstrap cards ── */
[data-theme="dark"] .card {
    background: #252840;
    border-color: #2b2f4a;
}
[data-theme="dark"] .card-header {
    background: #2a2d45;
    border-bottom-color: #2b2f4a;
    color: #c8ccdf;
}
[data-theme="dark"] .card-body { color: #c8ccdf; }
[data-theme="dark"] .card-footer {
    background: #2a2d45;
    border-top-color: #2b2f4a;
}

/* ── Modals ── */
[data-theme="dark"] .modal-content {
    background: #252840;
    border-color: #2b2f4a;
}
[data-theme="dark"] .modal-header {
    border-bottom-color: #2b2f4a;
}
[data-theme="dark"] .modal-footer {
    border-top-color: #2b2f4a;
}
[data-theme="dark"] .modal-title { color: #d4d7ea; }
[data-theme="dark"] .modal-body { color: #c8ccdf; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(1.5); }

/* ── Broker history modal ── */
[data-theme="dark"] #brokerHistoryModal .modal-content { border-color: #2b2f4a; }
[data-theme="dark"] #brokerHistoryModal .modal-header { border-bottom-color: #2b2f4a; }
[data-theme="dark"] #brokerHistoryModal .modal-title { color: #c8ccdf; }
[data-theme="dark"] #brokerHistoryModal .modal-footer { border-top-color: #2b2f4a; }
[data-theme="dark"] #brokerHistoryTable th {
    background: #2a2d45;
    color: #8a8fac;
}
[data-theme="dark"] #brokerHistoryTable td { color: #c8ccdf; }
[data-theme="dark"] .broker-request-code {
    background: #1e2138;
    border-color: #2b2f4a;
    color: #c8ccdf;
}

/* ── Alerts (flash) ── */
[data-theme="dark"] .fr-alert-success { background: #0d3d2e; color: #5dd9b0; }
[data-theme="dark"] .fr-alert-error   { background: #3a1020; color: #f28ab3; }
[data-theme="dark"] .fr-alert-warn    { background: #372d00; color: #ffd060; }
[data-theme="dark"] .fr-alert-info    { background: #0d2646; color: #6eb8ff; }

/* ── Bar chart section ── */
[data-theme="dark"] .bar-chart-section {
    background: #252840;
    box-shadow: 0 0 13px 0 rgba(0,0,0,0.25);
}
[data-theme="dark"] .bar-chart-title { color: #c8ccdf; }
[data-theme="dark"] .bar-chart-label { color: #8a8fac; }
[data-theme="dark"] .bar-chart-track { background: #2b2f4a; }

/* ── Offers chart ── */
[data-theme="dark"] .offers-chart { background: #252840; border-color: #2b2f4a; }
[data-theme="dark"] .offers-chart-bar-wrap {
    background: linear-gradient(to top, #1e2138, #252840);
    border-color: #2b2f4a;
}
[data-theme="dark"] .offers-chart-value { color: #8a8fac; }
[data-theme="dark"] .offers-chart-label { color: #7c82a0; }

/* ── Stats subtabs ── */
[data-theme="dark"] .stats-subtabs-wrap .stats-subtabs .btn-outline-secondary {
    color: #8a8fac;
    border-color: #363b5a;
}
[data-theme="dark"] .stats-subtabs-wrap .stats-subtabs .btn-outline-secondary:hover {
    background: #2e3252;
    color: #c8ccdf;
}

/* ── Drilldown popup ── */
[data-theme="dark"] .drilldown-popup {
    background: #252840;
    border-color: #2b2f4a;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
[data-theme="dark"] .drilldown-popup .dd-link { color: #c8ccdf; }
[data-theme="dark"] .drilldown-popup .dd-link:hover { background: #2e3252; color: var(--primary); }
[data-theme="dark"] .drilldown-popup .dd-link.dd-disabled,
[data-theme="dark"] .drilldown-popup .dd-link.dd-disabled:hover {
    color: #5c617a;
    background: transparent;
}
[data-theme="dark"] .drilldown-popup .dd-link.dd-disabled i,
[data-theme="dark"] .drilldown-popup .dd-link.dd-disabled:hover i { color: #5c617a; }
[data-theme="dark"] .drilldown-popup .dd-link i { color: #7c82a0; }
[data-theme="dark"] .drilldown-popup .dd-divider { background: #2b2f4a; }

/* ── Drilldown sub-table ── */
[data-theme="dark"] .drilldown-content .table th { background: #2a2d45; }
[data-theme="dark"] .drilldown-content .table td { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .drilldown-content .table tfoot td { background: #2b2f4a; }

/* ── Color legend popup ── */
[data-theme="dark"] .color-legend-popup {
    background: #252840;
    color: #c8ccdf;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
[data-theme="dark"] .color-legend-item .color-block { border-color: #2b2f4a; }

/* ── Notifications dropdown ── */
[data-theme="dark"] .notif-dropdown {
    background: #252840;
    border-color: #2b2f4a;
}
[data-theme="dark"] .notif-dropdown strong { color: #c8ccdf !important; }
[data-theme="dark"] .notif-dropdown .d-flex.align-items-center.justify-content-between.px-3 {
    border-bottom-color: #2b2f4a !important;
}
[data-theme="dark"] .notif-dropdown .text-center.py-2 {
    border-top-color: #2b2f4a !important;
}
[data-theme="dark"] #notifDropdownList > div {
    background: #252840 !important;
    border-bottom-color: #2b2f4a !important;
    color: #c8ccdf !important;
}
[data-theme="dark"] #notifDropdownList > div span { color: #c8ccdf !important; }
[data-theme="dark"] #notifDropdownEmpty p { color: #8a8fac !important; }
[data-theme="dark"] .notif-dropdown .d-flex.align-items-center.gap-2 a { color: #7c82a0 !important; }
[data-theme="dark"] .notif-dropdown .d-flex.align-items-center.gap-2 a:hover { color: #c8ccdf !important; }

/* ── Notification rows (page) ── */
[data-theme="dark"] .notif-row[data-read="false"] { background: #2a2d45; }
[data-theme="dark"] .notif-row[data-read="false"]:hover { background: #2e3252; }

/* ── Widget KPI ── */
[data-theme="dark"] .widget-kpi {
    background: #2a2d45;
    border-color: #2b2f4a;
}
[data-theme="dark"] .widget-kpi-label { color: #8a8fac; }
[data-theme="dark"] .widget-kpi-value { color: #d4d7ea; }
[data-theme="dark"] .widget-kpi-sub { color: #7c82a0; }
[data-theme="dark"] .widget-kpi-delta { color: #5dd9b0; }

/* ── Widget placeholders & catalog ── */
[data-theme="dark"] .widget-placeholder {
    border-color: #363b5a;
    background: #1e2138;
    color: #8a8fac;
}
[data-theme="dark"] .widget-catalog-item {
    background: #2a2d45;
    border-color: #2b2f4a;
}
[data-theme="dark"] .widget-catalog-name { color: #c8ccdf; }
[data-theme="dark"] .widget-catalog-desc { color: #8a8fac; }
[data-theme="dark"] .widget-modal-content .modal-body { background: #1e2138; }
[data-theme="dark"] .widget-catalog-title { color: #c8ccdf; }
[data-theme="dark"] .widget-section-title { color: #8a8fac; }
[data-theme="dark"] .widget-ghost-preview {
    background: rgba(37, 40, 64, 0.97);
    border-color: #2b2f4a;
    color: #c8ccdf;
}
[data-theme="dark"] .dashboard-widget-title.widget-title-editing {
    background: #2a2d45;
    border-color: var(--primary);
}
[data-theme="dark"] .dashboard-grid-edit .dashboard-widget-card { border-color: #363b5a; }

/* ── Dashboard badges ── */
[data-theme="dark"] .layout-sync-badge         { background: #2a2d45; color: #8a8fac; border-color: #363b5a; }
[data-theme="dark"] .layout-sync-badge-sync    { background: #0d2546; color: #6eb8ff; border-color: #1a4070; }
[data-theme="dark"] .layout-sync-badge-merge   { background: #0d2d20; color: #5dd9b0; border-color: #1a5040; }
[data-theme="dark"] .layout-sync-badge-tab     { background: #2d1d05; color: #ffd060; border-color: #5a3a10; }
[data-theme="dark"] .layout-source-badge            { background: #2a2d45; color: #8a8fac; border-color: #363b5a; }
[data-theme="dark"] .layout-source-badge.layout-source-user    { background: #0d2d20; color: #5dd9b0; border-color: #1a5040; }
[data-theme="dark"] .layout-source-badge.layout-source-role    { background: #2d1d05; color: #ffd060; border-color: #5a3a10; }
[data-theme="dark"] .layout-source-badge.layout-source-builtin { background: #2a2d45; color: #8a8fac; border-color: #363b5a; }
[data-theme="dark"] .dashboard-widget-title-badge { background: #2d1d05; color: #ffd060; border-color: #5a3a10; }

/* ── Grouping dropdown ── */
[data-theme="dark"] .grouping-dropdown {
    color: #c8ccdf;
    border-color: #363b5a;
    background-color: #2a2d45;
}

/* ── Column visibility ── */
[data-theme="dark"] .col-vis-item:hover { background: #2e3252; }

/* ── Records selector ── */
[data-theme="dark"] .records-selector { color: #8a8fac; }
[data-theme="dark"] .records-selector select {
    background-color: #2a2d45;
    border-color: #363b5a;
    color: #d0d3e6;
}

/* ── Search bar ── */
[data-theme="dark"] .search-bar i { color: #4e5370; }

/* ── Empty state ── */
[data-theme="dark"] .fr-empty-icon { color: #4e5370; }
[data-theme="dark"] .fr-empty-title { color: #7c82a0; }

/* ── Bootstrap utility overrides ── */
[data-theme="dark"] .text-muted    { color: #8a8fac !important; }
[data-theme="dark"] .text-secondary { color: #8a8fac !important; }
[data-theme="dark"] .bg-white      { background: #252840 !important; }
[data-theme="dark"] .bg-light      { background: #2a2d45 !important; }
[data-theme="dark"] hr             { border-color: #2b2f4a; opacity: 1; }
[data-theme="dark"] .border        { border-color: #2b2f4a !important; }
[data-theme="dark"] .border-bottom { border-bottom-color: #2b2f4a !important; }
[data-theme="dark"] .border-top    { border-top-color: #2b2f4a !important; }
[data-theme="dark"] small, [data-theme="dark"] .small { color: #8a8fac; }

/* ── Bootstrap btn overrides ── */
[data-theme="dark"] .btn-outline-secondary {
    color: #8a8fac;
    border-color: #363b5a;
}
[data-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] .btn-outline-secondary:focus {
    background: #2e3252;
    color: #c8ccdf;
    border-color: #363b5a;
}
[data-theme="dark"] .btn-light {
    background: #2e3252;
    border-color: #363b5a;
    color: #c8ccdf;
}
[data-theme="dark"] .btn-light:hover {
    background: #363c60;
    color: #fff;
    border-color: #363b5a;
}
[data-theme="dark"] .btn-outline-light {
    color: #c8ccdf;
    border-color: #363b5a;
}
[data-theme="dark"] .btn-outline-light:hover {
    background: #2e3252;
    color: #fff;
}
[data-theme="dark"] .btn-secondary {
    background: #363b5a;
    border-color: #3f4468;
    color: #c8ccdf;
}
[data-theme="dark"] .btn-secondary:hover {
    background: #3f4468;
    border-color: #3f4468;
}

/* ── Badges (Bootstrap) ── */
[data-theme="dark"] .badge.bg-secondary { background: #363b5a !important; color: #c8ccdf; }
[data-theme="dark"] .badge.bg-light     { background: #2a2d45 !important; color: #c8ccdf; }

/* ── Code / pre ── */
[data-theme="dark"] code { background: #2a2d45; color: #f28ab3; }
[data-theme="dark"] pre  { background: #1e2138; color: #c8ccdf; border-color: #2b2f4a; }

/* ── Flatpickr (date picker) dark overrides ── */
[data-theme="dark"] .flatpickr-calendar {
    background: #252840 !important;
    border-color: #2b2f4a !important;
    box-shadow: 0 6px 24px rgba(0,0,0,0.4) !important;
    color: #c8ccdf !important;
}
[data-theme="dark"] .flatpickr-months { background: #252840 !important; }
[data-theme="dark"] .flatpickr-month { background: #252840 !important; fill: #c8ccdf; color: #c8ccdf; }
[data-theme="dark"] .flatpickr-current-month { color: #c8ccdf !important; }
[data-theme="dark"] .flatpickr-current-month input.cur-year { color: #c8ccdf !important; }
[data-theme="dark"] .flatpickr-weekday { background: #252840 !important; color: #7c82a0 !important; fill: #7c82a0; }
[data-theme="dark"] .flatpickr-weekdays { background: #252840 !important; }
[data-theme="dark"] .flatpickr-day {
    color: #c8ccdf !important;
}
[data-theme="dark"] .flatpickr-day:hover,
[data-theme="dark"] .flatpickr-day:focus {
    background: #2e3252 !important;
    border-color: #2e3252 !important;
}
[data-theme="dark"] .flatpickr-day.flatpickr-disabled,
[data-theme="dark"] .flatpickr-day.prevMonthDay,
[data-theme="dark"] .flatpickr-day.nextMonthDay {
    color: #4e5370 !important;
}
[data-theme="dark"] .flatpickr-innerContainer { background: #252840 !important; }
[data-theme="dark"] .flatpickr-rContainer { background: #252840 !important; }
[data-theme="dark"] span.flatpickr-day.today:not(.selected):not(.startRange):not(.endRange) {
    border-color: var(--primary) !important;
}

/* ── Date range picker (drp) dark overrides ── */
[data-theme="dark"] .drp-trigger {
    background: #2a2d45;
    border-color: #363b5a;
    color: #c8ccdf;
}
[data-theme="dark"] .drp-trigger:hover  { border-color: #7c82a0; }
[data-theme="dark"] .drp-open .drp-trigger { border-color: var(--primary); }
[data-theme="dark"] .drp-icon { color: #7c82a0; }
[data-theme="dark"] .drp-popup {
    background: #252840;
    border-color: #2b2f4a;
    box-shadow: 0 6px 24px rgba(0,0,0,0.45);
}
[data-theme="dark"] .drp-sidebar { border-right-color: #2b2f4a; }
[data-theme="dark"] .drp-preset { color: #c8ccdf; }
[data-theme="dark"] .drp-preset:hover { background: #2e3252; }
[data-theme="dark"] .drp-footer {
    background: #1e2138;
    border-top-color: #2b2f4a;
}
[data-theme="dark"] .drp-time-group span { color: #7c82a0; }
[data-theme="dark"] .drp-time-sel {
    background: #2a2d45;
    border-color: #363b5a;
    color: #c8ccdf;
}
[data-theme="dark"] .drp-footer-preview { color: #8a8fac; }

/* ── Searchable select (ss) dark overrides ── */
[data-theme="dark"] .ss-trigger {
    background: #2a2d45;
    border-color: #363b5a;
}
[data-theme="dark"] .ss-trigger:hover  { border-color: #7c82a0; }
[data-theme="dark"] .ss-open .ss-trigger { border-color: var(--primary); }
[data-theme="dark"] .ss-trigger-text { color: #4e5370; }
[data-theme="dark"] .ss-trigger-text.ss-has-value { color: #c8ccdf; }
[data-theme="dark"] .ss-chevron { color: #7c82a0; }
[data-theme="dark"] .ss-dropdown {
    background: #252840;
    border-color: #2b2f4a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
[data-theme="dark"] .ss-search-wrap { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .ss-search-input {
    background: #2a2d45;
    border-color: #363b5a;
    color: #c8ccdf;
}
[data-theme="dark"] .ss-search-input:focus { border-color: var(--primary); }
[data-theme="dark"] .ss-search-icon { color: #4e5370; }
[data-theme="dark"] .ss-select-all {
    border-bottom-color: #2b2f4a;
    color: #c8ccdf;
}
[data-theme="dark"] .ss-option { color: #c8ccdf; }
[data-theme="dark"] .ss-option:hover { background: #2e3252; }
[data-theme="dark"] .ss-remote-footer { border-top-color: #2b2f4a; }

/* ── Page-specific dark overrides (distributions, caps, forms, logs, etc.) ── */

/* === distributions.html === */
[data-theme="dark"] .sc { background: #252840; border-color: #2b2f4a; }
[data-theme="dark"] .sc-h { color: #8a8fac; border-bottom-color: #2b2f4a; }
[data-theme="dark"] .sc-b { border-top-color: #2b2f4a; }
[data-theme="dark"] .sc-b .fl { color: #7c82a0; }
[data-theme="dark"] .sc-b select,
[data-theme="dark"] .sc-b input { background: #2a2d45; border-color: #363b5a; color: #c8ccdf; }
[data-theme="dark"] .dp-hdr h2 { color: #d4d7ea; }
[data-theme="dark"] .dp-card { background: #252840; border-color: #2b2f4a; box-shadow: 0 0 13px 0 rgba(0,0,0,0.25); }
[data-theme="dark"] .dp-gb span { color: #7c82a0; }
[data-theme="dark"] .dp-gb .btn-group .btn:not(.active) { background: #252840; border-color: #363b5a; color: #c8ccdf; }
[data-theme="dark"] .dp-sz { color: #7c82a0; }
[data-theme="dark"] .dp-sz select { background: #2a2d45; border-color: #363b5a; color: #c8ccdf; }
[data-theme="dark"] .dt thead th { background: #2a2d45; color: #7c82a0; border-bottom-color: #363b5a; }
[data-theme="dark"] .dt .cr:hover { background: #2e3252; }
[data-theme="dark"] .dt .cr td { border-bottom-color: #2b2f4a; color: #c8ccdf; }
[data-theme="dark"] .dt .dr > td { background: #1e2138; border-bottom-color: #2b2f4a; }
[data-theme="dark"] .dl { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .dl .nm { color: #c8ccdf; }
[data-theme="dark"] .dl .did { color: #5a607e; }
[data-theme="dark"] .dl .dt-date { color: #5a607e; }
[data-theme="dark"] .dp-empty p { color: #5a607e; }
[data-theme="dark"] .acts .ab { background: #2a2d45; border-color: #363b5a; color: #7c82a0; }
[data-theme="dark"] .acts .ab:hover { border-color: var(--primary); color: var(--primary); }

/* Shares overlay */
[data-theme="dark"] .sh-box { background: #252840; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
[data-theme="dark"] .sh-head { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .sh-head h4 { color: #d4d7ea; }
[data-theme="dark"] .sh-head .lu { color: #7c82a0; }
[data-theme="dark"] .sh-head .bx { color: #7c82a0; }
[data-theme="dark"] .sh-left { background: #1e2138; border-right-color: #2b2f4a; }
[data-theme="dark"] .sh-left .sl-search { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .sh-left .sl-search input { background: #2a2d45; border-color: #363b5a; color: #c8ccdf; }
[data-theme="dark"] .sh-left .sl-toggle { color: #7c82a0; border-bottom-color: #2b2f4a; }
[data-theme="dark"] .sh-left .sl-item { border-bottom-color: #2b2f4a; color: #c8ccdf; }
[data-theme="dark"] .sh-left .sl-item:hover { background: #2e3252; }
[data-theme="dark"] .sh-left .sl-item .bid { color: #5a607e; }
[data-theme="dark"] .sh-tabs { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .sh-tabs .tab { background: #2a2d45; border-color: #363b5a; color: #c8ccdf; }
[data-theme="dark"] .sh-tabs .tab.act { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .sh-bar { background: #1e5fa8; }
[data-theme="dark"] .sh-grp { background: #252840; border-color: #2b2f4a; }
[data-theme="dark"] .sh-grp-hdr { background: #2a2d45; border-bottom-color: #2b2f4a; color: #c8ccdf; }
[data-theme="dark"] .sh-grp-hdr .gb { background: #2a2d45; border-color: #363b5a; color: #7c82a0; }
[data-theme="dark"] .sh-grp-hdr .gb:hover { border-color: var(--primary); color: var(--primary); }
[data-theme="dark"] .sh-grp-hdr .gb-lbl { background: #2a2d45; border-color: #363b5a; color: #c8ccdf; }
[data-theme="dark"] .sh-grp-hdr .gb-lbl:hover { border-color: var(--primary); color: var(--primary); }
[data-theme="dark"] .sh-grp-body.drag-over { background: #1a3050; }
[data-theme="dark"] .sh-empty { color: #7c82a0; }
[data-theme="dark"] .sh-empty b { color: #c8ccdf; }
[data-theme="dark"] .sh-broker { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .sh-broker .drag { color: #3a3f62; }
[data-theme="dark"] .sh-broker .pct-input { background: #2a2d45; border-color: #363b5a; color: #c8ccdf; }
[data-theme="dark"] .sh-broker .pct-sign { color: #5a607e; }
[data-theme="dark"] .sh-broker .slider { background: #363b5a; }
[data-theme="dark"] .sh-foot { border-top-color: #2b2f4a; }
[data-theme="dark"] .sh-foot .btn-sched { background: #2a2d45; color: #7c82a0; border-color: #363b5a; }
[data-theme="dark"] .sh-foot .btn-sched:hover { background: #2e3252; color: #c8ccdf; }
[data-theme="dark"] .abm-help { color: #7c82a0; }

/* === distribution_form.html === */
[data-theme="dark"] .dist-section h6 { color: #c8ccdf; }
[data-theme="dark"] .dist-section h6 i { color: #7c82a0; }
[data-theme="dark"] .field-row label { color: #7c82a0; }
[data-theme="dark"] .param-item { background: #2a2d45; }
[data-theme="dark"] .configs-card { background: #252840; border-color: #2b2f4a; }
[data-theme="dark"] .configs-card .card-header { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .configs-card .card-header h6 { color: #c8ccdf; }
[data-theme="dark"] .config-table th { color: #7c82a0; border-bottom-color: #363b5a; }
[data-theme="dark"] .config-table td { border-bottom-color: #2b2f4a; color: #c8ccdf; }

/* === caps.html === */
[data-theme="dark"] .cap-view-btn:not(.active) { background: #252840; color: #5d9bff; border-color: #5d9bff; }
[data-theme="dark"] .cap-view-btn:not(.active):hover { background: #1a2d4a; }
[data-theme="dark"] .filter-tab { background: #252840; color: #5d9bff; border-color: #5d9bff; }
[data-theme="dark"] .filter-tab:hover:not(.active) { background: #1a2d4a; }
[data-theme="dark"] .ba-panel { background: #252840; border-color: #2b2f4a; }
[data-theme="dark"] .ba-panel-header { border-bottom-color: #2b2f4a; color: #c8ccdf; }
[data-theme="dark"] .ba-row { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .ba-row:hover { background: #2e3252; }
[data-theme="dark"] .ba-row .ba-id { color: #7c82a0; }
[data-theme="dark"] .ba-row .ba-name { color: #c8ccdf; }
[data-theme="dark"] .ba-row .ba-chevron { color: #4e5370; }
[data-theme="dark"] .country-badge { background: #2a2d45; color: #c8ccdf; }
[data-theme="dark"] .broker-badge { background: #0d2546; color: #6eb8ff; }
[data-theme="dark"] .affiliate-badge { background: #2d1d05; color: #ffd060; }
[data-theme="dark"] .progress-cap .progress { background: #363b5a; }
[data-theme="dark"] .progress-cap .cnt { color: #7c82a0; }
[data-theme="dark"] .progress-cap .pct { color: #c8ccdf; }

/* === user_form.html === */
[data-theme="dark"] .user-editor-section { background: #252840; border-color: #2b2f4a; }
[data-theme="dark"] .user-editor-section-title { color: #c8ccdf; }
[data-theme="dark"] .permissions-advanced { background: #1e2138; border-color: #363b5a; }
[data-theme="dark"] .permissions-advanced > summary { color: #8a9adf; }
[data-theme="dark"] .permissions-advanced-body { color: #c8ccdf; }
[data-theme="dark"] .module-advanced-box { background: #1e2138; border-color: #363b5a; }

/* === logs_audits.html === */
[data-theme="dark"] .audit-badge-action  { background: #0d1f4a; color: #7eb0ff; }
[data-theme="dark"] .audit-badge-entity  { background: #0d2820; color: #5dd9b0; }
[data-theme="dark"] .audit-badge-status-ok    { background: #0d2818; color: #5dd9b0; }
[data-theme="dark"] .audit-badge-status-error { background: #3a1020; color: #f28ab3; }
[data-theme="dark"] .audit-badge-status-warn  { background: #2d1d05; color: #ffd060; }
[data-theme="dark"] .audit-meta-muted  { color: #7c82a0; }
[data-theme="dark"] .audit-details summary { color: #7eb0ff; }
[data-theme="dark"] .audit-details-preview { color: #8a8fac; }
[data-theme="dark"] .audit-details pre { background: #1e2138; border-color: #2b2f4a; color: #c8ccdf; }

/* === source_form.html — inline style override === */
[data-theme="dark"] .tab-content-area { background: #252840 !important; border-color: #2b2f4a !important; }

/* === client_form.html — tab panels + info boxes === */
[data-theme="dark"] .tab-panel { background: #252840 !important; border-color: #2b2f4a !important; }

/* Light info boxes with inline backgrounds */
[data-theme="dark"] [style*="background:#f8f9fd"],
[data-theme="dark"] [style*="background:#f5f3ff"],
[data-theme="dark"] [style*="background:#fff8f1"],
[data-theme="dark"] [style*="background:#e8f4fd"],
[data-theme="dark"] [style*="background:#f8f9fa"],
[data-theme="dark"] [style*="background:#f3f4f6"],
[data-theme="dark"] [style*="background:#fafbfc"],
[data-theme="dark"] [style*="background:#f9fafb"] { background: #2a2d45 !important; border-color: #2b2f4a !important; }

[data-theme="dark"] [style*="background:#fff;"],
[data-theme="dark"] [style*="background:#fff\""],
[data-theme="dark"] [style*="background: #fff"] { background: #252840 !important; border-color: #2b2f4a !important; }

/* stats.html — inline table row/cell backgrounds */
[data-theme="dark"] tr[style*="background:#f7f8fc"],
[data-theme="dark"] tr[style*="background:#f0f1f5"] { background: #2a2d45 !important; }
[data-theme="dark"] td[style*="background:#fafbff"],
[data-theme="dark"] td[style*="background:#f4f5fa"] { background: #1e2138 !important; }
[data-theme="dark"] span[style*="background:#f8f9fa"] { background: #2a2d45 !important; border-color: #363b5a !important; color: #c8ccdf !important; }
[data-theme="dark"] span[style*="background:#eef0f8"] { background: #2a2d45 !important; }

/* notifications.html & general header bars with inline border */
[data-theme="dark"] [style*="background:#fafbfc"] { background: #1e2138 !important; border-color: #2b2f4a !important; }
[data-theme="dark"] .input-group-text.bg-white,
[data-theme="dark"] .input-group-text { background: #2a2d45; border-color: #363b5a; color: #8a8fac; }

/* settings/user_settings info boxes */
[data-theme="dark"] [style*="background:#f8f9fc"] { background: #2a2d45 !important; border-color: #2b2f4a !important; }

/* ── Bootstrap alerts (non-fr-alert ones) ── */
[data-theme="dark"] .alert-info     { background-color: #0d2646 !important; border-color: #1a4070 !important; color: #6eb8ff !important; }
[data-theme="dark"] .alert-success  { background-color: #0d2d20 !important; border-color: #1a5040 !important; color: #5dd9b0 !important; }
[data-theme="dark"] .alert-warning  { background-color: #2d1d05 !important; border-color: #5a3a10 !important; color: #ffd060 !important; }
[data-theme="dark"] .alert-danger   { background-color: #3a1020 !important; border-color: #6b2040 !important; color: #f28ab3 !important; }
[data-theme="dark"] .alert-secondary { background-color: #2a2d45 !important; border-color: #363b5a !important; color: #c8ccdf !important; }
[data-theme="dark"] .alert-light    { background-color: #2a2d45 !important; border-color: #363b5a !important; color: #c8ccdf !important; }
[data-theme="dark"] .alert-dark     { background-color: #1e2138 !important; border-color: #2b2f4a !important; color: #c8ccdf !important; }
[data-theme="dark"] .alert-primary  { background-color: #1a2546 !important; border-color: #2e4080 !important; color: #93b4ff !important; }

/* ── Bootstrap list-group ── */
[data-theme="dark"] .list-group-item { background-color: #252840; border-color: #2b2f4a; color: #c8ccdf; }
[data-theme="dark"] .list-group-item:hover { background-color: #2e3252; }
[data-theme="dark"] .list-group-item.active { background-color: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .list-group-item-action { color: #c8ccdf; }
[data-theme="dark"] .list-group-item-action:hover { background-color: #2e3252; color: #fff; }

/* ── Bootstrap progress ── */
[data-theme="dark"] .progress { background-color: #363b5a; }

/* ── Bootstrap accordion ── */
[data-theme="dark"] .accordion-item { background-color: #252840; border-color: #2b2f4a; }
[data-theme="dark"] .accordion-button { background-color: #2a2d45; color: #c8ccdf; }
[data-theme="dark"] .accordion-button:not(.collapsed) { background-color: #2e3252; color: #c8ccdf; box-shadow: inset 0 -1px 0 #2b2f4a; }
[data-theme="dark"] .accordion-button::after { filter: invert(1) brightness(0.8); }
[data-theme="dark"] .accordion-body { background-color: #252840; color: #c8ccdf; }

/* ── Bootstrap nav-pills ── */
[data-theme="dark"] .nav-pills .nav-link { color: #8a8fac; }
[data-theme="dark"] .nav-pills .nav-link.active { background-color: var(--primary); color: #fff; }

/* ── Bootstrap table (ensures no white bg bleeds through) ── */
[data-theme="dark"] .table > :not(caption) > * > * { background-color: transparent; color: #c8ccdf; border-color: #2b2f4a; }
[data-theme="dark"] .table-bordered > :not(caption) > * { border-color: #2b2f4a; }
[data-theme="dark"] .table-bordered > :not(caption) > * > * { border-color: #2b2f4a; }
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * { background-color: #2a2d45; --bs-table-accent-bg: #2a2d45; }
[data-theme="dark"] .table-hover > tbody > tr:hover > * { background-color: #2e3252; --bs-table-accent-bg: #2e3252; }
[data-theme="dark"] .table-sm > :not(caption) > * > * { padding: 4px 8px; }

/* ── Bootstrap popover ── */
[data-theme="dark"] .popover { background-color: #252840; border-color: #2b2f4a; }
[data-theme="dark"] .popover-header { background-color: #2a2d45; border-bottom-color: #2b2f4a; color: #c8ccdf; }
[data-theme="dark"] .popover-body { color: #c8ccdf; }
[data-theme="dark"] .popover-arrow::before { border-top-color: #2b2f4a; }

/* ── Bootstrap tooltip ── */
[data-theme="dark"] .tooltip-inner { background-color: #363b5a; color: #fff; }

/* ── Bootstrap offcanvas ── */
[data-theme="dark"] .offcanvas { background-color: #252840; color: #c8ccdf; }
[data-theme="dark"] .offcanvas-header { border-bottom-color: #2b2f4a; }

/* ── Bootstrap spinner ── */
[data-theme="dark"] .spinner-border,
[data-theme="dark"] .spinner-grow { color: var(--primary); }

/* ── Logs-unified dark overrides ── */
[data-theme="dark"] .filter-header { border-bottom-color: #2b2f4a; }
[data-theme="dark"] .filter-header h6 { color: #8a8fac; }
[data-theme="dark"] .filter-buttons { border-top-color: #2b2f4a; }
[data-theme="dark"] .btn-reset {
    background: #2a2d45;
    color: #8a8fac;
    border-color: #363b5a;
}
[data-theme="dark"] .btn-reset:hover {
    background: #2e3252;
    border-color: #4a4f70;
    color: #c8ccdf;
}
[data-theme="dark"] .preset-btn {
    background: #2a2d45;
    color: #8a8fac;
    border-color: #363b5a;
}
[data-theme="dark"] .preset-btn:hover {
    background: #2e3252;
    border-color: var(--primary);
    color: var(--primary);
}
[data-theme="dark"] .payload-box {
    background: #1e2138;
    border-color: #2b2f4a;
    color: #c8ccdf;
}
[data-theme="dark"] .status-success  { color: #5dd9b0; background: #0d2d20; }
[data-theme="dark"] .status-failed   { color: #f28ab3; background: #3a1020; }
[data-theme="dark"] .status-skipped  { color: #ffd060; background: #2d1d05; }
[data-theme="dark"] .status-received { color: #6eb8ff; background: #0d2546; }


/* ── Sidebar v2: fixed header/footer, scrolling nav, grouped sections ── */
.sidebar {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}
.sidebar-logo,
.sidebar-collapse { flex-shrink: 0; }

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 6px 0 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.14) transparent;
    /* Scroll shadows: a soft edge appears only while there is more menu above/below. */
    background:
        linear-gradient(var(--sidebar-bg) 30%, transparent) center top / 100% 28px no-repeat local,
        linear-gradient(transparent, var(--sidebar-bg) 70%) center bottom / 100% 28px no-repeat local,
        linear-gradient(rgba(0,0,0,0.30), transparent) center top / 100% 14px no-repeat scroll,
        linear-gradient(transparent, rgba(0,0,0,0.30)) center bottom / 100% 14px no-repeat scroll;
    background-color: var(--sidebar-bg);
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

.sidebar-nav .nav-section {
    list-style: none;
    padding: 16px 22px 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(162,165,185,0.55);
    white-space: nowrap;
    user-select: none;
}
.sidebar-nav > ul > .nav-section:first-child { padding-top: 8px; }

.sidebar-nav .nav-link {
    margin: 1px 10px;
    padding: 8px 12px;
    border-radius: 8px;
    gap: 11px;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.05); }
.sidebar-nav .nav-link.active {
    background: rgba(93,120,255,0.16);
    color: #fff;
    border-left: none;
    padding-left: 12px;
}
.sidebar-nav > ul > .nav-item > .nav-link.active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
}
.sidebar-nav .submenu {
    background: none;
    margin: 2px 0 4px 32px;
    padding-left: 0;
    border-left: 1px solid rgba(255,255,255,0.08);
}
.sidebar-nav .submenu .nav-link {
    margin: 1px 10px 1px 8px;
    padding: 6px 10px;
    font-size: 12.5px;
}
.sidebar-nav .submenu .nav-link.active {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.sidebar.collapsed .sidebar-nav .nav-section {
    height: 1px;
    padding: 0;
    margin: 10px 18px;
    font-size: 0;
    background: rgba(255,255,255,0.08);
}
.sidebar.collapsed .sidebar-nav > ul > .nav-section:first-child { margin-top: 4px; }
.sidebar.collapsed .sidebar-nav .nav-link {
    margin: 1px 12px;
    padding: 9px 0;
}
.sidebar.collapsed .sidebar-nav .nav-link.active { box-shadow: none; }

/* Short screens (laptops, zoomed browsers): denser menu so more of it fits. */
@media (max-height: 820px) {
    .sidebar-logo { height: 52px; }
    .sidebar-logo img, .sidebar-logo svg { height: 42px; }
    .sidebar-nav .nav-section { padding: 10px 22px 4px; }
    .sidebar-nav .nav-link { padding: 6px 12px; }
    .sidebar.collapsed .sidebar-nav .nav-link { padding: 7px 0; }
    .sidebar.collapsed .sidebar-nav .nav-section { margin: 7px 18px; }
    .sidebar-collapse { padding: 9px 20px; }
}

/* ── Lead phone lock ── */
.ico {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    vertical-align: -0.125em;
}
.phone-locked-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 9px 1px 7px;
    border: 1px solid #dfe3f0;
    border-radius: 999px;
    background: #f5f6fb;
    color: #6c7293;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 18px;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.phone-locked-pill .ico { width: 11px; height: 11px; color: #9aa0bd; transition: color 0.15s; }
.phone-locked-pill:hover,
.phone-locked-pill:focus-visible {
    background: rgba(93,120,255,0.08);
    border-color: rgba(93,120,255,0.35);
    color: var(--primary);
    outline: none;
}
.phone-locked-pill:hover .ico,
.phone-locked-pill:focus-visible .ico { color: var(--primary); }

.phone-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: rgba(93,120,255,0.12);
    color: var(--primary);
    font-size: 14px;
}

/* Header pill: locked → button that opens the unlock dialog; unlocked → countdown + hide now. */
.phone-access { display: flex; align-items: center; }
.phone-access[data-state="loading"],
.phone-access[data-state="hidden"] { display: none; }
.phone-access[data-state="locked"] .phone-access-unlocked,
.phone-access[data-state="unlocked"] .phone-access-locked { display: none; }

.phone-access-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 11px;
    border-radius: 999px;
    border: 1px solid #e3e6f2;
    background: #f7f8fc;
    color: #6c7293;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
}
.phone-access-pill .ico { width: 13px; height: 13px; }
button.phone-access-pill { cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s; }
button.phone-access-pill:hover {
    background: rgba(93,120,255,0.08);
    border-color: rgba(93,120,255,0.35);
    color: var(--primary);
}
.phone-access-unlocked {
    padding-right: 4px;
    border-color: rgba(10,187,135,0.35);
    background: rgba(10,187,135,0.08);
    color: #078a64;
}
/* Remaining time as a thin bar along the bottom edge. */
.phone-access-unlocked::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: var(--phone-access-progress, 100%);
    background: currentColor;
    opacity: 0.45;
    transition: width 1s linear;
}
.phone-access.is-ending .phone-access-unlocked {
    border-color: rgba(255,184,34,0.5);
    background: rgba(255,184,34,0.1);
    color: #b7791f;
}
.phone-access-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 34px;
    text-align: right;
}
.phone-access-lock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 2px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 10px;
    cursor: pointer;
    opacity: 0.75;
    transition: background 0.15s, opacity 0.15s;
}
.phone-access-lock:hover { background: rgba(0,0,0,0.08); opacity: 1; }

@media (max-width: 992px) {
    .phone-access-label { display: none; }
    .phone-access-pill { padding: 0 8px; }
    .phone-access-unlocked { padding-right: 3px; }
}

[data-theme="dark"] .phone-locked-pill { background: #262a42; border-color: #343959; color: #9aa0bd; }
[data-theme="dark"] .phone-locked-pill .ico { color: #7c82a0; }
[data-theme="dark"] .phone-locked-pill:hover { background: rgba(93,120,255,0.16); color: #9eb0ff; border-color: rgba(93,120,255,0.45); }
[data-theme="dark"] .phone-locked-pill:hover .ico { color: #9eb0ff; }
[data-theme="dark"] .phone-access-pill { background: #262a42; border-color: #343959; color: #9aa0bd; }
[data-theme="dark"] .phone-access-unlocked { background: rgba(10,187,135,0.12); border-color: rgba(10,187,135,0.4); color: #3fd6a6; }
[data-theme="dark"] .phone-access.is-ending .phone-access-unlocked { background: rgba(255,184,34,0.12); border-color: rgba(255,184,34,0.45); color: #ffc75a; }
[data-theme="dark"] .phone-access-lock:hover { background: rgba(255,255,255,0.1); }


/* Маленькие мониторы: колонки отчёта плотнее, чтобы таблица помещалась без обрезания справа */
@media (max-width: 1600px) {
    .breakdown-table .stats-table th,
    .breakdown-table .stats-table td {
        padding: 8px 5px;
        font-size: 12px;
        white-space: nowrap;
    }
}
