/* Flowtive UI base layer: shared control sizes and button styles.
   Loaded after every other dashboard stylesheet, so it wins over the older class rules
   without !important. Inline style="" attributes still win; those get cleaned up screen
   by screen. To roll back, remove the <link> to this file in dashboard.html. */

/* Tokens (sizes, radius, colour roles, type, motion) live in ui-tokens.css, loaded just before this file. */

/* ---------- Buttons: one shape, three sizes, four variants ---------- */

.btn-primary,
.btn-secondary,
.btn-small,
.btn-danger,
.ft-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--ft-h-md);
    padding: 6px 14px;
    border-radius: var(--ft-radius-ctl);
    font-family: inherit;
    font-size: var(--ft-text-md);
    font-weight: var(--ft-weight-semibold);
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    transform: none;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.btn-primary :is(i, svg),
.btn-secondary :is(i, svg),
.btn-danger :is(i, svg),
.ft-btn :is(i, svg) {
    font-size: var(--ft-icon-md);
}

/* Primary: the one red action on a screen. No lift, no shine. */
.btn-primary,
.ft-btn-primary {
    background: var(--brand-primary);
    border: 1px solid var(--brand-primary);
    color: var(--text-on-brand);
}

.btn-primary:hover,
.ft-btn-primary:hover {
    background: var(--brand-primary-dark);
    border-color: var(--brand-primary-dark);
    transform: none;
    box-shadow: none;
}

.btn-primary::after {
    display: none;
}

.btn-primary:active,
.btn-secondary:active,
.btn-small:active,
.btn-danger:active,
.ft-btn:active {
    transform: scale(0.98);
}

/* Secondary: neutral, bordered. */
.btn-secondary {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-light);
}

/* Ghost: no chrome until hovered. */
.ft-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.ft-btn-ghost:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-main);
}

/* Danger: destructive actions. */
.btn-danger {
    background: var(--bg-panel);
    border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--brand-primary-light);
    border-color: var(--danger);
}

/* Small size (keeps whatever colour the button already has). */
.btn-small {
    min-height: var(--ft-h-sm);
    padding: 4px 10px;
    font-size: var(--ft-text-sm);
    gap: 5px;
}

.btn-small:hover {
    transform: none;
}

.btn-small :is(i, svg) {
    font-size: var(--ft-icon-sm);
}

.ft-btn {
    min-height: var(--ft-h-md);
    height: auto;
}

/* Shared focus ring for keyboard users. */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-small:focus-visible,
.btn-danger:focus-visible,
.ft-btn:focus-visible,
.ft-pill-btn:focus-visible {
    outline: none;
    box-shadow: var(--ft-ring);
}

/* Dropdown-style pill buttons (filters, pickers). */
.ft-pill-btn {
    min-height: var(--ft-h-md);
    border-radius: var(--ft-radius-ctl);
    font-size: var(--ft-text-md);
}

.ft-pill-btn .chev {
    font-size: var(--ft-icon-sm);
    opacity: 1;
    color: var(--text-muted);
}

/* Extra-small size for ghost/inline actions. */
.ft-btn.ft-btn-sm {
    min-height: var(--ft-h-sm);
    padding: 4px 8px;
    font-size: var(--ft-text-sm);
    font-weight: var(--ft-weight-medium);
    gap: 5px;
}

.ft-btn.ft-btn-sm :is(i, svg) {
    font-size: var(--ft-icon-sm);
}

/* ---------- Task modal ----------
   One primary action (Save task). Everything else is secondary, ghost or danger.
   Fields share one height, radius and label style. */
#task-modal-enhanced .modal-header .tm-close {
    width: var(--ft-h-md);
    height: var(--ft-h-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--ft-radius-ctl);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--ft-icon-lg);
    cursor: pointer;
}

#task-modal-enhanced .modal-header .tm-close:hover {
    transform: none;
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-main);
}

#task-modal-enhanced #modal-title-enhanced {
    font-size: 15px;
    font-weight: var(--ft-weight-semibold);
}

#task-modal-enhanced #task-modal-title-icon {
    color: var(--text-muted) !important;
    font-size: var(--ft-icon-lg);
}

#task-modal-enhanced .section-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: none;
}

#task-modal-enhanced .section-card:hover {
    box-shadow: none;
}

#task-modal-enhanced .section-header h3 {
    font-size: var(--ft-text-md);
    font-weight: var(--ft-weight-semibold);
    color: var(--text-main);
}

#task-modal-enhanced .section-header h3 i {
    color: var(--text-muted);
    font-size: var(--ft-icon-md);
}

/* Labels: sentence case, muted, one size. */
#task-modal-enhanced label {
    display: block;
    margin: 0 0 6px;
    font-size: var(--ft-text-sm);
    font-weight: var(--ft-weight-medium);
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-secondary);
}

#task-modal-enhanced .tm-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

#task-modal-enhanced .tm-label-row label {
    margin: 0;
}

#task-modal-enhanced .tm-inline-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    white-space: nowrap;
}

/* Fields: 36px tall, 8px radius, 13px text. */
#task-modal-enhanced :is(input[type="text"], input[type="date"], input[type="number"], input[type="email"], input[type="url"], select, .tm-field) {
    width: 100%;
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--ft-radius-ctl);
    background: var(--bg-panel);
    color: var(--text-main);
    font-family: inherit;
    font-size: var(--ft-text-md);
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

#task-modal-enhanced textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--ft-radius-ctl);
    background: var(--bg-panel);
    color: var(--text-main);
    font-family: inherit;
    font-size: var(--ft-text-md);
    line-height: 1.5;
}

#task-modal-enhanced :is(input, select, textarea, .tm-field):hover:not(:focus):not(:disabled) {
    border-color: var(--text-light);
}

#task-modal-enhanced :is(input, select, textarea, .tm-field):focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: var(--ft-ring);
}

#task-modal-enhanced :is(input[type="text"], input[type="date"], input[type="number"], select, .tm-field)::placeholder,
#task-modal-enhanced textarea::placeholder {
    color: var(--text-light);
}

/* Title reads as a heading: no box until hovered or focused (ClickUp/Asana style). */
#task-modal-enhanced #m-title-enhanced {
    min-height: 44px;
    padding: 8px 10px !important;
    font-size: 18px !important;
    font-weight: var(--ft-weight-semibold);
    border-color: transparent;
    border-radius: var(--ft-radius-ctl) !important;
    background: transparent !important;
}

#task-modal-enhanced #m-title-enhanced:hover:not(:focus) {
    border-color: var(--border);
}

#task-modal-enhanced #m-title-enhanced:focus {
    border-color: var(--brand-primary);
    background: var(--bg-panel) !important;
}

/* Template bar */
#task-modal-enhanced #template-selector-bar {
    background: var(--bg-panel) !important;
    border-bottom: 1px solid var(--border-light) !important;
}

#task-modal-enhanced #template-selector-bar .tm-field {
    width: auto;
}

/* Assignee picker trigger matches the fields. */
#task-modal-enhanced #assignee-picker > .btn-secondary {
    min-height: 36px;
    padding: 6px 12px !important;
    border-radius: var(--ft-radius-ctl) !important;
    font-weight: var(--ft-weight-regular);
}

#task-modal-enhanced #assignee-dropdown {
    border-radius: 10px !important;
}

#task-modal-enhanced #assignee-search {
    border-radius: var(--ft-radius-ctl) !important;
    font-size: var(--ft-text-md) !important;
}

/* AI action: quiet, not a second red button. */
#task-modal-enhanced .tm-ai-btn {
    color: var(--brand-primary);
}

#task-modal-enhanced .tm-ai-btn:hover {
    background: var(--brand-primary-light);
    border-color: transparent;
    color: var(--brand-primary-dark);
}

/* Pro badge: small amber tint instead of a gradient pill. */
.tm-pro-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--warning) 16%, transparent);
    color: color-mix(in srgb, var(--warning) 70%, var(--text-main));
    font-size: 11px;
    font-weight: var(--ft-weight-semibold);
}

/* Dependency summary: neutral panel, not a red alert box. */
#task-modal-enhanced .tm-dep-stats {
    margin-top: 4px;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-app);
}

#task-modal-enhanced .tm-dep-stats-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: var(--ft-text-sm);
    font-weight: var(--ft-weight-semibold);
    color: var(--text-secondary);
}

#task-modal-enhanced .tm-dep-stats-title i {
    color: var(--text-muted);
}

#task-modal-enhanced .tm-dep-stats-row {
    display: flex;
    justify-content: space-between;
    font-size: var(--ft-text-md);
    padding: 2px 0;
}

#task-modal-enhanced .tm-dep-stats-row span:first-child {
    color: var(--text-muted);
}

#task-modal-enhanced .tm-dep-stats-row span:last-child {
    font-weight: var(--ft-weight-semibold);
    color: var(--text-main);
}

/* Footer actions: Save task is the only primary button in the modal. */
#task-modal-enhanced .tm-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

#task-modal-enhanced .tm-actions > button {
    width: 100%;
    min-height: 36px;
}

/* Comments / History tabs */
#task-modal-enhanced .activity-tab {
    font-size: var(--ft-text-md);
    font-weight: var(--ft-weight-medium);
}

/* ---------- Icon sizes ----------
   Outline glyphs read lighter than Font Awesome solid, so navigation icons go to
   16px (the ClickUp/Asana size). Row-level icon sizes are set inline in the JS
   templates and get fixed per screen. */
aside .sidebar-item i,
aside .section-toggle-left > i,
aside .workspace-tools > i {
    font-size: var(--ft-icon-lg);
    width: 18px;
    text-align: center;
}

aside .sidebar-item i.section-toggle-chevron,
aside .sidebar-item i.fa-chevron-down,
aside .sidebar-item i.fa-chevron-right {
    font-size: var(--ft-icon-sm);
    color: var(--text-muted);
}

/* ---------- Page header (ftRenderPageHeader) ----------
   Same header on every view: optional breadcrumb, then the scope or screen name. */
.ft-page-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 10px;
    min-width: 0;
}

.ft-page-header[hidden] {
    display: none;
}

.ft-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: var(--ft-fs-xs);
    font-weight: var(--ft-weight-medium);
    color: var(--text-muted);
}

.ft-breadcrumb[hidden] {
    display: none;
}

.ft-breadcrumb-sep {
    color: var(--text-light);
}

.ft-page-title {
    margin: 0;
    font-size: var(--ft-fs-xl);
    font-weight: var(--ft-weight-semibold);
    letter-spacing: -0.01em;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Toasts (ui-kit.js showToast) ----------
   Neutral surface, coloured icon for the type, optional action such as Undo. */
/* Bottom centre, clear of the floating + button in the bottom-right corner. */
.ft-toast-host {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 2147483646;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.ft-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    max-width: min(420px, calc(100vw - 40px));
    padding: 10px 8px 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--ft-r-card);
    background: var(--bg-panel);
    color: var(--text-main);
    font-size: var(--ft-fs-sm);
    line-height: 1.4;
    box-shadow: var(--ft-elev-3);
    animation: ft-toast-in var(--ft-dur) var(--ft-ease);
}

.ft-toast.is-leaving {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.ft-toast-icon {
    flex-shrink: 0;
    font-size: var(--ft-icon-lg);
}

.ft-toast--success .ft-toast-icon { color: var(--ft-success); }
.ft-toast--error .ft-toast-icon { color: var(--ft-danger); }
.ft-toast--warning .ft-toast-icon { color: var(--ft-warning); }
.ft-toast--info .ft-toast-icon { color: var(--ft-info); }

.ft-toast-msg {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.ft-toast-action {
    flex-shrink: 0;
    min-height: var(--ft-h-sm);
    padding: 4px 10px;
    border: none;
    border-radius: var(--ft-radius-ctl);
    background: transparent;
    color: var(--ft-accent);
    font: inherit;
    font-weight: var(--ft-weight-semibold);
    cursor: pointer;
}

.ft-toast-action:hover {
    background: var(--ft-accent-soft);
}

.ft-toast-close {
    flex-shrink: 0;
    width: var(--ft-h-sm);
    height: var(--ft-h-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--ft-radius-ctl);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.ft-toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

@keyframes ft-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 640px) {
    .ft-toast-host {
        left: 12px;
        right: 12px;
        bottom: 88px;
        transform: none;
        align-items: stretch;
    }

    .ft-toast {
        max-width: none;
    }
}

/* ---------- Dialogs (ui-kit.js ftDialog / ftConfirm / ftAlert) ---------- */
.ft-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.45);
    animation: ft-fade-in var(--ft-dur-fast) ease;
}

.ft-dialog-overlay.is-leaving {
    opacity: 0;
    transition: opacity 140ms ease;
}

.ft-dialog {
    width: 440px;
    max-width: 100%;
    max-height: calc(100vh - 32px);
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--ft-r-card);
    background: var(--bg-panel);
    color: var(--text-main);
    box-shadow: var(--ft-elev-3);
    animation: ft-dialog-in var(--ft-dur) var(--ft-ease);
}

.ft-dialog-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 0;
}

.ft-dialog-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: color-mix(in srgb, var(--ft-info) var(--ft-tint), transparent);
    color: var(--ft-info);
    font-size: var(--ft-icon-lg);
}

.ft-dialog--danger .ft-dialog-icon {
    background: color-mix(in srgb, var(--ft-danger) var(--ft-tint), transparent);
    color: var(--ft-danger);
}

.ft-dialog-title {
    margin: 0;
    font-size: var(--ft-fs-lg);
    font-weight: var(--ft-weight-semibold);
    color: var(--text-main);
}

.ft-dialog-body {
    padding: 12px 20px 4px 68px;
}

.ft-dialog-msg {
    margin: 0;
    font-size: var(--ft-fs-md);
    line-height: 1.55;
    color: var(--text-secondary);
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.ft-dialog-details {
    margin: 8px 0 0;
    font-size: var(--ft-fs-sm);
    color: var(--text-muted);
}

.ft-dialog-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 20px;
}

.ft-btn-danger-solid,
.ft-btn-danger-solid:hover {
    background: var(--ft-danger);
    border-color: var(--ft-danger);
    color: #fff;
}

.ft-btn-danger-solid:hover {
    filter: brightness(0.92);
}

@keyframes ft-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ft-dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

/* ---------- Soft chips (status / priority) ----------
   Set --chip to a status or priority colour; the chip tints itself from it.
   Used by the table view's status and priority pickers. */
.ft-pill-btn.ft-chip {
    width: auto;
    justify-content: flex-start;
    gap: 6px;
    min-height: var(--ft-h-sm);
    padding: 3px 8px 3px 8px;
    border: 1px solid color-mix(in srgb, var(--chip) var(--ft-tint-border), transparent);
    border-radius: var(--ft-r-chip);
    background: color-mix(in srgb, var(--chip) var(--ft-tint), transparent) !important;
    color: color-mix(in srgb, var(--chip) var(--ft-tint-text), var(--text-main));
    font-size: var(--ft-fs-xs);
    font-weight: var(--ft-weight-semibold);
    box-shadow: none;
}

.ft-pill-btn.ft-chip::before {
    content: '';
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--chip);
}

.ft-pill-btn.ft-chip .chev {
    margin-left: 2px;
    font-size: 10px;
    color: currentColor;
    opacity: 0.7;
}

/* Quiet row actions (table view): neutral until hovered; delete turns red on hover only. */
.ft-row-btn {
    width: var(--ft-h-sm);
    height: var(--ft-h-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--ft-radius-ctl);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--ft-icon-md);
    cursor: pointer;
    transition: background-color var(--ft-dur-fast) ease, color var(--ft-dur-fast) ease;
}

.ft-row-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-main);
}

.ft-row-btn.is-danger:hover {
    background: color-mix(in srgb, var(--ft-danger) var(--ft-tint), transparent);
    border-color: color-mix(in srgb, var(--ft-danger) var(--ft-tint-border), transparent);
    color: var(--ft-danger);
}

/* ---------- Red only for actions ----------
   Red stays on the primary action, the selected item and real danger (overdue, delete).
   Everything below used red as decoration or for a meaning that has its own colour. */

/* Gantt: bars by status colour, not brand red. */
.gantt .bar-wrapper.bar-inprogress .bar,
.gantt .bar-group.bar-inprogress .bar,
.gantt .bar-inprogress .bar {
    fill: var(--ft-status-progress) !important;
}

.gantt .bar-wrapper.bar-done .bar,
.gantt .bar-group.bar-done .bar,
.gantt .bar-done .bar {
    fill: var(--ft-status-done) !important;
}

.gantt .bar-wrapper.bar-todo .bar,
.gantt .bar-group.bar-todo .bar,
.gantt .bar-todo .bar {
    fill: var(--ft-status-todo) !important;
}

.gantt .bar {
    filter: none;
}

/* Org dashboard workload: neutral bars (load is not an error). */
.workload-bar-container .workload-bar-fill {
    background: var(--ft-status-todo);
}

/* Segmented control (Gantt Day / Week / Month). */
.ft-segment {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--ft-radius-ctl);
    background: var(--bg-app);
}

.ft-segment .ft-segment-btn {
    min-height: var(--ft-h-sm);
    padding: 4px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: var(--ft-fs-sm);
    font-weight: var(--ft-weight-medium);
    box-shadow: none;
    cursor: pointer;
}

.ft-segment .ft-segment-btn:hover {
    color: var(--text-main);
    background: var(--bg-hover);
}

.ft-segment .ft-segment-btn.active {
    background: var(--bg-panel);
    color: var(--text-main);
    box-shadow: var(--ft-elev-1);
}

/* Legend (Gantt). */
.ft-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 0 20px 10px;
    font-size: var(--ft-fs-xs);
    color: var(--text-secondary);
}

.ft-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ft-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--chip);
}

/* Section header icons: muted, not red. */
.section-header h3 i,
.section-header h4 i {
    color: var(--text-muted);
}

/* =====================================================================
   Phase 2: shared task chips, date picker, quick add, side panel
   ===================================================================== */

/* ---------- Date chip (ftDateChip / ftEnhanceDateInput) ---------- */
.ft-date-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--ft-h-sm);
    padding: 3px 8px;
    border: 1px solid transparent;
    border-radius: var(--ft-r-chip);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: var(--ft-fs-xs);
    font-weight: var(--ft-weight-medium);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--ft-dur-fast) ease, border-color var(--ft-dur-fast) ease;
}

.ft-date-chip i {
    font-size: var(--ft-icon-sm);
    color: var(--text-muted);
}

.ft-date-chip:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-main);
}

.ft-date-chip:focus-visible {
    outline: none;
    box-shadow: var(--ft-ring);
}

.ft-date-chip.is-empty {
    color: var(--text-light);
}

.ft-date-chip.is-overdue,
.ft-date-chip.is-overdue i {
    color: var(--ft-danger);
}

.ft-date-chip.is-soon {
    color: color-mix(in srgb, var(--ft-warning) 80%, var(--text-main));
}

.ft-date-chip:disabled {
    cursor: default;
    opacity: 0.7;
}

/* The real <input> stays in the DOM for its value; the chip is what people see. */
.ft-date-native {
    display: none !important;
}

/* Field-style date chips (filter bar, task form). */
.ft-date-chip.ft-date-field {
    min-height: var(--ft-h-md);
    padding: 4px 10px;
    border-color: var(--border);
    background: var(--bg-panel);
    color: var(--text-main);
    font-size: var(--ft-fs-sm);
}

.ft-date-chip.ft-date-field.is-empty {
    color: var(--text-muted);
}

#task-modal-enhanced .ft-date-chip.ft-date-field {
    width: 100%;
    min-height: 36px;
    justify-content: flex-start;
    border-radius: var(--ft-radius-ctl);
}

/* ---------- Date picker popover (ftDatePicker) ---------- */
.ft-datepicker {
    position: fixed;
    z-index: 2147483000;
    display: flex;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--ft-r-card);
    background: var(--bg-panel);
    color: var(--text-main);
    box-shadow: var(--ft-elev-3);
    animation: ft-fade-in var(--ft-dur-fast) ease;
}

.ft-dp-quick {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 148px;
    padding-right: 8px;
    border-right: 1px solid var(--border-light);
}

.ft-dp-quick-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: var(--ft-h-md);
    padding: 4px 10px;
    border: none;
    border-radius: var(--ft-radius-ctl);
    background: transparent;
    color: var(--text-main);
    font: inherit;
    font-size: var(--ft-fs-sm);
    text-align: left;
    cursor: pointer;
}

.ft-dp-quick-hint {
    font-size: var(--ft-fs-xs);
    color: var(--text-muted);
}

.ft-dp-quick-btn:hover,
.ft-dp-quick-btn:focus-visible {
    background: var(--bg-hover);
    outline: none;
}

.ft-dp-quick-btn.is-clear {
    margin-top: auto;
    color: var(--text-secondary);
}

.ft-dp-cal {
    width: 252px;
}

.ft-dp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.ft-dp-title {
    font-size: var(--ft-fs-sm);
    font-weight: var(--ft-weight-semibold);
}

.ft-dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 36px);
    gap: 0;
}

.ft-dp-wd {
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: var(--ft-weight-semibold);
    color: var(--text-muted);
}

.ft-dp-day {
    width: 36px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--ft-radius-ctl);
    background: transparent;
    color: var(--text-main);
    font: inherit;
    font-size: var(--ft-fs-sm);
    cursor: pointer;
}

.ft-dp-day:hover {
    background: var(--bg-hover);
}

.ft-dp-day:focus-visible {
    outline: none;
    box-shadow: var(--ft-ring);
}

.ft-dp-day.is-outside {
    color: var(--text-light);
}

.ft-dp-day.is-today {
    color: var(--ft-accent);
    font-weight: var(--ft-weight-semibold);
}

.ft-dp-day.is-selected,
.ft-dp-day.is-selected:hover {
    background: var(--ft-accent);
    color: var(--text-on-brand, #fff);
    font-weight: var(--ft-weight-semibold);
}

@media (max-width: 560px) {
    .ft-datepicker {
        flex-direction: column;
        left: 8px !important;
        right: 8px;
    }

    .ft-dp-quick {
        width: auto;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0 0 8px;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }

    .ft-dp-quick-hint {
        display: none;
    }
}

/* ---------- Quick add (list + board) ---------- */
.ft-quick-add-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: none;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.ft-quick-add {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
}

.ft-quick-add-input {
    flex: 1;
    min-width: 0;
    min-height: var(--ft-h-md);
    padding: 4px 10px;
    border: 1px solid var(--ft-accent);
    border-radius: var(--ft-radius-ctl);
    background: var(--bg-panel);
    color: var(--text-main);
    font: inherit;
    font-size: var(--ft-fs-sm);
    box-shadow: var(--ft-ring);
    outline: none;
}

.ft-quick-add-hint {
    flex-shrink: 0;
    font-size: var(--ft-fs-xs);
    color: var(--text-muted);
}

.board-add-task {
    margin: 6px 4px 4px;
    width: calc(100% - 8px);
    min-height: var(--ft-h-md);
    padding: 4px 10px;
    border-radius: var(--ft-radius-ctl);
    color: var(--text-muted);
    font-size: var(--ft-fs-sm);
}

.board-add-task:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.board-col .ft-quick-add {
    padding: 6px 4px;
}

.board-col .ft-quick-add-hint {
    display: none;
}

/* ---------- Board card footer ---------- */
.board-card .board-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.board-card .board-card-spacer {
    flex: 1;
}

.board-card .board-card-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 4px;
    font-size: var(--ft-fs-xs);
    color: var(--text-muted);
}

.board-card .board-card-count i {
    font-size: var(--ft-icon-sm);
}

.board-card .board-assignee-wrapper {
    display: inline-flex;
    align-items: center;
    padding: 2px;
    border: none;
    border-radius: var(--ft-r-full);
    background: transparent;
    cursor: pointer;
}

.board-card .board-assignee-wrapper:hover {
    background: var(--bg-hover);
}

/* ---------- Table rows ---------- */
.ft-table-row {
    border-bottom: 1px solid var(--border-light);
    transition: background-color var(--ft-dur-fast) ease;
}

.ft-table-row:hover {
    background: var(--bg-hover);
}

/* ---------- Task modal: header actions + footer (both layouts) ---------- */
#task-modal-enhanced .tm-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

#task-modal-enhanced .modal.modal-large {
    display: flex !important;
    flex-direction: column !important;
}

#task-modal-enhanced .modal-body {
    flex: 1 1 auto;
    min-height: 0;
}

#task-modal-enhanced .tm-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-panel);
}

#task-modal-enhanced .tm-footer-spacer {
    flex: 1;
}

#task-modal-enhanced .tm-footer > button {
    min-height: 36px;
    width: auto;
}

/* ---------- Task modal as a side panel (default; "Expand" restores the full view) ---------- */
#task-modal-enhanced.ft-panel:not(.is-expanded) {
    justify-content: flex-end !important;
    align-items: stretch !important;
    padding: 0 !important;
    background: rgba(15, 23, 42, 0.28) !important;
    backdrop-filter: none !important;
}

#task-modal-enhanced.ft-panel:not(.is-expanded) .modal.modal-large {
    width: min(760px, 100vw) !important;
    max-width: 100vw !important;
    /* Stretch to the full-height overlay. Not 100vh: at some widths the app zooms <html>
       (e.g. 0.78), which makes 100vh fall short of the screen. */
    height: auto !important;
    max-height: none !important;
    align-self: stretch !important;
    margin: 0 !important;
    border-radius: 16px 0 0 16px !important;
    transform: none !important;
    animation: ft-panel-in var(--ft-dur) var(--ft-ease);
}

#task-modal-enhanced.ft-panel:not(.is-expanded) .modal-body {
    padding: 0 !important;
    overflow: hidden !important;
}

#task-modal-enhanced.ft-panel:not(.is-expanded) .modal-columns {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    height: 100% !important;
    overflow-y: auto !important;
    padding: 12px 16px 24px !important;
}

/* Flatten the three columns so the sections can be re-ordered in one scroll:
   name + description, then properties, then checklist and the rest, then comments. */
#task-modal-enhanced.ft-panel:not(.is-expanded) .modal-left-column,
#task-modal-enhanced.ft-panel:not(.is-expanded) .modal-center-column,
#task-modal-enhanced.ft-panel:not(.is-expanded) .modal-right-column {
    display: contents !important;
}

#task-modal-enhanced.ft-panel:not(.is-expanded) .modal-left-column > :first-child { order: 1; }
#task-modal-enhanced.ft-panel:not(.is-expanded) .modal-center-column > * { order: 2; flex: none !important; }
#task-modal-enhanced.ft-panel:not(.is-expanded) .modal-left-column > :nth-child(n+2) { order: 3; }
#task-modal-enhanced.ft-panel:not(.is-expanded) .modal-right-column > * { order: 4; min-height: 320px; flex: none !important; }

#task-modal-enhanced.ft-panel:not(.is-expanded) .section-card {
    margin-bottom: 0 !important;
}

/* Properties as a two-column grid in the panel (Asana-style property block). */
#task-modal-enhanced.ft-panel:not(.is-expanded) .tm-props {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px !important;
}

#task-modal-enhanced.ft-panel:not(.is-expanded) .tm-props > hr,
#task-modal-enhanced.ft-panel:not(.is-expanded) .tm-props > .tm-dep-stats,
#task-modal-enhanced.ft-panel:not(.is-expanded) .tm-props > #custom-fields-section,
#task-modal-enhanced.ft-panel:not(.is-expanded) .tm-props > #recurring-task-section {
    grid-column: 1 / -1;
}

#task-modal-enhanced.ft-panel:not(.is-expanded) .tm-props > hr {
    margin: 0 !important;
}

/* Floating assistant button would sit on top of the panel's content. */
body.ft-task-open #ai-agent-btn {
    display: none !important;
}

@keyframes ft-panel-in {
    from { transform: translateX(24px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

@media (max-width: 768px) {
    #task-modal-enhanced.ft-panel:not(.is-expanded) .modal.modal-large {
        width: 100vw !important;
        border-radius: 0 !important;
    }

    #task-modal-enhanced.ft-panel:not(.is-expanded) .tm-props {
        grid-template-columns: minmax(0, 1fr);
    }

    #task-modal-enhanced #tm-expand-toggle {
        display: none;
    }
}

/* Manage team: invite note where the password field used to be. */
.tm-invite-note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--ft-radius-ctl);
    background: var(--bg-app);
    color: var(--text-secondary);
    font-size: var(--ft-fs-sm);
    line-height: 1.45;
}

.tm-invite-note i {
    margin-top: 2px;
    color: var(--ft-info);
}

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