/* ============================================================
   ТЁМНАЯ ТЕМА — общие переопределения для всего приложения.
   Подключается последним, чтобы перекрыть светлые стили секций.
   ============================================================ */

html[data-theme="dark"] {
    color-scheme: dark;
    --bg-app: #0F172A;
    --bg-card: #1E293B;
    --bg-soft: #273449;
    --text-app: #E2E8F0;
    --text-muted: #94A3B8;
    --border-app: #334155;
}

html[data-theme="dark"] body {
    background-color: #0F172A !important;
    color: #E2E8F0 !important;
}

/* ---------- Фоны ---------- */
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .bg-slate-50,
html[data-theme="dark"] .bg-gray-50 { background-color: #1E293B !important; }

html[data-theme="dark"] .bg-slate-100,
html[data-theme="dark"] .bg-gray-100 { background-color: #273449 !important; }

html[data-theme="dark"] .bg-slate-200,
html[data-theme="dark"] .bg-gray-200 { background-color: #334155 !important; }

html[data-theme="dark"] .bg-white\/80,
html[data-theme="dark"] .bg-white\/90 { background-color: rgba(30, 41, 59, .92) !important; }

/* ---------- Текст ---------- */
html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-slate-900,
html[data-theme="dark"] .text-slate-800,
html[data-theme="dark"] .text-gray-900,
html[data-theme="dark"] .text-gray-800,
html[data-theme="dark"] .text-black { color: #F1F5F9 !important; }

html[data-theme="dark"] .text-slate-700,
html[data-theme="dark"] .text-slate-600,
html[data-theme="dark"] .text-gray-700,
html[data-theme="dark"] .text-gray-600 { color: #CBD5E1 !important; }

html[data-theme="dark"] .text-slate-500,
html[data-theme="dark"] .text-slate-400,
html[data-theme="dark"] .text-gray-500,
html[data-theme="dark"] .text-gray-400,
html[data-theme="dark"] .text-muted { color: #94A3B8 !important; }

/* ---------- Границы ---------- */
html[data-theme="dark"] .border-slate-100,
html[data-theme="dark"] .border-slate-200,
html[data-theme="dark"] .border-slate-300,
html[data-theme="dark"] .border-gray-100,
html[data-theme="dark"] .border-gray-200 { border-color: #334155 !important; }

html[data-theme="dark"] .divide-slate-100 > :not([hidden]) ~ :not([hidden]),
html[data-theme="dark"] .divide-slate-200 > :not([hidden]) ~ :not([hidden]) { border-color: #334155 !important; }

/* ---------- Инпуты и кнопки ---------- */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background-color: #0F172A !important;
    border-color: #334155 !important;
    color: #F1F5F9 !important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #64748B !important; }

html[data-theme="dark"] .hover\:bg-slate-50:hover,
html[data-theme="dark"] .hover\:bg-slate-100:hover,
html[data-theme="dark"] .hover\:bg-white:hover { background-color: #334155 !important; }

/* ---------- Карточки и панели ---------- */
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .section-card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .report-card,
html[data-theme="dark"] .task-card,
html[data-theme="dark"] .stay-card,
html[data-theme="dark"] .stay-dialog,
html[data-theme="dark"] .stay-workspace,
html[data-theme="dark"] .stay-list,
html[data-theme="dark"] .stay-composer,
html[data-theme="dark"] .chat-msg,
html[data-theme="dark"] .drawer-panel,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .modal-panel {
    background-color: #1E293B !important;
    color: #E2E8F0 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .section-title,
html[data-theme="dark"] .task-day-title,
html[data-theme="dark"] .stay-list-title,
html[data-theme="dark"] .stay-dialog-name,
html[data-theme="dark"] .stay-card-title,
html[data-theme="dark"] .settings-title,
html[data-theme="dark"] .report-title { color: #F1F5F9 !important; }

html[data-theme="dark"] .section-preview,
html[data-theme="dark"] .task-object-name,
html[data-theme="dark"] .stay-dialog-sub,
html[data-theme="dark"] .stay-muted,
html[data-theme="dark"] .chat-empty { color: #94A3B8 !important; }

html[data-theme="dark"] .stay-sidebar,
html[data-theme="dark"] .settings-sidebar {
    background-color: #111C2E !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .settings-nav-item:hover,
html[data-theme="dark"] .stay-dialog:hover { background-color: #273449 !important; }
html[data-theme="dark"] .settings-nav-item.active,
html[data-theme="dark"] .stay-dialog.active { background-color: #1D4ED8 !important; color: #fff !important; }

html[data-theme="dark"] .chat-input,
html[data-theme="dark"] .stay-search,
html[data-theme="dark"] .stay-chat-input { background-color: #0F172A !important; color: #F1F5F9 !important; border-color: #334155 !important; }

html[data-theme="dark"] .ev-in,
html[data-theme="dark"] .ev-out { background-color: #273449 !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .ev-row.right .ev-out { background-color: #1E3A8A !important; }
html[data-theme="dark"] .stay-chat-bubble { background-color: #273449 !important; }
html[data-theme="dark"] .stay-chat-row.outgoing .stay-chat-bubble { background-color: #1E3A8A !important; }
html[data-theme="dark"] .stay-chat-text { color: #E2E8F0 !important; }

/* ---------- Шахматка ---------- */
html[data-theme="dark"] .chessboard-container { background-color: #0F172A !important; }
html[data-theme="dark"] #chessboardScroll,
html[data-theme="dark"] .chessboard-table,
html[data-theme="dark"] .chessboard-table tbody,
html[data-theme="dark"] .chessboard-table tr,
html[data-theme="dark"] .chessboard-table td { background-color: #0F172A !important; color: #E2E8F0 !important; }

html[data-theme="dark"] .chessboard-table thead th { background-color: #1E293B !important; color: #CBD5E1 !important; border-color: #334155 !important; }
html[data-theme="dark"] .chessboard-table .sticky-obj { background-color: #1E293B !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .chessboard-table td:not(.sticky-obj) { border-color: #1E293B !important; }
html[data-theme="dark"] .chessboard-table .date-cell { color: #CBD5E1 !important; }
html[data-theme="dark"] .chessboard-table .price-label,
html[data-theme="dark"] .chessboard-table .price { color: #94A3B8 !important; }
html[data-theme="dark"] .nav-arrow { background: #1E293B !important; border-color: #334155 !important; }
html[data-theme="dark"] .nav-arrow-label { color: #CBD5E1 !important; }

html[data-theme="dark"] .today-overlay { background: rgba(59, 130, 246, 0.12) !important; }

/* ---------- Прочее ---------- */
html[data-theme="dark"] .shadow-lg,
html[data-theme="dark"] .shadow-xl,
html[data-theme="dark"] .shadow-2xl { box-shadow: 0 10px 30px rgba(0, 0, 0, .45) !important; }

html[data-theme="dark"] .bg-slate-900\/60 { background-color: rgba(0, 0, 0, .7) !important; }

/* ---------- Карточки объектов/локаций ---------- */
html[data-theme="dark"] .loc-card,
html[data-theme="dark"] .obj-card {
    background-color: #1E293B !important;
    border-color: #334155 !important;
    color: #E2E8F0 !important;
}
html[data-theme="dark"] .obj-count {
    background-color: #334155 !important;
    color: #CBD5E1 !important;
}
html[data-theme="dark"] .loc-card .text-slate-800,
html[data-theme="dark"] .obj-card .text-slate-800,
html[data-theme="dark"] .loc-card .text-slate-900,
html[data-theme="dark"] .obj-card .text-slate-900 { color: #F1F5F9 !important; }

/* Перебиваем принудительно светлую шахматку */
html[data-theme="dark"] .chessboard-container { background-color: #0F172A !important; }
html[data-theme="dark"] .chessboard-container .bg-white { background-color: #1E293B !important; }
html[data-theme="dark"] .chessboard-container .bg-slate-50 { background-color: #273449 !important; }
html[data-theme="dark"] .chessboard-container .text-dark,
html[data-theme="dark"] .chessboard-container .text-slate-800,
html[data-theme="dark"] .chessboard-container .text-slate-900 { color: #F1F5F9 !important; }

/* ---------- Задачи ---------- */
html[data-theme="dark"] .task-card,
html[data-theme="dark"] .task-day,
html[data-theme="dark"] .task-filters { background-color: #1E293B !important; border-color: #334155 !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .task-title,
html[data-theme="dark"] .task-day-title { color: #F1F5F9 !important; }
html[data-theme="dark"] .task-meta,
html[data-theme="dark"] .task-object-name { color: #94A3B8 !important; }
html[data-theme="dark"] .task-card.completed { opacity: .65; }
html[data-theme="dark"] .task-card.overdue { border-color: #7F1D1D !important; }

/* ---------- Отчёты ---------- */
html[data-theme="dark"] .rep-card,
html[data-theme="dark"] .rep-header,
html[data-theme="dark"] .rep-body { background-color: #1E293B !important; border-color: #334155 !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .rep-card-title,
html[data-theme="dark"] .rep-range { color: #CBD5E1 !important; }
html[data-theme="dark"] .rep-tab,
html[data-theme="dark"] .period-toggle-btn { background-color: #273449 !important; color: #CBD5E1 !important; }
html[data-theme="dark"] .rep-tab.active,
html[data-theme="dark"] .period-toggle-btn.active { background-color: #1D4ED8 !important; color: #fff !important; }
html[data-theme="dark"] .rep-btn { background-color: #273449 !important; color: #E2E8F0 !important; border-color: #334155 !important; }

/* ---------- Проживание и чат ---------- */
html[data-theme="dark"] .stay-header,
html[data-theme="dark"] .stay-toolbar,
html[data-theme="dark"] .stay-dialog-header,
html[data-theme="dark"] .stay-composer,
html[data-theme="dark"] .stay-events { background-color: #1E293B !important; border-color: #334155 !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .stay-dialog-name,
html[data-theme="dark"] .stay-dialog-preview,
html[data-theme="dark"] .stay-event-text,
html[data-theme="dark"] .stay-chat-author { color: #E2E8F0 !important; }
html[data-theme="dark"] .stay-dialog-time,
html[data-theme="dark"] .stay-event-time { color: #94A3B8 !important; }
html[data-theme="dark"] .stay-chat-bubble { background-color: #273449 !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .stay-chat-row.out .stay-chat-bubble,
html[data-theme="dark"] .stay-chat-row.outgoing .stay-chat-bubble { background-color: #1E3A8A !important; }

/* ---------- Drawer / модалки / формы ---------- */
html[data-theme="dark"] .drawer-panel,
html[data-theme="dark"] .modal-drawer-panel,
html[data-theme="dark"] .modal-card { background-color: #1E293B !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .drawer-header,
html[data-theme="dark"] .drawer-footer,
html[data-theme="dark"] .modal-drawer-panel .border-b,
html[data-theme="dark"] .modal-drawer-panel .border-t { border-color: #334155 !important; }
html[data-theme="dark"] .dt-date-value,
html[data-theme="dark"] .dt-contact,
html[data-theme="dark"] .dt-house,
html[data-theme="dark"] .dt-price,
html[data-theme="dark"] .drawer-panel h2,
html[data-theme="dark"] .drawer-panel h3,
html[data-theme="dark"] .drawer-panel label { color: #E2E8F0 !important; }

/* ---------- Быстрые ответы / уведомления / тариф ---------- */
html[data-theme="dark"] .quick-reply,
html[data-theme="dark"] .qr-card,
html[data-theme="dark"] .notification-row,
html[data-theme="dark"] .plan-card { background-color: #1E293B !important; border-color: #334155 !important; color: #E2E8F0 !important; }

/* Точечные элементы, которые оставались светлыми */
html[data-theme="dark"] .drawer-footer { background-color: #1E293B !important; border-color: #334155 !important; }
html[data-theme="dark"] .dt-dates { background-color: #273449 !important; border-color: #334155 !important; }
html[data-theme="dark"] .dt-date-label,
html[data-theme="dark"] .dt-date-value,
html[data-theme="dark"] .dt-nights { color: #E2E8F0 !important; }
html[data-theme="dark"] .kpi-card { background-color: #1E293B !important; border-color: #334155 !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .bg-slate-50\/60 { background-color: rgba(39, 52, 73, .6) !important; }
html[data-theme="dark"] .task-filters button { background-color: #273449 !important; color: #CBD5E1 !important; border-color: #334155 !important; }
html[data-theme="dark"] .task-filters button.active { background-color: #1D4ED8 !important; color: #fff !important; }

/* ---------- Текст, который был #0f172a ---------- */
html[data-theme="dark"] .kpi-value,
html[data-theme="dark"] .rep-card-title,
html[data-theme="dark"] .donut-row b,
html[data-theme="dark"] .top-name,
html[data-theme="dark"] .top-revenue,
html[data-theme="dark"] .exp-title,
html[data-theme="dark"] .exp-amount,
html[data-theme="dark"] .breadcrumb .current,
html[data-theme="dark"] .task-day-title,
html[data-theme="dark"] .task-title,
html[data-theme="dark"] .detail-title,
html[data-theme="dark"] .detail-grid b,
html[data-theme="dark"] .stay-list-title,
html[data-theme="dark"] .stay-dialog-name,
html[data-theme="dark"] .stay-ws-left h2,
html[data-theme="dark"] .stay-card-title,
html[data-theme="dark"] .stay-dep-val,
html[data-theme="dark"] .qr-title,
html[data-theme="dark"] .dt-date-value,
html[data-theme="dark"] .dt-phone,
html[data-theme="dark"] .price-day-row .day-price { color: #F1F5F9 !important; }

/* ---------- Детали задачи ---------- */
html[data-theme="dark"] .detail-head,
html[data-theme="dark"] .detail-section,
html[data-theme="dark"] .detail-grid { background-color: #1E293B !important; border-color: #334155 !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .detail-text,
html[data-theme="dark"] .detail-text.muted { color: #94A3B8 !important; }
html[data-theme="dark"] .detail-section + .detail-section { border-top-color: #334155 !important; }

/* ---------- Управление проживанием ---------- */
html[data-theme="dark"] #view-stay { background: #0F172A !important; }
html[data-theme="dark"] .stay-list,
html[data-theme="dark"] .stay-select,
html[data-theme="dark"] .stay-booking-card,
html[data-theme="dark"] .stay-btn,
html[data-theme="dark"] .stay-composer-tools button,
html[data-theme="dark"] .msg-filter-btn,
html[data-theme="dark"] .stay-pager button { background: #1E293B !important; color: #E2E8F0 !important; border-color: #334155 !important; }
html[data-theme="dark"] .stay-dialog:hover { background: #273449 !important; }
html[data-theme="dark"] .stay-dialog.active,
html[data-theme="dark"] .stay-dialog.has-unread { background: #1E3A8A !important; border-color: #1D4ED8 !important; }
html[data-theme="dark"] .stay-ws-left,
html[data-theme="dark"] .stay-ws-main,
html[data-theme="dark"] .stay-ws-right,
html[data-theme="dark"] .stay-ws-aside { background: #0F172A !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .stay-card { background: #1E293B !important; border-color: #334155 !important; }
html[data-theme="dark"] .stay-progress { background: #334155 !important; }
html[data-theme="dark"] .stay-wf-line { background: #334155 !important; }
html[data-theme="dark"] .stay-wf-dot { background: #334155 !important; color: #CBD5E1 !important; }
html[data-theme="dark"] .stay-warn { background: #422006 !important; border-color: #854D0E !important; color: #FBBF24 !important; }
html[data-theme="dark"] .stay-ok { background: #052E1A !important; border-color: #166534 !important; color: #86EFAC !important; }
html[data-theme="dark"] .ev-note { background: #273449 !important; color: #E2E8F0 !important; border-left-color: #64748B !important; }
html[data-theme="dark"] .ev-system { background: #422006 !important; color: #FBBF24 !important; }
html[data-theme="dark"] .ev-housekeeping { background: #052E1A !important; border-color: #166534 !important; color: #86EFAC !important; }
html[data-theme="dark"] .stay-tab { color: #94A3B8 !important; }
html[data-theme="dark"] .stay-tab.active { color: #60A5FA !important; border-bottom-color: #3B82F6 !important; }

/* ---------- Отчёты ---------- */
html[data-theme="dark"] .donut-row,
html[data-theme="dark"] .top-row,
html[data-theme="dark"] .exp-row { color: #CBD5E1 !important; border-color: #334155 !important; }
html[data-theme="dark"] .rep-tab.active,
html[data-theme="dark"] .period-toggle-btn.active { background: #1D4ED8 !important; color: #fff !important; }

/* ---------- Детали задачи: плитки и чек-лист ---------- */
html[data-theme="dark"] .detail-grid > div { background: #273449 !important; }
html[data-theme="dark"] .detail-grid span { color: #94A3B8 !important; }
html[data-theme="dark"] .checklist-item { background: #1E293B !important; border-color: #334155 !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .checklist-item:hover { background: #273449 !important; }
html[data-theme="dark"] .checklist-item.done { background: #052E1A !important; border-color: #166534 !important; }
html[data-theme="dark"] .comment,
html[data-theme="dark"] .history-row,
html[data-theme="dark"] .comment-form input { background: #273449 !important; border-color: #334155 !important; color: #E2E8F0 !important; }
html[data-theme="dark"] .photo-add { background: #273449 !important; border-color: #475569 !important; color: #94A3B8 !important; }

/* ---------- Проживание: workflow ---------- */
html[data-theme="dark"] .stay-workflow { background: #1E293B !important; border-color: #334155 !important; }
html[data-theme="dark"] .stay-wf-label { color: #94A3B8 !important; }
html[data-theme="dark"] .stay-ws-left .stay-workflow,
html[data-theme="dark"] .stay-ws-main .stay-workflow { background: #1E293B !important; }

/* Текущая подписка: тёмный блок вместо светло-голубого */
html[data-theme="dark"] .bg-blue-50\/40 {
    background-color: #172554 !important;
    border-color: #1D4ED8 !important;
    color: #E2E8F0 !important;
}

/* Блок «Показывать в модуле бронирования» */
html[data-theme="dark"] .bg-cyan-50 { background-color: #164E63 !important; color: #E2E8F0 !important; border-color: #155E75 !important; }
html[data-theme="dark"] .bg-cyan-100 { background-color: #155E75 !important; }

/* Тёмная тема: сохранить и основные кнопки */
html[data-theme="dark"] button.bg-slate-800,
html[data-theme="dark"] button.bg-slate-900 {
    background: #334155 !important;
    border: 1px solid #64748B !important;
    color: #FFFFFF !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
html[data-theme="dark"] button.bg-slate-800:hover,
html[data-theme="dark"] button.bg-slate-900:hover {
    background: #475569 !important;
    border-color: #94A3B8 !important;
}
html[data-theme="dark"] button.bg-emerald-700 {
    background: #047857 !important;
    border: 1px solid #34D399 !important;
    color: #FFFFFF !important;
}
html[data-theme="dark"] button.bg-primary {
    border: 1px solid #60A5FA !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

/* ---------- Мои задачи горничной ---------- */
html[data-theme="dark"] .maid-hello { color: #F1F5F9; }
html[data-theme="dark"] .maid-sub { color: #94A3B8; }
html[data-theme="dark"] .maid-summary { color: #94A3B8; }
html[data-theme="dark"] .maid-summary b { color: #E2E8F0; }
html[data-theme="dark"] .maid-day-head b { color: #F1F5F9; }
html[data-theme="dark"] .maid-day-head span,
html[data-theme="dark"] .maid-day-head em { color: #94A3B8; }
html[data-theme="dark"] .maid-task-card {
    background: #1E293B; border-color: #334155;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
html[data-theme="dark"] .maid-task-card.overdue { border-color: #b91c1c; }
html[data-theme="dark"] .maid-task-title { color: #F1F5F9; }
html[data-theme="dark"] .maid-task-object { color: #93C5FD; }
html[data-theme="dark"] .maid-task-deadline { color: #94A3B8; }
html[data-theme="dark"] .maid-task-deadline.overdue { color: #FCA5A5; }
html[data-theme="dark"] .maid-task-deadline.soon { color: #FCD34D; }
html[data-theme="dark"] .maid-task-progress > div:first-child { color: #94A3B8; }
html[data-theme="dark"] .maid-progress-track { background: #334155; }
html[data-theme="dark"] .maid-task-status { color: #94A3B8; }
html[data-theme="dark"] .maid-task-action {
    background: #273449; border-color: #475569; color: #E2E8F0;
}
html[data-theme="dark"] .maid-task-action.primary { background: #3B82F6; border-color: #3B82F6; color: #fff; }
html[data-theme="dark"] .maid-day-empty { border-color: #334155; color: #94A3B8; }
html[data-theme="dark"] .maid-add-btn { background: #3B82F6; }

html[data-theme="dark"] .maid-report-btn { background: #3f1d1d; border-color: #7f1d1d; color: #fca5a5; }
html[data-theme="dark"] .maid-report-btn:last-child { background: #172554; border-color: #1e40af; color: #93c5fd; }

html[data-theme="dark"] .task-action-danger { background: #3f1d1d !important; border-color: #7f1d1d !important; color: #FCA5A5 !important; }

/* Типы задач в тёмной теме */
html[data-theme="dark"] .type-card { background: #1E293B; border-color: #475569; color: #CBD5E1; }
html[data-theme="dark"] .type-card.selected { background: #1E3A8A; border-color: #60A5FA; color: #FFFFFF; }
html[data-theme="dark"] .type-card.selected i { color: #BFDBFE; }

html[data-theme="dark"] .type-card.selected { color: #FFFFFF !important; }
html[data-theme="dark"] .type-card.selected span { color: #FFFFFF !important; }

/* ---------- Task templates / task add menu ---------- */
html[data-theme="dark"] .task-add-menu button,
html[data-theme="dark"] .task-add-menu button span,
html[data-theme="dark"] #drawerTaskTemplates .qr-title,
html[data-theme="dark"] #drawerTaskTemplates .drawer-body,
html[data-theme="dark"] #drawerTaskTemplates .drawer-footer button {
    color: #F1F5F9 !important;
}
html[data-theme="dark"] .task-add-menu button i,
html[data-theme="dark"] #drawerTaskTemplates .qr-preview {
    color: #AFC3C7 !important;
}
html[data-theme="dark"] .task-add-menu button:hover,
html[data-theme="dark"] #drawerTaskTemplates .qr-item:hover {
    background: #243B43 !important;
    color: #FFFFFF !important;
}