:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f2f4f7; --border: #e6e8ec;
  --text: #111827; --text-2: #4b5563; --muted: #8a919c;
  --accent: #2f6fed; --accent-strong: #1f5ad6; --accent-text: #ffffff; --accent-soft: #eaf1fe;
  --good: #15905a; --good-soft: #e5f5ed; --warn: #b26a00; --warn-soft: #fff4e0;
  --bad: #d23b40; --bad-soft: #fdeced; --info-soft: #f0f2f5; --violet: #6a5af9; --violet-soft: #efedff;
  --radius: 14px; --radius-sm: 10px;
  --shadow: none; --shadow-hover: 0 4px 16px rgba(17, 24, 39, .06);
  --nav-w: 208px; --bar: var(--accent); --grid: #eef0f3;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #151a22; --surface-2: #1c222c; --border: #262d38;
    --text: #e8ecf2; --text-2: #b4bcc8; --muted: #7f8896;
    --accent: #5b9dff; --accent-strong: #7aafff; --accent-text: #08142b; --accent-soft: #18263f;
    --good: #4cc98a; --good-soft: #15301f; --warn: #e8ad45; --warn-soft: #33270f;
    --bad: #f07075; --bad-soft: #3a1b1d; --info-soft: #1f2530; --violet: #9a8fff; --violet-soft: #26224a;
    --grid: #20262f; --shadow-hover: 0 4px 16px rgba(0, 0, 0, .3);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #151a22; --surface-2: #1c222c; --border: #262d38;
  --text: #e8ecf2; --text-2: #b4bcc8; --muted: #7f8896;
  --accent: #5b9dff; --accent-strong: #7aafff; --accent-text: #08142b; --accent-soft: #18263f;
  --good: #4cc98a; --good-soft: #15301f; --warn: #e8ad45; --warn-soft: #33270f;
  --bad: #f07075; --bad-soft: #3a1b1d; --info-soft: #1f2530; --violet: #9a8fff; --violet-soft: #26224a;
  --grid: #20262f; --shadow-hover: 0 4px 16px rgba(0, 0, 0, .3);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; line-height: 1.2; font-weight: 700; margin: 0; letter-spacing: -.015em; white-space: nowrap; }
h2 { font-size: 14.5px; font-weight: 600; margin: 0 0 12px; letter-spacing: -.005em; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 6px; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; }
.svg-i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- каркас --- */
.layout { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; }
nav { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; padding: 0 8px 18px; line-height: 1.2; }
nav .brand .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
nav .brand .logo .svg-i { width: 17px; height: 17px; }
nav .brand small { display: none; }
nav button { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 500; font-size: 13.5px; }
nav button:hover { background: var(--surface-2); color: var(--text); }
nav button.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
nav button.active .svg-i { color: var(--accent); }
nav button .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav .count { background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; font-weight: 600; line-height: 17px; }
nav .count.dot { width: 8px; height: 8px; padding: 0; border-radius: 50%; background: var(--good); }
nav .spacer { flex: 1; min-height: 12px; }
main { padding: 0 24px 40px; width: 100%; min-width: 0; max-width: 1400px; }

.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; padding: 14px 0; margin-bottom: 8px; position: sticky; top: 0; z-index: 4; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.pagebar { display: flex; align-items: center; gap: 14px; min-width: 0; flex-wrap: wrap; }
.topbar .pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.pill[data-goto] { cursor: pointer; }
.pill[data-goto]:hover { border-color: var(--accent); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.good .dot { background: var(--good); } .pill.warn .dot { background: var(--warn); } .pill.bad .dot { background: var(--bad); }
.pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); border-color: var(--bad); }
.pill.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; font-weight: 600; }
.pill .stack .ava { --s: 18px; }

.page-head, .toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar { justify-content: flex-start; }
.toolbar .chips, .page-head .chips { margin: 0; }

/* «?» — пояснение по наведению или нажатию */
.hint { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font: 600 10.5px/1 Inter, system-ui, sans-serif; font-style: normal; cursor: help; vertical-align: 1px; flex: none; user-select: none; }
.hint:hover { background: var(--accent-soft); color: var(--accent); }

/* --- карточки --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 12px; }
.grid > .card { margin-bottom: 0; }
.grid.two, .grid.three, .ov-grid { margin-bottom: 12px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 12px; align-items: center; min-width: 0; }
.tile.link { cursor: pointer; }
.tile.link:hover { border-color: var(--accent); }
.tile .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.tile .ic .svg-i { width: 17px; height: 17px; }
.tile .ic.good { background: var(--good-soft); color: var(--good); } .tile .ic.warn { background: var(--warn-soft); color: var(--warn); }
.tile .ic.bad { background: var(--bad-soft); color: var(--bad); } .tile .ic.violet { background: var(--violet-soft); color: var(--violet); }
.tile .num { font-size: 20px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile .lbl { color: var(--muted); font-size: 12px; }
.tile .sub { color: var(--muted); font-size: 12px; }

/* --- кнопки и поля --- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; font-weight: 500; font-size: 13.5px; color: var(--text); transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.good:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { color: var(--accent); background: var(--surface-2); }
.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 6px 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn .svg-i { width: 15px; height: 15px; }

input[type=text], input[type=password], input[type=number], input[type=tel], input[type=time], input[type=search], select, textarea {
  border: 1px solid var(--border); background: var(--surface); border-radius: 9px; padding: 7px 11px; width: 100%; outline: none; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 72px; resize: vertical; }
textarea.big { min-height: 260px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: flex; align-items: center; gap: 6px; font-weight: 500; margin-bottom: 5px; color: var(--text-2); font-size: 12.5px; }
label.field > small { display: block; color: var(--muted); margin-top: 4px; }
.check { display: inline-flex; gap: 6px; align-items: center; margin: 0 14px 6px 0; cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500; background: var(--info-soft); color: var(--text-2); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--surface); white-space: nowrap; }
tbody tr:hover td, table tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--text); }
th.sort.on { color: var(--accent); }
.table-wrap { overflow-x: auto; }

/* пилюли-фильтры: одна форма для вкладок, фильтров и выбора аккаунтов */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-2); white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.chip:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .n, .chip .count, .chip .badge { background: color-mix(in srgb, currentColor 14%, transparent); color: inherit; border-radius: 999px; padding: 0 7px; font-size: 11.5px; font-weight: 600; line-height: 18px; margin: 0; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 20%, transparent); }
/* сегменты: переключатель разделов и периодов */
.camp-media { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.camp-media:empty { display: none; }
.camp-media .ph { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.camp-media .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.camp-media .ph button { position: absolute; top: 3px; right: 3px; border: 0; border-radius: 50%; width: 20px; height: 20px; line-height: 20px; padding: 0; cursor: pointer; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; }
.camp-media .ph.loading { display: grid; place-items: center; font-size: 12px; color: var(--text-2); }
.camp-media.mini .ph { width: 44px; height: 44px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(17, 24, 39, .08), 0 0 0 1px var(--border); }

/* --- аватарки --- */
.ava { --s: 36px; position: relative; width: var(--s); height: var(--s); border-radius: 50%; flex: none; display: inline-grid; place-items: center; font-weight: 800; font-size: calc(var(--s) * .4); color: #fff; background: var(--c, var(--accent)); overflow: hidden; vertical-align: middle; }
.ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ava.sq { border-radius: 30%; }
.ava-wrap { position: relative; display: inline-flex; flex: none; }
.ava-wrap .st { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); background: var(--muted); }
.ava-wrap .st.good { background: var(--good); } .ava-wrap .st.warn { background: var(--warn); } .ava-wrap .st.bad { background: var(--bad); }
.stack { display: inline-flex; align-items: center; }
.stack .ava { --s: 26px; box-shadow: 0 0 0 2px var(--surface); }
.stack .ava + .ava { margin-left: -7px; }
.stack .more { margin-left: 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who > div { min-width: 0; }
.who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- сотрудники в обзоре --- */
.people { display: grid; }
.people { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; min-width: 0; }
.person:hover { background: var(--surface-2); }
.person .ava-wrap .st { width: 10px; height: 10px; }
.person .p-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.person .p-main b { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .p-main .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .p-main .badge { padding: 0 6px; }
.person .p-num { text-align: right; line-height: 1.2; }
.person .p-num b { display: block; font-variant-numeric: tabular-nums; font-weight: 600; }
.person .p-num span { font-size: 11px; color: var(--muted); }

.comment .row.spread > .row { min-width: 0; }
.comment .quote { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 10px 0; white-space: pre-wrap; word-break: break-word; }
.comment .reply { background: var(--accent-soft); border-radius: 14px; padding: 10px 14px; margin: 10px 0; white-space: pre-wrap; word-break: break-word; border-left: 4px solid var(--accent); }
.comment .sig { color: var(--muted); }
.comment .c-head { display: flex; gap: 10px; align-items: center; min-width: 0; }
.meter { height: 6px; background: var(--info-soft); border-radius: 3px; overflow: hidden; min-width: 60px; }
.meter > div { height: 100%; background: var(--accent); border-radius: 3px; }
.emp-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.emp-head .who .ava { --s: 52px; }
.emp-head h2 { margin: 0; }
.emp-line { display: flex; gap: 14px; flex-wrap: wrap; align-items: baseline; font-size: 12.5px; color: var(--muted); margin: 10px 0 2px; }
.emp-line b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.emp-stats { display: grid; grid-template-columns: repeat(4, minmax(70px, 1fr)); gap: 10px; margin: 16px 0 12px; }
.emp-stats div { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.emp-stats b { display: block; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.box { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
details > summary { font-weight: 500; color: var(--accent); cursor: pointer; }
.logs { background: #0f1420; color: #cfd6e2; font: 12px/1.55 ui-monospace, Consolas, monospace; padding: 14px; border-radius: var(--radius); max-height: calc(100vh - 140px); overflow: auto; white-space: pre-wrap; word-break: break-all; }
.banner { padding: 8px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 500; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

#toast { position: fixed; right: 16px; bottom: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; z-index: 20; }
#toast div { background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; max-width: 440px; pointer-events: auto; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
#toast div.err { background: var(--bad); color: #fff; }

.login { max-width: 400px; margin: 14vh auto; padding: 0 16px; }
.login .logo { width: 52px; height: 52px; border-radius: 16px; background: var(--accent); color: #fff; display: grid; place-items: center; margin-bottom: 16px; }
.chan-off { opacity: .65; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.switch { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.switch input { margin-top: 3px; }
.switch small { display: block; color: var(--muted); }
.hidden { display: none !important; }

.ai-models { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.ai-model { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ai-model > span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.ai-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.ai-tiles div { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.ai-tiles b { display: block; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ai-tiles span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
details.more { margin-top: 10px; }
details.more > summary { font-weight: 500; font-size: 12.5px; color: var(--muted); cursor: pointer; list-style: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }
details.more > summary:hover { color: var(--accent); }

.prof { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; margin-top: 12px; }
.prof-photo { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.prof-photo .ava { width: 112px; height: 112px; border-radius: 50%; background: var(--surface-2); object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 36px; color: var(--muted); overflow: hidden; }
.prof-photo .btn { width: 100%; justify-content: center; }
.bday { display: flex; gap: 6px; }
.bday input { width: 100%; }

.mini-wrap { position: relative; display: flex; flex-direction: column; height: calc(100vh - 90px); }
.mini-ext { align-self: flex-end; margin: -4px 0 6px; }
.mini-frame { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* --- графики --- */
.chart { position: relative; }
.chart .plot { position: relative; height: var(--h, 180px); display: flex; align-items: flex-end; gap: 2px; padding-top: 4px; border-bottom: 1px solid var(--border);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px); background-size: 100% 25%; }
.chart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; min-width: 0; }
.chart .col i { display: block; width: 100%; max-width: 34px; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 0; transition: opacity .1s; }
.chart .col i.zero { background: var(--border); height: 2px !important; border-radius: 1px; }
.chart .col:hover i, .chart .col.on i { background: var(--accent-strong); }
.chart .plot:hover .col:not(:hover) i { opacity: .55; }
.chart .xl { display: flex; gap: 2px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.chart .xl span { flex: 1; text-align: center; min-width: 0; overflow: visible; white-space: nowrap; display: flex; justify-content: center; }
.chart .max { position: absolute; right: 0; top: -2px; font-size: 11px; color: var(--muted); background: var(--surface); padding: 0 0 0 4px; font-variant-numeric: tabular-nums; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.chart-title b { font-size: 14.5px; font-weight: 600; }
.chart-title .big { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
#tip { position: fixed; z-index: 30; pointer-events: none; background: var(--text); color: var(--bg); padding: 8px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.45; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 260px; display: none; }
#tip b { font-weight: 800; }
.chart .col.stk { flex-direction: column; justify-content: flex-end; align-items: stretch; }
.chart .col.stk .wrap { display: flex; flex-direction: column-reverse; gap: 2px; width: 100%; max-width: 34px; margin: 0 auto; }
.chart .col.stk i { max-width: none; border-radius: 0; background: var(--c); min-height: 2px; }
.chart .col.stk i.top { border-radius: 4px 4px 0 0; }
.chart .col.stk:hover i { background: var(--c); filter: brightness(1.1); }
.chart .plot:hover .col.stk:not(:hover) i { opacity: .5; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); font-weight: 600; margin-bottom: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 200px) minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 13px; }
.hbar .t { color: var(--text-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 12px; background: var(--info-soft); border-radius: 6px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--bar); border-radius: 6px; }
.hbar .v { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 54px; text-align: right; }
.hbar .v small { color: var(--muted); font-weight: 600; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kv div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.kv b { display: block; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kv span { font-size: 12px; color: var(--muted); }
.rep-tabs { margin-bottom: 0; }
#repTiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1500px) { #repTiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 860px) { #repTiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
#repAccounts td .muted.small { white-space: nowrap; }
/* списки чатов — в окне фиксированной высоты со своей прокруткой, шапка таблицы прилипает */
.scroll-box { max-height: 560px; overflow: auto; border-radius: 12px; overscroll-behavior: contain; }
.scroll-box.short { max-height: 420px; }
.scroll-box th { position: sticky; top: 0; z-index: 1; }
.scroll-box::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-box::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#chanTable .who b, #repChannels .who b { white-space: normal; overflow: visible; }
#repChannels { table-layout: fixed; }
#repChannels th { white-space: normal; font-size: 11px; line-height: 1.25; padding: 9px 6px; vertical-align: bottom; }
#repChannels td { padding: 9px 6px; }
#repChannels th:first-child, #repChannels td:first-child { width: 28%; padding-left: 12px; }
#repChannels th:nth-child(9) { width: 9%; } #repChannels th:last-child { width: 11%; }
#repChannels .who { align-items: flex-start; }
#repChannels .who .muted { white-space: normal; }
#repChannels .stack .ava { --s: 22px; }

/* компактные сообщения: у всех карточек одна схема — шапка в строку, метки, текст до 3 строк, ИИ в строку, действия в ряд */
.card.comment { padding: 12px 14px; margin-bottom: 8px; }
.comment .c-top { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: nowrap; }
.comment .c-top .c-name { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.comment .c-top .c-time { flex: none; font-size: 12px; color: var(--text-3, var(--text-2)); white-space: nowrap; }
.comment .c-top .grow { flex: 1 1 0; min-width: 4px; }
.comment .c-top .icon-link { width: 28px; height: 28px; }
.comment .c-meta { display: flex; flex-wrap: nowrap; gap: 4px; margin-top: 6px; height: 20px; overflow: hidden; }
.comment .quote { padding: 8px 12px; margin: 8px 0 0; border-radius: 10px; line-height: 1.45; }
.comment .reply { padding: 8px 12px; margin: 6px 0 0; border-radius: 10px; }
.comment .ctx { font-size: 12px; margin-top: 4px; }
/* длинное сообщение — 3 строки, «ещё ▾» раскрывает */
.comment > .quote.clamp { cursor: pointer; }
.comment > .quote.clamp .q-txt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; height: 4.35em; }
.comment > .quote.clamp.open { cursor: auto; }
.comment > .quote.clamp.open .q-txt { display: block; height: auto; }
.comment .more { background: none; border: 0; padding: 2px 0; color: var(--accent); font-size: 12px; cursor: pointer; flex: none; }
.comment > .more { display: block; margin-top: 2px; height: 18px; line-height: 14px; }
.comment > .more.off { visibility: hidden; pointer-events: none; }
.comment .c-ai { display: flex; align-items: center; gap: 8px; margin-top: 2px; height: 20px; font-size: 12px; color: var(--text-2); min-width: 0; }
.comment .c-ai .c-why { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comment .ctx-box { font-size: 12.5px; max-height: 220px; overflow: auto; margin-top: 6px; }
.comment .c-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.comment .c-acts .grow { flex: 1 1 0; }
.comment .c-lbl { font-size: 12px; color: var(--text-2); }
.comment .c-pick { width: auto; max-width: 180px; padding: 4px 8px; font-size: 13px; }
.comment .c-acts .dd-btn { display: inline-flex; width: auto; max-width: 190px; min-height: 0; height: 30px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
.comment .ctx .quote { font-size: 12.5px; }
.comment textarea { min-height: 64px; }
.icon-link { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--border); color: var(--text-2); flex: none; }
.icon-link:hover { background: var(--surface-2); text-decoration: none; color: var(--accent); }

/* сотрудники: по 3 в ряд, раскрытая карточка — во всю ширину */
.emp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.emp-grid > .card { margin: 0; padding: 14px 16px; }
.emp-grid > .card.wide { grid-column: 1 / -1; }
.emp-grid .emp-head .who .ava { --s: 44px; }
.emp-grid .emp-head h2 { font-size: 14.5px; }
.emp-grid .emp-head { flex-wrap: nowrap; align-items: flex-start; }
.emp-grid .emp-head > .who { flex: 1; align-items: flex-start; }
.emp-grid .emp-head > div:last-child { flex: none; }
.emp-grid .emp-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 12px 0 8px; }
.emp-grid .emp-stats div { padding: 7px 9px; border-radius: 10px; }
.emp-grid .emp-stats b { font-size: 16px; }
.emp-grid .emp-stats span { font-size: 11px; }
.emp-grid details { margin-top: 8px !important; }
.chan-checks { max-height: 220px; overflow: auto; background: var(--surface-2); border-radius: 12px; padding: 8px 12px; }
@media (max-width: 1200px) { .emp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .emp-grid { grid-template-columns: minmax(0, 1fr); } }

/* каналы и группы: компактные строки */
.chan-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.3fr) minmax(0, 1.2fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.chan-row:last-child { border-bottom: 0; }
.chan-row:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.chan-row .who b { white-space: normal; }
.chan-row .nums { font-size: 12.5px; color: var(--text-2); }
.chan-row .nums b { color: var(--text); }
.chan-row .acts { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.chan-row .note-box { grid-column: 1 / -1; }
@media (max-width: 900px) { .chan-row { grid-template-columns: minmax(0, 1fr); } .chan-row .acts { justify-content: flex-start; } }
.ov-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .ov-grid { grid-template-columns: minmax(0, 1fr); } }
.tag-est { color: var(--muted); font-weight: 600; }

@media (max-width: 1100px) { .three { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  nav { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; overflow-x: auto; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--border); gap: 2px; }
  nav .brand, nav .spacer { display: none; }
  nav button { width: auto; white-space: nowrap; padding: 7px 10px; }
  nav button .lbl { overflow: visible; }
  main { padding: 0 16px 32px; }
  .topbar { position: static; padding: 10px 0; }
  .two, .three, .ai-models { grid-template-columns: minmax(0, 1fr); }
  .ai-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .emp-stats { grid-template-columns: repeat(2, 1fr); }
  .prof { grid-template-columns: 1fr; }
  .mini-wrap { height: calc(100vh - 150px); }
  .mini-ext { position: static; align-self: flex-end; margin-bottom: 6px; }
  .card { padding: 14px; }
  h1 { font-size: 18px; }
  .hbar { grid-template-columns: minmax(90px, 120px) minmax(0, 1fr) auto; }
}

/* --- песочница --- */
.sb-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 960px) { .sb-layout { grid-template-columns: minmax(0, 1fr); } }
.sb-side { padding: 16px; position: sticky; top: 16px; }
.sb-list { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; max-height: 62vh; overflow-y: auto; }
.sb-item { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.sb-item:hover { background: var(--surface-2); }
.sb-item.active { background: var(--accent-soft); }
.sb-item b { font-size: 13.5px; line-height: 1.35; }
.sb-chat { padding: 0; overflow: hidden; }
.sb-top { display: flex; gap: 12px; align-items: flex-start; padding: 18px 22px 10px; }
.sb-topic { font-weight: 700; font-size: 15.5px; }
.sb-settings { padding: 0 22px 12px; border-bottom: 1px solid var(--border); }
.sb-settings summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px; }
.sb-msgs { height: 56vh; min-height: 300px; overflow-y: auto; padding: 16px 22px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.sb-msg { display: flex; gap: 10px; align-items: flex-start; max-width: 82%; }
.sb-msg.me { align-self: flex-end; flex-direction: row-reverse; }
.sb-bubble { background: var(--surface); border-radius: 14px; padding: 8px 14px 6px; min-width: 0; border: 1px solid var(--border); }
.sb-msg.me .sb-bubble { background: var(--violet-soft); }
.sb-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.sb-head .grow { flex: 1; }
.sb-to { border-left: 2px solid var(--accent); padding-left: 8px; margin: 4px 0; }
.sb-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.sb-tools { display: flex; gap: 10px; opacity: 0; transition: opacity .15s; margin-top: 2px; }
.sb-msg:hover .sb-tools, .sb-msg:focus-within .sb-tools { opacity: 1; }
@media (hover: none) { .sb-tools { opacity: 1; } }
.sb-controls { padding: 12px 22px; border-top: 1px solid var(--border); }
.sb-compose { padding: 0 22px 18px; }
.sb-compose textarea { min-height: 64px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12.5px; }
.link-btn.danger { color: var(--bad); }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: sbspin .8s linear infinite; vertical-align: -2px; }
@keyframes sbspin { to { transform: rotate(360deg); } }
@media (max-width: 600px) { .sb-msg { max-width: 100%; } .sb-top, .sb-settings, .sb-controls, .sb-compose { padding-left: 14px; padding-right: 14px; } .sb-msgs { padding: 12px 14px; } }

button.icon-link { background: var(--surface); cursor: pointer; padding: 0; font-size: 14px; }
.sb-tabs { margin: 0 0 12px; }
.sb-tabs .count { background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 700; margin-left: 4px; }
.gap-group h3 { margin: 0 0 8px; font-size: 15px; }
.gap { padding: 10px 0; border-top: 1px solid var(--border); }
.gap:first-of-type { border-top: 0; }
.gap-q { font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.gap-miss, .gap-ans { font-size: 13.5px; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.gap.done, .gap.skip { opacity: .65; }
.gap-st { padding: 1px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.gap-st.done { background: var(--surface-2); color: var(--good, #2fa84f); }
.gap-st.skip { background: var(--surface-2); color: var(--muted, #888); }

/* онлайн-эфир: реплики ботов, нажатие — переход в мини-приложении */
.online-msg:hover { background: var(--surface-2); }
.online-msg.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }

.online-container { display: flex; gap: 14px; align-items: flex-start; }
@media (max-width: 900px) {
  .online-container { flex-direction: column; }
  #onlineSidebar { width: 100% !important; }
}
.online-chat-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 10px; cursor: pointer; background: transparent;
  transition: background .15s ease, border-color .15s ease;
  border: 1px solid transparent;
}
.online-chat-item:hover { background: var(--surface-2); }
.online-chat-item.active {
  background: var(--surface-2);
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* мягкие выпадающие списки (panel/select.js): системный <select> спрятан, вместо него кнопка и всплывающий список */
select.dd-native { display: none !important; }
.dd-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 9px 12px; text-align: left;
  border: 1px solid var(--border); background: var(--surface); border-radius: 12px; cursor: pointer; color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s; }
.dd-btn.dd-auto { display: inline-flex; width: auto; max-width: 100%; }
.dd-btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.dd-btn:focus-visible, .dd-btn.open { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dd-btn:disabled { opacity: .55; cursor: default; }
.dd-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-label.dd-empty { color: var(--muted); }
.dd-arrow { flex: none; width: 8px; height: 8px; margin: -3px 2px 0 4px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .15s; }
.dd-btn.open .dd-arrow { transform: rotate(225deg); margin-top: 3px; border-color: var(--accent); }
.dd-pop { position: fixed; z-index: 1000; display: flex; flex-direction: column; max-height: min(360px, 60vh); padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 36px rgba(20, 34, 64, .16), 0 2px 6px rgba(20, 34, 64, .06); animation: dd-in .12s ease-out; }
:root[data-theme="dark"] .dd-pop { box-shadow: 0 14px 40px rgba(0, 0, 0, .5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dd-pop { box-shadow: 0 14px 40px rgba(0, 0, 0, .5); } }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dd-pop:focus { outline: none; }
.dd-search { margin: 0 0 6px; border-radius: 10px !important; padding: 8px 10px !important; }
.dd-list { overflow-y: auto; }
.dd-opt { padding: 8px 10px; border-radius: 10px; cursor: pointer; line-height: 1.3; }
.dd-opt.act { background: var(--surface-2); }
.dd-opt.sel { color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.dd-opt.off { opacity: .45; cursor: default; }
.dd-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.dd-none { padding: 12px 10px; color: var(--muted); font-size: 13px; }
.online-q { padding: 8px 0; border-top: 1px solid var(--border); }
.online-q:first-child { border-top: none; padding-top: 0; }
/* «Ждут решения»: список слева, чат выбранного сообщения справа (мини-приложение) */
.q-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 44%); gap: 12px; align-items: start; }
.q-pane { position: sticky; top: 74px; height: calc(100vh - 90px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; display: flex; }
.q-pane iframe { flex: 1; width: 100%; border: 0; }
.q-pane-empty { margin: auto; padding: 24px; text-align: center; }
.q-split.solo { grid-template-columns: minmax(0, 1fr); } .q-split.solo .q-pane { display: none; }
#queueList .card.comment { cursor: pointer; transition: border-color .12s; }
#queueList .card.comment:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
#queueList .card.comment.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
@media (max-width: 1100px) { .q-split { grid-template-columns: minmax(0, 1fr); } .q-pane { display: none; } }

/* «⋯» в карточке очереди: спрятанные действия (массовая защита) */
.more-wrap { position: relative; display: inline-flex; }
.more-menu { position: absolute; bottom: calc(100% + 4px); left: 0; z-index: 20; display: flex; padding: 6px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0,0,0,.16); white-space: nowrap; }
