/**
 * Тема Logistyk HUB: світла за замовчуванням, темна через html[data-theme="dark"].
 * Персист: localStorage "lh-theme" = "light" | "dark"; без ключа — prefers-color-scheme.
 */

:root {
  color-scheme: light;

  /* Фон сторінки: зображення поверх --lh-bg-page (див. lh-layout.css, lh-login.css) */
  --lh-bg-page-image: none;

  /* Поверхні */
  --lh-bg-page: #e6e9eb;
  --lh-bg-elevated: #ffffff;
  --lh-bg-muted: #f5f8fa;
  --lh-bg-header: #ffffff;
  --lh-bg-kanban: #b4bcc0;
  --lh-bg-section: #e6e9eb;
  --lh-bg-card: #ebedef;
  --lh-bg-card-header: #ebedef;
  --lh-bg-card-content: #ffffff;
  --lh-bg-modal: #e6e9eb;
  --lh-bg-modal-alt: #f8fbff;
  --lh-bg-code: #ecf0f1;
  --lh-bg-hover-table: #f8fbff;
  --lh-bg-table-head: #34495e;
  --lh-bg-table-head-gradient: linear-gradient(135deg, #34495e, #47627c);
  --lh-table-gradient-end: #47627c;
  --lh-bg-table-row-alt: #ecf0f1;
  --lh-bg-docs: #f8f9fa;
  --lh-bg-docs-card: #ffffff;
  --lh-bg-pill: #ffffff;
  --lh-bg-icon: #eef4f8;
  --lh-bg-selected: linear-gradient(180deg, #f4faff 0%, #eaf4ff 100%);
  --lh-bg-editor: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  --lh-bg-priority-hover: #f4faff;
  --lh-bg-ghost-btn: #e6e9eb;
  --lh-bg-ghost-btn-hover: #dce1e4;
  --lh-bg-error: #fadbd8;
  --lh-bg-success: #d5f5e3;
  --lh-bg-warning: #fdebd0;
  --lh-bg-impersonate-banner: #fef3cd;
  --lh-bg-gap: #fef3cd;
  --lh-bg-chip-on: #d5f0e3;
  --lh-bg-chip-off: #eceff1;
  --lh-bg-chip-dim: #e8f4fc;
  --lh-bg-muted-chip: rgba(44, 62, 80, 0.08);
  --lh-bg-time-warn: rgba(230, 126, 34, 0.15);
  --lh-bg-time-gap: #fef3cd;
  --lh-bg-same-ra: linear-gradient(180deg, #f8fcfe 0%, #eaf4fb 100%);
  --lh-bg-journal-thead: #f8fafc;

  /* Текст */
  --lh-text: #2c3e50;
  --lh-text-muted: #95a5a6;
  --lh-text-secondary: #5d6d7e;
  --lh-text-tertiary: #566573;
  --lh-text-nav-active: #1a1f2e;
  --lh-text-inverse: #ffffff;
  --lh-text-link: #2980b9;
  --lh-text-link-hover: #1f6390;
  --lh-text-danger: #c0392b;
  --lh-text-danger-dark: #922b21;
  --lh-text-error: #a93226;
  --lh-text-accountable: #555555;
  --lh-text-responsible: #da1010;
  --lh-text-close-hover: #6a90b6;
  --lh-text-journal-muted: #6b7280;
  --lh-text-flash-success: #1e8449;
  --lh-text-flash-warning: #9c640c;
  --lh-text-gap: #7d5a00;
  --lh-text-gap-strong: #5a3e00;
  --lh-text-gap-status: #9c640c;
  --lh-text-chip-on: #1e8449;
  --lh-text-chip-off: #95a5a6;
  --lh-text-chip-dim: #2874a6;

  /* Межі */
  --lh-border: #e8ecef;
  --lh-border-strong: #cfd8dc;
  --lh-border-nav: #e8ecef;
  --lh-border-header: #8ac9ed73;
  --lh-border-section: #f8f9fa;
  --lh-border-card-focus: #3498db;
  --lh-border-input: #cfd8dc;
  --lh-border-input-hover: #aeb6b8;
  --lh-border-dashed: #b4bcc0;
  --lh-border-table: #e0e6e8;
  --lh-border-table-wrap: #cfd8dc;
  --lh-border-soft: #e1e4e8;
  --lh-border-doc: #d8e2ea;
  --lh-border-doc-hover: #9bc8f0;
  --lh-border-priority: #d8e2ea;
  --lh-border-selected: #3498db;
  --lh-border-error: #e6b0aa;
  --lh-border-warning: #f0c36d;
  --lh-border-flash-success: #a9dfbf;
  --lh-border-flash-warning: #f0c36d;
  --lh-border-journal: #e5e7eb;
  --lh-border-journal-cell: #f1f5f9;
  --lh-border-settings-table: #d9e2ec;
  --lh-border-settings-cell: #e8eef3;
  --lh-border-icon: #d0d7de;
  --lh-border-picker: #d7e1ea;
  --lh-border-add-task: #b8c0c5;
  --lh-border-trash: #e6b8b8;
  --lh-border-impersonate: #bdc3c7;
  --lh-border-gap: #f0c36d;
  --lh-border-time-warn: rgba(230, 126, 34, 0.4);
  --lh-border-time-same: #85c1e9;
  --lh-border-login-error: rgba(192, 57, 43, 0.25);

  /* Тіні */
  --lh-shadow-header: 0 1px 8px rgb(132, 194, 241);
  --lh-shadow-card: 5px 5px 15px rgba(0, 0, 0, 0.2);
  --lh-shadow-card-hover: 5px 8px 22px rgba(0, 0, 0, 0.28);
  --lh-shadow-login: 0 4px 24px rgba(44, 62, 80, 0.08);
  --lh-shadow-modal: 0 16px 48px rgba(0, 0, 0, 0.25);
  --lh-shadow-dialog: 0 20px 56px rgba(0, 0, 0, 0.22);
  --lh-shadow-flash: 0 2px 10px rgba(0, 0, 0, 0.12);
  --lh-shadow-table: 0 16px 40px rgba(15, 23, 42, 0.06);
  --lh-shadow-doc: 0 10px 24px rgba(15, 23, 42, 0.08);
  --lh-shadow-picker: 0 24px 48px rgba(15, 23, 42, 0.16);
  --lh-shadow-editor: 0 16px 32px rgba(15, 23, 42, 0.05);
  --lh-shadow-priority-menu: 0 16px 36px rgba(15, 23, 42, 0.12);

  /* Акценти */
  --lh-accent: #3498db;
  --lh-accent-hover: #2980b9;
  --lh-accent-strong: #2ac5f4;
  --lh-focus-ring: rgba(52, 152, 219, 0.2);
  --lh-focus-ring-alt: rgba(42, 197, 244, 0.2);
  --lh-focus-ring-dark: rgba(44, 62, 80, 0.14);
  --lh-backdrop: rgba(44, 62, 80, 0.45);
  --lh-login-error-bg: rgba(192, 57, 43, 0.08);

  --lh-kanban-title-bg: #262626;
  --lh-kanban-title-archive: #6b6b6b;

  --lh-user-role-bg: #e8eef2;
  --lh-user-role-text: #34495e;
  --lh-login-card-bg: #f7f8f9;
  --lh-trash-btn-bg: #fdf2f2;
  --lh-trash-btn-hover: #fadbd8;
  --lh-doc-text: #243447;
  --lh-doc-text-soft: #425466;
  --lh-doc-label: #6b7b88;
  --lh-doc-icon-selected-bg: #dceeff;
  --lh-doc-icon-selected-text: #1f6390;
  --lh-text-doc-title: #243447;
  --lh-text-picker: #34495e;
  --lh-bg-picker-hover: #eef7ff;
  --lh-bg-icon-selected: #eaf4ff;
  --lh-border-settings-docs: #d9e2ec;
  --lh-text-form-label: #7f8c8d;
  --lh-req: #e74c3c;
  --lh-text-section-label: #4b5d6c;
  --lh-selected-row-border: #e8eef3;
  --lh-add-task-color: #6c757d;
  --lh-add-task-hover: #4950575c;

  --lh-impersonate-btn-bg: #e67e22;
  --lh-impersonate-btn-hover: #ca6f1e;
  --lh-flash-error-bg: rgba(192, 57, 43, 0.08);

  --lh-corner-raci: #2c3e50;
  --lh-save-bg: #2c3e50;
  --lh-save-hover: #34495e;
  --lh-people-save: #2980b9;
  --lh-people-save-hover: #1f6dad;

  --lh-tag-more: #7f8c8d;
  --lh-pause-icon: #9aa6b2;
  --lh-time-warn-text: #c56a0a;
  --lh-time-muted: #7f8c8d;
  --lh-chip-muted-text: #7f8c8d;
  --lh-raci-hint: #95a5a6;
  --lh-settings-back: #2c3e50;
  --lh-doc-card-hover-border: #9bc8f0;
  --lh-shadow-primary-btn: rgba(39, 174, 96, 0.18);
  --lh-shadow-selected-doc: rgba(52, 152, 219, 0.16);
  --lh-shadow-focus-doc: rgba(52, 152, 219, 0.18);
  --lh-icon-doc-color: #2f5b84;
  --lh-login-submit-hover: #2980b9;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --lh-bg-page: #12161d;
  --lh-bg-page-image: url('../img/bg/v1.png');
  --lh-bg-elevated: #1a2228;
  --lh-bg-muted: #232b36;
  --lh-bg-header: #161a22;
  --lh-bg-kanban: #252b33;
  --lh-bg-section: #1a2228;
  --lh-bg-card: #1e252d;
  --lh-bg-card-header: #1f2634;
  --lh-bg-card-content: #2b2e3c;
  --lh-bg-modal: #12161d;
  --lh-bg-modal-alt: #151a22;
  --lh-bg-code: #2a313a;
  --lh-bg-hover-table: #222a35;
  --lh-bg-table-head: #2c3a4a;
  --lh-bg-table-head-gradient: linear-gradient(135deg, #2c3a4a, #3d4f63);
  --lh-table-gradient-end: #3d556d;
  --lh-bg-table-row-alt: #232b36;
  --lh-bg-docs: #181d24;
  --lh-bg-docs-card: #1e252d;
  --lh-bg-pill: #1e252d;
  --lh-bg-icon: #2a3440;
  --lh-bg-selected: linear-gradient(180deg, #1a2838 0%, #152028 100%);
  --lh-bg-editor: linear-gradient(180deg, #1a2228 0%, #151a22 100%);
  --lh-bg-priority-hover: #222a35;
  --lh-bg-ghost-btn: #252b33;
  --lh-bg-ghost-btn-hover: #2d333c;
  --lh-bg-error: #3d2528;
  --lh-bg-success: #1a3328;
  --lh-bg-warning: #3d3420;
  --lh-bg-impersonate-banner: #3a2f18;
  --lh-bg-gap: #3a2f18;
  --lh-bg-chip-on: #1a3328;
  --lh-bg-chip-off: #2a313a;
  --lh-bg-chip-dim: #1a2838;
  --lh-bg-muted-chip: rgba(255, 255, 255, 0.06);
  --lh-bg-time-warn: rgba(230, 126, 34, 0.15);
  --lh-bg-time-gap: #3a2f18;
  --lh-bg-same-ra: linear-gradient(180deg, #1a2838 0%, #182430 100%);
  --lh-bg-journal-thead: #1e252d;

  --lh-text: #e8edf3;
  --lh-text-muted: #9aa8b8;
  --lh-text-secondary: #a8b0c0;
  --lh-text-tertiary: #9aa8b8;
  --lh-text-nav-active: #f0f4f8;
  --lh-text-inverse: #ffffff;
  --lh-text-link: #5dade2;
  --lh-text-link-hover: #7fb3d5;
  --lh-text-danger: #e74c3c;
  --lh-text-danger-dark: #f1948a;
  --lh-text-error: #f5b7b1;
  --lh-text-accountable: #c8d0d8;
  --lh-text-responsible: #da1010;
  --lh-text-close-hover: #85c1e9;
  --lh-text-journal-muted: #9aa8b8;
  --lh-text-flash-success: #7dcea0;
  --lh-text-flash-warning: #f0c96b;
  --lh-text-gap: #e8c96b;
  --lh-text-gap-strong: #f0d08a;
  --lh-text-gap-status: #f0c96b;
  --lh-text-chip-on: #7dcea0;
  --lh-text-chip-off: #9aa8b8;
  --lh-text-chip-dim: #7dafe3;

  --lh-border: #2d333c;
  --lh-border-strong: #3d444d;
  --lh-border-nav: #2d333c;
  --lh-border-header: rgba(138, 201, 237, 0.35);
  --lh-border-section: #2d333c;
  --lh-border-card-focus: #3498db;
  --lh-border-input: #3d444d;
  --lh-border-input-hover: #4d555e;
  --lh-border-dashed: #4d555e;
  --lh-border-table: #333a44;
  --lh-border-table-wrap: #3d444d;
  --lh-border-soft: #2d333c;
  --lh-border-doc: #3d444d;
  --lh-border-doc-hover: #5d8ab8;
  --lh-border-priority: #3d444d;
  --lh-border-selected: #3498db;
  --lh-border-error: #6b3338;
  --lh-border-warning: #8a7030;
  --lh-border-flash-success: #2a5a40;
  --lh-border-flash-warning: #8a7030;
  --lh-border-journal: #2d333c;
  --lh-border-journal-cell: #242a32;
  --lh-border-settings-table: #3d444d;
  --lh-border-settings-cell: #333a44;
  --lh-border-icon: #3d444d;
  --lh-border-picker: #3d444d;
  --lh-border-add-task: #4d555e;
  --lh-border-trash: #6b3338;
  --lh-border-impersonate: #4d555e;
  --lh-border-gap: #8a7030;
  --lh-border-time-warn: rgba(230, 126, 34, 0.4);
  --lh-border-time-same: #4a6b8a;
  --lh-border-login-error: rgba(231, 76, 60, 0.35);

  --lh-shadow-header: 0 1px 8px rgba(0, 0, 0, 0.4);
  --lh-shadow-card: 5px 5px 15px rgba(0, 0, 0, 0.4);
  --lh-shadow-card-hover: 5px 8px 22px rgba(0, 0, 0, 0.5);
  --lh-shadow-login: 0 4px 24px rgba(0, 0, 0, 0.35);
  --lh-shadow-modal: 0 16px 48px rgba(0, 0, 0, 0.55);
  --lh-shadow-dialog: 0 20px 56px rgba(0, 0, 0, 0.5);
  --lh-shadow-flash: 0 2px 10px rgba(0, 0, 0, 0.4);
  --lh-shadow-table: 0 16px 40px rgba(0, 0, 0, 0.25);
  --lh-shadow-doc: 0 10px 24px rgba(0, 0, 0, 0.35);
  --lh-shadow-picker: 0 24px 48px rgba(0, 0, 0, 0.45);
  --lh-shadow-editor: 0 16px 32px rgba(0, 0, 0, 0.3);
  --lh-shadow-priority-menu: 0 16px 36px rgba(0, 0, 0, 0.4);

  --lh-backdrop: rgba(0, 0, 0, 0.65);
  --lh-focus-ring: rgba(93, 173, 226, 0.35);
  --lh-focus-ring-alt: rgba(42, 197, 244, 0.25);
  --lh-login-error-bg: rgba(231, 76, 60, 0.12);
  --lh-flash-error-bg: rgba(231, 76, 60, 0.12);

  --lh-kanban-title-bg: #14161f;
  --lh-kanban-title-archive: #4a4e56;

  --lh-user-role-bg: #2a313a;
  --lh-user-role-text: #c8d0d8;
  --lh-login-card-bg: #1a2228;
  --lh-trash-btn-bg: #3d2528;
  --lh-trash-btn-hover: #4d3035;
  --lh-doc-text: #dce4ec;
  --lh-doc-text-soft: #a8b8c8;
  --lh-doc-label: #8a9aaa;
  --lh-doc-icon-selected-bg: #1a3550;
  --lh-doc-icon-selected-text: #7dafe3;
  --lh-text-doc-title: #dce4ec;
  --lh-text-picker: #c8d0d8;
  --lh-bg-picker-hover: #253445;
  --lh-bg-icon-selected: #1a3550;
  --lh-border-settings-docs: #3d444d;
  --lh-text-form-label: #9aa8b8;
  --lh-text-section-label: #a8b8c8;
  --lh-selected-row-border: #333a44;
  --lh-add-task-color: #9aa8b8;
  --lh-add-task-hover: #8899aa80;

  --lh-corner-raci: #1e2832;
  --lh-save-bg: #34495e;
  --lh-save-hover: #3d566d;
  --lh-people-save: #2980b9;
  --lh-people-save-hover: #3498db;

  --lh-tag-more: #9aa8b8;
  --lh-time-warn-text: #f0b27a;
  --lh-time-muted: #9aa8b8;
  --lh-chip-muted-text: #9aa8b8;
  --lh-raci-hint: #9aa8b8;
  --lh-settings-back: #e8edf3;
  --lh-doc-card-hover-border: #5d8ab8;
  --lh-icon-doc-color: #7dafe3;
  --lh-login-submit-hover: #5dade2;
}

/* Кнопка перемикання теми (шапка, сторінка входу) */
.lh-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--lh-border-strong);
  border-radius: 10px;
  background: var(--lh-bg-muted);
  color: var(--lh-text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lh-theme-toggle:hover {
  background: var(--lh-bg-elevated);
  color: var(--lh-text);
  border-color: var(--lh-border-doc-hover);
}

.lh-theme-toggle:focus-visible {
  outline: 2px solid var(--lh-accent);
  outline-offset: 2px;
}

.lh-theme-toggle__icon {
  font-size: 1.15rem;
  line-height: 1;
}

html[data-theme="dark"] .lh-theme-toggle__icon--dark {
  display: none;
}

html:not([data-theme="dark"]) .lh-theme-toggle__icon--light {
  display: none;
}

.lh-theme-toggle--login {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
}

/* Нативний <dialog>: успадковує color-scheme від html, щоб поля й фон не лишались світлими */
.lh-task-create-dialog,
.lh-task-detail-dialog {
  color-scheme: inherit;
}

/* Міні-журнал задачі: у темній темі світліший блок (деталь / модалка) */
html[data-theme="dark"] .lh-task-detail__mini-log {
  background: #2a323c;
  border-color: #4a5568;
}

html[data-theme="dark"] .lh-task-detail__mini-log-title {
  background: #323d4a;
  color: #f2f6fb;
  border-bottom-color: #3d4a5a;
}

html[data-theme="dark"] .lh-task-detail__mini-log-count {
  color: #b8c5d3;
}

html[data-theme="dark"] .lh-task-detail__mini-log-title::before {
  color: #aab8c8;
}

html[data-theme="dark"] .lh-task-detail__mini-log-table-wrap {
  background: #262e38;
}

html[data-theme="dark"] .lh-task-detail__mini-log-table th {
  background: #384454;
  color: #e8eef5;
  border-bottom-color: #4a5568;
}

html[data-theme="dark"] .lh-task-detail__mini-log-table td {
  color: #eef2f7;
  border-bottom-color: #3d4a5a;
}

html[data-theme="dark"] .lh-task-detail__mini-log-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .lh-task-detail__mini-log-empty {
  color: #aab8c8;
}

/* Картка задачі (модалка / сторінка): заголовок і gap-банер — були жорсткі # у lh-task-detail.css */
html[data-theme="dark"] .lh-task-detail-inner {
  color: var(--lh-text) !important;
}

html[data-theme="dark"] .lh-task-detail__title {
  color: var(--lh-text) !important;
}

html[data-theme="dark"] .lh-task-detail__section-label,
html[data-theme="dark"] .lh-task-detail__meta-label {
  color: var(--lh-text-secondary) !important;
}

html[data-theme="dark"] .lh-task-detail__dates {
  color: var(--lh-text-secondary) !important;
}

html[data-theme="dark"] .lh-task-detail__gap-banner {
  color: var(--lh-text-gap) !important;
  font-size: 14px;
}

html[data-theme="dark"] .lh-task-detail__gap-banner strong {
  color: var(--lh-text-gap-strong) !important;
}

html[data-theme="dark"] .lh-task-detail__gap-waiting {
  color: var(--lh-text-gap) !important;
  opacity: 0.95;
}

html[data-theme="dark"] .lh-task-detail__close {
  color: var(--lh-text-secondary) !important;
}

html[data-theme="dark"] .lh-task-detail__close:hover {
  color: var(--lh-text-close-hover) !important;
}

html[data-theme="dark"] .lh-task-detail__docs-card-title {
  color: var(--lh-text-secondary) !important;
}

/* ─── Міні-журнал: підсвітка позаробочого часу ─── */
.lh-task-detail__mini-log-time {
  white-space: nowrap;
}

.lh-task-detail__mini-log-off-hours-badge {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  cursor: default;
  vertical-align: middle;
  opacity: 0.8;
}

/* Рядок у світлій темі */
.lh-task-detail__mini-log-row--off-hours {
  background: #fffbeb;
}

.lh-task-detail__mini-log-row--off-hours .lh-task-detail__mini-log-time {
  color: #b45309;
  font-style: italic;
}

/* Рядок у темній темі */
html[data-theme="dark"] .lh-task-detail__mini-log-row--off-hours {
  background: rgba(251, 191, 36, 0.08) !important;
}

html[data-theme="dark"] .lh-task-detail__mini-log-row--off-hours .lh-task-detail__mini-log-time {
  color: #fbbf24 !important;
  font-style: italic;
}
