:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f9;
  color: #111827;
  --line: #d9e0ea;
  --muted: #5b6778;
  --primary: #155eef;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.topbar h1,
.topbar p,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 21px;
  line-height: 1.2;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.status {
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.status[data-tone="ok"] {
  background: #e7f8ee;
  border-color: #abefc6;
  color: #067647;
}

.status[data-tone="busy"] {
  background: #eff8ff;
  border-color: #b2ddff;
  color: #175cd3;
}

.status[data-tone="error"],
.status[data-tone="warn"] {
  background: #fff4ed;
  border-color: #f9dbaf;
  color: #b93815;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(420px, 1fr);
  gap: 16px;
  padding: 16px;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px 0;
  background: #f4f6f9;
}

.tabs button {
  min-height: 34px;
  border-radius: 6px 6px 0 0;
  background: #ffffff;
}

.tabs button.active {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 800;
}

.history-view {
  padding: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.panel h2 {
  margin-bottom: 14px;
  font-size: 16px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: #101828;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  border-color: #9fb2cc;
  background: #f8fafc;
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

button.danger {
  border-color: #f4c7c2;
  color: var(--danger);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.note {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.active-call {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 12px;
  margin-bottom: 12px;
}

.phone-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.phone-actions .danger {
  grid-column: 1 / -1;
}

#remoteAudio {
  width: 100%;
  margin-top: 12px;
}

.phone-chat {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.flow-tree {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
}

.flow-tree li {
  position: relative;
  min-height: 34px;
  padding: 0 0 12px 28px;
  color: var(--muted);
  font-size: 13px;
}

.flow-tree li::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
}

.flow-tree li::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 17px;
  bottom: 0;
  width: 1px;
  background: #d9e0ea;
}

.flow-tree li:last-child {
  padding-bottom: 0;
}

.flow-tree li:last-child::after {
  display: none;
}

.flow-tree li[data-state="done"] {
  color: #067647;
}

.flow-tree li[data-state="done"]::before {
  border-color: #12b76a;
  background: #12b76a;
}

.flow-tree li[data-state="active"] {
  color: #175cd3;
  font-weight: 700;
}

.flow-tree li[data-state="active"]::before {
  border-color: #175cd3;
  background: #eff8ff;
}

.history-panel summary {
  cursor: pointer;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.call-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  overflow: hidden;
}

.call-list li {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid #e6ebf2;
}

.call-list li:last-child {
  border-bottom: 0;
}

.call-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.call-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge[data-status="ringing"],
.badge[data-status="dialing"],
.badge[data-status="starting"],
.badge[data-status="hangup-requested"] {
  border-color: #b2ddff;
  background: #eff8ff;
  color: #175cd3;
}

.badge[data-status="closed"] {
  border-color: #e6ebf2;
  background: #f2f4f7;
  color: #667085;
}

.call-meta {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 13px;
}

.call-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
  }
}
