:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --author: #2563eb;      /* синий — автор */
  --assignee: #f97316;    /* оранжевый — исполнитель */
  --observer: #16a34a;    /* зелёный — наблюдатель */
  --white: #ffffff;
  --orange: #f97316;
  --red: #ef4444;
  --green: #22c55e;
}

* { box-sizing: border-box; }

/* Плавное масштабирование под разрешение монитора.
   Базовый размер шрифта тянется от 14px на узких экранах до 18px на
   широких (2K/4K); всё остальное выражено в px-фиксированных размерах, но
   ключевые блоки ниже заданы через clamp()/vw/rem и масштабируются вместе. */
html {
  font-size: clamp(14px, 0.55vw + 8px, 18px);
  height: 100%;
}

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);

  /* Раскладка «шапка — контент — подвал» на всю высоту окна.
     Благодаря этому подвал всегда прижат к низу, а не висит по центру. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--red); min-height: 18px; font-size: 14px; }

/* Пустой блок ошибки не держит лишнюю высоту */
.error:empty { min-height: 0; margin: 0; padding: 0; }

/* ================= ЛОГОТИП ================= */

.auth-logo {
  width: 480px;
  max-width: 78vw;
  height: auto;
  display: block;
  filter: drop-shadow(0 10px 30px rgba(56, 189, 248, .25));
  user-select: none;
  pointer-events: none;
}

.board-watermark {
  position: fixed;
  inset: 0;
  /* Логотип-водяной знак смещён ниже центра доски */
  background: url("/static/logo.png") center calc(50% + 260px) / min(58vw, 720px) no-repeat;
  opacity: 1;
  filter: none;
  pointer-events: none;
  z-index: 0;
  user-select: none;
}

/* ---------- Auth ---------- */
.auth-page {
  flex: 1 0 auto;            /* растягивается, прижимая подвал к низу */
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  gap: 24px;
  min-height: 0;             /* высоту задаёт body, а не 100vh */
}
.auth-card {
  background: var(--panel);
  padding: 32px;
  border-radius: 14px;
  width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.tabs { display: flex; gap: 8px; margin: 0 0 18px; }
.tab {
  flex: 1; padding: 8px; border: 1px solid #334155; border-radius: 8px;
  background: linear-gradient(180deg, #334155 0%, var(--panel-2) 100%);
  color: var(--muted); cursor: pointer;
  box-shadow: 0 2px 0 #1a2432, 0 3px 8px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .06);
  transition: transform .08s ease, box-shadow .12s ease, filter .12s ease;
}
.tab:hover:not(.active) { filter: brightness(1.12); transform: translateY(-1px); }
.tab:active { transform: translateY(2px); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .3); }
.tab.active {
  background: linear-gradient(180deg, #4fc3f7 0%, var(--accent) 55%, #0ea5e9 100%);
  color: #001018; font-weight: 600; border-color: #0b86bd;
  box-shadow: 0 2px 0 #0b6f9c, 0 4px 10px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.auth-form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, textarea, select {
  background: var(--panel-2); border: 1px solid #334155; border-radius: 8px;
  padding: 9px 11px; color: var(--text); font-size: 14px; font-family: inherit;
}
input:disabled, textarea:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
button {
  background: linear-gradient(180deg, #4fc3f7 0%, var(--accent) 55%, #0ea5e9 100%);
  color: #001018; border: 1px solid #0b86bd; border-radius: 8px;
  padding: 10px 14px; font-weight: 600; cursor: pointer; font-size: 14px;
  box-shadow:
    0 2px 0 #0b6f9c,
    0 4px 10px rgba(0, 0, 0, .35),
    inset 0 1px 0 rgba(255, 255, 255, .45);
  transition: transform .08s ease, box-shadow .12s ease, filter .12s ease, background .12s ease;
  transform: translateY(0);
}
button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow:
    0 3px 0 #0b6f9c,
    0 7px 16px rgba(0, 0, 0, .45),
    inset 0 1px 0 rgba(255, 255, 255, .55);
}
button:active:not(:disabled) {
  transform: translateY(2px);
  filter: brightness(.96);
  box-shadow:
    0 0 0 #0b6f9c,
    0 1px 3px rgba(0, 0, 0, .35),
    inset 0 2px 4px rgba(0, 0, 0, .25);
}
button:focus-visible {
  outline: none;
  box-shadow:
    0 2px 0 #0b6f9c,
    0 4px 10px rgba(0, 0, 0, .35),
    inset 0 1px 0 rgba(255, 255, 255, .45),
    0 0 0 3px rgba(56, 189, 248, .45);
}
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }

button.ghost {
  background: linear-gradient(180deg, #334155 0%, #273449 100%);
  color: var(--text); border: 1px solid #475569;
  box-shadow:
    0 2px 0 #1a2432,
    0 4px 10px rgba(0, 0, 0, .3),
    inset 0 1px 0 rgba(255, 255, 255, .08);
}
button.ghost:hover:not(:disabled) {
  filter: brightness(1.12);
  border-color: #64748b;
  transform: translateY(-1px);
  box-shadow:
    0 3px 0 #1a2432,
    0 7px 16px rgba(0, 0, 0, .4),
    inset 0 1px 0 rgba(255, 255, 255, .1);
}
button.ghost:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    0 0 0 #1a2432,
    0 1px 3px rgba(0, 0, 0, .3),
    inset 0 2px 4px rgba(0, 0, 0, .3);
}
button.danger { color: var(--red); border-color: var(--red); }

/* ---------- Topbar ---------- */
.topbar {
  flex: 0 0 auto;            /* шапка не растягивается */
  display: flex; justify-content: space-between; align-items: center;
  padding: clamp(10px, 1vw, 18px) clamp(14px, 1.6vw, 32px); background: var(--panel);
  border-bottom: 1px solid #1e293b; position: sticky; top: 0; z-index: 10;
}
.brand { font-size: clamp(18px, 1.2vw + 8px, 26px); font-weight: 700; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions a { text-decoration: none; padding: 8px 12px; border-radius: 8px; border: 1px solid #334155; color: var(--text); }

/* ---------- Board ---------- */
.board {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;            /* контент растягивается, подвал уходит вниз */
  display: flex; gap: clamp(12px, 1.2vw, 24px);
  padding: clamp(12px, 1.5vw, 28px); align-items: flex-start;
  overflow-x: auto;
  background: transparent;
}
.column {
  position: relative; z-index: 1;
  background: rgba(30, 41, 59, .75); border-radius: 12px;  /* прозрачны на 25% */
  /* Ширина колонки тянется с экраном: 260px на узких, до 420px на широких. */
  width: clamp(260px, 20vw, 420px);
  flex: 0 0 clamp(260px, 20vw, 420px);
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
.column-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: 15px;
}
.column-head .del {
  cursor: pointer; color: var(--muted);
  border: 1px solid transparent; background: transparent;
  width: 26px; height: 26px; padding: 0; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: none; transition: color .12s, background .12s, transform .08s, box-shadow .12s, border-color .12s;
}
.column-head .del:hover {
  color: var(--red); border-color: var(--red); background: rgba(239, 68, 68, .12);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(239, 68, 68, .25);
}
.column-head .del:active { transform: translateY(1px); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .3); }
.column-list { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }

/* ---------- Card ---------- */
.card-tile {
  position: relative;
  /* Фон карточки прозрачен на 30% (текст и рамка — непрозрачные) */
  background: rgba(39, 52, 73, .70); border-radius: 10px; padding: 10px 12px;
  border: 2px solid var(--white); cursor: grab;
  display: flex; flex-direction: column; gap: 7px;
  overflow: hidden;                 /* чтобы красная шапка не вылезала */
}
.card-tile.orange { border-color: var(--orange); }
.card-tile.red    { border-color: var(--red); }
.card-tile.green  { border-color: var(--green); }

/* Треугольник в правом нижнем углу (внутри цветной рамки) */
.card-tile::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 30px;
  height: 30px;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  border-bottom-right-radius: 8px;
  background: transparent;
  pointer-events: none;
}
.card-tile.role-author::after   { background: var(--author); }
.card-tile.role-assignee::after { background: var(--assignee); }
.card-tile.role-observer::after { background: var(--observer); }

/* Наблюдатель — только чтение: курсор и отсутствие перетаскивания */
.card-tile.role-observer { cursor: pointer; }
.card-tile.role-observer .subtask { cursor: default; }

.card-tile .title { font-weight: 600; font-size: 14px; }
.card-tile .desc { font-size: 12px; color: var(--muted); white-space: pre-wrap; }
.card-tile .deadline { font-size: 12px; color: var(--muted); }
.badges { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: 4px; }
.badge {
  font-size: 11px; padding: 3px 10px; border-radius: 999px; color: #fff;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  display: inline-block; width: fit-content;
}
.badge.author { background: var(--author); }
.badge.assignee { background: var(--assignee); }
.badge.observer { background: var(--observer); }
.add-card {
  border: 1px dashed #475569; background: rgba(39, 52, 73, .4); color: var(--muted);
  border-radius: 8px; padding: 8px; cursor: pointer; width: 100%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2), inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease, color .12s ease, background .12s ease;
}
.add-card:hover:not(:disabled) {
  color: var(--text); border-color: var(--accent); background: rgba(56, 189, 248, .12);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, .25), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.add-card:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .3);
}

/* ---------- Важность: красная шапка ---------- */
.card-tile .card-important {
  margin: -10px -12px 6px -12px;
  padding: 7px 12px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Прогресс-линия (под заголовком) ---------- */
.card-tile .progress-line {
  height: 4px;
  width: 100%;
  background: #334155;
  border-radius: 999px;
  overflow: hidden;
}
.card-tile .progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width .2s ease;
}

/* ---------- Подзадачи на карточке ---------- */
.card-tile .subtasks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}
.card-tile .subtask {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
}
.card-tile .subtask .subtask-check {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 2px solid #64748b;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: #fff;
  transition: background .15s, border-color .15s;
}
.card-tile .subtask .subtask-check.on {
  background: var(--green);
  border-color: var(--green);
}
.card-tile .subtask .subtask-title { color: var(--text); word-break: break-word; }
.card-tile .subtask.done .subtask-title {
  text-decoration: line-through;
  color: var(--muted);
}

/* ---------- Редактор подзадач в модалке ---------- */
#subtasks-editor { margin-top: 4px; }
.subtasks-edit { display: flex; flex-direction: column; gap: 8px; }
.subtask-edit-row { display: flex; gap: 8px; align-items: center; }
.subtask-edit-row input[type="text"] { flex: 1; }
.subtask-edit-row input[type="checkbox"] {
  width: 18px; height: 18px; flex: 0 0 18px; cursor: pointer;
}
.subtask-edit-row button { padding: 6px 10px; min-width: 38px; }

/* ---------- Наблюдатели в модалке ---------- */
#observers-editor { margin-top: 4px; display: flex; flex-direction: column; gap: 8px; }
.observers-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  /* Ровно ~4 строки чипов; дальше — вертикальная прокрутка,
     чтобы список из сотни пользователей не растягивал карточку. */
  max-height: 126px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: var(--panel-2);
}
.observers-list:empty { display: none; }
.observer-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .12s, border-color .12s, opacity .12s;
}
.observer-chip:hover { border-color: var(--observer); }
.observer-chip.selected {
  background: var(--observer);
  border-color: var(--observer);
  color: #fff;
}
.observer-chip.disabled {
  opacity: .4;
  cursor: not-allowed;
  text-decoration: line-through;
}
.observers-hint { font-size: 12px; color: var(--muted); }
.observers-hint b { color: var(--observer); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-card {
  background: var(--panel); padding: 24px; border-radius: 14px;
  width: clamp(360px, 40vw, 560px);
  max-height: 90vh; overflow-y: auto;
}
.modal-card form { display: flex; flex-direction: column; gap: 12px; }

/* Появление модалки */
.modal:not(.hidden) .modal-card { animation: modal-in .14s ease-out; }
@keyframes modal-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.row { display: flex; gap: 8px; }

/* Чекбокс важности + подпись в одну строку */
.important-row {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.important-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* ---------- Profile ---------- */
.profile {
  position: relative; z-index: 1;
  flex: 1 0 auto;            /* прижимает подвал к низу окна */
  padding: 24px; max-width: 640px;
}
.profile .card {
  background: var(--panel); border-radius: 12px; padding: 18px; margin-bottom: 16px;
}
.profile h2 { margin: 0 0 4px; font-size: 18px; }
.link-code {
  font-size: 26px; font-weight: 700; letter-spacing: 3px; color: var(--accent);
  margin: 6px 0 10px;
}
hr { border: none; border-top: 1px solid #334155; margin: 14px 0; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; }

/* Кнопка «Привязать» — опущена на 10px от поля ввода */
#btn-link {
  margin-top: 10px;
}

/* Кнопка «Сохранить изменения» (блок «Пользователи») */
#btn-u-save {
  margin-top: 10px;
  display: block;
}

/* ---------- Footer ---------- */
.footer {
  flex: 0 0 auto;            /* не растягивается */
  position: relative;
  z-index: 2;                /* выше водяного знака */
  padding: 14px 22px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);  /* непрозрачный — перекрывает watermark */
  border-top: 1px solid #1e293b;
}
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }


/* ================= Комментарии ================= */
/* Счётчик на плитке доски: 💬 N */
.card-tile .comments-count {
  align-self: flex-start;
  font-size: 12px;
  color: var(--muted);
  background: rgba(56, 189, 248, .12);
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 1px 8px;
}

#comments-box { display: flex; flex-direction: column; gap: 8px; }

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.comment-row {
  background: var(--panel-2);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
}
.comment-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 4px;
}
.comment-head b { color: var(--text); font-weight: 600; }
.comment-date { color: var(--muted); font-size: 11px; white-space: nowrap; }
.comment-text {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-add { display: flex; gap: 8px; align-items: flex-end; }
.comment-add textarea { flex: 1; resize: vertical; min-height: 46px; }
.comment-add button { flex: 0 0 auto; }


/* ==========================================================================
   ПРОЕКТЫ (projects.html)
   ========================================================================== */

.project-board {
  align-items: flex-start;
  flex-wrap: nowrap;
}

/* Системная колонка: удалить нельзя (нет крестика, есть замок) */
.column.system-column { border-top: 3px solid var(--accent); }
.column.system-column.is-done { border-top-color: var(--green); }

.column-head .col-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.column-head .col-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 1px 8px;
}
.column-head .col-lock {
  cursor: default;
  font-size: 13px;
  color: var(--muted);
  opacity: .8;
  user-select: none;
}

/* Карточка проекта — близнец .card-tile задачи */
.project-card {
  position: relative;
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px 12px;
  border: 2px solid var(--white);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
  overflow: hidden;
}
.project-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}
.project-card.is-important { border-color: var(--red); }
.project-card.is-done      { border-color: var(--green); }

.project-card .project-title {
  font-weight: 600;
  font-size: 14px;
  word-break: break-word;
}
.project-card .project-desc {
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.project-card .project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.project-card .project-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(56, 189, 248, .12);
  border: 1px solid #334155;
  color: var(--text);
  white-space: nowrap;
}
.project-card .card-important {
  margin: -10px -12px 6px -12px;
  padding: 7px 12px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.column-list.project-list { min-height: 46px; }

.project-empty {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 12px 6px;
  border: 1px dashed #475569;
  border-radius: 8px;
}

/* Drag-состояния Sortable */
.project-card.sortable-ghost {
  opacity: .45;
  border-style: dashed;
}
.project-card.sortable-drag {
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}


/* ==========================================================================
   ДОПОЛНЕНИЯ v=10
   ========================================================================== */

/* Просроченный дедлайн — заметно краснее обычного */
.card-tile .deadline.overdue {
  color: var(--red);
  font-weight: 600;
}

/* Тосты (используются во всех страницах) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 72px;
  transform: translate(-50%, 20px);
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 100;
  max-width: min(90vw, 460px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--red); color: #fecaca; }

/* Пока список пользователей грузится */
select:disabled { opacity: .6; cursor: not-allowed; }

/* Промежуточные и широкие экраны — растягиваем контент на всю ширину */
@media (min-width: 1600px) {
  .column {
    width: clamp(320px, 17vw, 460px);
    flex: 0 0 clamp(320px, 17vw, 460px);
  }
  .board { gap: clamp(16px, 1.4vw, 32px); }
}
@media (min-width: 2200px) {
  .column {
    width: clamp(360px, 15vw, 520px);
    flex: 0 0 clamp(360px, 15vw, 520px);
  }
}

/* Мобильная раскладка: колонки почти на всю ширину экрана */
@media (max-width: 760px) {
  .board {
    flex-wrap: nowrap;
    gap: 10px;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
  }
  .column,
  .column.system-column {
    flex: 0 0 84vw;
    width: 84vw;
    max-width: 84vw;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  .topbar .actions { flex-wrap: wrap; gap: 6px; }
  .auth-card { width: 92vw; padding: 20px; }
  .modal-card {
    width: calc(100vw - 24px);
    max-height: 90vh;
    overflow-y: auto;
    padding: 18px;
  }
  .profile { padding: 14px; }
  .row { flex-wrap: wrap; }
  .comment-add { flex-direction: column; align-items: stretch; }
}

@media (prefers-color-scheme: dark) {
  .card-tile .deadline.overdue { color: #f87171; }
}


/* ==========================================================================
   ПРОЕКТЫ v=16 — дерево задач, прогресс, чекбоксы
   ========================================================================== */

/* Прогресс на карточке проекта в колонке */
.project-card-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.project-card-progress-track {
  flex: 1;
  height: 6px;
  background: #334155;
  border-radius: 999px;
  overflow: hidden;
}
.project-card-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width .3s ease;
}
.project-card-progress-label {
  font-size: 11px;
  color: var(--muted);
  min-width: 32px;
  text-align: right;
}

/* Большая модалка проекта */
.modal-card.project-detail-card {
  width: clamp(420px, 72vw, 1100px);
  width: min(72vw, 1100px);
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.project-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.project-detail-head h2 { margin: 0 0 4px; }
.project-detail-head #detail-sub { display: flex; flex-wrap: wrap; gap: 6px; }
.project-detail-head #detail-close { flex: 0 0 auto; }

.project-chip.danger { border-color: var(--red); color: #fecaca; }

/* Линейный статус-бар вверху проекта */
.project-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}
.project-progress-track {
  flex: 1;
  height: 14px;
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 999px;
  overflow: hidden;
}
.project-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 999px;
  transition: width .35s ease;
}
.project-progress-fill.full { background: var(--green); }
.project-progress-label {
  font-weight: 700;
  font-size: 14px;
  min-width: 42px;
  text-align: right;
  color: var(--green);
}

.project-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
button.danger.solid {
  background: linear-gradient(180deg, #f87171 0%, var(--red) 55%, #dc2626 100%);
  color: #fff; border: 1px solid #b91c1c;
  box-shadow:
    0 2px 0 #991b1b,
    0 4px 10px rgba(0, 0, 0, .35),
    inset 0 1px 0 rgba(255, 255, 255, .35);
}
button.danger.solid:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow:
    0 3px 0 #991b1b,
    0 7px 16px rgba(0, 0, 0, .45),
    inset 0 1px 0 rgba(255, 255, 255, .4);
}
button.danger.solid:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    0 0 0 #991b1b,
    0 1px 3px rgba(0, 0, 0, .35),
    inset 0 2px 4px rgba(0, 0, 0, .3);
}

.project-detail-desc {
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.project-detail-desc:empty { display: none; }

/* Легенда дедлайнов */
.tree-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.tree-legend .lg {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid var(--white);
  vertical-align: middle;
  margin-right: 4px;
}
.tree-legend .lg.orange { border-color: var(--orange); }
.tree-legend .lg.red    { border-color: var(--red); }
.tree-legend .lg.green  { border-color: var(--green); }

/* ===================== ДЕРЕВО ===================== */
.project-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0;
}

.tree-node { position: relative; }

/* Линия-«уголок» от родителя к каждому ребёнку.
   Рисуется псевдоэлементом у контейнера детей; горизонтальная часть
   соединяется с вертикальным стволом родителя. */
.tree-children {
  position: relative;
  margin-left: 26px;
  padding-left: 26px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tree-children:not(.empty)::before {
  /* вертикальный ствол от родителя вниз до середины последнего */
  content: "";
  position: absolute;
  left: 0;
  top: -10px;
  bottom: 22px;
  width: 2px;
  background: #334155;
  border-radius: 2px;
}
.tree-children:not(.empty) > .tree-node::before {
  /* горизонтальная «ветка» к каждому ребёнку */
  content: "";
  position: absolute;
  left: -26px;
  top: 22px;
  width: 26px;
  height: 2px;
  background: #334155;
}
.tree-children:not(.empty) > .tree-node:last-child::after {
  /* закрываем ствол ниже последней развилки (плавный конец) */
  content: "";
  position: absolute;
  left: -26px;
  top: 24px;
  bottom: 0;
  width: 2px;
  background: var(--panel); /* маскируем лишний хвост ствола */
  z-index: 0;
}

/* Сама задача */
.tree-task {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(39, 52, 73, .78);
  border: 2px solid var(--white);
  border-radius: 10px;
  padding: 8px 12px;
  transition: border-color .15s ease, background .15s ease;
}
.tree-task.state-orange { border-color: var(--orange); }
.tree-task.state-red    { border-color: var(--red); }
.tree-task.state-green  { border-color: var(--green); }
.tree-task.mine         { box-shadow: 0 0 0 1px rgba(56, 189, 248, .35) inset; }
/* Родитель, чьи подзадачи выполнены: подсвечен, но галка не стоит —
   задача по сути не выполнялась, только «обрамляется» как выполненная. */
.tree-task.done-outline {
  border-color: var(--green);
  border-style: dashed;
  background: rgba(34, 197, 94, .10);
}
.tree-task.done-outline .tree-task-title { color: #a7f3d0; }

/* Чекбокс-кружок (как в подзадачах доски) */
.tree-check {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid #64748b;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .25);
  transition: background .15s, border-color .15s, transform .08s, box-shadow .12s;
}
.tree-check:hover:not(.disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35), 0 4px 10px rgba(56, 189, 248, .3);
}
.tree-check:active:not(.disabled) { transform: translateY(1px); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .35); }
.tree-check.on { background: var(--green); border-color: var(--green); }
.tree-check.disabled { cursor: not-allowed; opacity: .55; box-shadow: none; }

.tree-task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tree-task-title { font-size: 14px; font-weight: 600; word-break: break-word; }
.tree-task.done .tree-task-title { text-decoration: line-through; color: var(--muted); }
.tree-task-desc {
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 2px;
}
.tree-edit { color: var(--text); }

.tree-task-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.tree-task-meta .tree-assignee { color: var(--text); }
.tree-task-meta .tree-due.overdue { color: var(--red); }
.tree-task-meta button {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
}
.tree-comments-btn { color: var(--accent); }
.tree-addchild { color: var(--green); }
.tree-kids-badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.tree-kids-badge.done {
  background: rgba(34, 197, 94, 0.16);
  color: var(--green);
}

/* Блок комментариев задачи */
.tree-comments {
  margin: 8px 0 4px 32px;
  padding: 10px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: rgba(15, 23, 42, .65);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tree-comments-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

/* Форма добавления задачи/подзадачи */
.task-add-box {
  margin-top: 8px;
  padding: 12px;
  border: 1px dashed #475569;
  border-radius: 10px;
}
.task-add-box h3 { margin: 0 0 8px; font-size: 14px; }
.task-add-form { display: flex; flex-direction: column; gap: 8px; }
.task-add-form .row { flex-wrap: wrap; }
.task-add-form .assignee-select { flex: 1 1 160px; }
.task-add-form input[type="datetime-local"] { flex: 1 1 180px; }

/* ============ Проекты в профиле ============ */
.profile-projects { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.profile-project-row {
  background: var(--panel-2);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ppr-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ppr-title { font-weight: 600; word-break: break-word; }
.ppr-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ppr-bar { display: flex; align-items: center; gap: 8px; }
.ppr-bar-track {
  flex: 1; height: 6px; background: #0b1220; border-radius: 999px; overflow: hidden;
}
.ppr-bar-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width .3s; }
.ppr-bar-label { font-size: 11px; color: var(--muted); min-width: 32px; text-align: right; }
.ppr-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.ppr-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ppr-actions button { padding: 6px 12px; font-size: 12px; }
.ppr-members { margin-top: 4px; }
.ppr-members-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ppr-member-chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--panel); border: 1px solid #334155; color: var(--text);
}
.profile-subhead { font-size: 15px; margin: 4px 0 0; }
