/* Invisible Doors Platform — рабочая адаптация визуального языка invisible-doors.ru */

:root {
  --bg: #f7f7f7;
  --bg-panel: #ffffff;
  --bg-card: #ffffff;
  --text: #171717;
  --text-dim: #6b6a6a;
  --accent: #e61408;
  --accent-hover: #c91208;
  --accent-soft: #fff0ee;
  --success: #237c4b;
  --warning: #946200;
  --bg-soft: #faf9f7;
  --border: #e5e5e5;
  --radius: 10px;
  --shadow: 0 12px 34px rgba(25, 25, 25, .055);
  --font: "Helvetica Neue", Arial, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.hidden { display: none !important; }
button:focus-visible, a:focus-visible, .tab-btn:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Кнопки и поля ── */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}
.btn:hover { border-color: #c9c9c5; transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-block { width: 100%; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Логин ── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; height: 100dvh;
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(240,24,13,.07) 8% calc(8% + 1px), transparent calc(8% + 1px)),
    linear-gradient(180deg, #fff 0, var(--bg) 75%);
}
.login-card {
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 14px;
  padding: 32px 28px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 20px 60px rgba(20, 20, 20, .09);
}
.login-logo {
  justify-content: center;
  margin-bottom: 2px;
}
.login-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 8px; }
.login-error { color: #b3261e; font-size: 13px; text-align: center; min-height: 18px; }

/* ── Каркас ── */
/* dvh: на iOS 100vh выше видимой области (панели Safari) — низ уезжал под них */
#app { display: flex; height: 100vh; height: 100dvh; }
#sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-top { padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; }
.logo {
  padding: 1px 2px 8px;
}
.brand-lockup { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-icon { width: 38px; height: 38px; display: block; flex: 0 0 38px; }
.login-logo .brand-icon { width: 48px; height: 48px; flex-basis: 48px; }
.brand-copy { display: flex; flex-direction: column; line-height: .96; text-align: left; }
.brand-copy strong { font-size: 15px; font-weight: 500; letter-spacing: .025em; white-space: nowrap; }
.brand-copy small { margin-top: 4px; color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: .08em; }
.login-logo .brand-copy strong { font-size: 21px; }
.login-logo .brand-copy small { font-size: 13px; }
.sidebar-top #new-chat-btn {
  min-height: 40px;
  letter-spacing: .01em;
}
.tabs { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.tab-btn {
  text-align: left; border: none; background: transparent;
  padding: 9px 10px; border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--text);
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.tab-btn:hover { background: #f5f5f3; }
.tab-btn.active { background: var(--accent-soft); color: #b5120a; box-shadow: inset 3px 0 var(--accent); }
.nav-badge, .chat-unread {
  display: inline-flex; align-items: center; justify-content: center; min-width: 19px; height: 19px;
  padding: 0 5px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px;
}
.sidebar-top .nav-badge { float: right; }
.chat-list { flex: 1; overflow-y: auto; padding: 8px 10px; }
.chat-item {
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 6px; align-items: center;
  color: var(--text);
}
.chat-item:hover { background: rgba(0,0,0,.04); }
.chat-item.active { background: var(--accent-soft); color: #a9120b; box-shadow: inset 3px 0 var(--accent); }
.chat-item.unread .t { font-weight: 650; }
.chat-item .del { visibility: hidden; color: var(--text-dim); border: none; background: none; cursor: pointer; }
.chat-item:hover .del { visibility: visible; }
.chat-item span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-bottom {
  padding: 12px 14px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim);
}
.work-chat-notice { flex-basis: 100%; font-size: 10.5px; line-height: 1.25; color: var(--text-dim); }
/* штамп сборки: видно, свежую ли версию сайта показывает браузер */
.build-stamp { font-size: 11px; color: var(--text-dim); text-align: center; }

#main {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background: linear-gradient(180deg, var(--bg) 0%, #f3f3f3 100%);
}
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: #fff;
}
#burger { display: none; font-size: 18px; }
#topbar-title { flex: 1; font-weight: 650; letter-spacing: .01em; }
#sidebar-backdrop { display: none; }
.codex-limit { width: 190px; flex: 0 0 190px; }
.codex-limit-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.codex-limit-line strong { color: var(--text); font-size: 12px; }
.codex-limit-track { height: 5px; margin-top: 4px; overflow: hidden; border-radius: 5px; background: var(--border); }
.codex-limit-track i { display: block; height: 100%; width: 0; border-radius: inherit; background: #5d9b68; transition: width .25s ease; }
.codex-limit.warn .codex-limit-track i { background: #d98927; }
.codex-limit.danger .codex-limit-track i { background: #c9473a; }

.tab-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ── Чат ── */
#messages { flex: 1; overflow-y: auto; padding: 24px 16px 12px; }
.msg { max-width: 760px; margin: 0 auto 14px; }
.msg-user .bubble {
  background: var(--accent-soft);
  border: 1px solid #ffd9d6;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-left: 15%;
}
.msg-assistant .bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(20, 20, 20, .035);
}
.bubble { overflow-wrap: break-word; }
.bubble p:first-child { margin-top: 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble pre {
  background: #2c2a26; color: #f1efe9; padding: 12px; border-radius: 8px;
  overflow-x: auto; font-family: var(--mono); font-size: 13px;
}
.bubble code { font-family: var(--mono); font-size: 13px; background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 4px; }
.bubble pre code { background: none; padding: 0; }
.bubble table { border-collapse: collapse; }
.bubble td, .bubble th { border: 1px solid var(--border); padding: 4px 8px; }

.msg-tool {
  max-width: 760px; margin: 0 auto 6px;
  font-size: 12.5px; color: var(--text-dim);
  font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-tool .tool-name { color: var(--accent); }
.msg-error {
  max-width: 760px; margin: 0 auto 14px;
  color: #b3261e; font-size: 13.5px;
  background: #fdeceb; border: 1px solid #f3c2be; border-radius: 8px; padding: 8px 12px;
}
.msg-meta { max-width: 760px; margin: 0 auto 14px; color: var(--text-dim); font-size: 12px; text-align: right; }
.msg-queued { opacity: .72; }
.queued-label {
  display: block; margin: 3px 5px 0 auto; width: fit-content;
  color: var(--text-dim); font-size: 11px;
}
.queue-meta { color: var(--accent); }

#composer { padding: 8px 16px 16px; }
.composer-row {
  max-width: 760px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end;
}
#input {
  flex: 1; resize: vertical; min-height: 80px; max-height: 480px;
  border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 8px 26px rgba(20,20,20,.065);
}
#send-btn { border-radius: 12px; padding: 12px 17px; }
#run-status {
  max-width: 760px; margin: 0 auto 8px; display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-dim);
}
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Файлы ── */
#files-crumbs { padding: 14px 20px 0; font-size: 13.5px; color: var(--text-dim); }
#files-crumbs a { color: var(--accent); cursor: pointer; text-decoration: none; }
#files-list { padding: 10px 20px 20px; overflow-y: auto; }
.file-row {
  display: flex; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  font-size: 14px; align-items: center;
}
.file-row:hover { background: rgba(0,0,0,.04); }
.file-row .size { margin-left: auto; color: var(--text-dim); font-size: 12px; }
#file-editor { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 5; }
#tab-files { position: relative; }
.editor-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 13px;
}
.editor-actions { display: flex; gap: 6px; }
#editor-area {
  flex: 1; border: none; border-radius: 0; resize: none;
  font-family: var(--mono); font-size: 13px; line-height: 1.5;
  padding: 16px 20px; background: var(--bg-card);
}

/* ── Агенты ── */
.cards { padding: 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; overflow-y: auto; }
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow);
  transition: border-color .18s ease, transform .18s ease;
}
.card:hover { border-color: #d6d6d3; transform: translateY(-1px); }
.card h3 { margin: 0; font-size: 16px; letter-spacing: .01em; }
.card .desc { color: var(--text-dim); font-size: 13.5px; }
.card .src { font-size: 11.5px; color: var(--text-dim); font-family: var(--mono); }
.card .tasks { flex: 1; background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.card .tasks-head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin-bottom: 4px; }
.card .tasks ul { margin: 0; padding-left: 18px; font-size: 12.5px; }
.card .tasks li { margin: 2px 0; }
.card .tasks-none { font-size: 12.5px; color: var(--text-dim); font-style: italic; }
/* Рабочее меню агента */
.agent-menu { display: flex; flex-wrap: wrap; gap: 6px; }
.agent-menu .btn { padding: 6px 10px; font-size: 13px; }
.regular-wrap { display: flex; flex-direction: column; gap: 6px; flex: 1; }

/* Задачник агента (CRM-доска) */
.taskboard {
  background: #f3f3f3; border-radius: 10px; padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
/* Двухэтажная строка задачи: сверху статус + кнопки, ниже — тело во всю ширину
   (карточки узкие; однострочная раскладка сжимала текст в вертикальную кашу) */
.task-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px;
}
.task-row.st-done, .task-row.st-cancelled { opacity: .55; }
.task-row.expanded { opacity: 1; }
.task-status { font-size: 12px; padding: 4px 6px; border-radius: 6px; margin-right: auto; }
.task-row.st-open .task-status { border-color: var(--accent); color: var(--accent); }
.task-row.st-in_progress .task-status { border-color: #b8860b; color: #b8860b; }
.task-body { flex: 1 1 100%; order: 2; min-width: 0; cursor: pointer; }
.task-edit input, .task-edit textarea, .task-edit select { width: 100%; }
.task-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-sub { font-size: 11.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row.expanded .task-title, .task-row.expanded .task-sub { white-space: normal; overflow: visible; }
.task-detail { font-size: 12.5px; margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.task-meta { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.tasks-closed-toggle {
  background: none; border: none; color: var(--text-dim);
  font-size: 12.5px; cursor: pointer; padding: 4px 0; text-align: left;
}
.tasks-closed-toggle:hover { color: var(--text); }
/* Правила и планы агента */
.rulesbox {
  background: var(--bg); border-radius: 8px; padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.rulesbox textarea { font-size: 13px; resize: vertical; font-family: var(--mono); }
.rulesbox .btn { align-self: flex-start; padding: 6px 12px; font-size: 13px; }
.task-act { padding: 2px 6px; font-size: 13px; }
.task-form { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.task-form input, .task-form select, .task-form textarea { padding: 7px 10px; font-size: 13px; }
.task-form textarea { resize: vertical; font-family: inherit; }
.task-form .btn { align-self: flex-start; padding: 6px 12px; font-size: 13px; }
.task-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.task-field-label { color: var(--text-dim); font-size: 11.5px; font-weight: 600; }
.task-form-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.task-form-error { padding: 8px 10px; color: #a42d24; background: #fde9e7; border: 1px solid #efbdb8; border-radius: 7px; font-size: 12px; }
.task-schedule { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 7px; border: 1px dashed var(--border); border-radius: 7px; }
.task-schedule input, .task-schedule select { width: auto; }
.task-automation-enabled { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; }
.task-automation-enabled input { width: auto; }
.task-automation { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.task-automation .btn { font-size: 12px; padding: 5px 8px; }
.automation-log { flex-basis: 100%; font-size: 12px; line-height: 1.5; color: var(--text-dim); padding: 7px; background: var(--bg); border-radius: 6px; max-height: 240px; overflow: auto; }
.automation-run-row { min-width: 0; padding: 7px 2px; border-bottom: 1px solid var(--border); }
.automation-run-row:last-child { border-bottom: 0; }
.automation-run-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.automation-run-badges { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.automation-run-meta { margin-left: auto; white-space: nowrap; color: var(--text-dim); }
.automation-run-error { margin-top: 4px; color: #b3261e; white-space: pre-wrap; overflow-wrap: anywhere; }
.run-status-chip, .delivery-status-chip {
  display: inline-flex; align-items: center; max-width: 100%; border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 7px; font-size: 11px; line-height: 1.35;
  font-weight: 650; white-space: nowrap;
}
.run-status-completed { color: #2f6b3c; background: #e7f3e9; border-color: #bad9c0; }
.run-status-needs_input { color: #875b0a; background: #fff3d8; border-color: #e9cf91; }
.run-status-unknown { color: #5f6268; background: #f0f1f2; border-color: #d4d6d9; }
.run-status-technical_failed { color: #a42d24; background: #fde9e7; border-color: #efbdb8; }
.run-status-running { color: #285f88; background: #e8f2fa; border-color: #b9d5e9; }
.run-status-scheduled { color: #5f6268; background: #f3f3f3; border-color: #d7d7d7; }
.delivery-status-queued { color: #67540d; background: #faf4d9; border-color: #dfd29b; }
.delivery-status-sent { color: #2f6b3c; background: #e7f3e9; border-color: #bad9c0; }
.delivery-status-failed { color: #a42d24; background: #fde9e7; border-color: #efbdb8; }
.task-edit { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.task-edit .btn { display: inline-block; margin-right: 6px; }
.weekday-checkboxes { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 8px; border: 1px dashed var(--border); border-radius: 7px; }
.weekday-checkboxes legend { padding: 0 4px; color: var(--text-dim); font-size: 11.5px; font-weight: 600; }
.weekday-check { display: inline-flex; align-items: center; gap: 3px; padding: 4px 6px; background: var(--bg); border-radius: 6px; font-size: 12px; cursor: pointer; }
.task-edit .weekday-check input, .automation-editor .task-automation-enabled input { width: auto; padding: 0; }
.taskboard-section-head { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ── Единый задачник ── */
#tasks-overview { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.tasks-summary { display: grid; grid-template-columns: repeat(4, minmax(100px, 1fr)); gap: 10px; }
.tasks-kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; }
.tasks-kpi { box-shadow: var(--shadow); }
.tasks-kpi strong { font-size: 24px; }
.tasks-kpi span { color: var(--text-dim); font-size: 12px; }
.tasks-filters { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(3, minmax(130px, 1fr)); gap: 8px; }
.tasks-overview-list { display: flex; flex-direction: column; gap: 8px; }
.overview-task { background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid #aaa; border-radius: 10px; padding: 12px; }
.overview-task { box-shadow: 0 6px 18px rgba(20,20,20,.035); }
.overview-task.pr-high { border-left-color: #d98927; }
.overview-task.pr-urgent, .overview-task.overdue { border-left-color: #c9473a; }
.overview-task-head { display: flex; justify-content: space-between; gap: 12px; }
.automation-title-wrap { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.automation-title-wrap strong { overflow-wrap: anywhere; }
.overview-agent { color: var(--accent); font-size: 12px; white-space: nowrap; }
.overview-task-meta { color: var(--text-dim); font-size: 12px; margin-top: 3px; }
.overview-task.overdue .overview-task-meta { color: #b83d32; font-weight: 600; }
.overview-task-desc { margin-top: 8px; font-size: 13px; white-space: pre-wrap; }
.overview-task-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.overview-task-actions select, .overview-task-actions .btn { font-size: 12px; padding: 5px 8px; }
.overview-task > .task-edit { width: 100%; }
.overview-task.source-platform { border-left-color: #6b7c92; }
.overview-task.source-legacy_schedule { border-left-color: #a8793b; }
.overview-task.source-system_automation { border-left-color: #5d718f; }
.managed-automation.compact { padding: 9px; box-shadow: none; }
.managed-automation.compact .overview-task-desc { max-height: 5.4em; overflow: auto; }
.automation-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.automation-source-badge, .automation-state-badge, .automation-risk-badge {
  display: inline-flex; align-items: center; width: fit-content; border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 7px; font-size: 10.5px; line-height: 1.35; font-weight: 650;
}
.automation-source-badge.source-platform { color: #4d6178; background: #eef2f6; }
.automation-source-badge.source-legacy_schedule { color: #76501f; background: #fbf2df; border-color: #e5cfa3; }
.automation-source-badge.source-system_automation { color: #425b78; background: #eaf1f8; border-color: #bfd0e1; }
.automation-state-badge.state-active { color: #2f6b3c; background: #e7f3e9; border-color: #bad9c0; }
.automation-state-badge.state-paused { color: #765b17; background: #faf4d9; border-color: #dfd29b; }
.automation-state-badge.state-closed { color: #666; background: #f0f1f2; border-color: #d4d6d9; }
.automation-risk-badge.risk-internal { color: #5f6268; background: #f0f1f2; }
.automation-risk-badge.risk-report { color: #285f88; background: #e8f2fa; border-color: #b9d5e9; }
.automation-risk-badge.risk-external_write { color: #a42d24; background: #fde9e7; border-color: #efbdb8; }
.automation-warning, .automation-conflict, .automation-readonly { margin-top: 8px; padding: 7px 9px; border-radius: 7px; font-size: 11.5px; line-height: 1.4; }
.automation-warning { color: #8a2c24; background: #fdeceb; border: 1px solid #f3c2be; }
.automation-conflict { color: #765b17; background: #fff6df; border: 1px solid #e7d39b; }
.automation-readonly { color: var(--text-dim); background: var(--bg); }
.overview-task-actions .automation-readonly { margin: 0; padding: 5px 8px; }
.automation-editor { margin-top: 10px; }

/* ── Сегодня ── */
#today-overview { overflow-y: auto; padding: 18px; }
.today-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 980px; margin: 0 auto 16px; }
.today-section { max-width: 980px; margin: 0 auto 18px; }
.today-section h3 { margin: 0 0 8px; font-size: 15px; }
.today-list { display: flex; flex-direction: column; gap: 7px; }
.today-row { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; padding: 11px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 9px; color: var(--text); }
.today-row { box-shadow: 0 6px 18px rgba(20,20,20,.03); }
.today-row > div, .today-failure { min-width: 0; }
.today-row strong, .today-row small { display: block; overflow-wrap: anywhere; }
.today-row small { margin-top: 3px; color: var(--text-dim); }
.today-row-button { font: inherit; cursor: pointer; }
.today-row-button:hover { border-color: var(--accent); }
.today-failure { border-left: 4px solid #c9473a; }
.today-row-main { flex: 1 1 320px; min-width: 0; }
.today-row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; min-width: 0; }
.today-row-head strong { flex: 1 1 240px; min-width: 0; }
.today-row-actions { display: flex; flex: 0 0 auto; gap: 6px; }
.today-row-actions .btn { padding: 5px 8px; font-size: 12px; white-space: nowrap; }
.today-run-error { color: #a42d24 !important; white-space: pre-wrap; }
.today-running { border-left: 4px solid #5b91b7; }
.today-needs-input { border-left: 4px solid #d49a2c; }
.today-failure, .today-delivery-failure { border-left: 4px solid #c9473a; }
.today-result { border-left: 4px solid #78a480; }
.tasks-empty, .tasks-loading { color: var(--text-dim); padding: 24px; text-align: center; }

/* ── Чаты команды: отдельный административный read-only viewer ── */
.team-chats-page { min-height: 0; height: 100%; display: flex; flex-direction: column; padding: 16px; gap: 12px; }
.team-chat-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) 220px 220px auto; gap: 8px; }
.team-chat-toolbar input, .team-chat-toolbar select { min-width: 0; }
.team-chats-layout {
  min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.team-chat-list { min-height: 0; overflow-y: auto; border-right: 1px solid var(--border); background: var(--bg-panel); }
.team-chat-row {
  width: 100%; display: block; border: 0; border-bottom: 1px solid var(--border); background: transparent;
  padding: 12px; text-align: left; color: var(--text); font: inherit; cursor: pointer;
}
.team-chat-row:hover { background: rgba(0,0,0,.035); }
.team-chat-row.active { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.team-chat-row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font-size: 13px; }
.team-chat-row-top span { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.team-chat-title { margin-top: 4px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-chat-preview { margin-top: 5px; color: var(--text-dim); font-size: 12px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.team-chat-meta { margin-top: 6px; color: var(--accent); font-size: 10.5px; overflow-wrap: anywhere; }
.team-chat-viewer { min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.team-chat-view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.team-chat-view-head h3 { margin: 0; font-size: 16px; }
.team-chat-context { margin-top: 3px; color: var(--text-dim); font-size: 12px; }
.team-chat-readonly { padding: 7px 16px; background: #f4f0e5; color: var(--text-dim); border-bottom: 1px solid var(--border); font-size: 11.5px; }
.team-chat-transcript { min-height: 0; flex: 1; overflow-y: auto; padding: 18px 16px; }
.team-message { max-width: 820px; margin: 0 auto 13px; display: flex; flex-direction: column; }
.team-message .bubble { border-radius: var(--radius); padding: 10px 14px; }
.team-message-user .bubble { margin-left: 13%; background: var(--accent-soft); }
.team-message-assistant .bubble { background: var(--bg-card); border: 1px solid var(--border); }
.team-message-error .bubble { color: #b3261e; background: #fdeceb; border: 1px solid #f3c2be; }
.team-message.queued { opacity: .7; }
.team-message-time { margin: 3px 5px 0; color: var(--text-dim); font-size: 10.5px; text-align: right; }
.team-chat-empty { margin: auto; padding: 24px; color: var(--text-dim); text-align: center; }

/* ── Входящие команды: Telegram-ответы менеджеров ── */
.team-inbox-page {
  height: 100%; min-height: 0; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.team-inbox-summary { flex: 0 0 auto; padding: 0; }
.team-inbox-kpi { border-left: 3px solid var(--border); }
.team-inbox-kpi-urgent { border-left-color: #c9473a; }
.team-inbox-kpi-warning { border-left-color: #d49a2c; }
.team-inbox-kpi-info { border-left-color: #5b91b7; }
.team-inbox-kpi-success { border-left-color: #78a480; }
.team-inbox-summary-note {
  grid-column: 1 / -1; color: var(--text-dim); font-size: 11.5px; padding: 0 4px;
}
.team-inbox-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px 180px 190px auto auto;
  gap: 8px; align-items: center;
}
.team-inbox-toolbar input, .team-inbox-toolbar select { min-width: 0; }
.team-inbox-trivial {
  display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim);
  font-size: 12px; white-space: nowrap;
}
.team-inbox-bulk {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card);
}
.team-inbox-bulk label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
#team-inbox-selected { color: var(--text-dim); font-size: 12px; }
#team-inbox-review { margin-left: auto; }
.team-inbox-plan {
  display: grid; gap: 11px; padding: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  border-radius: 12px; background: color-mix(in srgb, var(--accent-soft) 42%, var(--bg-card));
}
.team-inbox-plan-header {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 16px; align-items: start;
}
.team-inbox-plan-header h3 { margin: 0 0 5px; font-size: 16px; }
.team-inbox-plan-header p { margin: 0; color: var(--text-dim); font-size: 12.5px; line-height: 1.45; }
.team-inbox-plan-shield {
  padding: 9px 11px; border: 1px solid color-mix(in srgb, #4f8b61 38%, var(--border));
  border-radius: 9px; color: #386940;
  background: color-mix(in srgb, #78a480 11%, var(--bg-card)); font-size: 11.5px; line-height: 1.45;
}
.team-inbox-plan-task {
  display: grid; gap: 9px; padding: 12px;
  border: 1px solid var(--border); border-left: 4px solid #5b91b7;
  border-radius: 10px; background: var(--bg-card);
}
.team-inbox-plan-task.risk-internal_change { border-left-color: #d49a2c; }
.team-inbox-plan-task.risk-external_action { border-left-color: #c76c2e; }
.team-inbox-plan-task.risk-irreversible { border-left-color: #c9473a; }
.team-inbox-plan-task-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.team-inbox-plan-approve { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; }
.team-inbox-plan-risk {
  padding: 3px 7px; border: 1px solid var(--border); border-radius: 999px;
  color: #255d87; background: var(--bg-soft); font-size: 10.5px; white-space: nowrap;
}
.team-inbox-plan-risk.risk-internal_change { color: #8b4b00; }
.team-inbox-plan-risk.risk-external_action { color: #9a470d; background: #fff2dc; }
.team-inbox-plan-risk.risk-irreversible { color: #a42d24; background: #fdeceb; }
.team-inbox-plan-source, .team-inbox-plan-reason {
  color: var(--text-dim); font-size: 11.5px; line-height: 1.4;
}
.team-inbox-plan-fields {
  display: grid; grid-template-columns: minmax(190px, .7fr) minmax(260px, 1.3fr);
  gap: 8px;
}
.team-inbox-plan-fields label {
  display: grid; gap: 4px; color: var(--text-dim); font-size: 11px;
}
.team-inbox-plan-fields input, .team-inbox-plan-fields select,
.team-inbox-plan-fields textarea { min-width: 0; color: var(--text); font-size: 12.5px; }
.team-inbox-plan-fields textarea { resize: vertical; line-height: 1.45; }
.team-inbox-plan-instruction { grid-column: 1 / -1; }
.team-inbox-plan-external {
  display: flex; align-items: flex-start; gap: 7px; padding: 9px;
  border: 1px solid #edc995; border-radius: 8px; color: #8b4b00;
  background: #fff7e8; font-size: 12px; line-height: 1.4;
}
.team-inbox-plan-blocked {
  padding: 9px; border: 1px solid #f3c2be; border-radius: 8px;
  color: #a42d24; background: #fdeceb; font-size: 12px;
}
.team-inbox-plan-footer {
  display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px;
}
.team-inbox-plan-status { margin-right: auto; color: var(--text-dim); font-size: 11.5px; }
.team-inbox-plan-status.is-error { color: #b3261e; }
.team-inbox-list { display: grid; gap: 10px; padding-bottom: 20px; }
.team-inbox-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 11px;
  padding: 13px; border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: 12px; background: var(--bg-card); box-shadow: var(--shadow);
}
.team-inbox-item-new { border-left-color: #c9473a; }
.team-inbox-item-reviewing { border-left-color: #d49a2c; }
.team-inbox-item-dispatched { border-left-color: #5b91b7; }
.team-inbox-item-done { border-left-color: #78a480; }
.team-inbox-item-archived, .team-inbox-item.is-trivial { opacity: .72; }
.team-inbox-check { margin-top: 3px; }
.team-inbox-item-body { min-width: 0; }
.team-inbox-item-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.team-inbox-item-head > div:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.team-inbox-item-head strong { font-size: 14px; }
.team-inbox-item-head > div:first-child span { color: var(--text-dim); font-size: 11px; }
.team-inbox-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.team-inbox-badge {
  display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 999px;
  border: 1px solid var(--border); font-size: 10.5px; white-space: nowrap;
}
.team-inbox-category-correction { color: #a42d24; background: #fdeceb; border-color: #f3c2be; }
.team-inbox-category-problem { color: #8b4b00; background: #fff2dc; border-color: #f0d2a2; }
.team-inbox-category-request { color: #255d87; background: #eaf3fa; border-color: #bfd8ea; }
.team-inbox-category-idea { color: #67500a; background: #fff8d8; border-color: #e8d98e; }
.team-inbox-category-feedback { color: var(--text-dim); background: var(--bg-soft); }
.team-inbox-category-trivial { color: var(--text-dim); border-style: dashed; }
.team-inbox-message {
  margin-top: 9px; color: var(--text); font-size: 13.5px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.team-inbox-context { margin-top: 9px; color: var(--text-dim); font-size: 11.5px; }
.team-inbox-context summary { cursor: pointer; user-select: none; }
.team-inbox-context-row {
  display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 8px;
  margin-top: 6px; padding: 7px 9px; border-radius: 8px; background: var(--bg-soft);
}
.team-inbox-context-row strong { font-size: 11px; }
.team-inbox-context-row span { white-space: pre-wrap; overflow-wrap: anywhere; }
.team-inbox-context-out { border-left: 2px solid var(--accent); }
.team-inbox-resolution {
  margin-top: 9px; padding: 7px 9px; border-radius: 8px;
  color: #386940; background: color-mix(in srgb, #78a480 12%, transparent);
  font-size: 12px; white-space: pre-wrap;
}
.team-inbox-item-controls { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.team-inbox-item-controls select { width: auto; max-width: 260px; font-size: 12px; }
.team-inbox-status-new { color: #a42d24; }
.team-inbox-status-reviewing { color: #8b4b00; }
.team-inbox-status-dispatched { color: #255d87; }
.team-inbox-status-done { color: #386940; }
.team-inbox-error { position: sticky; top: 0; z-index: 2; }

/* ── Админка ── */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px; overflow-y: auto; }
.admin-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.admin-card h3 { margin-top: 0; }
.admin-card form { display: flex; flex-direction: column; gap: 8px; }
.admin-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.admin-row .sub { color: var(--text-dim); font-size: 12px; }
.admin-row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; }
.admin-access-edit, .admin-password-edit { padding: 10px; margin-bottom: 8px; background: var(--bg); border-radius: 8px; }
.admin-access-edit { max-height: 320px; overflow-y: auto; }
.admin-password-edit { display: flex; flex-direction: row !important; }
.admin-password-edit input { min-width: 0; flex: 1; }
.admin-hint { color: var(--text-dim); font-size: 13px; }
.admin-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin-card-head h3 { margin: 0; }
.admin-card-head select { width: auto; min-width: 130px; }
.admin-audit-card { grid-column: 1 / -1; }
.admin-team-chats-link { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-team-chats-link h3, .admin-team-chats-link p { margin: 0; }
.audit-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.audit-row { border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; min-width: 0; }
.audit-row.critical { border-left: 3px solid #b3261e; }
.audit-row-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.audit-row-top span { color: var(--text-dim); white-space: nowrap; }
.audit-row .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backup-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.backup-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.checks-col { flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.checks-label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
label.inline { display: flex; gap: 6px; align-items: center; font-size: 13.5px; }

/* ── Вложения и голос в композере ── */
.composer-icon { padding: 8px 9px; font-size: 16px; flex-shrink: 0; }
.composer-site { padding: 8px 9px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
#mic-btn.mic-on { background: var(--accent); color: #fff; border-radius: 50%; }
#attach-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px 6px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 3px 8px; font-size: 12.5px;
}
.attach-chip button {
  border: none; background: none; cursor: pointer;
  color: var(--text-dim); font-size: 14px; padding: 0; line-height: 1;
}

/* ── Нижняя навигация (только мобильный) ── */
#bottom-nav { display: none; }

/* ── Мобильный ── */
@media (max-width: 800px) {
  .audit-list { grid-template-columns: 1fr; }
  .composer-site span { display: none; }
  .composer-site { font-size: 16px; }
  #burger { display: block; }
  #sidebar {
    position: fixed; z-index: 20; height: 100%;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-backdrop.show {
    display: block; position: fixed; inset: 0; z-index: 15;
    background: rgba(0,0,0,.3);
  }
  .msg-user .bubble { margin-left: 5%; }
  .admin-grid { grid-template-columns: 1fr; }
  .team-chats-page { padding: 10px; }
  .team-chat-toolbar { grid-template-columns: 1fr 1fr; }
  .team-chat-toolbar input { grid-column: 1 / -1; }
  .team-chats-layout { grid-template-columns: 1fr; grid-template-rows: minmax(170px, 32vh) minmax(260px, 1fr); }
  .team-chat-list { border-right: 0; border-bottom: 1px solid var(--border); }
  .team-message-user .bubble { margin-left: 5%; }
  .team-inbox-page { padding: 10px; }
  .team-inbox-toolbar { grid-template-columns: 1fr 1fr; }
  .team-inbox-toolbar #team-inbox-search { grid-column: 1 / -1; }
  .team-inbox-trivial { white-space: normal; }
  .team-inbox-bulk { flex-wrap: wrap; }
  #team-inbox-review { width: 100%; margin-left: 0; }
  .team-inbox-plan { padding: 10px; }
  .team-inbox-plan-header, .team-inbox-plan-fields { grid-template-columns: 1fr; }
  .team-inbox-plan-instruction { grid-column: auto; }
  .team-inbox-plan-task-top { align-items: flex-start; flex-direction: column; }
  .team-inbox-plan-footer .btn { width: 100%; }
  .team-inbox-item-head { flex-direction: column; }
  .team-inbox-badges { justify-content: flex-start; }
  .team-inbox-item-controls select { flex: 1 1 180px; max-width: none; }
  .tasks-summary { grid-template-columns: repeat(2, 1fr); }
  .today-summary { grid-template-columns: 1fr; }
  #today-overview { padding: 12px; }
  .today-row { align-items: flex-start; flex-wrap: wrap; }
  .today-row-actions { width: 100%; justify-content: flex-end; }
  .today-row-head strong { flex-basis: 100%; }
  .automation-run-top { align-items: flex-start; flex-direction: column; }
  .automation-run-meta { margin-left: 0; white-space: normal; }
  .run-status-chip, .delivery-status-chip { white-space: normal; overflow-wrap: anywhere; }
  .tasks-filters { grid-template-columns: 1fr; }
  #tasks-overview { padding: 12px; }
  #model-select { max-width: 150px; }
  #reasoning-select { max-width: 150px; }

  /* вкладки переезжают из сайдбара в нижнее меню */
  .sidebar-top .tabs { display: none; }
  #main { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  /* чёлка/статус-бар не должны наезжать на верхнюю панель */
  #topbar { padding-top: calc(10px + env(safe-area-inset-top)); flex-wrap: wrap; }
  #topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .codex-limit { width: 82px; flex-basis: 82px; }
  .codex-limit-line { display: block; overflow: hidden; text-overflow: ellipsis; }
  #codex-limit-reset, #claude-limit-reset { display: none; }
  /* Метр контекста нужен и на телефоне — оставляем ему чуть больше места,
     но подпись «84k / 200k» прячем: процент в заголовке уже всё говорит. */
  #context-meter { width: 104px; flex-basis: 104px; }
  #context-meter-detail { display: none; }
  #model-select, #reasoning-select { flex: 1 1 140px; max-width: none; }
  #sidebar { padding-top: env(safe-area-inset-top); }
  #bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 12;
    background: var(--bg-panel); border-top: 1px solid var(--border);
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); overflow-x: auto;
  }
  #bottom-nav .tab-btn {
    flex: 1 0 62px; display: flex; flex-direction: column; align-items: center; gap: 1px;
    background: none; border: none; color: var(--text-dim);
    font-size: 11px; padding: 4px 2px; cursor: pointer; border-radius: 8px;
  }
  #bottom-nav .tab-btn span { font-size: 19px; line-height: 1.2; }
  #bottom-nav .tab-btn.active { color: var(--accent); background: var(--accent-soft); }
}

/* ── SMM-кабинет ── */
.smm-subnav { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.smm-hint { color: var(--text-dim); font-size: 13px; margin: 8px 0; }
.smm-badge {
  font-size: 12px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-panel); white-space: nowrap;
}
.smm-badge-published { background: #e4f2e4; border-color: #bcd9bc; color: #2f6b2f; }
.smm-badge-scheduled, .smm-badge-publishing { background: #eaf0f7; border-color: #c4d4e8; color: #2c5583; }
.smm-badge-failed, .smm-badge-partial { background: #f9e3e0; border-color: #e8b9b2; color: #a33325; }
.smm-badge-manual_pending { background: #faf0d9; border-color: #e6d3a3; color: #8a6d1d; }
.smm-post-link { display: inline-block; margin: 4px 8px 0 0; font-size: 13px; }
.smm-manual-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 8px; font-size: 13px;
}
.smm-manual-row input { flex: 1; min-width: 180px; }
.smm-form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.smm-check-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.smm-check-row label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.smm-post-form textarea { width: 100%; }
.smm-doc-editor { width: 100%; font-family: var(--mono); font-size: 13px; margin-bottom: 8px; }
.smm-media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; margin-top: 10px;
}
.smm-media-cell {
  position: relative; border: 2px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-card); cursor: pointer;
}
.smm-media-cell img { width: 100%; height: 90px; object-fit: cover; display: block; max-width: 100%; }
.smm-media-video { height: 90px; display: flex; align-items: center; justify-content: center; font-size: 32px; }
.smm-media-cap {
  font-size: 11px; color: var(--text-dim); padding: 4px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.smm-media-picker .smm-media-cell.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.smm-media-del {
  position: absolute; top: 4px; right: 4px; padding: 2px 6px; font-size: 12px;
}
@media (max-width: 800px) {
  .smm-media-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .smm-manual-row input { min-width: 120px; }
}
.smm-guide-btn { margin-top: 8px; font-size: 13px; }
.smm-guide {
  margin-top: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.5;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.smm-guide ol { margin: 6px 0 12px; padding-left: 20px; }
.smm-guide li { margin: 3px 0; }
.smm-cat-head { margin: 18px 0 4px; font-size: 15px; }
.smm-cat-dead { opacity: 0.75; }

/* Вкладка «Аналитика» — KPI бэк-офиса + скорость менеджеров продаж */
.analytics-page { padding: 16px; overflow-x: auto; }
.analytics-subtabs { display: flex; gap: 6px; margin-bottom: 18px; padding: 4px; width: fit-content; background: #ededed; border-radius: 11px; }
.analytics-subtab { border: 0; border-radius: 8px; padding: 8px 14px; background: transparent; color: var(--text-dim); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.analytics-subtab.active { background: var(--bg-card); color: var(--text); box-shadow: 0 2px 8px rgba(20,20,20,.08); }
.analytics-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.analytics-head h2 { margin: 0; font-size: 18px; }
.analytics-head select { padding: 6px 10px; border-radius: 8px; }
.analytics-table-wrap { margin: 18px 0; }
.analytics-table-wrap h3 { margin: 0 0 8px; font-size: 14px; opacity: .8; }
.analytics-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.analytics-table th, .analytics-table td { border: 1px solid var(--border, #2a2a2a); padding: 6px 10px; text-align: center; white-space: nowrap; }
.analytics-table th { background: rgba(127,127,127,.12); font-weight: 600; }
.analytics-table td:first-child, .analytics-table th:first-child { text-align: left; position: sticky; left: 0; background: var(--bg, #1b1b1b); }
.analytics-zone-legend { display: flex; flex-direction: column; gap: 5px; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); font-size: 13px; line-height: 1.45; }
.analytics-speed-note { margin: 9px 0 14px; color: var(--text-dim); font-size: 13px; line-height: 1.45; }
.analytics-coverage { margin: 4px 0 12px; color: var(--text-dim); font-size: 13px; }
.analytics-manager-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 12px; padding-bottom: 16px; }
.analytics-manager-card { min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); box-shadow: var(--shadow); }
.analytics-manager-card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.analytics-manager-card > header h3 { margin: 0; font-size: 16px; }
.analytics-manager-card > header span { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.analytics-manager-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.analytics-speed-metric { min-width: 0; padding: 11px 12px; border: 1px solid var(--border); border-left-width: 4px; border-radius: 9px; background: #fafafa; }
.analytics-speed-metric.zone-green { border-left-color: #33a852; background: #f3fbf5; }
.analytics-speed-metric.zone-yellow { border-left-color: #d39b13; background: #fffaf0; }
.analytics-speed-metric.zone-red { border-left-color: #d23c32; background: #fff5f4; }
.analytics-speed-metric.zone-none { border-left-color: #a7a7a7; }
.analytics-speed-metric h4 { margin: 0 0 8px; font-size: 14px; }
.analytics-zone-badge { margin-bottom: 9px; font-size: 13px; font-weight: 700; }
.analytics-speed-stats { display: flex; flex-direction: column; gap: 5px; margin: 0; }
.analytics-speed-stats > div { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.analytics-speed-stats dt { color: var(--text-dim); }
.analytics-speed-stats dd { margin: 0; font-weight: 600; text-align: right; }
.analytics-speed-pending { margin: 9px 0 0; padding-top: 8px; border-top: 1px solid rgba(127,127,127,.2); color: var(--text-dim); font-size: 12px; }
.analytics-speed-empty { min-height: 30px; margin: 0; font-size: 12px; }
.analytics-empty-card { padding: 16px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-dim); background: var(--bg-card); }
.nps-metrics { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 10px; margin: 0 0 16px; }
.nps-metric { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 13px 14px; border: 1px solid var(--border); border-left: 4px solid #9b9b9b; border-radius: 10px; background: var(--bg-card); }
.nps-metric strong { font-size: 23px; line-height: 1; }
.nps-metric span { color: var(--text-dim); font-size: 12px; line-height: 1.35; }
.nps-metric.positive { border-left-color: var(--success, #33a852); }
.nps-metric.negative { border-left-color: var(--danger, #d23c32); }
.nps-metric.warning { border-left-color: var(--warning, #d89516); }
.nps-metric.accent { border-left-color: var(--accent); }
.nps-warning { margin: 0 0 14px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border)); border-radius: 9px; color: var(--warning); background: color-mix(in srgb, var(--warning) 8%, transparent); font-size: 12px; line-height: 1.45; }
.nps-filters { display: grid; grid-template-columns: repeat(4, minmax(140px, 190px)) minmax(220px, 1fr); gap: 10px; align-items: end; margin: 0 0 14px; }
.nps-filter { display: flex; flex-direction: column; gap: 5px; min-width: 0; color: var(--text-dim); font-size: 11px; font-weight: 650; }
.nps-filter select, .nps-filter input { width: 100%; min-width: 0; height: 36px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); color: var(--text); font: inherit; font-size: 13px; font-weight: 400; }
.nps-table-wrap { overflow-x: auto; }
.nps-table { min-width: 1540px; }
.nps-table td { vertical-align: top; }
.nps-table td:nth-child(2), .nps-table td:nth-child(5), .nps-table td:nth-child(6), .nps-table td:nth-child(8), .nps-table td:nth-child(9) { text-align: left; }
.nps-table td:first-child, .nps-table th:first-child { min-width: 132px; }
.nps-table .nps-claim { min-width: 220px; max-width: 340px; white-space: normal; line-height: 1.4; }
.nps-table .nps-reality { min-width: 300px; max-width: 470px; white-space: normal; line-height: 1.4; }
.nps-finding { margin-top: 7px; }
.nps-task-assignee { display: block; margin: 0 0 5px; color: var(--text-dim); font-size: 10px; line-height: 1.35; }
.nps-table a { color: var(--accent); text-decoration: none; font-weight: 650; }
.nps-table a:hover { text-decoration: underline; }
.nps-task-number { display: block; margin-bottom: 3px; font-weight: 650; }
.nps-task-link { display: block; margin-bottom: 5px; font-size: 11px; }
.nps-badge { display: inline-flex; align-items: center; width: fit-content; padding: 3px 7px; border-radius: 999px; background: rgba(127,127,127,.12); color: var(--text-dim); font-size: 11px; font-weight: 700; white-space: nowrap; }
.nps-badge.outcome-problem, .nps-badge.task-overdue, .nps-badge.task-missing { color: var(--danger, #d23c32); background: color-mix(in srgb, var(--danger, #d23c32) 10%, transparent); }
.nps-badge.outcome-satisfied, .nps-badge.task-completed { color: var(--success, #33a852); background: color-mix(in srgb, var(--success, #33a852) 10%, transparent); }
.nps-badge.task-open { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.nps-badge.verification-verified { color: var(--success, #33a852); background: color-mix(in srgb, var(--success, #33a852) 10%, transparent); }
.nps-badge.verification-pending { color: var(--warning, #d89516); background: color-mix(in srgb, var(--warning, #d89516) 10%, transparent); }
.nps-badge.verification-insufficient, .nps-badge.verification-error { color: var(--text-dim); background: rgba(127,127,127,.12); }
.nps-no-results { padding: 18px !important; color: var(--text-dim); text-align: center !important; }
.manager-test-editor { max-width: 640px; margin: 0 0 18px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); }
.manager-test-form { display: grid; grid-template-columns: 1fr 160px 160px; gap: 12px; }
.manager-test-form .task-field:first-child, .manager-test-form .task-field:nth-child(2), .manager-test-form .analytics-speed-note { grid-column: 1 / -1; }
.manager-test-form textarea { min-height: 150px; resize: vertical; }
.manager-test-form > .btn { justify-self: start; }
.manager-test-campaign { margin: 0 0 16px; padding: 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); box-shadow: var(--shadow); }
.manager-test-campaign > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.manager-test-campaign h3 { margin: 0; font-size: 16px; }
.manager-test-campaign header p { margin: 4px 0 0; color: var(--text-dim); font-size: 12px; }
.manager-test-head-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.manager-test-preview { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent); }
.manager-test-approvals { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 13px; }
.manager-test-approval { padding: 5px 9px; border: 1px solid var(--border); border-radius: 999px; font-size: 11px; }
.manager-test-approval.approved { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); color: var(--success); background: color-mix(in srgb, var(--success) 8%, transparent); }
.manager-test-approval.pending { color: var(--warning); background: color-mix(in srgb, var(--warning) 8%, transparent); }
.manager-test-review { max-height: 760px; margin: 0 0 15px; padding: 15px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft); }
.manager-test-review-head, .manager-test-review-roster { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.manager-test-review-head h4 { margin: 0; }
.manager-test-review-head p { margin: 3px 0 0; color: var(--text-dim); font-size: 12px; }
.manager-test-review-roster { align-items: center; margin: 13px 0; padding: 11px; border-radius: 9px; background: var(--bg-card); font-size: 12px; line-height: 1.45; }
.manager-test-key-approval { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 8px; margin: 12px 0 16px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); }
.manager-test-key-approval input { min-width: 0; }
.manager-test-key-approval p { grid-column: 1 / -1; margin: 0; color: var(--text-dim); font-size: 11px; }
.manager-test-review-approved { padding: 10px; border-radius: 9px; color: var(--success); background: color-mix(in srgb, var(--success) 8%, transparent); font-size: 12px; }
.manager-test-review-questions { display: grid; gap: 10px; }
.manager-test-review-question { padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); }
.manager-test-review-question h5 { margin: 5px 0 10px; font-size: 13px; line-height: 1.45; }
.manager-test-review-question ul { display: grid; gap: 4px; margin: 0 0 10px; padding: 0; list-style: none; }
.manager-test-review-question li { padding: 5px 8px; border-radius: 6px; color: var(--text-dim); font-size: 12px; }
.manager-test-review-question li.correct { color: var(--success); background: color-mix(in srgb, var(--success) 9%, transparent); font-weight: 650; }
.manager-test-review-meta, .manager-test-review-explanation, .manager-test-review-source { margin: 0; font-size: 11px; line-height: 1.45; }
.manager-test-review-meta { color: var(--accent); font-weight: 700; }
.manager-test-review-explanation { margin-top: 8px; }
.manager-test-review-source { margin-top: 5px; color: var(--text-dim); }
.manager-test-table-wrap { overflow-x: auto; }
.manager-test-table td:first-child, .manager-test-table th:first-child { position: static; }
.manager-test-table a { margin-right: 8px; }
.manager-test-telegram { color: var(--accent); white-space: nowrap; font-weight: 650; }
.manager-test-copy { padding: 3px 7px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 11px; }
.manager-test-reset { padding: 4px 8px; white-space: nowrap; font-size: 11px; }
@media (max-width: 700px) {
  .manager-test-campaign > header, .manager-test-review-roster { flex-direction: column; }
  .manager-test-head-actions { justify-content: flex-start; }
  .manager-test-key-approval { grid-template-columns: 1fr; }
  .manager-test-key-approval p { grid-column: 1; }
}
@media (max-width: 720px) {
  .analytics-page { padding: 12px; }
  .analytics-subtabs { width: 100%; max-width: 100%; overflow-x: auto; }
  .analytics-subtab { flex: none; padding-inline: 10px; white-space: nowrap; }
  .analytics-manager-grid { grid-template-columns: 1fr; }
  .analytics-manager-metrics { grid-template-columns: 1fr; }
  .analytics-manager-card > header { align-items: flex-start; flex-direction: column; gap: 3px; }
  .manager-test-form { grid-template-columns: 1fr; }
  .manager-test-form .task-field, .manager-test-form .analytics-speed-note { grid-column: 1 !important; }
  .nps-metrics { grid-template-columns: 1fr 1fr; }
  .nps-filters { grid-template-columns: 1fr; }
}

/* ── Вкладка CRM: kanban воронок и автоматизаций (как Digital Pipeline в amo) ── */
#crm-root { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; }
.crm-top { padding: 14px 14px 0; display: flex; flex-direction: column; gap: 12px; }
.crm-board { display: flex; gap: 10px; overflow-x: auto; padding: 14px; align-items: flex-start; }
.crm-col {
  flex: 0 0 300px; min-width: 300px;
  background: #f3f3f3; /* как .taskboard */
  border-radius: 10px; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.crm-col-win { border-top: 3px solid #2e7d32; }
.crm-col-lose { border-top: 3px solid #c62828; }
.crm-col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 2px 4px; font-size: 13px; }
.crm-col-win .crm-col-head strong { color: #2e7d32; }
.crm-col-lose .crm-col-head strong { color: #c62828; }
.crm-col-count { color: var(--text-dim); font-size: 12px; }
.crm-card { cursor: pointer; padding: 10px; }
.crm-off { opacity: .55; }
.crm-badges { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.crm-kind { width: fit-content; }
.crm-flag {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-dim);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 1px 5px; overflow-wrap: anywhere;
}
.crm-source { margin-top: 6px; font-size: 11px; color: var(--text-dim); font-family: var(--mono); overflow-wrap: anywhere; }
.crm-reactivations {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; font-size: 13px; display: flex; flex-direction: column; gap: 5px;
}
.crm-reactivation-sub { color: var(--text-dim); font-size: 11.5px; margin-top: 4px; opacity: .8; }
.crm-reactivation-row { color: var(--text-dim); font-size: 12.5px; }
.crm-add-btn { align-self: flex-start; font-size: 12.5px; padding: 5px 8px; }
.crm-stage-select { max-width: 175px; }
.crm-form input, .crm-form select, .crm-form textarea { width: 100%; }
.crm-form .task-automation-enabled input { width: auto; padding: 0; }
@media (max-width: 800px) {
  /* свайп по столбцам; низ не перекрывается #bottom-nav — отступ уже задан на #main */
  .crm-col { flex-basis: 85vw; min-width: 85vw; }
  .crm-top { padding: 12px 12px 0; }
  .crm-board { padding: 12px; }
}

/* Качество звонков / отказы / допы на странице «Аналитика» (29.08.2026) */
.analytics-quality-block { margin-top: 28px; }
.analytics-quality-block h3 { margin: 0 0 4px; font-size: 16px; }
.analytics-quality-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; display: block; overflow-x: auto; }
.analytics-quality-table th, .analytics-quality-table td { border: 1px solid #e5e7eb; padding: 6px 10px; text-align: right; white-space: nowrap; }
.analytics-quality-table thead th { background: #f6f7f9; font-weight: 600; text-align: center; position: sticky; top: 0; }
.analytics-quality-table tbody th { text-align: left; font-weight: 600; background: #fbfbfc; }
.analytics-quality-table tbody tr:nth-child(even) td { background: #fafafa; }
