:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 236px;
}
:root[data-theme="dark"] {
  --bg: #0d0d12; --panel: #16161e; --panel-2: #1d1d28; --panel-3: #252532; --border: #2b2b3a; --grid: #23232f;
  --text: #ecebf3; --muted: #9d9ab0; --faint: #6c6980;
  --accent: #a970ff; --accent-2: #8f5cf0; --accent-soft: rgba(169, 112, 255, .14);
  --good: #3ccf8e; --bad: #ff5d73; --warn: #ffb547; --live: #ff4655;
  --heat-0: #1f1f2b; --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f3f8; --panel: #ffffff; --panel-2: #f7f6fb; --panel-3: #eeecf5; --border: #e2e0ea; --grid: #efeef4;
  --text: #1c1b24; --muted: #686579; --faint: #9b98aa;
  --accent: #7c3aed; --accent-2: #6d28d9; --accent-soft: rgba(124, 58, 237, .1);
  --good: #14915a; --bad: #d42f48; --warn: #b9770e; --live: #e02435;
  --heat-0: #f1effa; --shadow: 0 8px 24px rgba(30, 20, 60, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
p { margin: .4em 0; }
code { background: var(--panel-3); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.r { text-align: right; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 8px; }
.gap-lg { gap: 16px; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- каркас ---------- */
#app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40; transition: transform .2s;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { font-size: 26px; }
.brand b { display: block; font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav-item:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active .nav-ico { filter: none; }
.nav-ico { width: 20px; text-align: center; filter: grayscale(.4); }
.nav-item.is-live::after { content: 'LIVE'; margin-left: auto; font-size: 10px; font-weight: 700; background: var(--live); color: #fff; padding: 1px 6px; border-radius: 6px; animation: pulse 1.6s infinite; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 14px; display: grid; gap: 10px; }
.demo-flag { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--warn); border: 1px dashed var(--warn); border-radius: 8px; text-align: center; padding: 3px; }
.user { display: flex; gap: 10px; align-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { color: var(--muted); font-size: 12px; }
.main { margin-left: var(--sidebar); min-width: 0; }
.topbar { display: none; }
.page { padding: 24px 28px 60px; max-width: 1480px; margin: 0 auto; }
.page-inner { display: grid; gap: 18px; }
.nav-backdrop { display: none; }

.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- карточки ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; flex-wrap: wrap; }
.card-head h3 { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 160px; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card-body { padding: 14px 16px 16px; min-width: 0; }
.card.flat .card-body { padding: 0; }
.card.accent { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), transparent 60%), var(--panel); }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--accent); }
.kpi-label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 2px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.delta { font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 6px; }
.delta.up { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.delta.down { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }

/* ---------- элементы ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn.big { height: 46px; padding: 0 22px; font-size: 15px; justify-content: center; }
.btn.twitch { background: #9146ff; border-color: #9146ff; }
.btn .ico { font-size: 14px; }
.btn.dropdown b { font-weight: 600; }
.btn .caret { color: var(--muted); font-size: 11px; }
.btn.active-toggle { border-color: var(--accent); background: var(--accent-soft); }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 18px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--panel-2); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; position: sticky; top: 0; z-index: 20; }
.input, select.input, textarea.input {
  height: 34px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit; min-width: 0;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { display: grid; gap: 5px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--faint); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }

.help {
  display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--border);
  color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; flex: none; background: var(--panel-2);
}
.help:hover { color: var(--accent); border-color: var(--accent); }
.help-pop { max-width: 320px; font-size: 13px; line-height: 1.5; font-weight: 400; color: var(--text); }

.popover { position: absolute; z-index: 100; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px; max-width: min(380px, calc(100vw - 16px)); }
.menu { display: grid; min-width: 200px; margin: -4px -6px; max-height: 60vh; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: var(--text); font: inherit; text-align: left; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.menu-item:hover { background: var(--panel-2); }
.menu-item.active { color: var(--accent); font-weight: 600; }
.menu-item.check input { accent-color: var(--accent); }
.menu-hint { margin-left: auto; color: var(--muted); font-size: 12px; }
.menu-div { height: 1px; background: var(--border); margin: 4px 0; }
.menu-foot { padding: 8px 6px 2px; display: flex; justify-content: flex-end; }
.range-pop { display: grid; gap: 8px; }
.range-pop label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.chips { display: inline-flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--text); background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 40%, transparent); }
.chip:hover { text-decoration: none; border-color: var(--c, var(--accent)); }
.chip.sm { font-size: 11px; padding: 0 8px; }
.chip.guest { --c: var(--muted); font-weight: 500; }
.chip.muted { color: var(--muted); --c: var(--faint); font-weight: 400; }
.chip-toggle { cursor: pointer; opacity: .5; }
.chip-toggle.on { opacity: 1; }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--panel-3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.badge.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.live { background: var(--live); color: #fff; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.sm { font-size: 10px; padding: 0 5px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 9px 12px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-count { margin-left: 6px; font-size: 11px; background: var(--panel-3); padding: 0 6px; border-radius: 6px; color: var(--muted); }

/* ---------- таблицы ---------- */
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover, .tbl th.sorted { color: var(--text); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.tbl.compact td { padding: 5px 8px; }
.tbl tr.clickable { cursor: pointer; }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl .r { text-align: right; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 10px; color: var(--muted); font-size: 12px; }
.title-cell { display: grid; gap: 3px; min-width: 220px; }
.title-link { color: var(--text); font-weight: 500; }
.title-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.rank { color: var(--faint); font-size: 12px; width: 26px; display: inline-block; }

/* ---------- графики и списки ---------- */
.chart { width: 100%; min-width: 0; }
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar.clickable { cursor: pointer; }
.hbar.clickable:hover .hbar-label { color: var(--accent); }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--panel-3); border-radius: 5px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 5px; }
.hbar-val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 36px; text-align: right; }

.cloud { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; justify-content: center; padding: 8px 4px; line-height: 1.2; }
.cloud-w { font-weight: 600; }
.cloud-w.clickable { cursor: pointer; }
.cloud-w.clickable:hover { text-decoration: underline; }
.cloud-w.c0 { color: var(--accent); }
.cloud-w.c1 { color: var(--text); }
.cloud-w.c2 { color: #e05a9c; }
.cloud-w.c3 { color: #3593dc; }
.cloud-w.c4 { color: #26a86e; }

.insights { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.insight { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); border-left: 3px solid var(--border); }
.insight.good { border-left-color: var(--good); }
.insight.bad { border-left-color: var(--bad); }
.insight-ico { font-size: 16px; line-height: 1.3; }

.peaks { display: grid; gap: 10px; }
.peak { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--panel-2); display: grid; gap: 6px; }
.peak-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.peak-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 7px; cursor: pointer; border: 0; font: inherit; }
.peak-title { font-weight: 600; flex: 1; min-width: 160px; }
.kw { display: inline-block; font-size: 12px; background: var(--panel-3); border-radius: 6px; padding: 0 7px; margin: 0 4px 4px 0; }
.samples { display: grid; gap: 2px; font-size: 13px; }

.chat-box { max-height: 52vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; background: var(--panel-2); margin: 10px 0; }
.chat-line { padding: 2px 4px; border-radius: 6px; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.chat-line.hl { background: var(--accent-soft); }
.chat-line.kind-bot { opacity: .55; }
.chat-line.kind-system { color: var(--warn); }
.chat-line.deleted .msg-text { text-decoration: line-through; opacity: .6; }
.chat-time { background: none; border: 0; color: var(--faint); font: inherit; font-size: 11px; font-variant-numeric: tabular-nums; cursor: pointer; padding: 0 6px 0 0; }
.chat-time:hover { color: var(--accent); }
.nick { font-weight: 700; }
:root[data-theme="light"] .nick { filter: brightness(.75) saturate(1.2); }
.sys-tag { font-size: 10px; text-transform: uppercase; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); border-radius: 5px; padding: 0 5px; margin-right: 6px; }
.mention { color: var(--accent); font-weight: 500; }
.emote { color: var(--good); font-weight: 600; font-size: 12px; background: color-mix(in srgb, var(--good) 10%, transparent); border-radius: 5px; padding: 0 4px; }
.link { word-break: break-all; }
mark { background: color-mix(in srgb, var(--warn) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }

.player { position: relative; padding-top: 56.25%; border-radius: 10px; overflow: hidden; background: #000; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.empty { display: grid; place-items: center; gap: 6px; padding: 28px 10px; color: var(--muted); text-align: center; }
.empty-icon { font-size: 30px; opacity: .7; }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 60px 10px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--panel-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.error-box { padding: 12px 14px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--bad) 50%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--text); }
.note { padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px dashed var(--border); color: var(--muted); font-size: 13px; }
.note b { color: var(--text); }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); margin: 8px 0; }

.md h3, .md h4, .md h5 { margin: 16px 0 6px; }
.md h3:first-child, .md h4:first-child { margin-top: 0; }
.md ul { margin: 4px 0; padding-left: 20px; }
.md li { margin: 3px 0; }

/* ---------- модальные окна и уведомления ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(5, 5, 10, .6); z-index: 90; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 120; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 380px; animation: slide .2s; }
.toast.ok { border-left-color: var(--good); }
.toast.error { border-left-color: var(--bad); }
.toast.out { opacity: 0; transition: opacity .4s; }

.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.toggle input { display: none; }
.toggle-ui { width: 34px; height: 20px; border-radius: 99px; background: var(--panel-3); position: relative; transition: background .2s; flex: none; border: 1px solid var(--border); }
.toggle-ui::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.toggle input:checked + .toggle-ui { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-ui::after { transform: translateX(14px); background: #fff; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 32px 28px; display: grid; gap: 12px; text-align: center; box-shadow: var(--shadow); }
.login-logo { font-size: 46px; }
.demo-login { display: grid; gap: 8px; margin-top: 8px; }
.role-btn { display: grid; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit; cursor: pointer; }
.role-btn:hover { border-color: var(--accent); }
.role-btn span { color: var(--muted); font-size: 12px; }

/* ---------- разное ---------- */
.dropzone { border: 2px dashed var(--border); border-radius: 16px; padding: 40px 20px; text-align: center; background: var(--panel); cursor: pointer; transition: border-color .2s, background .2s; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .big { font-size: 40px; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.step b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-3); color: var(--muted); font-size: 12px; }
.step.active { color: var(--text); }
.step.active b { background: var(--accent); color: #fff; }
.cand { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.cand:hover, .cand.selected { border-color: var(--accent); background: var(--accent-soft); }
.streamer-card { display: grid; gap: 10px; border-top: 4px solid var(--c); }
.streamer-card .name { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.stat-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; border-bottom: 1px dashed var(--grid); }
.stat-line span:first-child { color: var(--muted); }
.stat-line b { font-variant-numeric: tabular-nums; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--live); display: inline-block; animation: pulse 1.4s infinite; }
.live-banner { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--radius); background: color-mix(in srgb, var(--live) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--live) 45%, transparent); }
.mood { display: grid; gap: 6px; }
.feed { max-height: 520px; overflow-y: auto; display: grid; gap: 1px; align-content: start; }
.legend-inline { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend-inline span { display: inline-flex; align-items: center; gap: 5px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 6px 0 -6px; }
.kbd { font-family: ui-monospace, monospace; font-size: 12px; background: var(--panel-3); padding: 1px 6px; border-radius: 5px; }
.log-line { font-family: ui-monospace, monospace; font-size: 12px; padding: 3px 0; border-bottom: 1px solid var(--grid); overflow-wrap: anywhere; }
.log-line.error { color: var(--bad); }
.log-line.warn { color: var(--warn); }
.cat-editor { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 10px; background: var(--panel-2); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-dot.ok { background: var(--good); }
.status-dot.bad { background: var(--bad); }
.status-dot.warn { background: var(--warn); }
.status-dot.off { background: var(--faint); }
.progress { height: 6px; background: var(--panel-3); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

/* ---------- адаптивность ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g21, .g12 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 35; }
  .main { margin-left: 0; }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 30; }
  .topbar .brand { padding: 0; font-weight: 700; }
  .page { padding: 16px 16px 48px; }
  .g2, .g4 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 20px; }
  .filters { position: static; }
  .hbar { grid-template-columns: minmax(70px, 38%) 1fr auto; }
}

.faq { border-bottom: 1px solid var(--grid); }
.faq summary { cursor: pointer; padding: 9px 0; font-weight: 600; }
.faq summary:hover { color: var(--accent); }
ol.muted { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
details summary { cursor: pointer; }

pre.digest { white-space: pre-wrap; font: 14px/1.55 var(--font); background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 0; overflow-wrap: anywhere; }

.top-questions { margin: 0; padding-left: 24px; display: grid; gap: 8px; }
.top-questions li { padding: 6px 4px; border-bottom: 1px dashed var(--grid); }
.top-questions li::marker { color: var(--accent); font-weight: 700; }

/* Обновление той же страницы с другими фильтрами: старый вид слегка приглушён. */
.page.refreshing { opacity: .6; transition: opacity .15s; pointer-events: none; }

/* ---------- команда: пасты, чат команды, оверлеи ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.sep { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; font: inherit; line-height: 1.45; }
textarea.input.code { font: 12px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; tab-size: 2; }
.nav-item.has-unread::after { content: ''; margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.paste-list { display: flex; flex-direction: column; gap: 10px; }
.paste { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); }
.paste-main { flex: 1; min-width: 0; }
.paste-title { font-weight: 600; margin-bottom: 4px; }
.paste-text { white-space: pre-wrap; word-break: break-word; margin-bottom: 6px; }
.paste-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
@media (max-width: 640px) { .paste { flex-direction: column; } .paste-actions { flex-direction: row; flex-wrap: wrap; } }

.team-chat { height: min(62vh, 640px); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 4px 2px; }
.tc-line { position: relative; padding: 4px 28px 4px 8px; border-radius: 8px; white-space: pre-wrap; word-break: break-word; }
.tc-line:hover { background: var(--panel-2); }
.tc-time { color: var(--faint); font-size: 11px; margin-right: 8px; font-variant-numeric: tabular-nums; }
.tc-del { position: absolute; right: 4px; top: 4px; border: 0; background: none; color: var(--faint); cursor: pointer; opacity: 0; }
.tc-line:hover .tc-del { opacity: 1; }
.tc-del:hover { color: var(--bad); }
.tc-input { align-items: stretch; }
.tc-input textarea { flex: 1; min-width: 200px; }

.steps-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.grant-row { padding: 6px 0; border-bottom: 1px solid var(--border); }
.grant-row:last-child { border-bottom: 0; }

/* редактор оверлея */
.ove { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .ove { grid-template-columns: 1fr; } }
.ove-main { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 6px; }
.ove-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ove-stage {
  position: relative; width: 100%; overflow: hidden; border-radius: 12px; border: 1px solid var(--border);
  background: repeating-conic-gradient(#2a2a36 0% 25%, #1f1f29 0% 50%) 0 0 / 24px 24px;
}
.ove-preview, .ove-boxes { position: absolute; left: 0; top: 0; transform-origin: 0 0; border: 0; }
/* color-scheme как у страницы оверлея — иначе в тёмной теме браузер зальёт фрейм белым. */
.ove-preview { pointer-events: none; background: transparent; color-scheme: normal; }
.ove-box { position: absolute; outline: 2px solid rgba(169, 112, 255, .55); outline-offset: -1px; cursor: move; touch-action: none; }
.ove-box.off { outline: 2px dashed rgba(255, 255, 255, .25); }
.ove-box.sel { outline: 4px solid var(--accent); background: rgba(169, 112, 255, .08); }
.ove-box-name { position: absolute; left: 0; top: 0; transform: translateY(-100%); background: rgba(0, 0, 0, .7); color: #fff; font-size: 22px; padding: 2px 10px; border-radius: 6px 6px 0 0; white-space: nowrap; pointer-events: none; }
.ove-box.off .ove-box-name { opacity: .6; }
.ove-handle { position: absolute; right: -14px; bottom: -14px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); border: 4px solid #fff; cursor: nwse-resize; }
.ove-add { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ove-add .btn { justify-content: flex-start; }
.ove-layers { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.ove-layer { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.ove-layer:hover { background: var(--panel-2); }
.ove-layer.sel { border-color: var(--accent); background: var(--accent-soft); }
.ove-layer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ove-eye { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--faint); cursor: pointer; font-size: 15px; }
.ove-eye.on { background: var(--good); border-color: var(--good); color: #fff; }
.ove-props { display: flex; flex-direction: column; gap: 12px; }
.ove-props .form-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.ove-show { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ove-thumb { max-width: 100%; max-height: 120px; border-radius: 8px; align-self: flex-start; background: repeating-conic-gradient(#2a2a36 0% 25%, #1f1f29 0% 50%) 0 0 / 16px 16px; }
.ove-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 60vh; overflow-y: auto; }
.ove-file { position: relative; }
.ove-file .icon-btn { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, .55); }
.ove-file-pick { width: 100%; display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); color: var(--text); cursor: pointer; text-align: left; overflow: hidden; }
.ove-file-pick:hover { border-color: var(--accent); }
.ove-file-pick img, .ove-file-ico { width: 100%; height: 100px; object-fit: contain; border-radius: 6px; display: grid; place-items: center; font-size: 40px; background: repeating-conic-gradient(#2a2a36 0% 25%, #1f1f29 0% 50%) 0 0 / 16px 16px; }
.ove-file-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
