/* «Позвонок» — фирменный стиль компании, токены сняты с сайта
   (127.0.0.1:8791/assets/css/site.css): малиновый #c70039, светлая тема
   по умолчанию, тёмная через prefers-color-scheme — как на сайте. */

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --border: #e4e7ec;
  --text: #14161a;
  --muted: #767e8b;

  --primary: #c70039;
  --primary-2: #ff3d6b;
  --accent: #c70039;
  --accent-soft: #fff1f4;

  --ok: #12683b;
  --ok-soft: #e8f7ee;
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.10);
  --danger: #c70039;
  --danger-soft: #fff1f4;
  --pending: #d97706;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 20, 28, 0.05), 0 8px 24px rgba(16, 20, 28, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --panel: #171c25;
    --panel-2: #151922;
    --border: #262d3a;
    --text: #eef1f6;
    --muted: #8b95a4;

    --primary: #ff3d6b;
    --primary-2: #ff6384;
    --accent: #ff3d6b;
    --accent-soft: #24121a;

    --ok: #34c77b;
    --ok-soft: rgba(52, 199, 123, 0.14);
    --info: #4b7bff;
    --info-soft: rgba(75, 123, 255, 0.14);
    --danger: #ff3d6b;
    --danger-soft: #24121a;
    --pending: #f5a623;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

/* ручное переключение темы (кнопка в шапке) — перебивает prefers-color-scheme
   независимо от системной темы; без явного выбора работает как раньше */
:root[data-theme="light"] {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --border: #e4e7ec;
  --text: #14161a;
  --muted: #767e8b;

  --primary: #c70039;
  --primary-2: #ff3d6b;
  --accent: #c70039;
  --accent-soft: #fff1f4;

  --ok: #12683b;
  --ok-soft: #e8f7ee;
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.10);
  --danger: #c70039;
  --danger-soft: #fff1f4;
  --pending: #d97706;

  --shadow: 0 1px 2px rgba(16, 20, 28, 0.05), 0 8px 24px rgba(16, 20, 28, 0.06);
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --panel: #171c25;
  --panel-2: #151922;
  --border: #262d3a;
  --text: #eef1f6;
  --muted: #8b95a4;

  --primary: #ff3d6b;
  --primary-2: #ff6384;
  --accent: #ff3d6b;
  --accent-soft: #24121a;

  --ok: #34c77b;
  --ok-soft: rgba(52, 199, 123, 0.14);
  --info: #4b7bff;
  --info-soft: rgba(75, 123, 255, 0.14);
  --danger: #ff3d6b;
  --danger-soft: #24121a;
  --pending: #f5a623;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- top nav ---------- */

.top-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 22px;
  height: 58px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.top-nav::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2), transparent 70%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  animation: cc-glow 3.5s ease-in-out infinite;
}

@keyframes cc-glow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(255, 61, 107, 0.30)); }
  50%      { filter: drop-shadow(0 0 12px rgba(255, 61, 107, 0.65)); }
}

.brand-name {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-tag {
  font-size: 12px;
  color: var(--muted);
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.tabs { display: flex; gap: 6px; }

.tab-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover { background: var(--accent-soft); color: var(--text); }
.tab-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* ---------- layout ---------- */

.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; flex-direction: column; }

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 26px 32px 40px;
}

.layout { display: flex; flex: 1; min-height: 0; }

.list-pane {
  width: 420px;
  min-width: 320px;
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-pane h1 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 18px 18px 10px;
  margin: 0;
}

.calls-list { overflow-y: auto; flex: 1 1 auto; min-height: 0; }

/* ---------- list rows ---------- */

.call-row {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.call-row:hover { background: var(--accent-soft); }
.call-row.active { background: var(--accent-soft); border-left-color: var(--accent); }

.call-row .top-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.call-row .phone { font-weight: 650; font-size: 14px; letter-spacing: -0.01em; }

.call-row .datetime { font-size: 12px; color: var(--muted); white-space: nowrap; }

.call-row .meta-line {
  margin-top: 5px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
}

.badge.out { background: var(--ok-soft); color: var(--ok); }
.badge.external { background: var(--info-soft); color: var(--info); }
.badge.other { background: var(--accent-soft); color: var(--muted); }
.badge.flag { background: var(--danger-soft); color: var(--danger); }

/* ---------- status dots ---------- */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--border);
}
.status-dot.done { background: var(--ok); }
.status-dot.error { background: var(--danger); }
.status-dot.pending { background: var(--pending); animation: cc-pulse 1.2s ease-out infinite; }
.status-dot.analysis.done { background: var(--primary-2); }

@keyframes cc-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.45); }
  100% { box-shadow: 0 0 0 7px rgba(245, 166, 35, 0); }
}

/* ---------- detail pane ---------- */

.detail-pane { flex: 1; padding: 28px 36px; overflow-y: auto; }

.empty-state { color: var(--muted); font-size: 14px; margin-top: 48px; text-align: center; }

.detail-header h2, .detail-pane > h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.detail-header .sub, .detail-pane > .sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
}

audio { width: 100%; margin: 14px 0 22px; accent-color: var(--accent); }

/* ---------- boxes & cards ---------- */

.transcript-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  min-height: 120px;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 14px;
  margin-bottom: 20px;
}

.transcript-box.pending { color: var(--muted); font-style: italic; }
.transcript-box.error { color: var(--danger); }

/* транскрипт диалогом (диаризация, docs/architecture.md 5.2) */
.dialog-turn {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 3px solid var(--border);
}

.dialog-turn.operator { border-left-color: var(--accent); }
.dialog-turn.client { border-left-color: var(--info); }

.dialog-speaker {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.dialog-turn.operator .dialog-speaker { color: var(--accent); }
.dialog-turn.client .dialog-speaker { color: var(--info); }

.dialog-text { flex: 1; }

.analysis-box { min-height: 60px; white-space: pre-wrap; line-height: 1.55; font-size: 14px; }

.analysis-box.pending { color: var(--muted); font-style: italic; }
.analysis-box.error {
  color: var(--danger);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 900px) {
  .analysis-grid { grid-template-columns: 1fr; }
}

.analysis-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.analysis-card h3 { margin: 0 0 14px; font-size: 14px; font-weight: 700; }

.analysis-card h4 {
  margin: 16px 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.analysis-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 14px;
}

.analysis-card dt { font-size: 12px; color: var(--muted); white-space: nowrap; }
.analysis-card dd { margin: 0; font-size: 13px; line-height: 1.45; }

.handling-summary { margin: 0; font-size: 13px; line-height: 1.5; }

.analysis-card ul { margin: 0; padding-left: 18px; font-size: 13px; }
.analysis-card ul li { margin-bottom: 5px; line-height: 1.45; }
.analysis-card ul li.muted {
  color: var(--muted);
  list-style: none;
  margin-left: -18px;
  font-style: italic;
}

.flags-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ---------- buttons ---------- */

button.transcribe-btn {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px -6px rgba(199, 0, 57, 0.55);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
}

button.analyze-btn { margin-left: 8px; }

button.transcribe-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px -8px rgba(255, 61, 107, 0.7);
}

button.transcribe-btn:disabled { opacity: 0.55; cursor: default; }

/* ---------- dashboard ---------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2), transparent);
  opacity: 0.9;
}

.metric-value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.metric-label { margin-top: 7px; font-size: 13px; color: var(--muted); }
.metric-sub { margin-top: 4px; font-size: 12px; color: var(--muted); }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr; }
}

.dash-card { min-height: 120px; }

/* horizontal bars */

.hbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.hbar-label {
  width: 120px;
  min-width: 90px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hbar-track {
  flex: 1;
  height: 12px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.hbar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 0.4s ease;
}

.hbar-value {
  width: 28px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
}

/* donut */

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.donut {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}

.donut-hole {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
}

.legend { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: 0 0 auto;
}

/* problem calls feed */

.problem-row {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.problem-row:hover { background: var(--accent-soft); border-color: var(--accent); }

.problem-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.problem-phone { font-weight: 650; font-size: 13px; }
.problem-op { font-size: 12px; color: var(--muted); white-space: nowrap; }

.problem-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* operators table */

.op-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.op-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.op-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}

.op-table tbody tr:last-child td { border-bottom: none; }
.op-table tbody tr:hover { background: var(--accent-soft); }

/* ---------- tasks ---------- */

.tasks-wrap { margin-top: 22px; }
.tasks-wrap h3 { font-size: 14px; font-weight: 700; margin: 0 0 10px; }

.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  transition: opacity 0.15s;
}

.task-row input[type="checkbox"] { accent-color: var(--accent); }
.task-row.done { opacity: 0.6; }
.task-row.done .task-desc { text-decoration: line-through; color: var(--muted); }

.task-desc { flex: 1; line-height: 1.45; }
.task-call-ref { color: var(--muted); font-size: 12px; white-space: nowrap; }

.muted { color: var(--muted); font-style: italic; }

/* ---------- scrollbars ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }

/* ---------- фильтр списка звонков + кликабельные элементы дашборда
   (architecture.md, Frontend #1 п.3а/3б) ---------- */

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 18px 8px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}

.filter-label { color: var(--accent); font-weight: 650; }

.filter-clear {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.filter-clear:hover { color: var(--text); }

.clickable { cursor: pointer; }
.badge.flag.clickable:hover { filter: brightness(1.12); text-decoration: underline; }
.legend-item.clickable:hover { color: var(--accent); }
.task-row.clickable:hover { background: var(--accent-soft); border-radius: 8px; }

/* ---------- «Проблемные звонки»: свёрнутый список + разворот ---------- */

.problem-list.collapsed {
  max-height: 340px;
  overflow: hidden;
  position: relative;
}

.problem-list.collapsed::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 44px;
  background: linear-gradient(to bottom, transparent, var(--panel));
  pointer-events: none;
}

.collapse-toggle {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 7px 12px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
}
.collapse-toggle:hover { background: var(--accent-soft); }

/* ---------- загрузка записей + пакетный прогон (architecture.md 4 п.2) ---------- */

.upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.upload-row input[type="file"] {
  flex: 1;
  min-width: 220px;
  font-size: 13px;
  color: var(--muted);
}

.upload-status { margin-top: 10px; font-size: 13px; }

/* ---------- выбор оператора в таблице дашборда (architecture.md 4 п.2) ---------- */

.op-table tbody tr.clickable:hover { background: var(--accent-soft); }
.op-table tbody tr.selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ---------- прогресс загрузки записей (architecture.md 4 п.2) ---------- */

.upload-hint { font-size: 12px; margin-bottom: 10px; }

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 4px 0 10px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 0.2s ease;
}

/* ---------- playbook (architecture.md 5.1а) ---------- */

.playbook-box {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

/* ---------- чеклист оператора (architecture.md 5.1, Блок B) ---------- */

.checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  padding: 12px;
  background: var(--panel-2);
  border-radius: var(--radius);
}

.checklist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.checklist-label { color: var(--muted); }

.checklist-badge.positive { background: var(--ok-soft); color: var(--ok); }
.checklist-badge.negative { background: var(--danger-soft); color: var(--danger); }
.checklist-badge.neutral { background: var(--accent-soft); color: var(--muted); }

/* ---------- страница логина (architecture.md, раздел 8) ---------- */

.login-card {
  width: 320px;
  margin: 10vh auto;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.login-card .logo { width: 48px; height: 48px; border-radius: 12px; }

.login-input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ---------- переключатель темы ---------- */

.theme-toggle {
  margin-left: auto;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--accent-soft); }

/* ---------- таблица операторов: разбивка по чеклисту, полная ширина ---------- */

.op-table-card { width: 100%; overflow-x: auto; }

.tri-wrap { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tri { font-weight: 650; }
.tri.positive { color: var(--ok); }
.tri.negative { color: var(--danger); }
.tri.neutral { color: var(--muted); }
.tri.clickable { cursor: pointer; border-radius: 4px; padding: 0 2px; }
.tri.clickable:hover { text-decoration: underline; background: var(--accent-soft); }

/* ---------- говорил/слушал + тишина (architecture.md 5.2а) ---------- */

.talk-ratio-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 8px;
  background: var(--panel-2);
}

.talk-ratio-seg { height: 100%; }
.talk-ratio-seg.operator { background: var(--accent); }
.talk-ratio-seg.client { background: var(--info); }
.talk-ratio-seg.silence { background: var(--border); }
.talk-ratio-seg.wait-operator { background: var(--pending); }
.talk-ratio-seg.wait-client { background: var(--muted); }
.talk-ratio-seg.silence-other { background: var(--border); }
.talk-ratio-seg.unknown { background: var(--pending); }

.talk-ratio-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.talk-ratio-legend-item::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.talk-ratio-legend-item.operator::before { background: var(--accent); }
.talk-ratio-legend-item.client::before { background: var(--info); }
.talk-ratio-legend-item.silence::before { background: var(--border); }
.talk-ratio-legend-item.wait-operator::before { background: var(--pending); }
.talk-ratio-legend-item.wait-client::before { background: var(--muted); }
.talk-ratio-legend-item.silence-other::before { background: var(--border); }
.talk-ratio-legend-item.unknown::before { background: var(--pending); }

.talk-ratio-disclaimer {
  font-size: 11px;
  color: var(--muted);
  margin: -4px 0 16px;
}

/* ---------- админ-вкладка и кнопки рабочей версии (backend.md, стройка 2026-08-02) ---------- */
.btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  margin-left: 8px;
  white-space: nowrap;
}
.btn:hover { background: var(--accent); color: #fff; }
/* выбранный период на графиках статуса моделей (model_health.md 3) */
.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.login-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  width: 100%;
}
#view-switcher, #imp-switcher {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  max-width: 230px;
}
#view-switcher option, #imp-switcher option {
  background: var(--panel);
  color: var(--text);
}

/* ---------- «Обзор» по клиникам: карточки (multitenant.md 7в) ---------- */
.ov-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.ov-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.ov-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 8px;
}
.ov-name { font-size: 16px; font-weight: 700; }
.badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-active { background: rgba(52, 199, 123, 0.15); color: #2aa568; }
.badge-trial { background: rgba(230, 161, 23, 0.15); color: #c98d10; }
.ov-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.ov-stat {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}
.ov-stat b { display: block; font-size: 17px; margin-bottom: 2px; }
.ov-stat span { font-size: 11px; color: var(--muted); }
.ov-sys {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-2);
}


.ov-debug {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

/* «Идёт обработка» — наглядность прогона в Лаборатории (user feedback 2026-08-02) */
.btn-running {
  opacity: 0.75;
  cursor: progress;
  animation: cc-pulse-bg 1.2s ease-in-out infinite;
}
@keyframes cc-pulse-bg {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary, var(--accent)); }
  50% { box-shadow: 0 0 0 4px transparent; }
}

/* Звонок без разбивки на роли (architecture.md 5.2к) — заметно, но не тревожно:
   это не ошибка обработки, разбор оператора всё равно сделан по тексту */
.roles-warning {
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--pending, var(--border));
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

/* Пункт чеклиста с приблизительной оценкой (playbook/analysis.md) */
.checklist-approx { color: var(--muted); cursor: help; font-weight: 600; }

/* Панель сортировки и фильтров списка звонков — кнопки, не выпадающие списки */
.calls-controls {
  padding: 0 18px;
  margin-bottom: 10px;
  flex: 0 0 auto;
  max-height: 42vh;
  overflow-y: auto;
}
.ctl-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
.ctl-caption {
  font-size: 11px;
  color: var(--muted);
  min-width: 92px;
  flex-shrink: 0;
}
.chip-btn {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.chip-btn:hover { color: var(--text); border-color: var(--primary); }
.chip-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
/* тон по смыслу: зелёное — пациент остался, красное — потеря, серое — факт */
.chip-btn.tone-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.chip-btn.tone-problem { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.chip-btn.tone-ok.active { background: var(--ok); border-color: var(--ok); color: #fff; }
.chip-btn.tone-problem.active { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctl-slider { flex: 1; max-width: 260px; accent-color: var(--primary); }

/* Теги качества по смыслу — те же цвета, что и кнопки фильтра */
.badge.flag.tone-ok { background: var(--ok-soft); color: var(--ok); }
.badge.flag.tone-problem { background: var(--danger-soft); color: var(--danger); }

/* Компактные выпадающие списки в панели звонков (сортировка, оператор) */
.ctl-select {
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 11px;
  max-width: 150px;
}
.ctl-select option { background: var(--panel); color: var(--text); }

/* Календарь: видно, сколько звонков в каждый день под текущими фильтрами */
.calendar-pop {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 8px;
  margin-bottom: 6px;
}
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: capitalize;
}
.calendar-nav {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  padding: 0 6px;
}
.calendar-nav:disabled { opacity: 0.3; cursor: default; }
.calendar-nav:not(:disabled):hover { color: var(--primary); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-wd {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  padding-bottom: 2px;
}
.calendar-day {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}
.calendar-day:hover:not(:disabled) { border-color: var(--primary); }
.calendar-day.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.calendar-day.empty { background: transparent; color: var(--muted); opacity: 0.35; cursor: default; }
.calendar-num { font-size: 11px; }
.calendar-count { font-size: 9px; color: var(--primary); font-weight: 700; }
.calendar-day.active .calendar-count { color: #fff; }

/* «Сколько работы сделал ИИ» — панель в карточке причин (4.6) */
.reasons-row { display: flex; gap: 24px; align-items: stretch; flex-wrap: wrap; }
.reasons-donut-box { flex: 1 1 340px; min-width: 280px; }
.work-side {
  flex: 0 1 320px;
  min-width: 260px;
  background: var(--panel-2);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.work-side h4 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.work-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.work-cell b { display: block; font-size: 22px; line-height: 1.15; color: var(--primary); }
.work-cell span { font-size: 11px; color: var(--muted); }

.work-tok-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.work-tok-head span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.work-tok-head b { font-size: 18px; color: var(--text); }

.work-bar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel);
}
.work-seg { display: block; height: 100%; min-width: 3px; }
.work-seg.in { background: var(--primary); }
.work-seg.out { background: var(--ok); }
.work-legend { display: flex; gap: 16px; font-size: 11px; }
.work-leg { display: inline-flex; align-items: center; gap: 5px; }
.work-leg::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.work-leg.in { color: var(--primary); }
.work-leg.out { color: var(--ok); }
.work-per { font-size: 12px; color: var(--text); }
.work-note { font-size: 11px; margin: 0; }

/* Подвал списка: сколько показано и догрузка следующей страницы (4.7) */
.list-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px 20px;
  font-size: 11px;
  color: var(--muted);
}

/* Второстепенные кнопки цикла черновика (multitenant.md 7к) */
.btn.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn.secondary:hover { color: var(--text); border-color: var(--primary); background: transparent; }

/* Обращения по направлениям (architecture.md 4.10) */
.cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  cursor: pointer;
}
.cat-row:hover .cat-label { color: var(--primary); }
.cat-label { flex: 0 0 170px; font-size: 12px; }
.cat-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}
.cat-fill { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.cat-count { flex: 0 0 34px; text-align: right; font-size: 12px; font-weight: 700; }

/* Флаги качества полосами: цвет заливки по тону тега (словарь клиники, 4.9) */
.cat-fill.tone-problem { background: var(--danger); }
.cat-fill.tone-ok { background: var(--ok); }
.cat-fill.tone-neutral { background: var(--muted); }

/* Длительность сверх лимита клиники (ТЗ заказчика, architecture.md 4.11) */
.dur-over { color: var(--danger); font-weight: 700; }

/* Нулевые теги и направления: видны, но приглушены — ноль тоже результат */
.cat-row.zero .cat-label, .cat-row.zero .cat-count { color: var(--muted); opacity: 0.65; }


/* ======================================================================
   ДИЗАЙН-СИСТЕМА v2 (2026-08-09) — компонентный слой поверх токенов выше.
   Документация: docs/ui_style.md. Принципы: лаконично, воздух, скругления,
   мягкие слоистые тени, пилюли для действий, малиновый — только для
   акцентов. Цветовые токены НЕ трогаем — обе темы работают как раньше.
   ====================================================================== */

:root {
  /* типографика: Manrope — текст, Syne — заголовки/цифры-акценты */
  --font: "Manrope", "Inter", system-ui, -apple-system, sans-serif;
  --display: "Syne", "Manrope", "Inter", sans-serif;
  /* скругления: карточки 16, контролы 12, пилюли 999 */
  --radius: 16px;
  --radius-ctl: 12px;
  /* слоистая тень карточек (в тёмной теме глубже — см. ниже) */
  --shadow-card: 0 1px 2px rgba(16, 20, 28, 0.05), 0 12px 40px rgba(16, 20, 28, 0.08);
  --ring: 0 0 0 3px rgba(199, 0, 57, 0.15);
}
@media (prefers-color-scheme: dark) {
  :root { --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.45), 0 12px 40px rgba(0, 0, 0, 0.4);
          --ring: 0 0 0 3px rgba(255, 61, 107, 0.22); }
}
:root[data-theme="dark"] { --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.45), 0 12px 40px rgba(0, 0, 0, 0.4);
                           --ring: 0 0 0 3px rgba(255, 61, 107, 0.22); }
:root[data-theme="light"] { --shadow-card: 0 1px 2px rgba(16, 20, 28, 0.05), 0 12px 40px rgba(16, 20, 28, 0.08);
                            --ring: 0 0 0 3px rgba(199, 0, 57, 0.15); }

/* --- фон и типографика ------------------------------------------------ */
body {
  font-family: var(--font);
  /* лёгкое малиновое свечение сверху — фирменная нота, не мешает контенту */
  background:
    radial-gradient(1100px 520px at 12% -12%, rgba(199, 0, 57, 0.07), transparent 55%),
    radial-gradient(800px 420px at 100% 0%, rgba(199, 0, 57, 0.04), transparent 50%),
    var(--bg);
  background-attachment: fixed;
}
:root[data-theme="dark"] body,
:root:not([data-theme="light"]) body { background-attachment: fixed; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body {
    background:
      radial-gradient(1100px 520px at 12% -12%, rgba(255, 61, 107, 0.06), transparent 55%),
      var(--bg);
    background-attachment: fixed;
  }
}
/* Display-шрифт (Syne) — только у самых крупных акцентов: заголовок страницы
   и логотип. У h2/h3 стилизованные цифры Syne читаются плохо («Оператор 203»
   выглядел сломанным, user feedback 2026-08-09) — им обычный текстовый. */
/* Кузня и Чаты: воздуха больше — экраны плотные, а работать в них долго
   (user feedback 2026-08-11 «чтобы не зажато было») */
.chat-ui .page-content { padding: 22px 30px 44px; }
.chat-ui .detail-card { padding: 1.3rem 1.4rem; }
.chat-ui .chat-sec { margin: 18px 4px 8px; }
.chat-ui textarea { padding: 10px 12px; }

h1, .brand-name {
  font-family: var(--display);
  letter-spacing: -0.02em;
  font-weight: 700;
}
h2, h3 {
  font-family: var(--font);
  letter-spacing: -0.01em;
  font-weight: 700;
}

/* --- кнопки: пилюли, мягкий подъём ------------------------------------ */
button {
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease,
              background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
button:hover { transform: translateY(-1px); border-color: var(--muted); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
button.active, .tab-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
/* главное действие страницы (submit форм) — малиновая пилюля с мягкой тенью */
button[type="submit"], .btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 8px 24px rgba(199, 0, 57, 0.25);
}
button[type="submit"]:hover, .btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); }

/* --- поля ввода: спокойная рамка, малиновое фокус-кольцо --------------- */
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctl);
  padding: 0.55rem 0.8rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }

/* --- карточки ---------------------------------------------------------- */
.detail-card, .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.15rem 1.25rem;
}
.detail-card + .detail-card { margin-top: 1rem; }

/* --- таблицы: заголовки капителью ------------------------------------- */
th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
th, td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border); }

/* --- чипы статусов (тон задаётся токенами тем) ------------------------- */
.chip {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  vertical-align: middle;
}
.chip.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.chip.warn { color: var(--pending); background: rgba(217, 119, 6, 0.12); border-color: transparent; }
.chip.rose { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* --- появление контента ------------------------------------------------ */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view.active { animation: rise 0.4s ease both; }
.detail-card { animation: rise 0.45s ease both; }

/* --- доступность ------------------------------------------------------- */
:focus-visible { outline: none; box-shadow: var(--ring); }
@media (prefers-reduced-motion: reduce) {
  .view.active, .detail-card { animation: none; }
  button, button:hover { transition: none; transform: none; }
}
