/* ========== ПРИНУДИТЕЛЬНЫЕ СТИЛИ ТЕМНОЙ ТЕМЫ ========== */
/* Этот файл загружается ПОСЛЕДНИМ и переопределяет все inline-стили */

/* ГЛОБАЛЬНОЕ ПЕРЕОПРЕДЕЛЕНИЕ для всех элементов с белым фоном */
body.dark-theme *:not(.btn-primary):not(.btn-success):not(.btn-danger):not(.btn-warning):not([class*="action-"]):not([class*="status-badge"]):not([class*="priority-"]):not(.subnav-tab.active) {
    --card-bg: #1e293b;
    --body-bg: #020617;
    --border-color: #334155;
    --input-bg: #1e293b;
    --text-dark: #e2e8f0;
    --text-gray: #94a3b8;
}

/* Переопределение CSS переменной --card-bg на уровне :root для темной темы */
body.dark-theme :root,
body.dark-theme {
    --card-bg: #1e293b !important;
}

body.dark-theme {
    --sidebar-bg: #0f172a !important;
    --sidebar-text: #94a3b8 !important;
    --sidebar-active: #1e293b !important;
    --body-bg: #020617 !important;
    --text-dark: #e2e8f0 !important;
    --text-gray: #94a3b8 !important;
    --primary-blue: #60a5fa !important;
    --success-green: #4ade80 !important;
    --danger-red: #f87171 !important;
    --warning-yellow: #fbbf24 !important;
    --card-bg: #1e293b !important;
    --border-color: #334155 !important;
    --input-bg: #1e293b !important;
    --table-hover: #334155 !important;
    --modal-overlay: rgba(0, 0, 0, 0.7) !important;
    
    background-color: #020617 !important;
    color: #e2e8f0 !important;
}

body.dark-theme .main-content,
body.dark-theme main {
    background-color: #020617 !important;
    color: #e2e8f0 !important;
}

body.dark-theme .card,
body.dark-theme .stat-item,
body.dark-theme .stats-grid .stat-card,
body.dark-theme .filter-card,
body.dark-theme .form-card,
body.dark-theme .detail-card,
body.dark-theme .ticket-card,
body.dark-theme .kanban-column,
body.dark-theme .kanban-item,
body.dark-theme .article-card,
body.dark-theme .template-card,
body.dark-theme .purchase-card,
body.dark-theme [class*="card"] {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .page-title,
body.dark-theme .page-header h1,
body.dark-theme .card-title,
body.dark-theme h1, 
body.dark-theme h2, 
body.dark-theme h3, 
body.dark-theme h4,
body.dark-theme h5 {
    color: #e2e8f0 !important;
}

body.dark-theme .form-input,
body.dark-theme input[type="text"],
body.dark-theme input[type="email"],
body.dark-theme input[type="password"],
body.dark-theme input[type="date"],
body.dark-theme input[type="number"],
body.dark-theme input[type="search"],
body.dark-theme input[type="tel"],
body.dark-theme input[type="file"],
body.dark-theme select,
body.dark-theme textarea {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme input[type="file"]::file-selector-button {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

body.dark-theme input[type="file"]::file-selector-button:hover {
    background-color: #475569 !important;
}

/* Модалка создания заявки — тёмная тема */
body.dark-theme .create-ticket-modal-content,
body.dark-theme .create-ticket-modal-content label,
body.dark-theme .create-ticket-modal-content .ticket-type-block,
body.dark-theme .create-ticket-modal-content .ticket-type-block span {
    color: var(--text-dark) !important;
}

body.dark-theme .ticket-type-block {
    background-color: #0f172a !important;
    border-color: #334155 !important;
}

body.dark-theme .ticket-type-block input[type="radio"] {
    accent-color: #60a5fa;
}

body.dark-theme .form-input::placeholder,
body.dark-theme input::placeholder,
body.dark-theme textarea::placeholder {
    color: #64748b !important;
}

body.dark-theme table,
body.dark-theme .data-table,
body.dark-theme .log-table {
    background-color: #1e293b !important;
}

body.dark-theme th {
    background-color: #0f172a !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}

body.dark-theme td {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme tr:hover td {
    background-color: #334155 !important;
}

/* Блок паролей в карточке оборудования — тёмная тема */
body.dark-theme .passwords-content-block {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme .btn-outline {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme .btn-outline:hover {
    background-color: #334155 !important;
}

body.dark-theme .subnav-tabs {
    border-color: #334155 !important;
    background-color: transparent !important;
}

body.dark-theme .subnav-tabs a,
body.dark-theme .subnav-tab {
    background-color: #1e293b !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}

body.dark-theme .subnav-tabs a:not(.active),
body.dark-theme .subnav-tab:not(.active) {
    color: #94a3b8 !important;
    background-color: transparent !important;
}

body.dark-theme .subnav-tabs a:hover,
body.dark-theme .subnav-tab:hover {
    color: #e2e8f0 !important;
    background-color: #334155 !important;
}

body.dark-theme .subnav-tabs a.active,
body.dark-theme .subnav-tab.active {
    background-color: #3b82f6 !important;
    color: white !important;
    border-color: #3b82f6 !important;
}

body.dark-theme .stat-number {
    color: #60a5fa !important;
}

body.dark-theme .stat-label {
    color: #94a3b8 !important;
}

body.dark-theme .user-link,
body.dark-theme a:not(.btn):not(.menu-item) {
    color: #60a5fa !important;
}

body.dark-theme .timestamp,
body.dark-theme .ip-address,
body.dark-theme .details-toggle {
    color: #94a3b8 !important;
}

body.dark-theme .details-content {
    background-color: #0f172a !important;
    color: #94a3b8 !important;
}

body.dark-theme .pagination a {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme .pagination a:hover {
    background-color: #334155 !important;
}

body.dark-theme .entity-badge,
body.dark-theme .badge,
body.dark-theme [class*="badge"]:not([class*="action-"]):not([class*="status-"]):not([class*="priority-"]) {
    background-color: #334155 !important;
    color: #94a3b8 !important;
}

body.dark-theme .filter-group label,
body.dark-theme label {
    color: #94a3b8 !important;
}

body.dark-theme .filters {
    background-color: transparent !important;
}

body.dark-theme .new-users-section {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .search-input {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme .kanban-column-header {
    border-color: #334155 !important;
}

body.dark-theme .kanban-item-meta,
body.dark-theme .ticket-card-company {
    color: #94a3b8 !important;
}

body.dark-theme .kanban-item-title,
body.dark-theme .ticket-card-title {
    color: #60a5fa !important;
}

body.dark-theme .modal-content,
body.dark-theme .modal > div,
body.dark-theme [id*="Modal"] > div {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}

body.dark-theme .close-btn {
    color: #94a3b8 !important;
}

body.dark-theme .close-btn:hover {
    color: #e2e8f0 !important;
}

body.dark-theme .step-item {
    background-color: #0f172a !important;
    border-color: #334155 !important;
}

body.dark-theme .step-number {
    background-color: #60a5fa !important;
}

body.dark-theme .info-row {
    border-color: #334155 !important;
}

body.dark-theme .info-label {
    color: #94a3b8 !important;
}

body.dark-theme .info-value {
    color: #e2e8f0 !important;
}

body.dark-theme .chart-bar {
    background-color: #334155 !important;
}

body.dark-theme .empty-state,
body.dark-theme .no-data {
    color: #64748b !important;
}

body.dark-theme .sidebar {
    background-color: #0a0f1a !important;
}

body.dark-theme .menu-item {
    color: #94a3b8 !important;
}

body.dark-theme .menu-item:hover,
body.dark-theme .menu-item.active {
    background-color: #1e293b !important;
    color: white !important;
}

/* Форма и другие элементы */
body.dark-theme .form-group,
body.dark-theme .form-section {
    background-color: transparent !important;
}

body.dark-theme .form-actions {
    border-color: #334155 !important;
}

body.dark-theme hr {
    border-color: #334155 !important;
}

body.dark-theme .divider {
    background-color: #334155 !important;
}

body.dark-theme pre,
body.dark-theme code {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
}

/* Alerts - сохраняем их цвета */
body.dark-theme .alert-success {
    background: rgba(74, 222, 128, 0.15) !important;
    border-color: #4ade80 !important;
    color: #4ade80 !important;
}

body.dark-theme .alert-error,
body.dark-theme .alert-danger {
    background: rgba(248, 113, 113, 0.15) !important;
    border-color: #f87171 !important;
    color: #f87171 !important;
}

body.dark-theme .alert-warning {
    background: rgba(251, 191, 36, 0.15) !important;
    border-color: #fbbf24 !important;
    color: #fbbf24 !important;
}

body.dark-theme .alert-info {
    background: rgba(96, 165, 250, 0.15) !important;
    border-color: #60a5fa !important;
    color: #60a5fa !important;
}

/* Навигация */
body.dark-theme .nav-tabs,
body.dark-theme .tab-list {
    border-color: #334155 !important;
}

body.dark-theme .nav-tab,
body.dark-theme .tab-item {
    color: #94a3b8 !important;
}

body.dark-theme .nav-tab.active,
body.dark-theme .tab-item.active {
    color: #60a5fa !important;
    border-color: #60a5fa !important;
}

/* Dropdown */
body.dark-theme .dropdown-menu,
body.dark-theme .select-dropdown {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .dropdown-item {
    color: #e2e8f0 !important;
}

body.dark-theme .dropdown-item:hover {
    background-color: #334155 !important;
}

/* Tooltip */
body.dark-theme .tooltip {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* Progress bars */
body.dark-theme .progress-bar-bg,
body.dark-theme .progress-track {
    background-color: #334155 !important;
}

/* ========== ФИЛЬТРЫ И ФОРМЫ ПОИСКА ========== */

/* Все select элементы */
body.dark-theme select,
body.dark-theme .filter-select,
body.dark-theme .form-select {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme select option {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}

/* Поиск */
body.dark-theme input[type="search"],
body.dark-theme .search-box,
body.dark-theme .search-input,
body.dark-theme input[placeholder*="оиск"],
body.dark-theme input[placeholder*="earch"] {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* Строка фильтров */
body.dark-theme .filters-row,
body.dark-theme .filter-bar,
body.dark-theme .toolbar {
    background-color: transparent !important;
}

/* Контейнер фильтров */
body.dark-theme .filters-container,
body.dark-theme .search-filters {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* Строка "Выбрать все" и массовые действия */
body.dark-theme .bulk-actions,
body.dark-theme .select-all-row,
body.dark-theme .mass-actions,
body.dark-theme tr.select-row,
body.dark-theme .table-footer {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

/* Checkbox container */
body.dark-theme .checkbox-cell,
body.dark-theme td:first-child,
body.dark-theme th:first-child {
    background-color: inherit !important;
}

/* ========== БЕЙДЖИ И СТАТУСЫ ========== */

/* Статусные бейджи - сохраняем их цвета но делаем фон прозрачнее */
body.dark-theme .status-new,
body.dark-theme .status-badge.new {
    background-color: rgba(96, 165, 250, 0.2) !important;
    color: #60a5fa !important;
}

body.dark-theme .status-accepted,
body.dark-theme .status-badge.accepted {
    background-color: rgba(251, 191, 36, 0.2) !important;
    color: #fbbf24 !important;
}

body.dark-theme .status-in_progress,
body.dark-theme .status-badge.in_progress {
    background-color: rgba(168, 85, 247, 0.2) !important;
    color: #a855f7 !important;
}

body.dark-theme .status-closed,
body.dark-theme .status-badge.closed {
    background-color: rgba(74, 222, 128, 0.2) !important;
    color: #4ade80 !important;
}

/* Категории */
body.dark-theme .category-badge,
body.dark-theme [class*="category-"] {
    background-color: rgba(96, 165, 250, 0.15) !important;
    color: #60a5fa !important;
    border-color: #334155 !important;
}

/* Приоритеты */
body.dark-theme .priority-low {
    background-color: rgba(74, 222, 128, 0.2) !important;
    color: #4ade80 !important;
}

body.dark-theme .priority-medium {
    background-color: rgba(251, 191, 36, 0.2) !important;
    color: #fbbf24 !important;
}

body.dark-theme .priority-high {
    background-color: rgba(251, 146, 60, 0.2) !important;
    color: #fb923c !important;
}

body.dark-theme .priority-critical {
    background-color: rgba(248, 113, 113, 0.2) !important;
    color: #f87171 !important;
}

/* ========== КНОПКИ ========== */

body.dark-theme .btn-secondary,
body.dark-theme .btn-default {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

body.dark-theme .btn-secondary:hover,
body.dark-theme .btn-default:hover {
    background-color: #475569 !important;
}

body.dark-theme .btn-success {
    background-color: #22c55e !important;
    color: white !important;
}

body.dark-theme .btn-danger {
    background-color: #ef4444 !important;
    color: white !important;
}

/* Основная синяя кнопка */
body.dark-theme .btn-primary {
    background-color: #3b82f6 !important;
    color: white !important;
    border-color: #3b82f6 !important;
}

body.dark-theme .btn-primary:hover {
    background-color: #2563eb !important;
}

/* Outline кнопки */
body.dark-theme .btn-outline {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

body.dark-theme .btn-outline:hover {
    background-color: #334155 !important;
    color: #ffffff !important;
}

/* Все кнопки - базовый стиль */
body.dark-theme .btn {
    color: #e2e8f0 !important;
}

body.dark-theme .btn.btn-primary {
    background-color: #3b82f6 !important;
    color: white !important;
}

body.dark-theme .btn.btn-success {
    background-color: #22c55e !important;
    color: white !important;
}

body.dark-theme .btn.btn-danger {
    background-color: #ef4444 !important;
    color: white !important;
}

body.dark-theme .btn.btn-warning {
    background-color: #f59e0b !important;
    color: white !important;
}

/* Кнопки с иконками */
body.dark-theme .btn svg,
body.dark-theme .btn i {
    color: inherit !important;
    fill: currentColor !important;
}

/* Маленькие кнопки */
body.dark-theme .btn-sm {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

body.dark-theme .btn-sm:hover {
    background-color: #475569 !important;
}

/* Светлые кнопки */
body.dark-theme .btn-light {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

/* ========== АВАТАРЫ И ИКОНКИ ========== */

body.dark-theme .avatar,
body.dark-theme .user-avatar {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}

/* ========== ДОПОЛНИТЕЛЬНЫЕ ЭЛЕМЕНТЫ ========== */

/* Иконки фото */
body.dark-theme .photo-icon,
body.dark-theme .image-placeholder {
    background-color: #334155 !important;
    border-color: #475569 !important;
}

/* Ссылки в таблице */
body.dark-theme td a {
    color: #60a5fa !important;
}

/* Время и даты */
body.dark-theme .time-badge,
body.dark-theme .date-cell {
    color: #94a3b8 !important;
}

/* Фоновые области */
body.dark-theme .bg-light,
body.dark-theme .bg-white {
    background-color: #1e293b !important;
}

/* Разделители */
body.dark-theme .separator,
body.dark-theme .divider {
    background-color: #334155 !important;
    border-color: #334155 !important;
}

/* Кнопки действий в таблице */
body.dark-theme .action-btn,
body.dark-theme .table-action {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

body.dark-theme .action-btn:hover,
body.dark-theme .table-action:hover {
    background-color: #475569 !important;
}

/* История и Удалить кнопки */
body.dark-theme .btn-sm {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

body.dark-theme .btn-sm.btn-danger,
body.dark-theme .btn-sm[style*="danger"],
body.dark-theme .btn-sm[style*="red"] {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
    border-color: #f87171 !important;
}

/* Выпадающие списки статусов */
body.dark-theme .status-select,
body.dark-theme select.status-dropdown {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* ========== ПРИНУДИТЕЛЬНОЕ ПЕРЕОПРЕДЕЛЕНИЕ INLINE СТИЛЕЙ ========== */

/* Все элементы с background: white в inline стилях */
body.dark-theme [style*="background: white"],
body.dark-theme [style*="background:white"],
body.dark-theme [style*="background-color: white"],
body.dark-theme [style*="background-color:white"],
body.dark-theme [style*="background: #fff"],
body.dark-theme [style*="background:#fff"],
body.dark-theme [style*="background-color: #fff"],
body.dark-theme [style*="background-color:#fff"],
body.dark-theme [style*="background: #ffffff"],
body.dark-theme [style*="background:#ffffff"] {
    background-color: #1e293b !important;
}

/* Search filter bar */
body.dark-theme .search-filter-bar {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .search-filter-bar .form-input,
body.dark-theme .search-filter-bar select,
body.dark-theme .search-filter-bar input {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme .search-input-wrapper {
    background-color: #0f172a !important;
    border-color: #334155 !important;
}

body.dark-theme .search-input-wrapper input {
    background-color: transparent !important;
    color: #e2e8f0 !important;
}

body.dark-theme .search-input-wrapper svg {
    color: #64748b !important;
    fill: #64748b !important;
}

/* Bulk actions */
body.dark-theme .bulk-actions {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

body.dark-theme .bulk-actions label {
    color: #e2e8f0 !important;
}

/* Pagination select */
body.dark-theme .pagination select,
body.dark-theme #perPageSelect {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* Stats cards icons */
body.dark-theme .card-icon {
    background-color: #334155 !important;
}

body.dark-theme .card-icon.icon-blue {
    background-color: rgba(96, 165, 250, 0.2) !important;
    color: #60a5fa !important;
}

body.dark-theme .card-icon.icon-orange {
    background-color: rgba(251, 146, 60, 0.2) !important;
    color: #fb923c !important;
}

body.dark-theme .card-icon.icon-green {
    background-color: rgba(74, 222, 128, 0.2) !important;
    color: #4ade80 !important;
}

body.dark-theme .card-icon[style*="dcfce7"] {
    background-color: rgba(74, 222, 128, 0.2) !important;
}

body.dark-theme .card-icon[style*="dbeafe"] {
    background-color: rgba(96, 165, 250, 0.2) !important;
}

/* Stat-card icons (dashboard, stats, warehouse) */
body.dark-theme .stat-icon {
    background-color: #334155 !important;
}

body.dark-theme .stat-icon.blue {
    background-color: rgba(96, 165, 250, 0.2) !important;
    color: #60a5fa !important;
}

body.dark-theme .stat-icon.orange {
    background-color: rgba(251, 146, 60, 0.2) !important;
    color: #fb923c !important;
}

body.dark-theme .stat-icon.green {
    background-color: rgba(74, 222, 128, 0.2) !important;
    color: #4ade80 !important;
}

body.dark-theme .stat-icon.red {
    background-color: rgba(248, 113, 113, 0.2) !important;
    color: #f87171 !important;
}

body.dark-theme .stat-icon.purple {
    background-color: rgba(167, 139, 250, 0.2) !important;
    color: #a78bfa !important;
}

body.dark-theme .stat-icon.teal {
    background-color: rgba(45, 212, 191, 0.2) !important;
    color: #2dd4bf !important;
}

body.dark-theme .stat-icon.yellow {
    background-color: rgba(251, 191, 36, 0.2) !important;
    color: #fbbf24 !important;
}

body.dark-theme .stats-cards .stat-card,
body.dark-theme .stats-grid .stat-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .stat-card.highlight {
    background: linear-gradient(135deg, #3b82f6, #6366f1) !important;
    border-color: transparent !important;
}

body.dark-theme .stat-content h3 {
    color: #94a3b8 !important;
}

body.dark-theme .stat-content .stat-value {
    color: #e2e8f0 !important;
}

/* Empty state */
body.dark-theme div[style*="background: white"] {
    background-color: #1e293b !important;
}

/* Excel button - keep its color but adjust for dark theme */
body.dark-theme .btn-outline[style*="dcfce7"] {
    background-color: rgba(74, 222, 128, 0.15) !important;
    color: #4ade80 !important;
    border-color: #4ade80 !important;
}

/* btn-light-red */
body.dark-theme .btn-light-red {
    background-color: rgba(248, 113, 113, 0.15) !important;
    color: #f87171 !important;
    border-color: #f87171 !important;
}

/* Number in stats */
body.dark-theme .number {
    color: #e2e8f0 !important;
}

body.dark-theme .card-info h3 {
    color: #94a3b8 !important;
}

/* Table header row */
body.dark-theme thead tr {
    background-color: #0f172a !important;
}

body.dark-theme thead th {
    background-color: #0f172a !important;
    color: #94a3b8 !important;
}

/* ========== СПЕЦИФИЧНЫЕ ЭЛЕМЕНТЫ DASHBOARD ========== */

/* Аватары клиентов */
body.dark-theme .client-avatar,
body.dark-theme .avatar-circle {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}

/* Бейджи категорий (Принтеры и т.д.) */
body.dark-theme .category-tag,
body.dark-theme span[style*="dbeafe"],
body.dark-theme span[style*="background: #"] {
    background-color: rgba(96, 165, 250, 0.2) !important;
    color: #60a5fa !important;
}

/* Бейджи приоритетов (Средний и т.д.) */
body.dark-theme span[style*="fef3c7"],
body.dark-theme .priority-tag {
    background-color: rgba(251, 191, 36, 0.2) !important;
    color: #fbbf24 !important;
}

/* Статусный бейдж "Закрыта" */
body.dark-theme .status-tag,
body.dark-theme span[style*="dcfce7"] {
    background-color: rgba(74, 222, 128, 0.2) !important;
    color: #4ade80 !important;
}

/* Иконка фото */
body.dark-theme .photo-cell,
body.dark-theme .photo-thumbnail {
    background-color: #334155 !important;
    border-color: #475569 !important;
}

/* Выпадающий select статуса в таблице */
body.dark-theme td select {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* История и Удалить кнопки в таблице */
body.dark-theme .btn-history,
body.dark-theme a[href*="history"] {
    background-color: #334155 !important;
    color: #60a5fa !important;
    border-color: #475569 !important;
}

body.dark-theme .btn-delete,
body.dark-theme button[onclick*="delete"],
body.dark-theme form[action*="delete"] button {
    background-color: rgba(248, 113, 113, 0.15) !important;
    color: #f87171 !important;
    border-color: #f87171 !important;
}

/* Все inline белые фоны в таблице */
body.dark-theme td[style*="background"],
body.dark-theme tr[style*="background"] {
    background-color: #1e293b !important;
}

/* Текст компании под именем клиента */
body.dark-theme .company-name,
body.dark-theme .client-company {
    color: #64748b !important;
}

/* Время в таблице */
body.dark-theme .resolution-time {
    color: #94a3b8 !important;
}

/* ========== СЕКЦИИ И ЗАГОЛОВКИ ========== */

/* Секции (Все пользователи, Новые пользователи и т.д.) */
body.dark-theme .section {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .section-header {
    background-color: #0f172a !important;
    border-color: #334155 !important;
}

body.dark-theme .section-title {
    color: #e2e8f0 !important;
}

body.dark-theme .section-badge {
    background-color: #eab308 !important;
}

/* Таблицы в секциях */
body.dark-theme .data-table {
    background-color: #1e293b !important;
}

body.dark-theme .data-table th {
    background-color: #0f172a !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}

body.dark-theme .data-table td {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme .data-table tr:hover td {
    background-color: #334155 !important;
}

/* ========== СТРАНИЦА СОТРУДНИКОВ/КЛИЕНТОВ ========== */

/* Карточки клиентов/сотрудников */
body.dark-theme .employee-card,
body.dark-theme .client-card,
body.dark-theme .user-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* Навигация по вкладкам (Сотрудники, Клиенты) */
body.dark-theme .tabs,
body.dark-theme .nav-tabs {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

body.dark-theme .tab,
body.dark-theme .nav-tab {
    background-color: transparent !important;
    color: #94a3b8 !important;
}

body.dark-theme .tab.active,
body.dark-theme .nav-tab.active {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}

body.dark-theme .tab:hover,
body.dark-theme .nav-tab:hover {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}

/* Ссылки в таблицах */
body.dark-theme .data-table a,
body.dark-theme .data-table .user-link {
    color: #60a5fa !important;
}

/* Роли пользователей */
body.dark-theme .role-admin {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
}

body.dark-theme .role-support {
    background-color: rgba(96, 165, 250, 0.2) !important;
    color: #60a5fa !important;
}

body.dark-theme .role-client {
    background-color: rgba(74, 222, 128, 0.2) !important;
    color: #4ade80 !important;
}

body.dark-theme .role-guest {
    background-color: rgba(251, 191, 36, 0.2) !important;
    color: #fbbf24 !important;
}

/* Фильтры на странице пользователей */
body.dark-theme .filters-section {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* Новые пользователи секция */
body.dark-theme .new-users-section {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* Поиск на странице пользователей */
body.dark-theme .user-search,
body.dark-theme .search-form {
    background-color: #1e293b !important;
}

body.dark-theme .search-form input {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* Пагинация */
body.dark-theme .pagination-info {
    color: #94a3b8 !important;
}

body.dark-theme .pagination-link {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

body.dark-theme .pagination-link:hover {
    background-color: #334155 !important;
}

body.dark-theme .pagination-link.active {
    background-color: #60a5fa !important;
    color: white !important;
}

/* Все элементы с явным белым фоном */
body.dark-theme [style*="background: #f8fafc"],
body.dark-theme [style*="background:#f8fafc"],
body.dark-theme [style*="background-color: #f8fafc"],
body.dark-theme [style*="background-color:#f8fafc"] {
    background-color: #0f172a !important;
}

/* ========== УНИВЕРСАЛЬНЫЕ СЕЛЕКТОРЫ ДЛЯ БЕЛЫХ ФОНОВ ========== */

/* Все div, section, article с белым фоном через CSS (не inline) */
body.dark-theme div,
body.dark-theme section,
body.dark-theme article,
body.dark-theme aside,
body.dark-theme header,
body.dark-theme footer,
body.dark-theme form {
    background-color: inherit;
}

/* Карточки и контейнеры */
body.dark-theme .card,
body.dark-theme .panel,
body.dark-theme .box,
body.dark-theme .container-white,
body.dark-theme .content-box,
body.dark-theme .detail-section,
body.dark-theme .info-section,
body.dark-theme .form-section,
body.dark-theme .filter-section,
body.dark-theme .search-section {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* Поисковые бары */
body.dark-theme .search-bar,
body.dark-theme .filter-bar,
body.dark-theme .toolbar-bar {
    background-color: #1e293b !important;
}

/* Все таблицы */
body.dark-theme table {
    background-color: #1e293b !important;
}

body.dark-theme table th {
    background-color: #0f172a !important;
    color: #94a3b8 !important;
}

body.dark-theme table td {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}

/* Переопределение для конкретных классов из шаблонов */
body.dark-theme .search-bar,
body.dark-theme .filter-card,
body.dark-theme .form-card,
body.dark-theme .stats-card,
body.dark-theme .detail-card,
body.dark-theme .info-card,
body.dark-theme .user-card,
body.dark-theme .company-card,
body.dark-theme .equipment-card,
body.dark-theme .task-card,
body.dark-theme .ticket-detail,
body.dark-theme .history-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* Формы и инпуты */
body.dark-theme .form-group {
    background-color: transparent !important;
}

body.dark-theme .form-control,
body.dark-theme .form-input,
body.dark-theme .form-select {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

/* Select опции */
body.dark-theme option {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}

/* Subnavigation */
body.dark-theme .subnav,
body.dark-theme .sub-nav,
body.dark-theme .clients-subnav {
    background-color: transparent !important;
}

/* Вкладки клиентов/сотрудников */
body.dark-theme .clients-tabs a,
body.dark-theme .subnav a:not(.active) {
    color: #94a3b8 !important;
}

body.dark-theme .clients-tabs a.active,
body.dark-theme .subnav a.active {
    color: #60a5fa !important;
    border-color: #60a5fa !important;
}

/* ========== STATUS BADGES — Закупки, КП, Заявки ========== */
body.dark-theme .status-draft {
    background: rgba(251, 191, 36, 0.2) !important;
    color: #fbbf24 !important;
}
body.dark-theme .status-needed,
body.dark-theme .status-received,
body.dark-theme .status-delivered,
body.dark-theme .status-signed {
    background: rgba(74, 222, 128, 0.2) !important;
    color: #4ade80 !important;
}
body.dark-theme .status-ordered {
    background: rgba(96, 165, 250, 0.2) !important;
    color: #60a5fa !important;
}
body.dark-theme .status-in_transit {
    background: rgba(129, 140, 248, 0.2) !important;
    color: #818cf8 !important;
}
body.dark-theme .status-cancelled {
    background: rgba(148, 163, 184, 0.2) !important;
    color: #94a3b8 !important;
}
body.dark-theme .priority-urgent {
    background: rgba(248, 113, 113, 0.2) !important;
    color: #f87171 !important;
}
body.dark-theme .priority-high {
    background: rgba(251, 191, 36, 0.2) !important;
    color: #fbbf24 !important;
}

/* Kebab menu, dropdowns */
body.dark-theme .kebab-menu {
    background: #1e293b !important;
    border-color: #334155 !important;
}
body.dark-theme .archived-notice {
    background: rgba(251, 191, 36, 0.15) !important;
    color: #fbbf24 !important;
}
body.dark-theme .archived-notice a,
body.dark-theme .archived-notice-link {
    color: #fbbf24 !important;
}

/* Dashboard filter banner */
body.dark-theme .filter-info-banner {
    background: rgba(96, 165, 250, 0.15) !important;
    border-color: var(--primary-blue) !important;
}
body.dark-theme .filter-info-text {
    color: var(--primary-blue) !important;
}

/* ========== VIEW SWITCHER (dark theme) ========== */
body.dark-theme .view-switcher {
    border-color: #334155 !important;
}
body.dark-theme .view-switcher-tab {
    background-color: #1e293b !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}
body.dark-theme .view-switcher-tab:hover:not(.active) {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}
body.dark-theme .view-switcher-tab.active {
    background-color: #3b82f6 !important;
    color: white !important;
    border-color: #3b82f6 !important;
}

/* ========== CALENDAR (dark theme) ========== */
body.dark-theme .calendar-day {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}
body.dark-theme .calendar-day.other-month {
    background-color: #0f172a !important;
    color: #475569 !important;
}
body.dark-theme .calendar-day.today {
    background-color: rgba(96, 165, 250, 0.15) !important;
}
body.dark-theme .calendar-day:hover {
    background-color: #334155 !important;
}
body.dark-theme .calendar-nav-btn {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
body.dark-theme .calendar-nav-btn:hover {
    background-color: #334155 !important;
}
body.dark-theme .current-month {
    color: #e2e8f0 !important;
}
body.dark-theme .calendar-grid {
    background-color: #334155 !important;
}
body.dark-theme .calendar-header {
    background-color: #0f172a !important;
}
body.dark-theme .day-number {
    color: #e2e8f0 !important;
}
body.dark-theme .task-item {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}
body.dark-theme .task-item:hover {
    background-color: #475569 !important;
}

/* ========== MONITORING TABS (dark theme) ========== */
body.dark-theme .monitoring-tab {
    background-color: #1e293b !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}
body.dark-theme .monitoring-tab:hover {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}
body.dark-theme .monitoring-tab.active {
    background-color: #3b82f6 !important;
    color: white !important;
    border-color: #3b82f6 !important;
}
body.dark-theme .monitoring-header {
    background-color: #1e293b !important;
}
body.dark-theme .info-card {
    background-color: #1e293b !important;
}
body.dark-theme .info-card .value {
    color: #60a5fa !important;
}

/* ========== REPORT CARDS (button fix) ========== */
.report-card form {
    display: flex;
    flex-direction: column;
}
.report-card .btn {
    width: 100%;
    text-align: center;
    margin-top: auto;
}
.report-card .date-range {
    margin-bottom: 12px;
}
.report-card .form-group {
    margin-bottom: 10px;
}

/* ========== WORKPLACE CARDS (dark theme) ========== */
body.dark-theme .workplace-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}
body.dark-theme .workplace-name {
    color: #e2e8f0 !important;
}
body.dark-theme .workplace-info {
    color: #94a3b8 !important;
}

/* ========== СКЛАД: Остатки на складах (product_view) — тёмная тема ========== */
body.dark-theme .stock-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    overflow: hidden;
}
body.dark-theme .stock-summary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    border-radius: 10px !important;
    color: white !important;
}
body.dark-theme .stock-table thead,
body.dark-theme .stock-table thead th {
    background-color: #0f172a !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}
body.dark-theme .stock-table td {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
body.dark-theme .stock-table tbody tr:hover td {
    background-color: #334155 !important;
}
