/* ============================================================
   ENHANCEMENTS — Dark Mode, Density, Slide-over Drawer,
   Command Palette (Ctrl+K), Mobile Bottom Nav & Card View,
   Active Sessions, Project Templates & Baseline Gantt
   ============================================================ */

/* 1. DARK MODE COMPONENT SURFACES (GLOBAL + BAN GIÁM ĐỐC + PHÒNG BAN) */
[data-theme="dark"] body,
body.dark-theme {
  background-color: var(--bg-app) !important;
  color: var(--text-primary);
}
[data-theme="dark"] .content-area,
body.dark-theme .content-area {
  background: var(--bg-app) !important;
  color: var(--text-primary);
}
[data-theme="dark"] .loading-overlay,
body.dark-theme .loading-overlay {
  background: rgba(11, 17, 32, 0.80) !important;
}
[data-theme="dark"] .topbar,
body.dark-theme .topbar {
  background: rgba(15, 23, 42, 0.88) !important;
  border-bottom-color: var(--border-color) !important;
  color: var(--text-primary);
}
[data-theme="dark"] .sidebar,
body.dark-theme .sidebar {
  background: var(--bg-sidebar) !important;
  border-right-color: var(--border-color) !important;
}
[data-theme="dark"] .logo-text,
[data-theme="dark"] .breadcrumb,
[data-theme="dark"] .user-name,
[data-theme="dark"] .topbar-user-name,
[data-theme="dark"] .stat-value,
[data-theme="dark"] .modal-title,
[data-theme="dark"] .bom-summary strong,
[data-theme="dark"] .org-stat strong,
body.dark-theme .logo-text,
body.dark-theme .breadcrumb,
body.dark-theme .user-name,
body.dark-theme .topbar-user-name,
body.dark-theme .stat-value,
body.dark-theme .modal-title,
body.dark-theme .bom-summary strong,
body.dark-theme .org-stat strong {
  color: var(--text-primary) !important;
}
[data-theme="dark"] .form-label,
[data-theme="dark"] .topbar-user-role,
[data-theme="dark"] .bom-total-sub,
body.dark-theme .form-label,
body.dark-theme .topbar-user-role,
body.dark-theme .bom-total-sub {
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .topbar-user-badge,
body.dark-theme .topbar-user-badge {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .topbar-user-badge:hover,
body.dark-theme .topbar-user-badge:hover {
  background: #233047 !important;
  border-color: #3B82F6 !important;
}
[data-theme="dark"] .nav-link,
body.dark-theme .nav-link {
  color: var(--text-secondary);
}
[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .sidebar-toggle:hover,
[data-theme="dark"] .btn-ghost:hover,
[data-theme="dark"] .modal-close:hover,
body.dark-theme .nav-link:hover,
body.dark-theme .sidebar-toggle:hover,
body.dark-theme .btn-ghost:hover,
body.dark-theme .modal-close:hover {
  background: var(--surface-hover) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .nav-link.active,
body.dark-theme .nav-link.active {
  background: rgba(59, 130, 246, 0.22) !important;
  color: #93C5FD !important;
}
[data-theme="dark"] .nav-badge,
body.dark-theme .nav-badge {
  background: #1E293B !important;
  color: #CBD5E1 !important;
}
[data-theme="dark"] .nav-badge.danger,
body.dark-theme .nav-badge.danger {
  background: rgba(239, 68, 68, 0.20) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .nav-divider,
body.dark-theme .nav-divider {
  background: var(--border-color) !important;
}
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .report-card,
[data-theme="dark"] .exec-panel,
[data-theme="dark"] .exec-metric,
[data-theme="dark"] .exec-toolbar,
[data-theme="dark"] .exec-facts,
[data-theme="dark"] .exec-definitions,
[data-theme="dark"] .project-card,
[data-theme="dark"] .kanban-card,
[data-theme="dark"] .modal,
[data-theme="dark"] .auth-modal-card,
[data-theme="dark"] .search-dropdown,
[data-theme="dark"] .topbar-account-actions,
[data-theme="dark"] .app-action-dialog,
[data-theme="dark"] .auth-room-tile,
[data-theme="dark"] .org-template,
[data-theme="dark"] .org-department-card,
[data-theme="dark"] .org-stat,
[data-theme="dark"] .org-legacy,
[data-theme="dark"] .org-table-scroll,
[data-theme="dark"] .org-dialog,
[data-theme="dark"] .org-recovery-card,
[data-theme="dark"] .assigned-card,
[data-theme="dark"] .hub-dialog,
[data-theme="dark"] .bom-dialog,
[data-theme="dark"] .drive-dialog,
[data-theme="dark"] .pl-tip,
body.dark-theme .card,
body.dark-theme .stat-card,
body.dark-theme .report-card,
body.dark-theme .exec-panel,
body.dark-theme .exec-metric,
body.dark-theme .exec-toolbar,
body.dark-theme .exec-facts,
body.dark-theme .exec-definitions,
body.dark-theme .project-card,
body.dark-theme .kanban-card,
body.dark-theme .modal,
body.dark-theme .auth-modal-card,
body.dark-theme .search-dropdown,
body.dark-theme .topbar-account-actions,
body.dark-theme .app-action-dialog,
body.dark-theme .auth-room-tile,
body.dark-theme .org-template,
body.dark-theme .org-department-card,
body.dark-theme .org-stat,
body.dark-theme .org-legacy,
body.dark-theme .org-table-scroll,
body.dark-theme .org-dialog,
body.dark-theme .org-recovery-card,
body.dark-theme .assigned-card,
body.dark-theme .hub-dialog,
body.dark-theme .bom-dialog,
body.dark-theme .drive-dialog,
body.dark-theme .pl-tip {
  background: var(--bg-card) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .exec-metric-primary,
body.dark-theme .exec-metric-primary {
  background: linear-gradient(135deg, #2563EB, #1D4ED8) !important;
  border-color: transparent !important;
  color: #FFFFFF !important;
}
[data-theme="dark"] .auth-room-tile:hover,
body.dark-theme .auth-room-tile:hover {
  background: rgba(59, 130, 246, 0.16) !important;
  border-color: #60A5FA !important;
}
[data-theme="dark"] .kanban-column,
body.dark-theme .kanban-column {
  background: var(--bg-kanban-col) !important;
  border-color: var(--border-color) !important;
}
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea,
[data-theme="dark"] .search-input,
[data-theme="dark"] .search-input:focus,
[data-theme="dark"] .auth-input,
[data-theme="dark"] .bom-table select,
[data-theme="dark"] .bom-table input,
[data-theme="dark"] .bom-table textarea,
body.dark-theme .form-input,
body.dark-theme .form-select,
body.dark-theme .form-textarea,
body.dark-theme .search-input,
body.dark-theme .search-input:focus,
body.dark-theme .auth-input,
body.dark-theme .bom-table select,
body.dark-theme .bom-table input,
body.dark-theme .bom-table textarea {
  background: var(--bg-input) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .btn-outline,
[data-theme="dark"] .topbar-btn,
[data-theme="dark"] .pl-btn,
[data-theme="dark"] .pl-btn-primary,
[data-theme="dark"] .pl-btn-success,
[data-theme="dark"] .pl-btn-excel,
body.dark-theme .btn-outline,
body.dark-theme .topbar-btn,
body.dark-theme .pl-btn,
body.dark-theme .pl-btn-primary,
body.dark-theme .pl-btn-success,
body.dark-theme .pl-btn-excel {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .btn-outline:hover,
[data-theme="dark"] .topbar-btn:hover,
[data-theme="dark"] .pl-btn:hover,
[data-theme="dark"] .pl-btn-primary:hover,
[data-theme="dark"] .pl-btn-success:hover,
[data-theme="dark"] .pl-btn-excel:hover,
body.dark-theme .btn-outline:hover,
body.dark-theme .topbar-btn:hover,
body.dark-theme .pl-btn:hover,
body.dark-theme .pl-btn-primary:hover,
body.dark-theme .pl-btn-success:hover,
body.dark-theme .pl-btn-excel:hover {
  background: #233047 !important;
  border-color: #3B82F6 !important;
  color: #FFFFFF !important;
}
[data-theme="dark"] table th,
[data-theme="dark"] .hub-table th,
[data-theme="dark"] .data-table th,
[data-theme="dark"] .exec-table th,
[data-theme="dark"] .org-member-table th,
[data-theme="dark"] .permission-matrix thead th,
[data-theme="dark"] .permission-group th,
[data-theme="dark"] .workload-table-wrapper .workload-table th,
body.dark-theme table th,
body.dark-theme .hub-table th,
body.dark-theme .data-table th,
body.dark-theme .exec-table th,
body.dark-theme .org-member-table th,
body.dark-theme .permission-matrix thead th,
body.dark-theme .permission-group th,
body.dark-theme .workload-table-wrapper .workload-table th {
  background: #0F172A !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}
[data-theme="dark"] table td,
[data-theme="dark"] .hub-table td,
[data-theme="dark"] .data-table td,
[data-theme="dark"] .exec-table td,
[data-theme="dark"] .bom-table td,
[data-theme="dark"] .permission-matrix td,
body.dark-theme table td,
body.dark-theme .hub-table td,
body.dark-theme .data-table td,
body.dark-theme .exec-table td,
body.dark-theme .bom-table td,
body.dark-theme .permission-matrix td {
  border-color: var(--border-color) !important;
  color: var(--text-primary);
}
[data-theme="dark"] .bom-table td,
body.dark-theme .bom-table td {
  background: var(--bg-card) !important;
}
[data-theme="dark"] .bom-table tbody tr:nth-child(even) td,
body.dark-theme .bom-table tbody tr:nth-child(even) td {
  background: #111A2B !important;
}
[data-theme="dark"] .donut-hole,
[data-theme="dark"] .hub-donut > div,
[data-theme="dark"] .exec-donut > div,
body.dark-theme .donut-hole,
body.dark-theme .hub-donut > div,
body.dark-theme .exec-donut > div {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer,
body.dark-theme .modal-header,
body.dark-theme .modal-footer {
  border-color: var(--border-color) !important;
  background: var(--bg-card) !important;
}
[data-theme="dark"] .progress-bar-wrapper,
[data-theme="dark"] .hub-track,
[data-theme="dark"] .exec-progress-track,
[data-theme="dark"] .workload-bar-wrap,
[data-theme="dark"] .workload-segment-todo,
[data-theme="dark"] .rp-work-remaining,
body.dark-theme .progress-bar-wrapper,
body.dark-theme .hub-track,
body.dark-theme .exec-progress-track,
body.dark-theme .workload-bar-wrap,
body.dark-theme .workload-segment-todo,
body.dark-theme .rp-work-remaining {
  background: #1E293B !important;
  border-color: var(--border-color) !important;
}

/* Global & Module Badges (Accessible Dark Tints) */
[data-theme="dark"] .badge-success,
[data-theme="dark"] .hub-approved,
[data-theme="dark"] .hub-present,
[data-theme="dark"] .hub-low,
[data-theme="dark"] .hub-stat--success .hub-stat-pct,
[data-theme="dark"] .hub-stat--success .hub-stat-icon,
[data-theme="dark"] .org-status-done,
[data-theme="dark"] .pc-status-completed,
[data-theme="dark"] .pc-task-done,
[data-theme="dark"] .pc-task-completed,
[data-theme="dark"] .pc-health-ok,
[data-theme="dark"] .pl-badge-done,
[data-theme="dark"] .bom-table .received,
[data-theme="dark"] .exec-empty-success > span,
body.dark-theme .badge-success,
body.dark-theme .hub-approved,
body.dark-theme .hub-present,
body.dark-theme .hub-low,
body.dark-theme .hub-stat--success .hub-stat-pct,
body.dark-theme .hub-stat--success .hub-stat-icon,
body.dark-theme .org-status-done,
body.dark-theme .pc-status-completed,
body.dark-theme .pc-task-done,
body.dark-theme .pc-task-completed,
body.dark-theme .pc-health-ok,
body.dark-theme .pl-badge-done,
body.dark-theme .bom-table .received,
body.dark-theme .exec-empty-success > span {
  background: rgba(16, 185, 129, 0.18) !important;
  color: #6EE7B7 !important;
  border-color: rgba(16, 185, 129, 0.35) !important;
}
[data-theme="dark"] .badge-danger,
[data-theme="dark"] .priority-high,
[data-theme="dark"] .hub-rejected,
[data-theme="dark"] .hub-high,
[data-theme="dark"] .hub-stat--danger .hub-stat-pct,
[data-theme="dark"] .hub-stat--danger .hub-stat-icon,
[data-theme="dark"] .pc-health-overdue,
[data-theme="dark"] .pc-alert,
[data-theme="dark"] .pl-badge-danger,
[data-theme="dark"] .pl-btn-danger,
[data-theme="dark"] .bom-table .cancelled,
[data-theme="dark"] .bom-import-error:not(:empty),
[data-theme="dark"] .rp-warning-overdue,
[data-theme="dark"] .rp-role-warning,
[data-theme="dark"] .org-recovery-actions .org-recovery-delete,
[data-theme="dark"] .pm-recovery-actions [data-purge-project],
[data-theme="dark"] .exec-badge-danger,
[data-theme="dark"] .exec-alert-count,
[data-theme="dark"] .exec-message-error,
[data-theme="dark"] .pm-risk-banner,
[data-theme="dark"] .tk-stat-danger,
[data-theme="dark"] .tk-risk-alert-banner,
body.dark-theme .badge-danger,
body.dark-theme .priority-high,
body.dark-theme .hub-rejected,
body.dark-theme .hub-high,
body.dark-theme .hub-stat--danger .hub-stat-pct,
body.dark-theme .hub-stat--danger .hub-stat-icon,
body.dark-theme .pc-health-overdue,
body.dark-theme .pc-alert,
body.dark-theme .pl-badge-danger,
body.dark-theme .pl-btn-danger,
body.dark-theme .bom-table .cancelled,
body.dark-theme .bom-import-error:not(:empty),
body.dark-theme .rp-warning-overdue,
body.dark-theme .rp-role-warning,
body.dark-theme .org-recovery-actions .org-recovery-delete,
body.dark-theme .pm-recovery-actions [data-purge-project],
body.dark-theme .exec-badge-danger,
body.dark-theme .exec-alert-count,
body.dark-theme .exec-message-error,
body.dark-theme .pm-risk-banner,
body.dark-theme .tk-stat-danger,
body.dark-theme .tk-risk-alert-banner {
  background: rgba(239, 68, 68, 0.16) !important;
  color: #FCA5A5 !important;
  border-color: rgba(239, 68, 68, 0.38) !important;
}
[data-theme="dark"] .pm-risk-banner *,
[data-theme="dark"] .tk-risk-alert-banner *,
body.dark-theme .pm-risk-banner *,
body.dark-theme .tk-risk-alert-banner * {
  color: #FECACA !important;
}
[data-theme="dark"] .pm-risk-banner button,
[data-theme="dark"] .tk-risk-alert-banner button,
body.dark-theme .pm-risk-banner button,
body.dark-theme .tk-risk-alert-banner button {
  background: rgba(239, 68, 68, 0.22) !important;
  border-color: rgba(248, 113, 113, 0.5) !important;
  color: #FEE2E2 !important;
}
[data-theme="dark"] .badge-warning,
[data-theme="dark"] .priority-medium,
[data-theme="dark"] .hub-pending,
[data-theme="dark"] .hub-medium,
[data-theme="dark"] .hub-leave_pending,
[data-theme="dark"] .hub-assessment,
[data-theme="dark"] .hub-stat--warning .hub-stat-pct,
[data-theme="dark"] .hub-stat--warning .hub-stat-icon,
[data-theme="dark"] .hub-pending-card,
[data-theme="dark"] .org-status-review,
[data-theme="dark"] .pc-status-paused,
[data-theme="dark"] .pc-status-review,
[data-theme="dark"] .pc-task-review,
[data-theme="dark"] .pc-health-late-start,
[data-theme="dark"] .pl-badge-review,
[data-theme="dark"] .bom-table .purchasing,
[data-theme="dark"] .rp-project-alert,
[data-theme="dark"] .rp-warning-status,
[data-theme="dark"] .exec-badge-warning,
[data-theme="dark"] .exec-quality,
[data-theme="dark"] .exec-quality-count,
body.dark-theme .badge-warning,
body.dark-theme .priority-medium,
body.dark-theme .hub-pending,
body.dark-theme .hub-medium,
body.dark-theme .hub-leave_pending,
body.dark-theme .hub-assessment,
body.dark-theme .hub-stat--warning .hub-stat-pct,
body.dark-theme .hub-stat--warning .hub-stat-icon,
body.dark-theme .hub-pending-card,
body.dark-theme .org-status-review,
body.dark-theme .pc-status-paused,
body.dark-theme .pc-status-review,
body.dark-theme .pc-task-review,
body.dark-theme .pc-health-late-start,
body.dark-theme .pl-badge-review,
body.dark-theme .bom-table .purchasing,
body.dark-theme .rp-project-alert,
body.dark-theme .rp-warning-status,
body.dark-theme .exec-badge-warning,
body.dark-theme .exec-quality,
body.dark-theme .exec-quality-count {
  background: rgba(245, 158, 11, 0.16) !important;
  color: #FDE68A !important;
  border-color: rgba(245, 158, 11, 0.40) !important;
}
[data-theme="dark"] .badge-info,
[data-theme="dark"] .hub-badge,
[data-theme="dark"] .org-mode,
[data-theme="dark"] .org-status-in-progress,
[data-theme="dark"] .pc-status-active,
[data-theme="dark"] .pc-task-in-progress,
[data-theme="dark"] .pl-badge-primary,
[data-theme="dark"] .pl-badge-prog,
[data-theme="dark"] .pl-sopt.active,
[data-theme="dark"] .pl-capopt.active,
[data-theme="dark"] .exec-year-chip,
[data-theme="dark"] .tk-tag,
[data-theme="dark"] .data-card-icon,
body.dark-theme .badge-info,
body.dark-theme .hub-badge,
body.dark-theme .org-mode,
body.dark-theme .org-status-in-progress,
body.dark-theme .pc-status-active,
body.dark-theme .pc-task-in-progress,
body.dark-theme .pl-badge-primary,
body.dark-theme .pl-badge-prog,
body.dark-theme .pl-sopt.active,
body.dark-theme .pl-capopt.active,
body.dark-theme .exec-year-chip,
body.dark-theme .tk-tag,
body.dark-theme .data-card-icon {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #93C5FD !important;
  border-color: rgba(59, 130, 246, 0.35) !important;
}
[data-theme="dark"] .org-mode-support,
body.dark-theme .org-mode-support {
  background: rgba(20, 184, 166, 0.18) !important;
  color: #5EEAD4 !important;
}
[data-theme="dark"] .badge-default,
[data-theme="dark"] .hub-cancelled,
[data-theme="dark"] .org-status,
[data-theme="dark"] .pc-status-not-started,
[data-theme="dark"] .pc-task-todo,
[data-theme="dark"] .pc-task-backlog,
[data-theme="dark"] .pc-health-inactive,
[data-theme="dark"] .pl-badge-gray,
[data-theme="dark"] .pl-badge-todo,
body.dark-theme .badge-default,
body.dark-theme .hub-cancelled,
body.dark-theme .org-status,
body.dark-theme .pc-status-not-started,
body.dark-theme .pc-task-todo,
body.dark-theme .pc-task-backlog,
body.dark-theme .pc-health-inactive,
body.dark-theme .pl-badge-gray,
body.dark-theme .pl-badge-todo {
  background: #1E293B !important;
  color: #CBD5E1 !important;
  border-color: #334155 !important;
}

/* Executive & Planning Specific Dark Accents */
[data-theme="dark"] .exec-month-value,
[data-theme="dark"] .exec-text-link,
[data-theme="dark"] .exec-small-code,
body.dark-theme .exec-month-value,
body.dark-theme .exec-text-link,
body.dark-theme .exec-small-code {
  color: #60A5FA !important;
}
[data-theme="dark"] .exec-table td:first-child .exec-text-link,
body.dark-theme .exec-table td:first-child .exec-text-link {
  color: var(--text-primary) !important;
}
[data-theme="dark"] .exec-upcoming-date,
[data-theme="dark"] .org-note,
[data-theme="dark"] .assigned-result,
body.dark-theme .exec-upcoming-date,
body.dark-theme .org-note,
body.dark-theme .assigned-result {
  background: #1B2538 !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .pl-trow.l0,
[data-theme="dark"] .pl-brow.l0,
body.dark-theme .pl-trow.l0,
body.dark-theme .pl-brow.l0 {
  background: rgba(59, 130, 246, 0.14) !important;
}
[data-theme="dark"] .pl-trow.l1,
[data-theme="dark"] .pl-brow.l1,
body.dark-theme .pl-trow.l1,
body.dark-theme .pl-brow.l1 {
  background: rgba(20, 184, 166, 0.12) !important;
}
[data-theme="dark"] .pl-brow.l2,
body.dark-theme .pl-brow.l2 {
  background: rgba(148, 163, 184, 0.06) !important;
}
[data-theme="dark"] .pl-trow.l1 .pl-tname,
[data-theme="dark"] .pl-trow.l1 .pl-daycell,
body.dark-theme .pl-trow.l1 .pl-tname,
body.dark-theme .pl-trow.l1 .pl-daycell {
  color: #5EEAD4 !important;
}
[data-theme="dark"] .pl-trow.l0 .pl-daycell,
body.dark-theme .pl-trow.l0 .pl-daycell {
  color: #93C5FD !important;
}
/* Sub-page Dark Mode coverage (Planning, BOM, Project Detail, Org, Control, Dialogs) */
[data-theme="dark"] .planning-shell,
[data-theme="dark"] .planning-toolbar,
[data-theme="dark"] .planning-card,
[data-theme="dark"] .wbs-panel,
[data-theme="dark"] .gantt-sidebar,
[data-theme="dark"] .gantt-header,
[data-theme="dark"] .gantt-row,
[data-theme="dark"] .bom-shell,
[data-theme="dark"] .bom-card,
[data-theme="dark"] .bom-toolbar,
[data-theme="dark"] .bom-group-tab,
[data-theme="dark"] .pd-shell,
[data-theme="dark"] .pd-card,
[data-theme="dark"] .pd-header,
[data-theme="dark"] .project-detail-card,
[data-theme="dark"] .org-card,
[data-theme="dark"] .org-panel,
[data-theme="dark"] .org-room-card,
[data-theme="dark"] .pc-card,
[data-theme="dark"] .pc-toolbar,
[data-theme="dark"] .action-dialog,
[data-theme="dark"] .action-dialog-box,
[data-theme="dark"] .hub-panel,
[data-theme="dark"] .hub-card,
body.dark-theme .planning-shell,
body.dark-theme .planning-toolbar,
body.dark-theme .planning-card,
body.dark-theme .wbs-panel,
body.dark-theme .gantt-sidebar,
body.dark-theme .gantt-header,
body.dark-theme .gantt-row,
body.dark-theme .bom-shell,
body.dark-theme .bom-card,
body.dark-theme .bom-toolbar,
body.dark-theme .bom-group-tab,
body.dark-theme .pd-shell,
body.dark-theme .pd-card,
body.dark-theme .pd-header,
body.dark-theme .project-detail-card,
body.dark-theme .org-card,
body.dark-theme .org-panel,
body.dark-theme .org-room-card,
body.dark-theme .pc-card,
body.dark-theme .pc-toolbar,
body.dark-theme .action-dialog,
body.dark-theme .action-dialog-box,
body.dark-theme .hub-panel,
body.dark-theme .hub-card {
  background-color: var(--bg-card) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .gantt-day-cell.is-weekend,
body.dark-theme .gantt-day-cell.is-weekend {
  background: rgba(148, 163, 184, 0.06) !important;
}
[data-theme="dark"] .bom-money-input,
[data-theme="dark"] .bom-input,
body.dark-theme .bom-money-input,
body.dark-theme .bom-input {
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

/* Screenshot 1: Timeline & Gantt complete Dark Mode */
[data-theme="dark"] .gantt-wrapper,
[data-theme="dark"] .gantt-project-row,
[data-theme="dark"] .gantt-project-row .gantt-sidebar-col,
body.dark-theme .gantt-wrapper,
body.dark-theme .gantt-project-row,
body.dark-theme .gantt-project-row .gantt-sidebar-col {
  background: #151E2E !important;
  border-color: #263449 !important;
  color: #F1F5F9 !important;
}
[data-theme="dark"] .gantt-header-row,
[data-theme="dark"] .gantt-header-row .gantt-sidebar-col,
[data-theme="dark"] .gantt-month-cell,
[data-theme="dark"] .gantt-day-cell,
body.dark-theme .gantt-header-row,
body.dark-theme .gantt-header-row .gantt-sidebar-col,
body.dark-theme .gantt-month-cell,
body.dark-theme .gantt-day-cell {
  background: #0F172A !important;
  border-color: #263449 !important;
  color: #CBD5E1 !important;
}
[data-theme="dark"] .gantt-day-cell.is-weekend,
[data-theme="dark"] .timeline-page .gantt-grid-line.is-weekend,
body.dark-theme .gantt-day-cell.is-weekend,
body.dark-theme .timeline-page .gantt-grid-line.is-weekend {
  background: rgba(148, 163, 184, 0.08) !important;
  color: #94A3B8 !important;
}
[data-theme="dark"] .timeline-page .gantt-grid-line,
[data-theme="dark"] .gantt-row,
body.dark-theme .timeline-page .gantt-grid-line,
body.dark-theme .gantt-row {
  border-color: #263449 !important;
}
[data-theme="dark"] .gantt-day-cell.is-today,
body.dark-theme .gantt-day-cell.is-today {
  background: rgba(59, 130, 246, 0.25) !important;
  color: #93C5FD !important;
}
[data-theme="dark"] .gantt-task-row,
[data-theme="dark"] .task-col,
body.dark-theme .gantt-task-row,
body.dark-theme .task-col {
  background: #111A2B !important;
  color: #CBD5E1 !important;
}
[data-theme="dark"] .gantt-project-row:hover,
[data-theme="dark"] .gantt-project-row:hover .gantt-sidebar-col,
[data-theme="dark"] .gantt-task-row:hover,
[data-theme="dark"] .gantt-task-row:hover .task-col,
body.dark-theme .gantt-project-row:hover,
body.dark-theme .gantt-project-row:hover .gantt-sidebar-col,
body.dark-theme .gantt-task-row:hover,
body.dark-theme .gantt-task-row:hover .task-col {
  background: #1B2538 !important;
}
[data-theme="dark"] .project-sidebar-title,
[data-theme="dark"] .gantt-project-bar,
body.dark-theme .project-sidebar-title,
body.dark-theme .gantt-project-bar {
  color: #F1F5F9 !important;
}
[data-theme="dark"] .task-sidebar-title,
[data-theme="dark"] .btn-toggle-expand,
body.dark-theme .task-sidebar-title,
body.dark-theme .btn-toggle-expand {
  color: #CBD5E1 !important;
}
[data-theme="dark"] .btn-toggle-expand:hover,
body.dark-theme .btn-toggle-expand:hover {
  background: #263449 !important;
  color: #F1F5F9 !important;
}

/* Screenshot 2: Accounts filter bar, password box, status & role badges */
[data-theme="dark"] .account-report-filters,
[data-theme="dark"] .account-password-dialog,
body.dark-theme .account-report-filters,
body.dark-theme .account-password-dialog {
  background: var(--bg-card) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .account-report-filters label,
body.dark-theme .account-report-filters label {
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .account-password,
[data-theme="dark"] .account-password-dialog button[data-close],
body.dark-theme .account-password,
body.dark-theme .account-password-dialog button[data-close] {
  background: var(--bg-input) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .account-status,
body.dark-theme .account-status {
  background: rgba(16, 185, 129, 0.18) !important;
  color: #6EE7B7 !important;
}
[data-theme="dark"] .account-status.locked,
body.dark-theme .account-status.locked {
  background: rgba(239, 68, 68, 0.18) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .account-role-badge,
[data-theme="dark"] .accounts-page td .badge,
body.dark-theme .account-role-badge,
body.dark-theme .accounts-page td .badge {
  background: rgba(99, 102, 241, 0.22) !important;
  color: #C7D2FE !important;
  border: 1px solid rgba(129, 140, 248, 0.35) !important;
}

/* Screenshot 5: Planning & WBS Gantt (--pl-* tokens) + Toast notifications */
[data-theme="dark"] .planning-wrapper,
body.dark-theme .planning-wrapper {
  --pl-bg0: #0B1120;
  --pl-bg1: #151E2E;
  --pl-bg2: #0F172A;
  --pl-bg3: #1B2538;
  --pl-hover: rgba(59, 130, 246, 0.14);
  --pl-border: #263449;
  --pl-border2: #334155;
  --pl-txt1: #F1F5F9;
  --pl-txt2: #CBD5E1;
  --pl-txt3: #94A3B8;
  --pl-primary: #93C5FD;
  background: var(--pl-bg1) !important;
  border-color: var(--pl-border) !important;
  color: var(--pl-txt1) !important;
}
[data-theme="dark"] .pl-sel,
[data-theme="dark"] .pl-zoom-box,
[data-theme="dark"] .pl-finput,
[data-theme="dark"] .pl-fsel,
[data-theme="dark"] .pl-sp-sel,
body.dark-theme .pl-sel,
body.dark-theme .pl-zoom-box,
body.dark-theme .pl-finput,
body.dark-theme .pl-fsel,
body.dark-theme .pl-sp-sel {
  background: #0F172A !important;
  border-color: #263449 !important;
  color: #F1F5F9 !important;
}
[data-theme="dark"] dialog.pl-import-error,
body.dark-theme dialog.pl-import-error {
  background: var(--bg-card) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .toast,
body.dark-theme .toast {
  background: #1E293B !important;
  color: #F1F5F9 !important;
  border: 1px solid #334155 !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5) !important;
}

/* Screenshot 6: Settings Left Navigation & Shortcuts */
[data-theme="dark"] .settings-nav,
body.dark-theme .settings-nav {
  background: #0F172A !important;
  border-right-color: var(--border-color) !important;
}
[data-theme="dark"] .settings-nav-item,
body.dark-theme .settings-nav-item {
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .settings-nav-item:hover,
body.dark-theme .settings-nav-item:hover {
  background: var(--surface-hover) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .settings-nav-item.active,
body.dark-theme .settings-nav-item.active {
  background: rgba(59, 130, 246, 0.22) !important;
  color: #93C5FD !important;
}
[data-theme="dark"] .shortcut-row,
[data-theme="dark"] kbd,
body.dark-theme .shortcut-row,
body.dark-theme kbd {
  background: #1B2538 !important;
  border-color: #334155 !important;
  color: #E2E8F0 !important;
}

/* Bonus: Kanban, Reports, Drive & Data Table hover Dark Mode */
[data-theme="dark"] .kb-toolbar,
body.dark-theme .kb-toolbar {
  background: #151E2E !important;
  border-color: #263449 !important;
}
[data-theme="dark"] .kb-select,
[data-theme="dark"] .kb-search-input,
body.dark-theme .kb-select,
body.dark-theme .kb-search-input {
  background: #0F172A !important;
  border-color: #263449 !important;
  color: #F1F5F9 !important;
}
[data-theme="dark"] .kb-search-input::placeholder,
body.dark-theme .kb-search-input::placeholder {
  color: #64748B !important;
}
[data-theme="dark"] .kb-column,
body.dark-theme .kb-column {
  background: #111927 !important;
  border-color: #263449 !important;
}
[data-theme="dark"] .kb-col-body,
body.dark-theme .kb-col-body {
  background: transparent !important;
}
[data-theme="dark"] .kb-col-body--dragover,
body.dark-theme .kb-col-body--dragover {
  background: rgba(59, 130, 246, 0.14) !important;
  outline-color: #60A5FA !important;
}
[data-theme="dark"] .kb-col-empty,
body.dark-theme .kb-col-empty {
  background: rgba(15, 23, 42, 0.55) !important;
  border-color: #2B3B54 !important;
  color: #94A3B8 !important;
}
[data-theme="dark"] .col-header-todo,
body.dark-theme .col-header-todo {
  background: #1E293B !important;
  color: #E2E8F0 !important;
  border-bottom-color: #64748B !important;
}
[data-theme="dark"] .col-header-in-progress,
body.dark-theme .col-header-in-progress {
  background: #172554 !important;
  color: #93C5FD !important;
  border-bottom-color: #3B82F6 !important;
}
[data-theme="dark"] .col-header-review,
body.dark-theme .col-header-review {
  background: #422006 !important;
  color: #FDE68A !important;
  border-bottom-color: #F59E0B !important;
}
[data-theme="dark"] .col-header-done,
body.dark-theme .col-header-done {
  background: #064E3B !important;
  color: #6EE7B7 !important;
  border-bottom-color: #10B981 !important;
}
[data-theme="dark"] .kb-col-count,
body.dark-theme .kb-col-count {
  background: rgba(255, 255, 255, 0.14) !important;
  color: inherit !important;
}
[data-theme="dark"] .kb-card,
body.dark-theme .kb-card {
  background: #151E2E !important;
  border-color: #263449 !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35) !important;
}
[data-theme="dark"] .kb-card:hover,
body.dark-theme .kb-card:hover {
  border-color: #3B82F6 !important;
}
[data-theme="dark"] .kb-card-title,
body.dark-theme .kb-card-title {
  color: #F1F5F9 !important;
}
[data-theme="dark"] .kb-card-desc,
body.dark-theme .kb-card-desc {
  color: #94A3B8 !important;
}
[data-theme="dark"] .kb-card-cat-tag,
body.dark-theme .kb-card-cat-tag {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #93C5FD !important;
  border-color: rgba(96, 165, 250, 0.36) !important;
}
[data-theme="dark"] .kb-card-project-tag,
body.dark-theme .kb-card-project-tag {
  background: rgba(99, 102, 241, 0.22) !important;
  color: #C7D2FE !important;
  border-color: rgba(129, 140, 248, 0.38) !important;
}
[data-theme="dark"] .kb-card-due,
body.dark-theme .kb-card-due {
  background: #1E293B !important;
  color: #CBD5E1 !important;
  border: 1px solid #334155 !important;
}
[data-theme="dark"] .kb-priority-high,
[data-theme="dark"] .kb-card-due--overdue,
body.dark-theme .kb-priority-high,
body.dark-theme .kb-card-due--overdue {
  background: rgba(239, 68, 68, 0.22) !important;
  color: #FCA5A5 !important;
  border-color: rgba(248, 113, 113, 0.35) !important;
}
[data-theme="dark"] .kb-priority-medium,
body.dark-theme .kb-priority-medium {
  background: rgba(245, 158, 11, 0.22) !important;
  color: #FDE68A !important;
}
[data-theme="dark"] .kb-priority-low,
body.dark-theme .kb-priority-low {
  background: rgba(16, 185, 129, 0.22) !important;
  color: #6EE7B7 !important;
}
[data-theme="dark"] .kb-context-menu,
body.dark-theme .kb-context-menu {
  background: #151E2E !important;
  border-color: #263449 !important;
}
[data-theme="dark"] .kb-ctx-item:hover,
body.dark-theme .kb-ctx-item:hover {
  background: #1E293B !important;
}

/* Project Detail (.rp-*) Dark Mode fixes */
[data-theme="dark"] .rp-work-bar,
[data-theme="dark"] .rp-work-remaining,
body.dark-theme .rp-work-bar,
body.dark-theme .rp-work-remaining {
  background: #0F172A !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .rp-role-chip,
[data-theme="dark"] .rp-project-roles,
body.dark-theme .rp-role-chip,
body.dark-theme .rp-project-roles {
  background: #151E2E !important;
  border-color: #263449 !important;
  color: #E2E8F0 !important;
}
[data-theme="dark"] .rp-metric-done > i,
body.dark-theme .rp-metric-done > i {
  background: rgba(16, 185, 129, 0.20) !important;
  color: #6EE7B7 !important;
}
[data-theme="dark"] .rp-metric-doing > i,
body.dark-theme .rp-metric-doing > i {
  background: rgba(59, 130, 246, 0.20) !important;
  color: #93C5FD !important;
}
[data-theme="dark"] .rp-metric-risk > i,
body.dark-theme .rp-metric-risk > i {
  background: rgba(245, 158, 11, 0.20) !important;
  color: #FDE68A !important;
}
[data-theme="dark"] .rp-metric-late > i,
body.dark-theme .rp-metric-late > i {
  background: rgba(239, 68, 68, 0.20) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .rp-project-alert,
body.dark-theme .rp-project-alert {
  background: rgba(239, 68, 68, 0.14) !important;
  border-color: rgba(248, 113, 113, 0.35) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .rp-warning-status,
body.dark-theme .rp-warning-status {
  background: rgba(245, 158, 11, 0.18) !important;
  color: #FDE68A !important;
}
[data-theme="dark"] .rp-warning-overdue,
body.dark-theme .rp-warning-overdue {
  background: rgba(239, 68, 68, 0.20) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .rp-detail-table-wrap td,
[data-theme="dark"] .rp-detail-table-wrap th,
[data-theme="dark"] .rp-project-detail-list > h3,
[data-theme="dark"] .rp-design-progress-row,
[data-theme="dark"] .rp-file-table th,
[data-theme="dark"] .rp-file-table td,
body.dark-theme .rp-detail-table-wrap td,
body.dark-theme .rp-detail-table-wrap th,
body.dark-theme .rp-project-detail-list > h3,
body.dark-theme .rp-design-progress-row,
body.dark-theme .rp-file-table th,
body.dark-theme .rp-file-table td {
  border-color: #263449 !important;
}
[data-theme="dark"] .kb-card-assignee-name,
[data-theme="dark"] .donut-value,
[data-theme="dark"] .proj-name-label,
[data-theme="dark"] .file-card-name,
body.dark-theme .kb-card-assignee-name,
body.dark-theme .donut-value,
body.dark-theme .proj-name-label,
body.dark-theme .file-card-name { color: var(--text-primary) !important; }
[data-theme="dark"] .legend-item,
[data-theme="dark"] .proj-pct-right,
body.dark-theme .legend-item,
body.dark-theme .proj-pct-right { color: var(--text-secondary) !important; }
[data-theme="dark"] .chip,
[data-theme="dark"] .filter-chip,
body.dark-theme .chip,
body.dark-theme .filter-chip {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .chip:hover,
[data-theme="dark"] .data-table tr:hover td,
body.dark-theme .chip:hover,
body.dark-theme .data-table tr:hover td {
  background: #1B2538 !important;
}
[data-theme="dark"] .file-cat-pill,
body.dark-theme .file-cat-pill {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #93C5FD !important;
}
[data-theme="dark"] .table,
body.dark-theme .table {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
}

/* 2. COMPACT DENSITY MODE (14" Laptop Optimization) */
[data-density="compact"] .hub-table td,
[data-density="compact"] .hub-table th,
[data-density="compact"] .data-table td,
[data-density="compact"] .data-table th {
  padding-top: 6px !important;
  padding-bottom: 6px !important;
  font-size: 12.5px;
}
[data-density="compact"] .stat-card {
  padding: 12px 14px;
}
[data-density="compact"] .content-area {
  padding: 14px 16px;
}

/* 3. STICKY MODAL HEADER/FOOTER ON SMALL SCREENS */
.modal {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
}
.modal .modal-body {
  overflow-y: auto;
  flex: 1 1 auto;
}
.modal .modal-header,
.modal .modal-footer {
  flex-shrink: 0;
}

/* 4. SLIDE-OVER DRAWER (60fps GPU) */
.mo-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.mo-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}
.mo-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 96vw);
  background: var(--bg-card);
  color: var(--text-primary);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 1201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.mo-drawer.is-open {
  transform: translateX(0);
}
.mo-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.mo-drawer-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.mo-drawer-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}
.mo-drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 20px;
}
.mo-drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
}

/* 5. COMMAND PALETTE (Ctrl+K) */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.50);
  backdrop-filter: blur(4px);
  z-index: 1300;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: min(12vh, 96px) 16px 24px;
}
.cmd-palette-overlay.is-open {
  display: flex;
}
.cmd-palette {
  width: min(620px, 100%);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.cmd-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}
.cmd-input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-family);
}
.cmd-kbd {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.cmd-list {
  max-height: min(56vh, 420px);
  overflow-y: auto;
  padding: 8px;
}
.cmd-group-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}
.cmd-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  font-size: 13.5px;
}
.cmd-item:hover,
.cmd-item.is-active {
  background: rgba(37, 99, 235, 0.12);
  color: var(--text-accent);
}
.cmd-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* 6. ACTIVE SESSIONS & PROJECT TEMPLATES & BASELINE GANTT */
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--surface-subtle);
}
.session-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
  word-break: break-word;
}
.tpl-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface-subtle);
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease;
}
.tpl-card:hover {
  border-color: var(--color-primary-500);
  transform: translateY(-1px);
}
.tpl-card.is-selected {
  border-color: var(--color-primary-600);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
.gantt-baseline-bar {
  position: absolute;
  height: 4px;
  bottom: 2px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, #94A3B8 0 6px, transparent 6px 10px);
  pointer-events: none;
  opacity: 0.85;
}

/* 7. MOBILE BOTTOM NAV, CARD VIEW & OFFLINE BANNER (< 768px) */
.mobile-bottom-nav {
  display: none;
}
.offline-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1400;
  background: #DC2626;
  color: #FFFFFF;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  display: none;
}
.offline-banner.is-visible {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 14px rgba(15, 23, 42, 0.08);
  }
  .mobile-nav-btn {
    min-height: 48px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
  }
  .mobile-nav-btn i {
    font-size: 16px;
  }
  .mobile-nav-btn.is-active {
    color: var(--color-primary-600);
    background: rgba(37, 99, 235, 0.08);
  }
  .content-area {
    padding-bottom: 76px !important;
  }
  .topbar .search-box {
    display: none;
  }
  .stats-grid,
  .rep-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .btn,
  .topbar-btn,
  .form-input,
  .form-select {
    min-height: 44px;
  }
  .hub-table-wrap,
  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }
  .offline-banner {
    bottom: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mo-drawer,
  .mo-drawer-backdrop,
  .tpl-card {
    transition: none !important;
  }
}

/* ==========================================================================
   Dark Mode Pass 4 — Exhaustive Zero-White V2 Sweep
   ========================================================================== */

/* style.css: Auth, Topbar User Menu, Search, Utility */
[data-theme="dark"] .auth-title-section h2,
body.dark-theme .auth-title-section h2 {
  color: var(--text-primary) !important;
}
[data-theme="dark"] .auth-label,
body.dark-theme .auth-label {
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .auth-input-wrapper,
body.dark-theme .auth-input-wrapper {
  background: var(--bg-input) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .auth-input-wrapper:hover,
body.dark-theme .auth-input-wrapper:hover {
  border-color: var(--border-strong) !important;
}
[data-theme="dark"] .auth-input-wrapper:focus-within,
body.dark-theme .auth-input-wrapper:focus-within {
  background: var(--bg-input) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
}
[data-theme="dark"] .auth-error-box,
body.dark-theme .auth-error-box {
  background: rgba(239, 68, 68, 0.16) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .user-avatar,
body.dark-theme .user-avatar {
  background: rgba(59, 130, 246, 0.22) !important;
  color: #93C5FD !important;
  border-color: rgba(59, 130, 246, 0.38) !important;
}
[data-theme="dark"] .user-menu-btn:hover,
body.dark-theme .user-menu-btn:hover,
[data-theme="dark"] .search-result-item:hover,
body.dark-theme .search-result-item:hover {
  background: var(--bg-elevated) !important;
}
[data-theme="dark"] .text-primary,
body.dark-theme .text-primary {
  color: #60A5FA !important;
}

/* projects.js: Filters, View Switcher, Action Buttons, Status & Priority Pills */
[data-theme="dark"] .pm-select-active,
body.dark-theme .pm-select-active {
  background: rgba(59, 130, 246, 0.16) !important;
  border-color: var(--primary) !important;
  color: #93C5FD !important;
}
[data-theme="dark"] .pm-view-btn.active,
body.dark-theme .pm-view-btn.active {
  background: rgba(59, 130, 246, 0.22) !important;
  color: #93C5FD !important;
  border-color: rgba(59, 130, 246, 0.45) !important;
}
[data-theme="dark"] .pm-filter-tag,
body.dark-theme .pm-filter-tag {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #93C5FD !important;
  border-color: rgba(59, 130, 246, 0.35) !important;
}
[data-theme="dark"] .pm-action-btn:hover,
body.dark-theme .pm-action-btn:hover,
[data-theme="dark"] .pm-icon-btn:hover,
body.dark-theme .pm-icon-btn:hover {
  background: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
}
[data-theme="dark"] .pm-action-view:hover,
body.dark-theme .pm-action-view:hover {
  background: rgba(59, 130, 246, 0.2) !important;
  color: #93C5FD !important;
  border-color: rgba(59, 130, 246, 0.4) !important;
}
[data-theme="dark"] .pm-action-kanban:hover,
body.dark-theme .pm-action-kanban:hover,
[data-theme="dark"] .pm-icon-btn.pm-action-kanban:hover,
body.dark-theme .pm-icon-btn.pm-action-kanban:hover {
  background: rgba(139, 92, 246, 0.2) !important;
  color: #DDD6FE !important;
  border-color: rgba(139, 92, 246, 0.4) !important;
}
[data-theme="dark"] .pm-action-edit:hover,
body.dark-theme .pm-action-edit:hover,
[data-theme="dark"] .pm-icon-btn.pm-action-edit:hover,
body.dark-theme .pm-icon-btn.pm-action-edit:hover {
  background: rgba(245, 158, 11, 0.18) !important;
  color: #FDE68A !important;
  border-color: rgba(245, 158, 11, 0.4) !important;
}
[data-theme="dark"] .pm-action-delete:hover,
body.dark-theme .pm-action-delete:hover,
[data-theme="dark"] .pm-icon-btn-danger:hover,
body.dark-theme .pm-icon-btn-danger:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #FCA5A5 !important;
  border-color: rgba(239, 68, 68, 0.42) !important;
}
[data-theme="dark"] .status-active,
body.dark-theme .status-active {
  background: rgba(59, 130, 246, 0.2) !important;
  color: #93C5FD !important;
  border-color: rgba(59, 130, 246, 0.38) !important;
}
[data-theme="dark"] .status-completed,
body.dark-theme .status-completed {
  background: rgba(16, 185, 129, 0.2) !important;
  color: #6EE7B7 !important;
  border-color: rgba(16, 185, 129, 0.38) !important;
}
[data-theme="dark"] .status-on-hold,
body.dark-theme .status-on-hold {
  background: rgba(245, 158, 11, 0.2) !important;
  color: #FDE68A !important;
  border-color: rgba(245, 158, 11, 0.38) !important;
}
[data-theme="dark"] .status-cancelled,
body.dark-theme .status-cancelled {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #FCA5A5 !important;
  border-color: rgba(239, 68, 68, 0.38) !important;
}
[data-theme="dark"] .status-planning,
body.dark-theme .status-planning {
  background: rgba(139, 92, 246, 0.2) !important;
  color: #DDD6FE !important;
  border-color: rgba(139, 92, 246, 0.38) !important;
}
[data-theme="dark"] .status-default,
body.dark-theme .status-default,
[data-theme="dark"] .priority-default,
body.dark-theme .priority-default {
  background: var(--bg-elevated) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] .priority-critical,
body.dark-theme .priority-critical {
  background: rgba(239, 68, 68, 0.22) !important;
  color: #FCA5A5 !important;
  border-color: rgba(239, 68, 68, 0.42) !important;
}
[data-theme="dark"] .priority-low,
body.dark-theme .priority-low {
  background: rgba(16, 185, 129, 0.18) !important;
  color: #6EE7B7 !important;
  border-color: rgba(16, 185, 129, 0.36) !important;
}

/* tasks.js: Overdue rows & status/priority badges */
[data-theme="dark"] .tk-row-overdue,
body.dark-theme .tk-row-overdue {
  background: rgba(239, 68, 68, 0.1) !important;
}
[data-theme="dark"] .tk-row-overdue:hover,
body.dark-theme .tk-row-overdue:hover {
  background: rgba(239, 68, 68, 0.16) !important;
}
[data-theme="dark"] .tk-overdue-badge,
body.dark-theme .tk-overdue-badge,
[data-theme="dark"] .tp-high,
body.dark-theme .tp-high {
  background: rgba(239, 68, 68, 0.22) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .tk-soon-badge,
body.dark-theme .tk-soon-badge,
[data-theme="dark"] .tp-medium,
body.dark-theme .tp-medium {
  background: rgba(245, 158, 11, 0.22) !important;
  color: #FDE68A !important;
}
[data-theme="dark"] .ts-todo,
body.dark-theme .ts-todo {
  background: var(--bg-elevated) !important;
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .ts-inprogress,
body.dark-theme .ts-inprogress {
  background: rgba(59, 130, 246, 0.2) !important;
  color: #93C5FD !important;
}
[data-theme="dark"] .ts-review,
body.dark-theme .ts-review {
  background: rgba(139, 92, 246, 0.22) !important;
  color: #DDD6FE !important;
}
[data-theme="dark"] .ts-done,
body.dark-theme .ts-done,
[data-theme="dark"] .tp-low,
body.dark-theme .tp-low {
  background: rgba(16, 185, 129, 0.2) !important;
  color: #6EE7B7 !important;
}

/* project-detail.css */
[data-theme="dark"] .rp-edit-project:hover,
body.dark-theme .rp-edit-project:hover {
  background: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
}
[data-theme="dark"] .rp-metric-done > i,
body.dark-theme .rp-metric-done > i {
  background: rgba(16, 185, 129, 0.2) !important;
  color: #6EE7B7 !important;
}
[data-theme="dark"] .rp-metric-doing > i,
body.dark-theme .rp-metric-doing > i {
  background: rgba(59, 130, 246, 0.2) !important;
  color: #93C5FD !important;
}
[data-theme="dark"] .rp-metric-late > i,
body.dark-theme .rp-metric-late > i {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .rp-metric-risk > i,
body.dark-theme .rp-metric-risk > i {
  background: rgba(245, 158, 11, 0.2) !important;
  color: #FDE68A !important;
}
[data-theme="dark"] .rp-summary-progress-line progress,
body.dark-theme .rp-summary-progress-line progress,
[data-theme="dark"] .rp-summary-progress-line progress::-webkit-progress-bar,
body.dark-theme .rp-summary-progress-line progress::-webkit-progress-bar {
  background: var(--bg-elevated) !important;
}

/* hub.css, planning.css, bom.css, organization.css, settings.js, kanban.js */
[data-theme="dark"] .hub-stat:nth-child(2) .hub-stat-icon,
body.dark-theme .hub-stat:nth-child(2) .hub-stat-icon {
  background: rgba(16, 185, 129, 0.2) !important;
  color: #6EE7B7 !important;
}
[data-theme="dark"] .hub-stat:nth-child(3) .hub-stat-icon,
body.dark-theme .hub-stat:nth-child(3) .hub-stat-icon {
  background: rgba(245, 158, 11, 0.2) !important;
  color: #FDE68A !important;
}
[data-theme="dark"] .hub-stat:nth-child(4) .hub-stat-icon,
body.dark-theme .hub-stat:nth-child(4) .hub-stat-icon {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .dash-alert-compact,
body.dark-theme .dash-alert-compact {
  background: rgba(239, 68, 68, 0.14) !important;
  border-color: rgba(239, 68, 68, 0.36) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .dash-alert-compact__text strong,
body.dark-theme .dash-alert-compact__text strong {
  color: #FECACA !important;
}
[data-theme="dark"] .hub-calendar button.has-record,
body.dark-theme .hub-calendar button.has-record {
  background: rgba(59, 130, 246, 0.22) !important;
  color: #93C5FD !important;
  border-color: rgba(59, 130, 246, 0.42) !important;
}
[data-theme="dark"] .pl-trow.l0:hover,
body.dark-theme .pl-trow.l0:hover {
  background: rgba(59, 130, 246, 0.16) !important;
}
[data-theme="dark"] .pl-import-error-icon,
body.dark-theme .pl-import-error-icon {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #FCA5A5 !important;
}
[data-theme="dark"] .pl-import-error-list,
body.dark-theme .pl-import-error-list {
  background: var(--bg-input) !important;
  border-color: var(--border) !important;
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .pl-import-error-list strong,
body.dark-theme .pl-import-error-list strong {
  color: var(--text-primary) !important;
}
[data-theme="dark"] .bom-del-row-btn:hover,
body.dark-theme .bom-del-row-btn:hover,
[data-theme="dark"] .org-recovery-actions .org-recovery-delete:hover,
body.dark-theme .org-recovery-actions .org-recovery-delete:hover,
[data-theme="dark"] .kb-ctx-item--delete:hover,
body.dark-theme .kb-ctx-item--delete:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #FCA5A5 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}
[data-theme="dark"] .settings-container,
body.dark-theme .settings-container {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .section-title,
body.dark-theme .section-title {
  color: var(--text-primary) !important;
}

/* === GEMINI FRONTEND DESIGN STANDARD LAYER === */
/* 1. Single-line desktop topbar with crisp surface separation & zero collision */
.topbar {
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border-color);
}
.topbar-title, .breadcrumb {
  letter-spacing: -0.02em;
}

/* 2. Consistent body prose & list scale + tabular numerals */
.page-content p,
.page-content li {
  line-height: 1.55;
}
.stat-value, .kpi-value, .exec-metric > strong, .hub-stat strong,
.pc-kpi strong, .org-stat strong, .rp-metric strong, .rp-summary-grid strong,
table td, .badge {
  font-variant-numeric: tabular-nums;
}

/* 3. Flatten nested card-in-card cages with subtle surface tint & 1px dividers */
.card .card,
.hub-card .hub-card,
.exec-panel .exec-panel,
.pc-panel .pc-project-card {
  box-shadow: none;
}
.card .card,
.hub-card .hub-card,
.exec-panel .exec-panel {
  background: var(--surface-subtle, #F8FAFC);
}

/* 4. Zero horizontal overflow on desktop and 390x844 mobile viewports */
html, body, .app-wrapper, .main-wrapper, .content-area {
  max-width: 100%;
  overflow-x: clip;
}
@media (max-width: 480px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .topbar .search-box,
  .topbar .global-search {
    min-width: 0;
    flex: 1 1 auto;
  }
  .content-area {
    padding: 12px;
  }
}

/* 5. Respect prefers-reduced-motion universally */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
