/* === PLANNER.CSS ===
   assets/css/planner.css
   НАЗНАЧЕНИЕ: Стили планировщика — три ресайзабельные панели, мини-календарь, недельный вид
   СВЯЗИ: app.css (CSS переменные)
   РАЗМЕР: ~400 строк */

/* --- 3-панельный layout --- */
.tf-planner {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.tf-pl-left {
    width: 220px;
    min-width: 180px;
    max-width: 320px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.tf-pl-middle {
    width: 300px;
    min-width: 200px;
    max-width: 500px;
    flex-shrink: 0;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.tf-pl-right {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tf-pl-handle {
    width: 5px;
    flex-shrink: 0;
    cursor: col-resize;
    background: var(--border);
    transition: background 0.15s;
    position: relative;
    z-index: 2;
}
.tf-pl-handle:hover,
.tf-pl-handle.active {
    background: var(--color-primary);
}

/* --- Заголовки панелей --- */
.tf-pl-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
}

/* --- Мини-календарь --- */
.tf-pl-cal {
    padding: 10px;
    border-bottom: 1px solid var(--border);
}
.tf-pl-cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.tf-pl-cal-nav span {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
.tf-pl-cal-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
}
.tf-pl-cal-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.tf-pl-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    text-align: center;
}
.tf-pl-cal-dow {
    font-family: var(--font-display);
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 2px 0;
}
.tf-pl-cal-day {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    font-family: var(--font-display);
    font-size: 11px;
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
}
.tf-pl-cal-day:hover { background: var(--bg-hover); }
.tf-pl-cal-day.empty { cursor: default; }
.tf-pl-cal-day.today {
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    font-weight: 600;
}
.tf-pl-cal-day.selected {
    background: var(--color-primary);
    color: #fff;
}
.tf-pl-cal-day.has-tasks::after {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--color-primary);
    position: absolute;
    bottom: 1px;
    left: 50%;
    transform: translateX(-50%);
}
.tf-pl-cal-day.selected.has-tasks::after { background: #fff; }
.tf-pl-cal-day.weekend { color: var(--text-muted); }

/* --- Смарт-списки --- */
.tf-pl-smart {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.tf-pl-smart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    border-left: 2px solid transparent;
}
.tf-pl-smart-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.tf-pl-smart-item.active {
    background: hsla(217, 91%, 60%, 0.08);
    border-left-color: var(--color-primary);
    color: var(--text-primary);
}
.tf-pl-smart-item .tf-pl-smart-icon { margin-right: 8px; opacity: 0.6; }
.tf-pl-smart-count {
    font-family: var(--font-display);
    font-size: 11px;
    flex: 0 0 auto;
    white-space: nowrap;
    min-width: 20px;
    text-align: right;
}
.tf-pl-smart-count.overdue { color: var(--color-danger); font-weight: 600; }

/* --- Фильтр по людям --- */
.tf-pl-users {
    padding: 10px;
    flex: 1;
}
.tf-pl-users-title {
    font-family: var(--font-display);
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}
.tf-pl-user-check {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}
.tf-pl-user-check input { margin: 0; cursor: pointer; }
.tf-pl-user-check:hover { color: var(--text-primary); }

/* --- Средняя панель: список задач --- */
.tf-pl-task-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}
.tf-pl-task-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    cursor: grab;
    transition: background 0.1s;
    position: relative;
}
.tf-pl-task-item:hover { background: var(--bg-hover); }
.tf-pl-task-item.dragging { opacity: 0.4; }
.tf-pl-task-item .tf-priority-bar {
    width: 3px;
    min-height: 30px;
    border-radius: 2px;
    flex-shrink: 0;
    align-self: stretch;
}
.tf-pl-task-item .tf-priority-bar.urgent { background: var(--color-danger); }
.tf-pl-task-item .tf-priority-bar.high { background: var(--color-warning); }
.tf-pl-task-item .tf-priority-bar.normal { background: var(--color-primary); }
.tf-pl-task-item .tf-priority-bar.low { background: var(--text-muted); }

.tf-pl-task-info { flex: 1; min-width: 0; }
.tf-pl-task-title {
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.tf-pl-task-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 10px;
    color: var(--text-muted);
}
.tf-pl-task-meta .overdue { color: var(--color-danger); }
.tf-pl-task-meta .tf-pl-deadline { white-space: nowrap; }
.tf-pl-task-meta .tf-pl-task-date { white-space: nowrap; opacity: 0.7; }

/* Urgent задачи — визуальное выделение */
.tf-pl-task-item.tf-pl-urgent {
    background: hsla(0, 70%, 50%, 0.08);
    border: 1px solid hsla(0, 70%, 50%, 0.25);
    border-left: none;
}
.tf-pl-task-item.tf-pl-urgent .tf-priority-bar {
    width: 4px;
}
.tf-pl-task-item.tf-pl-urgent .tf-pl-task-title {
    color: var(--color-danger);
    font-weight: 600;
}
html.light-theme .tf-pl-task-item.tf-pl-urgent {
    background: hsla(0, 70%, 50%, 0.06);
    border-color: hsla(0, 70%, 50%, 0.2);
}

.tf-pl-task-empty {
    padding: 30px 10px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* --- Правая панель: недельный вид --- */
.tf-pl-week-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.tf-pl-week-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.tf-pl-week-label {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
.tf-pl-week-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}
.tf-pl-week-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.tf-pl-week-grid-wrap {
    flex: 1;
    overflow: auto;
}
.tf-pl-week-cols {
    display: flex;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg-card);
}
.tf-pl-week-col-head {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    font-family: var(--font-display);
    font-size: 10px;
    color: var(--text-muted);
    border-left: 1px solid var(--border);
}
.tf-pl-week-col-head:first-child { border-left: none; width: 44px; flex: none; }
.tf-pl-week-col-head .day-num {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}
.tf-pl-week-col-head.today .day-num { color: var(--color-primary); }
.tf-pl-week-col-head.today { background: hsla(217, 91%, 60%, 0.05); }

.tf-pl-week-body {
    display: flex;
    position: relative;
}
.tf-pl-time-col {
    width: 44px;
    flex-shrink: 0;
}
.tf-pl-time-slot {
    height: 50px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0 4px;
    font-family: var(--font-display);
    font-size: 9px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    position: relative;
    cursor: context-menu;
}
.tf-pl-time-main { position: relative; z-index: 1; }
.tf-pl-time-sub {
    position: absolute;
    right: 4px;
    font-size: 8px;
    color: var(--text-muted);
    opacity: 0.5;
}
.tf-pl-day-col {
    flex: 1;
    border-left: 1px solid var(--border);
    position: relative;
}
.tf-pl-hour-cell {
    /* height задается inline из JS по HOUR_HEIGHT */
    border-bottom: 1px solid var(--border);
    position: relative;
}
.tf-pl-sub-line {
    position: absolute;
    left: 0;
    right: 0;
    border-bottom: 1px dashed hsla(220, 10%, 18%, 0.4);
    pointer-events: none;
}

/* Drop zone — высота и top задаются inline из JS */
.tf-pl-drop-zone {
    position: absolute;
    left: 0;
    right: 0;
}
.tf-pl-drop-zone.drag-over {
    background: hsla(217, 91%, 60%, 0.12);
    outline: 1px dashed var(--color-primary);
}

/* Блоки задач на таймлайне */
.tf-pl-task-block {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 3px;
    padding: 3px 5px;
    font-size: 10px;
    line-height: 1.2;
    overflow: hidden;
    cursor: pointer;
    border-left: 3px solid;
    z-index: 1;
}
.tf-pl-task-block:hover { z-index: 2; filter: brightness(1.1); }
.tf-pl-task-block.priority-urgent {
    border-left-color: var(--color-danger);
    background: hsla(0, 84%, 60%, 0.15);
    color: var(--text-primary);
}
.tf-pl-task-block.priority-high {
    border-left-color: var(--color-warning);
    background: hsla(38, 92%, 50%, 0.12);
    color: var(--text-primary);
}
.tf-pl-task-block.priority-normal {
    border-left-color: var(--color-primary);
    background: hsla(217, 91%, 60%, 0.12);
    color: var(--text-primary);
}
.tf-pl-task-block.priority-low {
    border-left-color: var(--text-muted);
    background: hsla(0, 0%, 50%, 0.08);
    color: var(--text-secondary);
}
.tf-pl-task-block-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tf-pl-task-block-time {
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 1px;
}
.tf-pl-task-block-label {
    font-size: 8px;
    color: var(--text-muted);
    margin-top: 1px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Inline создание задачи по клику --- */
.tf-pl-inline-wrap {
    position: absolute;
    left: 2px;
    right: 2px;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
}
.tf-pl-inline-input {
    width: 100%;
    height: 100%;
    padding: 3px 6px;
    border: 1.5px solid var(--color-primary);
    border-radius: 3px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 11px;
    outline: none;
    box-shadow: 0 0 0 2px hsla(217, 91%, 60%, 0.15);
}
.tf-pl-inline-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* --- Drag ghost для блоков задач --- */
.tf-pl-task-ghost {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    opacity: 0.85;
    border-radius: 3px;
    padding: 3px 5px;
    font-size: 10px;
    line-height: 1.2;
    background: var(--bg-card);
    border: 1.5px solid var(--color-primary);
    border-left: 3px solid var(--color-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

/* --- Блок в состоянии перетаскивания --- */
.tf-pl-block-dragging {
    opacity: 0.3 !important;
}

/* --- Resize handle — визуальный индикатор внизу блока задачи --- */
.tf-pl-resize-handle {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 8px;
    cursor: ns-resize;
    z-index: 3;
    border-radius: 0 0 3px 3px;
}
.tf-pl-resize-handle::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.15s;
}
.tf-pl-task-block:hover .tf-pl-resize-handle::after {
    opacity: 0.3;
}
/* Блок в состоянии resize */
.tf-pl-task-block.tf-pl-block-resizing {
    z-index: 10;
    outline: 1.5px dashed var(--color-primary);
    outline-offset: -1px;
}
.tf-pl-task-block.tf-pl-block-resizing .tf-pl-resize-handle::after {
    opacity: 0.7;
    background: var(--color-primary);
}
/* На прошлых днях — без resize */
.tf-pl-day-col.past .tf-pl-resize-handle {
    display: none;
}

/* --- Курсор grab для блоков задач --- */
.tf-pl-task-block {
    cursor: grab;
}
.tf-pl-task-block:active {
    cursor: grabbing;
}

/* --- Drop-zone hover при наведении (для inline-создания) --- */
.tf-pl-drop-zone {
    cursor: pointer;
    transition: background 0.1s;
}
.tf-pl-drop-zone:hover {
    background: hsla(217, 91%, 60%, 0.04);
}

/* --- Прошлые дни --- */
.tf-pl-day-col.past {
    background: hsla(0, 0%, 50%, 0.04);
}
.tf-pl-day-col.past .tf-pl-drop-zone {
    cursor: not-allowed;
}
.tf-pl-day-col.past .tf-pl-drop-zone:hover {
    background: hsla(0, 84%, 60%, 0.06);
}
.tf-pl-day-col.past .tf-pl-drop-zone.drag-over {
    background: hsla(0, 84%, 60%, 0.1);
}
.tf-pl-week-col-head.past {
    opacity: 0.5;
}

/* Линия "сейчас" */
.tf-pl-now-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-danger);
    z-index: 4;
    pointer-events: none;
}
.tf-pl-now-line::before {
    content: '';
    position: absolute;
    left: -3px;
    top: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-danger);
}

/* --- Выбор шага и вида: обертка + бейдж + dropdown --- */
.tf-pl-step-wrap,
.tf-pl-view-wrap {
    position: relative;
    display: inline-block;
}
.tf-pl-step-badge,
.tf-pl-view-badge {
    font-family: var(--font-display);
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 3px 10px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.tf-pl-step-badge:hover,
.tf-pl-view-badge:hover {
    background: var(--border);
    color: var(--text-primary);
}
.tf-pl-view-badge {
    color: var(--color-primary);
    font-weight: 600;
}
.tf-pl-step-dropdown,
.tf-pl-view-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 0;
    min-width: 120px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 50;
}
.tf-pl-step-dropdown.open,
.tf-pl-view-dropdown.open { display: block; }
.tf-pl-step-dropdown-title {
    padding: 5px 12px 3px;
    font-family: var(--font-display);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.tf-pl-step-option,
.tf-pl-view-option {
    padding: 5px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}
.tf-pl-step-option:hover,
.tf-pl-view-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.tf-pl-step-option.active,
.tf-pl-view-option.active {
    color: var(--color-primary);
    font-weight: 600;
}
.tf-pl-step-option.active::before,
.tf-pl-view-option.active::before {
    content: '\2713  ';
    font-size: 10px;
}

/* Индикатор пользователя в календаре */
.tf-pl-user-indicator {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    color: var(--color-primary);
    background: hsla(217, 91%, 60%, 0.1);
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
    margin-left: 6px;
}
.tf-pl-user-unscheduled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: var(--color-danger, hsl(0, 84%, 60%));
    border-radius: 9px;
    padding: 0 5px;
    margin-left: 4px;
}

/* Floating menu (ПКМ по шкале) */
.tf-pl-float-menu {
    position: fixed;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 0;
    min-width: 120px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* --- Месячный вид --- */
.tf-pl-month-grid {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: auto;
    padding: 0;
}
.tf-pl-month-header-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg-card);
}
.tf-pl-month-dow {
    text-align: center;
    padding: 6px 0;
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    border-left: 1px solid var(--border);
}
.tf-pl-month-dow:first-child { border-left: none; }
.tf-pl-month-body {
    flex: 1;
}
.tf-pl-month-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    min-height: 90px;
}
.tf-pl-month-cell {
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    padding: 4px;
    min-height: 90px;
    cursor: pointer;
    transition: background 0.1s;
    overflow: hidden;
}
.tf-pl-month-cell:first-child { border-left: none; }
.tf-pl-month-cell:hover { background: var(--bg-hover); }
.tf-pl-month-cell.empty {
    cursor: default;
    background: transparent;
}
.tf-pl-month-cell.today {
    background: hsla(217, 91%, 60%, 0.05);
}
.tf-pl-month-cell.today .tf-pl-month-day-num {
    color: var(--color-primary);
    font-weight: 700;
}
.tf-pl-month-cell.past {
    background: hsla(0, 0%, 50%, 0.03);
    opacity: 0.7;
}
.tf-pl-month-cell.weekend .tf-pl-month-day-num {
    color: var(--text-muted);
}
.tf-pl-month-day-num {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
}
.tf-pl-month-tasks {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.tf-pl-month-task {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 1px 3px;
    border-radius: 2px;
    font-size: 10px;
    line-height: 1.3;
    overflow: hidden;
    cursor: pointer;
}
.tf-pl-month-task:hover {
    background: hsla(217, 91%, 60%, 0.08);
}
.tf-pl-month-task-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tf-pl-month-task-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}
.tf-pl-month-task-time {
    flex: 0 0 auto;
    font-family: var(--font-display);
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
}
.tf-pl-month-more {
    font-size: 9px;
    color: var(--text-muted);
    padding: 1px 3px;
    font-style: italic;
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .tf-pl-left { display: none; }
    .tf-pl-handle:first-of-type { display: none; }
}
@media (max-width: 900px) {
    .tf-planner { flex-direction: column; }
    .tf-pl-middle,
    .tf-pl-right {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        max-height: 50vh;
    }
    .tf-pl-handle { display: none; }
}

/* === Task Popup (правый клик по задаче в планировщике) === */
.tf-task-popup {
    position: fixed;
    z-index: 200;
    width: 420px;
    max-height: 540px;
    background: var(--bg-card, hsl(220, 13%, 11%));
    border: 1px solid var(--border, hsl(220, 10%, 18%));
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: tf-popup-fadein 0.12s ease-out;
}
@keyframes tf-popup-fadein {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
.tf-task-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border, hsl(220, 10%, 18%));
    background: var(--bg-secondary, hsl(220, 15%, 10%));
    flex-shrink: 0;
}
.tf-task-popup-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary, hsl(0, 0%, 92%));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.tf-task-popup-close {
    background: none;
    border: none;
    color: var(--text-muted, hsl(0, 0%, 50%));
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    line-height: 1;
    flex: 0 0 auto;
}
.tf-task-popup-close:hover { color: var(--color-danger, hsl(0, 84%, 60%)); }
.tf-task-popup-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}
.tf-task-popup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.tf-task-popup-field {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 11px;
}
.tf-task-popup-field .tf-detail-label {
    flex: 0 0 auto;
    white-space: nowrap;
}
.tf-task-popup-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.tf-btn-private.tf-btn-active {
    background: hsla(45, 90%, 50%, 0.15);
    border-color: hsl(45, 90%, 50%);
    color: hsl(45, 90%, 50%);
}
.tf-btn-private.tf-btn-active:hover {
    background: hsla(45, 90%, 50%, 0.25);
}
.tf-task-popup-divider {
    border-top: 1px solid var(--border, hsl(220, 10%, 18%));
    margin: 2px 0;
}
.tf-task-popup-chat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, hsl(0, 0%, 50%));
}
/* Чат внутри popup — контейнер + высота + видимость текста */
#tf-popup-chat-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: visible;
}
.tf-task-popup .tf-chat-wrap {
    max-height: 220px;
    min-height: 80px;
    overflow-y: auto;
}
.tf-task-popup .tf-chat-msg {
    color: var(--text-primary, hsl(0, 0%, 92%)) !important;
    font-size: 12px;
}
.tf-task-popup .tf-chat-msg-text {
    color: var(--text-primary, hsl(0, 0%, 92%)) !important;
    word-break: break-word;
    white-space: pre-wrap;
}
html.light-theme .tf-task-popup .tf-chat-msg,
html.light-theme .tf-task-popup .tf-chat-msg-text {
    color: var(--text-primary, hsl(220, 20%, 12%)) !important;
}
.tf-task-popup .tf-chat-input {
    flex-shrink: 0;
}
/* Описание в popup — компактно */
.tf-task-popup-desc {
    font-size: 11px;
    color: var(--text-muted, hsl(0, 0%, 50%));
    white-space: pre-wrap;
    max-height: 60px;
    overflow: hidden;
    line-height: 1.4;
}
/* Light-тема */
html.light-theme .tf-task-popup {
    background: var(--bg-card, #fff);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
html.light-theme .tf-task-popup-header {
    background: var(--bg-secondary, hsl(220, 18%, 94%));
}
html.light-theme .tf-task-popup .tf-chat-wrap {
    background: var(--bg-primary, hsl(220, 20%, 97%));
    border-radius: 4px;
}
html.light-theme .tf-task-popup .tf-chat-outgoing {
    background: hsla(217, 91%, 60%, 0.1);
}
html.light-theme .tf-task-popup .tf-chat-incoming {
    background: hsla(0, 0%, 50%, 0.06);
}
html.light-theme .tf-task-popup .tf-chat-ai {
    background: hsla(142, 71%, 45%, 0.06);
}

/* ====== СЕЛЕКТОР ПОЛЬЗОВАТЕЛЯ (admin/founder/head) ====== */
.tf-pl-user-select-wrap {
    width: 100%;
}
.tf-pl-user-select {
    width: 100%;
    padding: 4px 6px;
    font-size: 12px;
    background: var(--card-bg, hsl(220, 10%, 10%));
    color: var(--text-primary, hsl(0, 0%, 92%));
    border: 1px solid var(--border-color, hsl(220, 10%, 18%));
    border-radius: 4px;
    cursor: pointer;
    outline: none;
}
.tf-pl-user-select:focus {
    border-color: var(--color-primary, hsl(217, 91%, 60%));
}
html.light-theme .tf-pl-user-select {
    background: hsl(220, 20%, 96%);
    color: hsl(220, 20%, 12%);
    border-color: hsl(220, 15%, 82%);
}

/* ====== READ-ONLY БАННЕР ====== */
.tf-pl-readonly-banner {
    background: hsl(217, 91%, 60%, 0.15);
    color: var(--color-primary, hsl(217, 91%, 60%));
    border: 1px solid hsl(217, 91%, 60%, 0.3);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 12px;
    text-align: center;
    margin-bottom: 6px;
}

/* ====== AI-ПОДСВЕТКА СВОБОДНЫХ СЛОТОВ ====== */
.tf-pl-drop-zone.ai-suggested {
    background: hsla(152, 69%, 40%, 0.1) !important;
    border: 1px dashed var(--ai-green, #10b981) !important;
    border-radius: 2px;
}
.tf-pl-drop-zone.ai-suggested::after {
    content: 'AI';
    position: absolute;
    top: 1px;
    right: 3px;
    font-size: 8px;
    color: var(--ai-green, #10b981);
    opacity: 0.7;
    pointer-events: none;
}

/* ====== WORKLOAD VIEW ====== */
.tf-pl-workload {
    padding: 10px;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.tf-pl-workload-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color, hsl(220, 10%, 18%));
    margin-bottom: 10px;
}
.tf-pl-workload-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tf-pl-workload-table {
    flex: 1;
    overflow-y: auto;
}
.tf-pl-wl-row {
    display: grid;
    grid-template-columns: 150px repeat(5, 1fr) 120px;
    gap: 4px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color, hsl(220, 10%, 18%));
}
.tf-pl-wl-row.tf-pl-wl-header-row {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, hsl(0, 0%, 50%));
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tf-pl-wl-cell {
    text-align: center;
    font-size: 12px;
}
.tf-pl-wl-name-cell {
    text-align: left;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tf-pl-wl-total-cell {
    font-weight: 600;
}
.tf-pl-wl-hours {
    display: block;
    font-size: 10px;
    color: var(--text-muted, hsl(0, 0%, 50%));
    margin-top: 2px;
}

/* Прогресс-бар загрузки */
.tf-pl-workload-bar {
    height: 8px;
    background: hsl(220, 10%, 15%);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
html.light-theme .tf-pl-workload-bar {
    background: hsl(220, 15%, 88%);
}
.tf-pl-workload-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.tf-pl-workload-bar.low .tf-pl-workload-fill {
    background: hsl(152, 69%, 40%); /* зеленый <50% */
}
.tf-pl-workload-bar.medium .tf-pl-workload-fill {
    background: hsl(45, 93%, 50%); /* желтый 50-80% */
}
.tf-pl-workload-bar.high .tf-pl-workload-fill {
    background: hsl(0, 84%, 60%); /* красный >80% */
}

/* --- Чекбоксы задач + кнопка авто-распределения --- */
.tf-pl-task-check {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.tf-pl-auto-schedule-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.tf-pl-auto-schedule-btn:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: hsla(217, 91%, 60%, 0.08);
}
.tf-pl-auto-schedule-btn.has-selection {
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.tf-pl-auto-schedule-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}
.tf-pl-auto-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    padding: 0 4px;
    margin-left: 2px;
}
