* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.subtitle {
  color: #666;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 5px;
  color: #555;
  font-weight: 500;
  font-size: 0.9rem;
}

input, select, textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 12px;
}

button {
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  background: #667eea;
  color: white;
}

button:hover {
  background: #5568d3;
}

button.secondary {
  background: #95a5a6;
}

button.secondary:hover {
  background: #7f8c8d;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status-banner {
  padding: 12px 15px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  display: none;
}

.status-banner.show {
  display: block;
}

.status-banner.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.status-banner.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.leads-summary {
  font-weight: 600;
  color: #555;
  margin-bottom: 14px;
  font-size: 0.95rem;
}

.metric-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 10px;
  padding: 24px 28px;
  margin-bottom: 28px;
}

.metric-label {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.9;
}

.metric-value {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 6px 0 4px;
}

.metric-sub {
  font-size: 0.85rem;
  opacity: 0.8;
}

.leads-list-heading {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.lead {
  border-left: 4px solid #667eea;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
}

.lead-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  cursor: pointer;
}

.lead-row:hover {
  background: rgba(102, 126, 234, 0.08);
}

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

.lead-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.lead-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lead-chevron {
  flex-shrink: 0;
  font-size: 1.4rem;
  line-height: 1;
  color: #999;
  transition: transform 0.15s ease;
}

.call-icon-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #eef0fb;
  text-decoration: none;
  font-size: 0.95rem;
}

.call-icon-btn:hover {
  background: #dde1f7;
}

.call-link {
  color: #667eea;
  font-weight: 500;
  text-decoration: none;
}

.call-link:hover {
  text-decoration: underline;
}

.lead.expanded .lead-chevron {
  transform: rotate(90deg);
}

.lead-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.lead-timestamp {
  color: #777;
  font-size: 0.8rem;
}

.lead-preview {
  color: #666;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.lead-details {
  padding: 0 15px 15px 34px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.lead-field {
  font-size: 0.88rem;
  margin-bottom: 3px;
  margin-top: 10px;
}

.lead-field strong {
  color: #555;
}

.lead-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.lead-controls select {
  width: auto;
  margin-bottom: 0;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e0e0ff;
  color: #4c4c9e;
}

.client-list-item, .site-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

.link-box {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px 10px;
  word-break: break-all;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #999;
}

.sms-toggle-card { padding: 14px 20px; }

.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0;
  cursor: pointer;
}

.switch-sub {
  display: block;
  font-weight: 400;
  font-size: 0.85rem;
  color: #666;
  margin-top: 2px;
}

input.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  min-width: 46px;
  height: 26px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 13px;
  background: #ccc;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

input.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: left 0.2s;
}

input.switch:checked { background: #2ecc71; }
input.switch:checked::after { left: 23px; }
input.switch:disabled { opacity: 0.6; cursor: default; }

.type-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: 6px;
}
.type-pill.form { background: #e8ebfb; color: #4553b8; }
.type-pill.call { background: #e3f6ea; color: #1e7a45; }

.call-item {
  border-left: 4px solid #2ecc71;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 10px;
}
.call-item.missed { border-left-color: #e74c3c; }
.call-item.missed .lead-preview { color: #c0392b; }
.call-row { cursor: default; }
.call-audio { margin-top: 8px; height: 32px; max-width: 100%; }

.leads-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.leads-list-header .leads-list-heading { margin-bottom: 0; }

.kind-filter {
  display: inline-flex;
  background: #eef0f6;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.kind-filter button {
  background: transparent;
  color: #555;
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 6px;
}
.kind-filter button:hover { background: #e2e5f0; }
.kind-filter button.active { background: white; color: #333; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

[hidden] { display: none !important; }

.lead-business {
  font-size: 1.15rem;
  font-weight: 700;
  color: #222;
  margin: 2px 0 1px;
}
.lead-name.secondary {
  font-size: 0.92rem;
  font-weight: 500;
  color: #555;
}

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.business-filter {
  width: auto;
  margin: 0;
  padding: 7px 10px;
  font-size: 0.85rem;
  border-radius: 8px;
  background: #eef0f6;
  border: none;
  color: #333;
}

.type-pill.text { background: #fdf1e0; color: #a8620c; }
.text-item {
  border-left: 4px solid #f0ad4e;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 10px;
}
.textback-note { color: #a8620c; font-weight: 500; }
.call-item.missed .textback-note { color: #a8620c; }

.thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 16px 16px;
}
.bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  word-break: break-word;
}
.bubble-body { white-space: pre-wrap; }
.bubble.inbound { align-self: flex-start; background: white; border: 1px solid #e3e3e3; }
.bubble.outbound { align-self: flex-end; background: #667eea; color: white; }
.bubble.outbound.auto { background: #fdf1e0; color: #6b4a1a; border: 1px dashed #f0ad4e; }
.bubble-tag { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 2px; }
.bubble-time { font-size: 0.7rem; opacity: 0.7; margin-top: 4px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.stat-tile {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 10px;
  padding: 20px 22px;
}
.stat-tile:nth-child(2) { background: linear-gradient(135deg, #2ecc71 0%, #1e8f57 100%); }
.stat-tile:nth-child(3) { background: linear-gradient(135deg, #f0ad4e 0%, #d9822b 100%); }
.stat-label { font-size: 0.9rem; font-weight: 500; opacity: 0.92; }
.stat-value { font-size: 2.8rem; font-weight: 700; line-height: 1.1; margin: 6px 0 2px; }
.stat-sub { font-size: 0.82rem; opacity: 0.85; }
@media (max-width: 640px) { .stat-row { grid-template-columns: 1fr; } }
