:root {
  --sidebar: #262626;
  --sidebar-hover: #333;
  --sidebar-active: #3d3d3d;
  --sidebar-text: #e6e6e6;
  --sidebar-muted: #9a9a9a;
  --topbar: #1e1e1e;
  --bg: #1d2b2a;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --column: #f1f2f4;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e1e4e8;
  --accent: #2f6fed;
  --accent-soft: #e8f0fe;
  --danger: #d33a2c;
  --danger-soft: #fdecea;
  --warn: #d98a00;
  --ok: #2e9e5b;
  --p-low: #2e9e5b;
  --p-med: #e0a100;
  --p-high: #d33a2c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .22);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ---------- Общие элементы ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface);
  white-space: nowrap;
}
.btn:hover { border-color: #c4c9d0; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 3px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted);
  width: 28px; height: 28px; border-radius: 6px;
  display: inline-grid; place-items: center; font-size: 16px; line-height: 1; flex: none;
}
.icon-btn:hover { background: rgba(0,0,0,.07); color: var(--text); }

.input, select.input, textarea.input {
  width: 100%; padding: 7px 10px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface);
}
.input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea.input { resize: vertical; min-height: 80px; }
label.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }

.avatar {
  --size: 24px;
  width: var(--size); height: var(--size); border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  color: #fff; font-size: calc(var(--size) * .42); font-weight: 600;
  border: 2px solid var(--surface); box-sizing: content-box;
  user-select: none;
}
.avatar.lg { --size: 34px; }
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -7px; }
.avatar.more { background: #8b95a1; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 6px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.high { background: var(--danger-soft); color: var(--p-high); border-color: #f6c6c0; }
.badge.med { background: #fff6dd; color: #a87500; border-color: #f2df9f; }
.badge.low { background: #e6f5ec; color: var(--p-low); border-color: #bfe3cc; }
.badge.overdue { background: var(--danger-soft); color: var(--danger); border-color: #f6c6c0; }
.badge.today { background: #fff2dc; color: #b06d00; border-color: #f3d5a0; }
.badge.done { background: #e6f5ec; color: var(--ok); border-color: #bfe3cc; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 24px 12px; }

/* ---------- Вход ---------- */

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 20% 10%, #2f4f4b, var(--bg) 60%);
  overflow: auto;
}
.auth-card {
  width: min(400px, 100%); background: var(--surface); border-radius: 14px;
  padding: 28px; box-shadow: var(--shadow-lg); display: grid; gap: 14px;
}
.auth-card h1 { margin: 0; font-size: 22px; }
.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 8px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 6px; }
.auth-tabs button.active { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.error-text { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- Каркас ---------- */

.shell { display: flex; height: 100vh; }

.sidebar {
  width: 248px; flex: none; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; overflow-y: auto; padding: 10px 8px;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border-radius: 7px; border: 0; background: transparent; color: inherit;
  text-align: left; text-decoration: none; min-width: 0;
}
.sidebar .nav-item:hover { background: var(--sidebar-hover); }
.sidebar .nav-item.active { background: var(--sidebar-active); }
.sidebar .nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .nav-item .count { font-size: 12px; color: var(--sidebar-muted); }
.sidebar .nav-item .count.hot { color: #fff; background: #d33a2c; border-radius: 9px; padding: 0 6px; }
.sidebar .nav-item .icon { width: 18px; text-align: center; opacity: .8; flex: none; }
.sidebar .nav-sub .nav-item { padding-left: 38px; font-size: 13.5px; }
.sidebar .section {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 10px 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--sidebar-muted);
}
.sidebar .section .icon-btn { color: var(--sidebar-muted); width: 22px; height: 22px; }
.sidebar .section .icon-btn:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar .project-item .icon-btn { visibility: hidden; color: var(--sidebar-muted); width: 22px; height: 22px; }
.sidebar .project-item:hover .icon-btn { visibility: visible; }
.sidebar .project-item .icon-btn:hover { background: #4a4a4a; color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .avatar { border-color: var(--sidebar); }
.role-tag { font-size: 10.5px; padding: 0 5px; border-radius: 4px; background: #4a4a4a; color: #ddd; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.main.board-bg {
  background:
    radial-gradient(ellipse at 70% 0%, rgba(87, 140, 120, .55), transparent 60%),
    radial-gradient(ellipse at 0% 100%, rgba(30, 70, 90, .7), transparent 55%),
    linear-gradient(160deg, #24413b, #182628 70%);
}
.main.plain-bg { background: var(--surface-2); }

.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--topbar); color: #f1f1f1;
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.topbar .avatar { border-color: var(--topbar); }
.topbar .grow { flex: 1; }
.topbar .btn { background: #2d2d2d; border-color: #3a3a3a; color: #eee; }
.topbar .btn:hover { background: #383838; }
.topbar .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.menu-toggle { display: none; color: #ddd; }
.menu-toggle:hover { background: #333; color: #fff; }

.view-switch { display: inline-flex; background: #2d2d2d; border-radius: 8px; padding: 3px; }
.view-switch button {
  border: 0; background: transparent; color: #bbb; padding: 4px 12px; border-radius: 6px; font-size: 13px;
}
.view-switch button.active { background: #4a4a4a; color: #fff; }

/* ---------- Фильтры ---------- */

.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 16px;
}
.board-bg .filters { background: rgba(0, 0, 0, .18); }
.plain-bg .filters { background: var(--surface); border-bottom: 1px solid var(--border); }
.filters .input, .filters select { width: auto; padding: 5px 9px; font-size: 13px; background: var(--surface); }
.filters .search { width: 220px; }
.filters .btn { padding: 5px 10px; font-size: 13px; }
.filters .btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip-count { background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }

.popover {
  position: fixed; z-index: 60; background: var(--surface); border-radius: 10px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  padding: 6px; min-width: 200px; max-height: 70vh; overflow-y: auto;
}
.popover .menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: 0; background: transparent; border-radius: 6px; text-align: left;
}
.popover .menu-item:hover, .popover .menu-item.focus { background: var(--surface-2); }
.popover .menu-item.danger { color: var(--danger); }
.popover .menu-item .check { margin-left: auto; color: var(--accent); }
.popover hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.popover .swatches { display: flex; gap: 6px; padding: 6px 10px; flex-wrap: wrap; }
.popover .swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; }
.popover .swatch.sel { border-color: var(--text); }
.popover .search-row { padding: 4px; }

.date-filters { display: grid; gap: 12px; padding: 10px; width: 330px; }
.date-filters .row { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 6px; align-items: center; font-size: 13px; }
.date-filters .presets { display: flex; flex-wrap: wrap; gap: 6px; }
.date-filters .checks { display: grid; gap: 6px; font-size: 13px; }

/* ---------- Доска ---------- */

.board {
  flex: 1; display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px 16px; overflow-x: auto; overflow-y: hidden;
}
.column {
  width: 290px; flex: none; max-height: 100%;
  display: flex; flex-direction: column;
  background: var(--column); border-radius: var(--radius);
  border-top: 6px solid var(--col-color, #9aa3ad);
  box-shadow: var(--shadow);
}
.column-head { padding: 10px 10px 4px 14px; }
.column-head .row1 { display: flex; align-items: center; gap: 6px; }
.column-head h3 { margin: 0; font-size: 15px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.column-head .total { font-size: 12px; color: var(--muted); }
.column-head .add-task {
  border: 0; background: transparent; color: var(--accent); padding: 2px 0; font-size: 13.5px;
}
.column-head .add-task:hover { text-decoration: underline; }
.cards { flex: 1; overflow-y: auto; padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 30px; }
.new-task { padding: 0 8px 4px; display: grid; gap: 6px; }
.new-task textarea { min-height: 60px; }
.new-task .actions { display: flex; gap: 6px; }
.load-more { margin: 0 8px 10px; }

.card {
  background: var(--surface); border-radius: 8px; box-shadow: var(--shadow);
  padding: 9px 10px 8px; cursor: pointer; user-select: none; position: relative;
  border: 1px solid transparent;
}
.card:hover { border-color: #c8d3e6; }
.card.selected { border-color: var(--accent); }
.card.is-done .card-title { color: var(--muted); text-decoration: line-through; }
.card-cover { margin: -9px -10px 8px; border-radius: 8px 8px 0 0; overflow: hidden; max-height: 150px; background: var(--surface-2); }
.card-cover img { width: 100%; display: block; max-height: 150px; object-fit: cover; }
.card-top { display: flex; gap: 8px; align-items: flex-start; }
.card-check {
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #9aa3ad; background: transparent;
  flex: none; margin-top: 1px; padding: 0; display: grid; place-items: center; font-size: 11px; color: transparent;
}
.card-check:hover { border-color: var(--ok); color: var(--ok); }
.card.is-done .card-check { background: var(--ok); border-color: var(--ok); color: #fff; }
.card-title { flex: 1; min-width: 0; word-break: break-word; font-size: 13.5px; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.card-meta .key { font-size: 11.5px; color: var(--muted); }
.card-meta .spacer { flex: 1; }
.card-meta .counter { font-size: 12px; color: var(--muted); }
.drop-placeholder { border: 2px dashed var(--accent); border-radius: 8px; background: rgba(47, 111, 237, .06); flex: none; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; transform: rotate(2deg); box-shadow: var(--shadow-lg); opacity: .95; }
.add-column {
  width: 240px; flex: none; padding: 14px; border-radius: var(--radius);
  border: 2px dashed rgba(255,255,255,.35); background: rgba(255,255,255,.08); color: #eef;
}
.add-column:hover { background: rgba(255,255,255,.16); }

/* ---------- Список ---------- */

.list-wrap { flex: 1; overflow: auto; padding: 16px; }
.table-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.tasks { width: 100%; border-collapse: collapse; }
table.tasks th, table.tasks td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tasks th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; user-select: none; position: sticky; top: 0; }
table.tasks th.sortable { cursor: pointer; }
table.tasks th.sortable:hover { color: var(--text); }
table.tasks th .arrow { color: var(--accent); }
table.tasks tbody tr { cursor: pointer; }
table.tasks tbody tr:hover { background: #f7f9fc; }
table.tasks tbody tr.selected { background: var(--accent-soft); }
table.tasks td.title { max-width: 420px; }
table.tasks td.title .t { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.tasks td.nowrap { white-space: nowrap; }
.status-cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.pagination {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; font-size: 13px; color: var(--muted);
}
.pagination .grow { flex: 1; }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages button {
  min-width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface);
}
.pagination .pages button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .pages button:disabled { opacity: .45; cursor: default; }
.pagination .pages .gap { padding: 0 4px; align-self: center; }
.pagination select { width: auto; padding: 4px 6px; }

/* ---------- Страница задачи ---------- */

.task-page { flex: 1; overflow-y: auto; position: relative; }
.task-page.drop-active::after {
  content: 'Отпустите, чтобы прикрепить файлы к задаче'; position: fixed; inset: 12px 12px 12px 260px; z-index: 50;
  border: 2px dashed var(--accent); border-radius: 14px; background: rgba(232, 240, 254, .9);
  display: grid; place-items: center; color: var(--accent); font-weight: 600; font-size: 16px; pointer-events: none;
}
.task-page.drop-active.drop-chat::after { content: 'Отпустите, чтобы прикрепить к сообщению'; }
.tp-head {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; background: var(--topbar); color: #eee; min-height: 54px;
}
.tp-head .btn { background: #2d2d2d; border-color: #444; color: #eee; }
.tp-head .btn:hover { background: #3a3a3a; }
.tp-head .icon-btn { color: #ddd; }
.tp-head .icon-btn:hover { background: #333; color: #fff; }
.tp-head .back-btn { font-weight: 600; }
.tp-head .crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: #bbb; white-space: nowrap; overflow: hidden; }
.tp-head .crumbs a { color: #ddd; text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.tp-head .crumbs a:hover { text-decoration: underline; }
.tp-head .crumbs .sep { color: #777; }
.tp-head .crumbs .key { color: #8fb3ff; }
.tp-wrap {
  max-width: 1320px; margin: 0 auto; padding: 20px; display: grid;
  grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start;
}
.tp-main, .tp-side { display: grid; gap: 16px; min-width: 0; }
.tp-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.tp-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
}
.status-pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c, #999); }
.tp-title {
  font-size: 24px; line-height: 1.3; font-weight: 700; border: 1px solid transparent; border-radius: 8px;
  padding: 4px 8px; margin: 0 -8px; resize: none; width: calc(100% + 16px); background: transparent; overflow: hidden;
}
.tp-title:hover { border-color: var(--border); }
.tp-title:focus { border-color: var(--accent); outline: none; }
.block.first { margin-top: 0; }
.block h4 .n { font-size: 11px; background: var(--surface-2); border-radius: 8px; padding: 1px 6px; letter-spacing: 0; }
.tp-tabs { padding: 0; overflow: hidden; }
.tp-tabs .tabs { padding: 0 10px; }
.tp-tab-body { padding: 14px 16px; max-height: 640px; overflow-y: auto; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button {
  border: 0; background: transparent; padding: 10px 10px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .n { font-size: 11px; background: var(--surface-2); border-radius: 8px; padding: 0 5px; margin-left: 3px; }
.tp-side .info-grid, .tp-side .role-group { grid-template-columns: 110px 1fr; }

.info-grid { display: grid; grid-template-columns: 130px 1fr; gap: 10px 12px; align-items: center; }
.info-grid > .k { color: var(--muted); font-size: 13px; }
.info-grid select.input, .info-grid input.input { padding: 5px 8px; }
.block { margin-top: 18px; }
.block h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.block h4 .grow { flex: 1; }

.role-group { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; align-items: start; margin-bottom: 10px; }
.role-group .k { color: var(--muted); font-size: 13px; padding-top: 4px; }
.people { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.person {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 2px;
  border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px;
}
.person .x { border: 0; background: transparent; color: var(--muted); padding: 0 4px; border-radius: 50%; }
.person .x:hover { color: var(--danger); }
.person .by { font-size: 11px; color: var(--muted); }
.add-person {
  width: 26px; height: 26px; border-radius: 50%; border: 1px dashed #b0b8c2; background: transparent; color: var(--muted);
}
.add-person:hover { border-color: var(--accent); color: var(--accent); }

.desc-view { white-space: pre-wrap; word-break: break-word; padding: 8px 10px; border-radius: 7px; border: 1px solid transparent; cursor: text; min-height: 40px; }
.desc-view:hover { border-color: var(--border); }
.desc-view.placeholder { color: var(--muted); }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.file {
  position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  background: var(--surface-2); display: flex; flex-direction: column;
}
.file .thumb { height: 86px; display: grid; place-items: center; background: #e9ecf0; cursor: pointer; font-size: 26px; overflow: hidden; }
.file .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file .thumb { position: relative; flex-direction: column; gap: 2px; }
.file .thumb .ext { font-size: 10.5px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.file .thumb:hover::after {
  content: '👁 Просмотр'; position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0,0,0,.45); color: #fff; font-size: 12px; font-weight: 600;
}
.files.big { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.files.big .thumb { height: 130px; font-size: 34px; }
.file .name { font-size: 12px; padding: 5px 7px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .sub { font-size: 11px; color: var(--muted); padding: 0 7px 5px; }
.file .actions { position: absolute; top: 4px; right: 4px; display: none; gap: 2px; }
.file:hover .actions { display: flex; }
.file .actions a, .file .actions button {
  width: 24px; height: 24px; border-radius: 5px; background: rgba(0,0,0,.6); color: #fff; border: 0;
  display: grid; place-items: center; text-decoration: none; font-size: 12px;
}
.paste-hint {
  margin-top: 8px; padding: 10px; border: 1px dashed #c4c9d0; border-radius: 8px;
  text-align: center; font-size: 12.5px; color: var(--muted); cursor: pointer;
}
.paste-hint:hover { border-color: var(--accent); color: var(--accent); }
kbd { font: 11px/1 ui-monospace, monospace; padding: 2px 5px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface); }

.meta-list { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }

/* Чат */
.messages { display: flex; flex-direction: column; gap: 12px; padding-bottom: 14px; }
.msg { display: flex; gap: 8px; }
.msg .bubble { background: var(--surface-2); border-radius: 10px; padding: 7px 10px; max-width: 100%; min-width: 0; }
.msg .who { font-size: 12px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.msg .who .time { color: var(--muted); font-weight: 400; }
.msg .who .del { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 0; display: none; }
.msg:hover .who .del { display: inline; }
.msg .text { white-space: pre-wrap; word-break: break-word; }
.msg .files { margin-top: 6px; grid-template-columns: repeat(auto-fill, minmax(130px, 160px)); }
.msg .bubble { flex: 1; }
.composer { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 8px; }
.composer textarea { min-height: 44px; max-height: 160px; resize: none; }
.composer .row { display: flex; gap: 6px; align-items: center; }
.composer .row .grow { flex: 1; font-size: 12px; color: var(--muted); }
.pending { display: flex; gap: 6px; flex-wrap: wrap; }
.pending .p {
  display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; max-width: 200px;
}
.pending .p img { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; }
.pending .p span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* История исполнителей */
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
.chain .arrow { color: var(--muted); }
.timeline { position: relative; display: grid; gap: 12px; padding-left: 18px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; }
.tl-item::before {
  content: ''; position: absolute; left: -18px; top: 5px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--muted);
}
.tl-item.active::before { border-color: var(--ok); background: var(--ok); }
.tl-item .line1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-item .line2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tl-item .note { font-size: 13px; margin-top: 4px; padding: 6px 8px; background: var(--surface-2); border-radius: 6px; white-space: pre-wrap; }

/* Лог */
.log { display: grid; gap: 10px; }
.log-item { display: flex; gap: 8px; font-size: 13px; }
.log-item .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.log-day { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; margin: 6px 0 2px; }

/* ---------- Диалоги ---------- */

dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg); color: var(--text);
}
dialog::backdrop { background: rgba(15, 20, 25, .45); }
dialog form { display: grid; gap: 14px; padding: 20px; }
dialog h3 { margin: 0; font-size: 17px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }
.user-checks { display: grid; gap: 2px; max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px; }
.user-checks label { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.user-checks label:hover { background: var(--surface-2); }

.viewer {
  position: fixed; inset: 0; z-index: 90; background: #0f1216; color: #eee;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; outline: none;
}
.v-top { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: rgba(0,0,0,.35); }
.v-title { flex: 1; min-width: 0; display: grid; }
.v-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.v-title span { font-size: 12px; color: #9aa; }
.v-count { font-size: 13px; color: #bbb; padding: 0 6px; }
.v-btn {
  border: 1px solid #444; background: #262a30; color: #eee; border-radius: 7px; padding: 6px 11px;
  font-size: 13px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.v-btn:hover { background: #343a42; }
.v-stage { display: grid; place-items: center; padding: 16px 64px; overflow: auto; min-height: 0; }
.v-stage img { max-width: 100%; max-height: calc(100vh - 190px); border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); cursor: zoom-in; background: #fff; }
.v-stage.zoomed { place-items: start center; }
.v-stage img.zoom { max-width: none; max-height: none; cursor: zoom-out; }
.v-doc { width: 100%; height: 100%; min-height: 60vh; border: 0; border-radius: 6px; background: #fff; }
.v-media { max-width: 100%; max-height: calc(100vh - 190px); border-radius: 6px; background: #000; }
.v-text {
  width: min(1100px, 100%); height: 100%; overflow: auto; background: #fff; color: var(--text);
  border-radius: 8px; padding: 14px 18px; align-self: stretch;
}
.v-text pre { margin: 0; font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.v-table { border-collapse: collapse; font-size: 13px; }
.v-table th, .v-table td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; white-space: nowrap; }
.v-table th { background: var(--surface-2); position: sticky; top: -14px; }
.v-card {
  background: #fff; color: var(--text); border-radius: 14px; padding: 28px 36px; text-align: center;
  display: grid; justify-items: center; gap: 4px; max-width: 440px;
}
.v-big-ico { font-size: 64px; line-height: 1.1; }
.v-name { font-weight: 600; word-break: break-word; }
.v-nav {
  position: fixed; top: 50%; transform: translateY(-50%); width: 46px; height: 64px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.08); color: #fff; font-size: 36px; line-height: 1; cursor: pointer;
}
.v-nav:hover { background: rgba(255,255,255,.18); }
.v-nav.prev { left: 10px; }
.v-nav.next { right: 10px; }
.v-strip { display: flex; gap: 6px; padding: 8px 16px 12px; overflow-x: auto; justify-content: safe center; }
.v-thumb {
  flex: none; width: 64px; height: 48px; border-radius: 6px; border: 2px solid transparent; padding: 0;
  background: #2a2e35; color: #ddd; overflow: hidden; cursor: pointer; opacity: .65;
}
.v-thumb.active, .v-thumb:hover { opacity: 1; border-color: #6f9dff; }
.v-thumb img { width: 100%; height: 100%; object-fit: cover; }
.v-thumb span { display: grid; place-items: center; font-size: 18px; }
.v-thumb small { font-size: 9px; font-weight: 700; }

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 120; display: grid; gap: 8px; }
.toast {
  background: #222; color: #fff; padding: 9px 16px; border-radius: 8px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: toast-in .18s ease-out;
}
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Пользователи ---------- */

.page { flex: 1; overflow: auto; padding: 20px; }
.page h2 { margin: 0 0 14px; font-size: 18px; }

/* ---------- Адаптив ---------- */

@media (max-width: 1100px) {
  /* Одна колонка: заголовок → поля → участники → файлы → обсуждение → даты → история */
  .tp-wrap { display: flex; flex-direction: column; align-items: stretch; }
  .tp-main, .tp-side { display: contents; }
  .tp-main > :nth-child(1) { order: 1; }
  .tp-side > :nth-child(1) { order: 2; }
  .tp-side > :nth-child(2) { order: 3; }
  .tp-main > :nth-child(2) { order: 4; }
  .tp-main > :nth-child(3) { order: 5; }
  .tp-side > :nth-child(3) { order: 6; }
  .tp-side > :nth-child(4) { order: 7; }
}
@media (max-width: 760px) {
  .tp-head { padding: 8px 12px; gap: 6px; }
  .tp-head .crumbs a, .tp-head .crumbs .sep, .tp-head .crumbs span { display: none; }
  .tp-wrap { padding: 12px; gap: 12px; }
  .tp-card { padding: 14px; }
  .tp-title { font-size: 20px; }
  .task-page.drop-active::after { left: 12px; }
  .files.big { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .v-stage { padding: 10px; }
  .v-nav { width: 36px; height: 52px; font-size: 28px; }
  .v-top .v-title span { display: none; }
  .v-top { padding: 8px 10px; gap: 6px; }
  .v-count { display: none; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-toggle { display: inline-grid; }
  .filters .search { width: 100%; }
  .column { width: 82vw; }
  .topbar h2 { max-width: 50vw; }
  .info-grid, .role-group { grid-template-columns: 1fr; gap: 4px; }
  table.tasks .hide-sm { display: none; }
  .date-filters { width: calc(100vw - 32px); }
}
