/* Дашборд задач. Вариант A: дерево слева + панель справа (выбор владельца
   10.10.2026 по мокапам). На телефоне дерево становится drill-down списком. */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { display: flex; flex-direction: column; min-height: 100%; }
.hidden { display: none !important; }
a { color: inherit; }

/* ── шапка ── */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg-side); position: sticky; top: 0; z-index: 5;
}
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top h1 { font: 600 20px/1.2 var(--font-serif); letter-spacing: -.01em; }
.back {
  display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 9px; color: var(--dim); text-decoration: none;
  border: 1px solid var(--border); background: var(--surface);
}
.back:hover { color: var(--text); }
.top-right { display: flex; align-items: center; gap: 10px; }
.synced { font-size: 12px; color: var(--dim); }
/* Источник не ответил — предупреждение, а не рядовая подпись. */
.stale-src { color: var(--warn, #c98a2b); }
.btn {
  font: 500 13px/1 inherit; padding: 9px 14px; border-radius: 9px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 0;
}
.btn:hover { background: var(--accent-hover); }
.btn[disabled] { opacity: .55; cursor: default; }

/* ── сводка: главный ответ на «что горит» ── */
.summary { display: flex; flex-direction: column; gap: 8px; padding: 14px 20px 0; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chips-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--dim);
  margin-right: 2px;
}
.chip {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 7px 12px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font: inherit; font-size: 13px; color: var(--dim); cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.chip.sm { padding: 5px 10px; font-size: 12px; background: var(--surface-2); }
.chip.waiting b, .chip.done b { color: var(--text); }
.chip.done { opacity: .75; }
.chip b { font: 600 15px/1 var(--font-serif); color: var(--text); }
.chip.overdue { border-color: rgba(179, 86, 77, .45); background: var(--err-bg); color: var(--err); }
.chip.overdue b { color: var(--err); }
.chip.soon { border-color: rgba(155, 125, 44, .4); background: rgba(155, 125, 44, .10); color: #8a6f27; }
.chip.soon b { color: #8a6f27; }
.chip.stale { border-color: var(--border); background: var(--surface-2); }
.chip.on_me b, .chip.total b { color: var(--text); }
/* Этап — единая шкала для всех источников. Крайние состояния приглушены:
   «Предстоит» ещё не работа, «Готово» уже не требует внимания. */
.chip.stage { background: var(--surface-2); }
.chip.stage.todo, .chip.stage.done { opacity: .8; }
.chip.stage.todo b, .chip.stage.done b { color: var(--dim); }

/* ── раскладка ── */
.body { display: grid; grid-template-columns: 320px 1fr; gap: 18px; padding: 16px 20px 32px; align-items: start; }
.tree {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; box-shadow: var(--shadow); position: sticky; top: 76px;
  max-height: calc(100vh - 100px); overflow: auto;
}

/* ── дерево ── */
.row {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; background: none; border-radius: 9px;
  color: inherit; font: inherit; cursor: pointer;
}
.row:hover { background: var(--surface-2); }
.row.on { background: var(--surface-2); }
.row.on .row-title { font-weight: 600; }
.row-root .row-title { font: 600 14px/1.3 var(--font-serif); }
.row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-dim .row-title { color: var(--dim); }
.chev { width: 14px; flex: 0 0 14px; color: var(--dim); transition: transform .15s; }
.chev.open { transform: rotate(90deg); }
.chev.none { visibility: hidden; }
.kids { margin-left: 14px; border-left: 1px solid var(--border); padding-left: 4px; }
.badge {
  flex: 0 0 auto; font: 600 11px/1 inherit; padding: 4px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--dim);
}
.badge.overdue { background: var(--err-bg); color: var(--err); }
.badge.soon { background: rgba(155, 125, 44, .14); color: #8a6f27; }
.badge.on_me { background: rgba(181, 83, 56, .12); color: var(--accent); }

/* ── панель проекта ── */
.panel { min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.crumbs { font-size: 12px; color: var(--dim); margin-bottom: 6px; }
.card h2 { font: 600 22px/1.25 var(--font-serif); letter-spacing: -.01em; margin-bottom: 14px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 18px; }
.meta div { min-width: 0; }
.meta dt { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); margin-bottom: 3px; }
.meta dd { font-size: 14px; overflow-wrap: anywhere; }
.meta a { color: var(--accent); text-decoration: none; }
.meta a:hover { text-decoration: underline; }

.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.link {
  font-size: 13px; color: var(--accent); text-decoration: none; padding: 6px 11px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.link:hover { border-color: var(--accent); }
.more { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.more > summary {
  cursor: pointer; font-size: 12px; color: var(--dim); list-style: none;
  display: inline-flex; align-items: center; gap: 5px;
}
.more > summary::after { content: "▾"; font-size: 10px; }
.more[open] > summary::after { content: "▴"; }
.more > summary::-webkit-details-marker { display: none; }
.more .meta { margin-top: 12px; }
.desc { margin-top: 12px; font-size: 13px; color: var(--dim); white-space: pre-line; }

.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 2px 8px; }
.list-head h3 { font: 600 15px/1.2 var(--font-serif); }
.list-head span { font-size: 12px; color: var(--dim); }

.task {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  margin-bottom: 8px; text-decoration: none; color: inherit;
}
.task:hover { border-color: var(--accent); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-sub { display: block; font-size: 12px; color: var(--dim); margin-top: 2px; }
.task-title { display: block; }
.task-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.pill { font: 500 11px/1 inherit; padding: 5px 8px; border-radius: 6px; background: var(--surface-2); color: var(--dim); white-space: nowrap; }
.pill.overdue { background: var(--err-bg); color: var(--err); font-weight: 600; }
.pill.soon { background: rgba(155, 125, 44, .14); color: #8a6f27; font-weight: 600; }
.pill.stale { background: var(--surface-2); color: var(--dim); }
.pill.src { background: transparent; border: 1px solid var(--border); }
.pill.stage { background: var(--surface-2); color: var(--text); font-weight: 600; }
.pill.stage.todo, .pill.stage.done { color: var(--dim); font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; background: var(--dim); }
.dot.overdue { background: var(--err); }
.dot.soon { background: #9b7d2c; }
.dot.ok { background: var(--ok); }
.dot.stale { background: var(--border); }

.empty { padding: 28px 20px; text-align: center; color: var(--dim); font-size: 14px; }
.err { margin: 0 20px 20px; padding: 12px 14px; border-radius: 10px; background: var(--err-bg); color: var(--err); font-size: 13px; }

/* ── телефон: drill-down вместо двух колонок ── */
@media (max-width: 760px) {
  .body { grid-template-columns: 1fr; gap: 0; padding: 12px 12px 28px; }
  .tree { position: static; max-height: none; box-shadow: none; }
  .summary { padding: 12px 12px 0; }
  /* Шапка в одну строку не влезает: отметка о синке наползала на заголовок. */
  .top { padding: 12px 14px; flex-wrap: wrap; row-gap: 8px; }
  .top-right { width: 100%; justify-content: space-between; }
  .synced { white-space: normal; }
  .chip.sm { font-size: 11px; padding: 4px 9px; }
  /* Три оси сводки в столбик съедали весь первый экран, и дерево уходило
     под сгиб. Каждая ось — одна строка с горизонтальной прокруткой. */
  .chips {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin: 0 -12px; padding: 0 12px;
  }
  .chips::-webkit-scrollbar { display: none; }
  .chips .chip { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; }
  .chips .chip b { font-size: 14px; }
  .chips-label { position: sticky; left: 0; }
  /* Узкий экран: подпись с путём до ветки длинная — пилюли уносим под неё,
     иначе заголовок задачи сжимается до «СЗ Перш…». */
  .task { flex-wrap: wrap; row-gap: 8px; }
  .task-main { flex: 1 1 calc(100% - 19px); }  /* точка (7px) + отступ (12px) */
  .task-right { width: 100%; justify-content: flex-start; }
  body.drilled .tree { display: none; }
  body:not(.drilled) .panel { display: none; }
  .panel-back {
    display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px;
    font-size: 13px; color: var(--dim); background: none; border: 0; cursor: pointer; padding: 4px 0;
  }
}
@media (min-width: 761px) { .panel-back { display: none; } }
