:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #18231f;
  --muted: #64736d;
  --line: #e1e7e4;
  --accent: #127a64;
  --accent-ink: #ffffff;
  --accent-soft: #e3f2ee;
  --agent: #eef3f8;
  --user: #e8f4ef;
  --danger: #b4372f;
  --warn: #a86a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 6px 24px rgb(0 0 0 / 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513;
    --panel: #161e1b;
    --ink: #e6efeb;
    --muted: #8fa19a;
    --line: #26322e;
    --accent: #2fb594;
    --accent-ink: #062018;
    --accent-soft: #15302a;
    --agent: #1a242c;
    --user: #17282244;
    --danger: #e0675e;
    --warn: #e0a33a;
    --shadow: none;
  }
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--ink);
  font:
    15px / 1.5 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
}
h1,
h2,
h3 {
  margin: 0 0 12px;
  font-weight: 600;
}
h2 {
  font-size: 17px;
}
h3 {
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 18px;
}
h3 small {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  margin-left: 6px;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.brand-sub {
  font-weight: 400;
  color: var(--muted);
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-small {
  padding: 5px 11px;
  font-size: 13px;
}
.btn:focus-visible,
.tab:focus-visible,
.talk-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* вход */
.login-body {
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(380px, 100%);
}
.login-card h1 {
  font-size: 20px;
  margin: 18px 0;
}
.login-card form {
  display: grid;
  gap: 14px;
}
.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 15px;
}
.login-error {
  color: var(--danger);
  margin: 0;
}

/* каркас */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 2;
}
.tabs {
  display: none;
  gap: 4px;
}
.tab {
  background: none;
  border: 0;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
}
.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100% - 60px);
}
.pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.pane-side {
  max-height: calc(100vh - 100px);
  overflow: auto;
  position: sticky;
  top: 80px;
}

/* разговор */
.talk-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 0 8px;
}
.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 24px;
}
.talk-btn {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    transform 0.15s,
    background 0.2s;
}
.talk-btn:hover {
  transform: scale(1.03);
}
.talk-btn .icon-phone {
  width: 46px;
  height: 46px;
  fill: currentColor;
  transition: transform 0.2s;
}
.talk-btn.live {
  background: var(--danger);
}
.talk-btn.live .icon-phone {
  transform: rotate(135deg);
}
.talk-btn.busy {
  opacity: 0.6;
  cursor: progress;
}
.talk-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
}
.talk-btn.live .talk-ring {
  border-color: var(--danger);
  animation: ring 1.8s ease-out infinite;
}
@keyframes ring {
  0% {
    transform: scale(0.95);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.25);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .talk-btn.live .talk-ring {
    animation: none;
    opacity: 0.4;
  }
}
.talk-label {
  margin-top: 14px;
  font-weight: 600;
}
.talk-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.timer {
  font-variant-numeric: tabular-nums;
  min-width: 44px;
}
.meter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.meter i {
  display: inline-block;
  width: 60px;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.meter i::after {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--lvl, 0%);
  background: var(--accent);
  transition: width 0.08s;
}
.status {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.status.error {
  color: var(--danger);
}
.status.warn {
  color: var(--warn);
}
.settings {
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
}
.settings summary {
  cursor: pointer;
}
.settings label {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  min-width: 260px;
}
.settings select {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.transcript {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.transcript.live {
  max-height: 42vh;
  overflow: auto;
}
.bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
}
.bubble small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}
.bubble.user {
  align-self: flex-end;
  background: var(--user);
  border-bottom-right-radius: 4px;
}
.bubble.agent {
  align-self: flex-start;
  background: var(--agent);
  border-bottom-left-radius: 4px;
}
.bubble.marker {
  align-self: center;
  background: none;
  color: var(--muted);
  font-size: 12px;
  padding: 2px;
}
.record-view .bubble,
#record-transcript .bubble {
  cursor: pointer;
}
#record-transcript .bubble:hover {
  outline: 1px solid var(--line);
}
#record-transcript .bubble.now {
  outline: 2px solid var(--accent);
}

/* запись */
.record-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.record-title {
  font-weight: 600;
}
.record-title span {
  color: var(--muted);
  font-weight: 400;
  margin-left: 8px;
  font-size: 13px;
}
#player {
  width: 100%;
}
.timeline {
  position: relative;
  height: 22px;
  margin: 4px 0 8px;
  border-bottom: 1px dashed var(--line);
}
.timeline .mark {
  position: absolute;
  top: 3px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  padding: 0;
}
.mark.greeting {
  background: var(--accent);
}
.mark.emergency {
  background: var(--danger);
}
.mark.tool {
  background: var(--warn);
}
.mark.note {
  background: var(--ink);
  border-radius: 2px;
  transform: rotate(45deg);
  width: 10px;
  height: 10px;
}
.record-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 24px;
}

.note-form {
  display: grid;
  gap: 10px;
}
.rating {
  display: flex;
  gap: 4px;
}
.rating button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
}
.rating button.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
  cursor: pointer;
  background: var(--bg);
}
.chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.note-form textarea {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  resize: vertical;
}
.note-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.here {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.notes {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}
.notes li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
}
.notes .meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.notes .meta button {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}
.notes .t {
  color: var(--accent);
  cursor: pointer;
}
.intake {
  font-size: 14px;
}
.intake table {
  border-collapse: collapse;
  width: 100%;
}
.intake td {
  border-bottom: 1px solid var(--line);
  padding: 4px 6px;
  vertical-align: top;
}
.intake td:first-child {
  color: var(--muted);
  width: 45%;
}

/* список */
.side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.export {
  display: flex;
  gap: 6px;
}
.calls {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 6px;
}
.calls li {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  cursor: pointer;
}
.calls li:hover {
  border-color: var(--accent);
}
.calls li.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.calls .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.calls .when {
  font-weight: 600;
}
.calls .first {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.ref {
  border-color: var(--warn);
  color: var(--warn);
}
.badge.bad {
  border-color: var(--danger);
  color: var(--danger);
}
.stars {
  color: var(--warn);
  letter-spacing: 1px;
}
.empty {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 820px) {
  .tabs {
    display: flex;
  }
  .topbar {
    padding: 10px 16px;
  }
  .brand-sub {
    display: none;
  }
  .layout {
    grid-template-columns: 1fr;
    padding: 12px 16px;
    gap: 12px;
  }
  .pane {
    padding: 16px;
  }
  .pane-side {
    position: static;
    max-height: none;
  }
  body:not(.show-list) .pane-side {
    display: none;
  }
  body.show-list .pane-main {
    display: none;
  }
  .record-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .bubble {
    max-width: 92%;
  }
  .settings label {
    min-width: 0;
  }
}

/* карточки списка не шире колонки */
.pane-side {
  overflow-x: hidden;
}
.calls {
  grid-template-columns: minmax(0, 1fr);
}
.calls li {
  min-width: 0;
}

.tab {
  white-space: nowrap;
}
