:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --border: #334155;
}

* { box-sizing: border-box; }

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

header {
  margin-bottom: 24px;
}

header h1 { margin: 0; font-size: 1.75rem; }
header p { margin: 6px 0 0; color: var(--muted); }

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--border);
}
.status-badge.online { background: var(--accent); color: #052e16; }
.status-badge.offline { background: #64748b; }
.status-badge.connecting { background: #f59e0b; color: #451a03; }
.status-badge.error { background: var(--danger); color: white; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.panel h2 { margin-top: 0; font-size: 1.25rem; }

input, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1220;
  color: var(--text);
  font-size: 1.1rem;
}

textarea { min-height: 70px; resize: vertical; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  transition: background 0.15s;
}

.primary { background: var(--accent); color: #052e16; font-weight: 600; }
.primary:hover { background: var(--accent-dark); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary { background: var(--border); color: var(--text); }
.secondary:hover { background: #475569; }
.secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.danger { background: var(--danger); color: white; }
.danger:hover { background: var(--danger-dark); }
.danger:disabled { opacity: 0.5; cursor: not-allowed; }

button.big { padding: 14px 28px; font-size: 1.1rem; }
button.small { padding: 4px 10px; font-size: 0.8rem; margin-left: 8px; }

.conn-log {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--muted);
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.dialpad button {
  padding: 18px;
  font-size: 1.25rem;
  background: #0b1220;
  color: var(--text);
  border: 1px solid var(--border);
}
.dialpad button:hover { background: var(--border); }

.call-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.call-info {
  margin-top: 16px;
  font-size: 1rem;
  min-height: 24px;
}

.muted { color: var(--muted); }
.hidden { display: none !important; }

.lead-actions { margin-bottom: 16px; }
.lead-actions button { margin-right: 8px; }

#lead-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 420px;
  overflow-y: auto;
}

.lead-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.lead-item:last-child { border-bottom: none; }
.lead-info { flex: 1; }
.lead-name { font-weight: 600; }
.lead-phone { color: var(--muted); font-size: 0.9rem; }
.lead-status {
  font-size: 0.75rem;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--border);
  margin-right: 8px;
}
.lead-status.new { background: #3b82f6; }

.lead-btns button {
  padding: 6px 10px;
  margin: 0;
  font-size: 0.8rem;
}

.logs { margin-top: 20px; }
#log-box {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 420px;
}

.modal-actions {
  margin-top: 16px;
}
