/* -------------------------------------------------
   TaskControl Theme Overrides
   Clean dark/light styling based on MudBlazor palette variables.
   Loaded last so it replaces old hardcoded dark/light CSS blocks.
-------------------------------------------------- */

/*html,
body,
.app-shell,
.main-content {
    background: var(--mud-palette-background) !important;
    color: var(--mud-palette-text-primary) !important;
}

body,
.mud-typography,
.mud-input,
.mud-input-root,
.mud-select,
.mud-input-control,
input,
textarea {
    color: var(--mud-palette-text-primary) !important;
}

input::placeholder,
textarea::placeholder {
    color: var(--mud-palette-text-secondary) !important;
    opacity: .9 !important;
}

.mud-input-label,
.mud-input-adornment,
.mud-icon-root,
.muted,
small {
    color: var(--mud-palette-text-secondary) !important;
}

.mud-input-outlined-border {
    border-color: color-mix(in srgb, var(--mud-palette-primary) 14%, var(--mud-palette-divider)) !important;
}

.page-header h1,
.page-header h2,
.page-header h3,
.panel-title,
.row-title,
h1,
h2,
h3 {
    color: var(--mud-palette-text-primary) !important;
}

.page-header p,
.panel-subtitle,
.saas-panel p {
    color: var(--mud-palette-text-secondary) !important;
}*/

/* -------------------------------------------------
   Layout / Sidebar / Topbar
-------------------------------------------------- */

/*.saas-sidebar,
.topbar {
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border-color: var(--mud-palette-divider) !important;
}

.brand-title,
.mini-title,
.user-info b,
.notification-title {
    color: var(--mud-palette-text-primary) !important;
}

.brand-subtitle,
.sidebar-section,
.mini-label,
.mini-text,
.user-info span,
.notification-subtitle {
    color: var(--mud-palette-text-secondary) !important;
}

.sidebar-card,
.notification-menu,
.notification-card,
.user-menu-card {
    background: color-mix(in srgb, var(--mud-palette-surface) 92%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
    color: var(--mud-palette-text-primary) !important;
}

.mud-nav-link {
    color: var(--mud-palette-text-secondary) !important;
    border-radius: 12px !important;
}

.mud-nav-link .mud-nav-link-text,
.mud-nav-link .mud-icon-root {
    color: var(--mud-palette-text-secondary) !important;
}

.mud-nav-link:hover,
.mud-nav-link.active,
.mud-nav-link.mud-nav-link-active {
    background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent) !important;
    color: var(--mud-palette-primary) !important;
}

.mud-nav-link:hover .mud-nav-link-text,
.mud-nav-link:hover .mud-icon-root,
.mud-nav-link.active .mud-nav-link-text,
.mud-nav-link.active .mud-icon-root,
.mud-nav-link.mud-nav-link-active .mud-nav-link-text,
.mud-nav-link.mud-nav-link-active .mud-icon-root {
    color: var(--mud-palette-primary) !important;
}*/

/* -------------------------------------------------
   Common cards / panels / toolbar zones
-------------------------------------------------- */

/*.saas-panel,
.metric-card,
.task-table-card,
.task-data-grid,
.task-filter-panel,
.chart-panel,
.calendar-shell,
.calendar-card,
.board-panel,
.kanban-column,
.report-card,
.ai-panel,
.ai-chat-panel,
.settings-card,
.task-short-card,
.erp-list-shell,
.erp-list-toolbar-zone,
.erp-grid-shell {
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .10) !important;
}

.card-soft,
.overview-widget-card,
.overview-mini-grid div,
.task-overview-card,
.task-progress-panel,
.task-details-meta-grid > div,
.task-short-card,
.task-card,
.ai-message,
.ai-suggestion,
.report-widget,
.calendar-side-panel {
    background: color-mix(in srgb, var(--mud-palette-surface) 88%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
    color: var(--mud-palette-text-primary) !important;
}*/

/* -------------------------------------------------
   Data tables / grids
-------------------------------------------------- */

/*.task-table,
.erp-data-grid,
.mud-table,
.mud-table-container {
    background: transparent !important;
    color: var(--mud-palette-text-primary) !important;
}

.task-table thead,
.erp-data-grid .mud-table-head th,
.mud-table-head th {
    background: color-mix(in srgb, var(--mud-palette-surface) 94%, var(--mud-palette-background)) !important;
    color: var(--mud-palette-text-secondary) !important;
    border-bottom: 1px solid var(--mud-palette-divider) !important;
}

.task-table th,
.task-table td,
.erp-data-grid .mud-table-body td,
.mud-table-body td {
    color: var(--mud-palette-text-primary) !important;
    border-bottom: 1px solid color-mix(in srgb, var(--mud-palette-divider) 70%, transparent) !important;
}

.task-table tr:hover,
.erp-data-grid .mud-table-body tr:hover,
.mud-table-body tr:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 6%, transparent) !important;
}

.task-title-cell b,
.task-title-button,
.impact-cell b,
.activity-cell,
.progress-cell small {
    color: var(--mud-palette-text-primary) !important;
}

.task-title-cell span,
.impact-cell span,
.table-footer,
.activity-cell span {
    color: var(--mud-palette-text-secondary) !important;
}

.activity-cell span,
.pager button,
.table-footer {
    background: color-mix(in srgb, var(--mud-palette-surface) 88%, transparent) !important;
    border-color: color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
}

.pager button.active {
    background: var(--mud-palette-primary) !important;
    border-color: var(--mud-palette-primary) !important;
    color: white !important;
}*/

/* -------------------------------------------------
   Filters / tabs / search controls
-------------------------------------------------- */

/*.task-tabs button,
.task-filter-control .mud-input-root,
.task-search-control .mud-input-root,
.erp-list-search .mud-input-root,
.calendar-filter .mud-input-root,
.report-filter .mud-input-root {
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border-color: color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
}

.task-tabs button.active {
    background: color-mix(in srgb, var(--mud-palette-primary) 14%, transparent) !important;
    color: var(--mud-palette-primary) !important;
    border-bottom-color: var(--mud-palette-primary) !important;
}

.task-tabs b,
.erp-grid-chip,
.tag-chip {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent) !important;
    color: var(--mud-palette-text-secondary) !important;
    border-color: color-mix(in srgb, var(--mud-palette-primary) 14%, var(--mud-palette-divider)) !important;
}*/

/* -------------------------------------------------
   Drawers and forms
-------------------------------------------------- */

/*.new-task-drawer .mud-drawer,
.task-drawer-panel,
.task-form-drawer,
.drawer-content {
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border-color: var(--mud-palette-divider) !important;
}

.drawer-header h2,
.drawer-header.compact h2,
.task-form-drawer h3,
.drawer-label,
.fake-editor-toolbar span,
.upload-preview-item b {
    color: var(--mud-palette-text-primary) !important;
}

.drawer-helper-text,
.upload-zone,
.upload-zone small,
.upload-preview-item small {
    color: var(--mud-palette-text-secondary) !important;
}

.fake-editor-toolbar,
.upload-zone,
.clickable-upload,
.upload-preview-item,
.rich-editor {
    background: color-mix(in srgb, var(--mud-palette-surface) 88%, transparent) !important;
    border-color: color-mix(in srgb, var(--mud-palette-primary) 12%, var(--mud-palette-divider)) !important;
    color: var(--mud-palette-text-secondary) !important;
}

.drawer-footer {
    background: linear-gradient(180deg, transparent, var(--mud-palette-surface) 38%) !important;
}*/

/* -------------------------------------------------
   Board / Kanban
-------------------------------------------------- */

/*.kanban-header,
.kanban-header b,
.task-card-title,
.task-card b {
    color: var(--mud-palette-text-primary) !important;
}

.kanban-header span,
.task-card span,
.task-card small,
.task-card p {
    color: var(--mud-palette-text-secondary) !important;
}

.task-card:hover,
.kanban-column:hover {
    border-color: color-mix(in srgb, var(--mud-palette-primary) 20%, var(--mud-palette-divider)) !important;
}*/

/* -------------------------------------------------
   Calendar
-------------------------------------------------- */

/*.calendar-page,
.calendar-wrapper,
.calendar-toolbar,
.calendar-panel,
.calendar-task-card,
.calendar-day-card,
.calendar-event-card {
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border-color: color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
}

.calendar-muted,
.calendar-task-card span,
.calendar-task-card small,
.calendar-day-card span {
    color: var(--mud-palette-text-secondary) !important;
}*/

/* -------------------------------------------------
   Dashboard / reports charts
-------------------------------------------------- */

/*.chart-placeholder,
.trend-chart,
.report-chart,
.report-kpi,
.report-list-item {
    background: color-mix(in srgb, var(--mud-palette-surface) 88%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
    color: var(--mud-palette-text-primary) !important;
}

.trend-label-row span,
.report-list-item span,
.metric-card span,
.metric-card small {
    color: var(--mud-palette-text-secondary) !important;
}

.metric-card strong,
.report-kpi strong {
    color: var(--mud-palette-text-primary) !important;
}*/

/* -------------------------------------------------
   AI intake
-------------------------------------------------- */

/*.ai-chat-window,
.ai-input-zone,
.ai-task-preview,
.ai-message.assistant,
.ai-message.user,
.ai-sidebar-card {
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border-color: color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
}

.ai-message p,
.ai-sidebar-card p,
.ai-task-preview p {
    color: var(--mud-palette-text-secondary) !important;
}*/

/* -------------------------------------------------
   Task dialogs: Overview / Chat / SubTasks / Attachments / History
-------------------------------------------------- */

/*.task-work-dialog .mud-dialog,
.task-overview-dialog .mud-dialog,
.task-details-dialog .mud-dialog {
    overflow: hidden;
    border-radius: 18px !important;
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 12%, var(--mud-palette-divider)) !important;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .28) !important;
}

.task-work-dialog .mud-dialog-title,
.task-overview-dialog .mud-dialog-title,
.task-details-dialog .mud-dialog-title {
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border-bottom: 1px solid var(--mud-palette-divider) !important;
    padding: 22px 28px !important;
}

.task-work-dialog .mud-dialog-content,
.task-overview-dialog .mud-dialog-content,
.task-details-dialog .mud-dialog-content {
    background: var(--mud-palette-background) !important;
    color: var(--mud-palette-text-primary) !important;
    padding: 24px 28px !important;
    min-height: 520px;
}

.task-work-dialog .mud-dialog-actions,
.task-overview-dialog .mud-dialog-actions,
.task-details-dialog .mud-dialog-actions {
    background: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border-top: 1px solid var(--mud-palette-divider) !important;
    padding: 14px 20px !important;
}

.task-dialog-title h2,
.task-details-titlebar h2 {
    margin: 0;
    color: var(--mud-palette-text-primary) !important;
    font-weight: 900;
}

.task-dialog-title p,
.task-details-titlebar p {
    margin: 6px 0 0;
    color: var(--mud-palette-text-secondary) !important;
}

.task-dialog-title b,
.task-details-titlebar b {
    color: var(--mud-palette-primary) !important;
}

.task-work-dialog .mud-dialog-title .mud-icon-root,
.task-work-dialog .mud-dialog-title .mud-icon-button,
.task-overview-dialog .mud-dialog-title .mud-icon-root,
.task-overview-dialog .mud-dialog-title .mud-icon-button,
.task-details-dialog .mud-dialog-title .mud-icon-root,
.task-details-dialog .mud-dialog-title .mud-icon-button {
    color: var(--mud-palette-text-secondary) !important;
}

.task-work-dialog .empty-state,
.task-overview-dialog .empty-state,
.task-details-dialog .empty-state,
.empty-state,
.empty-state.compact {
    background: color-mix(in srgb, var(--mud-palette-surface) 86%, transparent) !important;
    border: 1px dashed color-mix(in srgb, var(--mud-palette-primary) 14%, var(--mud-palette-divider)) !important;
    color: var(--mud-palette-text-secondary) !important;
}

.chat-author-chip {
    min-width: 180px;
    padding: 8px 12px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--mud-palette-surface) 90%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 12%, var(--mud-palette-divider)) !important;
}

.chat-author-chip span {
    display: block;
    color: var(--mud-palette-text-secondary) !important;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.chat-author-chip b {
    display: block;
    color: var(--mud-palette-text-primary) !important;
    font-size: 13px;
}

.task-chat-dialog .task-chat-window {
    background: transparent !important;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 420px;
    max-height: 52vh;
    overflow-y: auto;
    padding: 8px 0 28px;
}

.task-chat-dialog .task-chat-message {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.task-chat-dialog .task-chat-bubble,
.task-chat-bubble {
    flex: 1;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--mud-palette-surface) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
    color: var(--mud-palette-text-primary) !important;
}

.task-chat-top b {
    color: var(--mud-palette-text-primary) !important;
}

.task-chat-top span,
.task-chat-bubble p {
    color: var(--mud-palette-text-secondary) !important;
}

.task-chat-dialog .sticky-chat-input,
.sticky-chat-input,
.task-chat-input {
    background: var(--mud-palette-background) !important;
    border-top: 1px solid var(--mud-palette-divider) !important;
    margin-top: 18px;
    padding: 18px 0 0;
}

.task-subtasks-dialog .subtask-tree,
.subtask-tree {
    background: color-mix(in srgb, var(--mud-palette-surface) 86%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
    border-radius: 18px;
}

.task-subtasks-dialog .subtask-root,
.subtask-root {
    background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 24%, transparent) !important;
}

.task-subtasks-dialog .subtask-tree-item,
.subtask-tree-item,
.subtask-item,
.subtask-tree-child {
    background: var(--mud-palette-surface) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
}

.subtask-root b,
.subtask-tree-item b,
.subtask-main b {
    color: var(--mud-palette-text-primary) !important;
}

.subtask-root span,
.subtask-tree-item span,
.subtask-main span,
.subtask-tree-child span {
    color: var(--mud-palette-text-secondary) !important;
}

.subtask-branches {
    border-left-color: color-mix(in srgb, var(--mud-palette-primary) 16%, var(--mud-palette-divider)) !important;
}

.task-subtasks-dialog .subtask-add-panel,
.subtask-add-panel {
    border-top-color: var(--mud-palette-divider) !important;
}

.task-attachments-dialog .task-upload-box,
.task-upload-box,
.upload-zone,
.clickable-upload {
    background: var(--mud-palette-surface) !important;
    border-color: color-mix(in srgb, var(--mud-palette-primary) 16%, var(--mud-palette-divider)) !important;
    color: var(--mud-palette-text-secondary) !important;
}

.task-attachments-dialog .task-upload-box:hover,
.task-upload-box:hover,
.clickable-upload:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface)) !important;
    border-color: color-mix(in srgb, var(--mud-palette-primary) 38%, var(--mud-palette-divider)) !important;
}

.attachment-card,
.attachment-card.image-card,
.upload-preview-item {
    background: var(--mud-palette-surface) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
    color: var(--mud-palette-text-secondary) !important;
}

.attachment-card b,
.attachment-card.image-card b,
.upload-preview-item b {
    color: var(--mud-palette-text-primary) !important;
}

.attachment-card small,
.attachment-card.image-card small,
.upload-preview-item small {
    color: var(--mud-palette-text-secondary) !important;
}

.history-item {
    background: var(--mud-palette-surface) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-divider)) !important;
    color: var(--mud-palette-text-secondary) !important;
}

.history-item b {
    color: var(--mud-palette-text-primary) !important;
}

.history-item span {
    color: var(--mud-palette-text-secondary) !important;
}

.history-dot {
    background: var(--mud-palette-primary) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--mud-palette-primary) 16%, transparent) !important;
}

.overview-stage-card {
    background: color-mix(in srgb, var(--mud-palette-surface) 88%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 14%, var(--mud-palette-divider)) !important;
}

.overview-stage-card h3 {
    color: var(--mud-palette-text-primary) !important;
}

.overview-stage-card p,
.task-description,
.overview-chat-row span {
    color: var(--mud-palette-text-secondary) !important;
}

.overview-progress-number {
    background: color-mix(in srgb, var(--mud-palette-primary) 14%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 26%, transparent) !important;
    color: var(--mud-palette-primary) !important;
}

.overview-widget-title span {
    background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent) !important;
    color: var(--mud-palette-primary) !important;
}*/

/* Keep semantic/status colors explicit */
/*.badge.status.new,
.badge.status.inprogress,
.badge.status.review,
.badge.status.blocked,
.badge.status.done,
.badge.priority.low,
.badge.priority.medium,
.badge.priority.high,
.badge.priority.critical,
.project-dot,
.progress-fill,
.due-overdue,
.due-done {*/
    /* semantic colors intentionally remain hardcoded */
/*}

@media (max-width: 760px) {
    .task-subtasks-dialog .subtask-add-panel,
    .subtask-add-panel {
        grid-template-columns: 1fr !important;
    }

    .task-work-dialog .mud-dialog-content,
    .task-overview-dialog .mud-dialog-content,
    .task-details-dialog .mud-dialog-content {
        padding: 18px !important;
    }
}*/

/* External user dropdown spacing */
/*.select-option {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    min-width: 0;
}

.select-option .mini-avatar,
.mini-avatar {
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    font-size: 11px;
    font-weight: 900;
    color: white;
    background: var(--mud-palette-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--mud-palette-primary) 16%, transparent);
}*/

/* -------------------------------------------------
   v57 Theme audit fixes
   These rules keep the custom SaaS UI readable in both dark and light modes.
   They intentionally use the existing .dark-mode / .light-mode classes from MainLayout.
-------------------------------------------------- */

.app-shell.dark-mode,
.dark-mode .main-content,
.dark-mode .mud-main-content {
    background: #0B1220 !important;
    color: #F9FAFB !important;
}

.app-shell.light-mode,
.light-mode .main-content,
.light-mode .mud-main-content {
    background: #F8FAFC !important;
    color: #0F172A !important;
}

.light-mode .page-header h1,
.light-mode .page-header h2,
.light-mode .page-header h3,
.light-mode h1,
.light-mode h2,
.light-mode h3,
.light-mode h4,
.light-mode .panel-title,
.light-mode .row-title,
.light-mode .section-title,
.light-mode .task-title-button,
.light-mode .task-title-cell b,
.light-mode .brand-title,
.light-mode .mini-title,
.light-mode .user-info b {
    color: #0F172A !important;
}

.light-mode .page-header p,
.light-mode .muted,
.light-mode small,
.light-mode .panel-subtitle,
.light-mode .brand-subtitle,
.light-mode .sidebar-section,
.light-mode .mini-label,
.light-mode .mini-text,
.light-mode .user-info span,
.light-mode .task-title-cell span,
.light-mode .table-footer,
.light-mode .activity-cell span,
.light-mode .progress-cell small {
    color: #64748B !important;
}

.light-mode .topbar,
.light-mode .saas-sidebar,
.light-mode .mud-drawer,
.light-mode .mud-appbar {
    background: #FFFFFF !important;
    color: #0F172A !important;
    border-color: #E5E7EB !important;
}

.light-mode .saas-panel,
.light-mode .metric-card,
.light-mode .task-table-card,
.light-mode .task-data-grid,
.light-mode .task-filter-panel,
.light-mode .chart-panel,
.light-mode .calendar-shell,
.light-mode .calendar-card,
.light-mode .board-panel,
.light-mode .kanban-column,
.light-mode .report-card,
.light-mode .ai-panel,
.light-mode .ai-chat-panel,
.light-mode .settings-card,
.light-mode .task-short-card,
.light-mode .erp-list-shell,
.light-mode .erp-list-toolbar-zone,
.light-mode .erp-grid-shell,
.light-mode .overview-widget-card,
.light-mode .task-overview-card,
.light-mode .task-progress-panel,
.light-mode .advanced-filters-panel,
.light-mode .advanced-filters-content,
.light-mode .filter-group,
.light-mode .clean-list-panel,
.light-mode .task-details-panel,
.light-mode .detail-card,
.light-mode .meeting-note-row,
.light-mode .notification-menu,
.light-mode .user-menu-card,
.light-mode .sidebar-card {
    background: #FFFFFF !important;
    color: #0F172A !important;
    border-color: #E2E8F0 !important;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .08) !important;
}

.light-mode .card-soft,
.light-mode .overview-mini-grid div,
.light-mode .task-details-meta-grid > div,
.light-mode .task-card,
.light-mode .ai-message,
.light-mode .ai-suggestion,
.light-mode .report-widget,
.light-mode .calendar-side-panel,
.light-mode .meeting-note-content,
.light-mode .review-summary-card,
.light-mode .clean-list-row,
.light-mode .timeline-card,
.light-mode .task-timeline-item {
    background: #F8FAFC !important;
    color: #0F172A !important;
    border-color: #E2E8F0 !important;
}

.light-mode .task-table,
.light-mode .erp-data-grid,
.light-mode .mud-table,
.light-mode .mud-table-container {
    background: transparent !important;
    color: #0F172A !important;
}

.light-mode .task-table thead,
.light-mode .task-table th,
.light-mode .erp-data-grid .mud-table-head th,
.light-mode .mud-table-head th {
    background: #F1F5F9 !important;
    color: #334155 !important;
    border-bottom-color: #CBD5E1 !important;
}

.light-mode .task-table td,
.light-mode .erp-data-grid .mud-table-body td,
.light-mode .mud-table-body td,
.light-mode .mud-table-row,
.light-mode .task-row {
    color: #0F172A !important;
    border-bottom-color: #E2E8F0 !important;
}

.light-mode .task-table tr:hover,
.light-mode .erp-data-grid .mud-table-body tr:hover,
.light-mode .mud-table-body tr:hover,
.light-mode .task-row:hover {
    background: #EFF6FF !important;
}

.light-mode .mud-input-root,
.light-mode .mud-input,
.light-mode .mud-select,
.light-mode .mud-input-control,
.light-mode input,
.light-mode textarea,
.light-mode select,
.light-mode .search-box,
.light-mode .menu-search-field {
    color: #0F172A !important;
}

.light-mode input,
.light-mode textarea,
.light-mode select,
.light-mode .mud-input-slot,
.light-mode .mud-input-root-outlined,
.light-mode .mud-select-input {
    background: #FFFFFF !important;
}

.light-mode input::placeholder,
.light-mode textarea::placeholder,
.light-mode .mud-input > input::placeholder {
    color: #94A3B8 !important;
    opacity: 1 !important;
}

.light-mode .mud-input-label,
.light-mode .mud-input-adornment,
.light-mode .mud-icon-root,
.light-mode .mud-select-icon {
    color: #64748B !important;
}

.light-mode .mud-input-outlined-border,
.light-mode .mud-input-root-outlined .mud-input-outlined-border {
    border-color: #CBD5E1 !important;
}

.light-mode .mud-input-root:hover .mud-input-outlined-border,
.light-mode .mud-input-root.mud-focused .mud-input-outlined-border {
    border-color: #3B82F6 !important;
}

.light-mode .mud-popover,
.light-mode .mud-list,
.light-mode .mud-menu,
.light-mode .mud-menu-list,
.light-mode .mud-dialog,
.light-mode .mud-dialog-content,
.light-mode .mud-paper {
    background: #FFFFFF !important;
    color: #0F172A !important;
    border-color: #E2E8F0 !important;
}

.light-mode .mud-list-item,
.light-mode .mud-list-item-text,
.light-mode .mud-select-item,
.light-mode .mud-menu-item {
    color: #0F172A !important;
}

.light-mode .mud-list-item:hover,
.light-mode .mud-select-item:hover,
.light-mode .mud-menu-item:hover {
    background: #EFF6FF !important;
}

.light-mode .mud-overlay,
.light-mode .modal-backdrop,
.light-mode .details-backdrop {
    background: rgba(15, 23, 42, .32) !important;
}

.light-mode .task-details-dialog,
.light-mode .task-details-shell,
.light-mode .task-edit-drawer,
.light-mode .side-drawer,
.light-mode .drawer-panel,
.light-mode .meeting-note-drawer {
    background: #FFFFFF !important;
    color: #0F172A !important;
    border-color: #E2E8F0 !important;
}

.light-mode .filter-chip,
.light-mode .smart-tag,
.light-mode .tag-pill,
.light-mode .task-tag,
.light-mode .quick-filter-chip,
.light-mode .active-filter-pill,
.light-mode .status-pill,
.light-mode .priority-pill {
    background: #F1F5F9 !important;
    color: #334155 !important;
    border-color: #CBD5E1 !important;
}

.light-mode .filter-chip.active,
.light-mode .quick-filter-chip.active,
.light-mode .active-filter-pill,
.light-mode .smart-tag.active,
.light-mode .tag-pill.active {
    background: #DBEAFE !important;
    color: #1D4ED8 !important;
    border-color: #93C5FD !important;
}

.light-mode .sidebar-link,
.light-mode .sidebar-group-toggle {
    color: #475569 !important;
}

.light-mode .sidebar-link:hover,
.light-mode .sidebar-link.active,
.light-mode .sidebar-link.active .sidebar-link-text,
.light-mode .sidebar-link:hover .sidebar-link-text {
    background: #EFF6FF !important;
    color: #2563EB !important;
}

.light-mode .sidebar-icon-dot {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .10) !important;
}

.light-mode .btn-secondary,
.light-mode .btn-ghost,
.light-mode .btn-action,
.light-mode .pager button,
.light-mode .mud-button-root.mud-button-outlined {
    background: #FFFFFF !important;
    color: #334155 !important;
    border-color: #CBD5E1 !important;
}

.light-mode .btn-secondary:hover,
.light-mode .btn-ghost:hover,
.light-mode .btn-action:hover,
.light-mode .pager button:hover,
.light-mode .mud-button-root.mud-button-outlined:hover {
    background: #EFF6FF !important;
    color: #1D4ED8 !important;
    border-color: #93C5FD !important;
}

.light-mode .mud-snackbar,
.light-mode .mud-alert {
    color: #0F172A !important;
}

.light-mode .chart-placeholder,
.light-mode .chart-bar,
.light-mode .workload-bar-track,
.light-mode .progress-track {
    background: #E2E8F0 !important;
}

.light-mode .meeting-note-hint-card p {
    color: #64748B !important;
}

/* Keep dark mode stable for newer controls. */
.dark-mode .advanced-filters-panel,
.dark-mode .advanced-filters-content,
.dark-mode .filter-group,
.dark-mode .task-details-dialog,
.dark-mode .task-edit-drawer,
.dark-mode .side-drawer,
.dark-mode .drawer-panel,
.dark-mode .meeting-note-drawer {
    background: #111827 !important;
    color: #F9FAFB !important;
    border-color: rgba(148, 163, 184, .18) !important;
}

.dark-mode .mud-popover,
.dark-mode .mud-list,
.dark-mode .mud-menu-list,
.dark-mode .mud-paper {
    background: #111827 !important;
    color: #F9FAFB !important;
}


/* ==========================================================================
   Task Grid / XLS — reference-matched page
   Keep scoped to .task-grid-reference-page.
   ========================================================================== */
.task-grid-reference-page {
    --tg-page-bg: #f7f9fc;
    --tg-surface: #ffffff;
    --tg-surface-soft: #f8fafc;
    --tg-surface-hover: #fafcff;
    --tg-text: #0f172a;
    --tg-heading: #111827;
    --tg-muted: #64748b;
    --tg-muted-2: #94a3b8;
    --tg-border: #e2e8f0;
    --tg-border-soft: #edf2f7;
    --tg-control-border: #dbe3ef;
    --tg-control-text: #111827;
    --tg-accent: #2563eb;
    --tg-accent-soft: #eff6ff;
    --tg-accent-border: #93c5fd;
    --tg-success: #16a34a;
    --tg-success-text: #1f8b4d;
    --tg-warning: #f59e0b;
    --tg-warning-text: #92400e;
    --tg-danger: #ef4444;
    --tg-danger-text: #dc2626;
    --tg-dirty-bg: #fff9e8;
    --tg-dirty-hover: #fff5d7;
    --tg-error-bg: #fff1f2;
    --tg-overlay-bg: rgba(255, 255, 255, .62);
    --tg-dialog-backdrop: rgba(15, 23, 42, .38);
    --tg-shadow: rgba(15, 23, 42, .18);
    --tg-shadow-soft: rgba(15, 23, 42, .08);

    min-height: calc(100vh - 120px);
    margin: -16px;
    padding: 26px 26px 18px;
    background: var(--tg-page-bg);
    color: var(--tg-text);
}

.dark-mode .task-grid-reference-page {
    --tg-page-bg: #0b1220;
    --tg-surface: #111827;
    --tg-surface-soft: #172033;
    --tg-surface-hover: #182235;
    --tg-text: #e5e7eb;
    --tg-heading: #f8fafc;
    --tg-muted: #94a3b8;
    --tg-muted-2: #718096;
    --tg-border: #2a374a;
    --tg-border-soft: #223047;
    --tg-control-border: #334155;
    --tg-control-text: #e5e7eb;
    --tg-accent: #3b82f6;
    --tg-accent-soft: #172554;
    --tg-accent-border: #3b82f6;
    --tg-success: #22c55e;
    --tg-success-text: #86efac;
    --tg-warning: #f59e0b;
    --tg-warning-text: #fbbf24;
    --tg-danger: #ef4444;
    --tg-danger-text: #f87171;
    --tg-dirty-bg: #2a2415;
    --tg-dirty-hover: #332a16;
    --tg-error-bg: #351a21;
    --tg-overlay-bg: rgba(11, 18, 32, .72);
    --tg-dialog-backdrop: rgba(0, 0, 0, .58);
    --tg-shadow: rgba(0, 0, 0, .42);
    --tg-shadow-soft: rgba(0, 0, 0, .24);
}

.task-grid-reference-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--tg-border);
}

.task-grid-reference-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.task-grid-reference-title-block h1 {
    margin: 0;
    font-size: 2.05rem;
    line-height: 1.1;
    font-weight: 800;
    color: var(--tg-heading);
}

.task-grid-reference-title-block p {
    margin: 10px 0 0;
    font-size: 1.05rem;
    color: var(--tg-muted);
}

.task-grid-reference-info {
    display: inline-flex;
    width: 22px;
    height: 22px;
    border: 1.5px solid #3b82f6;
    border-radius: 999px;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    font-size: 13px;
    font-weight: 700;
}

.task-grid-reference-header-tools {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tg-top-select,
.tg-top-search input,
.tg-field,
.tg-page-size {
    border: 1px solid var(--tg-control-border);
    border-radius: 10px;
    background: var(--tg-surface);
    color: var(--tg-heading);
    font-size: 14px;
    line-height: 1.2;
    box-sizing: border-box;
}

.tg-top-select {
    width: 220px;
    height: 40px;
    padding: 0 14px;
    font-weight: 500;
}

.tg-top-search {
    position: relative;
    width: 290px;
}

.tg-top-search input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 42px;
}

.tg-search-icon {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: var(--tg-muted-2);
    font-size: 18px;
}

.task-grid-reference-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px 0 18px;
}

.tg-btn {
    height: 48px;
    padding: 0 18px;
    border: 1px solid var(--tg-control-border);
    border-radius: 8px;
    background: var(--tg-surface);
    color: var(--tg-text);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
}

.tg-btn-primary {
    background: linear-gradient(180deg, #2f7cf7 0%, #2563eb 100%);
    border-color: var(--tg-accent);
    color: #fff;
}

.tg-btn-success {
    color: var(--tg-success-text);
}

.tg-btn-icon {
    font-size: 15px;
    line-height: 1;
}

.tg-caret {
    font-size: 12px;
    color: var(--tg-muted);
    margin-left: -4px;
}

.task-grid-reference-table-shell {
    border: 1px solid var(--tg-border);
    background: var(--tg-surface);
    border-radius: 0;
    overflow: hidden;
}

.task-grid-reference-table-scroll {
    overflow: auto;
}

.task-grid-reference-table {
    width: 100%;
    min-width: 1450px;
    border-collapse: collapse;
}

.task-grid-reference-table thead th {
    height: 54px;
    padding: 0 12px;
    border-right: 1px solid var(--tg-border-soft);
    border-bottom: 1px solid var(--tg-border);
    text-align: left;
    white-space: nowrap;
    background: var(--tg-surface);
    font-size: 14px;
    font-weight: 700;
    color: var(--tg-heading);
}

/* Only the required asterisk is red. The old broad `th span` rule also
   painted the new sortable header labels/arrows red. */
.task-grid-reference-table thead th .tg-required-mark {
    color: #ef4444;
}

.tg-filter-row th {
    height: 48px !important;
    padding: 6px 8px !important;
    background: var(--tg-surface-soft) !important;
    border-bottom: 1px solid var(--tg-border) !important;
    vertical-align: middle;
}

.tg-filter-input,
.tg-filter-select {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--tg-control-border);
    border-radius: 8px;
    background: var(--tg-surface);
    color: var(--tg-text);
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

.tg-filter-input::placeholder {
    color: var(--tg-muted-2);
}

.tg-filter-input:focus,
.tg-filter-select:focus {
    border-color: var(--tg-accent-border);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.tg-filter-progress {
    text-align: center;
}

.task-grid-reference-table td {
    height: 53px;
    padding: 7px 10px;
    border-right: 1px solid var(--tg-border-soft);
    border-bottom: 1px solid var(--tg-border-soft);
    background: var(--tg-surface);
    vertical-align: middle;
}

.task-grid-reference-table tr:hover td {
    background: var(--tg-surface-hover);
}

.task-grid-reference-table tr.is-saving td {
    opacity: .72;
}

.col-check, .cell-check {
    width: 42px;
    min-width: 42px;
    text-align: center;
}

.col-index, .cell-index {
    width: 44px;
    min-width: 44px;
    text-align: center;
    color: var(--tg-text);
    font-weight: 600;
}

.col-title { min-width: 260px; }
.col-project { min-width: 160px; }
.col-status { min-width: 140px; }
.col-priority { min-width: 130px; }
.col-assignee { min-width: 165px; }
.col-date { min-width: 125px; }
.col-progress { min-width: 120px; }
.col-department { min-width: 130px; }
.col-module { min-width: 135px; }
.col-created { min-width: 130px; }
.col-save, .cell-save { width: 88px; min-width: 88px; text-align: center; }

.tg-field {
    width: 100%;
    height: 35px;
    padding: 0 10px;
    outline: none;
    box-shadow: none;
}

.tg-input {
    padding: 0 10px;
}

.tg-input-title {
    font-weight: 500;
}

.tg-field:focus {
    border-color: #9ebcf8;
}

select.tg-field {
    appearance: auto;
}

.tg-date-input {
    padding-right: 8px;
}

.tg-progress-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tg-progress-number {
    width: 52px;
    min-width: 52px;
    text-align: center;
    padding: 0 6px;
}

.tg-progress-bar {
    flex: 1;
    height: 10px;
    border-radius: 999px;
    background: var(--tg-border-soft);
    overflow: hidden;
}

.tg-progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--tg-success);
}

.tg-status,
.tg-priority {
    font-weight: 700;
}

.tg-status {
    transition: none;
}

.tg-status.is-new {
    color: #166534;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.tg-status.is-progress {
    color: var(--tg-accent);
    background: var(--tg-accent-soft);
    border-color: #bfdbfe;
}

.tg-status.is-pending {
    color: #a16207;
    background: #fefce8;
    border-color: #fde68a;
}

.tg-status.is-review {
    color: #7e22ce;
    background: #faf5ff;
    border-color: #e9d5ff;
}

.tg-status.is-blocked {
    color: var(--tg-danger-text);
    background: var(--tg-error-bg);
    border-color: #fecaca;
}

.tg-status.is-done {
    color: #047857;
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.tg-status.is-neutral {
    color: #475569;
    background: var(--tg-surface-soft);
    border-color: #cbd5e1;
}

.tg-priority.is-critical { color: var(--tg-danger-text); }
.tg-priority.is-high { color: #ef4444; }
.tg-priority.is-medium { color: #f59e0b; }
.tg-priority.is-low { color: #2563eb; }

.tg-row-save {
    width: 50px;
    height: 34px;
    border: 0;
    border-radius: 6px;
    background: var(--tg-accent);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.tg-row-save:disabled {
    opacity: .55;
    cursor: default;
}

.task-grid-reference-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    color: var(--tg-muted);
    font-size: 14px;
    background: var(--tg-surface);
}

.tg-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tg-page-size {
    height: 34px;
    padding: 0 10px;
}

.tg-page-btn,
.tg-page-indicator {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}

.tg-page-btn {
    border: 1px solid var(--tg-control-border);
    background: var(--tg-surface);
    color: var(--tg-text);
    cursor: pointer;
}

.tg-page-btn:disabled {
    opacity: .45;
    cursor: default;
}

.tg-page-indicator {
    background: var(--tg-accent);
    color: #fff;
}

.task-grid-reference-loading {
    padding: 40px;
    font-size: 15px;
    color: var(--tg-muted);
}

@media (max-width: 1200px) {
    .task-grid-reference-header {
        flex-direction: column;
        align-items: stretch;
    }

    .task-grid-reference-header-tools {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

@media (max-width: 760px) {
    .task-grid-reference-page {
        margin: -8px;
        padding: 16px;
    }

    .task-grid-reference-title-block h1 {
        font-size: 1.65rem;
    }

    .tg-top-select,
    .tg-top-search {
        width: 100%;
    }

    .task-grid-reference-footer,
    .tg-footer-right {
        flex-wrap: wrap;
    }
}

/* Task Grid: non-destructive loading overlay so editing/saving never blanks the table. */
.task-grid-reference-page .task-grid-reference-table-shell {
    position: relative;
}

.task-grid-reference-page .tg-busy-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--tg-overlay-bg);
    backdrop-filter: blur(1px);
    color: var(--tg-text);
    font-size: 14px;
    font-weight: 600;
    pointer-events: all;
}

.task-grid-reference-page .tg-busy-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    border-top-color: #2563eb;
    animation: tg-spin .7s linear infinite;
}

@keyframes tg-spin {
    to { transform: rotate(360deg); }
}

/* Task Grid dirty-state saving */
.task-grid-reference-page .tg-btn:disabled {
    opacity: .46;
    cursor: default;
    box-shadow: none;
}

.task-grid-reference-page .tg-btn-success:not(:disabled) {
    background: var(--tg-success);
    border-color: var(--tg-success);
    color: #fff;
    box-shadow: 0 2px 8px rgba(22, 163, 74, .18);
}

.task-grid-reference-page .tg-unsaved-summary {
    height: 35px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--tg-warning-text);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.task-grid-reference-page .tg-unsaved-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--tg-warning);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .12);
}

.task-grid-reference-page .task-grid-reference-table tbody tr.is-dirty td {
    background: var(--tg-dirty-bg);
}

.task-grid-reference-page .task-grid-reference-table tbody tr.is-dirty:hover td {
    background: var(--tg-dirty-hover);
}

.task-grid-reference-page .task-grid-reference-table tbody tr.is-dirty td:first-child {
    box-shadow: inset 3px 0 0 #f59e0b;
}

.task-grid-reference-page .task-grid-reference-table tbody tr.is-error td {
    background: var(--tg-error-bg);
}

.task-grid-reference-page .task-grid-reference-table tbody tr.is-error td:first-child {
    box-shadow: inset 3px 0 0 #ef4444;
}

/* Task Grid: dirty UI. Do not use CSS paint/layout containment here.
   Native select popups plus containment can force an extra repaint on Windows browsers. */
.task-grid-reference-page .tg-unsaved-summary.is-hidden {
    display: none;
}


/* Task Grid: status color is assigned independently from the actual status value.
   The same value always gets the same color; different values are distributed across the palette. */
.task-grid-reference-page .tg-status {
    color: var(--tg-status-text, #475569) !important;
    background: var(--tg-status-bg, #f8fafc) !important;
    border-color: var(--tg-status-border, #cbd5e1) !important;
    font-weight: 700;
}


/* Task Grid fullscreen / navigation controls */
.task-grid-reference-toolbar .tg-toolbar-spacer {
    flex: 1 1 auto;
    min-width: 12px;
}

.task-grid-reference-toolbar .tg-btn-back,
.task-grid-reference-toolbar .tg-btn-fullscreen {
    flex: 0 0 auto;
}

.task-grid-reference-toolbar .tg-btn-fullscreen.is-active {
    border-color: var(--tg-accent-border);
    background: var(--tg-accent-soft);
    color: var(--tg-accent);
}

.task-grid-reference-page:fullscreen {
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    margin: 0;
    padding: 18px 20px;
    overflow: auto;
    background: var(--tg-page-bg);
}

.task-grid-reference-page:fullscreen .task-grid-reference-table-shell {
    min-height: calc(100vh - 190px);
}

.task-grid-reference-page:fullscreen .task-grid-reference-table-scroll {
    max-height: calc(100vh - 245px);
}

/* Task Grid / XLS row context menu */
.tg-context-menu {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 4100;
    width: 210px;
    padding: 7px;
    border: 1px solid var(--tg-border);
    border-radius: 10px;
    background: var(--tg-surface);
    box-shadow: 0 18px 45px var(--tg-shadow), 0 4px 12px var(--tg-shadow-soft);
    color: var(--tg-text);
    font-size: 14px;
}

.tg-context-menu.is-open {
    display: block;
}

.tg-context-item {
    width: 100%;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--tg-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.tg-context-item:hover:not(:disabled) {
    background: var(--tg-surface-soft);
}

.tg-context-item:disabled {
    color: var(--tg-muted-2);
    cursor: default;
}

.tg-context-item kbd {
    border: 0;
    background: transparent;
    color: var(--tg-muted-2);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
}


.tg-context-submenu {
    position: relative;
}

.tg-context-submenu-trigger {
    position: relative;
}

.tg-context-arrow {
    color: var(--tg-muted-2);
    font-size: 18px;
    line-height: 1;
}

.tg-context-submenu-panel {
    display: none;
    position: absolute;
    left: calc(100% - 2px);
    top: -7px;
    width: 190px;
    padding: 7px;
    border: 1px solid var(--tg-border);
    border-radius: 10px;
    background: var(--tg-surface);
    box-shadow: 0 18px 45px var(--tg-shadow), 0 4px 12px var(--tg-shadow-soft);
    z-index: 4110;
}

.tg-context-submenu:hover > .tg-context-submenu-panel,
.tg-context-submenu:focus-within > .tg-context-submenu-panel {
    display: block;
}

.tg-excel-paste-overlay {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(2, 6, 23, .62);
}

.tg-excel-paste-dialog {
    width: min(620px, 96vw);
    border: 1px solid var(--tg-border, #334155);
    border-radius: 14px;
    padding: 18px;
    background: var(--tg-surface, #111827);
    color: var(--tg-text, #f8fafc);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

.tg-excel-paste-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 5px;
}

.tg-excel-paste-help {
    color: var(--tg-muted, #94a3b8);
    margin-bottom: 12px;
}

.tg-excel-paste-box {
    display: block;
    width: 100%;
    min-height: 180px;
    resize: vertical;
    box-sizing: border-box;
    border: 1px solid var(--tg-border, #334155);
    border-radius: 9px;
    padding: 10px 12px;
    background: var(--tg-input-bg, #0f172a);
    color: var(--tg-text, #f8fafc);
    font: 13px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
    outline: none;
}

.tg-excel-paste-box:focus {
    border-color: var(--tg-primary, #3b82f6);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .18);
}

.tg-excel-paste-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 12px;
}

.tg-context-separator {
    height: 1px;
    margin: 6px 4px;
    background: var(--tg-border);
}

.tg-context-danger {
    color: var(--tg-danger-text);
}

.tg-context-danger:hover:not(:disabled) {
    background: var(--tg-error-bg);
    color: var(--tg-danger-text);
}

/* Task Grid — per-user column settings */
.task-grid-reference-page .tg-col-hidden {
    display: none !important;
}

.task-grid-reference-page .col-id { min-width: 78px; }
.task-grid-reference-page .col-flag { min-width: 84px; text-align: center; }
.task-grid-reference-page .col-user { min-width: 140px; }
.task-grid-reference-page .col-description { min-width: 260px; }
.task-grid-reference-page .col-source { min-width: 150px; }
.task-grid-reference-page .col-tags { min-width: 180px; }
.task-grid-reference-page .col-parent { min-width: 130px; }
.task-grid-reference-page .tg-readonly-value {
    display: block;
    min-height: 32px;
    padding: 7px 8px;
    border: 1px solid var(--tg-border);
    border-radius: 7px;
    background: var(--tg-surface-soft);
    color: var(--tg-muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-grid-reference-page .tg-column-settings-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--tg-dialog-backdrop);
}

.task-grid-reference-page .tg-column-settings-dialog {
    width: min(620px, calc(100vw - 40px));
    max-height: min(760px, calc(100vh - 48px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--tg-control-border);
    border-radius: 14px;
    background: var(--tg-surface);
    box-shadow: 0 24px 70px var(--tg-shadow);
}

.task-grid-reference-page .tg-column-settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--tg-border);
}

.task-grid-reference-page .tg-column-settings-header h3 {
    margin: 0;
    color: var(--tg-text);
    font-size: 20px;
    font-weight: 800;
}

.task-grid-reference-page .tg-column-settings-header p {
    margin: 5px 0 0;
    color: var(--tg-muted);
    font-size: 13px;
}

.task-grid-reference-page .tg-column-settings-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--tg-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.task-grid-reference-page .tg-column-settings-close:hover { background: var(--tg-surface-soft); }

.task-grid-reference-page .tg-column-settings-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 22px;
    border-bottom: 1px solid var(--tg-border-soft);
    background: var(--tg-surface-soft);
}

.task-grid-reference-page .tg-column-settings-actions > span {
    margin-left: auto;
    color: var(--tg-muted);
    font-size: 12px;
}

.task-grid-reference-page .tg-column-mini-btn {
    height: 32px;
    padding: 0 11px;
    border: 1px solid var(--tg-control-border);
    border-radius: 7px;
    background: var(--tg-surface);
    color: var(--tg-text);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.task-grid-reference-page .tg-column-settings-list {
    overflow: auto;
    padding: 8px 12px;
}

.task-grid-reference-page .tg-column-setting-row {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.task-grid-reference-page .tg-column-setting-row:hover { background: var(--tg-surface-soft); }
.task-grid-reference-page .tg-column-setting-row input { width: 16px; height: 16px; }
.task-grid-reference-page .tg-column-setting-name { flex: 1; color: var(--tg-text); font-size: 13px; font-weight: 650; }
.task-grid-reference-page .tg-column-setting-badge {
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--tg-accent-soft);
    color: #2563eb;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .03em;
}
.task-grid-reference-page .tg-column-setting-badge.is-ui { background: var(--tg-surface-soft); color: var(--tg-muted); }
.task-grid-reference-page .tg-column-setting-readonly { color: var(--tg-muted-2); font-size: 11px; }

.task-grid-reference-page .tg-column-settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px 18px;
    border-top: 1px solid var(--tg-border);
    background: var(--tg-surface);
}


/* Task Grid: filter toggle active state */
.task-grid-reference-toolbar .tg-btn.is-active {
    background: var(--tg-accent-soft);
    border-color: var(--tg-accent-border);
    color: var(--tg-accent);
}

/* Status values keep their individual colors, but their light palette is blended into the dark surface. */
.dark-mode .task-grid-reference-page .tg-status {
    background: color-mix(in srgb, var(--tg-status-bg, #334155) 22%, var(--tg-surface)) !important;
    border-color: color-mix(in srgb, var(--tg-status-border, #64748b) 58%, var(--tg-border)) !important;
}

/* Native form controls follow the active Task Grid theme without duplicating component CSS. */
.dark-mode .task-grid-reference-page input,
.dark-mode .task-grid-reference-page select {
    color-scheme: dark;
}


/* ==========================================================================\n   Task Grid — stronger semantic colors in LIGHT mode\n   Dark mode keeps its variable-based blending below.\n   ========================================================================== */
body:not(.dark-mode) .task-grid-reference-page .tg-status {
    color: var(--tg-status-text, #475569) !important;
    background: color-mix(in srgb, var(--tg-status-text, #475569) 9%, #ffffff) !important;
    border-color: color-mix(in srgb, var(--tg-status-text, #475569) 28%, #e2e8f0) !important;
}

.task-grid-reference-page .tg-priority {
    border-width: 1px;
    border-style: solid;
}

body:not(.dark-mode) .task-grid-reference-page .tg-priority.is-critical {
    color: #b91c1c !important;
    background: #fff1f2 !important;
    border-color: #fecdd3 !important;
}

body:not(.dark-mode) .task-grid-reference-page .tg-priority.is-high {
    color: #dc2626 !important;
    background: #fef2f2 !important;
    border-color: #fecaca !important;
}

body:not(.dark-mode) .task-grid-reference-page .tg-priority.is-medium {
    color: #d97706 !important;
    background: #fffbeb !important;
    border-color: #fde68a !important;
}

body:not(.dark-mode) .task-grid-reference-page .tg-priority.is-low {
    color: #2563eb !important;
    background: #eff6ff !important;
    border-color: #bfdbfe !important;
}

/* Native select keeps the semantic fill instead of browser-white appearance. */
body:not(.dark-mode) .task-grid-reference-page select.tg-status,
body:not(.dark-mode) .task-grid-reference-page select.tg-priority {
    background-clip: padding-box;
}

/* ========================================================================== 
   Spaces — project-only catalog / workspace
   ========================================================================== */
.spaces-catalog-page {
    --sp-bg: #f5f7fb;
    --sp-sidebar: #f8fafc;
    --sp-surface: #ffffff;
    --sp-surface-2: #f8fafc;
    --sp-border: #e2e8f0;
    --sp-border-soft: #edf2f7;
    --sp-text: #0f172a;
    --sp-muted: #64748b;
    --sp-subtle: #94a3b8;
    --sp-primary: #6d4aff;
    --sp-primary-soft: #f0edff;
    --sp-hover: #f1f5f9;
    --sp-input: #ffffff;
    --sp-shadow: 0 8px 24px rgba(15, 23, 42, .06);
    /* Compatibility aliases used by the project picker / create-space panels. */
    --spaces-page: var(--sp-bg);
    --spaces-surface: var(--sp-surface);
    --spaces-input-bg: var(--sp-input);
    --spaces-border: var(--sp-border);
    --spaces-text: var(--sp-text);
    --spaces-muted: var(--sp-muted);
    --spaces-accent: var(--sp-primary);
    min-height: calc(100vh - 120px);
    margin: -16px;
    background: var(--sp-bg);
    color: var(--sp-text);
}

.dark-mode .spaces-catalog-page {
    /* Match the application's MudTheme PaletteDark from MainLayout. */
    --sp-bg: var(--mud-palette-background, #0B1220);
    --sp-sidebar: var(--mud-palette-drawer-background, #0B1220);
    --sp-surface: var(--mud-palette-surface, #111827);
    --sp-surface-2: #172033;
    --sp-border: #2A374A;
    --sp-border-soft: #223047;
    --sp-text: var(--mud-palette-text-primary, #F9FAFB);
    --sp-muted: var(--mud-palette-text-secondary, #9CA3AF);
    --sp-subtle: #64748B;
    --sp-primary: var(--mud-palette-primary, #3B82F6);
    --sp-primary-soft: #172554;
    --sp-hover: #182235;
    --sp-input: #0F172A;
    --sp-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

.spaces-catalog-shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: calc(100vh - 120px);
}

.spaces-catalog-sidebar {
    min-width: 0;
    padding: 18px 12px;
    background: var(--sp-sidebar);
    border-right: 1px solid var(--sp-border);
}

.spaces-catalog-sidebar-head,
.spaces-catalog-topbar,
.spaces-title-row,
.spaces-status-group-head,
.spaces-add-actions {
    display: flex;
    align-items: center;
}

.spaces-catalog-sidebar-head {
    justify-content: space-between;
    gap: 12px;
    padding: 0 6px 14px;
}

.spaces-catalog-sidebar-head h2 {
    margin: 0;
    color: var(--sp-text) !important;
    font-size: 18px;
    font-weight: 800;
}

.spaces-catalog-sidebar-head span {
    display: block;
    margin-top: 2px;
    color: var(--sp-muted);
    font-size: 11px;
}

.spaces-icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--sp-border);
    border-radius: 9px;
    background: var(--sp-surface);
    color: var(--sp-text);
    font-size: 20px;
    cursor: pointer;
}

.spaces-tree-root,
.spaces-tree-space-row,
.spaces-new-space {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--sp-muted);
    cursor: pointer;
}

.spaces-tree-root,
.spaces-tree-space-row {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 7px 9px;
    border-radius: 8px;
    text-align: left;
    font-size: 13px;
}

.spaces-tree-root {
    grid-template-columns: auto minmax(0, 1fr) auto;
    margin-bottom: 5px;
}

.spaces-tree-root:hover,
.spaces-tree-space-row:hover,
.spaces-tree-root.is-active,
.spaces-tree-space-row.is-active {
    background: var(--sp-hover);
    color: var(--sp-text);
}

.spaces-tree-root.is-active,
.spaces-tree-space-row.is-active {
    font-weight: 700;
}

.spaces-tree-icon { color: var(--sp-primary); font-size: 11px; }
.spaces-tree-chevron { color: var(--sp-subtle); font-size: 12px; }
.spaces-tree-space-dot {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    background: var(--sp-primary);
    box-shadow: inset 0 0 0 4px color-mix(in srgb, white 75%, transparent);
}
.spaces-tree-space-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spaces-tree-count {
    min-width: 22px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--sp-surface-2);
    color: var(--sp-muted);
    text-align: center;
    font-size: 10px;
}

.spaces-tree-projects { padding: 2px 0 6px 34px; }
.spaces-tree-project-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 29px;
    color: var(--sp-muted);
    font-size: 12px;
}
.spaces-project-folder { color: var(--sp-subtle); }
.spaces-tree-empty { padding: 5px 0; color: var(--sp-subtle); font-size: 11px; }

.spaces-new-space {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 9px;
    color: var(--sp-muted);
    text-align: left;
    font-size: 12px;
}
.spaces-new-space:hover { color: var(--sp-text); }

.spaces-add-box {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--sp-border);
    border-radius: 10px;
    background: var(--sp-surface);
}
.spaces-add-box input,
.spaces-inline-create input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--sp-border);
    border-radius: 8px;
    outline: none;
    background: var(--sp-input);
    color: var(--sp-text);
}
.spaces-add-box input:focus,
.spaces-inline-create input:focus { border-color: var(--sp-primary); }
.spaces-add-actions { gap: 7px; margin-top: 8px; }

.spaces-catalog-main {
    min-width: 0;
    padding: 18px 22px 28px;
    background: var(--sp-bg);
}

.spaces-catalog-topbar {
    justify-content: space-between;
    gap: 16px;
    min-height: 58px;
}
.spaces-kicker {
    color: var(--sp-muted);
    font-size: 11px;
    font-weight: 700;
}
.spaces-title-row { gap: 9px; }
.spaces-title-row h1 {
    margin: 2px 0 0;
    color: var(--sp-text) !important;
    font-size: 20px;
    font-weight: 800;
}
.spaces-star { color: var(--sp-muted); font-size: 18px; }

.spaces-btn {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--sp-border);
    border-radius: 8px;
    background: var(--sp-surface);
    color: var(--sp-text);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.spaces-btn.primary {
    border-color: var(--sp-primary);
    background: var(--sp-primary);
    color: #fff;
}

.spaces-view-tabs {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 42px;
    border-bottom: 1px solid var(--sp-border);
}
.spaces-view-tabs button,
.spaces-view-tabs .spaces-view-tab-link {
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--sp-muted);
    font-size: 12px;
    text-decoration: none;
}
.spaces-view-tabs .spaces-view-tab-link { cursor: pointer; }
.spaces-view-tabs .spaces-view-tab-link:hover {
    color: var(--sp-text);
    border-bottom-color: color-mix(in srgb, var(--sp-primary) 55%, transparent);
}
.spaces-view-tabs button { cursor: default; }
.spaces-view-tabs button.is-active {
    border-bottom-color: var(--sp-text);
    color: var(--sp-text);
    font-weight: 700;
}

.spaces-list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 46px;
}
.spaces-status-pill {
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--sp-primary-soft);
    color: var(--sp-primary);
    font-size: 11px;
    font-weight: 800;
}
.spaces-list-summary { color: var(--sp-muted); font-size: 11px; }
.spaces-list-summary strong { color: var(--sp-text); }

.spaces-inline-create {
    display: grid;
    grid-template-columns: minmax(220px, 420px) auto auto;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid var(--sp-border);
    border-radius: 10px;
    background: var(--sp-surface);
}

.spaces-project-stack { display: grid; gap: 14px; }
.spaces-project-card {
    padding: 16px 18px 18px;
    border: 1px solid var(--sp-border);
    border-radius: 10px;
    background: var(--sp-surface);
    box-shadow: var(--sp-shadow);
}
.spaces-project-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.spaces-project-breadcrumb { color: var(--sp-muted); font-size: 10px; }
.spaces-project-card-head h2 {
    margin: 3px 0 0;
    color: var(--sp-text) !important;
    font-size: 15px;
    font-weight: 800;
}
.spaces-project-card-head h2 span { color: var(--sp-subtle); font-weight: 600; }
.spaces-project-task-count { color: var(--sp-muted); font-size: 10px; }

.spaces-status-group + .spaces-status-group { margin-top: 20px; }
.spaces-status-group-head { gap: 8px; margin-bottom: 4px; }
.spaces-status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 8px;
    border: 1px solid currentColor;
    border-radius: 6px;
    background: color-mix(in srgb, currentColor 8%, var(--sp-surface));
    font-size: 10px;
    font-weight: 800;
}
.spaces-status-count { color: var(--sp-muted); font-size: 10px; }
.spaces-status-badge.is-progress, .spaces-task-dot.is-progress { color: #3b82f6; }
.spaces-status-badge.is-new, .spaces-task-dot.is-new { color: #64748b; }
.spaces-status-badge.is-pending, .spaces-task-dot.is-pending { color: #d97706; }
.spaces-status-badge.is-review, .spaces-task-dot.is-review { color: #7c3aed; }
.spaces-status-badge.is-blocked, .spaces-task-dot.is-blocked { color: #dc2626; }
.spaces-status-badge.is-done, .spaces-task-dot.is-done { color: #16a34a; }
.spaces-status-badge.is-neutral, .spaces-task-dot.is-neutral { color: #64748b; }

.spaces-task-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.5fr) minmax(130px, .5fr) 120px 130px;
    align-items: center;
    min-height: 32px;
    gap: 12px;
    border-bottom: 1px solid var(--sp-border-soft);
}
.spaces-task-grid-head {
    min-height: 28px;
    color: var(--sp-muted);
    font-size: 10px;
}
.spaces-task-row { color: var(--sp-muted); font-size: 11px; }
.spaces-task-row:hover { background: var(--sp-hover); }
.spaces-task-name {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    color: var(--sp-text);
    font-weight: 700;
}
.spaces-task-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border: 2px solid currentColor;
    border-radius: 50%;
    background: transparent;
}
.spaces-task-row .is-overdue { color: #ef4444; font-weight: 700; }
.spaces-priority { font-weight: 700; }
.spaces-priority.is-critical, .spaces-priority.is-high { color: #ef4444; }
.spaces-priority.is-medium { color: #f59e0b; }
.spaces-priority.is-low { color: #3b82f6; }

.spaces-project-empty,
.spaces-main-empty {
    color: var(--sp-muted);
    font-size: 12px;
}
.spaces-project-empty { padding: 14px 0 4px; }
.spaces-main-empty {
    padding: 50px 24px;
    border: 1px dashed var(--sp-border);
    border-radius: 12px;
    background: var(--sp-surface);
    text-align: center;
}
.spaces-main-empty-icon { color: var(--sp-primary); font-size: 28px; }
.spaces-main-empty h3 { margin: 8px 0 3px; color: var(--sp-text) !important; }
.spaces-main-empty p { margin: 0 0 14px; }

@media (max-width: 1000px) {
    .spaces-catalog-shell { grid-template-columns: 210px minmax(0, 1fr); }
    .spaces-task-grid { grid-template-columns: minmax(220px, 1fr) 110px 100px 100px; }
}

@media (max-width: 760px) {
    .spaces-catalog-page { margin: -12px; }
    .spaces-catalog-shell { display: block; }
    .spaces-catalog-sidebar { border-right: 0; border-bottom: 1px solid var(--sp-border); }
    .spaces-catalog-main { padding: 14px 12px 24px; }
    .spaces-inline-create { grid-template-columns: 1fr; }
    .spaces-task-grid { grid-template-columns: minmax(180px, 1fr) 100px; }
    .spaces-task-grid > :nth-child(3), .spaces-task-grid > :nth-child(4) { display: none; }
}


/* ==========================================================================\n   Spaces catalog — hierarchy/compactness refinement\n   ========================================================================== */
.spaces-tree-space {
    margin: 4px 0 8px;
}

.spaces-tree-space-row {
    min-height: 38px;
    border: 1px solid transparent;
    font-weight: 750;
}

.spaces-tree-space-row.is-active {
    border-color: color-mix(in srgb, var(--sp-primary) 28%, var(--sp-border));
    box-shadow: inset 3px 0 0 var(--sp-primary);
}

.spaces-tree-space-dot {
    width: 17px;
    height: 17px;
    border-radius: 5px;
    background: color-mix(in srgb, var(--sp-primary) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--sp-primary) 46%, transparent);
    position: relative;
}

.spaces-tree-space-dot::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 2px;
    background: var(--sp-primary);
}

.spaces-tree-projects {
    margin: 2px 6px 0 23px;
    padding: 4px 0 4px 12px;
    border-left: 1px solid var(--sp-border);
}

.spaces-tree-project-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 27px;
    padding: 3px 7px;
    border-radius: 6px;
    color: var(--sp-muted);
    font-size: 11px;
    text-decoration: none;
}

.spaces-tree-project-row:hover {
    background: var(--sp-hover);
    color: var(--sp-text);
}

.spaces-tree-project-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.spaces-project-folder {
    flex: 0 0 auto;
    color: color-mix(in srgb, var(--sp-primary) 60%, var(--sp-muted));
    font-size: 12px;
}

.spaces-view-tabs button:disabled {
    cursor: default;
    opacity: .48;
}

.spaces-view-tabs button:disabled:hover {
    color: var(--sp-muted);
    border-bottom-color: transparent;
}

.spaces-inline-create {
    margin-bottom: 12px;
    padding: 10px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--sp-primary) 5%, var(--sp-surface));
    border-color: color-mix(in srgb, var(--sp-primary) 26%, var(--sp-border));
}

.spaces-project-card {
    scroll-margin-top: 16px;
}

.spaces-project-card.is-empty {
    padding-top: 12px;
    padding-bottom: 12px;
}

.spaces-project-card.is-empty .spaces-project-card-head {
    margin-bottom: 2px;
}

.spaces-project-breadcrumb {
    display: flex;
    align-items: center;
    gap: 5px;
}

.spaces-project-breadcrumb span {
    display: inline-flex;
    padding: 2px 5px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--sp-primary) 11%, transparent);
    color: color-mix(in srgb, var(--sp-primary) 78%, var(--sp-text));
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .05em;
}

.spaces-project-breadcrumb b {
    color: var(--sp-subtle);
    font-weight: 500;
}

.spaces-project-card-head h2 {
    display: flex;
    align-items: center;
    gap: 7px;
}

.spaces-project-title-icon {
    color: var(--sp-primary) !important;
    font-size: 13px;
    font-weight: 500 !important;
}

.spaces-project-more {
    color: var(--sp-subtle) !important;
    font-weight: 600 !important;
    margin-left: 1px;
}

.spaces-project-empty {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 0 0 !important;
    min-height: 0;
}

.spaces-project-empty span {
    display: inline-flex;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--sp-hover);
    border: 1px solid var(--sp-border);
    color: var(--sp-muted);
    font-size: 9px;
    font-weight: 700;
}

/* Spaces — existing project picker */
.spaces-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.spaces-select-projects-btn {
    border-color: var(--spaces-border, #334155) !important;
    background: var(--spaces-surface, #111827) !important;
    color: var(--spaces-text, #e5e7eb) !important;
}

.spaces-project-picker {
    margin: 0 0 14px;
    border: 1px solid var(--spaces-border, #334155);
    border-radius: 12px;
    background: var(--spaces-surface, #111827);
    overflow: hidden;
}

.spaces-project-picker-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--spaces-border, #334155);
}

.spaces-project-picker-head h3 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
    color: var(--spaces-text, #e5e7eb);
}

.spaces-project-picker-head p {
    margin: 0;
    font-size: 12px;
    color: var(--spaces-muted, #94a3b8);
}

.spaces-picker-close {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--spaces-muted, #94a3b8);
    font-size: 20px;
    cursor: pointer;
}

.spaces-picker-close:hover {
    background: color-mix(in srgb, var(--spaces-accent, #7c3aed) 12%, transparent);
    color: var(--spaces-text, #e5e7eb);
}

.spaces-project-picker-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--spaces-border, #334155);
    background: color-mix(in srgb, var(--spaces-surface, #111827) 94%, var(--spaces-page, #0b0f14));
}

.spaces-project-picker-search {
    min-width: 240px;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--spaces-border, #334155);
    border-radius: 8px;
    background: var(--spaces-input-bg, #0f172a);
    color: var(--spaces-muted, #94a3b8);
}

.spaces-project-picker-search input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--spaces-text, #e5e7eb);
    font-size: 13px;
}

.spaces-project-picker-list {
    max-height: 390px;
    overflow: auto;
    padding: 8px;
}

.spaces-project-picker-row {
    display: grid;
    grid-template-columns: 20px 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.spaces-project-picker-row:hover {
    background: color-mix(in srgb, var(--spaces-accent, #7c3aed) 7%, transparent);
}

.spaces-project-picker-row.is-selected {
    border-color: color-mix(in srgb, var(--spaces-accent, #7c3aed) 58%, var(--spaces-border, #334155));
    background: color-mix(in srgb, var(--spaces-accent, #7c3aed) 12%, transparent);
}

.spaces-picker-project-icon {
    color: var(--spaces-accent, #7c3aed);
    font-size: 16px;
}

.spaces-picker-project-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.spaces-picker-project-info strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--spaces-text, #e5e7eb);
    font-size: 13px;
}

.spaces-picker-project-info small,
.spaces-picker-move {
    color: var(--spaces-muted, #94a3b8);
    font-size: 11px;
}

.spaces-picker-move {
    white-space: nowrap;
}

.spaces-project-picker-empty {
    padding: 26px 14px;
    text-align: center;
    color: var(--spaces-muted, #94a3b8);
    font-size: 13px;
}

.spaces-empty-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .spaces-project-picker-toolbar {
        align-items: stretch;
        flex-wrap: wrap;
    }
    .spaces-project-picker-search {
        min-width: 100%;
    }
    .spaces-picker-move {
        display: none;
    }
    .spaces-project-picker-row {
        grid-template-columns: 20px 22px minmax(0, 1fr);
    }
}

/* Spaces tree — independent expand/collapse */
.spaces-tree-space-row {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.spaces-tree-chevron-btn,
.spaces-tree-space-select {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
}

.spaces-tree-chevron-btn {
    flex: 0 0 28px;
    width: 28px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: var(--sp-subtle);
}

.spaces-tree-chevron-btn:hover {
    color: var(--sp-text);
}

.spaces-tree-chevron {
    display: inline-block;
    font-size: 15px;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform 120ms ease;
}

.spaces-tree-space.is-expanded .spaces-tree-chevron {
    transform: rotate(90deg);
}

.spaces-tree-space-select {
    min-width: 0;
    flex: 1 1 auto;
    height: 36px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 0 0;
    text-align: left;
    cursor: pointer;
}

.spaces-tree-space-select .spaces-tree-space-name {
    min-width: 0;
    flex: 1 1 auto;
}

.spaces-tree-space-row.is-active .spaces-tree-space-select {
    color: var(--sp-text);
    font-weight: 700;
}

.spaces-tree-space-row.is-active .spaces-tree-count {
    color: var(--sp-text);
}

/* Spaces — create Space on main canvas */
.spaces-new-space.is-active {
    color: var(--sp-text);
    background: var(--sp-hover);
    border-radius: 8px;
}

.spaces-create-space-panel {
    margin-top: 14px;
    border: 1px solid var(--sp-border);
    border-radius: 14px;
    background: var(--sp-surface);
    overflow: hidden;
}

.spaces-create-space-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--sp-border);
}

.spaces-create-space-head h2 {
    margin: 4px 0 4px;
    color: var(--sp-text) !important;
    font-size: 20px;
    font-weight: 800;
}

.spaces-create-space-head p {
    margin: 0;
    color: var(--sp-muted);
    font-size: 12px;
}

.spaces-create-space-body {
    padding: 20px 22px;
}

.spaces-create-field {
    display: block;
    max-width: 620px;
}

.spaces-create-field > span {
    display: block;
    margin-bottom: 7px;
    color: var(--sp-text);
    font-size: 12px;
    font-weight: 700;
}

.spaces-create-field input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--sp-border);
    border-radius: 9px;
    outline: none;
    background: var(--sp-input);
    color: var(--sp-text);
    font-size: 13px;
}

.spaces-create-field input:focus {
    border-color: var(--sp-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sp-primary) 14%, transparent);
}

.spaces-create-project-section {
    margin-top: 20px;
    border: 1px solid var(--sp-border);
    border-radius: 12px;
    overflow: hidden;
}

.spaces-create-project-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--sp-border);
    background: var(--sp-surface-2);
}

.spaces-create-project-title strong,
.spaces-create-project-title span {
    display: block;
}

.spaces-create-project-title strong {
    color: var(--sp-text);
    font-size: 13px;
}

.spaces-create-project-title div > span {
    margin-top: 2px;
    color: var(--sp-muted);
    font-size: 11px;
}

.spaces-create-selected-count {
    padding: 4px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--sp-primary) 14%, transparent);
    color: var(--sp-primary) !important;
    font-size: 11px !important;
    font-weight: 800;
    white-space: nowrap;
}

.spaces-create-picker-toolbar {
    border-bottom: 1px solid var(--sp-border);
}

.spaces-create-project-list {
    max-height: 360px;
}

.spaces-create-space-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--sp-border);
    background: var(--sp-surface-2);
}

.spaces-create-space-footer .spaces-btn.primary {
    min-width: 140px;
}

@media (max-width: 760px) {
    .spaces-create-space-head,
    .spaces-create-space-body,
    .spaces-create-space-footer {
        padding-left: 14px;
        padding-right: 14px;
    }

    .spaces-create-project-title {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Spaces tree — project rows are real selectable tree items. */
.spaces-tree-project-row {
    width: 100%;
    border: 0;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.spaces-tree-project-row.is-active {
    background: color-mix(in srgb, var(--sp-primary) 14%, var(--sp-surface));
    color: var(--sp-text);
    box-shadow: inset 2px 0 0 var(--sp-primary);
}

.spaces-tree-project-row.is-active .spaces-project-folder {
    color: var(--sp-primary);
}

/* ==========================================================================\n   Spaces main list — Project > Status > Task tree\n   ========================================================================== */
.spaces-main-tree-project { padding: 0; overflow: hidden; }
.spaces-main-tree-project-head { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 58px; margin: 0; padding: 10px 18px; }
.spaces-main-tree-project-head:hover { background: color-mix(in srgb, var(--sp-primary) 3%, var(--sp-surface)); }
.spaces-main-tree-toggle, .spaces-main-tree-status-head { appearance: none; border: 0; background: transparent; color: inherit; font: inherit; }
.spaces-main-tree-toggle { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border-radius: 5px; color: var(--sp-muted); cursor: pointer; }
.spaces-main-tree-toggle:hover { background: var(--sp-hover); color: var(--sp-text); }
.spaces-main-tree-chevron { display: inline-block; font-size: 17px; line-height: 1; transform: rotate(0deg); transition: transform .14s ease; }
.spaces-main-tree-project.is-expanded > .spaces-main-tree-project-head .spaces-main-tree-toggle .spaces-main-tree-chevron,
.spaces-main-tree-status.is-expanded > .spaces-main-tree-status-head .spaces-main-tree-chevron { transform: rotate(90deg); }
.spaces-main-tree-project-title { min-width: 0; }
.spaces-main-tree-project-body { position: relative; padding: 0 18px 14px 42px; }
.spaces-main-tree-project-body::before { content: ""; position: absolute; left: 29px; top: 0; bottom: 16px; width: 1px; background: var(--sp-border); }
.spaces-main-tree-status { position: relative; margin: 0; padding: 5px 0 3px 16px; }
.spaces-main-tree-status + .spaces-main-tree-status { margin-top: 5px; }
.spaces-main-tree-status::before { content: ""; position: absolute; left: -13px; top: 17px; width: 20px; height: 1px; background: var(--sp-border); }
.spaces-main-tree-status-head { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 2px 5px 2px 0; border-radius: 6px; cursor: pointer; text-align: left; }
.spaces-main-tree-status-head:hover { background: var(--sp-hover); }
.spaces-main-tree-status-head .spaces-main-tree-chevron { width: 14px; color: var(--sp-muted); font-size: 15px; }
.spaces-main-tree-status-body { margin-left: 21px; padding-left: 14px; border-left: 1px solid var(--sp-border-soft); }
.spaces-main-tree-task { position: relative; }
.spaces-main-tree-task::before { content: ""; position: absolute; left: -14px; top: 50%; width: 10px; height: 1px; background: var(--sp-border-soft); }
.spaces-main-tree-project.is-collapsed .spaces-project-task-count { color: var(--sp-subtle); }
@media (max-width: 760px) {
  .spaces-main-tree-project-head { grid-template-columns: 22px minmax(0, 1fr) auto; padding-inline: 10px; }
  .spaces-main-tree-project-body { padding-left: 30px; padding-right: 10px; }
  .spaces-main-tree-project-body::before { left: 18px; }
}

/* Spaces — clickable task titles */
.spaces-task-title-button {
    appearance: none;
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.spaces-task-title-button:hover {
    color: #60a5fa;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.spaces-task-title-button:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 3px;
    border-radius: 3px;
}


/* ==========================================================================
   Spaces Overview — real Space summary from Projects / Tasks
   ========================================================================== */
.spaces-overview { padding: 18px 22px 28px; }
.spaces-overview-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.spaces-overview-kpi { min-width: 0; padding: 15px 16px; border: 1px solid var(--sp-border); border-radius: 10px; background: var(--sp-surface); box-shadow: var(--sp-shadow); }
.spaces-overview-kpi span { display: block; color: var(--sp-muted); font-size: 12px; font-weight: 700; }
.spaces-overview-kpi strong { display: block; margin: 6px 0 1px; color: var(--sp-text); font-size: 25px; line-height: 1; }
.spaces-overview-kpi small { color: var(--sp-subtle); font-size: 11px; }
.spaces-overview-kpi.is-danger strong { color: #ef4444; }
.spaces-overview-kpi.is-success strong { color: #22c55e; }
.spaces-overview-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 16px; }
.spaces-overview-panel { min-width: 0; padding: 16px; border: 1px solid var(--sp-border); border-radius: 10px; background: var(--sp-surface); box-shadow: var(--sp-shadow); }
.spaces-overview-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.spaces-overview-panel-head h3 { margin: 2px 0 0; color: var(--sp-text); font-size: 16px; }
.spaces-overview-panel-head > span { color: var(--sp-muted); font-size: 12px; }
.spaces-overview-projects { grid-row: span 2; }
.spaces-overview-project-row { width: 100%; display: grid; grid-template-columns: minmax(140px, 1fr) minmax(120px, 1.4fr) 44px; align-items: center; gap: 12px; padding: 10px 4px; border: 0; border-top: 1px solid var(--sp-border-soft); background: transparent; color: var(--sp-text); text-align: left; cursor: pointer; }
.spaces-overview-project-row:first-of-type { border-top: 0; }
.spaces-overview-project-row:hover { background: var(--sp-hover); }
.spaces-overview-project-meta { min-width: 0; }
.spaces-overview-project-meta strong, .spaces-overview-project-meta span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spaces-overview-project-meta span { margin-top: 2px; color: var(--sp-muted); font-size: 11px; }
.spaces-overview-progress { height: 7px; overflow: hidden; border-radius: 999px; background: var(--sp-border-soft); }
.spaces-overview-progress span { display: block; height: 100%; border-radius: inherit; background: var(--sp-primary); }
.spaces-overview-project-row b { text-align: right; font-size: 12px; }
.spaces-overview-attention-list { display: grid; gap: 8px; }
.spaces-overview-attention-list > div { display: grid; grid-template-columns: 10px 34px 1fr; align-items: center; gap: 8px; min-height: 28px; color: var(--sp-muted); font-size: 12px; }
.spaces-overview-attention-list strong { color: var(--sp-text); font-size: 13px; }
.spaces-overview-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--sp-subtle); }
.spaces-overview-dot.critical, .spaces-overview-dot.overdue { background: #ef4444; }
.spaces-overview-dot.high { background: #f97316; }
.spaces-overview-dot.blocked { background: #a855f7; }
.spaces-overview-dot.due { background: #3b82f6; }
.spaces-overview-status-list { display: grid; gap: 7px; }
.spaces-overview-status-list > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; }
.spaces-overview-status-list strong { font-size: 13px; }
.spaces-overview-workload { display: grid; gap: 6px; }
.spaces-overview-workload > div { display: grid; grid-template-columns: 30px 1fr 28px; align-items: center; gap: 9px; padding: 6px 0; border-top: 1px solid var(--sp-border-soft); }
.spaces-overview-workload > div:first-child { border-top: 0; }
.spaces-overview-avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--sp-primary-soft); color: var(--sp-primary); font-size: 10px; font-weight: 800; }
.spaces-overview-workload span strong, .spaces-overview-workload span small { display: block; }
.spaces-overview-workload span small { margin-top: 1px; color: var(--sp-muted); font-size: 10px; }
.spaces-overview-workload > div > b { text-align: right; font-size: 12px; }
.spaces-overview-upcoming { margin-top: 16px; }
.spaces-overview-task-list { display: grid; }
.spaces-overview-task-list button { width: 100%; display: grid; grid-template-columns: minmax(0,1fr) 90px 90px; align-items: center; gap: 12px; min-height: 44px; padding: 6px 8px; border: 0; border-top: 1px solid var(--sp-border-soft); background: transparent; color: var(--sp-text); font: inherit; text-align: left; cursor: pointer; }
.spaces-overview-task-list button:first-child { border-top: 0; }
.spaces-overview-task-list button:hover { background: var(--sp-hover); }
.spaces-overview-task-list button > span:first-child strong, .spaces-overview-task-list button > span:first-child small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spaces-overview-task-list button > span:first-child small { margin-top: 2px; color: var(--sp-muted); font-size: 10px; }
.spaces-overview-task-list button > span:nth-child(2) { color: var(--sp-muted); font-size: 11px; }
.spaces-overview-empty { padding: 18px 4px; color: var(--sp-muted); font-size: 12px; }
.spaces-view-tabs button:not(:disabled) { cursor: pointer; }
@media (max-width: 1200px) {
  .spaces-overview-kpis { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .spaces-overview-grid { grid-template-columns: 1fr; }
  .spaces-overview-projects { grid-row: auto; }
}
@media (max-width: 680px) {
  .spaces-overview { padding: 12px; }
  .spaces-overview-kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .spaces-overview-project-row { grid-template-columns: minmax(0,1fr) 80px 36px; }
  .spaces-overview-task-list button { grid-template-columns: minmax(0,1fr) 72px; }
  .spaces-overview-task-list button .spaces-priority { display: none; }
}


/* Spaces: embedded existing views */
.spaces-embedded-view { min-width: 0; width: 100%; padding-top: 12px; }
.spaces-embedded-view .page-header { margin-top: 0; }
.spaces-embedded-board .kanban-scroll { margin-top: 0; }
.spaces-embedded-calendar .calendar-toolbar { margin-top: 0; }
.spaces-embedded-table .task-grid-reference-page { padding: 0; margin: 0; max-width: none; }
.spaces-embedded-table .task-grid-reference-header { margin-top: 0; }
.spaces-embedded-table .task-grid-reference-table-shell { min-height: 420px; }

/* Task Grid — safe Excel round-trip import */
.tg-import-excel-btn { position: relative; overflow: hidden; cursor: pointer; }
.tg-import-excel-btn.is-disabled { opacity: .55; pointer-events: none; }
.tg-import-excel-input { position: absolute !important; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.tg-excel-import-backdrop { position: fixed; inset: 0; z-index: 1400; display: grid; place-items: center; padding: 28px; background: rgba(2, 6, 23, .76); backdrop-filter: blur(4px); }
.tg-excel-import-dialog { width: min(1120px, calc(100vw - 42px)); max-height: calc(100vh - 54px); overflow: hidden; display: flex; flex-direction: column; border: 1px solid #334155; border-radius: 14px; background: #0f172a; color: #e5edf8; box-shadow: 0 24px 80px rgba(0,0,0,.48); }
.tg-excel-import-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 20px 22px 16px; border-bottom: 1px solid #253149; }
.tg-excel-import-header h3 { margin: 3px 0 2px; font-size: 22px; color: #f8fafc; }
.tg-excel-import-header p { margin: 0; color: #94a3b8; font-size: 12px; }
.tg-excel-import-eyebrow { color: #60a5fa; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.tg-excel-import-safety { margin: 16px 20px 0; padding: 12px 14px; border: 1px solid; border-radius: 10px; display: grid; gap: 3px; }
.tg-excel-import-safety strong { font-size: 13px; }
.tg-excel-import-safety span, .tg-excel-import-safety small { font-size: 11px; }
.tg-excel-import-safety.is-trusted { border-color: rgba(34,197,94,.45); background: rgba(22,163,74,.08); }
.tg-excel-import-safety.is-trusted strong { color: #86efac; }
.tg-excel-import-safety.is-warning { border-color: rgba(245,158,11,.5); background: rgba(180,83,9,.1); }
.tg-excel-import-safety.is-warning strong { color: #fbbf24; }
.tg-excel-import-kpis { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 9px; padding: 12px 20px 0; }
.tg-excel-import-kpis > div { padding: 10px 12px; border: 1px solid #26344d; border-radius: 9px; background: #111c31; }
.tg-excel-import-kpis strong, .tg-excel-import-kpis span { display: block; }
.tg-excel-import-kpis strong { font-size: 20px; line-height: 1; }
.tg-excel-import-kpis span { margin-top: 4px; color: #94a3b8; font-size: 10px; }
.tg-excel-import-kpis .is-conflict strong { color: #fbbf24; }
.tg-excel-import-kpis .is-error strong { color: #f87171; }
.tg-excel-import-db-note { margin: 10px 20px 0; padding: 9px 11px; border-radius: 8px; background: rgba(59,130,246,.09); color: #bfdbfe; font-size: 11px; }
.tg-excel-import-list { margin-top: 12px; padding: 0 20px 14px; overflow: auto; display: grid; gap: 8px; }
.tg-excel-import-empty { padding: 28px; border: 1px dashed #334155; border-radius: 10px; color: #94a3b8; text-align: center; }
.tg-excel-import-row { display: grid; grid-template-columns: minmax(0,1fr) 220px; gap: 14px; padding: 12px 13px; border: 1px solid #2a3852; border-radius: 10px; background: #111b2f; }
.tg-excel-import-row.kind-conflict { border-color: rgba(245,158,11,.5); }
.tg-excel-import-row.kind-error { border-color: rgba(248,113,113,.42); }
.tg-excel-import-row-main { display: grid; grid-template-columns: 78px minmax(170px,.7fr) minmax(260px,1.3fr); align-items: start; gap: 12px; }
.tg-excel-import-kind { display: inline-flex; justify-content: center; padding: 4px 7px; border-radius: 999px; background: #17233a; color: #bfdbfe; font-size: 10px; font-weight: 800; }
.kind-new .tg-excel-import-kind { background: rgba(34,197,94,.12); color: #86efac; }
.kind-conflict .tg-excel-import-kind { background: rgba(245,158,11,.12); color: #fbbf24; }
.kind-error .tg-excel-import-kind { background: rgba(239,68,68,.12); color: #fca5a5; }
.tg-excel-import-task strong, .tg-excel-import-task small { display: block; }
.tg-excel-import-task strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #f8fafc; }
.tg-excel-import-task small { margin-top: 4px; color: #7f8da6; font-size: 10px; }
.tg-excel-import-fields { display: grid; gap: 3px; color: #b8c5d9; font-size: 10px; line-height: 1.4; }
.tg-excel-import-fields .is-db { color: #93c5fd; }
.tg-excel-import-fields .is-conflict { color: #fbbf24; }
.tg-excel-import-fields .is-error { color: #fca5a5; }
.tg-excel-import-resolution { display: flex; align-items: center; justify-content: flex-end; }
.tg-excel-import-resolution select { width: 100%; min-height: 34px; border: 1px solid #334155; border-radius: 7px; padding: 0 28px 0 9px; background: #0b1324; color: #e5edf8; font-size: 11px; }
.tg-excel-import-skip { color: #fca5a5; font-size: 11px; font-weight: 700; }
.tg-excel-import-danger-confirm { margin: 0 20px 14px; padding: 12px 13px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid rgba(239,68,68,.55); border-radius: 9px; background: rgba(127,29,29,.18); cursor: pointer; }
.tg-excel-import-danger-confirm input { margin-top: 3px; }
.tg-excel-import-danger-confirm strong, .tg-excel-import-danger-confirm small { display: block; }
.tg-excel-import-danger-confirm strong { color: #fecaca; font-size: 11px; }
.tg-excel-import-danger-confirm small { margin-top: 3px; color: #fca5a5; font-size: 10px; }
.tg-excel-import-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 20px; border-top: 1px solid #253149; background: #0c1425; }
.tg-excel-import-footer > div:first-child { display: grid; gap: 3px; color: #94a3b8; font-size: 11px; }
.tg-excel-import-footer > div:last-child { display: flex; gap: 8px; }
.tg-excel-import-danger-text { color: #fca5a5; font-size: 10px; }
@media (max-width: 850px) {
  .tg-excel-import-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .tg-excel-import-row { grid-template-columns: 1fr; }
  .tg-excel-import-row-main { grid-template-columns: 70px 1fr; }
  .tg-excel-import-fields { grid-column: 1 / -1; }
  .tg-excel-import-footer { align-items: flex-start; flex-direction: column; }
}
.tg-excel-import-applied { color: #86efac; font-size: 11px; font-weight: 800; }
.tg-excel-import-fields .is-conflict-detail { margin-left: 8px; color: #fde68a; font-size: 10px; }


/* Tasks — non-blocking Send Follow-up side panel */
.task-followup-sidepanel {
  position: fixed;
  top: 76px;
  right: 18px;
  z-index: 1250;
  width: min(430px, calc(100vw - 32px));
  max-height: calc(100vh - 94px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #334155;
  border-radius: 14px;
  background: #0f172a;
  color: #e5edf8;
  box-shadow: 0 22px 64px rgba(0,0,0,.45);
}
.task-followup-sidepanel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 15px;
  border-bottom: 1px solid #26344d;
  background: #111b2f;
}
.task-followup-sidepanel-header h3 {
  margin: 2px 0 4px;
  font-size: 19px;
  color: #f8fafc;
}
.task-followup-sidepanel-header p {
  margin: 0;
  max-width: 330px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #94a3b8;
  font-size: 11px;
}
.task-followup-eyebrow {
  color: #60a5fa;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
}
.task-followup-close {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.task-followup-close:hover { background: #182235; color: #fff; }
.task-followup-sidepanel-body {
  padding: 16px 18px;
  overflow: auto;
  display: grid;
  gap: 12px;
}
.task-followup-field {
  display: grid;
  gap: 7px;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
}
.task-followup-field textarea {
  width: 100%;
  resize: vertical;
  min-height: 112px;
  padding: 11px 12px;
  border: 1px solid #3b82f6;
  border-radius: 9px;
  outline: none;
  background: #0b1324;
  color: #f8fafc;
  font: inherit;
  font-weight: 500;
  line-height: 1.45;
}
.task-followup-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid #2a3852;
  border-radius: 9px;
  background: #111b2f;
  cursor: pointer;
}
.task-followup-check input { margin-top: 3px; }
.task-followup-check strong,
.task-followup-check small { display: block; }
.task-followup-check strong { color: #e5edf8; font-size: 12px; }
.task-followup-check small { margin-top: 3px; color: #8796ad; font-size: 10px; line-height: 1.35; }
.task-followup-check.is-disabled { opacity: .55; cursor: default; }
.task-followup-sidepanel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 18px;
  border-top: 1px solid #26344d;
  background: #0c1425;
}
.task-followup-secondary,
.task-followup-primary {
  min-height: 38px;
  padding: 0 15px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 11px;
  cursor: pointer;
}
.task-followup-secondary {
  border: 1px solid #334155;
  background: transparent;
  color: #e2e8f0;
}
.task-followup-primary {
  border: 1px solid #3b82f6;
  background: #3b82f6;
  color: #fff;
}
.task-followup-secondary:disabled,
.task-followup-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}
@media (max-width: 700px) {
  .task-followup-sidepanel {
    top: 68px;
    right: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 76px);
  }
}

/* v52r: isolate task-grid repaints from page chrome. Search/filter data changes may
   repaint the table, but browser paint invalidation must not spill into the header
   and filter controls. */
.task-table-card {
    contain: paint;
}

/* v52s: global layout stability. Mud dialogs/popovers and task filtering must not
   change the viewport width when the browser scrollbar appears/disappears. */
html,
body {
    scrollbar-gutter: stable;
}

html {
    overflow-y: scroll;
}

/* The browser's scroll anchor must not move the filter/header area when the grid
   changes height after a search/filter or a context-menu action. */
.task-page-header,
.task-filter-panel,
.advanced-filters-panel,
.task-tabs,
.task-table-card {
    overflow-anchor: none;
}

/* Keep the result region geometrically stable when a filter returns only a few
   rows. The content can change; the page chrome above it does not collapse/jump. */
.task-table-card {
    min-height: min(620px, calc(100vh - 260px));
}

/* Avoid visual motion from generic Mud popover/menu transitions on Tasks. */
.task-data-grid .mud-menu,
.mud-popover-provider .mud-popover {
    transition: none !important;
}


/* Tasks — action loading is DOM/JS controlled so showing it never causes a Blazor render. */
.task-action-loading[hidden] { display: none !important; }

.task-action-loading {
  position: fixed;
  top: 78px;
  right: 28px;
  z-index: 1600;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 220px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid #334155;
  border-radius: 11px;
  background: #111827;
  color: #f8fafc;
  box-shadow: 0 12px 34px rgba(0,0,0,.32);
  pointer-events: none;
}

.task-action-loading-spinner {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  border: 2px solid rgba(148,163,184,.35);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: taskActionSpin .72s linear infinite;
}

.task-action-loading-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.task-action-loading-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.25;
}

.task-action-loading-copy small {
  color: #94a3b8;
  font-size: 10px;
}

@keyframes taskActionSpin { to { transform: rotate(360deg); } }

.light-mode .task-action-loading {
  border-color: #cbd5e1;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 12px 30px rgba(15,23,42,.14);
}

@media (max-width: 700px) {
  .task-action-loading {
    top: 68px;
    left: 10px;
    right: 10px;
    max-width: none;
  }
}


/* Tasks list: XLS-style filter/column controls. */
.task-list-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.task-list-search { flex: 1 1 420px; max-width: 620px; }
.task-list-toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.task-toolbar-active { border-color: var(--mud-palette-primary) !important; color: var(--mud-palette-primary) !important; }
.task-column-filter-strip {
  display: flex;
  align-items: end;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--mud-palette-lines-default);
  background: color-mix(in srgb, var(--mud-palette-surface) 94%, var(--mud-palette-primary) 6%);
}
.task-column-filter-strip label { display: grid; gap: 4px; min-width: 135px; }
.task-column-filter-strip label > span { font-size: 10px; font-weight: 700; color: var(--mud-palette-text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.task-column-filter-strip input,
.task-column-filter-strip select {
  height: 32px;
  border: 1px solid var(--mud-palette-lines-inputs);
  border-radius: 6px;
  padding: 0 9px;
  background: var(--mud-palette-background);
  color: var(--mud-palette-text-primary);
  outline: none;
  font-size: 12px;
}
.task-column-filter-strip input:focus,
.task-column-filter-strip select:focus { border-color: var(--mud-palette-primary); }
.task-columns-backdrop {
  position: fixed; inset: 0; z-index: 1800; display: grid; place-items: center;
  padding: 20px; background: rgba(2, 6, 23, .62);
}
.task-columns-dialog {
  width: min(620px, 96vw); max-height: min(760px, 90vh); overflow: hidden;
  border: 1px solid var(--mud-palette-lines-default); border-radius: 14px;
  background: var(--mud-palette-surface); color: var(--mud-palette-text-primary);
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.task-columns-dialog header { display:flex; justify-content:space-between; gap:18px; padding:18px 20px; border-bottom:1px solid var(--mud-palette-lines-default); }
.task-columns-dialog header h3 { margin:0 0 4px; font-size:18px; }
.task-columns-dialog header p { margin:0; color:var(--mud-palette-text-secondary); font-size:12px; }
.task-columns-close { border:0; background:transparent; color:inherit; font-size:26px; cursor:pointer; }
.task-columns-list { padding:14px 20px; display:grid; grid-template-columns:1fr 1fr; gap:8px 14px; overflow:auto; max-height:520px; }
.task-column-option { min-height:42px; display:flex; align-items:center; gap:10px; padding:8px 10px; border:1px solid var(--mud-palette-lines-default); border-radius:8px; }
.task-column-option input { width:16px; height:16px; }
.task-column-option.is-locked { opacity:.72; }
.task-column-option small { margin-left:auto; color:var(--mud-palette-text-secondary); font-size:10px; }
.task-column-lock { font-size:13px; }
.task-columns-dialog footer { display:flex; align-items:center; gap:10px; padding:14px 20px; border-top:1px solid var(--mud-palette-lines-default); }
.task-columns-spacer { flex:1; }
@media (max-width: 800px) {
  .task-list-toolbar-row { align-items:stretch; flex-direction:column; }
  .task-list-search { max-width:none; }
  .task-columns-list { grid-template-columns:1fr; }
}


/* Tasks: Maverick/Excel-style per-column filter popup. */
.task-table-card.filters-open {
  contain: none !important;
  overflow: visible !important;
}

.task-mav-filter-strip {
  align-items: center;
  flex-wrap: wrap;
  overflow: visible !important;
  gap: 7px;
  position: relative;
  z-index: 20;
}

.task-mav-filter-anchor {
  position: relative;
  min-width: 126px;
}

.task-mav-filter-button {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 9px;
  border: 1px solid var(--mud-palette-lines-inputs);
  border-radius: 6px;
  background: var(--mud-palette-background);
  color: var(--mud-palette-text-primary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.task-mav-filter-button:hover,
.task-mav-filter-button.active {
  border-color: var(--mud-palette-primary);
}

.task-mav-filter-button.active {
  color: var(--mud-palette-primary);
  background: color-mix(in srgb, var(--mud-palette-primary) 9%, var(--mud-palette-background));
}

.task-mav-filter-active-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--mud-palette-primary);
  margin-left: auto;
}

.task-mav-filter-popup {
  position: absolute;
  left: 0;
  top: calc(100% + 5px);
  z-index: 2300;
  width: 292px;
  min-height: 240px;
  overflow: hidden;
  border: 1px solid var(--mud-palette-lines-default);
  border-radius: 7px;
  background: var(--mud-palette-surface);
  color: var(--mud-palette-text-primary);
  box-shadow: 0 16px 42px rgba(0, 0, 0, .38);
}

.task-mav-filter-anchor.align-right .task-mav-filter-popup {
  left: auto;
  right: 0;
}

.task-mav-filter-tabs {
  height: 38px;
  display: flex;
  align-items: end;
  gap: 4px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--mud-palette-lines-default);
}

.task-mav-filter-tabs button {
  height: 31px;
  padding: 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--mud-palette-text-secondary);
  font-size: 11px;
  cursor: pointer;
}

.task-mav-filter-tabs button.active {
  color: var(--mud-palette-primary);
  border-bottom-color: var(--mud-palette-primary);
}

.task-mav-filter-search {
  margin: 10px 10px 7px;
  height: 31px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 7px;
  border: 1px solid var(--mud-palette-lines-inputs);
  border-radius: 4px;
  background: var(--mud-palette-background);
}

.task-column-filter-strip .task-mav-filter-search input {
  height: auto !important;
  width: 100%;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  color: inherit;
  font-size: 11px;
  outline: none;
}

.task-column-filter-strip .task-mav-filter-check {
  min-width: 0 !important;
  min-height: 25px;
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 7px !important;
  padding: 2px 10px;
  cursor: pointer;
}

.task-column-filter-strip .task-mav-filter-check.all {
  border-bottom: 1px solid var(--mud-palette-lines-default);
  padding-bottom: 7px;
}

.task-column-filter-strip .task-mav-filter-check input[type="checkbox"] {
  width: 14px !important;
  height: 14px !important;
  padding: 0 !important;
  border-radius: 2px !important;
  flex: 0 0 14px;
}

.task-column-filter-strip .task-mav-filter-check > span {
  color: var(--mud-palette-text-primary) !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  letter-spacing: normal !important;
  text-transform: none !important;
}

.task-mav-filter-values {
  height: 190px;
  overflow: auto;
  padding: 4px 0;
}

.task-mav-text-filter {
  min-height: 205px;
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 14px 12px;
}

.task-column-filter-strip .task-mav-text-filter select,
.task-column-filter-strip .task-mav-text-filter input {
  width: 100%;
  height: 32px;
  border: 1px solid var(--mud-palette-lines-inputs);
  border-radius: 4px;
  padding: 0 8px;
  background: var(--mud-palette-background);
  color: var(--mud-palette-text-primary);
  font-size: 11px;
}

.task-mav-filter-footer {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-top: 1px solid var(--mud-palette-lines-default);
}

.task-mav-filter-footer button {
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid var(--mud-palette-lines-default);
  border-radius: 4px;
  background: var(--mud-palette-background);
  color: var(--mud-palette-text-primary);
  font-size: 10px;
  cursor: pointer;
}

.task-mav-filter-footer button.apply {
  border-color: var(--mud-palette-primary);
  background: var(--mud-palette-primary);
  color: var(--mud-palette-primary-text);
}

.task-mav-filter-footer button.clear {
  color: var(--mud-palette-error);
}


/* Shared Maverick-style column filter used by Task Grid/XLS. */
.tg-mav-filter-row th {
  position: relative;
  overflow: visible !important;
  padding: 3px 4px !important;
  height: 34px;
}

.mav-column-filter {
  position: relative;
  width: 100%;
  min-width: 24px;
}

.mav-column-filter-trigger {
  width: 100%;
  min-width: 24px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--mud-palette-text-secondary);
  font-size: 10px;
  cursor: pointer;
}

.mav-column-filter-trigger:hover {
  border-color: var(--mud-palette-lines-inputs);
  background: color-mix(in srgb, var(--mud-palette-primary) 6%, transparent);
}

.mav-column-filter-trigger.active {
  color: var(--mud-palette-primary);
  border-color: var(--mud-palette-primary);
  background: color-mix(in srgb, var(--mud-palette-primary) 10%, transparent);
}

.mav-column-filter-popup {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  z-index: 4000;
  width: 270px;
  min-height: 255px;
  border: 1px solid #4b5563;
  border-radius: 4px;
  background: #25282d;
  color: #f3f4f6;
  box-shadow: 0 16px 36px rgba(0,0,0,.45);
  text-align: left;
  font-weight: 400;
}

.mav-column-filter-tabs {
  display: flex;
  align-items: end;
  gap: 4px;
  height: 37px;
  padding: 5px 8px 0;
  border-bottom: 1px solid #3f444d;
}

.mav-column-filter-tabs button {
  height: 31px;
  padding: 0 7px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #d1d5db;
  font-size: 11px;
  cursor: pointer;
}

.mav-column-filter-tabs button.active {
  color: #60a5fa;
  border-bottom-color: #60a5fa;
}

.mav-column-filter-search {
  margin: 10px 10px 7px;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid #4b5563;
  background: #1f2227;
}

.mav-column-filter-search input {
  width: 100%;
  height: 26px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f9fafb;
  font-size: 11px;
}

.mav-column-filter-check {
  min-height: 25px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 10px;
  color: #f3f4f6;
  font-size: 11px;
  cursor: pointer;
}

.mav-column-filter-check.all {
  padding-bottom: 7px;
  border-bottom: 1px solid #3f444d;
}

.mav-column-filter-check input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.mav-column-filter-values {
  height: 175px;
  overflow: auto;
  padding: 4px 0;
}

.mav-column-text-filter {
  min-height: 190px;
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 14px 12px;
}

.mav-column-text-filter select,
.mav-column-text-filter input {
  width: 100%;
  height: 31px;
  padding: 0 7px;
  border: 1px solid #4b5563;
  border-radius: 2px;
  background: #1f2227;
  color: #f9fafb;
  font-size: 11px;
  outline: none;
}

.mav-column-filter-footer {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 8px 9px;
  border-top: 1px solid #3f444d;
}

.mav-column-filter-footer button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #4b5563;
  background: #202329;
  color: #f3f4f6;
  font-size: 10px;
  cursor: pointer;
}

.mav-column-filter-footer button.apply {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

.mav-column-filter-footer button.clear {
  color: #fca5a5;
}

.light-mode .mav-column-filter-popup {
  border-color: #cbd5e1;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 14px 32px rgba(15,23,42,.18);
}

.light-mode .mav-column-filter-tabs,
.light-mode .mav-column-filter-check.all,
.light-mode .mav-column-filter-footer {
  border-color: #e2e8f0;
}

.light-mode .mav-column-filter-search,
.light-mode .mav-column-text-filter select,
.light-mode .mav-column-text-filter input,
.light-mode .mav-column-filter-footer button {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
}

.light-mode .mav-column-filter-check { color: #0f172a; }


/* Task Grid filter UX: filters live in column headers, not in a blank second row. */
.task-grid-reference-table thead th {
  overflow: visible !important;
}

.tg-header-cell-inner {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.tg-header-label {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.tg-required-mark {
  color: #ef4444;
  font-weight: 800;
}

.mav-column-filter.is-compact {
  width: auto;
  min-width: 24px;
  flex: 0 0 24px;
}

.mav-column-filter.is-compact .mav-column-filter-trigger {
  position: relative;
  width: 24px;
  min-width: 24px;
  height: 24px;
  padding: 0;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #718096;
  opacity: .72;
  transition: background .12s ease, border-color .12s ease, color .12s ease, opacity .12s ease;
}

.task-grid-reference-table thead th:hover .mav-column-filter.is-compact .mav-column-filter-trigger,
.mav-column-filter.is-compact .mav-column-filter-trigger:hover,
.mav-column-filter.is-compact.is-open .mav-column-filter-trigger {
  opacity: 1;
  color: #cbd5e1;
  border-color: #3b4a63;
  background: #172033;
}

.mav-column-filter.is-compact .mav-column-filter-trigger.active {
  opacity: 1;
  color: #60a5fa;
  border-color: #3b82f6;
  background: rgba(59,130,246,.13);
}

.mav-column-filter-active-indicator {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #60a5fa;
  box-shadow: 0 0 0 2px #111827;
}

.mav-column-filter.is-compact .mav-column-filter-popup {
  top: calc(100% + 6px);
  left: 0;
}

/* Keep right-side columns' popups inside the viewport/table area. */
.task-grid-reference-table th:nth-last-child(-n+5) .mav-column-filter-popup {
  left: auto;
  right: 0;
}

.task-grid-reference-toolbar .mud-icon-root {
  font-size: 18px;
}

/* Legacy filter row is intentionally unused after header-filter redesign. */
.tg-filter-row,
.tg-mav-filter-row {
  display: none !important;
}

/* Shared Tasks + Task Grid/XLS sortable/filterable column header.
   Title/sort and filter now live on the SAME line. This keeps the filter icon
   immediately beside the column title instead of creating a second header row. */
.mav-grid-header {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  overflow: visible;
}

.mav-grid-sort-button {
  min-width: 0;
  min-height: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  line-height: 1;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 1 auto;
}

.mav-grid-sort-button:hover .mav-grid-sort-label,
.mav-grid-sort-button:focus-visible .mav-grid-sort-label {
  color: #93c5fd;
}

.mav-grid-sort-button:focus-visible {
  outline: 1px solid #3b82f6;
  outline-offset: 2px;
  border-radius: 4px;
}

.mav-grid-sort-label {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.mav-grid-sort-arrow {
  flex: 0 0 auto;
  color: #60a5fa;
  font-size: 12px;
  line-height: 1;
  font-weight: 900;
}

.mav-grid-sort-arrow.is-idle {
  color: #64748b;
  opacity: .42;
  font-size: 11px;
}

.mav-grid-sort-button:hover .mav-grid-sort-arrow.is-idle {
  opacity: .9;
  color: #94a3b8;
}

.mav-column-sort-actions {
  display: grid;
  gap: 2px;
  padding: 7px;
  border-bottom: 1px solid #3f444d;
}

.mav-column-sort-actions button {
  width: 100%;
  min-height: 29px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: #e5e7eb;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}

.mav-column-sort-actions button:hover,
.mav-column-sort-actions button.active {
  border-color: #475569;
  background: #1f2937;
  color: #93c5fd;
}

.mav-column-sort-actions button.clear-sort {
  color: #fca5a5;
}

.mav-column-filter.align-right .mav-column-filter-popup {
  left: auto;
  right: 0;
}

.light-mode .mav-column-sort-actions {
  border-color: #e2e8f0;
}

.light-mode .mav-column-sort-actions button {
  color: #0f172a;
}

.light-mode .mav-column-sort-actions button:hover,
.light-mode .mav-column-sort-actions button.active {
  border-color: #cbd5e1;
  background: #f1f5f9;
  color: #2563eb;
}

/* MudDataGrid Tasks: title, sort state and filter icon stay on one compact line. */
.task-data-grid .mud-table-head .mud-table-row {
  height: 42px !important;
}

.task-data-grid .mud-table-head .mud-table-cell,
.task-data-grid thead th {
  height: 42px !important;
  min-height: 42px !important;
  padding: 0 10px !important;
  vertical-align: middle !important;
  overflow: visible !important;
  white-space: nowrap;
}

.task-data-grid .mud-table-cell .column-header {
  height: 42px !important;
  min-height: 42px !important;
  align-items: center !important;
  overflow: visible !important;
}

.task-data-grid thead th .mud-table-cell-custom-group {
  width: 100%;
  min-width: 0;
  height: 42px;
  overflow: visible !important;
}

.task-data-grid .mav-grid-header {
  height: 42px;
  min-height: 42px;
}

.task-data-grid .mav-grid-sort-label {
  white-space: nowrap;
}

.task-data-grid .mav-column-filter.is-compact .mav-column-filter-popup {
  z-index: 5000;
}

.task-data-grid thead th:nth-last-child(-n+4) .mav-column-filter-popup {
  left: auto;
  right: 0;
}
