/**
 * Тёмная тема оформления
 * Активируется применительно к html[data-theme="dark"]
 */
html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="dark"] body {
    background: linear-gradient(to bottom, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
}

/* Переопределение переменных для тёмной темы */
html[data-theme="dark"] {
    --ui-primary: #3b82f6;
    --ui-primary-hover: #60a5fa;
    --ui-success: #10b981;
    --ui-success-hover: #34d399;
    --ui-secondary-bg: #334155;
    --ui-secondary-border: #475569;
    --ui-secondary-color: #94a3b8;
    --ui-secondary-hover-bg: #475569;
    --ui-secondary-hover-border: #64748b;
    --ui-text: #f1f5f9;
    --ui-text-muted: #94a3b8;
    --ui-text-hint: #64748b;
    --ui-border: #334155;
    --ui-border-light: #1e293b;
    --ui-bg-muted: #1e293b;
    --ui-bg-subtle: #0f172a;
    --ui-modal-header-bg: #1e293b;

    --surface: #1e293b;
    --surface-2: #334155;
    --border: #334155;
    --text: #f1f5f9;
    --muted: #94a3b8;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 24px rgba(0,0,0,0.4);

    /* admin-styles.css — переопределение переменных админки */
    --admin-bg: #0c1222;
    --admin-bg-secondary: #151b2d;
    --admin-surface: #1a2234;
    --admin-surface-hover: #232d42;
    --admin-border: #2a3548;
    --admin-border-light: #1e2838;
    --admin-border-dark: #3d4a5f;
    --admin-text: #e8ecf4;
    --admin-text-secondary: #9ca8b8;
    --admin-text-muted: #6b7a8f;
    --admin-primary: #3b82f6;
    --admin-primary-dark: #2563eb;

    /* SmartTable — переопределение переменных */
    --st-header-bg: #334155;
    --st-border-color: #334155;
    --st-hover-bg: #334155;
    --st-selected-bg: #1e3a5f;
    --st-text-color: #e2e8f0;
    --st-text-secondary: #94a3b8;
    --st-white: #1e293b;
}

/* Sidebar в тёмной теме — нейтральный slate, чуть светлее основного фона */
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .crm-sidebar {
    background: #1e293b;
    border-right-color: #334155;
}

/* Основной контент */
html[data-theme="dark"] .main-content {
    background: var(--admin-bg);
}

html[data-theme="dark"] .smart-table-container,
html[data-theme="dark"] .reclamation-table-wrap {
    background: var(--surface);
    border-color: var(--border);
}

/* Модалки */
html[data-theme="dark"] .modal-content {
    background: #1e293b;
    border-color: #334155;
}

html[data-theme="dark"] .modal-professional .modal-header,
html[data-theme="dark"] .modal-professional h2,
html[data-theme="dark"] .subscription-details-header {
    border-color: #334155;
    background: #1e293b;
}

html[data-theme="dark"] .subscription-details-body {
    background: #1e293b;
}

html[data-theme="dark"] .data-section {
    background: #334155;
    border-color: #475569;
}

html[data-theme="dark"] .subscription-details-title,
html[data-theme="dark"] .modal-professional-title {
    color: #f1f5f9;
}

/* Инпуты и селекты — везде в приложении */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #f1f5f9 !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #64748b !important;
}

/* Универсально: любой элемент с белым/светлым фоном */
html[data-theme="dark"] select option {
    background: #1e293b;
    color: #e2e8f0;
}
html[data-theme="dark"] pre[style*="background: white"],
html[data-theme="dark"] pre[style*="background: #fff"] {
    background: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* Таблицы */
html[data-theme="dark"] .simple-table,
html[data-theme="dark"] .reclamation-table {
    background: #1e293b;
}

html[data-theme="dark"] table thead {
    background: #334155;
    border-color: #475569;
}

html[data-theme="dark"] table th {
    color: #e2e8f0;
    border-color: #475569;
}

html[data-theme="dark"] table td {
    border-color: #334155;
    color: #e2e8f0;
}

html[data-theme="dark"] table tbody tr:hover {
    background: #334155;
}

/* Админка: таблицы бэкапов и подписок — заголовки (жёсткий светлый градиент в admin-styles) */
html[data-theme="dark"] .backups-table th,
html[data-theme="dark"] .subscriptions-table th {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

/* Трекинг: таблица «История выполнения» */
html[data-theme="dark"] .tracking-jobs-table,
html[data-theme="dark"] .tracking-jobs-table-wrapper table {
    background: #1e293b !important;
}
html[data-theme="dark"] .tracking-jobs-table thead tr {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .tracking-jobs-table th {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .tracking-jobs-table tbody tr {
    border-color: #334155 !important;
}
html[data-theme="dark"] .tracking-jobs-table td {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .tracking-jobs-table td[style*="color: #666"],
html[data-theme="dark"] .tracking-jobs-table td[style*="color:#666"],
html[data-theme="dark"] .tracking-jobs-table span[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .tracking-jobs-table td[style*="color: #4caf50"] {
    color: #6ee7b7 !important;
}
html[data-theme="dark"] .tracking-jobs-table td[style*="color: #f44336"] {
    color: #fca5a5 !important;
}
html[data-theme="dark"] .tracking-jobs-table .job-details-row {
    background: #334155 !important;
}
html[data-theme="dark"] .tracking-jobs-table .job-details-row td {
    color: #94a3b8 !important;
}

/* Трекинг: карточки задач */
html[data-theme="dark"] .tracking-job-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .tracking-job-card:hover {
    background: #334155 !important;
}

/* Трекинг: предупреждение «Без билетов» — тёмный вариант */
html[data-theme="dark"] .tracking-warn-no-tickets {
    background: #422006 !important;
    color: #fcd34d !important;
    border: 1px solid #78350f;
}
html[data-theme="dark"] .tracking-warn-no-tickets span {
    color: #fbbf24 !important;
}

/* Трекинг: статус «Ошибка» — читаемый контраст */
html[data-theme="dark"] .job-status-badge.job-status-failed {
    background: #7f1d1d !important;
    color: #fca5a5 !important;
}

/* Админка: скроллбары в списках (SMS, бэкапы, логи и т.п.) */
html[data-theme="dark"] #sms-messages-list,
html[data-theme="dark"] #tracking-jobs-list,
html[data-theme="dark"] .tracking-jobs-table-wrapper,
html[data-theme="dark"] .messages-list {
    scrollbar-width: thin;
    scrollbar-color: #475569 #1e293b;
}
html[data-theme="dark"] #sms-messages-list::-webkit-scrollbar,
html[data-theme="dark"] #tracking-jobs-list::-webkit-scrollbar,
html[data-theme="dark"] .tracking-jobs-table-wrapper::-webkit-scrollbar,
html[data-theme="dark"] .messages-list::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
html[data-theme="dark"] #sms-messages-list::-webkit-scrollbar-track,
html[data-theme="dark"] #tracking-jobs-list::-webkit-scrollbar-track,
html[data-theme="dark"] .tracking-jobs-table-wrapper::-webkit-scrollbar-track,
html[data-theme="dark"] .messages-list::-webkit-scrollbar-track {
    background: #1e293b;
}
html[data-theme="dark"] #sms-messages-list::-webkit-scrollbar-thumb,
html[data-theme="dark"] #tracking-jobs-list::-webkit-scrollbar-thumb,
html[data-theme="dark"] .tracking-jobs-table-wrapper::-webkit-scrollbar-thumb,
html[data-theme="dark"] .messages-list::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

/* Хедер на главной (если есть) */
html[data-theme="dark"] .main-header,
html[data-theme="dark"] .toolbar-modern {
    background: #1e293b;
    border-color: #334155;
}

/* Админ-панель */
html[data-theme="dark"] .admin-container {
    background: var(--admin-bg);
}

html[data-theme="dark"] .admin-header {
    background: var(--admin-surface);
    border-color: var(--admin-border);
    box-shadow: 0 1px 0 rgba(255,255,255,0.03);
}

html[data-theme="dark"] .admin-tabs {
    background: var(--admin-bg-secondary);
    border: 1px solid var(--admin-border);
    border-radius: 8px;
}

html[data-theme="dark"] .admin-tab {
    color: var(--admin-text-secondary);
}

html[data-theme="dark"] .admin-tab:hover {
    color: var(--admin-text);
    background: rgba(255,255,255,0.04);
}

html[data-theme="dark"] .admin-tab.active {
    background: var(--admin-surface);
    color: #60a5fa !important;
    border: 1px solid var(--admin-border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

html[data-theme="dark"] .admin-card {
    background: var(--admin-surface);
    border-color: var(--admin-border);
}

/* ===== Область поиска ===== */
html[data-theme="dark"] .search-bar-area {
    background: #1e293b !important;
    border-bottom-color: #334155 !important;
}

/* ===== SmartTable: строки, пагинация, фильтры ===== */
html[data-theme="dark"] .st-table tbody tr:nth-child(even) td,
html[data-theme="dark"] .st-table tbody tr:nth-child(odd) td {
    background-color: #1e293b !important;
}
html[data-theme="dark"] .st-table tbody tr:hover td {
    background-color: #334155 !important;
}
html[data-theme="dark"] .st-table tbody tr.selected td {
    background-color: #1e3a5f !important;
}
html[data-theme="dark"] .st-table tbody tr.row-viewing td {
    background-color: #1e3a5f !important;
}
html[data-theme="dark"] .st-table tbody tr.row-viewing:hover td {
    background-color: #2563eb33 !important;
}
html[data-theme="dark"] .st-toolbar,
html[data-theme="dark"] .st-pagination {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .st-filter-dropdown,
html[data-theme="dark"] .st-modal-content,
html[data-theme="dark"] .st-modal-header,
html[data-theme="dark"] .st-modal-body,
html[data-theme="dark"] .st-modal-footer {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .st-modal-header h2,
html[data-theme="dark"] .st-column-group h3 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .st-loading {
    background: rgba(15, 23, 42, 0.9) !important;
}
html[data-theme="dark"] .st-table-wrapper::-webkit-scrollbar-track {
    background: #1e293b;
}
html[data-theme="dark"] .st-table-wrapper::-webkit-scrollbar-thumb {
    background: #475569;
}
html[data-theme="dark"] .st-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ===== База: ячейки месяцев, бейджи jan26/feb26 в заголовках и ячейках ===== */
html[data-theme="dark"] .st-table th span[style*="background:#fff3cd"],
html[data-theme="dark"] .st-table th span[style*="background: #fff3cd"],
html[data-theme="dark"] .st-table td span[style*="background:#fff3cd"],
html[data-theme="dark"] .st-table td span[style*="background: #fff3cd"] {
    background: #3d3520 !important;
    color: #fcd34d !important;
    border-color: #5a4d2e !important;
}
/* Тёмный текст #000 в ячейках таблицы — номера и месяцы */
html[data-theme="dark"] .st-table td span[style*="color:#000"],
html[data-theme="dark"] .st-table th span[style*="color:#000"] {
    color: #fcd34d !important;
}
html[data-theme="dark"] .month-cell.status-1 {
    color: #6ee7b7 !important;
}
html[data-theme="dark"] .month-cell.status-minus-1 {
    color: #fca5a5 !important;
}
html[data-theme="dark"] .month-cell.status-empty {
    color: #64748b !important;
}
/* Таблица базы: читаемость месяцев (jan26, feb26) — чуть крупнее бейджи */
html[data-theme="dark"] .st-table td span[style*="font-size:9px"],
html[data-theme="dark"] .st-table th span[style*="font-size:9px"] {
    font-size: 10px !important;
}
/* Ячейки месяцев редакционной подписки — подсветка в тёмной теме (принята/отклонена) */
html[data-theme="dark"] .st-table td[data-month-column="true"][data-editorial-status="loaded"] {
    background: #1e3a5f !important;
    border-left: 2px solid #60a5fa;
}
html[data-theme="dark"] .st-table td[data-month-column="true"][data-editorial-status="rejected"] {
    background: #3d1e1e !important;
    border-left: 2px solid #f87171;
}

/* ===== Журнал отправок: контейнер, заголовки месяцев, бейджи ===== */
html[data-theme="dark"] #shipping-log-content > div[style*="background: #fff"],
html[data-theme="dark"] #shipping-log-content > div[style*="background:#fff"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .month-header {
    background: #334155 !important;
}
html[data-theme="dark"] .month-header:hover {
    background: #475569 !important;
}
html[data-theme="dark"] .month-group {
    border-bottom-color: #334155 !important;
}
html[data-theme="dark"] .month-toggle {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .month-header span[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .shipping-log-description-badge,
html[data-theme="dark"] .shipping-log-row td span[style*="background: #f5f5f5"] {
    background: #334155 !important;
    color: #cbd5e1 !important;
}
html[data-theme="dark"] .shipping-log-row td[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .shipping-log-row td[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .shipping-log-row span[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .month-header span[style*="background: #e3f2fd"] {
    background: #1e3a5f !important;
    color: #93c5fd !important;
}
/* Кнопка переименования (карандаш) */
html[data-theme="dark"] .shipping-log-rename-btn {
    color: #93c5fd !important;
}
html[data-theme="dark"] .shipping-log-rename-btn:hover {
    color: #60a5fa !important;
}
/* Кнопки действий — контраст иконок */
html[data-theme="dark"] .shipping-log-preview-btn,
html[data-theme="dark"] .shipping-log-sync-btn,
html[data-theme="dark"] .shipping-log-delete-btn {
    color: #fff !important;
}
html[data-theme="dark"] .shipping-log-preview-btn {
    background: #475569 !important;
    border-color: #64748b !important;
}
html[data-theme="dark"] .shipping-log-preview-btn:hover {
    background: #64748b !important;
}
/* Скроллбар в журнале отправок */
html[data-theme="dark"] #shipping-log-content {
    scrollbar-width: thin;
    scrollbar-color: #475569 #1e293b;
}
html[data-theme="dark"] #shipping-log-content::-webkit-scrollbar {
    width: 6px;
}
html[data-theme="dark"] #shipping-log-content::-webkit-scrollbar-track {
    background: transparent;
}
html[data-theme="dark"] #shipping-log-content::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}
html[data-theme="dark"] #shipping-log-content::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}
/* Fallback-вид (без группировки) */
html[data-theme="dark"] #shipping-log-content > div[style*="overflow-x: auto"] {
    border-color: #334155 !important;
    background: #1e293b !important;
}
html[data-theme="dark"] #shipping-log-content p[style*="color: #666"],
html[data-theme="dark"] #shipping-log-content p[style*="text-align: center"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shipping-log-content .simple-table {
    background: #1e293b !important;
}

/* Скроллбар в архивных листах */
html[data-theme="dark"] #shipping-lists-content {
    scrollbar-width: thin;
    scrollbar-color: #475569 #1e293b;
}
html[data-theme="dark"] #shipping-lists-content::-webkit-scrollbar {
    width: 6px;
}
html[data-theme="dark"] #shipping-lists-content::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

/* ===== Модалка подготовки отправки: блоки параметров ===== */
html[data-theme="dark"] #shippingModal div[style*="background: #fafafa"],
html[data-theme="dark"] #shippingModal div[style*="background:#fafafa"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #shippingModal #arch-params,
html[data-theme="dark"] #shippingModal #regular-params,
html[data-theme="dark"] #shippingModal #mass-params,
html[data-theme="dark"] #shippingModal div[style*="background: #e8f5e9"],
html[data-theme="dark"] #shippingModal div[style*="background: #fff3e0"],
html[data-theme="dark"] #shippingModal div[style*="background: #e3f2fd"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #shippingModal #arch-params h3,
html[data-theme="dark"] #shippingModal #arch-params h4,
html[data-theme="dark"] #shippingModal #arch-params label span,
html[data-theme="dark"] #shippingModal #regular-params h4,
html[data-theme="dark"] #shippingModal #regular-params label span,
html[data-theme="dark"] #shippingModal #mass-params h4,
html[data-theme="dark"] #shippingModal #mass-params label span {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #shippingModal #arch-params small,
html[data-theme="dark"] #shippingModal #regular-params small,
html[data-theme="dark"] #shippingModal #mass-params small {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shippingModal #arch-list-name-hint,
html[data-theme="dark"] #shippingModal #regular-list-name-hint,
html[data-theme="dark"] #shippingModal #regular-current-month-hint,
html[data-theme="dark"] #shippingModal #mass-list-name-hint,
html[data-theme="dark"] #shippingModal #mass-current-month-hint {
    color: #93c5fd !important;
}
html[data-theme="dark"] #shippingModal label[style*="background: white"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #shippingModal h3[style*="color: #333"],
html[data-theme="dark"] #shippingModal label strong,
html[data-theme="dark"] #shippingModal label span[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #shippingModal label span[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shippingModal label[style*="background: white"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #shippingModal label[style*="background: white"]:hover {
    background: #475569 !important;
}
html[data-theme="dark"] #shippingModal div[style*="background: white"],
html[data-theme="dark"] #shippingModal div[style*="background: white"][style*="border: 1px solid #ddd"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #shippingModal div[style*="background: white"] span {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #shippingModal p[style*="background: white"] {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shippingModal .btn-group[style*="border-top"] {
    border-top-color: #475569 !important;
}

/* ===== Предпросмотр отправки ===== */
html[data-theme="dark"] #shippingPreviewModal .modal-content > div[style*="background: #fafafa"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #shippingPreviewModal h2,
html[data-theme="dark"] #shippingPreviewModal div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #shippingPreviewModal div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shippingPreviewModal div[style*="color: #999"] {
    color: #64748b !important;
}

/* ===== Журнал отправок: детали листа, рекламации ===== */
html[data-theme="dark"] #log-details-header,
html[data-theme="dark"] #log-details-title,
html[data-theme="dark"] #reclamation-contents-title,
html[data-theme="dark"] #reclamation-add,
html[data-theme="dark"] div[style*="background: #fafafa"][style*="border: 1px solid"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #log-details-header [style*="color: #333"],
html[data-theme="dark"] #log-details-header [style*="color:#333"],
html[data-theme="dark"] #reclamationModal [style*="color: #333"],
html[data-theme="dark"] #reclamationModal [style*="color:#333"],
html[data-theme="dark"] .modal h2[style*="color: #333"],
html[data-theme="dark"] .modal h2[style*="color:#333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #log-details-header [style*="color: #666"],
html[data-theme="dark"] #log-details-header [style*="color:#666"],
html[data-theme="dark"] .modal [style*="color: #666"],
html[data-theme="dark"] .modal [style*="color:#666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #edit-reclamation-subscription-issues {
    background: #334155 !important;
    border-color: #475569 !important;
}

/* ===== Таблицы в модалках ===== */
html[data-theme="dark"] .modal-content table {
    background: #1e293b !important;
}
html[data-theme="dark"] .modal-content table thead {
    background: #334155 !important;
}
html[data-theme="dark"] .modal-content table th {
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .modal-content table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .modal-content table tbody tr:hover td {
    background: #334155 !important;
}
html[data-theme="dark"] .modal-content table td:has(span[style*="background: #f5f5f5"]) span,
html[data-theme="dark"] .modal-content table td:has(.reclamation-pill) .reclamation-pill {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

/* ===== Модалка «Содержимое списка рекламаций» — читаемость ===== */
html[data-theme="dark"] #reclamationListContentsModal .reclamation-contents-info {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #reclamationListContentsModal .reclamation-contents-label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #reclamationListContentsModal .reclamation-contents-value {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #reclamationListContentsModal .reclamation-content-row td {
    color: #e2e8f0 !important;
}
/* Бейджи «Номера для досылки» — дата читаемее (10px вместо 8px) */
html[data-theme="dark"] .reclamation-issue-card .reclamation-issue-date {
    font-size: 10px !important;
    opacity: 1 !important;
}
/* Контейнер таблицы */
html[data-theme="dark"] #reclamationListContentsModal .reclamation-contents-table-wrap {
    border-color: #334155 !important;
}

/* ===== Трек-номера: читаемость в модалках «Содержимое списка» ===== */
html[data-theme="dark"] #shippingLogDetailsModal span[style*="#764ba2"],
html[data-theme="dark"] #shippingLogDetailsModal span[style*="color: #764ba2"] {
    color: #c4b5fd !important;
}
html[data-theme="dark"] #shippingLogDetailsModal button[style*="#764ba2"] {
    color: #c4b5fd !important;
    border-color: #a78bfa !important;
    background: rgba(139, 92, 246, 0.2) !important;
}
html[data-theme="dark"] #shippingLogDetailsModal div[style*="color: #555"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #reclamationListContentsModal .tracking-link,
html[data-theme="dark"] #reclamationListContentsModal a[style*="#1a73e8"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #shippingLogDetailsModal .simple-table td,
html[data-theme="dark"] #reclamationListContentsModal .simple-table td {
    color: #e2e8f0 !important;
}
/* Шапка и заголовок модалки «Содержимое списка отправки» */
html[data-theme="dark"] #shippingLogDetailsModal #log-details-header,
html[data-theme="dark"] #shippingLogDetailsModal [style*="background: #fafafa"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #shippingLogDetailsModal #log-details-list-number-display,
html[data-theme="dark"] #shippingLogDetailsModal #log-details-count,
html[data-theme="dark"] #shippingLogDetailsModal #log-details-status {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #shippingLogDetailsModal #log-details-created {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shippingLogDetailsModal h2#log-details-title {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* ===== Модалка «Треки по дням хранения» (#tracksStorageDaysModal) ===== */
html[data-theme="dark"] #tracksStorageDaysModal [style*="background: white"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #tracksStorageDaysModal #tracks-storage-days-title,
html[data-theme="dark"] #tracksStorageDaysModal h2[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tracksStorageDaysModal [style*="border-bottom: 1px solid #e0e0e0"] {
    border-color: #334155 !important;
}
html[data-theme="dark"] #tracksStorageDaysModal #tracks-storage-days-content {
    color: #e2e8f0;
}
html[data-theme="dark"] #tracksStorageDaysModal #tracks-storage-days-content div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracksStorageDaysModal thead tr,
html[data-theme="dark"] #tracksStorageDaysModal tr[style*="background: #f5f5f5"] {
    background: #334155 !important;
}
html[data-theme="dark"] #tracksStorageDaysModal thead th,
html[data-theme="dark"] #tracksStorageDaysModal th[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tracksStorageDaysModal tbody tr {
    border-color: #334155 !important;
}
html[data-theme="dark"] #tracksStorageDaysModal td[style*="color: #666"] {
    color: #e2e8f0 !important;
}
/* Трек-номер: #764ba2 → светлый фиолетовый для читаемости */
html[data-theme="dark"] #tracksStorageDaysModal code[style*="#764ba2"],
html[data-theme="dark"] #tracksStorageDaysModal code[style*="color: #764ba2"] {
    color: #c4b5fd !important;
}
/* ID Подписки: #2196f3 → светлый синий для читаемости */
html[data-theme="dark"] #tracksStorageDaysModal span[style*="#2196f3"],
html[data-theme="dark"] #tracksStorageDaysModal span[style*="color: #2196f3"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #tracksStorageDaysModal button[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracksStorageDaysModal div[style*="color: #999"] {
    color: #94a3b8 !important;
}

/* ===== Модалка «Детали отправления» (#shipmentDetailsModal) ===== */
html[data-theme="dark"] #shipmentDetailsModal .modal-content {
    background: #1e293b !important;
}
html[data-theme="dark"] #shipmentDetailsModalHeader {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #shipmentDetailsModalTitle,
html[data-theme="dark"] #shipmentDetailsModal h2[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent {
    background: #0f172a !important;
    color: #e2e8f0 !important;
}
/* Сравнение адресов — «Указанный клиентом» и «Нормализованный» (нет inline color) */
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="border-left: 4px solid"] div[style*="line-height: 1.6"],
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="border-left: 4px solid"] div[style*="line-height: 1.6"] div,
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="border-left: 4px solid"] div[style*="line-height: 1.6"] strong {
    color: #e2e8f0 !important;
}
/* Карточки и блоки */
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: white"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #f9f9f9"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent h3,
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="color: #999"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent [style*="border-bottom: 1px solid #e0e0e0"] {
    border-color: #334155 !important;
}
/* Блок «Почтовое отделение» — светлый inner box */
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: rgba(255,255,255,0.95)"],
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background:rgba(255,255,255,0.95)"] {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="rgba(255,255,255,0.95)"] div[style*="color: #666"],
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="rgba(255,255,255,0.95)"] div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="rgba(255,255,255,0.95)"] div[style*="border-top: 1px solid #e0e0e0"] {
    border-color: #475569 !important;
}
/* Сравнение индексов — совпадение */
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #e8f5e9"] {
    background: #14532d !important;
    border-color: #22c55e !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #e8f5e9"] div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #e8f5e9"] div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #e8f5e9"] div[style*="color: #4caf50"] {
    color: #86efac !important;
}
/* Сравнение индексов — несовпадение */
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #ffebee"] {
    background: #7f1d1d !important;
    border-color: #ef4444 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #ffebee"] div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #ffebee"] div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #ffebee"] div[style*="color: #f44336"] {
    color: #fca5a5 !important;
}
/* Нормализованный адрес — блок #f5f5f5 */
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #f5f5f5"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #f5f5f5"] div {
    color: #e2e8f0 !important;
}
/* История перемещений — карточки событий */
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #fff"] {
    background: #334155 !important;
}
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #f5f5f5"][style*="border-left"] {
    background: #334155 !important;
}
/* Линия таймлайна */
html[data-theme="dark"] #shipmentDetailsModalContent div[style*="background: #e0e0e0"][style*="width: 2px"] {
    background: #475569 !important;
}
/* Закрытие модалки */
html[data-theme="dark"] #shipmentDetailsModal .close {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #shipmentDetailsModal .close:hover {
    color: #e2e8f0 !important;
}

/* ===== Модалка «История перемещений» (#trackingHistoryModal) ===== */
html[data-theme="dark"] #trackingHistoryModal > div {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #tracking-history-content {
    background: #1e293b !important;
}
/* Блоки «Трек-номер» и «Текущий статус» */
html[data-theme="dark"] #tracking-history-content div[style*="background: #f5f5f5"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
/* Статус-боксы (В пути, Вручено и т.д.) — тёмные фоны и светлый текст */
html[data-theme="dark"] #tracking-history-content div[style*="background: #f3e5f5"] {
    background: #422006 !important;
    border-color: #78350f !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #f3e5f5"] div[style*="#7b1fa2"] {
    color: #fcd34d !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e3f2fd"] {
    background: #1e3a5f !important;
    border-color: #2563eb !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e3f2fd"] div[style*="color: #1976d2"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e8f5e9"] {
    background: #14532d !important;
    border-color: #166534 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e8f5e9"] div[style*="color: #2e7d32"] {
    color: #86efac !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #fce4ec"],
html[data-theme="dark"] #tracking-history-content div[style*="background: #ffebee"] {
    background: #7f1d1d !important;
    border-color: #991b1b !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #fce4ec"] div[style*="color: #c2185b"],
html[data-theme="dark"] #tracking-history-content div[style*="background: #ffebee"] div[style*="color: #c62828"] {
    color: #fca5a5 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #fff3e0"] {
    background: #422006 !important;
    border-color: #78350f !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #fff3e0"] div[style*="color: #e65100"] {
    color: #fcd34d !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e0f7fa"] {
    background: #0e7490 !important;
    border-color: #0891b2 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e0f7fa"] div[style*="#00bcd4"] {
    color: #67e8f9 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #f5f5f5"] div[style*="#616161"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e1f5fe"] {
    background: #0c4a6e !important;
    border-color: #0284c7 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e1f5fe"] div[style*="#0277bd"] {
    color: #7dd3fc !important;
}
/* Сообщение «История перемещений пока пуста» */
html[data-theme="dark"] #tracking-history-content div[style*="color: #999"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="color: #999"] + div {
    color: #94a3b8 !important;
}
/* Заголовки и другие элементы внутри контента */
html[data-theme="dark"] #tracking-history-content h3[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tracking-history-content [style*="background: white"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tracking-history-content [style*="background: white"] div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content [style*="background: white"] div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
/* Даты и чёрный текст в таймлайне */
html[data-theme="dark"] #tracking-history-content div[style*="color: #000"],
html[data-theme="dark"] #tracking-history-content div[style*="color:#000"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="color: #999"] {
    color: #94a3b8 !important;
}
/* Блок SMS уведомлений */
html[data-theme="dark"] #tracking-history-content [data-sms-block] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tracking-history-content [data-sms-block] div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content [data-sms-block] div[style*="color: #999"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content [data-sms-block] code {
    background: #1e293b !important;
    color: #93c5fd !important;
    border-color: #475569 !important;
}
/* Карточки email уведомлений (белый полупрозрачный фон) */
html[data-theme="dark"] #tracking-history-content div[style*="rgba(255,255,255"] {
    background: #334155 !important;
    border-color: #475569 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="rgba(255,255,255"] div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="rgba(255,255,255"] div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="rgba(255,255,255"] div[style*="color: #999"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="rgba(255,255,255"] div[style*="border-top: 1px solid #f0f0f0"] {
    border-top-color: #475569 !important;
}
/* Блок «Последняя операция» */
html[data-theme="dark"] #tracking-history-content div[style*="background: #e3f2fd"][style*="border-left"] {
    background: #1e3a5f !important;
    border-left-color: #3b82f6 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e3f2fd"] div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e3f2fd"] div[style*="color: #1976d2"] {
    color: #93c5fd !important;
}
/* Аналитика вручения — заголовок и карточки */
html[data-theme="dark"] #tracking-history-content div[style*="background: #e8f5e9"][style*="border-left: 4px"] {
    background: #14532d !important;
    border-left-color: #22c55e !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e8f5e9"] div[style*="color: #2e7d32"] {
    color: #86efac !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e8f5e9"] [style*="background: white"] {
    background: #334155 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e8f5e9"] [style*="background: white"] div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content div[style*="background: #e8f5e9"] [style*="background: white"] div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
/* Таймлайн — иконки этапов */
html[data-theme="dark"] #tracking-history-content div[style*="background: #f5f5f5"][style*="border-radius: 4px"] {
    background: #475569 !important;
    border-color: #64748b !important;
}
/* Развернутый вид — детали операций */
html[data-theme="dark"] #tracking-history-content #expanded-view div[style*="background: white"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tracking-history-content #expanded-view div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tracking-history-content #expanded-view div[style*="color: #000"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tracking-history-content #expanded-view div[style*="color: #999"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content #expanded-view div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-history-content #expanded-view div[style*="border-left: 2px solid #e0e0e0"] {
    border-left-color: #475569 !important;
}

/* ===== Детали подписки: info-block, list-item, norm-table ===== */
html[data-theme="dark"] .info-block.info-warning {
    background: #3d3520 !important;
    border-color: #5a4d2e !important;
    color: #fcd34d !important;
}
html[data-theme="dark"] .info-block.info-warning h4 {
    color: #fcd34d !important;
}
html[data-theme="dark"] .info-block.info-info {
    background: #1e2d3d !important;
    border-color: #2d4560 !important;
    color: #93c5fd !important;
}
html[data-theme="dark"] .info-block.info-info h4 {
    color: #93c5fd !important;
}
html[data-theme="dark"] .info-block.info-neutral {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .info-block.info-neutral h3,
html[data-theme="dark"] .info-block.info-neutral p,
html[data-theme="dark"] .info-block.info-neutral label {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .info-block.info-neutral small {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .list-item {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .list-item:hover {
    background: #475569 !important;
    border-color: #64748b !important;
}
html[data-theme="dark"] .list-item strong {
    color: #93c5fd !important;
}
html[data-theme="dark"] .list-item .data-field-label,
html[data-theme="dark"] .list-item .list-item-label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .list-item .list-item-name {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .list-item .list-item-remove-btn {
    background: #475569 !important;
    border-color: #64748b !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .list-item code {
    background: #1e293b !important;
    border-color: #475569 !important;
    color: #93c5fd !important;
}

/* ===== Месяцы подписки: бейджи в модалке деталей ===== */
html[data-theme="dark"] .month-badge {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .month-badge[data-month-status="sent"] {
    background: #1e3d2e !important;
    color: #6ee7b7 !important;
    border-color: #34d399 !important;
}
html[data-theme="dark"] .month-badge[data-month-status="pending"] {
    background: #3d3520 !important;
    color: #fcd34d !important;
    border-color: #f59e0b !important;
}
html[data-theme="dark"] .month-badge[data-month-status="cancelled"] {
    background: #3d1e1e !important;
    color: #f87171 !important;
    border-color: #ef4444 !important;
}
html[data-theme="dark"] .month-badge span[style*="color:#64748b"],
html[data-theme="dark"] .month-abbr-container {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .months-container + div [style*="color:#666"],
html[data-theme="dark"] #fullDataModalContent [style*="color:#666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .data-section [style*="border-bottom:1px solid #eee"],
html[data-theme="dark"] .data-section [style*="border-bottom: 1px solid #eee"] {
    border-bottom-color: #334155 !important;
}
html[data-theme="dark"] .norm-table-header > div {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .norm-table-header [style*="color:#64748b"] {
    color: #94a3b8 !important;
}
/* Строки таблицы нормализации */
html[data-theme="dark"] .norm-table-header + div[style*="display:grid"],
html[data-theme="dark"] [style*="grid-template-columns: 160px 1fr 1fr 140px"][style*="border-bottom"] {
    border-bottom-color: #334155 !important;
}
html[data-theme="dark"] #fullDataModalContent [style*="color:#999"],
html[data-theme="dark"] .modal [style*="color:#999"] {
    color: #64748b !important;
}
html[data-theme="dark"] .data-section h3 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .data-section [style*="border-bottom:1px solid #eee"] {
    border-bottom-color: #334155 !important;
}
html[data-theme="dark"] .norm-table-header > div[style*="color:#64748b"] {
    color: #94a3b8 !important;
}
/* Строки таблицы нормализации — текст */
html[data-theme="dark"] .data-section [style*="grid-template-columns: 160px 1fr 1fr 140px"] > div {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .data-section [style*="color:#2e7d32"] {
    color: #34d399 !important;
}
html[data-theme="dark"] .data-section [style*="color:#c62828"] {
    color: #f87171 !important;
}
html[data-theme="dark"] .data-section [style*="color:#667eea"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] .norm-table-header {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .client-info-block {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .client-info-heading,
html[data-theme="dark"] .client-info-block strong {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .client-info-value,
html[data-theme="dark"] .client-info-row {
    color: #e2e8f0 !important;
}
/* Подписки клиента: блок журнала, таблица, текущая строка */
html[data-theme="dark"] .journal-subscription-block {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .journal-subscription-header {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .client-subscriptions-table thead tr {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .client-subscriptions-table th {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .client-subscriptions-table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .client-subscriptions-current-row,
html[data-theme="dark"] .client-subscriptions-current-row td {
    background: #1e3a5f !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .client-sub-addr {
    color: #94a3b8 !important;
}
/* Подписки клиента: номера журналов (бейджи №19, №20…) — читаемость в тёмной теме */
html[data-theme="dark"] .client-subscriptions-table .client-sub-journal-badge[data-status="sent"] {
    background: #14532d !important;
    color: #86efac !important;
    border-color: #166534 !important;
}
html[data-theme="dark"] .client-subscriptions-table .client-sub-journal-badge[data-status="pending"] {
    background: #422006 !important;
    color: #fcd34d !important;
    border-color: #78350f !important;
}
html[data-theme="dark"] .client-subscriptions-table .client-sub-journal-badge[data-status="cancelled"] {
    background: #7f1d1d !important;
    color: #fca5a5 !important;
    border-color: #991b1b !important;
}
html[data-theme="dark"] .client-subscriptions-table .client-sub-journal-badge[data-status="overlap"] {
    background: #7f1d1d !important;
    color: #fca5a5 !important;
    border-color: #b91c1c !important;
}
html[data-theme="dark"] .client-subscriptions-table .client-sub-journal-badge[data-status="unknown"] {
    background: #334155 !important;
    color: #94a3b8 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .archive-list-item {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .archive-list-item:hover {
    border-color: #3b82f6 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
html[data-theme="dark"] .archive-list-date,
html[data-theme="dark"] .archive-list-info {
    color: #94a3b8 !important;
}

/* ===== История изменений (карточки в модалке подписки) ===== */
html[data-theme="dark"] .sub-history-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .sub-history-card-revert {
    background: #422006 !important;
    border-color: #78350f !important;
}
html[data-theme="dark"] .sub-history-action {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .sub-history-meta {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .sub-history-card-body {
    border-color: #334155 !important;
}
html[data-theme="dark"] .sub-history-fields-title {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .sub-history-field {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .sub-history-field-label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .sub-history-field-values,
html[data-theme="dark"] .sub-history-field > div:not(.sub-history-field-label) {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .sub-history-muted {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .sub-history-arrow {
    color: #64748b !important;
}
html[data-theme="dark"] .sub-history-old {
    color: #fca5a5 !important;
}
html[data-theme="dark"] .sub-history-new {
    color: #6ee7b7 !important;
}
html[data-theme="dark"] .sub-history-fields {
    border-color: #334155 !important;
}
html[data-theme="dark"] .sub-history-shipping div[style*="color:#1565c0"] {
    color: #93c5fd !important;
}

/* ===== Модалка редактирования месяцев ===== */
html[data-theme="dark"] #editMonthsModal .info-block:not(.info-warning):not(.info-info) {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #editMonthsModal .info-block:not(.info-warning):not(.info-info) h4 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #editMonthsModal .info-block small,
html[data-theme="dark"] #editMonthsModal .info-block [style*="color: var(--ui-text-muted)"] {
    color: #b0b8c4 !important;
}
html[data-theme="dark"] #editMonthsModal .info-block.info-warning small {
    color: #fde68a !important;
}
html[data-theme="dark"] #editMonthsModal .form-group h4 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #editMonthsModal .btn-details-secondary.btn-sm {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #editMonthsModal .form-group label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #edit-months-checkboxes {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #edit-months-checkboxes p {
    color: #94a3b8 !important;
}
/* Номера журналов (№33, №34…) — читаемость в тёмной теме */
html[data-theme="dark"] #edit-months-checkboxes span[style*="color: #333"],
html[data-theme="dark"] #edit-months-checkboxes span[style*="color:#333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #edit-months-checkboxes span[style*="color: #667eea"],
html[data-theme="dark"] #edit-months-checkboxes span[style*="color:#667eea"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #edit-months-checkboxes > div > div {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #edit-months-checkboxes > div > div:has(input:checked) {
    background: rgba(59, 130, 246, 0.15) !important;
    border-color: #3b82f6 !important;
}
/* Кнопки статуса (ожидает/отправлено) — контраст иконок */
html[data-theme="dark"] #edit-months-checkboxes button[style*="#ff9800"] {
    background: rgba(251, 191, 36, 0.25) !important;
    color: #fcd34d !important;
    border-color: #f59e0b !important;
}
html[data-theme="dark"] #edit-months-checkboxes button[style*="#34a853"] {
    background: rgba(52, 211, 153, 0.2) !important;
    color: #34d399 !important;
    border-color: #10b981 !important;
}
html[data-theme="dark"] #edit-months-checkboxes button[style*="#ea4335"] {
    background: rgba(248, 113, 113, 0.25) !important;
    color: #fca5a5 !important;
    border-color: #ef4444 !important;
}
html[data-theme="dark"] #edit-months-checkboxes button[style*="#9e9e9e"] {
    background: #475569 !important;
    color: #94a3b8 !important;
    border-color: #64748b !important;
}

/* ===== Кнопки Найти / Очистить в хедере ===== */
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-outline-secondary {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-outline-secondary:hover {
    background: #475569 !important;
    border-color: #64748b !important;
    color: #f1f5f9 !important;
}
html[data-theme="dark"] .btn-details-secondary:hover {
    color: #f1f5f9 !important;
}

/* ===== Модалка переноса подписки (transfer) ===== */
html[data-theme="dark"] .transfer-modal-content {
    background: #1e293b !important;
    border: 1px solid #334155;
}
html[data-theme="dark"] .transfer-modal-content h2 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .transfer-modal-close {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .transfer-modal-close:hover {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .transfer-modal-desc {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .transfer-modal-content label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .transfer-modal-content #transfer-target-journal {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* ===== Модалка редакционной подписки ===== */
html[data-theme="dark"] #editorialSubscriptionModal .editorial-tab {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #editorialSubscriptionModal .editorial-tab.active {
    color: #e2e8f0 !important;
    border-color: #3b82f6 !important;
}
html[data-theme="dark"] #editorialSubscriptionModal [style*="background: white"],
html[data-theme="dark"] #editorialSubscriptionModal [style*="background:white"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #editorialSubscriptionModal h3[style*="color: #333"],
html[data-theme="dark"] #editorialSubscriptionModal span[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #editorialSubscriptionModal small[style*="color: #666"] {
    color: #94a3b8 !important;
}

/* ===== Модалка редакционных месяцев ===== */
html[data-theme="dark"] .editorial-month-card {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .editorial-month-title {
    color: #93c5fd !important;
}
html[data-theme="dark"] .editorial-month-section,
html[data-theme="dark"] .editorial-month-section[style*="background: rgba"] {
    background: #1e293b !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .editorial-month-section h4 {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .editorial-month-section .current-value {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .editorial-month-section .column-info {
    color: #64748b !important;
}
html[data-theme="dark"] .editorial-month-controls select {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* ===== Модалка «Поиск продлений» (#renewalSearchModal) ===== */
html[data-theme="dark"] #renewalSearchModal .modal-content {
    background: #1e293b !important;
}
html[data-theme="dark"] #renewalSearchModal [style*="background: white"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #renewalSearchModal [style*="background: #e8f5e9"] {
    background: #14532d !important;
    border-color: #166534 !important;
}
html[data-theme="dark"] #renewalSearchModal [style*="background: #e8f5e9"] strong {
    color: #86efac !important;
}
html[data-theme="dark"] #renewalSearchModal [style*="background: #e8f5e9"] span[style*="color: #666"] {
    color: #94a3b8 !important;
}
/* Карточки подписок */
html[data-theme="dark"] #renewal-search-results > div > div[style*="background: white"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #renewal-search-results [style*="background: #f8f9fa"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #renewal-search-results [style*="color: #202124"],
html[data-theme="dark"] #renewal-search-results [style*="color:#202124"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #renewal-search-results .issue-range-cell {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #renewal-search-results strong[style*="#667eea"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #renewal-search-results span[style*="background: #f0f0f0"] {
    background: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #renewal-search-results [style*="color: #34a853"] {
    color: #4ade80 !important;
}
/* Бейджи дат (mar26-feb27) — #fff3cd уже в общих правилах, но усилим для renewal */
html[data-theme="dark"] #renewal-search-results span[style*="background:#fff3cd"],
html[data-theme="dark"] #renewal-search-results span[style*="background: #fff3cd"] {
    background: #422006 !important;
    color: #fcd34d !important;
    border-color: #78350f !important;
}
/* Скроллбар области результатов */
html[data-theme="dark"] #renewal-search-results > div[style*="overflow-y"] {
    scrollbar-color: #475569 #1e293b;
}
html[data-theme="dark"] #renewal-search-results > div[style*="overflow-y"]::-webkit-scrollbar-track {
    background: #1e293b;
}
html[data-theme="dark"] #renewal-search-results > div[style*="overflow-y"]::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}
/* Пустое состояние и ошибки */
html[data-theme="dark"] #renewal-search-results [style*="background: #f8f9fa"] {
    background: #334155 !important;
}
html[data-theme="dark"] #renewal-search-results [style*="background: #fff3cd"] {
    background: #422006 !important;
    color: #fcd34d !important;
    border-color: #78350f !important;
}
html[data-theme="dark"] #renewal-search-results [style*="background: #f8d7da"] {
    background: #7f1d1d !important;
    color: #fca5a5 !important;
    border-color: #991b1b !important;
}

/* ===== Модалки duplicates, table_filters (h2 уже в .modal) ===== */
html[data-theme="dark"] #duplicates-analysis-status {
    color: #94a3b8 !important;
}
/* Бейджи номеров журналов в анализе задвоений — как в деталях подписки */
html[data-theme="dark"] .duplicates-journal-badge {
    border-color: #475569 !important;
}
html[data-theme="dark"] .duplicates-journal-badge:not(.duplicates-journal-badge-overlap) {
    background: #14532d !important;
    color: #86efac !important;
}
html[data-theme="dark"] .duplicates-journal-badge.duplicates-journal-badge-overlap {
    background: #7f1d1d !important;
    color: #fca5a5 !important;
    border-color: #b91c1c !important;
}
html[data-theme="dark"] #tableFiltersModal #filtered-count-info {
    color: #86efac !important;
}

/* ===== listsModal — детали листов отгрузок (modals.js) ===== */
html[data-theme="dark"] #listsModalContent .shipping-list-card,
html[data-theme="dark"] #listsModalContent div[style*="background: #f8f9fa"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #listsModalContent div[style*="color: #667eea"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #listsModalContent div[style*="color: #764ba2"] {
    color: #c4b5fd !important;
}
html[data-theme="dark"] #listsModalContent div[style*="background: #e8f5e9"] {
    background: #14532d !important;
    border-color: #22c55e !important;
}
html[data-theme="dark"] #listsModalContent div[style*="background: #e8f5e9"] div[style*="color: #2e7d32"] {
    color: #86efac !important;
}
html[data-theme="dark"] #listsModalContent div[style*="background: #fff3e0"] {
    background: #3d3520 !important;
    border-color: #5a4d2e !important;
}
html[data-theme="dark"] #listsModalContent div[style*="background: #fff3e0"] div[style*="color: #e65100"] {
    color: #fcd34d !important;
}

/* ===== monthsModal — статусы месяцев (modals.js) ===== */
html[data-theme="dark"] #monthsModalContent p[style*="color:#666"],
html[data-theme="dark"] #monthsModalContent p[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #monthsModalContent .month-item {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #monthsModalContent .month-sent {
    background: #14532d !important;
    color: #86efac !important;
}
html[data-theme="dark"] #monthsModalContent .month-pending {
    background: #422006 !important;
    color: #fcd34d !important;
}
html[data-theme="dark"] #monthsModalContent .month-other {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

/* ===== trackingSearchModal — поиск по трек-номеру ===== */
html[data-theme="dark"] #trackingSearchModal div[style*="background: white"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #trackingSearchModal div[style*="background: white"] p[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #trackingSearchModal #tracking-search-results {
    color: #e2e8f0;
}
html[data-theme="dark"] #trackingSearchModal #tracking-search-results div[style*="background: #f0f0f0"],
html[data-theme="dark"] #trackingSearchModal #tracking-search-results div[style*="background: #f8f9fa"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #trackingSearchModal #tracking-search-results strong[style*="color: #667eea"],
html[data-theme="dark"] #trackingSearchModal #tracking-search-results div[style*="color: #667eea"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #trackingSearchModal #tracking-search-results div[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #trackingSearchModal #tracking-search-results div[style*="color: #202124"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #trackingSearchModal #tracking-search-results div[style*="background: #f8d7da"] {
    background: #7f1d1d !important;
    color: #fca5a5 !important;
}
html[data-theme="dark"] #trackingSearchModal #tracking-search-results div[style*="background: #e8f5e9"] {
    background: #14532d !important;
    border-color: #22c55e !important;
    color: #86efac !important;
}

/* ===== editorialMonthsModal — месяцы редакционки ===== */
html[data-theme="dark"] #editorialMonthsModal .editorial-month-card {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #editorialMonthsModal .editorial-month-section {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #editorialMonthsModal .editorial-month-title {
    color: #93c5fd !important;
}
html[data-theme="dark"] #editorialMonthsModal .editorial-month-section h4 {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #editorialMonthsModal .editorial-month-section .current-value {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #editorialMonthsModal .editorial-month-section .column-info {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #editorialMonthsModal p[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #editorialMonthsModal [style*="border-top: 1px solid #ddd"] {
    border-color: #334155 !important;
}
html[data-theme="dark"] #editorialMonthsModal .editorial-month-controls select {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* ===== addSubscriptionModal — добавить подписку ===== */
/* Модалка добавления подписки — тёмная тема */
html[data-theme="dark"] .modal-add-subscription__header {
    background: #1e293b;
    border-color: #334155;
}

html[data-theme="dark"] .modal-add-subscription__title {
    color: #f1f5f9;
}

html[data-theme="dark"] .modal-add-subscription__close {
    color: #94a3b8;
}

html[data-theme="dark"] .modal-add-subscription__close:hover {
    background: #334155;
    color: #f1f5f9;
}

html[data-theme="dark"] .modal-add-subscription__footer {
    background: #1e293b;
    border-color: #334155;
}

html[data-theme="dark"] .form-section {
    background: #334155;
    border-color: #475569;
}

html[data-theme="dark"] .modal-add-subscription .form-section--accordion .form-section__header {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
}

html[data-theme="dark"] .modal-add-subscription .form-section--accordion .form-section__header:hover {
    background: #475569;
}

html[data-theme="dark"] .form-section__title {
    color: #f1f5f9;
    border-color: #475569;
}

html[data-theme="dark"] .form-label {
    color: #94a3b8;
}

html[data-theme="dark"] .form-quick-months,
html[data-theme="dark"] .form-months-grid {
    background: #334155;
    border-color: #475569;
}

html[data-theme="dark"] .form-months-grid__placeholder {
    color: #64748b;
}

html[data-theme="dark"] .form-months-grid__error {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}

/* Чекбоксы месяцев */
html[data-theme="dark"] .form-month-label {
    background: #334155 !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] .form-month-label span {
    color: #f1f5f9 !important;
}

html[data-theme="dark"] #addSubscriptionModal label[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #addSubscriptionModal #add-months-checkboxes,
html[data-theme="dark"] #addSubscriptionModal div[style*="background: #f8f9fa"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #addSubscriptionModal #add-months-checkboxes div[style*="color: #999"] {
    color: #94a3b8 !important;
}

/* ===== exportSettingsModal — настройки экспорта ===== */
html[data-theme="dark"] #exportSettingsModal h2[style*="color: #333"] {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* ===== Общие светлые фоны (admin, notifications, emails и др.) ===== */
/* Жёлтые предупреждения #fff3cd (Bootstrap warning) — admin, renewal-search, tracking-search и др. */
html[data-theme="dark"] [style*="background: #fff3cd"],
html[data-theme="dark"] [style*="background:#fff3cd"] {
    background: #3d3520 !important;
    border-color: #5a4d2e !important;
    color: #fcd34d !important;
}
html[data-theme="dark"] [style*="background: #fff3cd"] [style*="color: #999"],
html[data-theme="dark"] [style*="background:#fff3cd"] [style*="color:#999"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] [style*="color: #856404"],
html[data-theme="dark"] [style*="color:#856404"] {
    color: #fcd34d !important;
}
/* Бейджи месяцев (background:#fff3cd, color:#000) — index, renewal-search, smart-table */
html[data-theme="dark"] span[style*="background:#fff3cd"],
html[data-theme="dark"] span[style*="background: #fff3cd"] {
    background: #3d3520 !important;
    color: #fcd34d !important;
    border-color: #5a4d2e !important;
}
html[data-theme="dark"] [style*="background: #fff3e0"],
html[data-theme="dark"] [style*="background:#fff3e0"],
html[data-theme="dark"] [style*="background: #e8f5e9"],
html[data-theme="dark"] [style*="background:#e8f5e9"],
html[data-theme="dark"] [style*="background: #e3f2fd"],
html[data-theme="dark"] [style*="background:#e3f2fd"],
html[data-theme="dark"] [style*="background: #f8f9fa"],
html[data-theme="dark"] [style*="background:#f8f9fa"],
html[data-theme="dark"] [style*="background: #fafafa"],
html[data-theme="dark"] [style*="background:#fafafa"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .shipping-list-card {
    background: #334155 !important;
    border-color: #475569 !important;
}
/* Контейнеры с background: white / #fff */
html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"] {
    background: #334155 !important;
}
/* Кнопки и code с фоном в модалках (list-item) */
html[data-theme="dark"] .list-item button[style*="background:#fff"],
html[data-theme="dark"] .list-item code[style*="background:#f1f5f9"] {
    background: #475569 !important;
    border-color: #64748b !important;
    color: #e2e8f0 !important;
}

/* ===== Данные в полях редактирования (field-input) ===== */
html[data-theme="dark"] [id^="field-input-"] {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* ===== Селект в модалках ===== */
html[data-theme="dark"] .modal-content select {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* Страница входа (login) */
html[data-theme="dark"] .login-container {
    background: rgba(30, 41, 59, 0.95) !important;
    border: 1px solid #334155;
}
html[data-theme="dark"] .login-header .subtitle {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .login-container .form-group label {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .login-container input {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .login-container input::placeholder {
    color: #64748b !important;
}

/* Страница профиля */
html[data-theme="dark"] .profile-page {
    background: #1e293b;
    border-color: #334155;
}

/* ===== Аналитика: marketing.html, delivery_analytics.html ===== */
html[data-theme="dark"] .main-marketing-content,
html[data-theme="dark"] .marketing-container {
    background: #0f172a !important;
}
html[data-theme="dark"] .marketing-container h2[style*="color: #333"],
html[data-theme="dark"] .marketing-container h3[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .marketing-container p[style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .marketing-tabs {
    border-bottom-color: #334155 !important;
}
html[data-theme="dark"] .marketing-tab {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .marketing-tab:hover,
html[data-theme="dark"] .marketing-tab.active {
    color: #60a5fa !important;
    border-bottom-color: #60a5fa !important;
}
html[data-theme="dark"] .kpi-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .kpi-card-title {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .kpi-card-value {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .marketing-table,
html[data-theme="dark"] .analytics-table {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .marketing-table th,
html[data-theme="dark"] .analytics-table th {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .marketing-table td,
html[data-theme="dark"] .analytics-table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
/* delivery_analytics.html */
html[data-theme="dark"] .analytics-header {
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
html[data-theme="dark"] .filters-bar {
    border-bottom-color: #334155 !important;
}
html[data-theme="dark"] .filters-bar label,
html[data-theme="dark"] .filters-bar .filter-group {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .chart-container,
html[data-theme="dark"] .analytics-chart {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .stat-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .stat-card.success {
    background: linear-gradient(135deg, #065f46 0%, #047857 100%) !important;
}
html[data-theme="dark"] .stat-card.warning {
    background: linear-gradient(135deg, #92400e 0%, #b45309 100%) !important;
}
html[data-theme="dark"] .stat-card.error {
    background: linear-gradient(135deg, #991b1b 0%, #b91c1c 100%) !important;
}
/* Конверсии: Детальная статистика по журналам (.stats-card) */
html[data-theme="dark"] .stats-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .stats-card h3 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .stats-label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .stats-value {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .stats-item {
    border-color: #334155 !important;
}
html[data-theme="dark"] .stat-label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .stat-value {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .stat-subtext {
    color: #64748b !important;
}
html[data-theme="dark"] .filter-label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .journal-breakdown {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .journal-table th {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .journal-table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* Маркетинг: таблицы .data-table, загрузка, читаемость */
html[data-theme="dark"] .marketing-container .data-table,
html[data-theme="dark"] .chart-container .data-table {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .marketing-container .data-table thead,
html[data-theme="dark"] .chart-container .data-table thead {
    background: #334155 !important;
}
html[data-theme="dark"] .marketing-container .data-table th,
html[data-theme="dark"] .chart-container .data-table th {
    color: #e2e8f0 !important;
    border-color: #475569 !important;
    font-weight: 600 !important;
}
html[data-theme="dark"] .marketing-container .data-table tbody tr,
html[data-theme="dark"] .chart-container .data-table tbody tr {
    border-color: #334155 !important;
}
html[data-theme="dark"] .marketing-container .data-table tbody tr:nth-child(even) {
    background: #334155 !important;
}
html[data-theme="dark"] .marketing-container .data-table tbody tr:nth-child(odd) {
    background: #1e293b !important;
}
html[data-theme="dark"] .marketing-container .data-table tbody tr:hover,
html[data-theme="dark"] .chart-container .data-table tbody tr:hover {
    background: #475569 !important;
}
html[data-theme="dark"] .marketing-container .data-table td,
html[data-theme="dark"] .chart-container .data-table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* Дашборд: карточка «Архивные заказы» — при dark theme фон становится #1e293b, текст #1a1a1a нечитаем */
html[data-theme="dark"] .kpi-card [style*="color: #1a1a1a"],
html[data-theme="dark"] .kpi-card [style*="color:#1a1a1a"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .kpi-card [style*="color: #333"][style*="text-shadow"] {
    color: #94a3b8 !important;
}

/* География: tfoot таблицы */
html[data-theme="dark"] .marketing-container tfoot tr[style*="background: #f8f9fa"],
html[data-theme="dark"] .chart-container tfoot tr[style*="background: #f8f9fa"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .marketing-container tfoot td[style*="color: #667eea"],
html[data-theme="dark"] .chart-container tfoot td[style*="color: #667eea"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] .marketing-container tfoot td[style*="color: #28a745"],
html[data-theme="dark"] .chart-container tfoot td[style*="color: #28a745"] {
    color: #86efac !important;
}

/* Отправки по месяцам — блоки и числа */
html[data-theme="dark"] #tab-shipping-month div[style*="background: #f8f9fa"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tab-shipping-month div[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tab-shipping-month div[style*="color: #667eea"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #tab-shipping-month td[style*="color: #667eea"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #tab-shipping-month td[style*="color: #28a745"] {
    color: #86efac !important;
}
html[data-theme="dark"] #tab-shipping-month td[style*="color: #ffc107"] {
    color: #fcd34d !important;
}

/* Аналитика трекинга — карточки операций, блоки времени */
html[data-theme="dark"] #tab-tracking-analytics div[style*="background: #f5f5f5"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tab-tracking-analytics div[style*="color: #2196f3"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #tab-tracking-analytics div[style*="background: #e3f2fd"] {
    background: #1e3a5f !important;
    border-color: #2563eb !important;
}
html[data-theme="dark"] #tab-tracking-analytics div[style*="background: #e3f2fd"] span[style*="color: #1976d2"],
html[data-theme="dark"] #tab-tracking-analytics div[style*="background: #e3f2fd"] span[style*="color: #2196f3"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #tab-tracking-analytics div[style*="background: #fff3e0"] {
    background: #422006 !important;
    border-color: #78350f !important;
}
html[data-theme="dark"] #tab-tracking-analytics div[style*="background: #fff3e0"] span[style*="color: #e65100"],
html[data-theme="dark"] #tab-tracking-analytics div[style*="background: #fff3e0"] span[style*="color: #ff9800"] {
    color: #fcd34d !important;
}
html[data-theme="dark"] #tab-tracking-analytics h3[style*="color: #333"],
html[data-theme="dark"] #tab-tracking-analytics h4[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tab-tracking-analytics div[style*="color: #333"] {
    color: #e2e8f0 !important;
}

/* Подписки на исходе — info-block подсказки (#d1ecf1, #0c5460) */
html[data-theme="dark"] .marketing-container [style*="background: #d1ecf1"],
html[data-theme="dark"] .marketing-container [style*="background:#d1ecf1"] {
    background: #0e7490 !important;
    border-color: #0891b2 !important;
    color: #e2e8f0 !important;
}

/* Подписки на исходе — Клиенты с несколькими подписками: читаемость email, телефона, бейджей */
html[data-theme="dark"] #tab-expiring td[style*="linear-gradient"][style*="#f0f4ff"],
html[data-theme="dark"] #tab-expiring td[style*="linear-gradient"][style*="#ffffff"] {
    background: #334155 !important;
    box-shadow: inset 3px 0 0 #475569, inset -3px 0 0 #475569 !important;
}
html[data-theme="dark"] #tab-expiring strong[style*="color: #667eea"],
html[data-theme="dark"] #tab-expiring td strong[style*="#667eea"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #tab-expiring small[style*="background: #667eea"] {
    background: #1e3a5f !important;
    color: #93c5fd !important;
}
html[data-theme="dark"] #tab-expiring .data-table td {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tab-expiring h3[style*="color: #555"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .marketing-container .chart-title,
html[data-theme="dark"] .chart-container .chart-title {
    color: #e2e8f0 !important;
    font-weight: 600 !important;
}
html[data-theme="dark"] .marketing-container .loading-initial,
html[data-theme="dark"] .loading-initial {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #94a3b8 !important;
}
html[data-theme="dark"] .marketing-container .loading-initial [style*="color: #666"],
html[data-theme="dark"] .loading-initial [style*="color:#666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .filters-bar input,
html[data-theme="dark"] .filters-bar select {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .filters-bar input::placeholder {
    color: #64748b !important;
}
/* Маркетинг: хедер — убрать яркий gradient, сделать лаконичным в тёмной теме */
html[data-theme="dark"] .marketing-header {
    background: #1e293b !important;
    border: 1px solid #334155 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}
html[data-theme="dark"] .marketing-header h1 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .marketing-header p {
    color: #94a3b8 !important;
}
/* Маркетинг: селекты в фильтрах (border: 2px solid #e8ecf3) */
html[data-theme="dark"] .filters-bar select[style*="#e8ecf3"],
html[data-theme="dark"] .filters-bar input[style*="#e8ecf3"] {
    border-color: #475569 !important;
}
html[data-theme="dark"] .marketing-container .loading-atom-text {
    color: #93c5fd !important;
}
/* Сайдбар: блок пользователя */
html[data-theme="dark"] .user-info-card [style*="rgba(255,255,255,0.7)"],
html[data-theme="dark"] .user-info-card [style*="rgba(255,255,255,0.6)"] {
    color: #94a3b8 !important;
}

/* Маркетинг: возвращенные отправления — динамический контент */
html[data-theme="dark"] #returned-shipments-report {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #returned-shipments-report [style*="background: white"],
html[data-theme="dark"] #returned-shipments-report [style*="background:white"] {
    background: #334155 !important;
    border-left-color: inherit !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}
html[data-theme="dark"] #returned-shipments-report [style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #returned-shipments-report [style*="color: #999"] {
    color: #64748b !important;
}
html[data-theme="dark"] #returned-shipments-report .data-table,
html[data-theme="dark"] #returned-shipments-report table {
    background: #1e293b !important;
}
html[data-theme="dark"] #returned-shipments-report table thead tr {
    background: #334155 !important;
}
html[data-theme="dark"] #returned-shipments-report table th {
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #returned-shipments-report table tbody tr {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #returned-shipments-report table tbody tr:nth-child(even) {
    background: #334155 !important;
}
html[data-theme="dark"] #returned-shipments-report table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #returned-shipments-report table tbody tr:hover {
    background: #475569 !important;
}
html[data-theme="dark"] #returned-shipments-report h2[style*="color: #333"],
html[data-theme="dark"] #tab-returned-shipments-report h2[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tab-returned-shipments-report p[style*="color: #666"] {
    color: #94a3b8 !important;
}

/* Сегменты: блоки с #f9f9f9 */
html[data-theme="dark"] #tab-segments [style*="background: #f9f9f9"],
html[data-theme="dark"] #tab-segments [style*="background:#f9f9f9"],
html[data-theme="dark"] #tab-segments [style*="background: #f5f5f5"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #tab-segments h3[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tab-segments p[style*="color: #666"] {
    color: #94a3b8 !important;
}

/* ===== Админка: admin.html — расширенные переопределения ===== */
html[data-theme="dark"] .admin-page,
html[data-theme="dark"] body.admin-page {
    background: var(--admin-bg) !important;
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .admin-container {
    background: var(--admin-bg) !important;
}
html[data-theme="dark"] .admin-header h1 {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .admin-header h1::before {
    background: #60a5fa;
}
html[data-theme="dark"] .tab-content {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .db-card,
html[data-theme="dark"] .admin-card {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
html[data-theme="dark"] .db-card:hover,
html[data-theme="dark"] .admin-card:hover {
    border-color: var(--admin-border-dark) !important;
}
html[data-theme="dark"] .db-card h3,
html[data-theme="dark"] .admin-card h3 {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .db-card h4,
html[data-theme="dark"] .admin-card h4,
html[data-theme="dark"] .tab-content h4 {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .db-card > p,
html[data-theme="dark"] .admin-card > p {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .admin-card-list-item {
    background: var(--admin-bg-secondary) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .admin-card-list-item:hover {
    background: var(--admin-surface-hover) !important;
}
html[data-theme="dark"] .admin-card-list-item * {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .loading {
    color: #94a3b8 !important;
}
/* Админка: поля db-info (ID базы, Путь, и т.д.) */
html[data-theme="dark"] .db-info-label {
    color: var(--admin-text-muted) !important;
}
html[data-theme="dark"] .db-info-item > div:last-child,
html[data-theme="dark"] .db-info-value {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .db-actions-group h4 {
    color: var(--admin-text-secondary) !important;
    border-bottom-color: var(--admin-border) !important;
}
html[data-theme="dark"] .db-actions-group,
html[data-theme="dark"] .db-actions-details {
    background: var(--admin-bg-secondary) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .db-actions-details summary {
    color: var(--admin-text-secondary) !important;
    border-bottom-color: var(--admin-border) !important;
}
html[data-theme="dark"] .db-actions-details summary:hover {
    color: #60a5fa !important;
}
html[data-theme="dark"] .db-tech-details {
    background: var(--admin-bg-secondary) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .db-tech-details summary {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .db-tech-details summary:hover {
    color: #60a5fa !important;
}
html[data-theme="dark"] .db-tech-value {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .btn-icon {
    background: var(--admin-surface-hover) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .btn-icon:hover {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #fff !important;
}
html[data-theme="dark"] .user-card {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .user-card:hover {
    border-color: var(--admin-border-dark) !important;
    background: var(--admin-surface-hover) !important;
}
html[data-theme="dark"] .user-card-name {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .user-card-email {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .user-card-date {
    color: var(--admin-text-muted) !important;
}
/* Админка: бейджи статуса (Файл существует и т.д.) */
html[data-theme="dark"] .status-badge.status-success {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #34d399 !important;
    border-color: rgba(16, 185, 129, 0.35) !important;
}
html[data-theme="dark"] .status-badge.status-error {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #f87171 !important;
    border-color: rgba(239, 68, 68, 0.35) !important;
}
html[data-theme="dark"] .status-badge.status-info {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #60a5fa !important;
    border-color: rgba(59, 130, 246, 0.35) !important;
}
/* Админка: фильтры истории, утилит, логов */
html[data-theme="dark"] .admin-filter-grid,
html[data-theme="dark"] .admin-history-filters {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .admin-history-filters select,
html[data-theme="dark"] .admin-history-filters input[type="text"],
html[data-theme="dark"] .admin-history-filters input[type="date"] {
    background: var(--admin-bg-secondary) !important;
    border-color: var(--admin-border) !important;
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .admin-history-filters select option {
    background: var(--admin-surface);
    color: var(--admin-text);
}
html[data-theme="dark"] .admin-history-filters label,
html[data-theme="dark"] .admin-filter-grid label {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .admin-history-table-wrap {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .admin-history-table thead,
html[data-theme="dark"] .admin-history-table thead tr {
    background: var(--admin-bg-secondary) !important;
}
html[data-theme="dark"] .admin-history-table th {
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .admin-history-table td {
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .admin-history-table tbody tr:hover {
    background: var(--admin-surface-hover) !important;
}
html[data-theme="dark"] .admin-history-section .db-card > p {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .admin-history-empty {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .admin-history-pagination {
    color: var(--admin-text-secondary);
}
html[data-theme="dark"] .admin-history-pagination a,
html[data-theme="dark"] .admin-history-pagination button {
    color: var(--admin-text) !important;
}

/* ===== Модалка «Детали изменения» — читаемость ===== */
html[data-theme="dark"] #history-details-modal .modal-content {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] #history-details-modal .modal-content h3 {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] #history-details-modal [style*="color: var(--admin-text-muted)"],
html[data-theme="dark"] #history-details-modal span[style*="admin-text-muted"] {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] #history-details-modal .modal-content > div[style*="grid-template-columns"] div {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] #history-details-modal [style*="color: var(--admin-text-secondary)"],
html[data-theme="dark"] #history-details-modal h4[style*="admin-text-secondary"] {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] #history-details-modal .modal-content > div[style*="grid-template-columns"] {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] #history-details-modal .modal-content > div[style*="grid-template-columns"] > div {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] #history-details-modal td[style*="color: #666"] {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] #history-details-modal td[style*="color: #d32f2f"] {
    color: #fca5a5 !important;
}
html[data-theme="dark"] #history-details-modal td[style*="color: #2e7d32"] {
    color: #6ee7b7 !important;
}
html[data-theme="dark"] .admin-action-badge {
    box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}

/* Предпросмотр шаблона — тёмная тема */
html[data-theme="dark"] .template-preview-modal .modal-content {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .template-preview-modal .template-preview-content h2 {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .template-preview-modal .template-preview-section h4 {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .template-preview-modal .template-preview-subject {
    background: var(--admin-bg-secondary) !important;
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .template-preview-modal .template-preview-html {
    border-color: var(--admin-border) !important;
    background: #fff !important;
}
html[data-theme="dark"] .template-preview-modal .template-preview-text {
    background: var(--admin-bg-secondary) !important;
    color: var(--admin-text) !important;
}

/* Предпросмотр шаблона на /notifications — текстовая версия читаема в тёмной теме */
.preview-text-content {
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 20px;
    border-radius: 4px;
}
html[data-theme="dark"] .preview-text-content {
    background: #ffffff !important;
    color: #1a1a1a !important;
    border: 1px solid #ddd !important;
}
html[data-theme="dark"] .preview-text-tab {
    background: #f5f5f5 !important;
    border-color: #ddd !important;
}

/* Редактирование шаблона на /notifications — тёмная тема модалки */
html[data-theme="dark"] #edit-template-modal > div {
    background: #1e293b !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #edit-template-modal input,
html[data-theme="dark"] #edit-template-modal textarea {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #f1f5f9 !important;
}
html[data-theme="dark"] #edit-template-modal input::placeholder,
html[data-theme="dark"] #edit-template-modal textarea::placeholder {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #edit-template-modal label {
    color: #e2e8f0 !important;
}

/* Редактирование шаблона — тёмная тема */
html[data-theme="dark"] .template-edit-modal .modal-content {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .template-edit-modal .modal-content h2 {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .template-edit-modal .form-group label {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .template-edit-modal .template-input {
    background: var(--admin-bg-secondary) !important;
    border-color: var(--admin-border) !important;
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .template-edit-modal .template-input::placeholder {
    color: var(--admin-text-muted) !important;
}
html[data-theme="dark"] .template-edit-modal select.template-input option {
    background: var(--admin-surface);
    color: var(--admin-text);
}
html[data-theme="dark"] .template-edit-modal .template-hint {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .template-edit-modal .template-vars-block {
    background: var(--admin-bg-secondary) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .template-edit-modal .template-vars-label {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .template-edit-modal .template-var-item {
    border-bottom-color: var(--admin-border) !important;
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .template-edit-modal .template-var-code {
    background: var(--admin-surface) !important;
    border-color: var(--admin-border) !important;
    color: #60a5fa !important;
}

/* ===== История изменений: групповые строки, «Развернуть» ===== */
html[data-theme="dark"] .admin-history-group {
    background: var(--admin-bg-secondary) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .admin-history-group-header {
    background: transparent !important;
}
html[data-theme="dark"] .admin-history-group-header:hover {
    background: var(--admin-surface-hover) !important;
}
html[data-theme="dark"] .admin-history-group-info {
    color: var(--admin-text) !important;
}
html[data-theme="dark"] .admin-history-group-meta {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .admin-history-group-toggle {
    color: #60a5fa !important;
}
html[data-theme="dark"] .admin-history-group-body {
    border-top-color: var(--admin-border) !important;
}
html[data-theme="dark"] .admin-history-group-table {
    background: var(--admin-surface) !important;
}
html[data-theme="dark"] .admin-history-group-table td {
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}
html[data-theme="dark"] .admin-history-group-table tbody tr:hover td {
    background: var(--admin-surface-hover) !important;
}
html[data-theme="dark"] .admin-history-table [style*="color: var(--admin-text-muted)"] {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .admin-changes-summary {
    color: var(--admin-text-secondary) !important;
}
html[data-theme="dark"] .admin-changes-details-btn {
    color: #93c5fd !important;
    background: rgba(96, 165, 250, 0.25) !important;
    border-color: rgba(96, 165, 250, 0.5) !important;
}
html[data-theme="dark"] .admin-changes-details-btn:hover {
    background: rgba(96, 165, 250, 0.35) !important;
    border-color: #60a5fa !important;
    color: #bfdbfe !important;
}
html[data-theme="dark"] .admin-history-order-link {
    color: #60a5fa !important;
    text-decoration: underline;
    text-underline-offset: 2px;
}
html[data-theme="dark"] .admin-history-order-link:hover {
    color: #93c5fd !important;
    text-decoration: underline;
}

/* Админка: вкладки Утилиты, Логи, Уведомления — блоки с #f9f9f9, #f5f5f5 */
html[data-theme="dark"] [style*="background: #f9f9f9"],
html[data-theme="dark"] [style*="background:#f9f9f9"],
html[data-theme="dark"] [style*="background: #f5f5f5"],
html[data-theme="dark"] [style*="background:#f5f5f5"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}

/* ===== Админка: Статистика по журналам (трекинг) — читаемость ===== */
html[data-theme="dark"] #tracking-stats-by-journal [style*="background: white"],
html[data-theme="dark"] #tracking-stats-by-journal [style*="background:white"] {
    background: #1e293b !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tracking-stats-by-journal h5,
html[data-theme="dark"] #tracking-stats-by-journal [style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tracking-stats-by-journal [style*="color: #666"] {
    color: #94a3b8 !important;
}
/* Синий текст на тёмном — светлее */
html[data-theme="dark"] #tracking-stats-by-journal [style*="color: #2196f3"],
html[data-theme="dark"] #tracking-stats-by-journal [style*="color: #1976d2"],
html[data-theme="dark"] #tracking-stats-by-journal [style*="color: #9c27b0"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #tracking-stats-by-journal [style*="color: #4caf50"],
html[data-theme="dark"] #tracking-stats-by-journal [style*="color: #2e7d32"] {
    color: #6ee7b7 !important;
}
html[data-theme="dark"] #tracking-stats-by-journal [style*="color: #e65100"],
html[data-theme="dark"] #tracking-stats-by-journal [style*="color: #ff9800"] {
    color: #fdba74 !important;
}
html[data-theme="dark"] #tracking-stats-by-journal [style*="color: #c2185b"] {
    color: #f9a8d4 !important;
}
html[data-theme="dark"] #tracking-stats-by-journal [style*="background: #f5f5f5"],
html[data-theme="dark"] #tracking-stats-by-journal [style*="background:#f5f5f5"] {
    background: #334155 !important;
    border-color: #475569 !important;
}

/* ===== Админка: Настройки — Модуль «Почта» ===== */
html[data-theme="dark"] #tab-settings [style*="background: #f5f5f5"],
html[data-theme="dark"] #tab-settings [style*="background:#f5f5f5"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tab-settings [style*="color: #666"],
html[data-theme="dark"] #tab-settings [style*="color:#666"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tab-settings h4 {
    color: #e2e8f0 !important;
}

/* ===== Админка: SMS — таблица логов ===== */
html[data-theme="dark"] #sms-messages-list table {
    background: #1e293b !important;
}
html[data-theme="dark"] #sms-messages-list table thead,
html[data-theme="dark"] #sms-messages-list table thead tr {
    background: #334155 !important;
}
html[data-theme="dark"] #sms-messages-list table th {
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #sms-messages-list table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #sms-messages-list table tbody tr:hover td {
    background: #334155 !important;
}

/* ===== Админка: SMS — карточки статистики (#sms-stats) ===== */
html[data-theme="dark"] #sms-stats > div {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #sms-stats div[style*="color: #666"],
html[data-theme="dark"] #sms-stats div[style*="color:#666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #sms-stats div[style*="color: #1976d2"],
html[data-theme="dark"] #sms-stats div[style*="color:#1976d2"] {
    color: #93c5fd !important;
}
html[data-theme="dark"] #sms-stats div[style*="color: #7b1fa2"],
html[data-theme="dark"] #sms-stats div[style*="color:#7b1fa2"] {
    color: #c4b5fd !important;
}
html[data-theme="dark"] #sms-stats div[style*="color: #2e7d32"],
html[data-theme="dark"] #sms-stats div[style*="color:#2e7d32"] {
    color: #6ee7b7 !important;
}
html[data-theme="dark"] #sms-stats div[style*="color: #e65100"],
html[data-theme="dark"] #sms-stats div[style*="color:#e65100"] {
    color: #fdba74 !important;
}
html[data-theme="dark"] #sms-stats div[style*="color: #c2185b"],
html[data-theme="dark"] #sms-stats div[style*="color:#c2185b"] {
    color: #f9a8d4 !important;
}
html[data-theme="dark"] #sms-stats div[style*="color: #00695c"],
html[data-theme="dark"] #sms-stats div[style*="color:#00695c"] {
    color: #5eead4 !important;
}
html[data-theme="dark"] #sms-stats div[style*="color: #558b2f"],
html[data-theme="dark"] #sms-stats div[style*="color:#558b2f"] {
    color: #86efac !important;
}

/* ===== Админка: Билеты для обработки — таблица ===== */
html[data-theme="dark"] #tracking-tickets-list table {
    background: #1e293b !important;
}
html[data-theme="dark"] #tracking-tickets-list table thead,
html[data-theme="dark"] #tracking-tickets-list table thead tr {
    background: #334155 !important;
}
html[data-theme="dark"] #tracking-tickets-list table th {
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tracking-tickets-list table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #tracking-tickets-list table td[style*="color: #333"],
html[data-theme="dark"] #tracking-tickets-list table td[style*="color:#333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tracking-tickets-list table td[style*="color: #666"],
html[data-theme="dark"] #tracking-tickets-list table td[style*="color:#666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #tracking-tickets-list [style*="background: #f5f5f5"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tracking-tickets-list [style*="color: #333"] {
    color: #e2e8f0 !important;
}

/* ===== Админка: Логи сервера — фильтры, статистика ===== */
html[data-theme="dark"] #logs-stats {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tab-logs [style*="background: #f5f5f5"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #tab-logs h4[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #logs-container {
    color: #d4d4d4 !important;
}
html[data-theme="dark"] #logs-container [style*="color: #6e7681"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] [style*="background: #f9f9f9"] h4,
html[data-theme="dark"] [style*="background: #f5f5f5"] h4 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] [style*="background: #f9f9f9"] p,
html[data-theme="dark"] [style*="background: #f5f5f5"] p {
    color: #94a3b8 !important;
}

/* ===== Почта: emails.html ===== */
html[data-theme="dark"] .emails-container {
    background: #0f172a !important;
}
html[data-theme="dark"] .filters-section {
    background: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}
html[data-theme="dark"] .filters-section .filter-group label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .emails-table {
    background: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}
html[data-theme="dark"] .emails-table th {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .emails-table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .emails-table tr:hover td {
    background: #334155 !important;
}

/* ===== Уведомления: notifications_new.html ===== */
html[data-theme="dark"] .email-client-container {
    background: #0f172a !important;
}
html[data-theme="dark"] .email-client-header {
    background: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3) !important;
}
html[data-theme="dark"] .notifications-control {
    background: #334155 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .notifications-list,
html[data-theme="dark"] .email-client-content {
    background: #0f172a !important;
}
html[data-theme="dark"] .email-client-content h2,
html[data-theme="dark"] .email-client-content h3 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .notification-item,
html[data-theme="dark"] .email-list-item {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .notification-item:hover,
html[data-theme="dark"] .email-list-item:hover {
    background: #334155 !important;
}
html[data-theme="dark"] .email-client-tabs {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .email-sidebar {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .email-filters {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .email-tab {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .email-tab:hover,
html[data-theme="dark"] .email-tab.active {
    color: #60a5fa !important;
}
html[data-theme="dark"] #notifications-list {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #notifications-list[style*="background: white"] {
    background: #1e293b !important;
}
html[data-theme="dark"] #notifications-list table thead,
html[data-theme="dark"] #notifications-list table thead tr {
    background: #334155 !important;
}
html[data-theme="dark"] #notifications-list table th {
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #notifications-list table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #notifications-list table tbody tr:hover td {
    background: #334155 !important;
}
/* Уведомления: инфо-блок, фильтры, пагинация */
html[data-theme="dark"] [style*="background: #f0f4ff"],
html[data-theme="dark"] [style*="background:#f0f4ff"] {
    background: #1e2d3d !important;
    border-color: #2d4560 !important;
}
html[data-theme="dark"] [style*="background: #f0f4ff"] p,
html[data-theme="dark"] [style*="background:#f0f4ff"] p {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] [style*="background: #f9f9f9"],
html[data-theme="dark"] [style*="background:#f9f9f9"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #tab-notifications label,
html[data-theme="dark"] #tab-unsubscribes label {
    color: #94a3b8 !important;
}
/* Админка: карточки шаблонов уведомлений */
html[data-theme="dark"] #notification-templates-list [style*="background: white"] {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #notification-templates-list h4[style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #notification-templates-list [style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #notification-templates-list [style*="color: #999"] {
    color: #64748b !important;
}
html[data-theme="dark"] #notification-templates-list [style*="background: #e3f2fd"] {
    background: #1e3a5f !important;
    color: #93c5fd !important;
}
html[data-theme="dark"] .email-tab.active {
    background: #334155 !important;
    color: #60a5fa !important;
}
html[data-theme="dark"] #notifications-search-input,
html[data-theme="dark"] #notifications-filter-type,
html[data-theme="dark"] #notifications-filter-status,
html[data-theme="dark"] #unsubscribe-filter-email {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #notifications-pagination {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .badge-type {
    background: #1e2d3d !important;
    color: #93c5fd !important;
}
html[data-theme="dark"] .badge-status {
    background: #1e3d2e !important;
    color: #6ee7b7 !important;
}
html[data-theme="dark"] .badge-failed {
    background: #3d1e1e !important;
    color: #f87171 !important;
}
html[data-theme="dark"] .email-viewer {
    background: #0f172a !important;
}
html[data-theme="dark"] .email-viewer-subject,
html[data-theme="dark"] .email-viewer-header {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .email-viewer-meta {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .email-viewer-body {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .accordion {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .accordion-header {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .accordion-body p {
    color: #94a3b8 !important;
}

/* Уведомления: карточки «По типам уведомлений» — читаемость в тёмной теме */
html[data-theme="dark"] .stats-type-card,
html[data-theme="dark"] #stats-by-type > div {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] .stats-type-title,
html[data-theme="dark"] #stats-by-type [style*="color: #333"],
html[data-theme="dark"] #stats-by-type [style*="color:#333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .stats-type-hint,
html[data-theme="dark"] #stats-by-type [style*="color: #999"],
html[data-theme="dark"] #stats-by-type [style*="color:#999"] {
    color: #94a3b8 !important;
}

/* Уведомления: вкладка Статистика */
html[data-theme="dark"] #tab-stats [style*="background: white"] {
    background: #334155 !important;
    border-color: #475569 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}
html[data-theme="dark"] #stats-tab-sent {
    background: #2563eb !important;
    color: white !important;
}
html[data-theme="dark"] #stats-tab-pending {
    background: #475569 !important;
    color: #94a3b8 !important;
}
html[data-theme="dark"] #stats-tab-pending.active,
html[data-theme="dark"] #stats-tab-sent.active {
    background: #334155 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tab-stats [style*="border-bottom: 2px solid #e0e0e0"] {
    border-bottom-color: #334155 !important;
}
html[data-theme="dark"] #recipients-sent-section,
html[data-theme="dark"] #recipients-pending-section {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #recipients-sent-section h3,
html[data-theme="dark"] #recipients-pending-section h3 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #recipients-list table,
html[data-theme="dark"] #pending-recipients-list table {
    background: #1e293b !important;
}
html[data-theme="dark"] #recipients-list table thead,
html[data-theme="dark"] #pending-recipients-list table thead {
    background: #334155 !important;
}
html[data-theme="dark"] #recipients-list table th,
html[data-theme="dark"] #pending-recipients-list table th {
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #recipients-list table td,
html[data-theme="dark"] #pending-recipients-list table td {
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #unsubscribes-list {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #unsubscribes-list table thead {
    background: #334155 !important;
}
html[data-theme="dark"] #unsubscribes-list table th {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #unsubscribes-list table td {
    color: #e2e8f0 !important;
}
/* Отписки: карточки статистики и placeholder */
html[data-theme="dark"] #unsubscribes-stats > div {
    background: #334155 !important;
    border-color: #475569 !important;
}
html[data-theme="dark"] #unsubscribes-stats [style*="color: #333"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #unsubscribes-stats [style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #unsubscribes-list [style*="color: #666"] {
    color: #94a3b8 !important;
}
html[data-theme="dark"] #unsubscribe-filter-email::placeholder {
    color: #64748b !important;
}
html[data-theme="dark"] #unsubscribe-filter-status {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] #tab-unsubscribes [style*="background: #f9f9f9"] {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] #tab-templates .accordion-body p[style*="color: #666"] {
    color: #94a3b8 !important;
}

/* email_settings.html */
html[data-theme="dark"] .settings-wrapper,
html[data-theme="dark"] body:has(.settings-wrapper) {
    background: #0f172a !important;
}
html[data-theme="dark"] .settings-main {
    background: #0f172a !important;
}
html[data-theme="dark"] .settings-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .page-header h1 {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .mailbox-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .mailbox-card:hover {
    background: #334155 !important;
}
html[data-theme="dark"] .mailbox-card h3,
html[data-theme="dark"] .mailbox-card .mailbox-name {
    color: #e2e8f0 !important;
}

/* ===== Webmail: webmail.html ===== */
html[data-theme="dark"] .webmail-app {
    background: #0f172a !important;
}
html[data-theme="dark"] .webmail-main {
    background: #1e293b !important;
}
html[data-theme="dark"] .webmail-toolbar {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .toolbar-search input {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .toolbar-search input:focus {
    background: #334155 !important;
    border-color: #3b82f6 !important;
}
html[data-theme="dark"] .toolbar-menu-btn {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .toolbar-menu-btn:hover {
    background: rgba(255,255,255,0.1) !important;
}
html[data-theme="dark"] .webmail-sidebar {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .email-list-pane,
html[data-theme="dark"] .webmail-list {
    background: #1e293b !important;
}
html[data-theme="dark"] .email-detail-pane,
html[data-theme="dark"] .webmail-detail {
    background: #0f172a !important;
}
html[data-theme="dark"] .email-list-item {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .email-list-item:hover {
    background: #334155 !important;
}
html[data-theme="dark"] .webmail-content {
    background: #0f172a !important;
}
html[data-theme="dark"] .folders-sidebar {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .mailbox-selector {
    border-color: #334155 !important;
}
html[data-theme="dark"] .mailbox-selector select {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .folder-item {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .folder-item:hover {
    background: #334155 !important;
}
html[data-theme="dark"] .folder-item.active {
    background: #1e3a5f !important;
    color: #60a5fa !important;
}
html[data-theme="dark"] .folder-item.active::before {
    background: #3b82f6 !important;
}
html[data-theme="dark"] .folder-count {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .messages-pane {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .messages-list {
    background: #1e293b !important;
}
html[data-theme="dark"] .messages-toolbar {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .message-row {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .message-row:hover {
    background: #334155 !important;
}
html[data-theme="dark"] .message-row.selected {
    background: #1e3a5f !important;
}
html[data-theme="dark"] .message-row.unread {
    background: #2d3748 !important;
}
html[data-theme="dark"] .message-sender,
html[data-theme="dark"] .message-subject {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .message-date {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .action-btn {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .action-btn:hover {
    background: rgba(255,255,255,0.1) !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .message-star {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .reading-pane {
    background: #0f172a !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .reading-header {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .reading-subject {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .reading-meta {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .reading-content {
    background: #0f172a !important;
    color: #e2e8f0 !important;
}
/* Контент письма: plain text, вложения, inline-цвета в заголовке */
html[data-theme="dark"] .reading-content div[style*="color: #202124"],
html[data-theme="dark"] .reading-content div[style*="color:#202124"],
html[data-theme="dark"] .reading-header div[style*="color: #202124"],
html[data-theme="dark"] .reading-header div[style*="color:#202124"],
html[data-theme="dark"] .reading-pane [style*="color: #202124"],
html[data-theme="dark"] .reading-pane [style*="color:#202124"] {
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .compose-btn {
    background: #1e3a5f !important;
    color: #93c5fd !important;
}
html[data-theme="dark"] .empty-state {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .empty-state h3,
html[data-theme="dark"] .empty-state p {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .pagination {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .pagination-info {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .pagination-btn {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .pagination-btn:hover:not(:disabled) {
    background: #475569 !important;
}
html[data-theme="dark"] .pagination-jump-label {
    color: #94a3b8 !important;
}
html[data-theme="dark"] .pagination-jump-input {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
/* Webmail: compose modal */
html[data-theme="dark"] .compose-modal {
    background: #1e293b !important;
}
html[data-theme="dark"] .compose-body {
    background: #1e293b !important;
}
html[data-theme="dark"] .compose-input,
html[data-theme="dark"] .compose-textarea {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .compose-label {
    color: #94a3b8 !important;
}
/* Уведомления: индикатор "Не прочитано" (тёмный круг на тёмном фоне) */
html[data-theme="dark"] #notifications-list [style*="background: #999"] {
    background: #64748b !important;
    color: #e2e8f0 !important;
}
html[data-theme="dark"] .messages-toolbar {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .message-item {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .message-item:hover {
    background: #334155 !important;
}
html[data-theme="dark"] .message-item.selected {
    background: #1e3a5f !important;
}
html[data-theme="dark"] .detail-pane {
    background: #0f172a !important;
}
html[data-theme="dark"] .detail-pane .detail-header {
    background: #1e293b !important;
    border-color: #334155 !important;
}
html[data-theme="dark"] .detail-pane .detail-body {
    background: #0f172a !important;
    color: #e2e8f0 !important;
}

/* Переключатель темы — стили в sidebar */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    background: #334155;
    border: 1px solid #475569;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
    background: #475569;
    border-color: #64748b;
}

.theme-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle-switch {
    width: 44px;
    height: 24px;
    background: #475569;
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
}

.theme-toggle-switch::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

html[data-theme="dark"] .theme-toggle-switch {
    background: rgba(59, 130, 246, 0.6);
}

html[data-theme="dark"] .theme-toggle-switch::after {
    transform: translateX(20px);
}
