:root {
  --kreilkamp-red: #BC0C06;
  --kreilkamp-red-dark: #8a0904;
  --kreilkamp-red-light: #d31309;
  --kreilkamp-navy: #1a2332;
  --kreilkamp-navy-dark: #0f1620;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --amber-500: #f59e0b;
  --amber-50: #fffbeb;
  --emerald-500: #10b981;
  --emerald-50: #ecfdf5;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--slate-50);
  color: var(--slate-900);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
}
aside.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--kreilkamp-navy);
  color: white;
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 32px;
  height: 32px;
  background: var(--kreilkamp-red);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: white;
}
.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand-sub {
  font-size: 10.5px;
  color: var(--slate-400);
  margin-top: 1px;
  letter-spacing: 0.3px;
}
nav.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
}
nav.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--slate-300);
  text-decoration: none;
  margin-bottom: 2px;
}
nav.sidebar-nav a:hover { background: rgba(255,255,255,.05); color: white; }
nav.sidebar-nav a.active { background: var(--kreilkamp-red); color: white; }
nav.sidebar-nav a.active:hover { background: var(--kreilkamp-red-dark); }
nav.sidebar-nav .nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px;
  color: var(--slate-400);
}
main { margin-left: 240px; min-height: 100vh; }
.main-inner { max-width: 1280px; padding: 28px 36px; margin: 0 auto; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
}
.page-head h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--slate-900);
}
.page-head .subtitle {
  font-size: 13px;
  color: var(--slate-500);
  margin-top: 4px;
}
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.stat-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 8px;
  color: var(--slate-900);
}
.stat-value.red { color: var(--kreilkamp-red); }
.stat-value.amber { color: var(--amber-500); }
.stat-value.emerald { color: var(--emerald-500); }
.stat-delta {
  font-size: 11px;
  color: var(--slate-500);
  margin-top: 4px;
}
h2.section-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-700);
  margin: 24px 0 12px 0;
}
.card {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
table th {
  background: var(--slate-50);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-500);
  border-bottom: 1px solid var(--slate-200);
}
table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--slate-100);
  font-size: 13px;
}
table tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge-qualified { background: var(--emerald-50); color: #047857; }
.badge-needs-clarification { background: var(--amber-50); color: #92400e; }
.badge-disqualified { background: #fef2f2; color: #991b1b; }
.badge-conversation { background: #eff6ff; color: #1e40af; }
.badge-after-hours { background: #fdf4ff; color: #86198f; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--slate-300);
  background: white;
  color: var(--slate-800);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--slate-50); }
.btn-primary {
  background: var(--kreilkamp-red);
  color: white;
  border-color: var(--kreilkamp-red);
}
.btn-primary:hover { background: var(--kreilkamp-red-dark); }
.tagline {
  font-size: 9.5px;
  color: var(--slate-400);
  margin-top: 2px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.demo-note {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 3px solid var(--amber-500);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  color: #92400e;
  margin-bottom: 16px;
}

/* ────────────────────────────────────────────────────────────
   Tablet + Mobile responsive layout
   < 900px collapses sidebar to a top bar with horizontal-scroll nav,
   single-column stat grid, horizontally scrolling tables.
   ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  body { font-size: 13.5px; }

  aside.sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    inset: auto;
    flex-direction: row;
    align-items: center;
    z-index: 50;
    padding: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
  }
  .brand {
    padding: 12px 14px;
    border-bottom: 0;
    border-right: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
  }
  .brand-name { font-size: 13px; }
  .brand-sub { font-size: 9.5px; }
  nav.sidebar-nav {
    flex: 1;
    display: flex;
    gap: 0;
    padding: 0 8px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  nav.sidebar-nav a {
    display: inline-flex;
    flex-shrink: 0;
    padding: 14px 12px;
    margin-bottom: 0;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    font-size: 12px;
  }
  nav.sidebar-nav a.active {
    background: transparent;
    color: white;
    border-bottom-color: var(--kreilkamp-red);
  }
  nav.sidebar-nav a.active:hover { background: rgba(255,255,255,.05); }
  .sidebar-footer { display: none; }

  main { margin-left: 0; }
  .main-inner { padding: 18px 16px; }

  .page-head {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  .page-head h1 { font-size: 19px; }
  .page-head > div:last-child {
    display: flex;
    gap: 8px;
  }
  .page-head .btn { flex: 1; justify-content: center; }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 24px; }

  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 640px; }

  .conv-layout {
    grid-template-columns: 1fr !important;
    height: auto !important;
  }
  .conv-list { max-height: 280px; }
  .conv-thread { min-height: 60vh; }

  .config-grid { grid-template-columns: 1fr !important; gap: 16px; }
  .config-nav {
    position: static;
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding: 6px 0;
    border-bottom: 1px solid var(--slate-200);
    margin-bottom: 8px;
  }
  .config-nav a {
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 12px;
  }
  .field-row {
    grid-template-columns: 1fr !important;
    gap: 6px;
  }
  .field-input { width: 100% !important; max-width: none; }

  .timeline-row { grid-template-columns: 1fr !important; gap: 4px; padding: 12px 14px; }
  .timeline-time { font-size: 11.5px; }

  .event-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px;
    padding: 10px 12px;
  }
  .event-row > span:nth-child(3) {
    grid-column: 1 / -1;
    overflow-x: auto;
    max-width: 100%;
  }
  .event-row.header > span:nth-child(3) {
    overflow: hidden;
  }

  .main-inner > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .filter-bar { gap: 6px; }
  .search-input { max-width: 100%; flex-basis: 100%; order: -1; }
  .chip { font-size: 11px; padding: 5px 10px; }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 17px; }
  .stat-value { font-size: 22px; }
  .ascii-chart { font-size: 9.5px; }
}
