:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --user-bg: #1e3a5f;
  --ai-bg: #1a2e1a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

nav {
  margin-top: 0.75rem;
}

nav a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

nav a:hover {
  text-decoration: underline;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.call-status {
  font-size: 1.05rem;
  margin-bottom: 1rem;
  min-height: 1.5em;
}

.call-status.connected {
  color: var(--success);
}

.call-status.error {
  color: var(--danger);
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.caller-id-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text);
}

.caller-id-field .optional {
  color: var(--muted);
  font-weight: normal;
}

.caller-id-field input {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.hint {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.transcript {
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.transcript-line {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.95rem;
}

.transcript-line.user {
  background: var(--user-bg);
  align-self: flex-end;
  max-width: 85%;
}

.transcript-line.assistant {
  background: var(--ai-bg);
  align-self: flex-start;
  max-width: 85%;
}

.transcript-line .role {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.transcript-line.system {
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  align-self: center;
}

.saved-lead {
  margin: 0;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.lead-count {
  color: var(--muted);
  font-size: 0.9rem;
}

.error-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.leads-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lead-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  background: var(--bg);
}

.lead-card header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.lead-card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-new { background: #1e40af; color: #bfdbfe; }
.badge-called_back { background: #713f12; color: #fde68a; }
.badge-booked { background: #14532d; color: #bbf7d0; }
.badge-closed { background: #374151; color: #d1d5db; }

.badge-urgency {
  background: #4c1d95;
  color: #ddd6fe;
}

.badge-urgency.emergency,
.badge-urgency.urgent {
  background: #7f1d1d;
  color: #fecaca;
}

.lead-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.lead-meta dt {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lead-meta dd {
  margin: 0.15rem 0 0;
}

.lead-transcript {
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
}

.lead-actions {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.lead-actions select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}
