:root {
  --bg: #0b0c10;
  --surface: #13151b;
  --surface-2: #1b1e27;
  --field: #0e1015;
  --border: #262a36;
  --border-strong: #3a4052;
  --text: #f2f3f7;
  --muted: #9096a6;
  --primary: #7c6cff;
  --primary-2: #a78bfa;
  --primary-ink: #ffffff;
  --glow: rgba(124, 108, 255, 0.22);
  --danger: #ff6b6b;
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Public Sans", system-ui, sans-serif;
  font-size: 15px;
}

body {
  background:
    radial-gradient(900px 480px at 50% -220px, var(--glow), transparent 70%)
    fixed,
    var(--bg);
}

button, input, textarea, select { font: inherit; color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  background: rgba(11, 12, 16, 0.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.2px;
}

.mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--primary-ink);
  font-size: 15px;
  box-shadow: 0 6px 18px var(--glow);
}

.tabs {
  display: flex;
  gap: 4px;
  margin: 0 auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.tab.active { color: var(--text); background: var(--surface-2); }

.count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.count:empty { display: none; }

.tab.active .count { background: var(--primary); color: var(--primary-ink); }

main { max-width: 1040px; margin: 0 auto; padding: 32px 20px 80px; }

.hidden { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

.card h2 { margin: 0 0 6px; font-size: 19px; }

.section-title {
  margin: 30px 0 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}

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

.small { font-size: 13px; line-height: 1.5; }

textarea, input, select {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea { resize: vertical; margin: 12px 0; }

textarea:focus, input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--glow);
}

::placeholder { color: #5d6373; }

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

.row > input { flex: 1; min-width: 180px; }

.primary, .ghost, .danger {
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
}

.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--primary-ink);
  box-shadow: 0 6px 18px var(--glow);
}

.primary:hover:not(:disabled) { filter: brightness(1.1); }

.ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.ghost:hover:not(:disabled) { border-color: var(--border-strong); }

.danger { background: none; color: var(--danger); }

.danger:hover:not(:disabled) { background: rgba(255, 107, 107, 0.12); }

button:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.link:hover, .tab:hover { color: var(--text); }

.list { display: grid; gap: 12px; margin-top: 14px; }

.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  transition: border-color 0.15s;
}

.item:hover { border-color: var(--border-strong); }

.avatar {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--primary-2);
  font-weight: 700;
  font-size: 17px;
}

.item-main { min-width: 0; flex: 1; }

.item-title { font-weight: 600; overflow-wrap: anywhere; }

.item-title .badge { margin: 0 0 0 10px; vertical-align: 1px; }

.item-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: capitalize;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(144, 150, 166, 0.14);
  color: var(--muted);
  margin-right: 8px;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.ready, .badge.booked, .badge.completed {
  color: var(--ok);
  background: rgba(52, 211, 153, 0.13);
}

.badge.failed, .badge.cancelled, .badge.not_interested {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.13);
}

.badge.crawling, .badge.extracting, .badge.indexing, .badge.queued,
.badge.interested {
  color: var(--warn);
  background: rgba(251, 191, 36, 0.13);
}

.badge.crawling::before, .badge.extracting::before,
.badge.indexing::before, .badge.queued::before {
  animation: blink 1.1s ease-in-out infinite;
}

@keyframes blink { 50% { opacity: 0.25; } }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(5, 6, 9, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px;
  overflow-y: auto;
}

.modal-card {
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.modal-card h2 { margin-top: 0; }

.modal-card h3 {
  margin: 24px 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--primary-2);
}

.modal-card p { line-height: 1.55; }

.modal-card ul { margin: 0; padding-left: 18px; line-height: 1.6; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.field { margin-top: 14px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.callview {
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    radial-gradient(900px 480px at 50% -220px, var(--glow), transparent 70%),
    var(--bg);
  display: flex;
  flex-direction: column;
}

.call-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}

.call-title { font-weight: 700; font-size: 17px; margin-bottom: 4px; }

.call-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: 0;
}

.transcript {
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.line.agent {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  align-self: flex-start;
}

.line.caller {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--primary-ink);
  border-bottom-right-radius: 5px;
  align-self: flex-end;
}

.captured {
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 24px;
  overflow-y: auto;
}

.captured h3 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--primary-2);
}

.captured dl { margin: 0; }

.captured dt { color: var(--muted); font-size: 12px; margin-top: 16px; }

.captured dd { margin: 4px 0 0; font-weight: 600; overflow-wrap: anywhere; }

.state { font-size: 12px; font-weight: 600; }
.state.ok { color: var(--ok); }
.state.pending { color: var(--warn); }

.pulse {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 8px;
}

.pulse.speaking {
  background: var(--primary-2);
  box-shadow: 0 0 12px var(--primary);
  animation: blink 0.9s ease-in-out infinite;
}

.pulse.listening { background: var(--ok); }
.pulse.thinking { background: var(--warn); }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card { width: 380px; max-width: 100%; }

.login-card .brand { margin-bottom: 18px; }

.login-card .primary { width: 100%; margin-top: 20px; padding: 11px 16px; }

.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-top: 10px;
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .brand { flex: 1; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .tab { flex: 1; justify-content: center; padding: 7px 8px; }
  .actions { width: 100%; }
  .call-head { padding: 14px 16px; }
  .call-body { grid-template-columns: 1fr; }
  .captured { border-left: none; border-top: 1px solid var(--border); }
  .line { max-width: 92%; }
}
