/* ЕВРОКОНВЕЙЕР — фирменная тема. Палитра с euroconveyor-st.ru. */

/* Шрифт Inter (вариативный, локально). Latin + Cyrillic. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

:root {
  --color-primary: #3a4d63;        /* графит/сталь — акцент: кнопки, ссылки, активное */
  --color-primary-hover: #2a394b;
  --color-primary-soft: #eef1f5;

  /* В светлой теме ФОН страницы — белый, а карточки/панели на нём — слегка ТЕМНЕЕ,
     чтобы вложенные области не сливались с фоном. Чем глубже вложенность —
     тем темнее: bg (белый) → surface → elevated. */
  --color-bg: #ffffff;
  --color-surface: #f3f5f8;        /* первая ступень: панель/карточка на белом фоне */
  --color-elevated: #e7eaf0;       /* вторая ступень: вложенная карточка внутри панели */

  --color-text: #1f2733;           /* холодный почти-чёрный (сталь) */
  --color-text-muted: #687180;
  --color-border: #e4e7ec;

  --color-bar: #475569;            /* стальные прогресс-бары */
  --color-hover: #eceff3;          /* холодный серый ховер/активный пункт */

  --color-success: #3ba776;
  --color-warning: #e0a23b;
  --color-danger: #e0533b;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(28, 28, 43, 0.06);
  --shadow: 0 4px 16px rgba(28, 28, 43, 0.08);
  --sidebar-w: 240px;
}

/* ===== Тёмная тема ===== */
html[data-theme="dark"] {
  --color-primary: #6f89a8; --color-primary-hover: #84a0c0; --color-primary-soft: #232c37;
  --color-bg: #14181e; --color-surface: #1d232b;
  --color-elevated: #29313c;       /* в тёмной — заметно СВЕТЛЕЕ surface, чтобы вложенные карточки «всплывали» */
  --color-text: #e6e9ee; --color-text-muted: #9aa3af; --color-border: #2c333d;
  --color-bar: #6f89a8; --color-hover: #252c35;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 6px 22px rgba(0,0,0,.5);
}
html[data-theme="dark"] body { background: var(--color-bg); color: var(--color-text); }
html[data-theme="dark"] .card, html[data-theme="dark"] .yg-card, html[data-theme="dark"] .dcard,
html[data-theme="dark"] .subtask, html[data-theme="dark"] .st-prog,
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea,
html[data-theme="dark"] .dboard-search {
  background: var(--color-surface) !important; color: var(--color-text); border-color: var(--color-border) !important; }
/* Поиск в топбаре — input лежит ВНУТРИ .tb-search-пилюли. Тёмная тема выше форсит
   у input bg+border surface — получалась двойная «пилюля». Возвращаем прозрачность. */
html[data-theme="dark"] .tb-search input {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
html[data-theme="dark"] .yg-col, html[data-theme="dark"] .dcol { background: #181d24 !important; border-color: #262d36; }
html[data-theme="dark"] .yg-col-h, html[data-theme="dark"] .dcol-h { filter: brightness(.46) saturate(1.25); color: #e6e9ee; }
html[data-theme="dark"] .yg-st, html[data-theme="dark"] .yg-tag, html[data-theme="dark"] .dc-tag,
html[data-theme="dark"] .yg-badge, html[data-theme="dark"] .st-bar { filter: brightness(.82); }
html[data-theme="dark"] .yg-st:not([class*="tc-"]):not(.amount) { background: #262d36; border-color: #333b46; color: #c3cad4; }
html[data-theme="dark"] .st-bar { background: #2c333d; }
html[data-theme="dark"] .dtable th, html[data-theme="dark"] table th { background: #1a1f26; }
html[data-theme="dark"] .dtable td, html[data-theme="dark"] .dtable th { border-color: #262d36; }
html[data-theme="dark"] .deals-table td, html[data-theme="dark"] tr:hover { background: transparent; }
html[data-theme="dark"] .yg-check { background: #262d36; border-color: #3a434f; }
html[data-theme="dark"] .rrow_picture, html[data-theme="dark"] .s-prev { filter: none; }
html[data-theme="dark"] img { opacity: .94; }
/* тёмные полосы прокрутки */
html[data-theme="dark"] * { scrollbar-color: #3a434f #181d24; }
html[data-theme="dark"] ::-webkit-scrollbar { width: 11px; height: 12px; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: #181d24; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #39424e; border-radius: 6px; border: 2px solid #181d24; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4a5563; }
html[data-theme="dark"] .yg-col-body::-webkit-scrollbar-thumb, html[data-theme="dark"] .dcol-body::-webkit-scrollbar-thumb { background: #39424e; }

/* кнопка переключения темы */
.theme-switch { display: flex; gap: 6px; margin: 8px 8px 4px; }
.theme-switch button { flex: 1; border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text-muted); border-radius: 8px; padding: 6px 0; font-size: 12px; cursor: pointer; }
.theme-switch button.on { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  letter-spacing: -0.01em;
}

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

h1, h2, h3 { color: var(--color-text); margin: 0 0 .5em; font-weight: 700; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 20px 14px;
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
  transition: transform .22s ease;
}
/* сворачивание бокового меню (десктоп/web) */
.nav-collapse, .nav-expand { display: none; }
@media (min-width: 861px) {
  /* ручка свёртывания — такая же вертикальная вкладка, как раскрытие, на правом крае меню */
  .nav-collapse { display: flex; position: absolute; top: 50%; right: 0; transform: translateY(-50%);
    width: 22px; height: 52px; align-items: center; justify-content: center; border: 1px solid var(--color-border);
    border-right: none; border-radius: 10px 0 0 10px; background: var(--color-surface); color: var(--color-text);
    cursor: pointer; font-size: 15px; line-height: 1; box-shadow: var(--shadow-sm); }
  .nav-collapse:hover { background: var(--color-hover); }
  .nav-collapsed .sidebar { transform: translateX(-100%); }
  .nav-collapsed .content { margin-left: 0; width: 100%; }
  /* кнопка раскрытия — по центру левого края экрана */
  .nav-expand { position: fixed; top: 50%; left: 0; transform: translateY(-50%); z-index: 60;
    width: 22px; height: 52px; align-items: center; justify-content: center; border: 1px solid var(--color-border);
    border-left: none; border-radius: 0 10px 10px 0; background: var(--color-surface); color: var(--color-text);
    cursor: pointer; font-size: 15px; line-height: 1; box-shadow: var(--shadow-sm); }
  .nav-expand:hover { background: var(--color-hover); }
  .nav-collapsed .nav-expand { display: flex; }
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 6px; font-weight: 800; font-size: 17px; letter-spacing: .2px; }
.brand .logo { flex-shrink: 0; }
/* вращение шестиугольника логотипа по часовой стрелке */
.logo-hex { transform-box: fill-box; transform-origin: center; animation: hexspin 14s linear infinite; }
.brand:hover .logo-hex { animation-duration: 1.4s; }
@keyframes hexspin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .logo-hex { animation: none; } }
.brand { gap: 12px; }
.brand-text { display: flex; flex-direction: column; justify-content: center; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.2px; }
.brand-name b { font-weight: 800; }
.brand-name .bn-light { font-weight: 300; }
.brand-sub { font-size: 6.5px; font-weight: 400; letter-spacing: .1px; color: var(--color-text-muted); text-transform: uppercase; margin-top: 3px; white-space: nowrap; }
.workspace { display: inline-flex; align-items: center; gap: 6px; margin: 10px 8px 16px; padding: 4px 10px; font-size: 10px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--color-text-muted); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 20px; }
.ws-dot { width: 6px; height: 6px; border-radius: 50%; background: #3f9d57; flex-shrink: 0; }

/* Меню: прокручиваемое (под много пунктов) */
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; overflow-y: auto; min-height: 0; margin-right: -6px; padding-right: 6px; }
.nav-section { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--color-text-muted); padding: 11px 12px 3px; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 11px; border-radius: var(--radius-sm);
  color: var(--color-text); font-weight: 600; font-size: 11.5px;
  opacity: 1; transition: background .12s, box-shadow .12s;
}
.nav .ic { width: 16px; height: 16px; flex: 0 0 auto; opacity: .62; }
.nav a.active .ic, .nav-drop[open] > summary .ic { opacity: 1; }
.nav-drop > summary .chev { margin-left: auto; }
.nav a:hover { background: var(--color-hover); }
.nav a.active { background: var(--color-hover); color: var(--color-text); font-weight: 700; box-shadow: inset 3px 0 0 var(--color-primary); }
/* Ещё не запущенные разделы — блёклые */
.nav a.muted { opacity: .4; font-weight: 500; }
.nav a.muted:hover { opacity: .6; background: transparent; cursor: default; }

/* Выпадающее меню (разделы-дропдауны) */
.nav-drop > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 9px;
  padding: 6px 11px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 12px; color: var(--color-text); transition: background .12s;
}
.nav-drop > summary::-webkit-details-marker { display: none; }
.nav-drop > summary::marker { content: ""; }
.nav-drop > summary:hover { background: var(--color-hover); }
.nav-drop[open] > summary { background: var(--color-hover); font-weight: 700; }
.nav-drop > summary .chev { margin-left: auto; font-size: 9px; color: var(--color-text-muted); transition: transform .15s; }
.nav-drop[open] > summary .chev { transform: rotate(90deg); color: var(--color-primary); }
/* Раскрытый список — отдельная вложенная панель, не сливается с основным меню */
.nav-sub2 { display: flex; flex-direction: column; gap: 2px; margin: 3px 0 6px 12px; padding: 5px 4px 5px 6px;
  border-left: 2px solid var(--color-border); background: var(--color-bg); border-radius: 0 10px 10px 0; }
.nav-sub2 a { padding-left: 16px; font-size: 12px; }
.nav-sub2 a.active { background: var(--color-surface); box-shadow: inset 3px 0 0 var(--color-primary); }

/* Корзина «Неразмечено» — отделена линией сверху, приглушённая */
.nav-drop-unsorted { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--color-border); }
.nav-drop-unsorted > summary { color: var(--color-text-muted); font-weight: 500; }
.nav-drop-unsorted > summary .ic { opacity: .55; }
.nav-drop-unsorted[open] > summary { color: var(--color-text); }
/* Круглые точки вместо иконок */
.nav-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; flex-shrink: 0; margin: 0 5px;
  transition: background .12s, transform .12s;
}
.nav a.active .nav-dot { background: var(--color-primary); transform: scale(1.15); }
.nav a .ico { width: 18px; text-align: center; }

/* Раскрывающийся раздел меню (HR и т.п.) */
.nav-group > summary {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-weight: 600; color: var(--color-text);
  list-style: none; user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: var(--color-hover); }
.nav-group > summary .chev { margin-left: auto; font-size: 10px; color: var(--color-text-muted); transition: transform .15s; }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px 17px; padding-left: 11px; border-left: 1px solid var(--color-border); }
.nav-sub a { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--color-text); font-weight: 500; opacity: 1; font-size: 14px; }
.nav-sub a:hover { background: var(--color-hover); }
.nav-sub a.active { background: var(--color-hover); font-weight: 600; }
.nav-sub a.muted { opacity: .35; font-weight: 500; }
.nav-sub a.muted:hover { opacity: .5; background: transparent; cursor: default; }

/* Гантт отпусков */
.gantt-scroll { overflow-x: auto; cursor: grab; }
.gantt-scroll.drag { cursor: grabbing; user-select: none; }
.gantt { min-width: 1600px; }
.gantt-head { display: flex; align-items: stretch; border-bottom: 1px solid var(--color-border); }
.gantt-row { display: flex; align-items: center; border-bottom: 1px solid var(--color-border); }
.gantt-row:last-child { border-bottom: none; }
.gantt-row:hover { background: var(--color-bg); }
.g-name { width: 230px; flex-shrink: 0; display: flex; align-items: center; gap: 9px; padding: 8px 16px; }
.g-fio { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-track { position: relative; flex: 1; height: 34px; }
.g-months { display: flex; height: 38px; }
.g-month { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--color-text-muted); border-left: 1px solid var(--color-border); }
.g-month.today { color: var(--color-primary); font-weight: 700; background: var(--color-primary-soft); }
/* Слой сетки-ячеек внутри строки */
.g-cells { position: absolute; inset: 0; display: flex; }
.g-cell { border-left: 1px solid var(--color-border); opacity: .7; }
.g-cell.today { background: var(--color-primary-soft); opacity: 1; }
.g-bar {
  position: absolute; top: 7px; height: 20px; min-width: 6px; z-index: 2;
  background: var(--color-primary); border-radius: 6px; overflow: visible;
}
/* Подпись с датой — справа от полосы, тёмным текстом (влезает при любой ширине) */
.g-bar span {
  position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
  margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--color-text);
  white-space: nowrap; pointer-events: none;
}
.g-dept {
  padding: 9px 16px; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--color-text-muted);
  background: var(--color-bg); border-bottom: 1px solid var(--color-border);
}

.sidebar-footer { margin-top: auto; border-top: 1px solid var(--color-border); padding-top: 14px; font-size: 13px; color: var(--color-text-muted); }
/* Кто онлайн */
.online-box { position: relative; margin-bottom: 14px; }
.online-toggle { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--color-border); background: var(--color-surface); border-radius: 20px; padding: 5px 12px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--color-text); cursor: pointer; }
.online-toggle:hover { background: var(--color-hover); }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #45c463; flex-shrink: 0; box-shadow: 0 0 0 3px rgba(69,196,99,.18); }
.online-pop { position: absolute; bottom: calc(100% + 8px); left: 0; width: 250px; max-width: 80vw; max-height: 320px; overflow-y: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(20,22,30,.2); z-index: 80; padding: 6px; }
.online-pop[hidden] { display: none; }
.online-pop-h { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--color-text-muted); padding: 6px 8px; }
.online-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px; }
.online-row:hover { background: var(--color-hover); }
.online-ava { width: 34px; height: 34px; font-size: 12px; position: relative; }
.online-ava::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: #45c463; border: 2px solid var(--color-surface); }
.online-name { font-size: 13.5px; font-weight: 600; color: var(--color-text); }
.online-empty { padding: 10px 8px; font-size: 13px; }
.sidebar-footer .user { display: flex; align-items: center; gap: 10px; }

/* Скачать приложение */
.app-dl { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--color-border); }
.app-dl-title { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--color-text-muted); font-weight: 600; margin-bottom: 9px; }
.app-dl-btns { display: flex; gap: 6px; }
.app-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border: 1px solid var(--color-border); border-radius: 9px; font-size: 11px; font-weight: 600; color: var(--color-text); background: var(--color-surface); }
.app-btn span { font-size: 16px; line-height: 1; }
.app-btn:hover { background: var(--color-hover); border-color: var(--color-primary); color: var(--color-text); }

.content { margin-left: var(--sidebar-w); flex: 1; padding: 28px 36px; width: calc(100% - var(--sidebar-w)); }
/* ===== Глобальный верхний бар (одна компактная линия) ===== */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 8px 0; margin-bottom: 8px; background: var(--color-bg); transition: transform .22s ease, opacity .18s ease, margin .22s ease, padding .22s ease; }

/* Скрытый топбар (по скроллу или по тапу на ▲ — переключает .chrome-hidden у body) */
body.chrome-hidden .topbar,
body.chrome-hidden .mtopbar { transform: translateY(-100%); opacity: 0; pointer-events: none; }
body.chrome-hidden .topbar { margin-bottom: 0; padding: 0; height: 0; min-height: 0; overflow: hidden; }
body.chrome-hidden .mtopbar { margin-bottom: 0; }

/* Кнопка-«пилюля» снизу экрана для возврата шапки */
.chrome-peek {
  position: fixed; top: 6px; right: 12px;
  width: 30px; height: 30px;
  display: none; align-items: center; justify-content: center;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 50%; cursor: pointer; z-index: 80;
  font-size: 13px; color: var(--color-text-muted);
  box-shadow: 0 2px 8px rgba(28,28,43,.12);
}
body.chrome-hidden .chrome-peek { display: flex; }
.chrome-peek:hover { color: var(--color-primary); border-color: var(--color-primary); }
.tb-back { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); font-size: 20px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }
.tb-back:hover { background: var(--color-hover); }
.tb-title { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.tb-title h1 { font-size: 16px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title p { display: none; }
.tb-search { flex: 0 0 auto; width: 170px; max-width: 32vw; height: 34px; margin: 0; display: flex; align-items: center; gap: 7px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 999px; padding: 0 14px; box-shadow: var(--shadow-sm); transition: width .22s ease, box-shadow .15s; position: relative; }
.tb-search:focus-within { width: 460px; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); position: relative; }

/* Выпадающий список найденных деталей — компактный, маленькие превью */
.tb-search-dd {
  position: absolute; top: calc(100% + 6px); left: 0;
  width: 540px; max-width: calc(100vw - 40px);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(28,28,43,.16), 0 2px 6px rgba(28,28,43,.08);
  max-height: 70vh; overflow-y: auto; overflow-x: hidden;
  z-index: 100;
  padding: 4px;
  box-sizing: border-box;
}
.tb-dd-row {
  display: flex; align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--color-text);
  transition: background .1s;
  min-height: 0;
}
.tb-dd-row:hover, .tb-dd-row.active { background: color-mix(in srgb, var(--color-primary) 9%, transparent); color: var(--color-text); }
.tb-dd-row .prev {
  flex: 0 0 auto;
  width: 28px; height: 22px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
}
.tb-dd-row .prev img {
  display: block;
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
}
.tb-dd-row .prev .no-prev { font-size: 8px; color: var(--color-text-muted); padding: 0 2px; }
.tb-dd-row .info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.tb-dd-row .info .art {
  font-family: ui-monospace, monospace;
  font-size: 11.5px; font-weight: 700;
  color: var(--color-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.25;
}
.tb-dd-row .info .nm {
  font-size: 11.5px; font-weight: 500;
  color: var(--color-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.25;
}
.tb-dd-row .info .meta {
  font-size: 10px; color: var(--color-text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.25;
}
.tb-dd-row .actions { flex: 0 0 auto; display: inline-flex; gap: 4px; }
.tb-dd-row .actions a {
  font-size: 10px; font-weight: 700;
  padding: 3px 7px; border-radius: 4px;
  text-decoration: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
  line-height: 1.2;
  white-space: nowrap;
}
.tb-dd-row .actions a.pdf { background: #dc2626; color: #fff; border-color: #dc2626; }
.tb-dd-row .actions a.pdf:hover { background: #b91c1c; }
.tb-dd-row .actions a.dxf:hover { border-color: var(--color-primary); color: var(--color-primary); }
.tb-dd-empty {
  padding: 14px; text-align: center; color: var(--color-text-muted);
  font-size: 12px;
}
.tb-dd-h {
  padding: 6px 10px 3px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  letter-spacing: .3px;
}
/* Внутренний input не должен наследовать глобальные input/select/textarea —
   там есть border, padding, background и :focus с box-shadow, которые рисовали
   «лишний овал» внутри пилюли .tb-search. Сбрасываем здесь. */
.tb-search input {
  flex: 1; min-width: 0;
  border: 0 !important; outline: 0 !important; box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
  font: inherit; font-size: 13px; line-height: 1;
  color: var(--color-text);
  border-radius: 0 !important;
}
.tb-search input:focus { box-shadow: none !important; border-color: transparent !important; }
.tb-search input::-webkit-search-cancel-button { display: none; }
.tb-ico { flex: 0 0 auto; width: 15px; height: 15px; opacity: .5; }
.tb-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.tb-actions .btn, .tb-actions a.btn { height: 34px; padding: 0 14px; font-size: 13px; display: inline-flex; align-items: center; }
.tb-online { flex: 0 0 auto; display: flex; align-items: center; gap: 9px; position: relative; }
.tb-avas { display: inline-flex; }
.tb-ava { width: 27px; height: 27px; border-radius: 50%; color: #fff; font-size: 9.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--color-bg); margin-left: -8px; }
.tb-ava:first-child { margin-left: 0; }
.tb-online-pill { display: inline-flex; align-items: center; gap: 7px; height: 34px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); border-radius: 999px; padding: 0 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-sm); white-space: nowrap; }
.tb-online-pill:hover { background: var(--color-hover); }
.tb-online-pop {
  position: absolute;
  /* Сбрасываем left/bottom от .online-pop — иначе попап растягивается на всю ширину контейнера */
  left: auto; bottom: auto;
  right: 0; top: calc(100% + 8px);
  z-index: 200;
}
.srow { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 9px 6px; border-bottom: 1px solid var(--color-border); text-decoration: none; color: var(--color-text); }
.srow:last-child { border-bottom: none; }
.srow:hover { background: var(--color-hover); border-radius: 8px; }
@media (max-width: 760px){ .tb-avas, .tb-online-pill span:last-child { display: none; } .tb-search{ max-width:none; } .topbar{ gap:8px; } }
.calc-page .topbar, .chat-page .topbar, .chat-home-page .topbar { display: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-head h1 { font-size: 20px; margin: 0; }

/* ---------- Components ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--color-primary); color: #fff;
  border: none; padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--color-primary-hover); color: #fff; }
.btn-ghost { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* Вкладки страницы */
.tabs { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 1px solid var(--color-border); }
.tabs a { padding: 9px 16px; font-weight: 600; color: var(--color-text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--color-text); }
.tabs a.active { color: var(--color-text); border-bottom-color: var(--color-primary); }

/* Панель фильтров */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters select { width: auto; min-width: 150px; }

.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px;
}

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.dash-split { grid-template-columns: 1.4fr 1fr; }
/* Вакансии */
.vac-list { margin: 8px 0 0; padding-left: 20px; }
.vac-list li { margin-bottom: 7px; font-size: 14px; line-height: 1.5; }
.vac-meta { display: flex; flex-direction: column; }
.vac-meta div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--color-border); font-size: 14px; }
.vac-meta div:last-child { border-bottom: none; }
.vac-meta span { color: var(--color-text-muted); }
.vac-meta b { font-weight: 600; text-align: right; }
.pub-badge { font-size: 11.5px; font-weight: 700; color: var(--color-warning); white-space: nowrap; }
.pub-badge.is-pub { color: var(--color-success); }
.pub-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--color-text); }
.pub-toggle input { width: 16px; height: 16px; accent-color: var(--color-primary); }
.vac-card { transition: border-color .12s; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .dash-split { grid-template-columns: 1fr; } }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .num { font-size: 30px; font-weight: 800; line-height: 1; }
.stat .label { color: var(--color-text-muted); font-size: 13px; }
.stat.danger .num { color: var(--color-danger); }
a.card.stat { color: inherit; text-decoration: none; cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
a.card.stat:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md, 0 6px 18px rgba(28,28,43,.10)); transform: translateY(-2px); }
a.card.stat .label { text-decoration: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 600; }
.badge-planning { background: #eef0f4; color: #5a6172; }
.badge-active { background: var(--color-primary-soft); color: var(--color-primary-hover); }
.badge-on_hold { background: #fdf2e0; color: var(--color-warning); }
.badge-done { background: #e6f6ee; color: var(--color-success); }
.badge-lost { background: #fdecea; color: var(--color-danger); }

.prio { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.prio-low { background: #9aa0ad; }
.prio-medium { background: var(--color-primary); }
.prio-high { background: var(--color-warning); }
.prio-urgent { background: var(--color-danger); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--color-primary-soft);
  color: var(--color-primary-hover); font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.progress { height: 6px; background: var(--color-bg); border-radius: 100px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--color-bar); border-radius: 100px; }

.muted { color: var(--color-text-muted); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }

/* Tables / lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.list-item:last-child { border-bottom: none; }

/* Forms */
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); font: inherit; background: #fff; color: var(--color-text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
label { font-size: 13px; font-weight: 600; color: var(--color-text-muted); display: block; margin-bottom: 5px; }
.field { margin-bottom: 14px; }

/* ---------- Kanban ---------- */
.board { display: flex; gap: 16px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; }
.column { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); width: 280px; flex-shrink: 0; padding: 12px; }
.column-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 12px; padding: 0 4px; }
.column-head .count { background: #fff; border: 1px solid var(--color-border); border-radius: 100px; padding: 1px 9px; font-size: 12px; color: var(--color-text-muted); }
.column-body { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }
.tcard {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 12px; box-shadow: var(--shadow-sm); cursor: grab;
}
.tcard:active { cursor: grabbing; }
.tcard.dragging { opacity: .5; }
.tcard .title { font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.tcard .meta { display: flex; align-items: center; justify-content: space-between; }
.tcard .due { font-size: 12px; color: var(--color-text-muted); }
.tcard .due.overdue { color: var(--color-danger); font-weight: 600; }
.column.drag-over { outline: 2px dashed var(--color-primary); outline-offset: -4px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(28,28,43,.45); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); width: 460px; max-width: 90vw; max-height: calc(100vh - 80px); overflow-y: auto; padding: 24px; box-shadow: var(--shadow); }

/* Tree */
.tree { list-style: none; padding-left: 0; }
.tree ul { list-style: none; padding-left: 22px; border-left: 1px solid var(--color-border); margin-left: 6px; }
.tree-dept { font-weight: 700; padding: 6px 0; }
.tree-emp { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background .12s; }
.tree-emp:hover { background: var(--color-hover); }
.tree-emp .pos { color: var(--color-text-muted); font-size: 13px; }

/* Панель сотрудника (выезжает справа) */
.emp-overlay { position: fixed; inset: 0; background: rgba(28,28,43,.25); opacity: 0; visibility: hidden; transition: opacity .18s, visibility .18s; z-index: 60; }
.emp-overlay.open { opacity: 1; visibility: visible; }
.emp-panel { position: fixed; top: 0; right: 0; height: 100vh; width: 340px; max-width: 90vw; background: var(--color-surface); border-left: 1px solid var(--color-border); box-shadow: -8px 0 28px rgba(28,28,43,.10); transform: translateX(100%); transition: transform .22s ease; z-index: 61; padding: 26px 24px; overflow-y: auto; }
.emp-panel.open { transform: translateX(0); }
.emp-close { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 17px; line-height: 1; cursor: pointer; color: var(--color-text-muted); padding: 4px; }
.emp-close:hover { color: var(--color-text); }
.emp-top { text-align: center; padding: 6px 0 18px; border-bottom: 1px solid var(--color-border); }
.emp-avatar { width: 76px; height: 76px; border-radius: 50%; background: var(--color-primary-soft); color: var(--color-primary-hover); font-size: 26px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.emp-top h2 { font-size: 18px; margin: 0 0 4px; }
.emp-pos { color: var(--color-text-muted); font-size: 14px; margin-bottom: 12px; }
.emp-section { padding-top: 18px; display: flex; flex-direction: column; gap: 15px; }
.emp-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.emp-row .emp-lab { color: var(--color-text-muted); flex-shrink: 0; }
.emp-row > span:last-child, .emp-row a { font-weight: 500; text-align: right; word-break: break-word; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; }
.login-card .brand { justify-content: center; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 14px; }
.alert-error { background: #fdecea; color: var(--color-danger); }
.empty { text-align: center; color: var(--color-text-muted); padding: 40px; }

/* ---------- Analytics ---------- */
.section-head { display: flex; align-items: center; gap: 10px; margin: 26px 0 14px; }
.section-head h2 { font-size: 17px; margin: 0; }
.section-head .pill { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 100px; padding: 2px 12px; font-size: 13px; color: var(--color-text-muted); font-weight: 600; }

.card-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; }

/* Карточки аналитики — мягче и просторнее */
.kpi-grid .card, .analytics-row .card, .widget { box-shadow: 0 2px 10px rgba(28,28,43,.05); border-radius: 16px; }
.widget, .kpi { display: flex; flex-direction: column; gap: 12px; padding: 18px; }

.ico-chip { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; color: #fff; font-weight: 700; flex-shrink: 0; }
.ico-site, .ico-lead, .ico-smm { background: #f0eff2; color: #6f6c74; }
.ico-youtube { background: #ff0000; }
.ico-instagram { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.ico-avito { background: #04e061; color: #0a2540; }

.w-head { display: flex; align-items: center; gap: 10px; }
.w-title { font-size: 13.5px; font-weight: 600; color: var(--color-text-muted); }
.w-title a { color: inherit; }
.w-value { font-size: 27px; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.w-unit { font-size: 12px; color: var(--color-text-muted); font-weight: 500; margin-left: 4px; }
.w-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }

.delta { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border-radius: 100px; white-space: nowrap; }
.delta-up { background: #e6f6ee; color: var(--color-success); }
.delta-down { background: #fdecea; color: var(--color-danger); }
.delta-flat { background: var(--color-bg); color: var(--color-text-muted); }

/* Контейнеры ECharts */
.ec { width: 100%; }
.widget .ec, .chart.ec { height: 54px; }
.kpi .ec { height: 46px; }
.ec-big { width: 100%; height: 215px; }
.ec-donut { width: 140px; height: 140px; flex-shrink: 0; }
.ec-gauge { width: 100%; height: 150px; }
.ec-geo { width: 100%; height: 215px; }

/* География + Директ в один ряд */
.geo-direct-row { grid-template-columns: 1.15fr 1fr; margin-top: 18px; }
@media (max-width: 1100px) { .geo-direct-row { grid-template-columns: 1fr; } }

/* Яндекс.Директ */
.ico-direct { background: #fc3f1d; color: #fff; }
.direct-stats { display: flex; gap: 10px; margin: 4px 0 8px; }
.direct-stats .d-stat { flex: 1; background: var(--color-bg); border-radius: var(--radius-sm); padding: 12px 14px; }
.direct-stats .d-val { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.5px; }
.direct-stats .d-lab { font-size: 12px; color: var(--color-text-muted); }
.d-foot { font-size: 13px; padding-top: 10px; border-top: 1px solid var(--color-border); margin-top: 4px; }
.d-foot b { color: var(--color-text); }

/* SEO-позиции */
.seo-list { display: flex; flex-direction: column; }
.seo-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--color-border); }
.seo-row:last-child { border-bottom: none; }
.seo-q { display: flex; flex-direction: column; min-width: 0; }
.seo-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seo-freq { font-size: 11px; color: var(--color-text-muted); }
.seo-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.seo-pos { min-width: 30px; height: 28px; padding: 0 8px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; }
.seo-pos.top { background: #e6f6ee; color: var(--color-success); }
.seo-pos.mid { background: var(--color-bg); color: var(--color-text); }
.seo-pos.low { background: #fdecea; color: var(--color-danger); }
.seo-delta { font-size: 12px; font-weight: 700; min-width: 34px; text-align: right; }
.seo-delta.up { color: var(--color-success); }
.seo-delta.down { color: var(--color-danger); }
.seo-delta.flat { color: var(--color-text-muted); }

/* KPI goal */
.goal { margin-top: 2px; }
.goal-bar { height: 6px; background: var(--color-bg); border-radius: 100px; overflow: hidden; margin-bottom: 6px; }
.goal-bar > span { display: block; height: 100%; background: var(--color-bar); border-radius: 100px; }
.goal-lab { font-size: 12px; color: var(--color-text-muted); }

.w-subs { display: flex; gap: 20px; border-top: 1px solid var(--color-border); padding-top: 12px; }
.w-subs .sub { display: flex; flex-direction: column; }
.w-subs .sub .s-val { font-weight: 700; font-size: 16px; }
.w-subs .sub .s-lab { font-size: 11px; color: var(--color-text-muted); }

/* Ряд donut / большой график / gauge */
.analytics-row { grid-template-columns: 0.85fr 1.5fr 0.85fr; margin-top: 18px; }
@media (max-width: 1200px) { .analytics-row { grid-template-columns: 1fr; } }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { width: 130px; height: 130px; flex-shrink: 0; transform: rotate(-90deg); }
.donut-bg { fill: none; stroke: var(--color-bg); stroke-width: 4; }
.donut-seg { fill: none; stroke-width: 4; stroke-linecap: round; }
.donut-num { transform: rotate(90deg); transform-origin: 21px 21px; font-size: 7px; font-weight: 800; fill: var(--color-text); text-anchor: middle; }
.donut-cap { transform: rotate(90deg); transform-origin: 21px 21px; font-size: 2.6px; fill: var(--color-text-muted); text-anchor: middle; }
.legend { display: flex; flex-direction: column; gap: 9px; flex: 1; }
.leg-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.leg-item .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.leg-item .leg-val { margin-left: auto; color: var(--color-text-muted); font-weight: 600; font-size: 12px; }

/* Gauge */
.gauge { width: 100%; max-width: 200px; height: 110px; }
.g-bg { fill: none; stroke: var(--color-bg); stroke-width: 12; stroke-linecap: round; }
.g-val { fill: none; stroke: var(--color-primary); stroke-width: 12; stroke-linecap: round; }
.g-num { font-size: 22px; font-weight: 800; fill: var(--color-text); text-anchor: middle; }

/* География */
.geo-list { display: flex; flex-direction: column; gap: 12px; }
.geo-row { display: grid; grid-template-columns: 150px 1fr 60px; align-items: center; gap: 14px; }
.geo-name { font-size: 14px; font-weight: 500; }
.geo-bar { height: 8px; background: var(--color-bg); border-radius: 100px; overflow: hidden; }
.geo-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #3a4d63, #7689a0); border-radius: 100px; }
.geo-val { text-align: right; font-weight: 700; font-size: 14px; }

/* Таблица */
.dtable { width: 100%; border-collapse: collapse; }
.dtable th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--color-text-muted); font-weight: 600; padding: 12px 20px; border-bottom: 1px solid var(--color-border); }
.dtable td { padding: 14px 20px; border-bottom: 1px solid var(--color-border); font-size: 14px; vertical-align: middle; }
.dtable tbody tr:last-child td { border-bottom: none; }
.dtable tbody tr:hover { background: var(--color-bg); }
.dtable tr.crow, .dtable tr.lrow { cursor: pointer; }

/* Карточка клиента */
.lead-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 700px) { .lead-grid { grid-template-columns: 1fr; } }
.btn.is-disabled { opacity: .4; pointer-events: none; }

/* Финансы: список «кто прислал» */
.sub-list { display: flex; flex-direction: column; }
.sub-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--color-border); }
.sub-row:last-child { border-bottom: none; }
.sub-name { font-weight: 600; font-size: 14px; }
.sub-cnt { font-size: 13px; }
.sub-sum { margin-left: auto; font-weight: 700; font-size: 14px; }

/* Этапы проекта (12-этапная методика) */
.stages { display: flex; flex-direction: column; gap: 10px; }
.stage { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.stage.stage-active { box-shadow: inset 3px 0 0 var(--color-primary), var(--shadow-sm); }
.stage.stage-done { opacity: .82; }
.stage-head { display: flex; align-items: center; gap: 12px; }
.stage-num { width: 26px; height: 26px; border-radius: 50%; background: var(--color-bg); color: var(--color-text-muted); font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border: 1px solid var(--color-border); }
.stage-done .stage-num { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.stage-active .stage-num { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.stage-title { font-weight: 700; font-size: 14.5px; }
.stage-badge { margin-left: 4px; }
.stage-prog { margin-left: auto; font-size: 12px; }
.stage-items { display: flex; flex-direction: column; gap: 7px; margin: 12px 0 0 38px; }
.stage-item { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; color: var(--color-text); }
.stage-item input { width: 16px; height: 16px; accent-color: var(--color-primary); cursor: pointer; flex-shrink: 0; }
.stage-item.done span { text-decoration: line-through; color: var(--color-text-muted); }

/* Архив файлов */
.archive-search { display: flex; align-items: center; gap: 10px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; padding: 5px 5px 5px 14px; margin-bottom: 22px; box-shadow: var(--shadow-sm); }
.archive-search svg { color: var(--color-text-muted); flex-shrink: 0; }
.archive-search input { border: none; box-shadow: none !important; padding: 11px 4px; font-size: 15px; background: transparent; }
.archive-search input:focus { outline: none; }
.crumbs { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 14px; flex-wrap: wrap; }
.crumbs a { font-weight: 600; color: var(--color-text); }
.crumbs .sep { color: var(--color-text-muted); }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.fcard { display: flex; flex-direction: column; gap: 3px; padding: 16px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; box-shadow: var(--shadow-sm); color: var(--color-text); transition: border-color .12s, background .12s; }
.fcard:hover { border-color: var(--color-primary); background: var(--color-hover); color: var(--color-text); }
.folder-ico { width: 30px; height: 30px; color: var(--color-primary); margin-bottom: 5px; }
.fcard .fname { font-weight: 600; font-size: 14px; }
.ext-badge { display: inline-block; min-width: 40px; text-align: center; font-size: 10px; font-weight: 800; letter-spacing: .3px; color: var(--color-text-muted); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 6px; padding: 3px 6px; margin-right: 8px; vertical-align: middle; }
/* Ссылки в таблицах — чёрные bold, без фиолетового «звона» */
.dtable a { color: var(--color-text); font-weight: 600; }
.dtable a:hover { text-decoration: underline; }

/* Прочитанные / непрочитанные (как письма) */
.read-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 10px; vertical-align: middle; cursor: pointer; border: 2px solid var(--color-border); background: transparent; transition: background .12s, border-color .12s; }
.read-dot:hover { border-color: var(--color-primary); }
tr.crow.unread .read-dot { background: var(--color-primary); border-color: var(--color-primary); }
tr.crow.unread td a { color: var(--color-text); font-weight: 800; }
tr.crow:not(.unread) td a { color: var(--color-text-muted); font-weight: 500; }
tr.crow:not(.unread) { background: #fbfbfa; }

/* Бейдж релевантности */
.rbadge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 100px; margin-left: 8px; vertical-align: middle; }
.rbadge-relevant { background: #e6f6ee; color: var(--color-success); }
.rbadge-maybe { background: #fdf2e0; color: var(--color-warning); }
.rbadge-irrelevant { background: #fdecea; color: var(--color-danger); }

.unread-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.unread-toggle input { width: auto; }

.nav-badge { background: var(--color-primary); color: #fff; border-radius: 100px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: auto; }
.dtable .ico-chip { width: 26px; height: 26px; font-size: 12px; vertical-align: middle; }
/* На телефоне широкие таблицы (цех/безопасность, тендеры и т.п.) можно листать вправо */
@media (max-width: 760px) {
  .dtable { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .dtable th, .dtable td { padding: 11px 14px; }
}

/* Чат проекта */
.chat-wrap { display: block; }
@media (max-width: 900px) { .chat-wrap { grid-template-columns: 1fr; } }
.chat-main { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; min-height: 420px; }
.chat-feed { padding: 16px 8px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; max-height: 62vh; }
@media (max-width: 760px) { .chat-feed { padding-left: 5px; padding-right: 5px; } }
.chat-empty { color: var(--color-text-muted); text-align: center; padding: 40px 0; font-size: 14px; }
.msg { display: flex; gap: 11px; }
.msg .avatar { flex-shrink: 0; width: 34px; height: 34px; font-size: 12px; }
.msg-body { display: flex; flex-direction: column; gap: 2px; }
.msg-meta { font-size: 12px; color: var(--color-text-muted); }
.msg-meta b { color: var(--color-text); font-weight: 600; font-size: 13px; margin-right: 6px; }
.msg-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg-file { font-size: 13px; font-weight: 600; margin-top: 3px; }
/* системное событие */
.msg-sys { align-self: center; max-width: 92%; text-align: center; }
.msg-sys span { display: inline-block; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 100px; padding: 5px 14px; font-size: 12.5px; color: var(--color-text-muted); }
.msg-sys time { display: block; font-size: 11px; margin-top: 3px; color: var(--color-text-muted); }
/* компоновщик */
.chat-compose { border-top: 1px solid var(--color-border); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-end; }
.chat-compose textarea { flex: 1; resize: none; min-height: 42px; max-height: 160px; padding: 10px 12px; font: inherit; font-size: 14px; border: 1px solid var(--color-border); border-radius: 10px; }
.chat-compose .file-lbl { font-size: 12px; color: var(--color-text-muted); cursor: pointer; padding: 8px; }
/* Панель информации о чате (выезжает справа, как в Telegram) */
.chat-members { position: fixed; top: 0; right: 0; height: 100%; width: 340px; max-width: 88%;
  background: var(--color-surface); border-left: 1px solid var(--color-border);
  box-shadow: -10px 0 30px rgba(20,22,30,.18); z-index: 86;
  transform: translateX(100%); transition: transform .22s ease; overflow-y: auto; padding: 0 0 24px; }
.info-open .chat-members { transform: translateX(0); }
.ci-ov { position: fixed; inset: 0; background: rgba(20,22,30,.4); z-index: 85; opacity: 0; pointer-events: none; transition: opacity .2s; }
.ci-ov.open { opacity: 1; pointer-events: auto; }
.ci-x { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 24px; line-height: 1; color: var(--color-text-muted); cursor: pointer; z-index: 1; }
.ci-top { text-align: center; padding: 28px 20px 18px; border-bottom: 1px solid var(--color-border); }
.ci-ava { width: 84px; height: 84px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 30px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.ci-title { font-size: 18px; font-weight: 700; }
.ci-sub { font-size: 13px; color: var(--color-text-muted); margin-top: 3px; }
.chat-members h4 { margin: 16px 18px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--color-text-muted); }
.chat-member { display: flex; align-items: center; gap: 11px; padding: 8px 18px; cursor: pointer; }
.chat-member:hover { background: var(--color-hover); }
.chat-member .avatar { width: 38px; height: 38px; font-size: 13px; position: relative; }
.chat-member .avatar.on::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #45c463; border: 2px solid var(--color-surface); }
.chat-member .cm-name { font-size: 14px; font-weight: 600; }
.chat-member .cm-pos { font-size: 12px; color: var(--color-text-muted); }
.chat-member[data-online] .cm-pos { color: #3a8fd6; }
.sel-sm { padding: 7px 11px; font-size: 13px; border: 1px solid var(--color-border); border-radius: 9px; background: var(--color-surface); }

/* Платёжный календарь */
.paycal-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.paycal-month { font-size: 17px; font-weight: 700; min-width: 170px; text-align: center; }
.paycal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.paycal-head { margin-bottom: 6px; }
.paycal-wd { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--color-text-muted); padding: 2px 0; }
.paycal-grid:not(.paycal-head) { margin-bottom: 6px; }
.paycal-cell { min-height: 92px; border: 1px solid var(--color-border); border-radius: 10px; padding: 6px 8px; background: var(--color-surface); display: flex; flex-direction: column; gap: 4px; }
.paycal-cell.we { background: color-mix(in srgb, var(--color-bg) 60%, var(--color-surface)); }
.paycal-cell.out { opacity: .4; }
.paycal-cell.today { border-color: var(--color-primary); box-shadow: inset 0 0 0 1px var(--color-primary); }
.paycal-day { font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.paycal-cell.today .paycal-day { color: var(--color-primary); }
.paycal-items { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.paycal-item { font-size: 12px; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paycal-item.in { background: rgba(63,157,87,.16); color: #2e7d46; }
.paycal-item.out { background: rgba(224,83,59,.14); color: #c0392b; }
.paycal-cell.has { cursor: pointer; }
.paycal-cell.has:hover { border-color: var(--color-primary); }
.paycal-totals { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: 13px; font-weight: 600; }
.pc-in { color: #2e7d46; }
.pc-out { color: #c0392b; }
.pc-net { font-weight: 700; }
.pc-party { display: flex; flex-direction: column; }
.pc-meta { font-size: 11px; color: var(--color-text-muted); font-weight: 400; }
/* Платёжная таблица */
.pay-widget { margin-bottom: 18px; }
.pw-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.pw-title { font-weight: 700; font-size: 15px; }
.pw-tabs { display: inline-flex; border: 1px solid var(--color-border); border-radius: 10px; overflow: hidden; }
.pw-tabs button { border: none; background: var(--color-surface); padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer; color: var(--color-text-muted); }
.pw-tabs button + button { border-left: 1px solid var(--color-border); }
.pw-tabs button.active { background: var(--color-primary); color: #fff; font-weight: 600; }
.pw-figs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pw-fig { border: 1px solid var(--color-border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.pw-fig.in { background: rgba(63,157,87,.07); }
.pw-fig.out { background: rgba(224,83,59,.06); }
.pw-lbl { font-size: 12.5px; color: var(--color-text-muted); }
.pw-val { font-size: 22px; font-weight: 800; }
.pw-fig.in .pw-val { color: #2e7d46; }
.pw-fig.out .pw-val { color: #c0392b; }
.pw-max { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
@media (max-width: 600px) { .pw-figs { grid-template-columns: 1fr; } }
.pay-form .pf-grid { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.pay-form label { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; color: var(--color-text-muted); gap: 4px; flex: 0 0 auto; }
.pay-form input, .pay-form select { width: 100%; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 9px; font: inherit; font-size: 14px; font-weight: 400; color: var(--color-text); background: var(--color-surface); }
.pay-form .f-sum { width: 110px; }
.pay-form .f-proj { width: 120px; }
.pay-form .f-type { width: 120px; }
.pay-form .f-kind { width: 120px; }
.pay-form .f-date { width: 160px; }
.pay-form .f-com { flex: 1 1 180px; min-width: 160px; }
.pay-form .pf-add { flex: 0 0 auto; }
@media (max-width: 860px) { .pay-form label, .pay-form .f-com { flex: 1 1 45%; width: auto; } .pay-form .pf-add { width: 100%; } }
.pay-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.pay-search { flex: 1 1 220px; min-width: 180px; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: 9px; font: inherit; font-size: 14px; background: var(--color-surface); color: var(--color-text); }
.pay-controls .pw-tabs button { padding: 7px 11px; font-size: 12.5px; }
.pay-table { width: 100%; border-collapse: collapse; }
.pay-table th, .pay-table td { padding: 9px 10px; border-bottom: 1px solid var(--color-border); font-size: 14px; text-align: left; }
.pay-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; color: var(--color-text-muted); }
.pay-table .ta-r { text-align: right; }
.pay-dir { font-weight: 600; }
.pay-dir.in { color: #2e7d46; }
.pay-dir.out { color: #c0392b; }
.cell-clip { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; }
.deals-table th { white-space: nowrap; }
.deals-table td { vertical-align: top; }
/* Воронка */
.funnel { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.funnel-col { flex: 0 0 230px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 12px; padding: 10px; }
.funnel-col.drop { outline: 2px dashed var(--color-primary); outline-offset: -4px; }
.funnel-h { font-size: 12px; font-weight: 700; color: var(--color-text); margin-bottom: 8px; }
.funnel-meta { font-size: 11px; font-weight: 400; color: var(--color-text-muted); margin-top: 2px; }
.funnel-card { display: block; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px; padding: 9px 11px; margin-bottom: 8px; text-decoration: none; color: var(--color-text); cursor: grab; box-shadow: var(--shadow-sm); }
.funnel-card:hover { border-color: var(--color-primary); }
.funnel-card.dragging { opacity: .45; }
.fc-company { font-weight: 600; font-size: 13px; }
.fc-meta { font-size: 11.5px; color: var(--color-text-muted); margin-top: 3px; }
/* Карточка сделки */
.deal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .deal-grid { grid-template-columns: 1fr; } }
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 6px 0; border-bottom: 1px dashed var(--color-border); font-size: 13.5px; vertical-align: top; }
.kv td:first-child { color: var(--color-text-muted); width: 38%; }
.pc-modal { position: fixed; inset: 0; background: rgba(20,22,30,.45); display: flex; align-items: center; justify-content: center; z-index: 120; padding: 16px; }
.pc-modal[hidden] { display: none; }
.pc-card { background: var(--color-surface); border-radius: 14px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(20,22,30,.3); overflow: hidden; }
.pc-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--color-border); }
.pc-head b { font-size: 16px; }
.pc-head button { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--color-text-muted); }
.pc-list { max-height: 50vh; overflow-y: auto; padding: 6px 0; }
.pc-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 16px; font-size: 14px; }
.pc-row + .pc-row { border-top: 1px solid var(--color-border); }
.pc-row .pc-amt { font-weight: 700; white-space: nowrap; }
.pc-row.in .pc-amt { color: #2e7d46; }
.pc-row.out .pc-amt { color: #c0392b; }
.pc-foot { display: flex; gap: 16px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--color-border); font-weight: 700; }
@media (max-width: 760px) {
  .paycal-cell { min-height: 64px; padding: 4px 5px; }
  .paycal-grid { gap: 3px; }
  .paycal-day { font-size: 12px; }
}

/* ===== Доски (YouGile-стиль) ===== */
.bd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.bd-card { display: block; text-decoration: none; color: #fff; border-radius: 14px; padding: 16px; min-height: 96px; box-shadow: var(--shadow-sm); }
.bd-card:hover { transform: translateY(-2px); transition: transform .12s; }
.bd-blue { background: linear-gradient(160deg,#3a8fd6,#2f6fb0); }
.bd-green { background: linear-gradient(160deg,#3f9d57,#2e7d46); }
.bd-purple { background: linear-gradient(160deg,#8a5cd6,#6a40b0); }
.bd-orange { background: linear-gradient(160deg,#e0a23b,#c47f1e); }
.bd-gray { background: linear-gradient(160deg,#5b7290,#41566e); }
.bd-title { font-size: 16px; font-weight: 700; }
.bd-desc { font-size: 12.5px; opacity: .9; margin-top: 4px; }
.bd-meta { font-size: 12px; opacity: .85; margin-top: 12px; }

.yg-board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 10px; cursor: grab; }
.yg-board.grabbing, .dboard.grabbing { cursor: grabbing; user-select: none; }
.yg-board.grabbing .yg-card, .dboard.grabbing .dcard { pointer-events: none; }
.yg-col { flex: 0 0 280px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 14px; padding: 8px; }
.yg-col-h { display: flex; align-items: center; gap: 8px; padding: 9px 12px; margin: -2px -2px 9px; border-radius: 11px; background: #e8eaed; }
.yg-col-title { font-weight: 700; font-size: 13.5px; }
.yg-cnt { background: rgba(255,255,255,.6); }
/* цветные колонки (как в YouGile) */
.yg-col.c-green   { background:#eef7f1; } .yg-col.c-green   .yg-col-h{ background:#cdebd6; color:#1e7a44; }
.yg-col.c-yellow  { background:#fbf7e8; } .yg-col.c-yellow  .yg-col-h{ background:#f4e7b6; color:#876c14; }
.yg-col.c-teal    { background:#eaf6f4; } .yg-col.c-teal    .yg-col-h{ background:#c5ebe5; color:#1d7d72; }
.yg-col.c-purple  { background:#f3eefb; } .yg-col.c-purple  .yg-col-h{ background:#e2d6f6; color:#5b34a8; }
.yg-col.c-blue    { background:#eef5fc; } .yg-col.c-blue    .yg-col-h{ background:#d0e4f7; color:#2a6699; }
.yg-col.c-orange  { background:#fdf2e8; } .yg-col.c-orange  .yg-col-h{ background:#f7ddc1; color:#9a5a1e; }
.yg-col.c-pink    { background:#fcedf4; } .yg-col.c-pink    .yg-col-h{ background:#f5d4e5; color:#a33a72; }
.yg-col.c-red     { background:#fdeeec; } .yg-col.c-red     .yg-col-h{ background:#f6cfc9; color:#a33529; }
.yg-col.c-gray    { background:#f2f3f5; } .yg-col.c-gray    .yg-col-h{ background:#e3e5e9; color:#4a5260; }
.yg-cnt { font-size: 11px; color: var(--color-text-muted); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px; padding: 0 7px; }
.yg-x { border: none; background: none; cursor: pointer; color: var(--color-text-muted); font-size: 13px; }
.yg-col-body { min-height: 30px; max-height: calc(100vh - 250px); overflow-y: auto; overflow-x: hidden; padding-right: 2px; }
.yg-col-body::-webkit-scrollbar { width: 7px; } .yg-col-body::-webkit-scrollbar-thumb { background: #cbd0d8; border-radius: 4px; }
.yg-col-body.drop { outline: 2px dashed var(--color-primary); outline-offset: -3px; border-radius: 8px; }
.yg-col-sum { font-size: 11.5px; color: var(--color-text-muted); padding: 0 6px 8px; }
.yg-card { display: block; background: #fff; border: 1px solid var(--color-border); border-left: 3px solid transparent; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; color: var(--color-text); cursor: pointer; box-shadow: 0 1px 2px rgba(20,22,30,.05); }
.yg-card:hover { box-shadow: 0 4px 14px rgba(20,22,30,.10); }
.yg-card.dragging { opacity: .45; }
.yg-card.done { opacity: .65; }
.yg-card.done .yg-card-title { text-decoration: line-through; }
.yg-card.prio-high { border-left-color: #c0392b; }
.yg-card.prio-medium { border-left-color: #e0a23b; }
.yg-card.prio-low { border-left-color: #3a8fd6; }
.yg-card-top { display: flex; align-items: flex-start; gap: 7px; }
.yg-check-f { flex: 0 0 auto; line-height: 0; }
.yg-check { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #c4c9d1; background: #fff; color: #2e9d57; font-size: 11px; line-height: 1; cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.yg-check.on { background: #2e9d57; border-color: #2e9d57; color: #fff; }
.yg-card-title { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.yg-stickers { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.yg-st { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: #5b6675; background: #eef0f3; border: 1px solid #e2e6ec; border-radius: 7px; padding: 2px 8px; }
.yg-st b { font-weight: 700; font-size: 10px; opacity: .9; }
.yg-st.amount { color: #2e7d46; }
.yg-st.over { color: #c0392b; background: #fdeeec; border-color: #f3cfc9; }
.yg-st.tc-purple { color:#7c3aed; background:#f1eafd; border-color:#e0d2fa; }
.yg-st.tc-blue   { color:#2f6fb0; background:#eef5fc; border-color:#cfe2f5; }
.yg-st.tc-green  { color:#2e7d46; background:#eaf6ee; border-color:#c8e6d2; }
.yg-st.tc-orange { color:#c4701e; background:#fbeede; border-color:#f0d6b4; }
.yg-st.tc-teal   { color:#1d7d72; background:#e3f4f1; border-color:#c2e6e0; }
.yg-st.tc-pink   { color:#bb3a78; background:#fbe9f2; border-color:#f2cfe0; }
.yg-st.tc-red    { color:#c0392b; background:#fdeeec; border-color:#f3cfc9; }
.yg-st.tc-gray   { color:#5b6675; background:#f1f3f6; border-color:#e2e6ec; }
.yg-card-foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; padding-top: 8px; border-top: 1px solid #eef0f3; }
.yg-prog { font-size: 11px; color: var(--color-text-muted); }
.yg-badge { font-size: 11px; color: var(--color-text-muted); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 8px; padding: 1px 6px; }
.yg-badge.over { color: #c0392b; border-color: #e0a8a0; }
.yg-badge.sprint { color: #6a40b0; }
.yg-badge.amount { color: #2e7d46; font-weight: 700; border-color: #bfe0c8; background: #f0f8f2; }
.yg-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.yg-tag { font-size: 10.5px; font-weight: 600; color: #5b6675; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 6px; padding: 1px 7px; }
.yg-tag.tc-purple { color:#7c3aed; background:#f1eafd; border-color:#e0d2fa; }
.yg-tag.tc-blue   { color:#2f6fb0; background:#eef5fc; border-color:#cfe2f5; }
.yg-tag.tc-green  { color:#2e7d46; background:#eaf6ee; border-color:#c8e6d2; }
.yg-tag.tc-orange { color:#c4701e; background:#fbeede; border-color:#f0d6b4; }
.yg-tag.tc-teal   { color:#1d7d72; background:#e3f4f1; border-color:#c2e6e0; }
.yg-tag.tc-pink   { color:#bb3a78; background:#fbe9f2; border-color:#f2cfe0; }
.yg-tag.tc-red    { color:#c0392b; background:#fdeeec; border-color:#f3cfc9; }
.yg-tag.tc-gray   { color:#5b6675; background:#f1f3f6; border-color:#e2e6ec; }
.yg-avas { display: inline-flex; gap: 3px; margin-left: auto; }
.yg-ava { width: 22px; height: 22px; border-radius: 50%; background: var(--color-primary); color: #fff; font-size: 9px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.yg-add input, .yg-addcol input { width: 100%; border: 1px dashed var(--color-border); background: transparent; border-radius: 9px; padding: 7px 10px; font: inherit; font-size: 12.5px; color: var(--color-text); }
.yg-add input:focus, .yg-addcol input:focus { border-style: solid; background: var(--color-surface); outline: none; }
.yg-addcol { flex: 0 0 230px; }
.yg-assignee { display: inline-flex; align-items: center; gap: 6px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 20px; padding: 2px 8px 2px 2px; font-size: 12.5px; }
/* Подзадачи (сворачиваемые группы, как в YouGile) */
.subtask { border: 1px solid var(--color-border); border-radius: 10px; margin-bottom: 8px; background: #fbfbfc; }
.subtask > summary { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; list-style: none; font-weight: 600; font-size: 13.5px; }
.subtask > summary::-webkit-details-marker { display: none; }
.st-chev { color: var(--color-text-muted); transition: transform .15s; font-size: 11px; }
.subtask[open] > summary .st-chev { transform: rotate(90deg); }
.st-title { flex: 1; }
.st-prog { font-size: 11px; color: var(--color-text-muted); background: #fff; border: 1px solid var(--color-border); border-radius: 10px; padding: 1px 8px; }
.st-x { border: none; background: none; cursor: pointer; color: var(--color-text-muted); font-size: 12px; }
.st-bar { height: 4px; background: #e6e8ec; border-radius: 3px; margin: 0 12px 4px; overflow: hidden; }
.st-bar > span { display: block; height: 100%; background: #2e9d57; border-radius: 3px; transition: width .2s; }
.st-body { padding: 4px 12px 10px; }

/* Доска задач (стикеры) */
.board-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .board-cols { grid-template-columns: 1fr; } }
.board-col { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 14px; padding: 12px; }
.board-col-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--color-text-muted); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.board-cnt { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px; padding: 0 7px; font-size: 11px; }
.board-empty { color: var(--color-text-muted); font-size: 13px; text-align: center; padding: 16px 0; }
.sticky {
  position: relative; border-radius: 14px;
  padding: 13px 14px; margin-bottom: 12px;
  border: 1px solid rgba(20,22,30,.06);
  /* Многослойная мягкая тень */
  box-shadow:
    0 1px 2px rgba(20,22,30,.06),
    0 4px 10px rgba(20,22,30,.08),
    0 14px 28px rgba(20,22,30,.10);
  transition: transform .22s cubic-bezier(.22,1,.36,1), box-shadow .22s cubic-bezier(.22,1,.36,1);
  /* Анимация появления: лёгкий подъём + раскрытие */
  animation: stickyIn .55s cubic-bezier(.22,1,.36,1) both;
  transform-origin: 50% 20%;
  will-change: transform, opacity;
}
.sticky:hover {
  transform: translateY(-3px) scale(1.012);
  box-shadow:
    0 1px 2px rgba(20,22,30,.08),
    0 10px 20px rgba(20,22,30,.14),
    0 26px 48px rgba(20,22,30,.18);
}
.sticky:active {
  transform: translateY(-1px) scale(1.005);
  transition: transform .08s ease;
}

@keyframes stickyIn {
  0%   { opacity: 0; transform: translateY(14px) scale(.96) rotate(-.6deg); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}

/* Каскад появления: каждая последующая карточка с небольшой задержкой,
   чтобы получился «волной» эффект сверху вниз внутри колонки. */
.sticky:nth-child(1)  { animation-delay: .02s; }
.sticky:nth-child(2)  { animation-delay: .08s; }
.sticky:nth-child(3)  { animation-delay: .14s; }
.sticky:nth-child(4)  { animation-delay: .20s; }
.sticky:nth-child(5)  { animation-delay: .26s; }
.sticky:nth-child(6)  { animation-delay: .32s; }
.sticky:nth-child(7)  { animation-delay: .38s; }
.sticky:nth-child(8)  { animation-delay: .44s; }
.sticky:nth-child(9)  { animation-delay: .50s; }
.sticky:nth-child(10) { animation-delay: .56s; }
.sticky:nth-child(n+11) { animation-delay: .60s; }

/* При перетаскивании анимация мешает — отключаем. */
.sticky.dragging { animation: none !important; transform: none; }

/* Уважаем системную настройку «уменьшить движение» */
@media (prefers-reduced-motion: reduce) {
  .sticky { animation: none; transition: none; }
  .sticky:hover { transform: none; }
}

/* Плавное появление колонок при загрузке доски */
.board-col {
  animation: colIn .5s cubic-bezier(.22,1,.36,1) both;
}
.board-col:nth-child(1) { animation-delay: 0s; }
.board-col:nth-child(2) { animation-delay: .08s; }
.board-col:nth-child(3) { animation-delay: .16s; }
.board-col:nth-child(n+4) { animation-delay: .24s; }
@keyframes colIn {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .board-col { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   Глобальные анимации появления для карточек и плиток по всей платформе
   ═══════════════════════════════════════════════════════════════════ */
@keyframes platformFadeUp {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes platformPopIn {
  0%   { opacity: 0; transform: scale(.92); }
  60%  { opacity: 1; transform: scale(1.02); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes platformRowIn {
  0%   { opacity: 0; transform: translateX(-6px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* KPI-плитки на дашборде и складе */
.wh-kpi {
  animation: platformFadeUp .45s cubic-bezier(.22,1,.36,1) both;
}
.wh-kpi:nth-child(1){ animation-delay: .04s; }
.wh-kpi:nth-child(2){ animation-delay: .10s; }
.wh-kpi:nth-child(3){ animation-delay: .16s; }
.wh-kpi:nth-child(4){ animation-delay: .22s; }
.wh-kpi:nth-child(n+5){ animation-delay: .28s; }

/* Карточки дашборда (виджеты, графики, мини-таблицы) */
.dash-card, .dash-stage, .dash-mini {
  animation: platformFadeUp .5s cubic-bezier(.22,1,.36,1) both;
}
.dash-stage:nth-child(1){ animation-delay: .02s; }
.dash-stage:nth-child(2){ animation-delay: .06s; }
.dash-stage:nth-child(3){ animation-delay: .10s; }
.dash-stage:nth-child(4){ animation-delay: .14s; }
.dash-stage:nth-child(5){ animation-delay: .18s; }
.dash-stage:nth-child(6){ animation-delay: .22s; }
.dash-stage:nth-child(7){ animation-delay: .26s; }
.dash-stage:nth-child(n+8){ animation-delay: .30s; }

.dash-grid-2 .dash-card:nth-child(1){ animation-delay: .12s; }
.dash-grid-2 .dash-card:nth-child(2){ animation-delay: .20s; }

.dash-mini:nth-child(1){ animation-delay: .04s; }
.dash-mini:nth-child(2){ animation-delay: .08s; }
.dash-mini:nth-child(3){ animation-delay: .12s; }
.dash-mini:nth-child(4){ animation-delay: .16s; }
.dash-mini:nth-child(n+5){ animation-delay: .20s; }

/* Hover-лифт для dash-card (раньше был только у stage) */
.dash-card { transition: transform .18s cubic-bezier(.22,1,.36,1), box-shadow .18s ease; }
.dash-card:hover { transform: translateY(-2px); }

/* Карточки и колонки доски «Производство» */
.pb-card {
  animation: platformFadeUp .5s cubic-bezier(.22,1,.36,1) both;
}
.pb-cards .pb-card:nth-child(1){ animation-delay: .03s; }
.pb-cards .pb-card:nth-child(2){ animation-delay: .07s; }
.pb-cards .pb-card:nth-child(3){ animation-delay: .11s; }
.pb-cards .pb-card:nth-child(4){ animation-delay: .15s; }
.pb-cards .pb-card:nth-child(5){ animation-delay: .19s; }
.pb-cards .pb-card:nth-child(6){ animation-delay: .23s; }
.pb-cards .pb-card:nth-child(7){ animation-delay: .27s; }
.pb-cards .pb-card:nth-child(8){ animation-delay: .31s; }
.pb-cards .pb-card:nth-child(n+9){ animation-delay: .35s; }

.pb-col {
  animation: platformFadeUp .45s cubic-bezier(.22,1,.36,1) both;
}
.pb-col:nth-child(1){ animation-delay: 0s; }
.pb-col:nth-child(2){ animation-delay: .06s; }
.pb-col:nth-child(3){ animation-delay: .12s; }
.pb-col:nth-child(4){ animation-delay: .18s; }
.pb-col:nth-child(5){ animation-delay: .24s; }
.pb-col:nth-child(n+6){ animation-delay: .30s; }

/* Строки таблицы — лёгкий каскадный fade-in слева */
.wh-table tbody tr {
  animation: platformRowIn .35s ease-out both;
}
.wh-table tbody tr:nth-child(1){ animation-delay: .02s; }
.wh-table tbody tr:nth-child(2){ animation-delay: .04s; }
.wh-table tbody tr:nth-child(3){ animation-delay: .06s; }
.wh-table tbody tr:nth-child(4){ animation-delay: .08s; }
.wh-table tbody tr:nth-child(5){ animation-delay: .10s; }
.wh-table tbody tr:nth-child(6){ animation-delay: .12s; }
.wh-table tbody tr:nth-child(7){ animation-delay: .14s; }
.wh-table tbody tr:nth-child(8){ animation-delay: .16s; }
.wh-table tbody tr:nth-child(9){ animation-delay: .18s; }
.wh-table tbody tr:nth-child(10){ animation-delay: .20s; }
.wh-table tbody tr:nth-child(n+11){ animation-delay: .22s; }

/* Chip'ы / категории / status-pill — pop-in */
.wh-chip, .status-pill, .dept-btn, .pb-meta-tag {
  animation: platformPopIn .35s cubic-bezier(.22,1,.36,1) both;
}
.wh-chip:nth-child(1){ animation-delay: .02s; }
.wh-chip:nth-child(2){ animation-delay: .05s; }
.wh-chip:nth-child(3){ animation-delay: .08s; }
.wh-chip:nth-child(4){ animation-delay: .11s; }
.wh-chip:nth-child(5){ animation-delay: .14s; }
.wh-chip:nth-child(6){ animation-delay: .17s; }
.wh-chip:nth-child(n+7){ animation-delay: .20s; }

/* Боковая панель карточки проекта (slide-in справа) */
.pb-panel.open { animation: panelSlideIn .35s cubic-bezier(.22,1,.36,1); }
@keyframes panelSlideIn {
  0%   { transform: translateX(40px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}
.pb-section {
  animation: platformFadeUp .4s cubic-bezier(.22,1,.36,1) both;
}
.pb-section:nth-of-type(1){ animation-delay: .10s; }
.pb-section:nth-of-type(2){ animation-delay: .18s; }
.pb-section:nth-of-type(n+3){ animation-delay: .24s; }

/* Уважение к настройке «уменьшить движение» */
@media (prefers-reduced-motion: reduce) {
  .wh-kpi, .dash-card, .dash-stage, .dash-mini,
  .pb-card, .pb-col, .pb-section, .pb-panel.open,
  .wh-table tbody tr, .wh-chip, .status-pill, .dept-btn, .pb-meta-tag {
    animation: none !important;
  }
}
/* Шапка стикера: два бейджа (отдел слева + ответственный справа) на одной линии. */
.sticky-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.sticky-head > * { margin-bottom: 0 !important; }
.sticky-head > form { flex: 0 1 auto; min-width: 0; }
/* Старые правила assignee (абсолютное позиционирование) больше не нужны. */
.sticky-assignee-form { margin: 0; }
.sticky-assignee {
  font-size: 11px; color: #5a6273;
  background: rgba(255,255,255,.55);
  border-radius: 999px; padding: 3px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Бейдж ответственного (когда выбран) — тот же размер и форма, что у .sticky-dept,
   но с нейтральной заливкой. Используется через класс .sticky-assignee-pill в шаблоне. */
.sticky-assignee-pill {
  color: #5a6273 !important;
  background-color: rgba(255,255,255,.55) !important;
  border-color: rgba(20,22,30,.10) !important;
  background-image: none !important;
  padding: 5px 10px !important;
  font-weight: 700 !important;
}
/* Пустой бейдж ответственного — пунктирная нейтральная пилюля.
   Наследует все остальные стили от .sticky-dept (размер, padding, стрелочка). */
.sticky-assignee-empty {
  color: #5a6273 !important;
  background-color: rgba(255,255,255,.40) !important;
  border-color: rgba(20,22,30,.22) !important;
  border-style: dashed !important;
  font-weight: 600 !important;
  animation: none !important; /* перебиваем пульсацию, если у dept-empty она есть */
}
.sticky-assignee-empty:hover {
  background-color: rgba(255,255,255,.7) !important;
  border-color: rgba(20,22,30,.45) !important;
  color: #2a2f3a !important;
}
.sticky-cmt { border: none; background: rgba(255,255,255,.55); border-radius: 10px; padding: 2px 9px; font-size: 12px; color: #3a4150; cursor: pointer; }
.sticky-cmt:hover { background: rgba(255,255,255,.85); }
/* мини-чат комментариев внутри стикера */
.sticky-chat { margin-top: 10px; border-top: 1px solid rgba(20,22,30,.12); padding-top: 8px; }
.sticky-chat[hidden] { display: none; }
.chat-msgs { max-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.chat-msg { background: rgba(255,255,255,.7); border-radius: 9px; padding: 6px 8px; }
.chat-meta { font-size: 10.5px; color: #5a6273; margin-bottom: 2px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cmt-del { border: none; background: none; cursor: pointer; color: #99303a; font-size: 12px; line-height: 1; padding: 0 2px; opacity: .6; }
.cmt-del:hover { opacity: 1; }
.chat-text { font-size: 12.5px; color: #2a2f3a; white-space: pre-wrap; word-break: break-word; }
.chat-empty { font-size: 12px; color: #5a6273; padding: 2px 0 6px; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; border: 1px solid rgba(20,22,30,.18); border-radius: 9px; padding: 6px 9px; font: inherit; font-size: 12.5px; background: rgba(255,255,255,.85); }
.chat-send { border: none; background: var(--color-primary); color: #fff; border-radius: 9px; padding: 0 12px; cursor: pointer; font-size: 13px; }
/* перетаскивание */
.sticky[draggable] { cursor: grab; }
.sticky.dragging { opacity: .45; }
.board-col.drop { outline: 2px dashed var(--color-primary); outline-offset: -4px; }
/* Цветные стикеры — диагональный градиент сверху вниз + легкий блик слева сверху. */
.sticky-yellow {
  background:
    radial-gradient(ellipse at top left, rgba(255,255,255,.55), transparent 55%),
    linear-gradient(160deg, #fffadf 0%, #fff0a8 55%, #ffe680 100%);
}
.sticky-green {
  background:
    radial-gradient(ellipse at top left, rgba(255,255,255,.55), transparent 55%),
    linear-gradient(160deg, #e6fbeb 0%, #c8f1d3 55%, #abe6bb 100%);
}
.sticky-blue {
  background:
    radial-gradient(ellipse at top left, rgba(255,255,255,.55), transparent 55%),
    linear-gradient(160deg, #e3f3fc 0%, #bfe3f7 55%, #9bd1f0 100%);
}
.sticky-pink {
  background:
    radial-gradient(ellipse at top left, rgba(255,255,255,.55), transparent 55%),
    linear-gradient(160deg, #fde3ee 0%, #f9c5dc 55%, #f3a5c8 100%);
}
.sticky-gray {
  background:
    radial-gradient(ellipse at top left, rgba(255,255,255,.55), transparent 55%),
    linear-gradient(160deg, #f1f2f5 0%, #dee1e8 55%, #c5c9d2 100%);
}
.sticky-title { font-weight: 700; font-size: 14px; color: #2a2f3a; }
.sticky.has-assignee .sticky-title { padding-right: 64px; }
.sticky-body { font-size: 13px; color: #3a4150; margin-top: 6px; white-space: pre-wrap; }
.sticky-body.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sticky-body.clamp.open { display: block; -webkit-line-clamp: unset; overflow: visible; }
.sticky-more {
  margin-top: 4px; padding: 0; background: none; border: 0; cursor: pointer;
  font-size: 11.5px; font-weight: 600; color: var(--color-primary);
}
.sticky-more:hover { text-decoration: underline; }
.sticky-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.sticky-meta { font-size: 11.5px; color: #5a6273; }
.sticky-actions { display: flex; align-items: center; gap: 6px; }
.sticky-move { font-size: 11px; border: 1px solid rgba(20,22,30,.15); border-radius: 7px; background: rgba(255,255,255,.6); padding: 2px 4px; }
.sticky-edit { border: none; background: none; cursor: pointer; color: #3a4150; font-size: 14px; }
.sticky-del { border: none; background: none; cursor: pointer; color: #99303a; font-size: 14px; }

/* Пайплайн проектов */
.pipe-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1100px) { .pipe-board { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .pipe-board { grid-template-columns: 1fr; } }
.pipe-col { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px; }
.pipe-col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 0 2px; }
.pc-title { font-weight: 700; font-size: 14px; }
.pc-count { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 100px; padding: 1px 9px; font-size: 12px; color: var(--color-text-muted); }
.pipe-drop { display: flex; flex-direction: column; gap: 10px; min-height: 80px; border-radius: 10px; transition: background .12s; }
.pipe-drop.over { background: var(--color-hover); box-shadow: inset 0 0 0 2px var(--color-primary); }
.pipe-empty { text-align: center; color: var(--color-text-muted); padding: 14px 0; font-size: 13px; }
.pproject { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 12px 13px; box-shadow: var(--shadow-sm); cursor: grab; }
.pproject:active { cursor: grabbing; }
.pproject.dragging { opacity: .5; }
.pp-top { display: flex; align-items: center; justify-content: space-between; min-height: 16px; margin-bottom: 4px; }
.pp-code { font-size: 11px; font-weight: 700; color: var(--color-text-muted); letter-spacing: .3px; }
.pp-unread { background: var(--color-primary); color: #fff; border-radius: 100px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.pp-name { display: block; font-weight: 600; font-size: 14px; color: var(--color-text); line-height: 1.3; }
.pp-name:hover { color: var(--color-primary); }
.pp-stage { font-size: 12px; color: var(--color-text-muted); margin-top: 5px; }
.pp-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; margin-top: 6px; }
.pp-foot .avatar-xs { width: 22px; height: 22px; font-size: 10px; display: inline-flex; vertical-align: middle; margin-right: 3px; }

/* Модалка установки PWA */
.install-modal { position: fixed; inset: 0; background: rgba(20,22,30,.5); display: none; align-items: center; justify-content: center; z-index: 80; padding: 20px; }
.install-modal.open { display: flex; }
.install-card { background: var(--color-surface); border-radius: 16px; max-width: 380px; width: 100%; padding: 26px 26px 24px; position: relative; box-shadow: 0 20px 60px rgba(20,22,30,.3); }
.install-card h3 { margin: 0 0 14px; font-size: 18px; }
.install-card #installSteps { font-size: 14px; line-height: 1.7; color: var(--color-text); }
.install-x { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 24px; line-height: 1; color: var(--color-text-muted); cursor: pointer; }

/* ===== Чат: пузыри в стиле Telegram ===== */
/* фон-«ватман»: мягкий стальной градиент + инженерная сетка (мелкая + крупная) */
.chat-feed {
  background-color: #e9edf2;
  background-image:
    radial-gradient(circle at 18% 12%, rgba(74,95,120,.10), transparent 42%),
    radial-gradient(circle at 85% 80%, rgba(58,77,99,.09), transparent 45%),
    linear-gradient(rgba(58,77,99,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(58,77,99,.05) 1px, transparent 1px),
    linear-gradient(rgba(58,77,99,.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(58,77,99,.09) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 28px 28px, 28px 28px, 140px 140px, 140px 140px;
}
/* сообщения прижаты к низу (как в мессенджере): мало сообщений — внизу у поля ввода */
.chat-feed { flex: 1 1 auto; }
.chat-feed::before { content: ""; margin-top: auto; }
/* разделитель дат */
.chat-day { text-align: center; margin: 4px 0; }
.chat-day span { display: inline-block; background: rgba(40,56,74,.12); color: var(--color-text); font-size: 11.5px; font-weight: 700; padding: 3px 12px; border-radius: 100px; text-transform: capitalize; backdrop-filter: blur(2px); }
.msg { display: flex; gap: 8px; max-width: 80%; align-items: flex-end; }
.msg-in { align-self: flex-start; }
.msg-out { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar { width: 30px; height: 30px; font-size: 11px; flex-shrink: 0; }
.bubble { position: relative; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 14px; padding: 7px 12px 5px; box-shadow: var(--shadow-sm); min-width: 0; max-width: 100%; }
.msg-in.tail .bubble { border-bottom-left-radius: 5px; }
/* свои сообщения: светлее графит + адаптивный градиент во весь экран (как в Telegram) */
.msg-out .bubble { background: linear-gradient(160deg, #6a83a2 0%, #546983 45%, #495d73 100%); background-attachment: fixed; background-size: 100vw 100vh; color: #fff; border-color: transparent; }
.msg-out.tail .bubble { border-bottom-right-radius: 5px; }
/* хвостики пузырей — только у последнего сообщения серии */
.msg-in.tail .bubble::before { content: ""; position: absolute; left: -5px; bottom: 0; width: 10px; height: 14px; background: var(--color-surface); border-left: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); border-bottom-left-radius: 12px 8px; clip-path: polygon(0 100%, 100% 100%, 100% 0); }
.msg-out.tail .bubble::before { content: ""; position: absolute; right: -5px; bottom: 0; width: 10px; height: 14px; background: linear-gradient(160deg, #6a83a2 0%, #546983 45%, #495d73 100%); background-attachment: fixed; background-size: 100vw 100vh; border-bottom-right-radius: 12px 8px; clip-path: polygon(0 100%, 100% 100%, 0 0); }
/* группировка подряд идущих сообщений одного автора */
.msg.grouped { margin-top: -12.5px; }
.avatar-spacer { visibility: hidden; }
.b-author { font-size: 12px; font-weight: 700; color: var(--color-primary); margin-bottom: 2px; cursor: pointer; }
.b-author:hover { text-decoration: underline; }
.msg-out .b-author { color: #fff; opacity: .9; }
.msg-in .avatar { cursor: pointer; }
.b-text { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; display: inline; }
/* время прижато к низу-справа на одной строке с текстом (как в Telegram) */
.b-time { font-size: 9px; opacity: .55; float: right; margin: 3px 0 0 10px; white-space: nowrap; }
.bubble::after, .b-foot::after { content: ""; display: block; clear: both; }
.msg-out .b-time { color: #fff; opacity: .8; }
.b-file { display: inline-block; font-size: 13px; font-weight: 600; margin-top: 3px; }
.msg-out .b-file { color: #fff; }
.chat-compose { align-items: center; }
.chat-compose .file-lbl { display: flex; align-items: center; justify-content: center; color: var(--color-text-muted); cursor: pointer; padding: 7px; border-radius: 50%; transition: color .12s, background .12s; }
.chat-compose .file-lbl:hover { color: var(--color-primary); background: var(--color-hover); }
.chat-compose .file-lbl svg { width: 21px; height: 21px; display: block; }
/* меню прикрепления + чип выбранного файла */
.att-menu[hidden], .cloud-modal[hidden], .att-chip[hidden] { display: none !important; }
.att-wrap { position: relative; }
.att-menu { position: absolute; bottom: 46px; left: 0; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 190px; z-index: 30; display: flex; flex-direction: column; gap: 2px; }
.att-menu button { background: none; border: none; text-align: left; padding: 10px 12px; border-radius: 8px; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--color-text); }
.att-menu button:hover { background: var(--color-hover); }
.compose-mid { flex: 1; display: flex; flex-direction: column; gap: 6px; position: relative; }
/* @упоминания */
.mention { color: var(--color-primary); font-weight: 600; cursor: pointer; }
.mention:hover { text-decoration: underline; }
.msg-out .mention { color: #d3e3f6; }
.mention-pop { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(20,22,30,.20); overflow-y: auto; max-height: 240px; z-index: 40; }
.mention-pop[hidden] { display: none; }
.mn-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none; cursor: pointer; padding: 8px 12px; font: inherit; font-size: 14px; color: var(--color-text); }
.mn-item:hover { background: var(--color-hover); }
.mn-ava { width: 30px; height: 30px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mn-name { font-weight: 600; }
.att-chip { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; background: var(--color-primary-soft); border: 1px solid var(--color-border); border-radius: 100px; padding: 4px 6px 4px 12px; font-size: 12.5px; font-weight: 600; max-width: 100%; }
.att-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-chip button { background: none; border: none; cursor: pointer; color: var(--color-text-muted); font-size: 14px; line-height: 1; padding: 2px 4px; }
.chat-compose .compose-mid textarea { width: 100%; }
/* модалка выбора файла из Облака */
.cloud-modal { position: fixed; inset: 0; background: rgba(20,22,30,.45); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 20px; }
.cloud-card { background: var(--color-surface); border-radius: 16px; width: 100%; max-width: 460px; max-height: 70vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(20,22,30,.3); overflow: hidden; }
.cloud-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--color-border); font-size: 15px; }
.cloud-head button { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--color-text-muted); }
.cloud-card #cloudSearch { margin: 12px 16px; width: auto; }
.cloud-list { overflow-y: auto; padding: 0 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.cloud-item { display: flex; align-items: center; gap: 12px; background: none; border: none; border-radius: 10px; padding: 9px 10px; cursor: pointer; text-align: left; width: 100%; }
.cloud-item:hover { background: var(--color-hover); }
.cloud-item .ci-ext { flex-shrink: 0; min-width: 42px; text-align: center; font-size: 10px; font-weight: 800; color: var(--color-text-muted); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 6px; padding: 4px 6px; }
.cloud-item .ci-mid { display: flex; flex-direction: column; min-width: 0; }
.cloud-item .ci-mid b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cloud-item .ci-mid span { font-size: 11.5px; font-weight: 400; color: var(--color-text-muted); }
.cloud-item .ci-ico { flex-shrink: 0; width: 42px; display: flex; align-items: center; justify-content: center; color: var(--color-primary); }
.cloud-item .ci-ico svg { width: 24px; height: 24px; }
.cloud-head b { font-weight: 600; }
.cloud-crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 0 16px 8px; font-size: 13px; }
.cloud-crumbs button { background: none; border: none; color: var(--color-primary); font-weight: 600; cursor: pointer; font-size: 13px; padding: 2px 0; }
.cloud-crumbs .sep { color: var(--color-text-muted); }
.cloud-empty { text-align: center; color: var(--color-text-muted); padding: 24px; font-size: 13.5px; font-weight: 400; }

/* карточка сотрудника в чате (по клику на участника) */
.chat-member { cursor: pointer; width: 100%; text-align: left; }
.chat-member:hover { background: var(--color-hover); border-radius: 8px; }
.ep-ov { position: fixed; inset: 0; background: rgba(20,22,30,.4); z-index: 88; opacity: 0; pointer-events: none; transition: opacity .2s; }
.ep-ov.open { opacity: 1; pointer-events: auto; }
.ep-panel { position: fixed; top: 0; right: 0; height: 100%; width: 320px; max-width: 88%; background: var(--color-surface); border-left: 1px solid var(--color-border); box-shadow: -10px 0 30px rgba(20,22,30,.18); z-index: 89; transform: translateX(100%); transition: transform .22s ease; padding: 24px 20px; overflow-y: auto; }
.ep-panel.open { transform: translateX(0); }
.ep-x { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 24px; line-height: 1; color: var(--color-text-muted); cursor: pointer; }
.ep-top { text-align: center; padding: 8px 0 18px; border-bottom: 1px solid var(--color-border); }
.ep-ava { width: 66px !important; height: 66px !important; font-size: 23px !important; margin: 0 auto 12px; display: inline-flex; }
.ep-name { font-weight: 700; font-size: 17px; }
.ep-pos { color: var(--color-text-muted); font-size: 13px; margin-top: 3px; }
.ep-rows { margin: 14px 0; }
.ep-r { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--color-border); font-size: 13.5px; }
.ep-r span { color: var(--color-text-muted); }
.ep-r b { font-weight: 600; text-align: right; word-break: break-word; }
.ep-dm { display: flex; width: 100%; justify-content: center; margin-top: 16px; background: var(--color-primary); color: #fff; }
.ep-dm:hover { background: var(--color-primary-hover); color: #fff; }
.btn.chat-send { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 15px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* колонка пузыря + реакции */
.msg-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-items: flex-start; }
.msg-out .msg-col { align-items: flex-end; }
/* пузырь подстраивается по ширине под содержимое (как в Telegram) */
/* ширина пузыря строго по содержимому — сообщения разной ширины, как в Telegram */
.bubble { width: fit-content; max-width: 100%; }
.rx-row { display: flex; align-items: center; gap: 6px; margin-top: 5px; clear: both; }
.rx-row .b-time { margin: 0 0 0 auto; float: none; }
.rx-chips { display: flex; gap: 4px; flex-wrap: wrap; }
/* чип реакции: эмодзи + мини-аватары тех, кто поставил (вместо числа) */
.rx-chip { background: var(--color-bg); border: none; border-radius: 100px; padding: 2px 8px 2px 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; line-height: 1.5; animation: rxpop .16s ease; }
.rx-emo { font-size: 14px; line-height: 1; }
.rx-avas { display: inline-flex; align-items: center; }
.rx-ava { width: 16px; height: 16px; border-radius: 50%; font-size: 8px; font-weight: 700; color: #fff; display: inline-flex; align-items: center; justify-content: center; margin-left: -4px; }
.rx-ava:first-child { margin-left: 0; }
.rx-more { font-size: 10px; font-weight: 700; color: var(--color-text-muted); margin-left: 2px; }
.rx-chip.mine { background: var(--color-primary-soft); }
.msg-out .rx-chip { background: rgba(255,255,255,.18); }
.msg-out .rx-chip.mine { background: rgba(255,255,255,.32); }
.msg-out .rx-more { color: rgba(255,255,255,.85); }
.rx-add { display: none; }
@keyframes rxpop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* пикер реакций */
.rx-picker { position: fixed; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 100px; box-shadow: var(--shadow); padding: 5px 8px; display: flex; gap: 2px; z-index: 90; animation: rxpop .12s ease; }
.rx-picker button { background: none; border: none; font-size: 21px; cursor: pointer; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; transition: transform .1s, background .1s; }
.rx-picker button:hover { transform: scale(1.3); background: var(--color-hover); }

/* ===== Закреплённое сообщение ===== */
.pin-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--color-border); background: var(--color-surface); cursor: pointer; color: var(--color-primary); }
.pin-bar.hidden { display: none; }
.pin-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pin-mid b { font-size: 12px; color: var(--color-primary); }
.pin-mid span { font-size: 13px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-x { border: none; background: none; cursor: pointer; color: var(--color-text-muted); font-size: 14px; padding: 2px 4px; }

/* ===== Цитата-ответ внутри пузыря ===== */
.b-reply { display: flex; flex-direction: column; gap: 1px; border-left: 3px solid currentColor; padding: 2px 8px; margin-bottom: 4px; border-radius: 4px; background: rgba(0,0,0,.05); cursor: pointer; max-width: 100%; min-width: 0; overflow: hidden; }
.msg-out .b-reply { background: rgba(255,255,255,.16); }
.br-author { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.br-text { font-size: 12.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-edited { font-size: 10px; opacity: .7; font-style: italic; }
/* Инлайн фото/видео в сообщении — на всю ширину пузыря (как в Telegram) */
.bubble.has-media { padding: 0; overflow: hidden; width: 290px; }
.b-media-wrap { position: relative; line-height: 0; }
.b-media-wrap:has(.b-author.over)::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 48px; background: linear-gradient(rgba(0,0,0,.5), rgba(0,0,0,0)); pointer-events: none; z-index: 1; }
.b-author.over { position: absolute; top: 7px; left: 11px; z-index: 2; margin: 0; font-size: 13px; font-weight: 700; text-shadow: 0 1px 4px rgba(0,0,0,.75); }
.b-media { display: block; line-height: 0; }
.b-media img, video.b-media { display: block; width: 100%; height: auto; max-height: 420px; object-fit: cover; background: #000; cursor: pointer; }
.b-foot { padding: 6px 12px 5px; }
.b-reply.pad { margin: 8px 10px 2px; }
/* фото без подписи — время поверх фото в углу */
.has-media.nocap .b-foot { position: absolute; right: 7px; bottom: 7px; padding: 1px 7px; background: rgba(0,0,0,.5); border-radius: 10px; display: inline-flex; align-items: center; }
.has-media.nocap .b-foot::after { display: none; }
.has-media.nocap .b-foot .b-time { color: #fff; opacity: .95; float: none; margin: 0; font-size: 10px; }
.has-media.nocap .b-foot:has(.rx-row) { position: static; right: auto; bottom: auto; padding: 6px 12px 5px; background: none; }
/* коллаж: несколько фото подряд от одного автора без подписи */
.album { display: flex; flex-direction: column; gap: 3px; max-width: 80%; align-self: flex-start; border-radius: 14px; overflow: hidden; margin: 2px 0; }
.album.msg-out { align-self: flex-end; }
.alb-row { display: flex; gap: 3px; }
.album .msg { display: block; max-width: none; margin: 0; min-width: 0; flex: 1 1 0; }
.album .msg-col { width: 100%; height: 100%; }
.album .avatar, .album .avatar-spacer, .album .b-author.over, .album .b-media-wrap::before, .album .b-foot { display: none; }
.album .bubble.has-media { width: 100%; height: 100%; border-radius: 0; }
.album .b-media-wrap, .album .b-media { height: 100%; display: block; }
.album .b-media img, .album video.b-media { width: 100%; height: 100%; object-fit: cover; max-height: none; border-radius: 0; display: block; }
/* ===== Выбор сообщений ===== */
.sel-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 130; display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); box-shadow: 0 2px 12px rgba(20,22,30,.10); }
.sel-bar[hidden] { display: none; }
.sel-x { border: none; background: none; font-size: 18px; line-height: 1; cursor: pointer; color: var(--color-text); padding: 4px 6px; }
.sel-count { font-weight: 700; flex: 1; font-size: 15px; }
.sel-acts { display: flex; gap: 4px; }
.sel-acts button { border: none; background: none; cursor: pointer; font-size: 18px; padding: 6px 9px; border-radius: 9px; }
.sel-acts button:hover { background: var(--color-hover); }
.sel-danger { color: var(--color-danger); }
body.sel-mode .chat-feed .msg { cursor: pointer; }
body.sel-mode .msg.selected { background: rgba(58,143,214,.14); border-radius: 12px; }
.msg.selected .bubble { outline: 2px solid var(--color-primary); outline-offset: 1px; }
/* ===== Создание чата ===== */
.tg-newchat { color: var(--color-primary); margin-top: auto; }
.tg-newchat svg { width: 22px; height: 22px; }
.tg-newchat .tg-flabel { color: var(--color-primary); font-weight: 700; }
.tg-newchat:hover { background: var(--color-hover); }
.nc-modal { position: fixed; inset: 0; background: rgba(20,22,30,.45); display: flex; align-items: center; justify-content: center; z-index: 120; padding: 16px; }
.nc-modal[hidden] { display: none; }
.nc-card { background: var(--color-surface); border-radius: 16px; width: 100%; max-width: 440px; max-height: 84vh; display: flex; flex-direction: column; gap: 10px; padding: 18px; box-shadow: 0 20px 60px rgba(20,22,30,.3); }
.nc-head { display: flex; align-items: center; justify-content: space-between; }
.nc-head b { font-size: 17px; }
.nc-head button { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--color-text-muted); }
.nc-input { width: 100%; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: 10px; font: inherit; font-size: 14px; background: var(--color-surface); color: var(--color-text); }
.nc-list { flex: 1 1 auto; overflow-y: auto; border: 1px solid var(--color-border); border-radius: 10px; min-height: 140px; }
.nc-emp { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.nc-emp:hover { background: var(--color-hover); }
.nc-emp input { width: 17px; height: 17px; accent-color: var(--color-primary); flex-shrink: 0; }
.nc-ava { width: 32px; height: 32px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nc-mid { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.nc-mid b { font-size: 14px; font-weight: 600; }
.nc-mid span { font-size: 12px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc-submit { width: 100%; justify-content: center; }
.msg.flash .bubble { animation: msgflash 1.1s ease; }
@keyframes msgflash { 0%,100% { box-shadow: var(--shadow-sm); } 30% { box-shadow: 0 0 0 3px var(--color-primary); } }

/* ===== Панель «ответить / редактировать» над полем ввода ===== */
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin-bottom: 6px; background: var(--color-bg); border-left: 3px solid var(--color-primary); border-radius: 8px; }
.reply-bar[hidden] { display: none; }
.rb-ic { font-size: 16px; color: var(--color-primary); }
.rb-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.rb-mid b { font-size: 12.5px; color: var(--color-primary); }
.rb-mid span { font-size: 12.5px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-x { border: none; background: none; cursor: pointer; color: var(--color-text-muted); font-size: 15px; padding: 2px 4px; }

/* ===== Контекстное меню сообщения (Telegram-стиль) ===== */
.msg-menu { position: fixed; z-index: 120; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 14px; box-shadow: 0 10px 34px rgba(20,22,30,.22); overflow: hidden; min-width: 210px; animation: rxpop .12s ease; }
.mm-rx { display: flex; gap: 2px; padding: 7px 9px; border-bottom: 1px solid var(--color-border); flex-wrap: wrap; justify-content: center; }
.mm-emo { background: none; border: none; font-size: 22px; cursor: pointer; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: transform .1s, background .1s; }
.mm-emo:hover { transform: scale(1.25); background: var(--color-hover); }
.mm-acts { display: flex; flex-direction: column; padding: 5px; }
.mm-acts button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: none; cursor: pointer; font: inherit; font-size: 14px; color: var(--color-text); padding: 10px 12px; border-radius: 9px; }
.mm-acts button:hover { background: var(--color-hover); }
.mm-acts button span { width: 20px; text-align: center; font-size: 15px; opacity: .85; }
.mm-acts button.mm-danger { color: var(--color-danger); }
.mm-acts button.mm-danger:hover { background: rgba(224,83,59,.10); }
/* На телефоне отключаем нативное выделение текста/коллаут, чтобы long-press открывал меню чисто */
@media (max-width: 760px) { .chat-feed .bubble, .chat-feed .b-media img, .chat-feed .b-media video { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; } }

/* ===== Страница чата на всю высоту окна (десктоп и мобайл) ===== */
.chat-page .content { display: flex; flex-direction: column; height: 100vh; }
.chat-page .page-head { flex: 0 0 auto; margin-bottom: 14px; }
.chat-page .tabs { flex: 0 0 auto; }
.chat-page .chat-wrap { flex: 1 1 auto; min-height: 0; align-items: stretch; }
.chat-page .chat-main { min-height: 0; }
.chat-page .chat-feed { max-height: none; }

/* ===== Калькулятор (встроен на всю высоту) ===== */
.calc-page .content { padding: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.calc-toolbar { flex: 0 0 auto; display: flex; justify-content: flex-end; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--color-border); background: var(--color-surface); }
.calc-frame { width: 100%; flex: 1 1 auto; border: 0; display: block; min-height: 0; }
@media (max-width: 860px) { .calc-page .content { height: calc(100vh - 46px); } }

/* ===== Чат-домашняя: 3 колонки (папки | список | окно чата), как Telegram Desktop ===== */
.chat-home-page .content { height: 100vh; padding: 0; overflow: hidden; }
.chat-home-page .tg { height: 100%; max-width: none; gap: 0; }
.chat-home-page .tg-rail { height: 100%; position: static; top: auto; border-right: 1px solid var(--color-border); padding: 10px 6px; overflow-y: auto; }
.chat-home-page .tg-list { flex: 0 0 340px; width: 340px; height: 100%; overflow-y: auto; border-right: 1px solid var(--color-border); padding: 8px; }
.chat-home-page .tg-chat.active { background: var(--color-primary-soft); }
.chat-home-page .tg-panel { flex: 1 1 auto; min-width: 0; height: 100%; background: #e9edf2; }
.chat-home-page .tg-panel iframe { width: 100%; height: 100%; border: 0; display: block; }
.tg-panel-empty { height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--color-text-muted); }
.tg-panel-empty svg { opacity: .5; }
.tg-panel-empty p { margin: 12px 0 0; font-size: 14px; }
/* личные чаты скрыты, пока не выбрана папка «Личные» */
.tg-chat[data-folder="direct"] { display: none; }

/* ===== Встроенное окно чата (iframe) ===== */
.chat-embed { height: 100vh; display: flex; flex-direction: column; background: var(--color-surface); }
/* Шапка чата (Telegram-стиль): назад слева · название по центру · иконка справа */
.chat-head { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--color-border); background: var(--color-surface); flex: 0 0 auto; }
.ch-back { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--color-primary); flex-shrink: 0; }
.ch-back:hover { background: var(--color-hover); }
.ch-back svg { width: 22px; height: 22px; }
.ch-mid { flex: 1; min-width: 0; text-align: center; }
.ch-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub { font-size: 12.5px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-ava { width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-head.embed { padding: 9px 16px; }
.chat-page .mtopbar { display: none; }   /* на странице чата только шапка чата */
.chat-embed .chat-wrap { flex: 1 1 auto; min-height: 0; display: block; }
.chat-embed .chat-main { height: 100%; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
.chat-embed .chat-feed { flex: 1 1 auto; min-height: 0; max-height: none; }

@media (max-width: 900px) {
  .chat-home-page .content { height: auto; padding: 12px 10px 30px; overflow: visible; }
  .chat-home-page .tg { height: auto; }
  .chat-home-page .tg-rail { height: auto; position: sticky; top: 8px; }
  .chat-home-page .tg-list { width: auto; flex: 1 1 auto; height: auto; overflow: visible; border-right: none; }
  .chat-home-page .tg-panel { display: none; }
}

/* ===== Чат-домашняя (Telegram: папки столбиком слева + список) ===== */
.tg { display: flex; align-items: flex-start; gap: 0; max-width: 920px; }
.tg-rail { display: flex; flex-direction: column; gap: 2px; width: 88px; flex-shrink: 0; border-right: 1px solid var(--color-border); padding-right: 6px; position: sticky; top: 8px; }
.tg-folder { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 11px 4px; border: none; background: none; border-radius: 10px; cursor: pointer; color: var(--color-text-muted); font: inherit; }
.tg-folder svg { width: 25px; height: 25px; }
.tg-flabel { font-size: 11px; font-weight: 600; text-align: center; line-height: 1.15; }
.tg-folder:hover { background: var(--color-hover); }
.tg-folder.active { color: var(--color-primary); background: var(--color-primary-soft); }
.tg-fbadge { position: absolute; top: 7px; right: 12px; background: var(--color-primary); color: #fff; border-radius: 100px; min-width: 18px; height: 18px; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.tg-list { flex: 1; min-width: 0; padding-left: 12px; display: flex; flex-direction: column; }
.tg-chat { display: flex; gap: 12px; align-items: center; padding: 9px 8px; border-radius: 10px; color: var(--color-text); }
.tg-chat:hover { background: var(--color-hover); color: var(--color-text); }
.tg-ava { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg, #4a5f78, #28384a); color: #fff; font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tg-mid { flex: 1; min-width: 0; }
.tg-row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tg-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-time { font-size: 12px; color: var(--color-text-muted); flex-shrink: 0; }
.tg-row2 { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; align-items: center; }
.tg-prev { font-size: 13px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tg-unread { background: var(--color-primary); color: #fff; border-radius: 100px; min-width: 20px; height: 20px; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 6px; flex-shrink: 0; }
.tg-empty { color: var(--color-text-muted); padding: 30px 0; text-align: center; font-size: 14px; }
/* Поиск по чатам: на телефоне скрыт, раскрывается свайпом вниз; на десктопе виден всегда */
.tg-search { overflow: hidden; max-height: 0; transition: max-height .22s ease; }
.tg-search.open { max-height: 60px; }
.tg-search-in { display: flex; align-items: center; gap: 8px; margin: 4px 6px 8px; padding: 9px 12px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 11px; color: var(--color-text-muted); }
.tg-search-in input { flex: 1; min-width: 0; border: none; background: none; outline: none; font: inherit; font-size: 14px; color: var(--color-text); }
.tg-search-x { border: none; background: none; cursor: pointer; color: var(--color-text-muted); font-size: 15px; line-height: 1; padding: 2px 4px; }
@media (min-width: 901px) { .chat-home-page .tg-search { max-height: 60px; } }
body.chat-home-page { overscroll-behavior-y: contain; }

/* ===== Мобильный топбар + меню-шторка справа ===== */
.mtopbar { display: none; }
.nav-overlay { display: none; }
@media (max-width: 860px) {
  .mtopbar { display: flex; align-items: center; justify-content: flex-start; gap: 8px; position: sticky; top: 0; z-index: 50; background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 9px 14px; }
  .mt-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; }
  .mt-burger { background: none; border: none; font-size: 24px; line-height: 1; color: var(--color-text); cursor: pointer; padding: 2px 8px; }
  .sidebar { left: 0; right: auto; width: 280px; max-width: 85vw; transform: translateX(-100%); transition: transform .25s ease; border-right: 1px solid var(--color-border); border-left: none; z-index: 70; box-shadow: 8px 0 28px rgba(20,22,30,.18); padding-top: 16px; }
  .sidebar .brand { display: none; }  /* логотип+название уже есть в топбаре */
  /* крупнее пункты меню на телефоне + удобнее тап */
  .sidebar .nav a { font-size: 15px; padding-top: 9px; padding-bottom: 9px; }
  .sidebar .nav-drop > summary { font-size: 15px; padding-top: 11px; padding-bottom: 11px; }
  .sidebar .nav-sub2 a { font-size: 14px; }
  .sidebar .workspace { font-size: 11.5px; }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; width: 100%; padding: 16px 14px 40px; }
  .nav-overlay { display: block; position: fixed; inset: 0; background: rgba(20,22,30,.45); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 65; }
  .nav-overlay.open { opacity: 1; pointer-events: auto; }
  .pipe-board { grid-template-columns: 1fr; }
  .tg-rail { width: 70px; padding-right: 4px; }
  .tg-flabel { font-size: 10px; }
  .tg-list { padding-left: 8px; }

  /* Чат на весь экран: лента тянется, поле ввода прижато к низу */
  .chat-page .content { display: flex; flex-direction: column; padding: 0;
    height: 100vh; height: 100dvh; }   /* топбар на странице чата скрыт — занимаем весь экран */
  .chat-page .page-head { flex: 0 0 auto; padding: 10px 14px 8px; margin: 0; }
  .chat-page .page-head h1 { font-size: 18px; }
  .chat-page .tabs { flex: 0 0 auto; margin: 0; padding: 0 14px; }
  .chat-page .chat-wrap { flex: 1 1 auto; min-height: 0; display: block; }
  .chat-page .chat-main { height: 100%; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
  .chat-page .chat-feed { flex: 1 1 auto; min-height: 0; max-height: none; }
  .chat-page .chat-compose { position: sticky; bottom: 0; background: var(--color-surface); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .rx-add { opacity: .55; }  /* на тач-экранах кнопка реакции всегда видна */
}

/* ===== Бэклог: фильтр по отделам (цветные пилюли в шапке) ===== */
.bd-head { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; }
.tb-title .bd-head { overflow: visible; }
.dept-filter { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.dept-filter::-webkit-scrollbar { height: 0; }
.dept-btn {
  font-size: 11.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--color-border); color: var(--color-text-muted);
  background: var(--color-surface); transition: filter .12s, background .12s, color .12s;
}
.dept-btn:hover { filter: brightness(.97); }
.dept-btn.on { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
/* цвет каждого отдела */
.dept-btn.dc-purple { color:#7c3aed; background:#f1eafd; border-color:#e0d2fa; }
.dept-btn.dc-blue   { color:#2f6fb0; background:#eef5fc; border-color:#cfe2f5; }
.dept-btn.dc-green  { color:#2e7d46; background:#eaf6ee; border-color:#c8e6d2; }
.dept-btn.dc-orange { color:#c4701e; background:#fbeede; border-color:#f0d6b4; }
.dept-btn.dc-teal   { color:#1d7d72; background:#e3f4f1; border-color:#c2e6e0; }
.dept-btn.dc-pink   { color:#bb3a78; background:#fbe9f2; border-color:#f2cfe0; }
.dept-btn.dc-red    { color:#c0392b; background:#fdeeec; border-color:#f3cfc9; }
.dept-btn.dc-gray   { color:#5b6675; background:#f1f3f6; border-color:#e2e6ec; }
.dept-btn.dc-yellow { color:#a06b00; background:#fff7d6; border-color:#f0d572; }
.dept-btn.dc-yellow.on { background:#caa44a; color:#fff; border-color:#caa44a; }
.dept-btn.dc-purple.on { background:#7c3aed; color:#fff; border-color:#7c3aed; }
.dept-btn.dc-blue.on   { background:#2f6fb0; color:#fff; border-color:#2f6fb0; }
.dept-btn.dc-green.on  { background:#2e7d46; color:#fff; border-color:#2e7d46; }
.dept-btn.dc-orange.on { background:#c4701e; color:#fff; border-color:#c4701e; }
.dept-btn.dc-teal.on   { background:#1d7d72; color:#fff; border-color:#1d7d72; }
.dept-btn.dc-pink.on   { background:#bb3a78; color:#fff; border-color:#bb3a78; }
.dept-btn.dc-red.on    { background:#c0392b; color:#fff; border-color:#c0392b; }
.dept-btn.dc-gray.on   { background:#5b6675; color:#fff; border-color:#5b6675; }

/* кнопка «+ Стикер» — округлая, с обводкой, прозрачная заливка */
.btn-add-sticky {
  flex: 0 0 auto; margin-left: 4px; white-space: nowrap; cursor: pointer;
  font-size: 12px; font-weight: 600; line-height: 1; padding: 7px 14px;
  border-radius: 999px; background: transparent;
  color: var(--color-primary); border: 1.5px solid var(--color-primary);
  transition: background .12s, color .12s;
}
.btn-add-sticky:hover { background: var(--color-primary); color: #fff; }

/* Pill-обёртка (button/label/span). Подгоняется под свой текст inline-flex'ом.
   Раньше внутри был скрытый <select>, теперь — кастомный popup #stickyPop. */
.sticky-pill {
  position: relative;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 5px 10px; border-radius: 999px;
  border: 1.5px solid transparent; letter-spacing: .25px;
  cursor: pointer;
  white-space: nowrap;
  vertical-align: middle;
  color: inherit;
  font-family: inherit;
}

/* ── Кастомный popup для выбора отдела/ответственного ── */
.sticky-pop {
  position: absolute;
  min-width: 200px; max-width: 320px; max-height: 60vh;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow:
    0 1px 2px rgba(15,23,42,.08),
    0 12px 32px rgba(15,23,42,.18),
    0 24px 48px rgba(15,23,42,.16);
  padding: 6px;
  z-index: 2000;
  overflow-y: auto;
  animation: stickyPopIn .14s cubic-bezier(.22,1,.36,1);
}
@keyframes stickyPopIn {
  0%   { opacity: 0; transform: translateY(-4px) scale(.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.sticky-pop[hidden] { display: none; }

/* Дедлайн на стикере в колонке «В работе» */
.sticky-deadline-form { display: inline-flex; margin: 0; }
.sticky-deadline {
  position: relative;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 4px 9px; border-radius: 999px;
  border: 1.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  background-color: rgba(255,255,255,.55);
  color: #5a6273;
  border-color: rgba(20,22,30,.12);
}
.sticky-deadline.empty {
  border-style: dashed;
  background-color: rgba(255,255,255,.35);
  font-weight: 600;
}
.sticky-deadline.empty:hover { background-color: rgba(255,255,255,.75); }
.sticky-deadline.has-date {
  color: #3f5a86;
  background-color: rgba(63,90,134,.10);
  border-color: rgba(63,90,134,.30);
}
.sticky-deadline.today {
  color: #c4701e;
  background-color: rgba(245,194,77,.20);
  border-color: rgba(245,194,77,.50);
}
.sticky-deadline.overdue {
  color: #b91c1c;
  background-color: rgba(239,68,68,.15);
  border-color: rgba(239,68,68,.45);
  animation: deadlinePulse 2.4s ease-in-out infinite;
}
@keyframes deadlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
  50%      { box-shadow: 0 0 0 4px rgba(239,68,68,.18); }
}
.sticky-deadline-ico { font-size: 12px; line-height: 1; }
.sticky-deadline-input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
  border: 0; padding: 0; margin: 0;
}

/* Подпись под заголовком колонки — подсказка пользователю */
.board-col-sub {
  font-size: 11px; color: var(--color-text-muted);
  margin: -4px 0 10px;
  letter-spacing: .1px;
  font-style: italic;
}

/* Колонка «История» — полупрозрачная, чтобы визуально не отвлекала. */
.board-col[data-col="history"] {
  opacity: .55;
  transition: opacity .2s ease;
}
.board-col[data-col="history"]:hover { opacity: 1; }
.board-col[data-col="history"] .board-col-h::before {
  content: "🗂 ";
}
.board-col[data-col="history"] .sticky { filter: saturate(.65); }
.board-col[data-col="history"] .sticky:hover { filter: saturate(1); }
.sticky-pop-opt {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border: 0; border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--color-text);
  text-align: left;
}
.sticky-pop-opt:hover {
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}
.sticky-pop-opt.selected {
  background: color-mix(in srgb, var(--color-primary) 16%, transparent);
  color: var(--color-primary);
}
.sticky-pop-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: var(--color-text-muted);
}
.sticky-pop-dot.dc-pink   { background: #ec4899; }
.sticky-pop-dot.dc-blue   { background: #3b82f6; }
.sticky-pop-dot.dc-green  { background: #22c55e; }
.sticky-pop-dot.dc-yellow { background: #eab308; }
.sticky-pop-dot.dc-gray   { background: #94a3b8; }
.sticky-pop-dot.dc-purple { background: #a855f7; }
.sticky-pop-dot.dc-orange { background: #f97316; }
.sticky-pop-dot.dc-teal   { background: #14b8a6; }
.sticky-pop-dot.dc-red    { background: #ef4444; }
html[data-theme="dark"] .sticky-pop {
  background: var(--color-elevated);
  box-shadow:
    0 1px 2px rgba(0,0,0,.45),
    0 16px 40px rgba(0,0,0,.55),
    0 28px 60px rgba(0,0,0,.40);
}
.sticky-pill-text { display: inline-block; }
.sticky-pill-arrow { font-size: 9px; opacity: .7; line-height: 1; }
/* Статичная пилюля (когда ответственный уже назначен) — без стрелочки и кликов. */
.sticky-assignee-pill.sticky-pill { cursor: default; }
.sticky-assignee-pill .sticky-pill-arrow { display: none; }
/* Старая совместимость для .sticky-dept без обёртки (на всякий случай) */
.sticky-dept { color: inherit; }
.sticky-dept-empty {
  color: #b8480f !important;
  background-color: rgba(255, 233, 217, .92) !important;
  border-color: #f0a36a !important;
  border-style: dashed;
  font-weight: 800;
  /* Лёгкое привлечение внимания — пульсация */
  animation: deptEmptyPulse 2.4s ease-in-out infinite;
}
.sticky-dept-empty:hover {
  background-color: #ffd8b8 !important;
  color: #8c3209 !important;
  border-color: #d97a40 !important;
}
/* Тёмная тема — затемнённый вариант плашки «выбери отдел/ответственного»,
   чтобы не выделялся как яркая белая/кремовая пилюля на тёмной карточке. */
html[data-theme="dark"] .sticky-dept-empty {
  color: #ffcfa0 !important;
  background-color: rgba(184, 72, 15, .28) !important;
  border-color: rgba(240, 163, 106, .55) !important;
}
html[data-theme="dark"] .sticky-dept-empty:hover {
  background-color: rgba(184, 72, 15, .42) !important;
  color: #ffdeb8 !important;
}
html[data-theme="dark"] .sticky-assignee-empty {
  color: #cdd5e0 !important;
  background-color: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.18) !important;
}
html[data-theme="dark"] .sticky-assignee-empty:hover {
  background-color: rgba(255,255,255,.10) !important;
  color: #fff !important;
}
html[data-theme="dark"] .sticky-assignee-pill {
  color: #cdd5e0 !important;
  background-color: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.12) !important;
}
@keyframes deptEmptyPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(216, 122, 64, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(216, 122, 64, .18); }
}
.sticky-dept-form { display: inline-block; margin: 0; }
/* Пункты в открытом списке всегда читаемы.
   Без !important тёмная тема перебивает (html[data-theme=dark] input/select/textarea ...) */
.sticky-dept option,
.sticky-assignee option {
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
  font-weight: 600;
  padding: 4px 6px;
}
/* color-scheme подсказывает браузеру, как рисовать нативную часть (список опций):
   в тёмной теме — тёмный popup со светлым текстом. */
html[data-theme="dark"] .sticky-dept,
html[data-theme="dark"] .sticky-assignee,
html[data-theme="dark"] select { color-scheme: dark; }
@media (prefers-reduced-motion: reduce) {
  .sticky-dept-empty { animation: none; }
}
/* !important — потому что html[data-theme="dark"] select { background:var(--color-surface) !important }
   перебивает обычный background-color и пилюли становятся чёрными. */
.sticky-dept.dc-purple { color:#7c3aed !important; background-color:#f1eafd !important; border-color:#e0d2fa !important; }
.sticky-dept.dc-blue   { color:#2f6fb0 !important; background-color:#eef5fc !important; border-color:#cfe2f5 !important; }
.sticky-dept.dc-green  { color:#2e7d46 !important; background-color:#eaf6ee !important; border-color:#c8e6d2 !important; }
.sticky-dept.dc-orange { color:#c4701e !important; background-color:#fbeede !important; border-color:#f0d6b4 !important; }
.sticky-dept.dc-teal   { color:#1d7d72 !important; background-color:#e3f4f1 !important; border-color:#c2e6e0 !important; }
.sticky-dept.dc-pink   { color:#bb3a78 !important; background-color:#fbe9f2 !important; border-color:#f2cfe0 !important; }
.sticky-dept.dc-red    { color:#c0392b !important; background-color:#fdeeec !important; border-color:#f3cfc9 !important; }
.sticky-dept.dc-gray   { color:#5b6675 !important; background-color:#f1f3f6 !important; border-color:#e2e6ec !important; }
.sticky-dept.dc-yellow { color:#a06b00 !important; background-color:#fff7d6 !important; border-color:#f0d572 !important; }
