/* ==========================================================================
   theme.css — светлая и тёмная темы для всего сайта.
   Подключается последним, после design.css / gallery.css / help.css.
   Тёмная тема включается атрибутом data-theme="dark" на <html>.
   ========================================================================== */

:root {
  --ipg-bg: #f0f2f5;
  --ipg-bg-soft: #f8fafc;
  --ipg-surface: #ffffff;
  --ipg-surface-2: #f1f5f9;
  --ipg-text: #0f172a;
  --ipg-muted: #64748b;
  --ipg-border: #e2e8f0;
  --ipg-primary: #2563eb;
  --ipg-link: #2563eb;
  --ipg-input-bg: #ffffff;
  --ipg-shadow: 0 10px 30px -18px rgba(15, 23, 42, 0.35);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ipg-bg: #0b1220;
  --ipg-bg-soft: #0f172a;
  --ipg-surface: #16233a;
  --ipg-surface-2: #1b2a41;
  --ipg-text: #e6edf7;
  --ipg-muted: #94a3b8;
  --ipg-border: #2b3a52;
  --ipg-primary: #60a5fa;
  --ipg-link: #93c5fd;
  --ipg-input-bg: #0f172a;
  --ipg-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.8);
}

/* --------------------------------------------------------------------------
   База
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body {
  background:
    radial-gradient(1200px 600px at 0% 0%, #12203a 0%, transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, #1a1733 0%, transparent 55%),
    radial-gradient(900px 700px at 50% 100%, #0c2a2e 0%, transparent 60%),
    linear-gradient(180deg, #0b1220 0%, #0d1526 50%, #0a1420 100%) !important;
  background-attachment: fixed !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .help-page {
  background:
    radial-gradient(900px 500px at 0% 0%, #12203a 0%, transparent 60%),
    radial-gradient(800px 500px at 100% 0%, #1a1733 0%, transparent 55%),
    linear-gradient(180deg, #0b1220 0%, #0d1526 100%) !important;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6 {
  color: var(--ipg-text);
}

html[data-theme="dark"] a:not(.btn):not(.tile):not(.brand-title) {
  color: var(--ipg-link);
}

html[data-theme="dark"] hr {
  border-color: var(--ipg-border);
}

/* --------------------------------------------------------------------------
   Карточки и контейнеры
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .card,
html[data-theme="dark"] .user-card,
html[data-theme="dark"] .brand-body,
html[data-theme="dark"] .group-item,
html[data-theme="dark"] .fault-row,
html[data-theme="dark"] .counter,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .photos-toolbar,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .tile,
html[data-theme="dark"] .footer,
html[data-theme="dark"] .help-card,
html[data-theme="dark"] .help-section,
html[data-theme="dark"] .timeline-wrap,
html[data-theme="dark"] .timeline-item,
html[data-theme="dark"] .visit-kv,
html[data-theme="dark"] .server-kv,
html[data-theme="dark"] .server-cron-preview,
html[data-theme="dark"] .wn-toast,
html[data-theme="dark"] .wn-modal,
html[data-theme="dark"] .wn-item,
html[data-theme="dark"] .toolbar-editor-box,
html[data-theme="dark"] .toolbar-list,
html[data-theme="dark"] .toolbar-item,
html[data-theme="dark"] .handover-reminder,
html[data-theme="dark"] .comment-bubble,
html[data-theme="dark"] .status-msg {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .brand-body,
html[data-theme="dark"] .timeline-wrap,
html[data-theme="dark"] .photos-toolbar {
  background: var(--ipg-bg-soft) !important;
}

html[data-theme="dark"] .ipg-head-top,
html[data-theme="dark"] .ipg-guar-row,
html[data-theme="dark"] .help-hero,
html[data-theme="dark"] .help-toolbar,
html[data-theme="dark"] .toolbar-editor-head,
html[data-theme="dark"] .toolbar-editor-foot,
html[data-theme="dark"] .wn-modal-head,
html[data-theme="dark"] .wn-modal-foot {
  background: var(--ipg-surface-2) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .ipg-header-card {
  border-color: var(--ipg-border) !important;
  box-shadow: var(--ipg-shadow) !important;
}

/* Мягкое плавное наведение: спокойный сине-фиолетовый акцент без перелива */
html[data-theme="dark"] .group-item,
html[data-theme="dark"] .photo-card,
html[data-theme="dark"] .otm-item,
html[data-theme="dark"] .vc-item,
html[data-theme="dark"] .fault-details,
html[data-theme="dark"] .fault-item {
  transition:
    background-color 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease,
    transform 0.35s ease;
}

html[data-theme="dark"] .group-item:hover {
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(139, 92, 246, 0.10)),
    var(--ipg-surface) !important;
  border-color: rgba(59, 130, 246, 0.70) !important;
  box-shadow:
    0 0 0 1px rgba(59, 130, 246, 0.28),
    0 14px 30px -22px rgba(56, 189, 248, 0.55) !important;
}

/* Наведение на неисправность внутри карточки ТС */
html[data-theme="dark"] .fault-details:hover {
  border-color: rgba(59, 130, 246, 0.70) !important;
  box-shadow:
    0 0 0 1px rgba(59, 130, 246, 0.28),
    0 14px 30px -22px rgba(56, 189, 248, 0.55) !important;
}

html[data-theme="dark"] .fault-details:hover .fault-item {
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(139, 92, 246, 0.10)),
    var(--ipg-surface) !important;
}

html[data-theme="dark"] .group-item:hover {
  transform: translateY(-2px);
}

/* Градиент карточек «Фото по РА» — как в окне «Что нового» */
html[data-theme="dark"] .group-item {
  background:
    linear-gradient(135deg, #16233a 0%, #1a2b45 60%, #122a33 100%) !important;
  border-color: rgba(99, 102, 241, 0.22) !important;
}

html[data-theme="dark"] .group-item:hover {
  background:
    linear-gradient(135deg, #1b2c47 0%, #213554 60%, #16323d 100%) !important;
  border-color: rgba(129, 140, 248, 0.62) !important;
  box-shadow:
    0 0 0 1px rgba(129, 140, 248, 0.28),
    0 16px 34px -22px rgba(56, 189, 248, 0.55) !important;
}

/* Заголовки брендов: тот же градиент, но насыщеннее и с рамкой */
html[data-theme="dark"] .brand-kamaz .brand-title,
html[data-theme="dark"] .brand-compass .brand-title,
html[data-theme="dark"] .brand-foton .brand-title,
html[data-theme="dark"] .brand-sitrak .brand-title,
html[data-theme="dark"] .brand-pritsep .brand-title,
html[data-theme="dark"] .brand-nobrand .brand-title {
  background: linear-gradient(135deg, #1e3a8a 0%, #312e81 55%, #0e7490 100%) !important;
  color: #eef2ff !important;
  box-shadow:
    inset 0 0 0 1px rgba(129, 140, 248, 0.45),
    0 10px 24px -16px rgba(0, 0, 0, 0.85) !important;
}

html[data-theme="dark"] .brand-section .brand-title::before {
  color: #c7d2fe !important;
}

html[data-theme="dark"] .brand-section .brand-title .cnt {
  background: rgba(199, 210, 254, 0.2) !important;
  color: #e0e7ff !important;
}

html[data-theme="dark"] .group-item:hover .group-title,
html[data-theme="dark"] .group-item:hover b {
  color: #bfdbfe !important;
}

html[data-theme="dark"] .photo-card:hover,
html[data-theme="dark"] .vc-item:hover {
  border-color: rgba(59, 130, 246, 0.70) !important;
  box-shadow:
    0 0 0 1px rgba(59, 130, 246, 0.28),
    0 14px 30px -22px rgba(139, 92, 246, 0.55) !important;
  transform: translateY(-2px);
}

html[data-theme="dark"] .otm-item:hover {
  border-color: rgba(59, 130, 246, 0.70) !important;
  box-shadow: 0 10px 24px -20px rgba(56, 189, 248, 0.55) !important;
}

@media (prefers-reduced-motion: reduce) {
  html[data-theme="dark"] .group-item,
  html[data-theme="dark"] .fault-row,
  html[data-theme="dark"] .photo-card,
  html[data-theme="dark"] .otm-item,
  html[data-theme="dark"] .vc-item {
    transition: none;
  }

  html[data-theme="dark"] .group-item:hover,
  html[data-theme="dark"] .photo-card:hover,
  html[data-theme="dark"] .vc-item:hover {
    transform: none;
  }
}

html[data-theme="dark"] .type-option,
html[data-theme="dark"] .photo-card,
html[data-theme="dark"] .photo-meta,
html[data-theme="dark"] .fault-details,
html[data-theme="dark"] .fault-details .fault-item,
html[data-theme="dark"] .otm-item,
html[data-theme="dark"] .btn-cancel,
html[data-theme="dark"] .card-settings-toggle,
html[data-theme="dark"] .vc-fault-badge {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .file-preview-box,
html[data-theme="dark"] .fault-body,
html[data-theme="dark"] .otm-body,
html[data-theme="dark"] table.doc-table th {
  background: var(--ipg-bg-soft) !important;
  color: var(--ipg-muted) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] table.doc-table td {
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] table.doc-table tr:hover td {
  background: var(--ipg-bg-soft) !important;
}

html[data-theme="dark"] .group-thumb {
  background: var(--ipg-bg-soft) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .fault-details.status-waiting-parts .fault-item {
  background: #3a2e12 !important;
}

html[data-theme="dark"] .fault-status-select.status-waiting-parts {
  background: #3a2e12 !important;
  color: #fcd34d !important;
  border-color: #78350f !important;
}

html[data-theme="dark"] .vc-item {
  background: var(--ipg-surface) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .vc-item:hover {
  border-color: #3b4d68 !important;
}

html[data-theme="dark"] .vc-item-title {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .vc-item-date,
html[data-theme="dark"] .vc-item-meta {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .vc-item-meta a {
  background: #12233f !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .vc-timeline::before {
  background: var(--ipg-border) !important;
}

html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .modal-box,
html[data-theme="dark"] .editor-panel,
html[data-theme="dark"] .editor-toolbar,
html[data-theme="dark"] .editor-canvas,
html[data-theme="dark"] .viewer-toolbar,
html[data-theme="dark"] .photo-viewer,
html[data-theme="dark"] .doc-preview {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
}

/* Поиск работ */
html[data-theme="dark"] .tree-head,
html[data-theme="dark"] .tree-summary,
html[data-theme="dark"] .tree-leaf,
html[data-theme="dark"] .cart-panel,
html[data-theme="dark"] .cart-head,
html[data-theme="dark"] .cart-foot,
html[data-theme="dark"] .cart-close,
html[data-theme="dark"] .tree-qty {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .tree-head,
html[data-theme="dark"] .tree-summary,
html[data-theme="dark"] .cart-foot {
  background: var(--ipg-bg-soft) !important;
}

html[data-theme="dark"] .tree-leaf:hover,
html[data-theme="dark"] .tree-summary:hover,
html[data-theme="dark"] .cart-close:hover {
  background: #223451 !important;
}

html[data-theme="dark"] .tree-group[open] > .tree-summary {
  background: #1b2a41 !important;
}

html[data-theme="dark"] .cart-add {
  background: var(--ipg-surface-2) !important;
  color: #93c5fd !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .cart-add:hover {
  background: #12233f !important;
  border-color: #1e3a8a !important;
}

html[data-theme="dark"] .cart-add.in-cart {
  background: #123326 !important;
  color: #6ee7b7 !important;
  border-color: #14532d !important;
}

html[data-theme="dark"] .workload-value,
html[data-theme="dark"] .cart-count {
  background: #12233f !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .btn-print {
  background: #12233f !important;
  color: #93c5fd !important;
  border-color: #1e3a8a !important;
}

html[data-theme="dark"] .btn-print:hover {
  background: #16294a !important;
}

html[data-theme="dark"] .cart-clear {
  background: #3a1717 !important;
  color: #fca5a5 !important;
  border-color: #7f1d1d !important;
}

html[data-theme="dark"] .cart-clear:hover {
  background: #4a1c1c !important;
}

/* Генератор писем */
html[data-theme="dark"] .lg-form-card,
html[data-theme="dark"] .lg-btn {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .lg-btn:hover {
  background: #223451 !important;
  border-color: #3b4d68 !important;
}

html[data-theme="dark"] .lg-btn-primary {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #2563eb !important;
}

html[data-theme="dark"] .lg-btn-primary:hover {
  background: #1d4ed8 !important;
  border-color: #1d4ed8 !important;
}

html[data-theme="dark"] .lg-preview {
  background: var(--ipg-bg-soft) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .lg-section-title,
html[data-theme="dark"] .lg-field label,
html[data-theme="dark"] .lg-check,
html[data-theme="dark"] .lg-autosave {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .lg-row-remove {
  background: #3a1717 !important;
  color: #fca5a5 !important;
  border-color: #7f1d1d !important;
}

html[data-theme="dark"] .lg-row-remove:hover {
  background: #4a1c1c !important;
}

html[data-theme="dark"] .lg-section + .lg-section {
  border-top-color: var(--ipg-border) !important;
}

/* Профиль */
html[data-theme="dark"] .stat-item {
  background: #12233f !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .stat-item b {
  color: #93c5fd !important;
}

html[data-theme="dark"] .photo-card {
  background: var(--ipg-surface-2) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .photo-meta {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .user-info,
html[data-theme="dark"] .form-row label {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .user-info b {
  color: #93c5fd !important;
}

html[data-theme="dark"] .logout {
  color: #fca5a5 !important;
}

/* Вход и регистрация */
html[data-theme="dark"] label,
html[data-theme="dark"] .checkbox {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .error {
  background: #3a1717 !important;
  color: #fca5a5 !important;
}

html[data-theme="dark"] .notice {
  background: #12233f !important;
  color: #93c5fd !important;
}

/* Печатный документ А4 всегда остаётся белым с чёрным текстом. */
html[data-theme="dark"] .document-paper {
  background: #ffffff !important;
  color: #000000 !important;
}

html[data-theme="dark"] .brand-section {
  box-shadow: 0 10px 28px -16px rgba(0, 0, 0, 0.8) !important;
}

/* --------------------------------------------------------------------------
   Текст и подписи
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .tile-title,
html[data-theme="dark"] .brand-name,
html[data-theme="dark"] .user-name,
html[data-theme="dark"] .user-login,
html[data-theme="dark"] .ipg-brand-title,
html[data-theme="dark"] .help-hero__title,
html[data-theme="dark"] .help-section h2,
html[data-theme="dark"] .help-section h3,
html[data-theme="dark"] .wn-item-title,
html[data-theme="dark"] .wn-modal-title,
html[data-theme="dark"] .wn-toast-title {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .tile-desc,
html[data-theme="dark"] .brand-sub,
html[data-theme="dark"] .welcome p,
html[data-theme="dark"] .meta,
html[data-theme="dark"] .group-item-meta,
html[data-theme="dark"] .date-group-title,
html[data-theme="dark"] .footer,
html[data-theme="dark"] .help-hero__sub,
html[data-theme="dark"] .help-section p,
html[data-theme="dark"] .help-section li,
html[data-theme="dark"] .user-stats,
html[data-theme="dark"] .visit-source,
html[data-theme="dark"] .page-subtitle,
html[data-theme="dark"] .wn-item-text,
html[data-theme="dark"] .wn-sub,
html[data-theme="dark"] .wn-modal-sub,
html[data-theme="dark"] .wn-modal-foot,
html[data-theme="dark"] .wn-toast-sub,
html[data-theme="dark"] .toolbar-empty,
html[data-theme="dark"] .visit-ip {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .group-item-title,
html[data-theme="dark"] .meta-photo-date b,
html[data-theme="dark"] .meta-photo-date.is-today b {
  color: #6ee7b7 !important;
}

html[data-theme="dark"] .meta-photo-date,
html[data-theme="dark"] .meta-created-date,
html[data-theme="dark"] .fault-badge-list,
html[data-theme="dark"] .fault-badge-list b {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .client-text {
  background: var(--ipg-surface-2) !important;
  border-color: var(--ipg-border) !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .meta-today-tag {
  background: #123326 !important;
  border-color: #14532d !important;
  color: #6ee7b7 !important;
}

/* --------------------------------------------------------------------------
   Кнопки
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-ghost,
html[data-theme="dark"] .filter-btn,
html[data-theme="dark"] .tab,
html[data-theme="dark"] .vc-tab,
html[data-theme="dark"] .help-page__print,
html[data-theme="dark"] .help-page__back {
  background: var(--ipg-surface-2) !important;
  color: #cbd5e1 !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .btn-ghost:hover,
html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .filter-btn:hover,
html[data-theme="dark"] .tab:hover,
html[data-theme="dark"] .vc-tab:hover {
  background: #223451 !important;
  color: #e6edf7 !important;
  border-color: #3b4d68 !important;
}

/* Кнопки в шапке страницы — никакого белого фона */
html[data-theme="dark"] .ipg-head-actions .btn:not(.btn-primary):not(.btn-green):not(.btn-red):not(.btn-ai):not(.btn-orange) {
  background: var(--ipg-surface-2) !important;
  color: #cbd5e1 !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .ipg-head-actions .btn:not(.btn-primary):not(.btn-green):not(.btn-red):not(.btn-ai):not(.btn-orange):hover {
  background: #223451 !important;
  color: var(--ipg-text) !important;
  border-color: #3b4d68 !important;
}

html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .filter-btn.active,
html[data-theme="dark"] .tab.active,
html[data-theme="dark"] .vc-tab.active {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #2563eb !important;
}

html[data-theme="dark"] .btn-green {
  background: #047857 !important;
  color: #ffffff !important;
  border-color: #047857 !important;
}

html[data-theme="dark"] .btn-red {
  background: #b91c1c !important;
  color: #ffffff !important;
  border-color: #b91c1c !important;
}

html[data-theme="dark"] .btn-orange {
  background: linear-gradient(135deg, #c2410c, #ea580c) !important;
  color: #ffffff !important;
}

html[data-theme="dark"] .tab.active {
  background: var(--ipg-surface) !important;
  color: #93c5fd !important;
  border-color: var(--ipg-border) !important;
  border-top-color: #3b82f6 !important;
}

html[data-theme="dark"] .tab .cnt,
html[data-theme="dark"] .tab.active .cnt {
  background: #1e3a8a !important;
  color: #bfdbfe !important;
}

html[data-theme="dark"] .tab .remind-cnt {
  background: #b91c1c !important;
  color: #ffffff !important;
}

/* --------------------------------------------------------------------------
   Поля ввода
   -------------------------------------------------------------------------- */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .form-input,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-textarea,
html[data-theme="dark"] .editable,
html[data-theme="dark"] .comment-input,
html[data-theme="dark"] .toolbar-editor-select,
html[data-theme="dark"] .help-search {
  background: var(--ipg-input-bg) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
}

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

html[data-theme="dark"] select option {
  background: #0f172a;
  color: #e6edf7;
}

html[data-theme="dark"] .editable:focus {
  background: #3a2e12 !important;
  box-shadow: inset 0 0 0 2px #eab308 !important;
}

html[data-theme="dark"] input[type="checkbox"],
html[data-theme="dark"] input[type="radio"] {
  accent-color: #60a5fa;
}

/* --------------------------------------------------------------------------
   Плашки, бейджи, уведомления
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .flash,
html[data-theme="dark"] .alert {
  background: var(--ipg-surface-2) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .flash-success,
html[data-theme="dark"] .alert-success {
  background: #0f2f24 !important;
  color: #86efac !important;
  border-color: #14532d !important;
}

html[data-theme="dark"] .flash-error,
html[data-theme="dark"] .alert-error {
  background: #3a1717 !important;
  color: #fca5a5 !important;
  border-color: #7f1d1d !important;
}

html[data-theme="dark"] .alert-warning {
  background: #3a2e12 !important;
  color: #fcd34d !important;
  border-color: #78350f !important;
}

html[data-theme="dark"] .badge {
  background: var(--ipg-surface-2) !important;
  color: #cbd5e1 !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .badge-green,
html[data-theme="dark"] .badge-ok {
  background: #123326 !important;
  color: #6ee7b7 !important;
  border-color: #14532d !important;
}

html[data-theme="dark"] .badge-red,
html[data-theme="dark"] .badge-error,
html[data-theme="dark"] .badge-fault {
  background: #3a1717 !important;
  color: #fca5a5 !important;
  border-color: #7f1d1d !important;
}

html[data-theme="dark"] .badge-missing,
html[data-theme="dark"] .badge-warning {
  background: #3a2e12 !important;
  color: #fcd34d !important;
  border-color: #78350f !important;
}

html[data-theme="dark"] .badge-blue,
html[data-theme="dark"] .badge-type {
  background: #12233f !important;
  color: #93c5fd !important;
  border-color: #1e3a8a !important;
}

html[data-theme="dark"] .badge-violet {
  background: #241a3f !important;
  color: #c4b5fd !important;
  border-color: #4c1d95 !important;
}

html[data-theme="dark"] .toolbar-badge {
  background: #dc2626 !important;
  color: #ffffff !important;
}

/* --------------------------------------------------------------------------
   Главная страница
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .topbar .brand-name,
html[data-theme="dark"] .welcome h1 {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .welcome h1 b {
  color: #93c5fd !important;
}

html[data-theme="dark"] .tile {
  border-color: #23324a !important;
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.85) !important;
}

html[data-theme="dark"] .tile::before {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0.05) 100%) !important;
}

html[data-theme="dark"] .tile:hover {
  border-color: #35507a !important;
}

html[data-theme="dark"] .footer {
  background: rgba(22, 35, 58, 0.85) !important;
  border-color: #23324a !important;
}

html[data-theme="dark"] #loading {
  background: #0b1220 !important;
  color: var(--ipg-muted) !important;
}

/* --------------------------------------------------------------------------
   Админ-панель
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .user-header,
html[data-theme="dark"] .visit-history li {
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .visit-history summary {
  color: #93c5fd !important;
}

html[data-theme="dark"] .visit-history ul {
  border-left-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .user-badge.badge-admin {
  background: #3a1717 !important;
  color: #fca5a5 !important;
}

html[data-theme="dark"] .user-badge.badge-viewer {
  background: #1b2a41 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .user-badge.badge-user {
  background: #12233f !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .visit-metric,
html[data-theme="dark"] .visit-chart,
html[data-theme="dark"] .reset-form {
  background: var(--ipg-bg-soft) !important;
  border-color: var(--ipg-border) !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .visit-metric-value {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .visit-metric-key,
html[data-theme="dark"] .visit-chart-title,
html[data-theme="dark"] .visit-chart-sub,
html[data-theme="dark"] .visit-chart-empty,
html[data-theme="dark"] .visit-axis-label {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .visit-bar.is-zero {
  background: #334155 !important;
}

/* --------------------------------------------------------------------------
   Передача смены
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .main-container {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
  box-shadow: var(--ipg-shadow) !important;
}

html[data-theme="dark"] .excel-table {
  background: var(--ipg-surface) !important;
}

html[data-theme="dark"] .excel-table td,
html[data-theme="dark"] .excel-table td * {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .excel-table td .editable {
  background: transparent !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .excel-table td .editable:focus {
  background: #3a2e12 !important;
  box-shadow: inset 0 0 0 2px #eab308 !important;
}

html[data-theme="dark"] .excel-table td .comment-bubble.empty {
  background-color: #3a1717 !important;
}

html[data-theme="dark"] .excel-table td .comment-bubble.meta-empty {
  background-color: #3a2e12 !important;
}

html[data-theme="dark"] .excel-table td .open-card-link {
  background-color: #12233f !important;
}

html[data-theme="dark"] .editable:empty::before {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .excel-table td {
  background: var(--ipg-surface) !important;
  border-color: var(--ipg-border) !important;
}

/* Шапка таблицы: без оранжевого — тёмная с синим акцентом */
html[data-theme="dark"] .excel-table th {
  background: var(--ipg-surface-2) !important;
  color: #cbd5e1 !important;
  border-color: var(--ipg-border) !important;
  box-shadow: inset 0 -2px 0 #2563eb !important;
}

html[data-theme="dark"] .handover-table-wrap {
  background: var(--ipg-surface) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .comment-chat {
  background: var(--ipg-bg-soft) !important;
}

html[data-theme="dark"] .handover-toolbar {
  background: var(--ipg-bg) !important;
}

html[data-theme="dark"] .tabs {
  border-bottom-color: #2563eb !important;
}

/* Кнопка «+ Добавить строку»: вместо оранжевой — синяя */
html[data-theme="dark"] #btnAddRow {
  background: #1e3a8a !important;
  color: #e6edf7 !important;
  border: 1px solid #2563eb !important;
  box-shadow: 0 8px 18px -12px rgba(37, 99, 235, 0.9) !important;
}

html[data-theme="dark"] #btnAddRow:hover {
  background: #2563eb !important;
}

/* Страховка: любые белые inline-подложки внутри таблицы смены */
html[data-theme="dark"] .handover-table-wrap [style*="background:#fff"],
html[data-theme="dark"] .handover-table-wrap [style*="background: #fff"],
html[data-theme="dark"] .handover-table-wrap [style*="background:#ffffff"],
html[data-theme="dark"] .handover-table-wrap [style*="background: #ffffff"] {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
}

/* Единый фон строк: цветом выделяем только статус, а не всю строку */
html[data-theme="dark"] tr.row-empty td,
html[data-theme="dark"] tr.row-filled td,
html[data-theme="dark"] tr.row-stale td {
  background: var(--ipg-surface) !important;
}

/* Акцентная полоса + мягкое свечение у левого края */
html[data-theme="dark"] tr.row-empty td.col-order {
  box-shadow: inset 5px 0 0 #ef4444 !important;
  background-image: linear-gradient(90deg, rgba(239, 68, 68, 0.18), rgba(239, 68, 68, 0) 110px) !important;
}

html[data-theme="dark"] tr.row-filled td.col-order {
  box-shadow: inset 5px 0 0 #22c55e !important;
  background-image: linear-gradient(90deg, rgba(34, 197, 94, 0.18), rgba(34, 197, 94, 0) 110px) !important;
}

html[data-theme="dark"] tr.row-stale td.col-order {
  box-shadow: inset 5px 0 0 #eab308 !important;
  background-image: linear-gradient(90deg, rgba(234, 179, 8, 0.20), rgba(234, 179, 8, 0) 110px) !important;
}

/* Убираем двойную полосу в колонке комментария */
html[data-theme="dark"] tr.row-empty td.col-comment,
html[data-theme="dark"] tr.row-filled td.col-comment,
html[data-theme="dark"] tr.row-stale td.col-comment {
  box-shadow: none !important;
}

/* Подсветка строки при наведении — чтобы было видно, где курсор */
html[data-theme="dark"] .excel-table tbody tr:hover td {
  background-color: #1b2a41 !important;
}

/* Мягкая цветная линия под всей строкой */
html[data-theme="dark"] tr.row-empty td {
  border-bottom-color: rgba(239, 68, 68, 0.35) !important;
}

html[data-theme="dark"] tr.row-filled td {
  border-bottom-color: rgba(34, 197, 94, 0.30) !important;
}

html[data-theme="dark"] tr.row-stale td {
  border-bottom-color: rgba(234, 179, 8, 0.35) !important;
}

/* Подсказка о «зависшей» строке */
html[data-theme="dark"] .stale-hint {
  background: #3a2e12 !important;
  border-color: #a16207 !important;
  color: #fcd34d !important;
}

/* Фильтр «без комментария» — без оранжевого */
html[data-theme="dark"] .handover-reminder .rem-filter {
  background: #12233f !important;
  color: #93c5fd !important;
  border-color: #1e3a8a !important;
}

html[data-theme="dark"] .handover-reminder .rem-filter a {
  color: #bfdbfe !important;
}

html[data-theme="dark"] .handover-reminder .rem-filter-link {
  color: #93c5fd !important;
}

html[data-theme="dark"] .comment-bubble .cb-text {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .comment-bubble.empty {
  background: #3a1717 !important;
  color: #fca5a5 !important;
}

html[data-theme="dark"] .comment-bubble.meta-empty {
  background: #3a2e12 !important;
  color: #fcd34d !important;
  border-color: #78350f !important;
}

html[data-theme="dark"] .handover-reminder .rem-hint {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .handover-reminder .rem-filter {
  background: #12233f !important;
  color: #93c5fd !important;
  border-color: #1e3a8a !important;
}

html[data-theme="dark"] .open-card-link {
  background: #12233f !important;
  color: #93c5fd !important;
  border-color: #1e3a8a !important;
}

html[data-theme="dark"] .btn-del-row {
  background: #3a1717 !important;
  color: #fca5a5 !important;
  border-color: #7f1d1d !important;
}

/* --------------------------------------------------------------------------
   История ТС
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .counter {
  background: #12233f !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .counter b {
  color: #60a5fa !important;
}

html[data-theme="dark"] .empty,
html[data-theme="dark"] .works-empty,
html[data-theme="dark"] .cart-empty,
html[data-theme="dark"] .toolbar-empty {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .empty-section {
  background: var(--ipg-bg-soft) !important;
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .otm-status.done {
  background: #123326 !important;
  color: #6ee7b7 !important;
  border-left-color: #10b981 !important;
}

html[data-theme="dark"] .otm-status.not-done {
  background: #3a1717 !important;
  color: #fca5a5 !important;
  border-left-color: #ef4444 !important;
}

html[data-theme="dark"] .filter-btn.active {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
}

/* --------------------------------------------------------------------------
   Инструкция
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .help-card,
html[data-theme="dark"] .help-doc,
html[data-theme="dark"] .help-page__container .card {
  background: var(--ipg-surface) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .help-doc__head {
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .help-doc__title {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .help-doc__open {
  color: #93c5fd !important;
}

html[data-theme="dark"] .help-toc__link {
  background: var(--ipg-surface-2) !important;
  border-color: var(--ipg-border) !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .help-toc__link:hover {
  background: #223451 !important;
  border-color: #3b4d68 !important;
  color: #e6edf7 !important;
}

html[data-theme="dark"] .help-empty {
  background: var(--ipg-surface) !important;
  color: var(--ipg-muted) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .help-toolbar {
  background: rgba(22, 35, 58, 0.9) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .help-hero__title {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .help-search {
  background: var(--ipg-input-bg) !important;
  border-color: var(--ipg-border) !important;
  color: var(--ipg-text) !important;
}

/* --------------------------------------------------------------------------
   Модальное окно «Что нового» и редактор кнопок
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .wn-overlay,
html[data-theme="dark"] .toolbar-editor-overlay {
  background: rgba(2, 6, 23, 0.7) !important;
}

html[data-theme="dark"] .wn-modal-head,
html[data-theme="dark"] .toolbar-editor-head {
  background: linear-gradient(135deg, #16233a 0%, #1a2b45 60%, #122a33 100%) !important;
}

html[data-theme="dark"] .wn-modal-title,
html[data-theme="dark"] .wn-toast-title,
html[data-theme="dark"] .toolbar-editor-head {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .wn-modal-close,
html[data-theme="dark"] .wn-toast-close,
html[data-theme="dark"] .toolbar-editor-close {
  background: #223451 !important;
  color: #cbd5e1 !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .toolbar-item button {
  background: #223451 !important;
  color: #cbd5e1 !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .toolbar-item button.tb-add {
  background: #123326 !important;
  border-color: #14532d !important;
  color: #6ee7b7 !important;
}

html[data-theme="dark"] .toolbar-item button.tb-remove {
  background: #3a1717 !important;
  border-color: #7f1d1d !important;
  color: #fca5a5 !important;
}

html[data-theme="dark"] .wn-toast-open {
  background: #2563eb !important;
  color: #ffffff !important;
}

/* --------------------------------------------------------------------------
   Inline-стили: фоны
   -------------------------------------------------------------------------- */
html[data-theme="dark"] [style*="background:#fff;"],
html[data-theme="dark"] [style*="background: #fff;"],
html[data-theme="dark"] [style*="background:#fff "],
html[data-theme="dark"] [style*="background: #fff "],
html[data-theme="dark"] [style*="background:#ffffff;"],
html[data-theme="dark"] [style*="background: #ffffff;"],
html[data-theme="dark"] [style*="background:white;"],
html[data-theme="dark"] [style*="background: white;"],
html[data-theme="dark"] [style*="background:#f8fafc"],
html[data-theme="dark"] [style*="background: #f8fafc"],
html[data-theme="dark"] [style*="background:#f9fafb"],
html[data-theme="dark"] [style*="background: #f9fafb"],
html[data-theme="dark"] [style*="background:#f1f5f9"],
html[data-theme="dark"] [style*="background: #f1f5f9"],
html[data-theme="dark"] [style*="background:#f0f2f5"],
html[data-theme="dark"] [style*="background: #f0f2f5"],
html[data-theme="dark"] [style*="background:#eff6ff"],
html[data-theme="dark"] [style*="background: #eff6ff"],
html[data-theme="dark"] [style*="background:#eef2ff"],
html[data-theme="dark"] [style*="background: #eef2ff"],
html[data-theme="dark"] [style*="background:#e2e8f0"],
html[data-theme="dark"] [style*="background: #e2e8f0"],
html[data-theme="dark"] [style$="background:#fff"],
html[data-theme="dark"] [style$="background: #fff"],
html[data-theme="dark"] [style$="background:#ffffff"],
html[data-theme="dark"] [style$="background: #ffffff"],
html[data-theme="dark"] [style*="background:#fff !important"],
html[data-theme="dark"] [style*="background: #fff !important"] {
  background: var(--ipg-surface) !important;
}

/* Мягкие цветные подложки */
html[data-theme="dark"] [style*="background:#fef2f2"],
html[data-theme="dark"] [style*="background: #fef2f2"],
html[data-theme="dark"] [style*="background:#fee2e2"],
html[data-theme="dark"] [style*="background: #fee2e2"] {
  background: #3a1717 !important;
}

html[data-theme="dark"] [style*="background:#f0fdf4"],
html[data-theme="dark"] [style*="background: #f0fdf4"],
html[data-theme="dark"] [style*="background:#ecfdf5"],
html[data-theme="dark"] [style*="background: #ecfdf5"],
html[data-theme="dark"] [style*="background:#dcfce7"],
html[data-theme="dark"] [style*="background: #dcfce7"] {
  background: #123326 !important;
}

html[data-theme="dark"] [style*="background:#fffbeb"],
html[data-theme="dark"] [style*="background: #fffbeb"],
html[data-theme="dark"] [style*="background:#fefce8"],
html[data-theme="dark"] [style*="background: #fefce8"],
html[data-theme="dark"] [style*="background:#fef9c3"],
html[data-theme="dark"] [style*="background: #fef9c3"],
html[data-theme="dark"] [style*="background:#fff7ed"],
html[data-theme="dark"] [style*="background: #fff7ed"],
html[data-theme="dark"] [style*="background:#ffedd5"],
html[data-theme="dark"] [style*="background: #ffedd5"] {
  background: #3a2e12 !important;
}

html[data-theme="dark"] [style*="background:#dbeafe"],
html[data-theme="dark"] [style*="background: #dbeafe"],
html[data-theme="dark"] [style*="background:#bfdbfe"],
html[data-theme="dark"] [style*="background: #bfdbfe"] {
  background: #12233f !important;
}

html[data-theme="dark"] [style*="background:#f5f3ff"],
html[data-theme="dark"] [style*="background: #f5f3ff"],
html[data-theme="dark"] [style*="background:#ede9fe"],
html[data-theme="dark"] [style*="background: #ede9fe"] {
  background: #241a3f !important;
}

/* --------------------------------------------------------------------------
   Inline-стили: текст
   -------------------------------------------------------------------------- */
html[data-theme="dark"] [style*="color:#0f172a"],
html[data-theme="dark"] [style*="color: #0f172a"],
html[data-theme="dark"] [style*="color:#1a1a1a"],
html[data-theme="dark"] [style*="color: #1a1a1a"],
html[data-theme="dark"] [style*="color:#1e293b"],
html[data-theme="dark"] [style*="color: #1e293b"],
html[data-theme="dark"] [style*="color:#111827"],
html[data-theme="dark"] [style*="color: #111827"],
html[data-theme="dark"] [style*="color:#000"],
html[data-theme="dark"] [style*="color: black"] {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] [style*="color:#334155"],
html[data-theme="dark"] [style*="color: #334155"],
html[data-theme="dark"] [style*="color:#475569"],
html[data-theme="dark"] [style*="color: #475569"],
html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color: #64748b"],
html[data-theme="dark"] [style*="color:#666"],
html[data-theme="dark"] [style*="color: #666"],
html[data-theme="dark"] [style*="color:#888"],
html[data-theme="dark"] [style*="color: #888"],
html[data-theme="dark"] [style*="color:#94a3b8"],
html[data-theme="dark"] [style*="color: #94a3b8"],
html[data-theme="dark"] [style*="color:#6b7280"],
html[data-theme="dark"] [style*="color: #6b7280"],
html[data-theme="dark"] [style*="color:#4b5563"],
html[data-theme="dark"] [style*="color: #4b5563"] {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] [style*="color:#dc2626"],
html[data-theme="dark"] [style*="color: #dc2626"],
html[data-theme="dark"] [style*="color:#b91c1c"],
html[data-theme="dark"] [style*="color: #b91c1c"],
html[data-theme="dark"] [style*="color:#991b1b"],
html[data-theme="dark"] [style*="color: #991b1b"] {
  color: #fca5a5 !important;
}

html[data-theme="dark"] [style*="color:#16a34a"],
html[data-theme="dark"] [style*="color: #16a34a"],
html[data-theme="dark"] [style*="color:#059669"],
html[data-theme="dark"] [style*="color: #059669"],
html[data-theme="dark"] [style*="color:#065f46"],
html[data-theme="dark"] [style*="color: #065f46"],
html[data-theme="dark"] [style*="color:#166534"],
html[data-theme="dark"] [style*="color: #166534"],
html[data-theme="dark"] [style*="color:#047857"],
html[data-theme="dark"] [style*="color: #047857"] {
  color: #6ee7b7 !important;
}

html[data-theme="dark"] [style*="color:#b45309"],
html[data-theme="dark"] [style*="color: #b45309"],
html[data-theme="dark"] [style*="color:#ca8a04"],
html[data-theme="dark"] [style*="color: #ca8a04"],
html[data-theme="dark"] [style*="color:#854d0e"],
html[data-theme="dark"] [style*="color: #854d0e"],
html[data-theme="dark"] [style*="color:#9a3412"],
html[data-theme="dark"] [style*="color: #9a3412"],
html[data-theme="dark"] [style*="color:#c2410c"],
html[data-theme="dark"] [style*="color: #c2410c"] {
  color: #fcd34d !important;
}

html[data-theme="dark"] [style*="color:#1e3a8a"],
html[data-theme="dark"] [style*="color: #1e3a8a"],
html[data-theme="dark"] [style*="color:#1d4ed8"],
html[data-theme="dark"] [style*="color: #1d4ed8"],
html[data-theme="dark"] [style*="color:#2563eb"],
html[data-theme="dark"] [style*="color: #2563eb"] {
  color: #93c5fd !important;
}

/* --------------------------------------------------------------------------
   Inline-стили: границы
   -------------------------------------------------------------------------- */
html[data-theme="dark"] [style*="border: 1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border:1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border: 1.5px solid #e2e8f0"],
html[data-theme="dark"] [style*="border-bottom: 1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border-bottom:1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border-top: 1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border-top:1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border-right: 1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border-right:1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border: 1px solid #cbd5e1"],
html[data-theme="dark"] [style*="border:1px solid #cbd5e1"],
html[data-theme="dark"] [style*="border: 1px solid #f1f5f9"],
html[data-theme="dark"] [style*="border:1px solid #f1f5f9"] {
  border-color: var(--ipg-border) !important;
}

/* --------------------------------------------------------------------------
   «РА не предъявлены» (ra_reminder.php)
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .ra-reminder-box {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
  border: 1px solid var(--ipg-border) !important;
}

html[data-theme="dark"] .ra-reminder-head {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
  border-bottom-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .ra-reminder-head-icon {
  background: linear-gradient(135deg, #422006, #78350f) !important;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.35) !important;
}

html[data-theme="dark"] .ra-reminder-hint > summary {
  background: #1e2f4d !important;
  border-color: #2f4a72 !important;
  color: #c7d2fe !important;
}

html[data-theme="dark"] .ra-reminder-hint > summary:hover,
html[data-theme="dark"] .ra-reminder-hint[open] > summary {
  background: #24395c !important;
}

html[data-theme="dark"] .ra-reminder-hint-body {
  background: var(--ipg-surface-2) !important;
  color: var(--ipg-muted) !important;
  border: 1px solid var(--ipg-border) !important;
}

html[data-theme="dark"] .ra-search-icon {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .ra-reset-btn {
  background: rgba(220, 38, 38, 0.16) !important;
  border-color: rgba(248, 113, 113, 0.45) !important;
  color: #fca5a5 !important;
}

html[data-theme="dark"] .ra-reset-btn:hover {
  background: rgba(220, 38, 38, 0.28) !important;
}

html[data-theme="dark"] .ra-reminder-filters {
  background: var(--ipg-bg-soft) !important;
  border-bottom-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .ra-filter-label {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .ra-chip {
  background: var(--ipg-surface-2) !important;
  border-color: var(--ipg-border) !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .ra-chip:hover {
  background: #223451 !important;
}

html[data-theme="dark"] .ra-chip.active {
  background: #ea580c !important;
  border-color: #ea580c !important;
  color: #ffffff !important;
}

html[data-theme="dark"] .ra-reminder-search {
  background: var(--ipg-input-bg) !important;
  border-color: var(--ipg-border) !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .ra-reminder-search::placeholder {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .ra-reminder-close {
  background: var(--ipg-surface-2) !important;
  border-color: var(--ipg-border) !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .ra-reminder-close:hover {
  background: #223451 !important;
}

html[data-theme="dark"] .ra-card-head {
  background: var(--ipg-surface-2) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .ra-card-num {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .ra-card-client {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .ra-card-count {
  background: #223451 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .ra-card-link {
  color: #93c5fd !important;
}

html[data-theme="dark"] .ra-fault-row {
  border-bottom-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .ra-fault-desc {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .ra-fault-meta {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .ra-reminder-select {
  background: var(--ipg-input-bg) !important;
  border-color: var(--ipg-border) !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .ra-reminder-empty {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .ra-reminder-close--float {
  background: var(--ipg-surface-2) !important;
  border-color: var(--ipg-border) !important;
  color: var(--ipg-text) !important;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.85) !important;
}

html[data-theme="dark"] .ra-reminder-title {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .ra-reminder-subtitle {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .ra-tab {
  background: var(--ipg-surface-2) !important;
  border-color: var(--ipg-border) !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .ra-tab:hover {
  border-color: #3b82f6 !important;
}

html[data-theme="dark"] .ra-tab.active {
  background: #1e2f4d !important;
  border-color: #6366f1 !important;
  color: #c7d2fe !important;
}

html[data-theme="dark"] .ra-tab .cnt {
  background: #223451 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .ra-tab.active .cnt {
  background: #3730a3 !important;
  color: #e0e7ff !important;
}

html[data-theme="dark"] .ra-brand {
  background: var(--ipg-surface) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .ra-brand-head {
  background: linear-gradient(135deg, #1e40af, #0e7490) !important;
  color: #f8fafc !important;
}

html[data-theme="dark"] .ra-brand-body {
  background: var(--ipg-surface) !important;
}

html[data-theme="dark"] .ra-card-group {
  background: var(--ipg-surface) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .ra-card-link {
  background: #1e2f4d !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .ra-card-link:hover {
  background: #25395c !important;
}

html[data-theme="dark"] .ra-fault-row:hover {
  background: #16273f !important;
}

html[data-theme="dark"] .ra-overdue.lvl-1 {
  background: #422006 !important;
  color: #fbbf24 !important;
}

html[data-theme="dark"] .ra-overdue.lvl-2 {
  background: #450a0a !important;
  color: #f87171 !important;
}

html[data-theme="dark"] .ra-row-state {
  color: #34d399 !important;
}

html[data-theme="dark"] .ra-row-state.is-err {
  color: #f87171 !important;
}

/* --------------------------------------------------------------------------
   Поиск по VIN (search_vin.php)
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .vin-summary {
  background: linear-gradient(135deg, #12233f, #0f2e3a) !important;
  border-left-color: #3b82f6 !important;
}

html[data-theme="dark"] .vin-summary-title {
  color: #bfdbfe !important;
}

html[data-theme="dark"] .vin-summary-sub {
  color: #93c5fd !important;
}

html[data-theme="dark"] .section-title {
  color: #93c5fd !important;
  border-bottom-color: #1e3a8a !important;
}

html[data-theme="dark"] .field-row {
  border-bottom-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .field-label {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .field-value {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .search-empty {
  background: var(--ipg-bg-soft) !important;
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .warranty-banner.yes {
  background: linear-gradient(135deg, #0f2e22, #123326) !important;
  color: #6ee7b7 !important;
  border-left-color: #10b981 !important;
}

html[data-theme="dark"] .warranty-banner.no {
  background: linear-gradient(135deg, #3a1717, #3f1d1d) !important;
  color: #fca5a5 !important;
  border-left-color: #ef4444 !important;
}

html[data-theme="dark"] .warranty-banner.test {
  background: linear-gradient(135deg, #12233f, #16294a) !important;
  color: #93c5fd !important;
  border-left-color: #3b82f6 !important;
}

html[data-theme="dark"] .warranty-banner.test-done {
  background: linear-gradient(135deg, #1b2a41, #223451) !important;
  color: #cbd5e1 !important;
  border-left-color: #94a3b8 !important;
}

html[data-theme="dark"] .warranty-banner.warn {
  background: linear-gradient(135deg, #3a2e12, #42340f) !important;
  color: #fcd34d !important;
  border-left-color: #f59e0b !important;
}

html[data-theme="dark"] .warranty-banner::before {
  box-shadow: none !important;
}

html[data-theme="dark"] .warranty-banner .banner-sub {
  background: rgba(11, 18, 32, 0.55) !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .warranty-banner .banner-sub .row {
  border-bottom-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .warranty-banner .banner-sub .row .label {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .warranty-banner .banner-sub .row .value {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .warranty-banner .calc-note {
  color: #fcd34d !important;
}

/* --------------------------------------------------------------------------
   Поиск работ — корзина и итоги (works.php)
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .cart-item {
  border-bottom-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .cart-item-code {
  color: #fcd34d !important;
}

html[data-theme="dark"] .cart-item-name {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .cart-item-hours {
  background: #12233f !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .cart-remove {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .cart-remove:hover {
  color: #fca5a5 !important;
}

html[data-theme="dark"] .cart-qty-input {
  background: var(--ipg-input-bg) !important;
  border-color: var(--ipg-border) !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .cart-total {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .cart-total b {
  color: #93c5fd !important;
}

html[data-theme="dark"] .cart-empty {
  color: var(--ipg-muted) !important;
}

/* --------------------------------------------------------------------------
   Генератор писем — панель кнопок (letter_form.php)
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .lg-wrap {
  --lg-line: var(--ipg-border);
  --lg-ink: var(--ipg-text);
}

html[data-theme="dark"] .lg-toolbar {
  background: var(--ipg-surface) !important;
  border-color: var(--ipg-border) !important;
  box-shadow: var(--ipg-shadow) !important;
}

html[data-theme="dark"] .lg-inline {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .lg-btn {
  background: var(--ipg-surface-2) !important;
  border-color: var(--ipg-border) !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .lg-btn:hover {
  background: #223451 !important;
  border-color: #3b4d68 !important;
}

/* --------------------------------------------------------------------------
   Главная страница — имя пользователя (index.html)
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .topbar .uname {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .topbar .uname b {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .topbar .user-nav a.profile {
  background: #12233f !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .topbar .user-nav a.profile:hover {
  background: #16294a !important;
}

html[data-theme="dark"] .topbar .user-nav a.admin {
  background: #3a1717 !important;
  color: #fca5a5 !important;
}

html[data-theme="dark"] .topbar .user-nav a.admin:hover {
  background: #4a1c1c !important;
}

html[data-theme="dark"] .topbar .user-nav a.help {
  background: #241a3f !important;
  color: #c4b5fd !important;
}

html[data-theme="dark"] .topbar .user-nav a.help:hover {
  background: #2e2150 !important;
}

html[data-theme="dark"] .topbar .user-nav a.logout {
  background: var(--ipg-surface-2) !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .topbar .user-nav a.logout:hover {
  background: #223451 !important;
}

/* --------------------------------------------------------------------------
   Фото по РА — пустые плитки и заголовки неисправностей (gallery.php)
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .photo-empty-slot {
  background: var(--ipg-bg-soft) !important;
  border-color: var(--ipg-border) !important;
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .photo-empty-slot:hover {
  border-color: #3b82f6 !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .fault-title-wrap {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .fault-title-wrap > span {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .fault-title-wrap > span > a {
  color: var(--ipg-muted) !important;
}

/* --------------------------------------------------------------------------
   Фото по РА — PDF-редактор и карточка ТС (gallery.php)
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .pdf-editor-shell,
html[data-theme="dark"] .pdf-editor-head,
html[data-theme="dark"] .pdf-editor-foot {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .pdf-editor-head h3 {
  color: #c4b5fd !important;
}

html[data-theme="dark"] .pdf-editor-toolbar,
html[data-theme="dark"] .pdf-editor-body {
  background: var(--ipg-bg-soft) !important;
  color: var(--ipg-text) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] #pdfPagesGrid .photo-card {
  background: var(--ipg-surface) !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .card-type-select,
html[data-theme="dark"] .card-custom-caption,
html[data-theme="dark"] .card-date-input {
  background: var(--ipg-input-bg) !important;
  border-color: var(--ipg-border) !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .card-label,
html[data-theme="dark"] .meta-created-date {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .meta-created-date b,
html[data-theme="dark"] .fault-badge-list b {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .fault-badge-list {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .badge-missing {
  background: #3a2e12 !important;
  color: #fcd34d !important;
  border-color: #78350f !important;
}

html[data-theme="dark"] .modal-small h3 {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .modal-small p {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .vc-tab {
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .vc-tab.vc-active {
  background: #12233f !important;
  color: #93c5fd !important;
  border-color: #1e3a8a !important;
}

html[data-theme="dark"] .vc-item::before {
  background: var(--ipg-surface) !important;
  box-shadow: 0 0 0 3px var(--ipg-surface) !important;
}

/* --------------------------------------------------------------------------
   Переключатель темы (главная страница)
   -------------------------------------------------------------------------- */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
}

.theme-switch button {
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 15px;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.theme-switch button:hover {
  background: #eef2ff;
  color: #1d4ed8;
}

.theme-switch button.is-active {
  background: #2563eb;
  color: #ffffff;
}

html[data-theme="dark"] .theme-switch {
  background: #16233a;
  border-color: #2b3a52;
}

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

html[data-theme="dark"] .theme-switch button:hover {
  background: #223451;
  color: #e6edf7;
}

html[data-theme="dark"] .theme-switch button.is-active {
  background: #2563eb;
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Гарантия по VIN (header.php) — заголовок и раскрытые детали
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .ipg-guar-title {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] #warrantyDetails {
  background: var(--ipg-bg-soft) !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] #warrantyDetails .warranty-details,
html[data-theme="dark"] #warrantyDetails .warranty-info {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] #warrantyDetails .warranty-info .label,
html[data-theme="dark"] #warrantyDetails .warranty-row .label {
  color: var(--ipg-muted) !important;
}

/* Таблицы внутри раскрытой гарантии приходят из JS с inline-стилями */
html[data-theme="dark"] #warrantyDetails [style*="background: #fff"],
html[data-theme="dark"] #warrantyDetails [style*="background:#fff"] {
  background: var(--ipg-surface) !important;
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] #warrantyDetails [style*="border-bottom: 1px dashed #cbd5e1"],
html[data-theme="dark"] #warrantyDetails [style*="border-bottom:1px dashed #cbd5e1"] {
  border-bottom-color: var(--ipg-border) !important;
}

html[data-theme="dark"] [style*="background:#f0fdf4"],
html[data-theme="dark"] [style*="background: #f0fdf4"] {
  background: #123326 !important;
}

html[data-theme="dark"] [style*="color:#6d28d9"],
html[data-theme="dark"] [style*="color: #6d28d9"] {
  color: #c4b5fd !important;
}

/* --------------------------------------------------------------------------
   Кнопки-«призраки» и вторичные (шапка, «Открыть все» и т.п.)
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .btn-ghost {
  background: var(--ipg-surface-2) !important;
  color: #cbd5e1 !important;
  border-color: var(--ipg-border) !important;
}

html[data-theme="dark"] .btn-ghost:hover {
  background: #223451 !important;
  color: var(--ipg-text) !important;
  border-color: #3b4d68 !important;
}

html[data-theme="dark"] .btn-secondary {
  background: #12233f !important;
  color: #93c5fd !important;
  border-color: #1e3a8a !important;
}

html[data-theme="dark"] .btn-secondary:hover {
  background: #16294a !important;
  border-color: #2563eb !important;
}

html[data-theme="dark"] .toolbar-icon-btn {
  background: var(--ipg-surface-2) !important;
  color: #cbd5e1 !important;
  border-color: var(--ipg-border) !important;
}

/* --------------------------------------------------------------------------
   Кнопки «Скачать» / «Удалить» под фото (gallery.php)
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .photo-actions a.action-dl {
  background: #123326 !important;
  color: #6ee7b7 !important;
}

html[data-theme="dark"] .photo-actions a.action-dl:hover {
  background: #14532d !important;
  color: #a7f3d0 !important;
}

html[data-theme="dark"] .photo-actions a.action-del {
  background: #3a1717 !important;
  color: #fca5a5 !important;
}

html[data-theme="dark"] .photo-actions a.action-del:hover {
  background: #4a1c1c !important;
  color: #fecaca !important;
}

html[data-theme="dark"] .filename {
  color: var(--ipg-link) !important;
}

/* Кнопка «+ Ещё N фото» / «Открыть все» на телефоне */
html[data-theme="dark"] .mobile-gallery-toggle {
  background: linear-gradient(135deg, #12233f, #16294a) !important;
  border-color: #1e3a8a !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .mobile-gallery-toggle[aria-expanded="true"] {
  background: linear-gradient(135deg, #1b2a41, #223451) !important;
  border-color: var(--ipg-border) !important;
  color: #cbd5e1 !important;
}

/* --------------------------------------------------------------------------
   Список неисправностей в карточках ТС (gallery.php)
   -------------------------------------------------------------------------- */
html[data-theme="dark"] .fault-row-desc {
  color: var(--ipg-text) !important;
}

html[data-theme="dark"] .fault-count {
  background: var(--ipg-surface-2) !important;
  color: var(--ipg-muted) !important;
}

html[data-theme="dark"] .fault-status-badge.status-new {
  background: #12233f !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .fault-status-badge.status-diagnostics {
  background: #241a3f !important;
  color: #c4b5fd !important;
}

html[data-theme="dark"] .fault-status-badge.status-in-progress {
  background: #3a2e12 !important;
  color: #fcd34d !important;
}

html[data-theme="dark"] .fault-status-badge.status-waiting-parts {
  background: #431407 !important;
  color: #fdba74 !important;
}

html[data-theme="dark"] .fault-status-badge.status-ra-submitted {
  background: #123326 !important;
  color: #6ee7b7 !important;
}

html[data-theme="dark"] .fault-status-select.status-new {
  background: #12233f !important;
  border-color: #1e3a8a !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .fault-status-select.status-diagnostics {
  background: #241a3f !important;
  border-color: #5b21b6 !important;
  color: #c4b5fd !important;
}

html[data-theme="dark"] .fault-status-select.status-in-progress {
  background: #3a2e12 !important;
  border-color: #a16207 !important;
  color: #fcd34d !important;
}

html[data-theme="dark"] .fault-status-select.status-waiting-parts {
  background: #431407 !important;
  border-color: #c2410c !important;
  color: #fdba74 !important;
}

html[data-theme="dark"] .fault-status-select.status-ra-submitted {
  background: #123326 !important;
  border-color: #047857 !important;
  color: #6ee7b7 !important;
}

/* Плашки гарантии в карточках (inline-стили) */
html[data-theme="dark"] [style*="background:#f0f9ff"],
html[data-theme="dark"] [style*="background: #f0f9ff"] {
  background: #0f2e3a !important;
}

html[data-theme="dark"] [style*="color:#0369a1"],
html[data-theme="dark"] [style*="color: #0369a1"] {
  color: #7dd3fc !important;
}

/* --------------------------------------------------------------------------
   Мобильная адаптация
   -------------------------------------------------------------------------- */
@media (max-width: 700px) {
  .theme-switch button { padding: 7px 9px; }

  /* Название неисправности должно оставаться светлым и на телефоне:
     gallery.css задаёт тёмный цвет в media-запросе. */
  html[data-theme="dark"] .fault-title-wrap,
  html[data-theme="dark"] .fault-title-wrap > span {
    color: var(--ipg-text) !important;
  }

  html[data-theme="dark"] .fault-title-wrap > span > a {
    color: var(--ipg-muted) !important;
  }

  /* Пустые плитки фото на телефоне — компактнее */
  html[data-theme="dark"] .photo-empty-slot {
    min-height: 160px !important;
  }

  /* Поиск по VIN: гарантийные баннеры и сводка */
  html[data-theme="dark"] .vin-summary {
    padding: 12px 14px !important;
    gap: 10px !important;
  }

  html[data-theme="dark"] .vin-summary-title {
    font-size: 15px !important;
  }

  html[data-theme="dark"] .warranty-banner {
    padding: 16px 14px !important;
    font-size: 16px !important;
  }

  html[data-theme="dark"] .warranty-banner .banner-sub {
    padding: 10px 12px !important;
  }

  html[data-theme="dark"] .warranty-banner .banner-sub .row {
    gap: 4px !important;
  }

  html[data-theme="dark"] .warranty-banner .banner-sub .row .value {
    text-align: left !important;
  }

  /* «РА не предъявлены» */
  html[data-theme="dark"] .ra-reminder-box {
    max-height: calc(100vh - 20px) !important;
  }

  html[data-theme="dark"] .ra-reminder-head {
    padding: 12px 58px 12px 14px !important;
    font-size: 16px !important;
  }

  html[data-theme="dark"] .ra-reminder-filters {
    padding: 8px 12px !important;
  }

  html[data-theme="dark"] .ra-fault-row {
    flex-direction: column !important;
  }

  html[data-theme="dark"] .ra-fault-actions,
  html[data-theme="dark"] .ra-fault-actions .ra-reminder-select {
    width: 100% !important;
    max-width: none !important;
  }

  /* Корзина поиска работ */
  html[data-theme="dark"] .cart-foot {
    padding: 12px 14px 14px !important;
  }

  html[data-theme="dark"] .cart-total {
    font-size: 13px !important;
  }

  html[data-theme="dark"] .cart-total b {
    font-size: 18px !important;
  }

  /* Панель кнопок генератора писем */
  html[data-theme="dark"] .lg-toolbar {
    padding: 8px 10px !important;
  }

  /* Передача смены: горизонтальный скролл и читаемый текст */
  html[data-theme="dark"] .excel-table td,
  html[data-theme="dark"] .excel-table td * {
    color: var(--ipg-text) !important;
  }

  html[data-theme="dark"] .excel-table td .editable {
    background: transparent !important;
  }

  html[data-theme="dark"] .editable:empty::before {
    color: var(--ipg-muted) !important;
  }

  /* Главная: имя пользователя на телефоне скрыто, но если показывается — светлое */
  html[data-theme="dark"] .topbar .uname,
  html[data-theme="dark"] .topbar .uname b {
    color: var(--ipg-text) !important;
  }
}
