:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e1e4ea;
  --text: #1d2330;
  --muted: #6b7385;
  --accent: #3b5bdb;
  --accent-soft: #e7ecff;
  --ok: #2f9e44;
  --ok-soft: #e6f6ea;
  --warn: #e8890c;
  --warn-soft: #fff3e0;
  --danger: #d6336c;
  --danger-soft: #fde8ef;
  --over: #7048e8;
  --over-soft: #efe9ff;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --surface: #1d2129;
    --surface-2: #232833;
    --border: #323846;
    --text: #e6e9ef;
    --muted: #9aa3b5;
    --accent: #7b93ff;
    --accent-soft: #263055;
    --ok: #51cf66;
    --ok-soft: #1f3a27;
    --warn: #ffa94d;
    --warn-soft: #3d2f1c;
    --danger: #f06595;
    --danger-soft: #42202d;
    --over: #9775fa;
    --over-soft: #2e2550;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; white-space: nowrap; }
.brand span { color: var(--muted); }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); white-space: nowrap;
}
.tabs button:hover { background: var(--surface-2); }
.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

main { padding: 16px 20px 40px; }

/* ---------- Общие элементы ---------- */
.btn {
  border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: none; }
input[type=email], input[type=password], input[type=text], input[type=date], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--border); background: var(--surface); padding: 6px 8px; border-radius: 8px;
}
textarea { width: 100%; min-height: 60px; }
.muted { color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; min-width: 120px;
}
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.warn b { color: var(--warn); }
.stat.accent b { color: var(--accent); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* ---------- Доска ---------- */
.board-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .board-layout { grid-template-columns: 1fr; } }

.train { margin-bottom: 22px; }
.train h2 { font-size: 16px; margin: 0 0 10px; display: flex; gap: 10px; align-items: baseline; }
.train h2 small { font-weight: 400; color: var(--muted); font-size: 12px; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }

.team {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; border-top: 4px solid var(--team-color, var(--border));
  transition: outline-color .1s, opacity .2s;
  outline: 2px dashed transparent; outline-offset: 2px;
}
.team.drop-over, .zone.drop-over { outline-color: var(--accent); background: var(--accent-soft); }
.team.dim { opacity: .35; }
.team-head { display: flex; align-items: center; gap: 6px; }
.team-head .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.reinforced { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.fill { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 6px; }
.fill.ok { background: var(--ok-soft); color: var(--ok); }
.fill.vac { background: var(--warn-soft); color: var(--warn); }
.fill.over { background: var(--over-soft); color: var(--over); }

.roles { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; font-size: 12px; }
.roles dt { color: var(--muted); }
.roles dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roles dd.empty { color: var(--muted); opacity: .6; }

.slots { display: flex; flex-direction: column; gap: 4px; }
.chip {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); cursor: grab; font-size: 13px; min-height: 30px;
}
.chip:hover { border-color: var(--accent); }
.chip.dragging { opacity: .4; }
.chip .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .gr { font-size: 11px; color: var(--muted); }
.chip .lead { color: #f59f00; font-size: 13px; }
.chip.hit { box-shadow: 0 0 0 2px var(--accent); }
.chip .out { font-size: 11px; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.chip.moving { border-color: var(--warn); }
.chip.moving .out { background: var(--warn-soft); color: var(--warn); }
.chip.leaving { border-color: var(--danger); }
.chip.leaving .out { background: var(--danger-soft); color: var(--danger); }
.chip.unassign .out { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.slot-vacant {
  border: 1.5px dashed var(--warn); color: var(--warn); border-radius: 8px; padding: 5px 8px; font-size: 12px; min-height: 30px;
  display: flex; align-items: center; background: var(--warn-soft);
}
.slot-vacant.next { border-color: var(--border); background: none; color: var(--muted); }
.incoming-title { font-size: 11px; color: var(--muted); margin-top: 2px; }
.chip.incoming { border: 1.5px dashed var(--ok); background: var(--ok-soft); cursor: pointer; }
.chip.incoming .out { color: var(--ok); }

.side { position: sticky; top: 68px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 84px); overflow: auto; }
.zone {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px;
  outline: 2px dashed transparent; outline-offset: 2px;
}
.zone h3 { margin: 0 0 8px; font-size: 13px; display: flex; justify-content: space-between; }
.zone.leave { border-color: var(--danger); background: var(--danger-soft); }
.zone.leave h3 { color: var(--danger); }
.zone .hint { font-size: 12px; color: var(--muted); }
details.zone summary { cursor: pointer; font-weight: 600; font-size: 13px; }

/* ---------- Модалка ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 15, 25, .45); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 60px 16px; overflow: auto; }
.modal { background: var(--surface); border-radius: 14px; width: min(520px, 100%); box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.modal.wide { width: min(760px, 100%); }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.check { display: flex; gap: 8px; align-items: center; }

/* ---------- Таблицы ---------- */
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
table.grid th, table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.grid th { background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 600; }
table.grid tr.group td { background: var(--surface-2); font-weight: 600; }
table.grid td.actions { text-align: right; white-space: nowrap; }
.ev { font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.ev.join { background: var(--ok-soft); color: var(--ok); }
.ev.transfer { background: var(--warn-soft); color: var(--warn); }
.ev.unassign { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.ev.leave_project { background: var(--danger-soft); color: var(--danger); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

.subtabs { display: flex; gap: 6px; margin-bottom: 12px; }

/* ---------- Таймлайн ---------- */
.tl { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; position: relative; max-height: calc(100vh - 190px); }
.tl-row { display: flex; border-bottom: 1px solid var(--border); min-height: 28px; }
.tl-row.head { position: sticky; top: 0; z-index: 3; background: var(--surface-2); font-size: 12px; color: var(--muted); }
.tl-row.group { background: var(--surface-2); font-weight: 600; font-size: 12px; }
.tl-name { position: sticky; left: 0; z-index: 2; width: 230px; flex: 0 0 230px; padding: 5px 10px; background: inherit; border-right: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.tl-row:not(.head):not(.group) .tl-name { background: var(--surface); }
.tl-track { position: relative; flex: 0 0 auto; }
.tl-month { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--border); }
.tl-month-label { position: absolute; top: 6px; padding-left: 6px; white-space: nowrap; }
.tl-bar { position: absolute; top: 4px; height: 20px; border-radius: 5px; color: #fff; font-size: 11px; padding: 0 6px; line-height: 20px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.tl-bar.open { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tl-leave { position: absolute; top: 3px; color: var(--danger); font-weight: 700; font-size: 14px; transform: translateX(-4px); }
.tl-line { position: absolute; top: 0; bottom: 0; width: 2px; z-index: 1; pointer-events: none; }
.tl-line.today { background: var(--danger); }
.tl-line.board { background: var(--accent); opacity: .6; }

.heat { border-collapse: separate; border-spacing: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; font-size: 12px; }
.heat th { color: var(--muted); font-weight: 500; padding: 2px 6px; text-align: left; white-space: nowrap; }
.heat td.cell { width: 52px; text-align: center; border-radius: 4px; padding: 3px 0; cursor: pointer; font-variant-numeric: tabular-nums; }
.heat td.cell.ok { background: var(--ok-soft); color: var(--ok); }
.heat td.cell.vac1 { background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.heat td.cell.vac2 { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.heat td.cell.over { background: var(--over-soft); color: var(--over); font-weight: 700; }
.heat tr.train-row th { padding-top: 8px; color: var(--text); font-weight: 600; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; }
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 600px) {
  main { padding: 12px 16px 40px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand span, .brand { font-size: 13px; }
  .field-row { grid-template-columns: 1fr; }
  .tl-name { width: 140px; flex-basis: 140px; }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Итерация 2 ---------- */
.brand { font-size: 15px; }
.top-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.user-menu { position: relative; }
.user-menu summary { cursor: pointer; list-style: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap; font-size: 13px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-2); }
.user-menu .menu { position: absolute; right: 0; top: 36px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; padding: 4px; z-index: 30; min-width: 160px; }
.user-menu .menu .btn { text-align: left; }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; }

.login { max-width: 340px; margin: 12vh auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login h1 { margin: 0; font-size: 20px; }

.scenario-bar {
  position: sticky; top: 52px; z-index: 19; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 8px 20px; background: var(--warn-soft); border-bottom: 1px solid var(--warn); font-size: 13px;
}
.scenario-bar .spacer { flex: 1; }
.in-scenario .side { top: 110px; }
.in-scenario .team { border-style: dashed; }
.warn-text { color: var(--warn); font-size: 13px; }
tr.op-error td { background: var(--warn-soft); }

.compare-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; }
.diff-summary { font-size: 13px; }
.team.changed { box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.diff-badge { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.chip.diff-new { border-left: 4px solid var(--accent); }
.chip .out.diff-from { color: var(--accent); background: var(--accent-soft); }
.chip.diff-gone { opacity: .6; border-style: dashed; cursor: pointer; }
.chip.diff-gone .nm { text-decoration: line-through; }
.roles dd.diff-role { color: var(--accent); font-weight: 600; }
.roles dd s { font-weight: 400; }
.role-next { color: var(--warn); font-size: 11px; }
.warn-icon { color: var(--warn); cursor: help; }
.slot-vacant { cursor: default; justify-content: space-between; }
.readonly .slot-vacant { cursor: default; }
body:not(.readonly) .slot-vacant:not(.next) { cursor: pointer; }
.vac-pick { font-size: 11px; opacity: .8; }

.skill-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.skill-tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); margin: 1px 2px; }
.skill-tag.lvl2 { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.skill-tag.lvl3 { background: var(--accent); border-color: transparent; color: #fff; }
.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 12px; }
.skill-edit { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
ul.compact { margin: 4px 0 0; padding-left: 18px; }

.tl-lead { position: absolute; top: 2px; height: 4px; border-radius: 2px; background: #f59f00; z-index: 1; }
.ev.role-assign { background: var(--ok-soft); color: var(--ok); }
.ev.role-change { background: var(--warn-soft); color: var(--warn); }
.ev.role-vacate { background: var(--danger-soft); color: var(--danger); }

.heat.comp th.rot { writing-mode: vertical-rl; text-orientation: mixed; padding: 6px 2px; font-size: 11px; height: 96px; text-align: end; vertical-align: bottom; white-space: nowrap; }
.heat.comp td.cell { width: 30px; min-width: 30px; background: var(--surface-2); color: var(--muted); }
.heat.comp td.cell.g-has { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.heat.comp td.cell.lvl1 { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }
.heat.comp td.cell.lvl2 { background: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text); }
.heat.comp td.cell.lvl3 { background: var(--accent); color: #fff; font-weight: 700; }
.heat.comp td.sep-col, .heat.comp th.sep-col { width: 8px; background: none; }
.heat.comp td.risk { color: var(--warn); font-size: 12px; white-space: nowrap; padding-left: 8px; }
.heat.comp tr.bench-row th { color: var(--muted); font-style: italic; }
.heat.comp tr.total-row td, .heat.comp tr.total-row th { border-top: 1px solid var(--border); font-weight: 700; color: var(--text); background: none; }
pre.details { font-size: 11px; margin: 4px 0 0; white-space: pre-wrap; max-width: 420px; }
.topbar { flex-wrap: wrap; height: auto; min-height: 52px; gap: 8px 20px; padding-top: 6px; padding-bottom: 6px; }
.scenario-bar { position: static; }
.in-scenario .side { top: 68px; }
.slot-vacant { gap: 8px; }

/* ---------- Подрядчики ---------- */
/* Метка подрядчика: цвет задаётся через --ctr; фон и текст смешиваются с цветами темы, поэтому читаются и в светлой, и в тёмной. */
.ctr-badge {
  --ctr: var(--over);
  display: inline-block; flex: 0 0 auto; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-left: 4px; padding: 0 5px; border-radius: 999px; vertical-align: 1px;
  font-size: 10.5px; line-height: 15px; font-weight: 600; letter-spacing: .01em;
  color: color-mix(in srgb, var(--ctr) 72%, var(--text));
  background: color-mix(in srgb, var(--ctr) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--ctr) 40%, transparent);
  cursor: help;
}
.ctr-badge.full { max-width: 28ch; }
.chip .ctr-badge { margin-left: 0; }
.roles dd .ctr-badge { vertical-align: 0; }
/* Фильтр «штатные / подрядчики» на доске */
.chip.ctr-dim, .roles dd.ctr-dim { opacity: .3; }
.chip.ctr-dim:hover { opacity: .7; }
select.ctr-filter.active { border-color: var(--accent); color: var(--accent); }
/* Счётчик подрядчиков в шапке команды */
.ctr-count {
  font-size: 11px; padding: 0 6px; border-radius: 6px; white-space: nowrap; cursor: help;
  color: var(--over); background: var(--over-soft);
}
.heat.comp td.cell.ctr-has { background: var(--over-soft); color: var(--over); font-weight: 700; }
.color-field { display: flex; align-items: center; gap: 12px; }
.color-field input[type=color] { width: 44px; height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.color-field input[type=color]:disabled { opacity: .4; }

/* Шапка карточки команды: при нехватке места метки переносятся, название не сжимается до «Ком…» */
/* Шапка карточки — всегда одна строка: длинное название сокращается многоточием (полное — в подсказке) */
.team-head { flex-wrap: nowrap; min-width: 0; }
.team-head > * { flex-shrink: 0; }
.team-head .name { flex: 1 1 auto; min-width: 40px; flex-shrink: 1; }

/* ---------- Направления ---------- */
.stream-switch { display: flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.stream-switch button { border: 0; background: none; padding: 5px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 13px; white-space: nowrap; }
.stream-switch button.active { background: var(--accent); color: #fff; font-weight: 600; }
.spec-tag { font-size: 10.5px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.others { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--muted); }
.others button { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; font: inherit; }
.others button:hover { color: var(--accent); text-decoration: underline; }
.others .vac { color: var(--warn); }

/* ---------- Закрытие команды ---------- */
.closing-badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.closing-badge.conflict { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.team.closing { background-image: repeating-linear-gradient(135deg, transparent 0 12px, color-mix(in srgb, var(--danger) 5%, transparent) 12px 24px); }
.team.closed-conflict { outline: 2px solid var(--danger); outline-offset: 0; }
.chip.must-move { box-shadow: inset 3px 0 0 var(--danger); }
.closing-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; padding: 6px 8px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); }
.closing-bar.done { background: var(--ok-soft); color: var(--ok); }
.redistribute-table select { max-width: 240px; }
.stat.danger b { color: var(--danger); }
.heat td.cell.closed { background: none; color: var(--muted); opacity: .5; }
/* Метки (специализация, подрядчик, переход) переносятся на вторую строку, а не сжимают имя */
.chip { flex-wrap: wrap; row-gap: 3px; }
.chip .nm { min-width: 110px; }

/* ---------- Системы и целевые команды ---------- */
.team-target { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
.team-system { font-size: 12px; color: var(--muted); margin-top: -4px; display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; }

/* ---------- Изменения от других пользователей ---------- */
.changes-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 20px; background: var(--accent-soft); color: var(--accent); border-bottom: 1px solid var(--accent); font-size: 13px; }
.changes-banner[hidden] { display: none; }
.ev.draft-ev { background: var(--warn-soft); color: var(--warn); }

/* ---------- Шапка карточки команды: две строки, правые блоки по правому краю, без переносов ---------- */
.team { container-type: inline-size; }
.team-head, .team-sub { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; min-width: 0; }
.team-head .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-open { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: var(--text); font: inherit; font-weight: 600; }
.team-open:hover { color: var(--accent); text-decoration: underline; }
.head-right { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.team-sub { margin-top: -4px; min-height: 22px; }
.team-sub .team-system { margin: 0; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; }
.team-sub .sys-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.team-target { flex-shrink: 0; }
@container (max-width: 250px) { .team-target .lbl { display: none; } }
.team.flash { animation: team-flash 1.6s ease-out; }
@keyframes team-flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }

/* ---------- Карточка команды ---------- */
.modal.xwide { width: min(1100px, 100%); }
.tc-title { display: inline-flex; align-items: center; gap: 4px; }
.tc-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; }
.tc-h { margin: 6px 0 0; font-size: 14px; }
.tc-roles th { width: 170px; font-weight: 500; color: var(--muted); background: none; font-size: 13px; }
.tc-streams { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.tc-stream h4 { margin: 0 0 6px; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.tc-cap { font-weight: 400; font-size: 12px; }
.tc-table td { font-size: 13px; padding: 5px 8px; }
.tc-vacancy td { color: var(--warn); background: var(--warn-soft); font-size: 12px; }
.tc-must-move td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.tc-incoming { font-size: 12px; margin-top: 6px; color: var(--muted); }
.tc-plan td { font-size: 13px; }
.tc-date { width: 100px; white-space: nowrap; }
.tc-table td, .tc-roles td { white-space: nowrap; }
.tc-table td:first-child, .tc-roles td:nth-child(2) { white-space: normal; }
/* Запланированный приход, закрывающий вакансию: стоит на месте вакансии */
.chip.incoming.covers-vacancy { border-color: var(--ok); background: color-mix(in srgb, var(--ok-soft) 70%, var(--warn-soft)); }
.tc-covered td { color: var(--ok); background: var(--ok-soft); font-size: 12px; }
.ev.return { background: var(--ok-soft); color: var(--ok); }
.chip.maternity { border-style: dashed; opacity: .85; }
.badge-maternity { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--over-soft); color: var(--over); white-space: nowrap; }
.people-filters select { max-width: 220px; }

/* Доска: выбор конкретных команд (выпадающая панель) и пометка статистики по фильтру */
details.team-pick { position: relative; }
details.team-pick > summary { list-style: none; user-select: none; white-space: nowrap; }
details.team-pick > summary::-webkit-details-marker { display: none; }
details.team-pick > summary.active { border-color: var(--accent); color: var(--accent); }
.tp-panel {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; width: 320px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.tp-tools { display: flex; gap: 6px; }
.tp-tools input { flex: 1; min-width: 0; }
.tp-list { max-height: 50vh; overflow-y: auto; }
.tp-train { padding: 4px 0; border-bottom: 1px solid var(--border); }
.tp-train:last-child { border-bottom: 0; }
.tp-train-name { font-weight: 600; }
.tp-team { padding-left: 20px; font-size: 13px; }
.tp-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.stats.filtered .stat { border-color: var(--accent-soft); }
.stats-note { align-self: center; color: var(--accent); font-size: 12px; font-weight: 600; }
