/* AI Dialer cabinet — кабинет клиента и админка (vanilla, без сборки) */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #2b2f33;
  --muted: #8a9299;
  --accent: #3398cc;
  --accent-dark: #2a7fae;
  --green: #35b26f;
  --red: #e2574c;
  --amber: #e8a13c;
  --border: #dfe4e8;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PT Sans", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
#app { max-width: 1024px; margin: 0 auto; padding: 16px; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.topbar__brand { font-size: 20px; font-weight: 700; }
.topbar__nav { display: flex; gap: 4px; }
.topbar__user { font-size: 13px; color: var(--muted); margin-left: auto; }
.navbtn {
  background: transparent; border: none; border-bottom: 3px solid transparent;
  padding: 8px 14px; font-size: 14px; cursor: pointer; color: var(--muted);
}
.navbtn:hover { color: var(--text); }
.navbtn--active { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 700; }

.banner {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px;
}
.banner--ok { background: #e2f6ea; color: #1e7e44; border: 1px solid #bfe8cf; }
.banner--error { background: #fde7e5; color: #a33327; border: 1px solid #f5c6c1; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 18px; }
.panel h3 { margin: 18px 0 8px; font-size: 15px; }

.tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.tab {
  background: #eef1f4; border: none; border-radius: 4px;
  padding: 8px 18px; font-size: 14px; cursor: pointer; color: var(--muted);
}
.tab--active { background: var(--accent); color: #fff; font-weight: 700; }

label { display: block; margin: 12px 0 4px; font-weight: 700; font-size: 13px; }
select, input[type="text"], input[type="password"], input[type="number"], textarea {
  width: 100%; max-width: 520px;
  padding: 8px 10px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 14px; background: #fff; color: var(--text);
  font-family: inherit;
}
textarea { resize: vertical; }
select:disabled { background: #f0f2f4; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.hint code { background: #eef1f4; padding: 1px 5px; border-radius: 3px; }

.row { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.row--spread { justify-content: space-between; }

.btn {
  padding: 9px 18px; border: none; border-radius: 4px;
  background: var(--accent); color: #fff; font-size: 14px; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn--primary { font-size: 15px; padding: 11px 24px; }
.btn--ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn--ghost:hover { background: #eef6fb; }
.btn--danger { background: var(--red); }
.btn--danger:hover { background: #c74338; }
.btn--sm { padding: 6px 12px; font-size: 13px; }

.msg { min-height: 1.2em; margin: 10px 0 0; }
.msg--error { color: var(--red); }
.msg--ok { color: var(--green); }

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 4px; }
.stat {
  background: #f7f9fb; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 16px; min-width: 120px;
}
.stat__value { font-size: 22px; font-weight: 700; }
.stat__label { font-size: 12px; color: var(--muted); }

.calls { width: 100%; border-collapse: collapse; margin-top: 4px; }
.calls th, .calls td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.calls th { font-size: 12px; color: var(--muted); text-transform: uppercase; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge--queued      { background: #eef1f4; color: #5b636b; }
.badge--dialing     { background: #fff3dd; color: #a86e12; }
.badge--answered,
.badge--in_dialog   { background: #ddf3ff; color: #1f6f9e; }
.badge--transferring{ background: #f3e6ff; color: #6a3fb5; }
.badge--done        { background: #e2f6ea; color: #1e7e44; }
.badge--failed      { background: #fde7e5; color: #a33327; }
.badge--ok          { background: #e2f6ea; color: #1e7e44; }
.badge--bad         { background: #fde7e5; color: #a33327; }

.btn--danger { background: #d64541; color: #fff; border-color: #d64541; }
.btn--danger:hover { background: #b83a36; }

/* Суперадмин: столбчатая диаграмма токенов по дням */
.bars { display: flex; align-items: flex-end; gap: 4px; padding: 8px 0; min-height: 90px; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bar__fill { width: 18px; background: var(--primary, #2f7fe0); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar__label { font-size: 10px; color: var(--muted); margin-top: 4px; transform: rotate(-45deg); }

.campaign-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.campaign-item__name { font-weight: 700; }
.campaign-item__meta { color: var(--muted); font-size: 12px; }
.campaign-item__actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.footer { display: flex; align-items: center; gap: 8px; padding: 8px 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot--ok { background: var(--green); }
.dot--bad { background: var(--red); }
.muted { color: var(--muted); }

/* Модалка деталей звонка */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 40px 16px;
}
.modal[hidden] { display: none; }
.modal__box {
  background: var(--panel); border-radius: var(--radius);
  max-width: 640px; width: 100%; max-height: 80vh; overflow: auto;
  padding: 20px 24px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}
.transcript { margin-top: 12px; }
.transcript__row { margin: 8px 0; padding: 8px 12px; border-radius: 8px; }
.transcript__row--ai { background: #eef6fb; }
.transcript__row--client { background: #f3f1ec; }
.transcript__who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.eventlog { font-size: 12px; color: var(--muted); }
.eventlog li { margin: 2px 0; }

/* Редактор сценариев */
.rule {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px; background: #fafbfc;
}
.rule__head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.rule__num {
  font-weight: 700; color: var(--accent-dark);
  background: #e4f1f9; border-radius: 50%;
  width: 26px; height: 26px; display: inline-flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.rule__title { flex: 1; }
.rule label { display: block; margin: 6px 0; font-size: 13px; }
.rule input[type="text"], .rule textarea, .rule select {
  width: 100%; padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 4px; font-family: inherit;
}
.rule textarea { resize: vertical; }
.rule__row { display: flex; gap: 8px; flex-wrap: wrap; }
.rule__row > label { flex: 1; min-width: 160px; }
.calls tbody tr[data-callid] { cursor: pointer; }
.calls tbody tr[data-callid]:hover { background: #f6f9fb; }
