.theme-toggle { background: var(--surface-soft); border-color: var(--line); font-family: inherit; }
.theme-toggle:focus-visible { outline: 3px solid var(--brand-primary); outline-offset: 3px; }

html[data-bs-theme="dark"] {
    color-scheme: dark;
    --brand-primary: #78aaff;
    --ink: #e5edf7;
    --muted: #aebdd0;
    --line: #354459;
    --surface: #1b2738;
    --surface-soft: #233247;
}
html[data-bs-theme="dark"] body {
    background: radial-gradient(circle at top left, rgba(20,184,166,.08), transparent 32rem), linear-gradient(180deg, #111b2a, #0d1522);
    color: var(--ink);
}
html[data-bs-theme="dark"] :is(.site-header, .site-footer) { background: rgba(17,27,42,.94); border-color: var(--line); }
html[data-bs-theme="dark"] :is(.header-link, .footer-links a, .dashboard-freshness) { color: var(--muted); }
html[data-bs-theme="dark"] .header-link:is(:hover, :focus-visible, [aria-current="page"]) { color: var(--brand-primary); background: var(--surface-soft); border-color: var(--line); }

html[data-bs-theme="dark"] .dashboard-theme {
    --dashboard-primary: #70cbc5;
    --dashboard-primary-deep: #bce9e5;
    --dashboard-primary-soft: #253e43;
    --dashboard-primary-faint: #1c3038;
    --dashboard-border: #354b58;
    --dashboard-control-border: #496170;
}
html[data-bs-theme="dark"] .instagram-theme { --dashboard-primary: #d2a6f2; --dashboard-primary-deep: #edd9fc; --dashboard-primary-soft: #392b49; --dashboard-primary-faint: #292338; --dashboard-border: #4a3a5a; --dashboard-control-border: #665179; }
html[data-bs-theme="dark"] .telegram-theme { --dashboard-primary: #79c9f0; --dashboard-primary-deep: #c4e8fb; --dashboard-primary-soft: #213d51; --dashboard-primary-faint: #1a2d3d; --dashboard-border: #344c61; --dashboard-control-border: #48647b; }

html[data-bs-theme="dark"] :is(.page-panel, .app-card, .auth-card, .metric-card, .rfm-panel, .rfm-filter, .chart-card, .customer-card, .dashboard-filter, .tg-panel, .tg-kpi, .ig-kpi, .ig-mini-kpi, .ig-feature-panel, .messaging-filter, .messaging-dashboard .tg-head, .messaging-dashboard .dashboard-hero, .rfm-nav, .empty-state) {
    background: var(--surface); color: var(--ink); border-color: var(--line);
}
html[data-bs-theme="dark"] :is(.dashboard-plot, .dashboard-theme form.row, .ci-table-expander, .ci-table-expander > summary, .input-guide, .guide-path span) { background: var(--surface-soft); color: var(--ink); border-color: var(--line); }
html[data-bs-theme="dark"] :is(.rfm-page-head h1, .chart-card header h2, .metric-number, .dashboard-plot-title, .form-label, .voip-filter-label, .input-guide > summary, .input-guide-body) { color: var(--ink); }
html[data-bs-theme="dark"] :is(.metric-label, .metric-card small, .customer-cell small, .rfm-page-head p, .empty-state p, .tg-note, .tg-empty, .messaging-dashboard .dashboard-hero .opacity-75, .tg-kpi span, .ig-kpi span, .ig-mini-kpi span, .ci-table-expander > summary small, .guide-path) { color: var(--muted); }
html[data-bs-theme="dark"] :is(.rfm-nav-items a, .voip-nav .nav-link:not(.active)) { color: var(--muted); }
html[data-bs-theme="dark"] :is(.rfm-nav-items a:hover, .rfm-nav-items a.active, .messaging-tab:not(.active)) { background: var(--dashboard-primary-soft); color: var(--dashboard-primary-deep); }

html[data-bs-theme="dark"] :is(.form-control, .form-select, input[type="text"], input[type="password"], input[type="email"], .tg-filter select, .input-group-text) { background-color: var(--surface-soft); color: var(--ink); border-color: var(--line); }
html[data-bs-theme="dark"] :is(.form-control, input)::placeholder { color: var(--muted); }
html[data-bs-theme="dark"] :is(.choices__inner, .rfm-search .form-control, .rfm-search .input-group-text) { background-color: var(--surface-soft) !important; color: var(--ink); border-color: var(--line) !important; }
html[data-bs-theme="dark"] :is(.choices__list--dropdown, .choices__list[aria-expanded]) { background: var(--surface); color: var(--ink); border-color: var(--line); }
html[data-bs-theme="dark"] .choices__list--dropdown .choices__item--selectable.is-highlighted { background: var(--surface-soft); }
html[data-bs-theme="dark"] .choices__input { color: var(--ink); }

html[data-bs-theme="dark"] .table {
    --bs-table-bg: var(--surface);
    --bs-table-color: var(--ink);
    --bs-table-striped-bg: var(--surface-soft);
    --bs-table-striped-color: var(--ink);
    --bs-table-hover-bg: #2c4055;
    --bs-table-hover-color: var(--ink);
    border-color: var(--line);
}
html[data-bs-theme="dark"] .table thead th { background: var(--dashboard-primary-soft, var(--surface-soft)); color: var(--dashboard-primary-deep, var(--ink)); }
html[data-bs-theme="dark"] :is(.table td, .table th, .customer-card-header, .pagination-wrap) { border-color: var(--line); }
html[data-bs-theme="dark"] .bg-white { background-color: var(--surface) !important; }
html[data-bs-theme="dark"] .text-dark { color: var(--ink) !important; }
html[data-bs-theme="dark"] .dashboard-theme :is(.btn-app, .btn-primary) { color: #fff; background: var(--dashboard-primary-dark); border-color: var(--dashboard-primary); }
html[data-bs-theme="dark"] .btn-app { color: #111b2a; }
html[data-bs-theme="dark"] .dashboard-theme .btn-app { color: #fff; }
html[data-bs-theme="dark"] :is(.btn-error-secondary, .skip-link) { background: var(--surface); color: var(--ink); border-color: var(--line); }
html[data-bs-theme="dark"] .ig-search-result { background: var(--surface); border-color: var(--line); }
html[data-bs-theme="dark"] .jalali-date-input { background-color: var(--surface-soft) !important; }
html[data-bs-theme="dark"] .jalali-calendar-trigger { border-color: var(--line); }
html[data-bs-theme="dark"] .datepicker-plot-area,
html[data-bs-theme="dark"] .datepicker-plot-area :is(.datepicker-navigator .pwt-btn, .datepicker-day-view .table-days td span, .datepicker-month-view .month-item, .datepicker-year-view .year-item, .datepicker-time-view, .datepicker-toolbox) { background: var(--surface); color: var(--ink); border-color: var(--line); }
html[data-bs-theme="dark"] .datepicker-plot-area .datepicker-day-view .table-days td.selected span { background: #2563eb; color: #fff; }
html[data-bs-theme="dark"] .dashboard-theme :is(.btn-outline-primary:hover, .btn-outline-primary:focus) { background: var(--dashboard-primary-dark); color: #fff; }
