/* Gantt Matter — оформление. Светлая и тёмная темы, мобильная раскладка. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e3e6ea;
  --border-strong: #cdd3da;
  --text: #16191d;
  --text-dim: #666e79;
  --text-faint: #949ba4;
  --accent: #3b62d9;
  --accent-soft: #eaefff;
  --accent-text: #ffffff;
  --bar: #5b82f0;
  --bar-done: #2f4fb8;
  --summary: #3d4550;
  --milestone: #e0932a;
  --critical: #d8453c;
  --critical-soft: #fdecea;
  --off: #eef0f3;
  --off-holiday: #fbeeee;
  --today: #e0563f;
  --ok: #1f9254;
  --warn: #b5730d;
  --shadow: 0 1px 2px rgba(16, 20, 26, .06), 0 4px 14px rgba(16, 20, 26, .07);
  --shadow-lg: 0 10px 40px rgba(16, 20, 26, .16);
  --radius: 10px;
  --radius-sm: 7px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

:root[data-theme='dark'] {
  --bg: #14171b;
  --surface: #1b1f24;
  --surface-2: #22272e;
  --border: #2c323a;
  --border-strong: #3c444e;
  --text: #e8ebee;
  --text-dim: #9aa4b0;
  --text-faint: #6d7783;
  --accent: #6b8cf5;
  --accent-soft: #232c46;
  --accent-text: #0d1017;
  --bar: #5b82f0;
  --bar-done: #93b0ff;
  --summary: #b7c0cc;
  --milestone: #e0a33f;
  --critical: #ef6a60;
  --critical-soft: #35211f;
  --off: #1f242a;
  --off-holiday: #2a2022;
  --today: #ef6a52;
  --ok: #3ec27a;
  --warn: #e0a33f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
/* Атрибут hidden должен работать и на кнопках: у них свой display,
   который иначе перебивает правило браузера */
[hidden] { display: none !important; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  position: fixed; inset: 0;      /* никакой прокрутки самой страницы */
  width: 100%;
}
h1, h2, h3 { margin: 0; font-weight: 620; letter-spacing: -.01em; }
h1 { font-size: 21px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
a { color: var(--accent); }
input, select, textarea, button { font: inherit; color: inherit; }

/* ── Элементы управления ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background .12s, border-color .12s, transform .06s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { color: var(--critical); border-color: var(--border-strong); }
.btn--danger:hover { background: var(--critical-soft); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn--icon { width: 36px; padding: 0; }

.field { display: block; margin-bottom: 14px; }
.field__label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 5px; font-weight: 500; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; padding: 9px 11px; min-height: 76px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.select { appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
}
.chip--org { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip--ok { color: var(--ok); }
.chip--warn { color: var(--warn); }
.chip--danger { color: var(--critical); }

.note { font-size: 12.5px; color: var(--text-dim); }
.error {
  background: var(--critical-soft); color: var(--critical);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px;
}
.empty { text-align: center; padding: 56px 20px; color: var(--text-dim); }
.empty h3 { margin-bottom: 6px; color: var(--text); }

/* ── Каркас приложения ───────────────────────────────────────────────────── */

/* Высота ровно по экрану, с учётом «чёлки» и полосы жестов на айфоне.
   Без этого в ярлыке с рабочего стола низ уезжает под системную полосу,
   а страница начинает пружинить вместо прокрутки. */
.app {
  display: flex; flex-direction: column;
  /* body закреплён (position: fixed; inset: 0), поэтому 100% — это ровно
     видимая область. -webkit-fill-available здесь давал неверную высоту. */
  height: 100%;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  overflow: hidden;
}

.topbar {
  display: flex; align-items: center; gap: 10px;
  height: 54px; padding: 0 14px; flex: none;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar__brand { display: flex; align-items: center; gap: 9px; font-weight: 640; letter-spacing: -.02em; }
.topbar__logo {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  background: linear-gradient(135deg, var(--accent), #7d5bf0);
  position: relative; overflow: hidden;
}
.topbar__logo::after {
  content: ''; position: absolute; left: 4px; top: 7px; width: 13px; height: 3px;
  border-radius: 2px; background: #fff; box-shadow: 0 5px 0 rgba(255,255,255,.75);
}
.topbar__spacer { flex: 1; }
.topbar__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__user { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--critical); color: #fff; font-size: 11px; font-weight: 600;
  display: inline-grid; place-items: center;
}

.main { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; }
.page { max-width: 1080px; margin: 0 auto; padding: 22px 16px 60px; }
.page__head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page__head h1 { flex: 1; min-width: 200px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card__head {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card__body { padding: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 13px; border: none; background: none; cursor: pointer;
  color: var(--text-dim); font-weight: 500; border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 550; color: var(--text-dim); font-size: 12px;
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }
.table__actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Вход ────────────────────────────────────────────────────────────────── */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth__box { width: 100%; max-width: 380px; }
.auth__logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; font-size: 18px; font-weight: 650; }
.auth__switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-dim); }
.auth__switch button { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 500; }

/* ── Список досок ────────────────────────────────────────────────────────── */

.boards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.bcard {
  display: block; text-align: left; width: 100%; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px; box-shadow: var(--shadow); transition: border-color .12s, transform .08s;
}
.bcard:hover { border-color: var(--accent); transform: translateY(-1px); }
.bcard__title { font-weight: 600; margin-bottom: 5px; }
.bcard__meta { font-size: 12.5px; color: var(--text-dim); margin-bottom: 11px; }
.bcard__foot { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.group-title { margin: 26px 0 12px; display: flex; align-items: center; gap: 9px; }
.group-title h2 { font-size: 15px; }
.group-title .note { font-weight: 400; }

/* ── Экран доски ─────────────────────────────────────────────────────────── */

.board { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.board__bar {
  display: flex; align-items: center; gap: 7px; padding: 8px 12px; flex: none;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.board__bar::-webkit-scrollbar { display: none; }
.board__bar > * { flex: none; }
.board__bar .spacer { flex: 1 1 auto; min-width: 4px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  height: 34px; padding: 0 11px; flex: none; border: none; background: var(--surface);
  cursor: pointer; color: var(--text-dim); font-size: 13px; white-space: nowrap;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }

/* ── Диаграмма ───────────────────────────────────────────────────────────── */

.gantt { position: relative; flex: 1; min-height: 0; background: var(--surface); }
.gantt__scroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; }
.gantt__inner {
  display: grid;
  grid-template-columns: var(--left-w) var(--chart-w);
  grid-template-rows: auto 1fr;
  width: max-content; min-width: 100%; min-height: 100%;
}
.gantt__corner {
  position: sticky; left: 0; top: 0; z-index: 5;
  background: var(--surface); border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}
.gantt__headright {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface); border-bottom: 1px solid var(--border-strong);
}
.gantt__left {
  position: sticky; left: 0; z-index: 2; overflow: visible;
  background: var(--surface); border-right: 1px solid var(--border-strong);
}
.gantt__right { position: relative; }
.gantt.is-dragging { cursor: grabbing; user-select: none; }
.gantt.is-dragging .gantt__scroll { scroll-behavior: auto; }

.gantt__headtitle {
  height: 100%; display: flex; align-items: flex-end; padding: 0 12px 7px;
  font-size: 12px; font-weight: 550; color: var(--text-dim);
}
.ghead { position: relative; height: 52px; }
.ghead__row { position: absolute; left: 0; right: 0; }
.ghead__row--major { top: 0; height: 26px; }
.ghead__row--minor { top: 26px; height: 26px; }
.ghead__cell {
  position: absolute; top: 0; height: 26px; display: flex; align-items: center;
  font-size: 12px; font-weight: 550; color: var(--text);
  border-left: 1px solid var(--border); overflow: hidden; white-space: nowrap;
}
.ghead__label { padding-left: 8px; will-change: transform; }
.ghead__day {
  position: absolute; top: 0; height: 26px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-left: 1px solid var(--border); font-size: 10.5px; color: var(--text-dim);
  overflow: hidden;
}
.ghead__day.is-off { background: var(--off); color: var(--text-faint); }
.ghead__day.is-today { background: var(--accent); color: #fff; font-weight: 600; }
.ghead__day.is-today .ghead__dwd { color: rgba(255,255,255,.8); }
.ghead__dnum { font-size: 11.5px; line-height: 1.05; color: var(--text); font-weight: 500; }
.ghead__day.is-off .ghead__dnum { color: var(--text-faint); }
.ghead__day.is-today .ghead__dnum { color: #fff; }
.ghead__dwd { font-size: 9px; line-height: 1.1; text-transform: uppercase; letter-spacing: .02em; }

.grow {
  display: flex; align-items: center; gap: 2px; height: var(--row-h);
  padding-left: calc(6px + var(--depth) * 15px); padding-right: 4px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  -webkit-tap-highlight-color: transparent; position: relative;
}
.grow__color {
  width: 3px; height: 62%; border-radius: 2px; flex: none; margin-right: 4px;
  background: transparent;
}
.grow__color.is-set { box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.grow__more {
  width: 22px; height: 22px; flex: none; border-radius: 5px;
  display: grid; place-items: center; color: var(--text-faint);
  font-size: 15px; line-height: 1; opacity: 0; transition: opacity .1s, background .1s;
}
.grow:hover .grow__more, .grow.is-selected .grow__more { opacity: 1; }
.grow__more:hover { background: var(--border); color: var(--text); }
.grow__input {
  width: 100%; height: 24px; padding: 0 5px; font-size: 13px;
  border: 1px solid var(--accent); border-radius: 5px; background: var(--surface);
  outline: none; box-shadow: 0 0 0 3px var(--accent-soft);
}
.gantt.is-rowdrag { cursor: grabbing; user-select: none; }
.gantt.is-rowdrag .grow { cursor: grabbing; }
.grow.is-ghost { opacity: .4; }
.gantt__dropline {
  position: absolute; height: 2px; right: 6px; z-index: 6; pointer-events: none;
  background: var(--accent); border-radius: 2px;
}
.gantt__dropline::before {
  content: ''; position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}
/* Подсказка «куда попадёт»: иначе непонятно, станет задача подзадачей или нет */
.gantt__dropline::after {
  content: attr(data-hint); position: absolute; left: 10px; top: -9px;
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 500;
  padding: 1px 7px; border-radius: 9px; white-space: nowrap;
}
.grow:hover { background: var(--surface-2); }
.grow.is-selected { background: var(--accent-soft); }
.grow__twist {
  width: 17px; flex: none; text-align: center; color: var(--text-faint); font-size: 10px;
}
.grow__twist.is-active { cursor: pointer; color: var(--text-dim); }
.grow__text { flex: 1; min-width: 0; }
.grow__name {
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25;
}
.grow.is-summary .grow__name { font-weight: 600; }
/* Название и кружки исполнителей в одну строку: название ужимается, кружки — нет */
.grow__nameline { display: flex; align-items: center; gap: 5px; min-width: 0; }
.grow__nameline .grow__name { min-width: 0; }
.grow__who { display: flex; gap: 2px; flex: none; }
.grow__dot {
  width: 17px; height: 17px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 8.5px; font-weight: 600; letter-spacing: .2px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--border);
}
.grow__dot--rest { background: var(--surface-2); color: var(--text-dim); }
.grow__meta { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; }
.grow__right { display: flex; gap: 6px; align-items: center; flex: none; }
.grow__dur { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; }
.grow__pct { font-size: 10.5px; color: var(--ok); font-weight: 600; }

.gchart { display: block; }
.gchart .off { fill: var(--off); }
.gchart .off--holiday { fill: var(--off-holiday); }
.gchart .gridline { stroke: var(--border); stroke-width: 1; opacity: .55; }
.gchart .gridline--month { stroke: var(--border-strong); opacity: .9; }
.gchart .gridline--row { stroke: var(--border); opacity: .8; }
.gchart .todayline { stroke: var(--today); stroke-width: 2; stroke-dasharray: 4 3; opacity: .85; }

.bar__body { fill: var(--bar); }
.bar__done { fill: var(--bar-done); }
.bar__done--tinted { filter: brightness(.68) saturate(1.15); }
.bar.is-critical .bar__body { fill: var(--critical); }
.bar.is-critical .bar__done { filter: brightness(.75); }
.bar.is-conflict .bar__body { stroke: var(--warn); stroke-width: 2; stroke-dasharray: 3 2; }
.bar.is-selected .bar__body { stroke: var(--text); stroke-width: 2; }
.bar .summary { fill: var(--summary); }
.bar .milestone { fill: var(--milestone); stroke: var(--surface); stroke-width: 1.5; }
.bar .baseline { fill: var(--text-faint); opacity: .45; }
.bar__label { fill: var(--text-dim); font-size: 11.5px; font-family: var(--font); pointer-events: none; }
/* Подпись вехи — ромб сам по себе ничего не сообщает */
.bar__label--ms { fill: var(--text); font-weight: 600; font-size: 11px; }
.bar__grip { fill: transparent; cursor: ew-resize; }
.bar__link { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.5; cursor: crosshair; opacity: 0; }
.bar:hover .bar__link { opacity: 1; }
.bar:hover .bar__body { filter: brightness(1.08); }
.gantt__right .bar { cursor: pointer; }

.link { fill: none; stroke: var(--text-faint); stroke-width: 1.4; opacity: .8; }
.link--critical { stroke: var(--critical); opacity: 1; stroke-width: 1.8; }
.arrowhead { fill: var(--text-faint); }
.arrowhead--crit { fill: var(--critical); }
.ghostlink { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 3; }

/* Граница между колонкой задач и диаграммой — её тянут мышью или пальцем */
.gantt__resizer {
  position: absolute; top: 0; bottom: 0; width: 7px; z-index: 6;
  cursor: col-resize; touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.gantt__resizer::before {
  content: ''; position: absolute; left: 2px; top: 0; bottom: 0; width: 3px;
  background: transparent; transition: background .12s;
}
.gantt__resizer:hover::before { background: var(--accent); }
.gantt.is-resizing { user-select: none; cursor: col-resize; }
.gantt.is-resizing .gantt__resizer::before { background: var(--accent); }
/* Маленькая «ручка» посередине — чтобы границу вообще заметили */
.gantt__resizer::after {
  content: ''; position: absolute; left: 0; top: 50%; margin-top: -14px;
  width: 7px; height: 28px; border-radius: 4px;
  background: var(--border-strong); opacity: 0; transition: opacity .12s;
}
.gantt__resizer:hover::after, .gantt.is-resizing .gantt__resizer::after { opacity: 1; }

.gantt__tip {
  position: absolute; z-index: 20; pointer-events: none; max-width: 300px;
  background: var(--text); color: var(--bg); padding: 7px 10px;
  border-radius: var(--radius-sm); font-size: 12px; line-height: 1.45;
  box-shadow: var(--shadow-lg);
}
/* В тёмной теме подсказка не инвертируется: светлая плашка резала бы глаз.
   Цвета заданы явно — от переменных темы здесь только тень. */
:root[data-theme='dark'] .gantt__tip { background: #2f3640; color: #eef1f4; }

/* ── Панель задачи ───────────────────────────────────────────────────────── */

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(12, 15, 20, .35);
  z-index: 40; animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0 } }
.sheet {
  position: fixed; z-index: 41; background: var(--surface);
  display: flex; flex-direction: column;
  right: 0; top: 0; bottom: 0; width: min(420px, 100%);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: slide-in .18s ease;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: .5 } }
.sheet__head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); flex: none;
}
.sheet__head h3 { flex: 1; min-width: 0; }
.sheet__body { flex: 1; overflow: auto; padding: 16px; }
.sheet__foot {
  padding: 11px 14px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex: none; align-items: center;
}
.sheet__status { font-size: 12.5px; color: var(--text-dim); transition: color .15s; }
.sheet__status.is-ok { color: var(--ok); }
.sheet__status.is-error { color: var(--critical); }
.sheet__grip { display: none; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12, 15, 20, .4);
  z-index: 50; display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: min(460px, 100%); max-height: 88dvh; display: flex; flex-direction: column;
}
.modal__head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.modal__head h3 { flex: 1; }
.modal__body { padding: 16px; overflow: auto; }
.modal__foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 13px; z-index: 90; box-shadow: var(--shadow-lg); animation: fade .15s;
  max-width: calc(100% - 32px); text-align: center;
}
.toast--error { background: var(--critical); color: #fff; }

.linkrow, .assignrow {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.linkrow:last-child, .assignrow:last-child { border-bottom: none; }
.linkrow__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress-wrap input[type=range] { flex: 1; accent-color: var(--accent); }
.progress-wrap span { width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); padding: 8px 12px; }
.legend i { display: inline-block; width: 12px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* ── Мобильная раскладка ─────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .topbar { height: 50px; padding: 0 10px; gap: 4px; flex: none; }
  .topbar .topbar__hide { display: none; }
  .topbar__title { font-size: 13.5px; max-width: 34vw; }
  .grow { padding-left: calc(5px + var(--depth) * 11px); }
  .grow__name { font-size: 12.5px; }
  .grow__meta { font-size: 10px; }
  .ghead__day { font-size: 10px; }
  .topbar__brand span { display: none; }
  .page { padding: 16px 12px 60px; }
  .boards { grid-template-columns: 1fr; }
  .sheet {
    left: 0; right: 0; top: auto; bottom: 0; width: 100%;
    max-height: min(86dvh, calc(100dvh - 40px));
    border-radius: 16px 16px 0 0; border-left: none;
    padding-bottom: env(safe-area-inset-bottom);
    animation: slide-up .2s ease;
  }
  @keyframes slide-up { from { transform: translateY(100%) } }
  .sheet__grip {
    display: block; width: 38px; height: 4px; border-radius: 2px;
    background: var(--border-strong); margin: 8px auto 0; flex: none;
  }
  .sheet__body { padding: 14px; }
  .table--wide { display: block; overflow-x: auto; white-space: nowrap; }
  .board__bar {
    padding: 7px 10px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .board__bar::-webkit-scrollbar { display: none; }
  .board__bar > * { flex: none; }
  .board__bar .spacer { display: none; }
  .btn { height: 38px; }
  .seg button { height: 36px; }
}

@media (pointer: coarse) {
  .bar__grip, .bar__link { display: none; }
  /* На телефоне границу надо ещё суметь поймать пальцем */
  .gantt__resizer { width: 20px; margin-left: -7px; }
  .gantt__resizer::after {
    opacity: 1; left: 5px; width: 9px; height: 34px; margin-top: -17px;
    background: var(--border-strong);
    box-shadow: 0 0 0 2px var(--surface);
  }
  .grow__more { opacity: 1; width: 26px; height: 26px; }
  .grow { padding-right: 6px; }
}

@media print {
  .topbar, .board__bar, .sheet, .modal-backdrop { display: none !important; }
  .gantt__scroll { position: static; overflow: visible; }
}

/* ── Палитра цветов ──────────────────────────────────────────────────────── */
.palette { display: flex; gap: 7px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; flex: none;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
  transition: transform .08s; padding: 0;
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { border-color: var(--text); }
.swatch--none { background: var(--surface-2); position: relative; }
.swatch--none::after {
  content: ''; position: absolute; inset: 6px 3px; border-top: 2px solid var(--critical);
  transform: rotate(-45deg); transform-origin: center;
}

/* ── Канбан ──────────────────────────────────────────────────────────────── */

.kanban {
  display: flex; gap: 12px; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden; padding: 2px 2px 12px;
  -webkit-overflow-scrolling: touch;
}
.kcol {
  flex: 0 0 268px; max-width: 268px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
  max-height: calc(100vh - 210px);
}
.kcol.is-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.kcol__head {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.kcol__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.kcol__name { font-size: 13px; font-weight: 600; flex: 1; }
.kcol__count {
  font-size: 11px; color: var(--text-dim); background: var(--surface);
  border-radius: 20px; padding: 1px 8px; border: 1px solid var(--border);
}
/* Пустая колонка тоже должна быть крупной мишенью для перетаскивания */
.kcol__body { padding: 9px; display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; min-height: 180px; }
.kcol__empty { font-size: 12px; color: var(--text-faint); text-align: center; padding: 14px 0; }

.kcard {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--kcard-color, var(--bar));
  border-radius: var(--radius-sm); padding: 9px 10px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .1s, box-shadow .1s;
}
.kcard:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.kcard.is-dragging { opacity: .35; }
/* Копия карточки, которая едет за курсором или пальцем */
.kcard--ghost {
  position: fixed; z-index: 60; pointer-events: none; margin: 0;
  box-shadow: var(--shadow-lg); transform: rotate(1.5deg);
  opacity: .95;
}
/* Палец по карточке тянет её вбок, а вверх-вниз по-прежнему листает колонку */
.kcard { touch-action: pan-y; }
.kcard__stage { font-size: 10.5px; color: var(--text-faint); margin-bottom: 2px; }
.kcard__name { font-size: 13px; line-height: 1.3; }
.kcard__meta { display: flex; align-items: center; gap: 7px; margin-top: 8px; flex-wrap: wrap; }
.kcard__date { font-size: 10.5px; color: var(--text-dim); }
.kcard__date.is-late { color: var(--critical); font-weight: 600; }
.kcard__pct { font-size: 10.5px; color: var(--ok); font-weight: 600; }
.kcard__flag {
  font-size: 10px; color: var(--warn); border: 1px solid var(--warn);
  border-radius: 20px; padding: 0 6px;
}
.kcard__who { display: flex; gap: 2px; margin-left: auto; }
.kcard__dot {
  width: 19px; height: 19px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--border);
}
.kcard__dot--rest { background: var(--surface-2); color: var(--text-dim); }

@media (max-width: 760px) {
  .kcol { flex-basis: 78vw; max-width: 78vw; max-height: none; }
}

/* ── Чек-лист и обсуждение в карточке задачи ─────────────────────────────── */

.ckbar { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-bottom: 10px; }
.ckbar__fill { height: 100%; background: var(--ok); transition: width .2s; }
.ckrow {
  display: flex; align-items: center; gap: 9px; padding: 5px 0;
  border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.ckrow:last-of-type { border-bottom: none; }
.ckrow.is-done span { color: var(--text-faint); text-decoration: line-through; }

.cmt { display: flex; gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.cmt:last-of-type { border-bottom: none; }
.cmt__head { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; }
.cmt__body { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; margin-top: 2px; }

/* ── Ресурсы и показатели ────────────────────────────────────────────────── */

.loadbar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.loadbar__fill { height: 100%; background: var(--accent); transition: width .25s; }
.loadbar__fill.is-over { background: var(--critical); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.tile__num { font-size: 26px; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; }

/* ── Файлы, история, уведомления ─────────────────────────────────────────── */

.filerow {
  display: flex; align-items: center; gap: 9px; padding: 6px 0;
  border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.filerow:last-of-type { border-bottom: none; }
.filerow__icon {
  flex: none; font-size: 9px; font-weight: 700; letter-spacing: .3px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 4px; padding: 3px 5px; min-width: 38px; text-align: center;
}
.filerow__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.histrow {
  display: flex; gap: 9px; padding: 5px 0; font-size: 12.5px;
  border-bottom: 1px solid var(--border);
}
.histrow:last-of-type { border-bottom: none; }

.notif {
  display: flex; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.notif:last-of-type { border-bottom: none; }
.notif.is-new { border-left: 3px solid var(--accent); padding-left: 9px; margin-left: -12px; }

/* ── Редактор колонок ────────────────────────────────────────────────────── */

.modal--wide { max-width: 560px; }
.colrow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.colrow .input { flex: 1; min-width: 0; }
.coldot {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer; padding: 0;
}
.select--sm { height: 30px; font-size: 13px; width: auto; min-width: 165px; padding: 0 26px 0 9px;
  background-position: calc(100% - 13px) 13px, calc(100% - 8px) 13px; }

/* ── Меню для узкого экрана ──────────────────────────────────────────────── */

.topbar__menu { display: none; }
.menurow {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 13px 4px; border: none; background: none; cursor: pointer;
  border-bottom: 1px solid var(--border); font-size: 15px;
}
.menurow:last-of-type { border-bottom: none; }
.menurow:active { background: var(--surface-2); }

@media (max-width: 760px) {
  .topbar__menu { display: inline-flex; }
  .topbar__user .btn { display: none; }        /* «Выйти» переехало в меню */
  .modal { max-height: calc(100dvh - 32px); }
  .modal__body { max-height: 66dvh; overflow: auto; -webkit-overflow-scrolling: touch; }
  .select--sm { min-width: 140px; }
}

/* ── ERP: проекты, отпуска, лёгкая версия ─────────────────────────────────── */

/* Полоса готовности на карточке доски в проекте */
.progressline {
  height: 4px; border-radius: 2px; background: var(--surface-2);
  margin: 8px 0 2px; overflow: hidden;
}
.progressline__fill { height: 100%; background: var(--ok); border-radius: 2px; }

/* Кружок исполнителя-сущности (лёгкая версия): просто цвет, имя — в легенде */
.grow__pdot {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}

/* Легенда исполнителей под диаграммой */
.legendbar {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  padding: 8px 14px; border-top: 1px solid var(--border);
  background: var(--surface); font-size: 12.5px; color: var(--text-dim);
}
.legendbar__item { display: inline-flex; gap: 6px; align-items: center; }
.legendbar__dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* Статистика отпуска */
.vstats { display: flex; gap: 26px; flex-wrap: wrap; }
.vstat__value { font-size: 21px; font-weight: 650; letter-spacing: -.3px; }
.vstat__value.is-neg { color: var(--critical); }
.vstat__value.is-pos { color: var(--ok); }
.vstat__label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* Табель отпусков: сетка год × сотрудники */
.vgrid { border-collapse: collapse; font-size: 11px; width: 100%; }
.vgrid th, .vgrid td { border: 1px solid var(--border); text-align: center; }
.vgrid th {
  padding: 3px 2px; font-weight: 500; color: var(--text-dim);
  background: var(--surface-2); min-width: 17px;
}
.vgrid th.is-off { color: var(--text-faint); background: var(--surface-3, var(--surface-2)); }
.vgrid .vgrid__name {
  text-align: left; padding: 3px 8px; white-space: nowrap;
  font-weight: 500; color: var(--text); background: var(--surface);
  position: sticky; left: 0; z-index: 1; min-width: 130px;
}
.vgrid thead .vgrid__name { background: var(--surface-2); font-weight: 650; }
td.vcell { height: 20px; min-width: 17px; padding: 0; }
.vcell--off  { background: var(--surface-2); }
.vcell--hol  { background: var(--critical-soft); }
.vcell--paid { background: var(--ok); }
.vcell--unpaid { background: #e0932a; }
.vcell--plan {
  background: repeating-linear-gradient(45deg,
    var(--accent-soft), var(--accent-soft) 3px, transparent 3px, transparent 6px);
  outline: 1px dashed var(--accent); outline-offset: -2px;
}
.vleg { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; color: var(--text-dim); }
.vleg .vcell { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }

/* Строка исполнителя в настройках лёгкой версии */
.perfrow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.perfrow .input { flex: 1; min-width: 150px; }
.vstat__value.is-adv { color: var(--warn); }

/* ── Боковая навигация ───────────────────────────────────────────────────── */
/* Инструменты слева и всегда на виду: человек не ищет, куда нажать, а видит
   весь набор сразу — как в Basecamp. Топбар остаётся под поиск и профиль. */

.shell { display: flex; flex: 1; min-height: 0; }

.nav {
  width: 178px; flex: none; display: flex; flex-direction: column; gap: 2px;
  padding: 10px 8px; border-right: 1px solid var(--border);
  background: var(--surface); overflow-y: auto;
}
.navitem {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: none; border-radius: 8px; cursor: pointer;
  background: none; color: var(--text-2); font-size: 13.5px; font-weight: 500;
  text-align: left; font-family: inherit;
}
.navitem:hover { background: var(--surface-2); color: var(--text); }
.navitem.is-active { background: var(--accent-soft); color: var(--accent); }
.navitem__icon { width: 17px; text-align: center; flex: none; font-size: 15px; }
.navitem__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navitem .badge { flex: none; }
.nav__spacer { flex: 1; min-height: 8px; }
.nav__create {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: none; color: var(--text); font-size: 13.5px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.nav__create:hover { background: var(--surface-2); }

/* Поиск в шапке: узкая кнопка, разворачивается в палитру по ⌘K */
.searchbtn {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  color: var(--text-3); font-size: 13px; cursor: pointer; min-width: 190px;
  font-family: inherit;
}
.searchbtn:hover { border-color: var(--border-strong); }
.searchbtn kbd {
  margin-left: auto; font-size: 11px; font-family: inherit; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}

/* ── Палитра поиска ──────────────────────────────────────────────────────── */

.palette {
  width: min(560px, calc(100vw - 28px)); max-height: 66vh;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg, 0 18px 48px rgba(0,0,0,.22));
  display: flex; flex-direction: column; overflow: hidden;
}
.palette__input {
  height: 50px; border: none; border-bottom: 1px solid var(--border);
  background: none; color: var(--text); font-size: 15px; padding: 0 16px;
  outline: none; font-family: inherit; width: 100%;
}
.palette__list { overflow: auto; padding: 6px; }
.palette__group {
  font-size: 11px; color: var(--text-3); text-transform: uppercase;
  letter-spacing: .05em; padding: 9px 10px 4px;
}
.palette__row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: none; border-radius: 7px; background: none;
  color: var(--text); font-size: 13.5px; cursor: pointer; text-align: left;
  font-family: inherit;
}
.palette__row.is-cursor { background: var(--accent-soft); color: var(--accent); }
.palette__row small { color: var(--text-3); font-size: 12px; margin-left: auto; flex: none; }
.palette__icon { width: 16px; text-align: center; flex: none; opacity: .7; }
.palette__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Главная: сегодня ────────────────────────────────────────────────────── */

.home { display: flex; flex-direction: column; gap: 22px; }
.home__hello { font-size: 21px; font-weight: 640; letter-spacing: -.02em; }
.home__sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.hblock__head {
  display: flex; align-items: baseline; gap: 9px; margin-bottom: 9px;
}
.hblock__head h2 { font-size: 14px; font-weight: 600; }
.hblock__more {
  margin-left: auto; font-size: 12.5px; color: var(--text-3);
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.hblock__more:hover { color: var(--accent); }

.hrow {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 14px; border: none; border-bottom: 1px solid var(--border);
  background: none; color: var(--text); font-size: 13.5px; cursor: pointer;
  text-align: left; font-family: inherit;
}
.hrow:last-child { border-bottom: none; }
.hrow:hover { background: var(--surface-2); }
.hrow__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
/* Название задачи важнее пути к ней: сжимаем путь, а не имя */
.hrow__name { flex: 0 1 auto; min-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow__where {
  color: var(--text-3); font-size: 12.5px; flex: 1 1 auto;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hrow__right { margin-left: auto; flex: none; font-size: 12.5px; color: var(--text-3); }
.hrow__right.is-over { color: var(--critical); }
.hrow__acts { margin-left: auto; display: flex; gap: 6px; flex: none; }

/* Лента: кто что сделал */
.feed { display: flex; flex-direction: column; gap: 1px; }
.feedrow {
  display: flex; align-items: center; gap: 9px; padding: 7px 2px;
  font-size: 13px; color: var(--text-2); cursor: pointer;
  background: none; border: none; text-align: left; width: 100%; font-family: inherit;
}
.feedrow:hover { color: var(--text); }
.feedrow__ava {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 9.5px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.feedrow__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feedrow__time { flex: none; color: var(--text-3); font-size: 12px; }

/* Полоса прогресса проекта */
.prog {
  height: 5px; border-radius: 3px; background: var(--surface-2);
  overflow: hidden; display: flex; flex: none;
}
.prog__done { background: var(--ok); flex: none; }
.prog__over { background: var(--critical); flex: none; }
.projrow {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 14px; border: none; border-bottom: 1px solid var(--border);
  background: none; color: var(--text); font-size: 13.5px; cursor: pointer;
  text-align: left; font-family: inherit;
}
.projrow:last-child { border-bottom: none; }
.projrow:hover { background: var(--surface-2); }
.projrow__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projrow .prog { width: 84px; }

/* Хлебные крошки на доске и в проекте */
.crumbs {
  display: flex; align-items: center; gap: 5px; font-size: 12.5px;
  color: var(--text-3); margin-bottom: 8px; flex-wrap: wrap;
}
.crumbs button {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--text-3); font-size: inherit; font-family: inherit;
}
.crumbs button:hover { color: var(--accent); text-decoration: underline; }
.crumbs__sep { opacity: .5; }
.crumbs__cur { color: var(--text-2); }

/* Уведомления, сгруппированные по дню */
.notifday {
  font-size: 11px; color: var(--text-3); text-transform: uppercase;
  letter-spacing: .05em; padding: 12px 0 5px;
}
.notifday:first-child { padding-top: 0; }

@media (max-width: 900px) {
  .nav { width: 56px; padding: 10px 6px; }
  .navitem { justify-content: center; padding: 9px 0; }
  .navitem__label { display: none; }
  .navitem .badge { position: absolute; transform: translate(13px, -11px); }
  .navitem { position: relative; }
  .nav__create { padding: 9px 0; }
  .nav__create span { display: none; }
  .searchbtn { min-width: 0; }
  .searchbtn span, .searchbtn kbd { display: none; }
}

@media (max-width: 760px) {
  /* На телефоне навигация уезжает вниз — большим пальцем удобнее */
  .shell { flex-direction: column; }
  .nav {
    width: 100%; flex-direction: row; border-right: none;
    border-top: 1px solid var(--border); padding: 6px 4px;
    order: 2; gap: 0; overflow-x: auto;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }
  .navitem { flex: 1; flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 10.5px; }
  .navitem__icon { font-size: 17px; }
  .navitem__label { display: block; font-size: 10px; text-align: center; }
  .navitem .badge { position: absolute; transform: translate(12px, -4px); }
  .nav__spacer, .nav__create { display: none; }
  .main { order: 1; }
  .palette { width: calc(100vw - 20px); max-height: 74vh; }
  /* На телефоне путь к задаче не помещается — остаётся имя и срок */
  .hrow__where { display: none; }
  .hrow { padding: 10px 12px; gap: 8px; }
  .hrow__name { flex: 1; }
  .projrow { padding: 10px 12px; }
  .projrow .prog { width: 54px; }
}
