:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e8eef7;
  --muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #2d3a4f;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

.view { min-height: 100vh; }
.login-card {
  max-width: 420px;
  margin: 10vh auto;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.login-card label { display: block; margin-bottom: 1rem; }
.login-card input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar h1 { margin: 0; font-size: 1.25rem; }
.topbar-actions { display: flex; gap: 0.5rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  padding: 1rem 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.stat-card strong { display: block; font-size: 1.4rem; }

.queue-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1.5rem 0.75rem;
}
.queue-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.queue-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.stat-click { cursor: pointer; }
.stat-click:hover { border-color: var(--primary); }
.status-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  padding: 0.2rem;
  max-width: 110px;
}
.detail-panel input[type=date] {
  width: 100%;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  margin-top: 0.35rem;
}

.toolbar, .bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0 1.5rem 1rem;
}
.toolbar input[type=search], .toolbar select {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.toolbar input[type=search] { min-width: 240px; flex: 1; }
.checkbox-label { display: flex; align-items: center; gap: 0.35rem; color: var(--muted); }

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-sm { padding: 0.35rem 0.55rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 1.25rem; font-size: 1rem; }
.btn-success { background: #166534; color: #fff; }
.btn-call { background: #065f46; color: #fff; }
.btn-danger { background: #7f1d1d; color: #fff; border: 1px solid #991b1b; }
.btn-danger:hover { background: #991b1b; }
.demo-link-box {
  margin: 1rem 0;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  text-align: left;
}
.demo-link-box input {
  width: 100%;
  margin: 0.35rem 0 0.5rem;
  padding: 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
}
.demo-link-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }

.customer-box {
  margin: 1rem 0;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.customer-box h3 { margin: 0 0 0.65rem; font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.cust-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.5rem; }
.checkbox-row { display: flex; align-items: center; gap: 0.45rem; margin: 0.5rem 0; }
.checkbox-row input { width: auto; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-onboarding { background: rgba(255, 193, 7, 0.15); color: #ffc107; }
.badge-live { background: rgba(76, 175, 80, 0.15); color: #81c784; }
.checklist { margin: 0.65rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.88rem; }
.capability-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.layout { display: grid; grid-template-columns: 1fr 360px; gap: 0; min-height: calc(100vh - 220px); }
.table-wrap { overflow: auto; padding: 0 1rem 2rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 0.55rem 0.45rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--bg); }
tr:hover td { background: rgba(255,255,255,0.02); }

.status-pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface2);
}
.status-new { color: #93c5fd; }
.status-emailed { color: #fcd34d; }
.status-called { color: #86efac; }
.status-won { color: var(--success); }
.status-lost { color: var(--danger); }

.detail-panel {
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
  overflow: auto;
  position: relative;
}
.close-btn { position: absolute; top: 0.5rem; right: 0.5rem; font-size: 1.4rem; }
.detail-panel h2 { margin-top: 0; font-size: 1.1rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1rem 0; }
.detail-panel textarea, .detail-panel select {
  width: 100%;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.activity-list { list-style: none; padding: 0; margin: 0; }
.activity-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  max-width: 360px;
  z-index: 100;
}
.loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
}

.demo-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1e3a5f, var(--bg));
}
.demo-card {
  max-width: 520px;
  width: 92%;
  padding: 2rem;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  text-align: center;
}
.demo-card h1 {
  font-size: clamp(1.25rem, 5vw, 1.75rem);
  line-height: 1.2;
  word-break: break-word;
}
.demo-card .btn-lg {
  width: 100%;
  max-width: 320px;
  min-height: 52px;
  font-size: 1.05rem;
  touch-action: manipulation;
}
.demo-card #demo-status {
  min-height: 2.5rem;
  padding: 0 0.5rem;
  line-height: 1.4;
}
@media (max-width: 600px) {
  .demo-page { align-items: flex-start; padding: 1rem 0 2rem; }
  .demo-card { width: 100%; padding: 1.25rem; border-radius: 12px; }
}
.badge {
  display: inline-block;
  background: rgba(59,130,246,0.15);
  color: #93c5fd;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
}
.pricing-box {
  margin-top: 1.5rem;
  text-align: left;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .detail-panel { border-left: none; border-top: 1px solid var(--border); }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.65);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow: auto;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.modal-card h2 { margin-top: 0; font-size: 1.15rem; }
.modal-card label { display: block; margin-bottom: 0.75rem; font-size: 0.85rem; }
.modal-card input,
.modal-card select,
.modal-card textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
