/* f.Construction — фирменный стиль: тёмный фон, фиолетовый #791EA4, оранжевый акцент, Arial */
:root {
  --bg: #1e1e1e;
  --bg-deep: #171717;
  --surface: #262626;
  --surface-2: #2e2e2e;
  --surface-3: #1f1f1f;
  --line: #353535;
  --line-strong: #444;
  --text: #ffffff;
  --text-2: #d6d6d6;
  --muted: #a8a8a8;
  --brand: #791ea4;
  --brand-hover: #8e2bbf;
  --brand-deep: #543787;
  --brand-text: #c79ae8;
  --orange: #ff8562;
  --blue: #6ab0f3;
  --green: #6fcf97;
  --radius: 14px;
  --pill: 50px;
  --font: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { color: #e2c6f5; text-decoration: underline; }
h1 { font-size: 26px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 16px; font-weight: 600; margin: 0; }
.h-sm { font-size: 14px; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 12px; }
code { background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.lead { max-width: 760px; margin-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; }
.over { color: var(--orange); }

/* ---------- Шапка ---------- */
.top { display: flex; align-items: center; gap: 12px 28px; flex-wrap: wrap; padding: 12px 24px; background: var(--bg-deep); border-bottom: 1px solid #2a2a2a; position: sticky; top: 0; z-index: 20; }
.logo { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -.4px; }
.logo span { color: #9b3fc8; }
.logo:hover { color: var(--text); text-decoration: none; }
.logo-big { font-size: 34px; }
.mainnav { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; }
.mainnav a { color: var(--text-2); padding: 8px 16px; border-radius: var(--pill); }
.mainnav a:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.mainnav a[aria-current="page"] { background: var(--brand); color: #fff; font-weight: 600; }
.usermenu { display: flex; align-items: center; gap: 14px; }
.usermenu form { margin: 0; }
.me { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.me:hover { text-decoration: none; color: var(--text); }
.ghost-link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.ghost-link:hover { color: var(--text); text-decoration: underline; }
.danger, .ghost-link.danger { color: var(--orange); }

/* ---------- Страница ---------- */
.page { padding: 24px; max-width: 1280px; margin: 0 auto; }
.page-wide { max-width: none; }
.narrow { max-width: 760px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.head-row h1 { margin: 0; }
.head-row p { margin: 4px 0 0; }
.back { display: inline-block; margin-bottom: 12px; font-size: 14px; }
.card-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 16px; }
.gap-lg { gap: 16px; }
.actions { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.actions form { margin: 0; }
.empty { text-align: center; padding: 40px 20px; }

/* ---------- Сообщения ---------- */
.flash { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash-item { padding: 12px 16px; border-radius: 12px; background: #2f2440; border: 1px solid var(--brand); }
.flash-error { background: #3a2520; border-color: var(--orange); }
.note { padding: 14px 16px; border-radius: 12px; background: #2f2440; border: 1px solid var(--brand-deep); margin-bottom: 16px; }
.note-strong { border-color: var(--orange); background: #3a2a22; line-height: 1.7; }

/* ---------- Кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 22px; border-radius: var(--pill); border: 2px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; text-decoration: none; }
.btn-outline { background: transparent; border-color: #741d9d; }
.btn-outline:hover { background: rgba(121, 30, 164, .25); }
.btn-small { min-height: 38px; padding: 0 16px; font-size: 14px; }
.btn-wide { width: 100%; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-3); color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.icon-btn:hover { color: var(--orange); border-color: var(--orange); }
.pill { min-height: 36px; padding: 0 14px; border-radius: var(--pill); border: 1px solid var(--line-strong); background: transparent; color: var(--text-2); font: inherit; font-size: 13px; cursor: pointer; }
.pill:hover { border-color: var(--brand-text); color: var(--text); }
.pill-on, .pill-on:disabled { background: var(--brand); border-color: var(--brand); color: #fff; cursor: default; }

/* ---------- Формы ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field > label, .field .label { color: var(--text-2); font-size: 13px; }
.field-check label { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; cursor: pointer; }
.req { color: var(--orange); }
.help { font-size: 12px; color: var(--muted); }
.form-error { color: var(--orange); font-size: 13px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--orange); }
input[type="text"], input[type="password"], input[type="email"], input[type="search"], input[type="date"], input[type="number"], input[type="tel"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: #1a1a1a; color: var(--text); font: inherit; font-size: 15px;
}
textarea { resize: vertical; min-height: 90px; }
input[type="date"] { color-scheme: dark; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); }
input[type="file"] { color: var(--text-2); font: inherit; font-size: 14px; max-width: 100%; }
input[type="file"]::file-selector-button { margin-right: 12px; min-height: 36px; padding: 0 16px; border-radius: var(--pill); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
input[type="file"]::file-selector-button:hover { border-color: var(--brand-text); }
input::placeholder, textarea::placeholder { color: #8a8a8a; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; max-height: 220px; overflow-y: auto; padding: 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: #1a1a1a; }
.checklist label { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; cursor: pointer; }
.inline-form { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(220px, 2fr) minmax(180px, 1.5fr) auto; gap: 12px; align-items: end; }
@media (max-width: 760px) { .inline-form { grid-template-columns: 1fr; } }

/* ---------- Вход ---------- */
.page-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; }
.auth-box .stack { margin-top: 20px; }

/* ---------- Аватары, бейджи ---------- */
.ava { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; background: var(--brand-deep); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.ava-sm { width: 24px; height: 24px; font-size: 10px; }
.ava-lg { width: 64px; height: 64px; font-size: 22px; }
.ava-empty { background: #3a3a3a; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; padding: 3px 9px; border-radius: var(--pill); border: 1px solid var(--line-strong); color: var(--text-2); text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.badge-low { color: var(--muted); }
.badge-high { color: var(--blue); border-color: rgba(106, 176, 243, .5); background: rgba(106, 176, 243, .1); }
.badge-urgent { color: var(--orange); border-color: rgba(255, 133, 98, .55); background: rgba(255, 133, 98, .12); }
.badge-head { color: var(--brand-text); border-color: rgba(199, 154, 232, .45); text-transform: none; letter-spacing: 0; }
.num { color: var(--muted); font-size: 12px; }
.status { font-size: 12px; padding: 3px 10px; border-radius: var(--pill); border: 1px solid var(--line-strong); color: var(--text-2); white-space: nowrap; }
.status-in_progress { color: var(--blue); border-color: rgba(106, 176, 243, .5); }
.status-waiting { color: var(--orange); border-color: rgba(255, 133, 98, .5); }
.status-review { color: var(--brand-text); border-color: rgba(199, 154, 232, .5); }
.status-done { color: var(--green); border-color: rgba(111, 207, 151, .5); }

/* ---------- Фильтры ---------- */
.tabs-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs-pills a { padding: 8px 16px; border-radius: var(--pill); border: 1px solid var(--line-strong); color: var(--text-2); font-size: 14px; }
.tabs-pills a:hover { text-decoration: none; border-color: var(--brand-text); color: var(--text); }
.tabs-pills a[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filters input[type="search"] { flex: 1 1 240px; max-width: 320px; min-height: 40px; border-radius: var(--pill); padding: 8px 16px; }
.filters select { flex: 0 1 200px; width: auto; max-width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--pill); font-size: 14px; }

/* ---------- Канбан ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(260px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: var(--bg-deep); border: 1px solid #2a2a2a; border-radius: var(--radius); display: flex; flex-direction: column; min-height: 200px; max-height: calc(100vh - 230px); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px; border-top: 3px solid var(--line-strong); border-radius: var(--radius) var(--radius) 0 0; }
.col-in_progress .col-head { border-top-color: var(--blue); }
.col-waiting .col-head { border-top-color: var(--orange); }
.col-review .col-head { border-top-color: var(--brand-text); }
.col-done .col-head { border-top-color: var(--green); }
.col-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.col-count { font-size: 12px; color: var(--muted); background: var(--surface); border-radius: var(--pill); padding: 2px 8px; }
.col-add { margin-left: auto; width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); border: 1px solid var(--line-strong); font-size: 18px; }
.col-add:hover { background: var(--brand); border-color: var(--brand); color: #fff; text-decoration: none; }
.cards { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 4px 10px 12px; overflow-y: auto; min-height: 80px; }
.col-foot { padding: 0 14px 12px; font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid transparent; border-radius: 12px; cursor: grab; transition: border-color .15s, transform .15s; }
.card:hover { border-color: #555; }
.card.prio-high { border-left-color: var(--blue); }
.card.prio-urgent { border-left-color: var(--orange); }
.card-link { display: flex; flex-direction: column; gap: 8px; padding: 12px; color: var(--text); }
.card-link:hover { text-decoration: none; color: var(--text); }
.card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 600; line-height: 1.3; word-break: break-word; }
.due { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.due.today { color: var(--blue); }
.due.over { color: var(--orange); font-weight: 600; }
.chip-order { align-self: flex-start; font-size: 12px; padding: 2px 9px; border-radius: var(--pill); background: rgba(121, 30, 164, .22); color: var(--brand-text); }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-2); }
.who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.counts { display: inline-flex; gap: 10px; color: var(--muted); font-size: 12px; }
.counts span { display: inline-flex; align-items: center; gap: 3px; }
.card-from { font-size: 12px; color: var(--muted); }
.card-ghost { opacity: .35; }
.card-drag { transform: rotate(1.5deg); box-shadow: 0 10px 24px rgba(0, 0, 0, .45); }
.cards.drop-hint { outline: 2px dashed rgba(199, 154, 232, .35); outline-offset: -4px; border-radius: 10px; }
@media (max-width: 760px) {
  .page { padding: 16px; }
  .top { padding: 10px 16px; }
  .me-name { display: none; }
  .top { position: static; gap: 8px 16px; }
  .mainnav a { padding: 7px 12px; }
  .board { grid-template-columns: repeat(5, 82vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; max-height: none; }
  .filters input[type="search"] { flex: 1 1 100%; max-width: none; }
  .filters select { flex: 1 1 calc(50% - 5px); min-width: 0; }
  h1 { font-size: 22px; }
}

/* ---------- Карточка задачи ---------- */
.task-layout { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.task-main { flex: 999 1 520px; min-width: 0; }
.task-side { flex: 1 1 300px; min-width: 0; max-width: 100%; }
.task-head { margin-bottom: 16px; }
.task-tags { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.task-title { text-transform: none; letter-spacing: 0; font-size: 28px; }
.prose { color: var(--text-2); word-break: break-word; }
.prose p:first-child { margin-top: 0; }
.prose p:last-child { margin-bottom: 0; }
.status-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.status-buttons form { margin: 0; }
.props { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; margin: 0 0 16px; font-size: 14px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; color: var(--text); word-break: break-word; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; max-height: 360px; overflow-y: auto; }
.history li { display: flex; flex-direction: column; gap: 2px; color: var(--text-2); }
.files { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.files li { display: flex; align-items: center; gap: 12px; }
.files form { margin: 0 0 0 auto; }
.ext { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--brand-text); }
.file-info { display: flex; flex-direction: column; min-width: 0; word-break: break-all; }
.upload-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.comments { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.comment { display: flex; gap: 12px; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { margin-bottom: 4px; }
.comment-form textarea { min-height: 80px; }

/* ---------- Структура ---------- */
.org { display: flex; flex-direction: column; gap: 14px; }
.dept { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.dept-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px 16px; flex-wrap: wrap; }
.dept-name { font-size: 17px; text-transform: uppercase; letter-spacing: .5px; }
.people { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; }
.person { display: flex; align-items: center; gap: 12px 16px; padding: 10px 0; border-top: 1px solid #303030; flex-wrap: wrap; }
.person-main { flex: 1 1 220px; min-width: 0; }
.person-name { color: var(--text); font-weight: 600; }
.person-contacts { display: flex; flex-direction: column; gap: 2px; flex: 0 1 220px; }
.person-tasks { font-size: 13px; padding: 4px 12px; border-radius: var(--pill); border: 1px solid var(--line-strong); color: var(--text-2); white-space: nowrap; }
.dept-inactive summary { cursor: pointer; color: var(--muted); }
@media (max-width: 760px) { .dept { margin-left: 0 !important; } }
.profile { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.profile-main { flex: 1 1 300px; min-width: 0; }
.profile-main h1 { text-transform: none; letter-spacing: 0; }
.profile-contacts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 14px; }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.task-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.task-list li a { flex: 1 1 200px; color: var(--text); }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line-strong); }
.table td { padding: 12px; border-bottom: 1px solid #303030; }
.row-muted td { color: var(--muted); }
.errors { color: var(--orange); }

/* ---------- Чаты ---------- */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: var(--pill); background: var(--orange); color: #1e1e1e; font-size: 12px; font-weight: 700; line-height: 1; }
.nav-badge[hidden] { display: none; }
.page-chat { padding-bottom: 0; }
.chat-layout { display: flex; gap: 16px; height: calc(100vh - var(--top-h, 63px) - 48px); min-height: 420px; }
.chat-rooms { flex: 0 0 300px; display: flex; flex-direction: column; background: var(--bg-deep); border: 1px solid #2a2a2a; border-radius: var(--radius); padding: 16px 10px; overflow-y: auto; }
.chat-rooms-title { font-size: 18px; padding: 0 8px; margin-bottom: 12px; }
.chat-rooms ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.room { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; color: var(--text); }
.room:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.room-active { background: #2f2440; }
.room-active:hover { background: #2f2440; }
.room-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--brand-text); }
.room-icon-general { background: var(--brand); border-color: var(--brand); color: #fff; font-size: 18px; }
.room-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room-title { font-weight: 600; font-size: 14px; }
.room-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-rooms-hint { padding: 12px 8px 0; margin-top: auto; }
.chat-room { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.chat-head h2 { font-size: 16px; }
.chat-head-main { min-width: 0; }
.chat-back { display: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); align-items: center; justify-content: center; color: var(--text); flex: 0 0 auto; }
.chat-back:hover { text-decoration: none; }
.chat-feed { flex: 1; overflow-y: auto; padding: 12px 18px; display: flex; flex-direction: column; }
#chat-list { margin-top: auto; }
.chat-more { align-self: center; font-size: 13px; padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: var(--pill); margin-bottom: 10px; }
.chat-empty { margin: auto; color: var(--muted); }
.chat-day { display: flex; justify-content: center; margin: 16px 0 8px; }
.chat-day span { font-size: 12px; color: var(--muted); background: var(--surface-3); border: 1px solid var(--line); padding: 3px 12px; border-radius: var(--pill); }
.msg { display: flex; gap: 10px; padding: 2px 6px; border-radius: 10px; }
.msg:hover { background: rgba(255, 255, 255, .03); }
.msg-head { margin-top: 10px; }
.msg-ava { flex: 0 0 34px; }
.msg-body { flex: 1; min-width: 0; }
.msg-meta { margin-bottom: 2px; font-size: 14px; }
.msg-mine .msg-meta b { color: var(--brand-text); }
.msg-text { color: var(--text-2); word-break: break-word; white-space: normal; }
.msg-deleted { color: var(--muted); font-style: italic; font-size: 14px; }
.msg-side { flex: 0 0 56px; display: flex; align-items: flex-start; justify-content: flex-end; gap: 6px; }
.msg-side form { margin: 0; }
.msg-time { opacity: 0; padding-top: 2px; }
.msg:hover .msg-time { opacity: 1; }
.msg-del { width: 26px; height: 26px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; opacity: 0; }
.msg:hover .msg-del, .msg-del:focus-visible { opacity: 1; }
.msg-del:hover { color: var(--orange); border-color: var(--orange); }
.msg-image { display: inline-block; margin-top: 6px; }
.msg-image img { display: block; max-width: min(360px, 100%); max-height: 280px; border-radius: 10px; border: 1px solid var(--line); }
.msg-file { display: inline-flex; align-items: center; gap: 10px; margin-top: 6px; padding: 8px 12px 8px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-3); color: var(--text); max-width: 100%; }
.msg-file:hover { border-color: var(--brand-text); text-decoration: none; color: var(--text); }
.chat-form { display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--bg-deep); }
.chat-attach { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); cursor: pointer; }
.chat-attach:hover, .chat-attach:focus-within { border-color: var(--brand-text); color: var(--text); }
.chat-attach input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.chat-input { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.chat-input textarea { min-height: 44px; max-height: 180px; resize: none; border-radius: 22px; padding: 11px 16px; line-height: 1.4; }
.chat-file-chip { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; max-width: 100%; font-size: 13px; padding: 4px 6px 4px 12px; border-radius: var(--pill); background: rgba(121, 30, 164, .25); color: var(--brand-text); }
.chat-file-chip[hidden] { display: none; }
.chat-file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-file-chip button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .3); color: #fff; cursor: pointer; }
.chat-send { flex: 0 0 auto; width: 44px; padding: 0; }
.chat-error { padding: 0 16px 10px; background: var(--bg-deep); }
.chat-error[hidden] { display: none; }
@media (max-width: 760px) {
  .page-chat { padding: 0; }
  .page-chat .flash { margin: 8px; }
  .chat-layout { height: calc(100dvh - var(--top-h, 140px)); min-height: 320px; gap: 0; }
  .chat-rooms, .chat-room { border-radius: 0; border-left: 0; border-right: 0; }
  .chat-rooms { flex: 1; }
  .chat-layout.has-room .chat-rooms { display: none; }
  .chat-layout:not(.has-room) .chat-room { display: none; }
  .chat-back { display: inline-flex; }
  .chat-feed { padding: 10px 8px; }
  .msg-side { flex-basis: 34px; }
  .msg-time { display: none; }
  .msg-del { opacity: .6; }
}

/* ---------- Темы, события задач, результат ---------- */
.rooms-group { display: flex; align-items: center; justify-content: space-between; padding: 16px 10px 6px; }
.rooms-group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 600; }
.rooms-add { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); font-size: 17px; }
.rooms-add:hover { background: var(--brand); border-color: var(--brand); color: #fff; text-decoration: none; }
.rooms-empty { padding: 4px 10px 8px; line-height: 1.5; }
.rooms-archive { padding: 12px 10px 0; }
.rooms-archive summary { cursor: pointer; margin-bottom: 6px; }
.room-icon-topic { color: var(--blue); font-size: 15px; }
.room-icon-general { background: var(--brand); border-color: var(--brand); color: #fff; font-size: 18px; }
.chat-head-main { flex: 1; }
.chat-head-action { flex: 0 0 auto; }
.chat-archived { padding: 16px 18px; border-top: 1px solid var(--line); background: var(--bg-deep); font-size: 14px; }
.event-card { margin-top: 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--line); border-left: 3px solid var(--line-strong); max-width: 640px; }
.ev-task_created .event-card { border-left-color: var(--blue); }
.ev-task_result .event-card { border-left-color: var(--brand-text); }
.ev-task_done .event-card { border-left-color: var(--green); background: rgba(111, 207, 151, .06); }
.ev-task_comment .event-card { border-left-color: #8a8a8a; }
.event-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 4px; }
.event-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; color: var(--muted); }
.ev-task_created .event-tag { color: var(--blue); }
.ev-task_result .event-tag { color: var(--brand-text); }
.ev-task_done .event-tag { color: var(--green); }
.event-task { color: var(--text); font-weight: 600; font-size: 14px; }
.event-card .msg-text { font-size: 14px; }
.attach-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attach-img { display: block; }
.attach-img img { display: block; width: 180px; height: 135px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.attach-grid .msg-file { margin-top: 0; }
.chip-result { font-size: 12px; padding: 2px 9px; border-radius: var(--pill); color: var(--orange); border: 1px solid rgba(255, 133, 98, .5); }
.card-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.card-chips .chip-order { align-self: auto; }
.result-cta { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 16px; border-radius: var(--radius); border: 1px dashed var(--line-strong); color: var(--text-2); font-size: 14px; }
.result-cta-required { border: 1px solid rgba(255, 133, 98, .6); background: rgba(255, 133, 98, .07); }
.result-box { border-color: rgba(111, 207, 151, .45); }
.result-item + .result-item { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.result-item .prose { margin-top: 4px; }
.pill-link { display: inline-flex; align-items: center; }
.pill-link:hover { text-decoration: none; }
@media (max-width: 760px) { .attach-img img { width: 140px; height: 105px; } }

/* ---------- Страница заказа ---------- */
.link-plain { color: var(--text); }
.order-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.order-head-main { min-width: 0; flex: 1 1 380px; }
.order-head .btn .nav-badge { margin-left: 8px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { margin-bottom: 0; padding: 16px 18px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 600; margin-top: 6px; }
.progress { height: 8px; border-radius: 8px; background: #383838; overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 8px; border-radius: 8px; background: var(--brand); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.task-group { margin-top: 10px; }
.task-group summary { cursor: pointer; list-style: none; }
.task-group summary::-webkit-details-marker { display: none; }
details.task-group summary .group-title::after { content: " ▸"; color: var(--muted); font-size: 12px; }
details.task-group[open] summary .group-title::after { content: " ▾"; }
.group-title { font-size: 13px; font-weight: 400; margin: 6px 0; display: flex; align-items: center; gap: 8px; }
.order-tasks { list-style: none; margin: 0 0 6px; padding: 0; }
.order-tasks li { display: grid; grid-template-columns: minmax(0, 1fr) auto 170px 60px; align-items: center; gap: 6px 14px; padding: 10px 0; border-top: 1px solid #303030; }
.ot-title { color: var(--text); font-weight: 600; min-width: 0; word-break: break-word; }
.ot-title:hover { color: var(--brand-text); }
.ot-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.ot-count { display: inline-flex; align-items: center; gap: 3px; }
.ot-who { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); min-width: 0; }
.ot-due { text-align: right; }
.chip-ok { font-size: 12px; padding: 2px 9px; border-radius: var(--pill); color: var(--green); border: 1px solid rgba(111, 207, 151, .5); white-space: nowrap; }
.tabs-small { margin: 10px 0 14px; }
.tabs-small a { padding: 6px 12px; font-size: 13px; }
.order-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.of-item { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-3); min-width: 0; }
.of-item form { margin: 0 0 0 auto; }
.of-thumb { flex: 0 0 auto; }
.of-thumb img { display: block; width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.of-item .ext:hover { text-decoration: none; }
.of-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.of-name { color: var(--text); word-break: break-all; font-size: 14px; }
.of-src-result a, .of-src-result { color: var(--green); }
.of-src-docs { color: var(--brand-text); }
.order-upload { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.order-desc { font-size: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.people-mini, .chat-mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.people-mini li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.people-mini a { color: var(--text); }
.chat-mini { margin-top: 10px; }
.chat-mini li { display: flex; flex-direction: column; gap: 2px; color: var(--text-2); word-break: break-word; }
.mini-ev { color: var(--brand-text); font-weight: 600; font-size: 13px; }
.nowrap { white-space: nowrap; }
@media (max-width: 760px) {
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 20px; }
  .order-tasks li { grid-template-columns: minmax(0, 1fr) auto; }
  .ot-title { order: 1; }
  .ot-who { order: 2; }
  .ot-meta { order: 3; justify-content: flex-start; }
  .ot-meta:empty { display: none; }
  .ot-due { order: 4; }
  .order-files { grid-template-columns: 1fr; }
}
