/* ============================================================
   Team CRM — интерфейс v0.3 (docs/DESIGN.md)
   Токены → база → элементы управления → компоновка → экраны
   ============================================================ */
:root {
  --bg: #f7f7f8; --surface: #fff; --surface-2: #f3f4f6; --surface-3: #e9eaee; --sidebar: #fbfbfc;
  --border: #e4e5e9; --border-strong: #d3d5db; --text: #17181c; --text-2: #3b3f48; --muted: #5f6573;
  --accent: #4f5bc4; --accent-hover: #4350b3; --accent-weak: #eef0fd; --on-accent: #fff;
  --danger: #c62828; --danger-weak: #fdecec; --danger-strong: #c62828; --ok: #15803d; --warn: #b45309;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06); --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
  --shadow: 0 12px 32px rgba(16, 24, 40, .14); --radius: 12px; --radius-sm: 8px;
  --s-new: #6b7280; --s-in_progress: #d97706; --s-review: #2563eb; --s-done: #16a34a; --s-cancelled: #9ca3af;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* тёмная тема: по системе (если не выбрана светлая вручную) или принудительно через data-theme="dark" */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #16181d; --surface-2: #1d2026; --surface-3: #272b33; --sidebar: #121418;
    --border: #2a2e36; --border-strong: #3a3f4a; --text: #e8e9ed; --text-2: #c4c7cf; --muted: #9aa1ae;
    --accent: #8b93f0; --accent-hover: #9ea5f4; --accent-weak: #262a48; --on-accent: #0f1020;
    --danger: #f87171; --danger-weak: #3a1f22; --danger-strong: #b91c1c; --ok: #4ade80; --warn: #fbbf24;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 4px 12px rgba(0, 0, 0, .45); --shadow: 0 12px 32px rgba(0, 0, 0, .55);
    --s-new: #9ca3af; --s-in_progress: #f59e0b; --s-review: #60a5fa; --s-done: #22c55e; --s-cancelled: #6b7280;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #16181d; --surface-2: #1d2026; --surface-3: #272b33; --sidebar: #121418;
  --border: #2a2e36; --border-strong: #3a3f4a; --text: #e8e9ed; --text-2: #c4c7cf; --muted: #9aa1ae;
  --accent: #8b93f0; --accent-hover: #9ea5f4; --accent-weak: #262a48; --on-accent: #0f1020;
  --danger: #f87171; --danger-weak: #3a1f22; --danger-strong: #b91c1c; --ok: #4ade80; --warn: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 4px 12px rgba(0, 0, 0, .45); --shadow: 0 12px 32px rgba(0, 0, 0, .55);
  --s-new: #9ca3af; --s-in_progress: #f59e0b; --s-review: #60a5fa; --s-done: #22c55e; --s-cancelled: #6b7280;
  color-scheme: dark;
}

/* ---------- база ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); font-feature-settings: "cv11", "ss01"; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.ic { flex: none; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font: 500 13px ui-monospace, Consolas, monospace; }

/* ---------- кнопки: secondary (по умолчанию), primary, ghost, danger, icon ---------- */
button, .btn {
  font: 500 13px/1 var(--font); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm); white-space: nowrap; text-decoration: none;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:active, .btn:active { background: var(--surface-3); }
button:focus-visible, .btn:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }
button:disabled:hover { background: var(--surface); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:disabled:hover { background: var(--accent); }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); color: var(--text); }
button.danger, .btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border-strong)); }
button.danger:hover { background: var(--danger-weak); }
button.danger.solid { background: var(--danger-strong); border-color: var(--danger-strong); color: #fff; }
button.danger.solid:hover { filter: brightness(1.08); background: var(--danger-strong); }
button.ghost.danger { border-color: transparent; }
.icon-btn { width: 32px; padding: 0; flex: none; }
.btn-sm, button.btn-sm { height: 28px; padding: 0 8px; font-size: 12px; }
.icon-btn.btn-sm { width: 28px; padding: 0; }
.kbd { font: 500 11px var(--font); color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; margin-left: 2px; }
button.primary .kbd { color: inherit; border-color: color-mix(in srgb, var(--on-accent) 40%, transparent); }

/* ---------- поля ---------- */
input, select, textarea {
  font: 14px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0 10px; height: 34px; width: 100%; transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 72px; line-height: 1.45; }
select { appearance: none; padding-right: 30px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--border-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); flex: none; margin: 0; }
input[type=color] { padding: 2px; width: 40px; flex: none; cursor: pointer; }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
label.field, div.field { display: block; margin-bottom: 14px; }
label.field > span, .field .lbl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; padding: 4px 0; font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
.input-icon { position: relative; display: inline-flex; align-items: center; }
.input-icon .ic { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 32px; }

/* сегменты в стиле Linear: «таблетка» с выделенным сегментом */
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; overflow-x: auto; scrollbar-width: none; flex: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: var(--muted); font-weight: 500; }
.seg button:hover { background: transparent; color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12), 0 0 0 1px var(--border); }
:root[data-theme="dark"] .seg button.on { background: var(--surface-3); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button.on { background: var(--surface-3); } }
.seg button .n { color: var(--muted); font-weight: 400; }
.seg-icons button { padding: 0 8px; }

/* ---------- значки, аватары, статусы ---------- */
.av { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10.5px; font-weight: 600; color: #fff; flex: none; letter-spacing: 0; }
.avs { display: inline-flex; } .avs .av { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); } .avs .av:first-child { margin-left: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; height: 22px; padding: 0 8px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.badge.overdue { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: var(--danger-weak); }
.st-ic { flex: none; display: block; }
.st-ic.st-new, .st-new .dot { color: var(--s-new); background-color: transparent; }
.st-ic.st-in_progress { color: var(--s-in_progress); } .st-ic.st-review { color: var(--s-review); }
.st-ic.st-done { color: var(--s-done); } .st-ic.st-cancelled { color: var(--s-cancelled); }
.st-done .dot { background: var(--s-done); } .st-cancelled .dot { background: var(--s-cancelled); }
.pr { display: inline-flex; align-items: center; gap: 6px; }
.pr-ic { flex: none; display: block; color: var(--muted); }
.pr-ic.pr-high { color: var(--text-2); } .pr-ic.pr-urgent { color: var(--danger); }
.pr-urgent { color: var(--danger); font-weight: 500; }
.overdue { color: var(--danger); font-weight: 500; }

/* ---------- экраны входа ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%), var(--bg); }
.auth form { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-md); }
.auth h1 { font-size: 20px; margin-bottom: 18px; }
.auth button.primary { width: 100%; height: 38px; font-size: 14px; }
.auth .links { text-align: center; margin: 16px 0 0; font-size: 13px; }
.auth .links a { display: inline-flex; align-items: center; gap: 6px; }
.error { color: var(--danger); background: var(--danger-weak); padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; }
.notice { color: var(--text); background: var(--accent-weak); padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; }

/* ---------- компоновка ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; padding: 4px 8px 14px; min-width: 0; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; font-size: 13.5px; }
.nav a .ic { color: var(--muted); }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--surface-3); color: var(--text); }
.nav a.active .ic { color: var(--accent); }
.nav .section { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 16px 10px 6px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.theme-row { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 10px; }
.me { border-top: 1px solid var(--border); padding: 10px 0 0 6px; display: flex; align-items: center; gap: 8px; }
.me .who { flex: 1; min-width: 0; color: var(--text); }
.me .who:hover { text-decoration: none; }
.me .who b, .me .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who b { font-weight: 600; font-size: 13px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.topbar h1 { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 20px 24px 32px; flex: 1; min-width: 0; }
.menu-btn { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s, visibility .2s; visibility: hidden; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); visibility: visible; }
  .sidebar.open + .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 49; background: rgba(10, 12, 20, .4); }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 0 12px; }
}
@media (max-width: 560px) { .topbar .new-label { display: none; } .topbar [data-new-task] { width: 32px; padding: 0; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card > h2:first-child { margin-bottom: 4px; }
.card-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .ic { margin: 0 auto 10px; opacity: .7; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.back:hover { color: var(--text); text-decoration: none; }

/* ---------- счётчики ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { height: auto; justify-content: flex-start; font: inherit; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s; text-align: left; }
.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.stat .stat-ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.stat .stat-txt { min-width: 0; }
.stat .stat-txt span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat b { display: block; font-size: 20px; font-weight: 600; line-height: 1.2; }
.stat.red .stat-ic { background: var(--danger-weak); color: var(--danger); } .stat.red b { color: var(--danger); }
.stat.amber .stat-ic { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); } .stat.amber b { color: var(--warn); }
.stat.green .stat-ic { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); } .stat.green b { color: var(--ok); }
.stat.blue .stat-ic { background: var(--accent-weak); color: var(--accent); }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .stat { padding: 10px 12px; gap: 10px; } .stat .stat-ic { width: 28px; height: 28px; } }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--surface-2); }
td .cell-title { font-weight: 500; }
.counts { display: inline-flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; }
.counts > span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- раздел «Задачи»: шапка, фильтры ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters > select, .filters > input, .filters > .input-icon { width: auto; }
.filters select { max-width: 220px; }
.filters .input-icon input { width: 200px; }
.filters .check { height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-sm); }
.filters .check:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); }
@media (max-width: 700px) { .seg-layout .lay-label { display: none; } .seg-layout button { padding: 0 10px; } .cal-hint { display: none !important; } }
@media (max-width: 560px) {
  .filters .input-icon, .filters .input-icon input, .filters select { width: 100%; max-width: none; }
  .filters .input-icon { flex: 1 1 100%; }
}

/* ---------- список задач (группы по статусу, как в Plane) ---------- */
.tl { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.tl-group + .tl-group { border-top: 1px solid var(--border); }
.tl-ghead { display: flex; width: 100%; height: 38px; justify-content: flex-start; gap: 8px; padding: 0 14px; border: 0; border-radius: 0; box-shadow: none;
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 13px; }
.tl-ghead:hover { background: var(--surface-3); }
.tl-ghead .chev { color: var(--muted); transition: transform .15s; }
.tl-group.collapsed .chev { transform: rotate(-90deg); }
.tl-group.collapsed .tl-rows { display: none; }
.tl-ghead .n { color: var(--muted); font-weight: 500; }
.tl-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 14px; border-top: 1px solid var(--border); cursor: pointer; }
.tl-row:hover { background: var(--surface-2); }
.tl-row:focus-visible { outline-offset: -2px; }
.tl-id { color: var(--muted); font-size: 12px; width: 40px; flex: none; font-variant-numeric: tabular-nums; }
.tl-title { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-chips { display: flex; gap: 6px; align-items: center; flex: none; }
.chip-sm { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; color: var(--text-2); background: var(--surface); white-space: nowrap; }
.chip-sm.overdue { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.chip-sm.icon-only { padding: 0 5px; }
.tl-row .avs { flex: none; min-width: 24px; justify-content: flex-end; }
@media (max-width: 700px) {
  .tl-row { flex-wrap: wrap; row-gap: 6px; padding: 10px 12px; }
  .tl-id { display: none; }
  .tl-title { flex: 1 1 calc(100% - 60px); white-space: normal; }
  .tl-chips { flex: 1 1 auto; flex-wrap: wrap; padding-left: 24px; }
}

/* ---------- доска ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)) auto; gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.kb-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; min-width: 0; transition: background .12s, border-color .12s; }
.kb-col.over { border-color: var(--accent); background: var(--accent-weak); }
.kb-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-size: 13px; }
.kb-head b { font-weight: 600; }
.kb-count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kb-list { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kb-empty { text-align: center; padding: 18px 0; }
.kb-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; box-shadow: var(--shadow-sm); transition: box-shadow .12s, border-color .12s; }
.kb-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.kb-card[draggable=true] { cursor: grab; }
.kb-card.dragging { opacity: .4; }
.kb-card.pending { opacity: .6; pointer-events: none; }
.kb-title { display: flex; gap: 6px; align-items: flex-start; }
.kb-title b { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 500; font-size: 13.5px; }
.kb-id { color: var(--muted); font-size: 11.5px; }
.kb-move { margin: -4px -6px 0 0; color: var(--muted); }
.kb-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.kb-meta:empty { display: none; }
.kb-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.kb-counts { display: inline-flex; gap: 10px; color: var(--muted); font-size: 12px; }
.kb-counts > span { display: inline-flex; align-items: center; gap: 4px; }
.kb-col.deny { border-color: var(--danger); background: var(--danger-weak); cursor: not-allowed; }
.kb-deny-hint { display: none; color: var(--danger); padding: 0 6px 8px; }
.kb-col.deny .kb-deny-hint { display: block; }
.kb-col.collapsed .kb-deny-hint { display: none !important; }
.kb-col.collapsed { width: 44px; cursor: pointer; padding: 8px 0; }
.kb-col.collapsed .kb-list { display: none; }
.kb-col.collapsed .kb-head { flex-direction: column; writing-mode: vertical-rl; padding: 4px 0; margin: 0 auto; }
.kb-col.collapsed .kb-head .st-ic { transform: rotate(90deg); }
.kb-col.collapsed .kb-count { margin: 8px 0 0; }
.kb-col.collapsed.over .kb-list { display: none; }
.kb-col:not(.collapsed)[data-col=cancelled] { width: 260px; }
@media (max-width: 700px) {
  /* на телефоне колонки листаются по горизонтали внутри доски */
  .board { grid-template-columns: repeat(4, 82%) auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 8px; scroll-padding: 0 16px; }
  .kb-col { scroll-snap-align: start; }
  .kb-col:not(.collapsed)[data-col=cancelled] { width: calc(82vw - 26px); }
}

/* ---------- всплывающие меню ---------- */
.popover { position: fixed; z-index: 90; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; min-width: 200px; max-width: min(320px, calc(100vw - 16px)); }
.menu { display: flex; flex-direction: column; gap: 1px; }
.menu-head { font-size: 12px; color: var(--muted); padding: 6px 8px 4px; white-space: normal; }
.menu button { justify-content: flex-start; height: auto; min-height: 32px; padding: 6px 8px; border: 0; box-shadow: none; background: transparent; flex-wrap: wrap; text-align: left; white-space: normal; }
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--surface-2); outline: none; }
.menu button.current { font-weight: 600; }
.menu-label { display: inline-flex; align-items: center; gap: 8px; flex: 1; }
.menu-check { color: var(--accent); }
.menu-note { flex-basis: 100%; font-size: 11.5px; color: var(--muted); font-weight: 400; padding-left: 22px; }
.pop-form { padding: 8px; display: flex; flex-direction: column; gap: 8px; min-width: 240px; }
.pop-form .row { justify-content: flex-end; }

/* ---------- календарь ---------- */
.cal-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); }
.cal-hint { display: inline-flex; align-items: center; gap: 6px; }
.fc { --fc-border-color: var(--border); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--surface-2); --fc-today-bg-color: var(--accent-weak); --fc-list-event-hover-bg-color: var(--surface-2);
  --fc-neutral-text-color: var(--muted); --fc-highlight-color: var(--accent-weak); --fc-non-business-color: var(--surface-2); --fc-now-indicator-color: var(--danger);
  --fc-more-link-bg-color: var(--surface-2); --fc-more-link-text-color: var(--text); --fc-button-text-color: var(--text); --fc-button-bg-color: var(--surface);
  --fc-button-border-color: var(--border-strong); --fc-button-hover-bg-color: var(--surface-2); --fc-button-hover-border-color: var(--border-strong);
  --fc-button-active-bg-color: var(--surface-3); --fc-button-active-border-color: var(--border-strong); color: var(--text); font-size: 13px; }
.fc a, .fc .fc-col-header-cell-cushion, .fc .fc-daygrid-day-number, .fc .fc-list-day-text, .fc .fc-list-day-side-text { color: var(--text); text-decoration: none; }
.fc .fc-col-header-cell-cushion { font-weight: 500; color: var(--muted); font-size: 12px; text-transform: capitalize; }
.fc .fc-list-empty, .fc .fc-list-day-cushion, .fc .fc-popover-header { background: var(--surface-2); color: var(--text); }
.fc .fc-popover { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
.fc .fc-list-event:hover td { background: var(--surface-2); }
.fc .fc-day-other .fc-daygrid-day-top { opacity: .5; }
.fc .fc-button { background: var(--surface); color: var(--text); border-color: var(--border-strong); text-transform: none; font: 500 13px var(--font); height: 32px; padding: 0 10px; box-shadow: var(--shadow-sm); }
.fc .fc-button:hover { background: var(--surface-2); color: var(--text); }
.fc .fc-button:focus { box-shadow: none; }
.fc .fc-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); font-weight: 600; }
.fc .fc-button .fc-icon { font-size: 1.2em; }
.fc .fc-toolbar-title { font-size: 16px; font-weight: 600; }
.fc .fc-toolbar-title::first-letter { text-transform: uppercase; }
.fc-event { cursor: pointer; border-radius: 6px; padding: 1px 4px; font-size: 12px; }
.fc-event.is-done { opacity: .55; text-decoration: line-through; }
.fc-ev { display: flex; align-items: center; gap: 4px; overflow: hidden; }
.fc-ev .pr-ic { color: inherit; }
.fc-ev-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.fc-daygrid-event .fc-ev { color: var(--text); }
.fc-daygrid-event .fc-ev-title, .fc-timegrid-event .fc-ev-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-list-event .fc-ev { overflow: visible; }
.fc-list-event .fc-ev-title { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 700px) { .fc .fc-toolbar { flex-direction: column; gap: 8px; } .cal-wrap { padding: 10px; } }

/* ---------- панель задачи (peek) ---------- */
.panel-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 20, .3); z-index: 60; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface); z-index: 61; box-shadow: var(--shadow);
  border-left: 1px solid var(--border); display: flex; flex-direction: column; animation: slidein .18s ease-out; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.panel-top { display: flex; align-items: center; gap: 6px; height: 48px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--border); flex: none; }
.panel-top .crumb { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-width: 0; }
.panel-body { flex: 1; overflow-y: auto; padding: 20px 24px 24px; }
.panel-title { font-size: 20px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; border: 1px solid transparent; padding: 4px 6px; margin: -5px -7px 12px; border-radius: 6px; overflow-wrap: anywhere; }
.panel-title[contenteditable=true]:hover { border-color: var(--border); }
.panel-title[contenteditable=true]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.panel-meta { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.props-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.prop { height: 28px; padding: 0 9px; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-2); border-color: var(--border); box-shadow: none; max-width: 100%; }
.prop:disabled { opacity: 1; cursor: default; background: var(--surface); }
.prop:disabled:hover { background: var(--surface); }
.prop .lbl { color: var(--muted); font-weight: 400; }
.prop.overdue { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.prop .avs .av { width: 18px; height: 18px; font-size: 8.5px; }
.prop.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-weak); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.sec-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin: 22px 0 8px; color: var(--text); }
.sec-title .spacer + button { margin-right: -6px; }
.desc { white-space: pre-wrap; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); min-height: 44px; overflow-wrap: anywhere; }
.desc.editable { cursor: text; }
.desc.editable:hover { border-color: var(--border-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; }
.chip button { width: 20px; height: 20px; padding: 0; border: 0; background: none; box-shadow: none; color: var(--muted); }
.chip button:hover { color: var(--text); background: var(--surface-3); }
/* лента активности */
.feed { display: flex; flex-direction: column; gap: 2px; }
.ev-sys { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; font-size: 12.5px; color: var(--muted); }
.ev-sys .ev-ic { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.ev-sys .ev-txt { padding-top: 3px; min-width: 0; overflow-wrap: anywhere; }
.ev-sys b { color: var(--text-2); font-weight: 500; }
.ev-sys .badge { height: 20px; font-size: 11.5px; }
.ev-comment { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 6px 0; background: var(--surface); box-shadow: var(--shadow-sm); }
.ev-comment .ev-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.ev-comment .ev-head b { color: var(--text); font-weight: 600; }
.ev-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); background: var(--surface-2); }
.file:hover { border-color: var(--border-strong); text-decoration: none; }
.file img { max-width: 200px; max-height: 130px; border-radius: 6px; display: block; }
.file.thumb { height: auto; padding: 3px; }
.composer { border-top: 1px solid var(--border); padding: 12px 16px; background: var(--surface); flex: none; }
.composer-box { border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.composer textarea { border: 0; box-shadow: none; min-height: 52px; background: transparent; resize: none; }
.composer textarea:focus { box-shadow: none; }
.composer-foot { display: flex; align-items: center; gap: 6px; padding: 4px 6px 6px; }
.composer-foot .files-label { font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.composer.drag .composer-box { border-style: dashed; border-color: var(--accent); }
@media (max-width: 600px) { .panel-body { padding: 16px; } .panel-top { padding: 0 8px 0 16px; } .composer { padding: 10px 12px; } }

/* ---------- модальные окна ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 20, .45); z-index: 80; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: min(620px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal header { padding: 14px 14px 0 20px; display: flex; align-items: center; gap: 8px; }
.modal header h2 { margin: 0; flex: 1; font-size: 16px; }
.modal .body { padding: 16px 20px; overflow-y: auto; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* выбор людей */
.picker { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.picker input.search { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; }
.picker .list { max-height: 190px; overflow-y: auto; padding: 4px 8px; }
.picker .list .check { display: flex; }
.picker .sel { padding: 8px 8px 0; }

/* напоминания */
.rem-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

/* ---------- уведомления ---------- */
.bell { position: relative; }
.bell .count { position: absolute; top: 1px; right: 1px; background: var(--danger-strong); color: #fff; border-radius: 99px; font-size: 10px; font-weight: 600; min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 4px; pointer-events: none; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); width: min(380px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 40; overflow: hidden; }
.dropdown .head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); }
.dropdown .items { max-height: 420px; overflow-y: auto; }
.notif { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--surface-2); }
.notif .n-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: transparent; }
.notif.unread .n-dot { background: var(--accent); }
.notif .meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- всплывающие сообщения ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 400px; cursor: pointer; animation: slidein .2s; font-size: 13.5px; }
.toast .ic { margin-top: 1px; opacity: .85; }
.toast.err { background: var(--danger-strong); color: #fff; }

/* ---------- роли ---------- */
.roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.role-card { padding: 16px; }
.role-card .role-name { display: flex; gap: 8px; margin-bottom: 12px; }
.role-card .role-name input[name=name] { font-weight: 600; }
.role-card .perm { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: 13px; cursor: pointer; }
.role-card .perm input { margin-top: 2px; }
.role-count { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.role-card .role-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ---------- брендинг ---------- */
.brand i, .auth-brand i, .logo-preview i { border-radius: 8px; background: var(--accent); display: inline-grid; place-items: center; color: var(--on-accent); font-style: normal; font-weight: 700; flex: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-logo { border-radius: 8px; object-fit: contain; flex: none; background: var(--surface); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand i { border-radius: 12px; }
.auth-brand b { display: block; font-size: 15px; font-weight: 600; }
.auth-brand span { display: block; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.logo-edit { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.logo-preview { width: 88px; height: 88px; border: 1px dashed var(--border-strong); border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); }
.logo-preview i { border-radius: 14px; }
.form-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

/* ---------- сотрудники ---------- */
.perm-list { margin: 4px 0 6px; padding-left: 18px; }
.perm-list li { margin: 1px 0; }
.creds { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; background: var(--surface-2); padding: 14px; border-radius: 10px; align-items: center; border: 1px solid var(--border); }
.creds span { color: var(--muted); font-size: 13px; }
.creds code { font: 600 14px ui-monospace, Consolas, monospace; user-select: all; word-break: break-all; }
.user-cell { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.user-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.user-head .who { flex: 1; min-width: 220px; }
.user-head h2 { margin-bottom: 6px; font-size: 20px; }
.user-head .facts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.user-head .facts span { display: inline-flex; align-items: center; gap: 6px; }
.av-lg { width: 64px; height: 64px; font-size: 22px; }
.stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.seg-wrap { flex-wrap: wrap; }
@media (max-width: 1100px) { .stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .user-head .actions-col { width: 100%; } }

/* ---------- сенсорные экраны: цели касания не меньше 40px ---------- */
@media (pointer: coarse) {
  button, .btn, select, input:not([type=checkbox]):not([type=radio]):not([type=color]), .nav a, .fc .fc-button { min-height: 40px; }
  .icon-btn, .icon-btn.btn-sm, .kb-move, .chip button { min-width: 40px; min-height: 40px; }
  .seg button { min-height: 40px; min-width: 40px; }
  .topbar [data-new-task] { width: 40px; }
  .back { min-height: 40px; }
  .me .who { min-height: 40px; display: flex; flex-direction: column; justify-content: center; }
  .seg { padding: 2px; }
  .check { min-height: 40px; }
  .check input[type=checkbox], .role-card .perm input { width: 20px; height: 20px; }
  .fc .fc-button { min-width: 40px; }
  input[type=color] { height: 40px; }
  .role-card .perm { min-height: 40px; align-items: center; }
  .role-card .perm input { margin-top: 0; }
  .notif { padding: 12px 14px; }
  .kb-move { margin: -10px -8px -6px 0; }
  .prop { min-height: 40px; }
  .chip { height: 40px; }
  .menu button { min-height: 40px; }
  .tl-ghead { height: 44px; }
}

   Клиенты (.cl-*) и чат (.chat-*) — модули v0.4
   ============================================================ */
/* ---------- клиенты: список ---------- */
.cl-st .dot { background: var(--s-new); }
.cl-st-in_progress .dot { background: var(--s-in_progress); }
.cl-st-client .dot { background: var(--s-done); }
.cl-st-rejected .dot { background: var(--s-cancelled); }
.cl-st-rejected { color: var(--muted); }
.cl-badge-inline { display: inline-flex; align-items: center; gap: 6px; }
.cl-badge-inline .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cl-nowrap { white-space: nowrap; }
.cl-revoked td { color: var(--muted); }
.cl-revoked .cell-title { text-decoration: line-through; }
@media (max-width: 700px) { .cl-hide-sm { display: none; } }

/* ---------- клиенты: карточка ---------- */
.cl-head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.cl-head-main { flex: 1; min-width: 220px; }
.cl-head h2 { font-size: 20px; margin-bottom: 8px; overflow-wrap: anywhere; }
.cl-page { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.cl-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cl-card { padding: 16px; }
.cl-card h3 { margin-bottom: 10px; }
.cl-facts { display: grid; grid-template-columns: 20px 1fr; gap: 8px; margin: 0; font-size: 13.5px; }
.cl-facts dt { color: var(--muted); padding-top: 2px; }
.cl-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.cl-notes { margin-top: 12px; font-size: 13px; }
.cl-tasks { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }
.cl-task { justify-content: flex-start; height: auto; min-height: 36px; padding: 6px 8px; gap: 8px; white-space: normal; text-align: left; font-weight: 400; }
.cl-task-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cl-wall { min-width: 0; }
.cl-composer { background: var(--surface); margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.cl-composer .seg button { display: inline-flex; gap: 5px; align-items: center; }
.cl-composer .files-label { flex: 1; }
.cl-feed .ev-comment { background: var(--surface); }
.cl-ev-call { border-left: 3px solid var(--accent); }
.cl-sys-av { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface-3); color: var(--muted); flex: none; }
.cl-code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; margin: 0 0 10px; }
.cl-key code { font-size: 13px; }
@media (max-width: 900px) { .cl-page { grid-template-columns: 1fr; } }

/* ---------- чат ---------- */
.nav a .chat-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; line-height: 1; }
.chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); margin: -20px -24px -32px; height: calc(100vh - 52px); height: calc(100dvh - 52px); background: var(--surface); }
.chat-side { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--sidebar); }
.chat-side-head { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border); }
.chat-search { flex: 1; min-width: 0; }
.chat-search input { width: 100%; }
.chat-list { flex: 1; overflow-y: auto; padding: 4px; }
.chat-list .empty { padding: 32px 12px; }
.chat-list-sep { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 12px 10px 4px; }
.chat-item { width: 100%; height: auto; min-height: 56px; padding: 8px 10px; justify-content: flex-start; gap: 10px; border: 0; box-shadow: none; background: transparent; text-align: left; font-weight: 400; border-radius: var(--radius-sm); }
.chat-item:hover { background: var(--surface-2); }
.chat-item.on { background: var(--surface-3); }
.chat-item .av { width: 36px; height: 36px; font-size: 13px; }
.chat-item-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-item-txt > b, .chat-item-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-top, .chat-item-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-item-top b { flex: 1; min-width: 0; }
.chat-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; flex: none; }
.chat-group-av { background: var(--surface-3); color: var(--text-2); }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-empty { margin: auto; }
.chat-head { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.chat-head .av { width: 32px; height: 32px; font-size: 12px; }
.chat-head-txt { min-width: 0; display: flex; flex-direction: column; }
.chat-head-txt b, .chat-head-txt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-back { display: none; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; background: var(--bg); }
.chat-older { text-align: center; padding-bottom: 8px; }
.chat-up { transform: rotate(180deg); }
.chat-day { text-align: center; margin: 14px 0 8px; }
.chat-day span { font-size: 11.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 2px 10px; }
.chat-msg { display: flex; align-items: flex-end; gap: 4px; max-width: min(640px, 82%); margin-top: 8px; flex-wrap: wrap; }
.chat-msg.grouped { margin-top: 2px; }
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-author { flex-basis: 100%; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 0 0 2px 12px; }
.chat-bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 7px 12px 5px; min-width: 64px; max-width: 100%; box-shadow: var(--shadow-sm); }
.chat-msg.mine .chat-bubble { background: var(--accent-weak); border-color: color-mix(in srgb, var(--accent) 25%, var(--border)); }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-bubble .files { margin-top: 6px; }
.chat-meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.chat-deleted { display: inline-flex; align-items: center; gap: 6px; font-style: italic; color: var(--muted); font-size: 13px; }
.chat-more { opacity: 0; color: var(--muted); }
.chat-msg:hover .chat-more, .chat-more:focus-visible { opacity: 1; }
.chat-composer { border-top: 1px solid var(--border); padding: 10px 16px 12px; background: var(--surface); flex: none; }
.chat-composer textarea { border: 0; box-shadow: none; min-height: 40px; max-height: 160px; background: transparent; resize: none; }
.chat-composer textarea:focus { box-shadow: none; }
.chat-composer.drag .composer-box { border-style: dashed; border-color: var(--accent); }
.chat-editing { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--accent); padding: 0 2px 6px; }
@media (max-width: 860px) { .chat { margin: -16px; } }
/* на мобильном — два экрана: список диалогов или переписка */
@media (max-width: 700px) {
  .chat { grid-template-columns: 1fr; }
  .chat.has-conv .chat-side { display: none; }
  .chat:not(.has-conv) .chat-main { display: none; }
  .chat-back { display: inline-flex; }
  .chat-head { padding: 0 8px; }
  .chat-msgs { padding: 12px; }
  .chat-msg { max-width: 92%; }
  .chat-composer { padding: 8px 10px 10px; }
}
@media (pointer: coarse) { .chat-more { opacity: 1; } .chat-item { min-height: 60px; } }
=======
/* ============ v0.4: меньше рамок, страница задачи, фильтр, список дня ============ */
.tl { border: 0; box-shadow: none; background: transparent; border-radius: 0; }
.tl-ghead { background: transparent; height: 34px; padding: 0 4px; font-size: 12.5px; color: var(--muted); }
.tl-ghead:hover { background: transparent; color: var(--text); }
.tl-group + .tl-group { border-top: 0; margin-top: 12px; }
.tl-row { border-top: 0; border-bottom: 1px solid var(--border); padding: 6px 4px; border-radius: 0; }
.tl-row:hover { background: var(--surface-2); }
.chip-sm { border: 0; background: transparent; padding: 0 4px; color: var(--muted); }
.chip-sm.overdue { color: var(--danger); }
.kb-col { background: transparent; border-color: transparent; }
.kb-card { box-shadow: none; }
/* фильтр */
.toolbar .on .filter-n, .filter-n:not(:empty) { margin-left: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-size: 11px; display: inline-grid; place-items: center; }
.filter-n:empty { display: none; }
.search-sm input { width: 180px; height: 32px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.active-filters:empty { display: none; }
.fchip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 2px 0 10px; border-radius: 99px; background: var(--accent-weak); color: var(--text); font-size: 12.5px; }
.fchip button { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 99px; background: transparent; box-shadow: none; color: var(--muted); }
.link-btn { border: 0; background: none; box-shadow: none; color: var(--accent); height: 26px; padding: 0 6px; font-size: 12.5px; }
.overdue-link { display: inline-flex; align-items: center; gap: 6px; color: var(--danger); font-size: 13px; font-weight: 500; }
.pop-filter { min-width: 260px; padding: 8px; }
.fp-sec + .fp-sec { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.fp-title { font-size: 12px; color: var(--muted); font-weight: 500; margin: 2px 4px 4px; }
.fp-opt { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.fp-opt:hover { background: var(--surface-2); }
.pop-wide { width: min(440px, calc(100vw - 16px)); max-width: none; }
.pop-title { font-weight: 600; font-size: 13px; }
/* страница задачи */
.task-page { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 40px; align-items: start; max-width: 1240px; }
.tp-top { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.tp-top .back { margin: 0; }
.tp-title { font-size: 24px; font-weight: 600; line-height: 1.3; margin: 0 -6px 4px; padding: 2px 6px; border-radius: 6px; border: 1px solid transparent; overflow-wrap: anywhere; }
.tp-title[contenteditable=true]:hover { border-color: var(--border); }
.tp-title[contenteditable=true]:focus { outline: none; border-color: var(--accent); }
.tp-meta { margin-bottom: 16px; }
.props-more { margin-top: -8px; }
.tp-sec { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin: 28px 0 10px; color: var(--text); }
.tp-desc { white-space: pre-wrap; overflow-wrap: anywhere; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; min-height: 40px; }
.tp-desc.editable { cursor: text; }
.tp-desc.editable:hover { background: var(--surface-2); }
.materials { border-radius: 10px; }
.materials.drag { outline: 2px dashed var(--accent); outline-offset: 4px; }
.mat-empty { padding: 14px; border: 1px dashed var(--border-strong); border-radius: 10px; }
.mat-grid, .thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 128px)); gap: 8px; margin-bottom: 8px; }
.thumbs { grid-template-columns: repeat(auto-fill, minmax(72px, 96px)); margin-top: 6px; }
.thumb { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.file-ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flip-v { transform: rotate(180deg); }
.tp-side { position: sticky; top: 72px; display: flex; flex-direction: column; max-height: calc(100vh - 92px); }
.tp-side .tp-sec { margin-top: 0; }
.tp-side .feed { flex: 1; overflow-y: auto; min-height: 120px; padding-right: 4px; }
.tp-side .composer { border-top: 0; padding: 10px 0 0; background: transparent; }
.ev-comment { box-shadow: none; background: var(--surface-2); border: 0; }
.ev-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
@media (max-width: 900px) {
  .task-page { grid-template-columns: 1fr; gap: 24px; }
  .tp-side { position: static; max-height: none; }
  .tp-side .feed { overflow: visible; }
  .tp-title { font-size: 20px; }
}
/* форма «Дополнительно» */
details.more summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; list-style: none; margin-bottom: 10px; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary .chev { transform: rotate(90deg); }
/* календарь: события в одну строку, список дня справа */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.cal-main { min-width: 0; }
.fc .fc-daygrid-day-frame { min-height: 96px; }
.fc .fc-daygrid-event { overflow: hidden; margin: 1px 2px; }
.fc .fc-daygrid-block-event { background: var(--surface-2) !important; border-color: var(--border) !important; }
.fc .fc-daygrid-event .fc-ev { color: var(--text); min-width: 0; }
.fc-ev-time { color: var(--muted); flex: none; }
.fc .fc-daygrid-day.is-selected { background: var(--accent-weak); }
.fc .fc-daygrid-day { cursor: pointer; }
.fc .fc-daygrid-more-link { font-size: 12px; color: var(--muted); }
.fc-ev-mini { justify-content: center; }
.day-list { position: sticky; top: 72px; }
.day-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; text-transform: capitalize; }
.day-rows { display: flex; flex-direction: column; }
.day-row { justify-content: flex-start; height: auto; min-height: 40px; padding: 6px 8px; border: 0; box-shadow: none; background: transparent; text-align: left; gap: 8px; border-radius: 8px; font-weight: 400; }
.day-row:hover { background: var(--surface-2); }
.day-time { width: 42px; flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.day-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-empty { padding: 8px 0; }
.day-add { margin-top: 8px; }
@media (max-width: 1100px) { .cal-layout { grid-template-columns: minmax(0, 1fr); } .day-list { position: static; } }
@media (max-width: 700px) { .fc .fc-daygrid-day-frame { min-height: 52px; } }
.fc .fc-daygrid-dot-event { padding: 1px 2px; }
.fc .fc-daygrid-dot-event:hover { background: var(--surface-2); }
@media (max-width: 560px) { .search-sm { flex: 1 1 100%; order: 3; } .search-sm input { width: 100%; } }
/* меню пользователя в шапке */
.me-btn { width: 36px; height: 36px; border-radius: 50%; }
.me-btn .av { width: 28px; height: 28px; font-size: 11.5px; }
.pop-me { min-width: 240px; }
.me-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.me-head .who { min-width: 0; }
.me-head .who b, .me-head .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-link { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 6px 8px; border-radius: 6px; color: var(--text); font-size: 13px; font-weight: 500; }
.menu-link:hover { background: var(--surface-2); text-decoration: none; }
.pop-me .theme-row { padding: 4px 4px 4px 8px; }
.pop-me .theme-row > span { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.pop-me button[data-logout] { color: var(--danger); }
.sidebar { gap: 0; }
.topbar { border-bottom-color: transparent; background: var(--bg); }
@media (pointer: coarse) {
  .me-btn { width: 40px; height: 40px; } .menu-link { min-height: 40px; }
  .fp-opt { min-height: 40px; } .overdue-link { min-height: 40px; }
  .file-name { padding: 10px 0; } .fchip button { width: 32px; height: 32px; } .fchip { height: 34px; }
  .day-row { min-height: 44px; }
}

/* =====================================================
/* ---------- глазик в поле пароля ---------- */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap input { padding-right: 40px; width: 100%; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; padding: 0; border: 0; background: transparent; color: var(--muted); display: inline-grid; place-items: center; border-radius: 6px; cursor: pointer; }
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.pw-toggle svg { width: 18px; height: 18px; }

/* ---------- просмотр картинок ---------- */
body.lb-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(8, 10, 16, .92); display: flex; flex-direction: column; animation: lb-in .15s ease-out; }
@keyframes lb-in { from { opacity: 0; } }
.lb-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; color: #fff; min-height: 56px; }
.lb-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lb-count { color: rgba(255, 255, 255, .65); font-size: 13px; flex: none; }
.lb-spacer { flex: 1; }
.lb-btn { width: 44px; height: 44px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, .1); color: #fff; display: inline-grid; place-items: center; cursor: pointer; flex: none; text-decoration: none; }
.lb-btn:hover { background: rgba(255, 255, 255, .2); }
.lb-btn:focus-visible, .lb-nav:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 64px 24px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); background: #fff; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .1); color: #fff; display: grid; place-items: center; cursor: pointer; z-index: 1; }
.lb-nav:hover { background: rgba(255, 255, 255, .22); }
.lb-prev { left: 8px; } .lb-next { right: 8px; }
@media (max-width: 600px) { .lb-stage { padding: 0 8px 16px; } .lb-nav { top: auto; bottom: 16px; transform: none; width: 52px; height: 52px; } }
/* увеличение в просмотре */
.lb-stage { overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.lb-stage img { transform-origin: center center; will-change: transform; cursor: zoom-in; -webkit-user-drag: none; }
.lightbox.lb-zoomed .lb-stage img { cursor: grab; box-shadow: none; }
.lightbox.lb-zoomed .lb-stage img:active { cursor: grabbing; }
.lightbox.lb-zoomed .lb-nav { opacity: .35; }
.lb-zoom { display: flex; align-items: center; gap: 2px; background: rgba(255, 255, 255, .08); border-radius: 12px; padding: 2px; }
.lb-zoom .lb-btn { background: transparent; width: 40px; height: 40px; }
.lb-zoom .lb-btn:hover { background: rgba(255, 255, 255, .15); }
.lb-level { min-width: 56px; height: 40px; border: 0; background: transparent; color: #fff; font: 600 13px/1 inherit; border-radius: 8px; cursor: pointer; font-variant-numeric: tabular-nums; }
.lb-level:hover { background: rgba(255, 255, 255, .15); }
@media (max-width: 600px) { .lb-zoom .lb-btn { display: none; } .lb-name { max-width: 30vw; } }
/* переключатель языка RU · EN · BG */
.lang-switch button { padding: 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.auth .auth-lang { position: absolute; top: 16px; right: 16px; }
.auth { position: relative; }
@media (max-width: 560px) { .top-lang { display: none; } }

/* ---------- окна на телефоне: кнопки внизу всегда видны ----------
   100vh на телефоне больше видимой области (адресная строка и панель браузера), поэтому берём dvh,
   а тело окна сжимается и прокручивается само, не выталкивая шапку и кнопки за экран */
.modal { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.modal header, .modal footer { flex: none; }
.modal .body { flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sidebar { height: 100vh; height: 100dvh; }
@media (max-width: 600px) {
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal { width: 100%; max-height: 100vh; max-height: 100dvh; border-radius: 16px 16px 0 0; border-bottom: 0; }
  .modal footer { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--surface); }
  .modal footer > button { flex: 1 1 auto; justify-content: center; min-height: 44px; }
  .modal footer > .spacer { display: none; }
}

/* ============ QA-UI: узкие экраны ============ */
/* UI-02: страница задачи на телефоне не шире экрана — колонки minmax(0, 1fr), длинные имена обрезаются многоточием */
.tp-main, .tp-side { min-width: 0; }
.props-chips .prop { min-width: 0; max-width: 100%; }
.props-chips .prop > span:not(.avs):not(.lbl) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row { min-width: 0; }
.ev-txt a, .ev-files .file, .file { max-width: 100%; min-width: 0; }
.ev-files .file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: 28px; }
.ev-head { min-width: 0; }
.ev-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.file .muted, .file-main .muted { white-space: nowrap; }
@media (max-width: 900px) { .task-page { grid-template-columns: minmax(0, 1fr); } }

/* UI-06: список чатов на телефоне — по ширине экрана, должность и превью с многоточием */
.chat-item-txt > span, .chat-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-item-bottom > .chat-preview { flex: 1; }
.chat-side-head { min-width: 0; }
.chat-side-head .chat-search { flex: 1; min-width: 0; }
.chat-side-head .chat-search input { width: 100%; }
@media (max-width: 760px) { .chat { grid-template-columns: minmax(0, 1fr); } .chat-side { min-width: 0; } }

/* UI-12: таблицы. Поиск в панели не сжимается; на телефоне строки таблиц — карточки */
.toolbar-search { flex: 1 1 240px; max-width: 360px; }
.toolbar-search input { width: 100%; }
.td-ellipsis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-tasks .td-title { min-width: 240px; }
@media (max-width: 1100px) { .uc-tasks .hide-md { display: none; } }
@media (max-width: 640px) {
  .toolbar-search { flex-basis: 100%; max-width: none; }
  .table-wrap.stack { overflow: visible; background: transparent; border: 0; box-shadow: none; }
  .stack table, .stack tbody, .stack tr, .stack td { display: block; width: 100%; }
  .stack thead { display: none; }
  .stack tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
  .stack tr.hidden { display: none; }
  .stack td { border: 0; padding: 3px 0; min-width: 0; max-width: none; }
  .stack td.td-title { padding-bottom: 6px; font-size: 14.5px; }
  .stack td[data-label] { display: flex; gap: 10px; align-items: center; font-size: 13px; }
  .stack td[data-label]::before { content: attr(data-label); flex: 0 0 104px; color: var(--muted); font-size: 12px; }
  .stack td.hide-md, .stack .cl-hide-sm { display: flex; }
  .stack td.td-counts:empty, .stack td.td-counts .counts:empty { display: none; }
  .stack tr.clickable:hover td { background: transparent; }
  .uc-tasks .td-title { min-width: 0; }
}

/* ============ QA-UI: чек-лист, меню комментария, файлы в композере ============ */
.checklist .tp-sec .muted { font-weight: 500; }
.ck-bar { height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: -2px 0 8px; }
.ck-bar span { display: block; height: 100%; background: var(--ok); border-radius: inherit; transition: width .2s; }
.ck-list { list-style: none; margin: 0 0 6px; padding: 0; }
.ck-item { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 2px 4px; margin: 0 -4px; border-radius: 6px; }
.ck-item:hover { background: var(--surface-2); }
.ck-item input[type=checkbox] { width: 18px; height: 18px; flex: none; cursor: pointer; }
.ck-item input[type=checkbox]:disabled { cursor: not-allowed; }
.ck-text { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 4px 0; }
.ck-text[role=button] { cursor: text; }
.ck-item.done .ck-text { color: var(--muted); text-decoration: line-through; }
.ck-item .ck-del { opacity: 0; }
.ck-item:hover .ck-del, .ck-item .ck-del:focus-visible { opacity: 1; }
.ck-edit { flex: 1; min-width: 0; height: 30px; }
.ck-new { margin-top: 2px; border-style: dashed; }
.ck-new:focus { border-style: solid; }
.ev-sys { position: relative; }
.ev-sys .ev-more { margin-left: auto; flex: none; }
.ev-more { opacity: .55; }
.ev-comment:hover .ev-more, .ev-sys:hover .ev-more, .ev-more:focus-visible { opacity: 1; }
.ev-body:empty { display: none; }
.ev-edit textarea { min-height: 64px; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px; }
.pending-files:empty { display: none; }
.pending-files .chip { max-width: 100%; min-width: 0; }
.pending-files .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 200px; }
@media (pointer: coarse) { .ck-item .ck-del, .ev-more { opacity: 1; } .ck-item { min-height: 44px; } .ck-item input[type=checkbox] { width: 22px; height: 22px; } }

/* UI-20: цели касания на телефоне — глазик в поле пароля, телефон и почта в карточках */
@media (pointer: coarse) {
  .pw-toggle { width: 40px; height: 40px; right: 0; }
  .facts a, .cl-contacts a, dd a[href^="tel:"], dd a[href^="mailto:"] { display: inline-block; padding: 10px 0; }
}

/* ============ Чат: просмотр администратором, прозрачность для сотрудников ============ */
.chat-mode { padding: 10px 10px 0; }
.chat-mode .seg { width: 100%; }
.chat-mode .seg button { flex: 1; justify-content: center; }
.chat-gdpr { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 12px 10px; border-top: 1px solid var(--border); font-size: 11.5px; }
.chat-gdpr .ic { flex: none; opacity: .8; }
.chat-admin-note { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--accent-weak); color: var(--text); font-size: 12.5px; font-weight: 500; border-bottom: 1px solid var(--border); }
.chat-admin .chat-msg .chat-author { display: block; }
.chat-versions-btn { height: auto; padding: 0; font-size: inherit; color: inherit; text-decoration: underline dotted; }
.chat-versions { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border-strong); display: flex; flex-direction: column; gap: 6px; }
.chat-version > div { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
@media (pointer: coarse) {
  .ck-text[role=button] { min-height: 40px; display: flex; align-items: center; }
  .facts a, .cl-contacts a, dd a[href^="tel:"], dd a[href^="mailto:"] { display: inline-flex; align-items: center; min-height: 40px; padding: 0; }
}
@media (pointer: coarse) { .ev-files .file, .files .file:not(.thumb) { min-height: 40px; line-height: 38px; } }

/* R-02: файл на стене — строка flex, по высоте не обрезается; многоточие только у имени */
.ev-files .file { display: inline-flex; align-items: center; gap: 6px; height: auto; min-height: 30px; line-height: 1.3; max-width: 100%; overflow: visible; white-space: nowrap; }
.ev-files .file .file-nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ev-files .file .muted, .ev-files .file .ic { flex: none; }
@media (pointer: coarse) { .ev-files .file { min-height: 40px; line-height: 1.3; } }

/* R-04: кнопка «Отменить» во всплывашке */
.toast { align-items: center; }
.toast-action { margin-left: auto; height: 28px; padding: 0 10px; background: transparent; color: inherit; border: 1px solid currentColor; box-shadow: none; font-weight: 600; flex: none; }
.toast-action:hover { background: rgba(127, 127, 127, .2); }
@media (pointer: coarse) { .toast-action { min-height: 40px; } }

/* UI-20: на касании точки задач в месячной сетке не перехватывают нажатие — оно попадает в день и открывает список дня */
@media (pointer: coarse) {
  .fc-daygrid-day .fc-daygrid-event:has(.fc-ev-mini) { pointer-events: none; }
  .ev-txt a[href^="#/clients/"] { display: inline-flex; align-items: center; min-height: 40px; }
}
/* UI-23: миниатюры картинок в композере */
.pending-files .chip-img { padding-left: 4px; }
.pending-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; flex: none; }

/* ---------- Отчёты (docs/REPORTS.md) ---------- */
.rep-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.rep-toolbar .spacer { flex: 1; }
.rep-dates { display: inline-flex; align-items: center; gap: 6px; }
.rep-dates input { width: 150px; }
.rep-period { margin: 0 0 12px; }
.rep-kpi .stat-txt b { display: inline-block; margin-right: 8px; }
/* Подписи KPI переносятся, а не обрезаются; стрелка ↑/↓ — своим цветом (перебиваем .stat .stat-txt span) */
.stat.rep-kpi .stat-txt span { white-space: normal; }
.stat .stat-txt .rep-delta { display: block; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.stat .stat-txt .rep-delta.pos { color: var(--ok); }
.stat .stat-txt .rep-delta.neg { color: var(--danger); }
.rep-who .badge { align-self: flex-start; height: 18px; font-size: 11px; }
.rep-table td, .rep-table th { white-space: nowrap; }
.rep-table .num { text-align: right; }
.rep-table tbody tr { cursor: pointer; }
.rep-table tbody tr:hover { background: var(--surface-2); }
.rep-table tfoot td { border-top: 2px solid var(--border); font-weight: 600; background: var(--surface-2); }
.th-sort { height: auto; padding: 0; border: 0; background: none; box-shadow: none; font: inherit; color: inherit; gap: 4px; }
.th-sort:hover { background: none; color: var(--text); }
.th-sort.on { color: var(--text); }
.rep-who { display: inline-flex; align-items: center; gap: 10px; text-align: left; white-space: normal; }
.rep-who > span { display: flex; flex-direction: column; min-width: 0; }
.rep-rate { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.rep-bar { width: 64px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.rep-bar i { display: block; height: 100%; background: currentColor; }
.rep-rate b { min-width: 3.2em; text-align: right; }
.rep-rate.good, .rep-big.good { color: var(--ok); } .rep-rate.mid, .rep-big.mid { color: var(--warn); } .rep-rate.bad, .rep-big.bad { color: var(--danger); }
.rep-rate.none, .rep-big.none { color: var(--muted); }
.rep-bad { color: var(--danger); font-weight: 600; }
.rep-cards { display: none; }
.rep-card { display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: 100%; height: auto; padding: 12px 14px; margin-bottom: 8px; text-align: left; font: inherit; background: var(--surface); }
.rep-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rep-big { font-size: 26px; font-weight: 700; line-height: 1; }
.rep-card-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 12px; color: var(--muted); }
.rep-card-nums b { display: block; font-size: 17px; color: var(--text); }
.rep-card-nums .rep-bad b { color: var(--danger); }
.rep-person { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.rep-person .av { width: 44px; height: 44px; font-size: 16px; }
.rep-person h2 { margin: 0; font-size: 20px; }
.rep-facts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 16px; padding: 14px 16px; margin-bottom: 16px; }
.rep-fact { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rep-fact b { font-size: 16px; }
.rep-section { margin-bottom: 16px; padding: 16px; }
.rep-section h3 { margin: 0 0 12px; font-size: 15px; }
.rep-sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.rep-sec-head h3 { margin: 0; }
.rep-chart { width: 100%; height: auto; display: block; }
.rep-grid { stroke: var(--border); stroke-width: 1; }
.rep-axis { fill: var(--muted); font-size: 11px; }
.rep-seg-on { fill: var(--ok); background: var(--ok); }
.rep-seg-late { fill: var(--warn); background: var(--warn); }
.rep-seg-overdue { fill: var(--danger); background: var(--danger); }
.rep-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; color: var(--muted); }
.rep-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rep-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.rep-tasks { display: flex; flex-direction: column; }
.rep-task { display: flex; align-items: center; gap: 10px; width: 100%; height: auto; min-height: 40px; padding: 8px 6px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: none; box-shadow: none; text-align: left; font: inherit; }
.rep-task:last-child { border-bottom: 0; }
.rep-task-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-task-dl { flex: none; }
.rep-task > .small { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.rep-out { flex: none; }
.rep-out-on_time { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.rep-out-late { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.rep-out-overdue { color: var(--danger); background: var(--danger-weak); }
.rep-out-in_progress { color: var(--accent); background: var(--accent-weak); }
.rep-out-cancelled { color: var(--muted); background: var(--surface-2); }
.print-head { display: none; }
@media (max-width: 1100px) { .rep-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .rep-table { display: none; }
  .rep-cards { display: block; }
  .rep-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rep-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rep-toolbar .spacer { display: none; }
  .rep-dates { width: 100%; }
  .rep-dates label { flex: 1; } .rep-dates input { width: 100%; }
  .rep-task { flex-wrap: wrap; }
  .rep-task-title { flex-basis: calc(100% - 30px); white-space: normal; }
  .rep-task-dl { margin-left: 24px; }
}
@media (pointer: coarse) {
  .rep-toolbar .seg button { height: 40px; }
  .th-sort { min-height: 40px; }
}
@media print {
  .sidebar, .sidebar-backdrop, .topbar, .no-print, #toasts, #modal-root { display: none !important; }
  .layout, .main, .content { display: block; padding: 0; margin: 0; overflow: visible; height: auto; }
  body { background: #fff; color: #000; }
  .print-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #ccc; }
  .rep-table { display: block !important; overflow: visible; box-shadow: none; }
  .rep-cards { display: none !important; }
  .rep-stats { grid-template-columns: repeat(4, 1fr) !important; }
  .rep-facts { grid-template-columns: repeat(5, 1fr) !important; }
  .card, .stat, .table-wrap { box-shadow: none; break-inside: avoid; }
  .rep-task { break-inside: avoid; }
  .rep-task-title { white-space: normal; }
}
