:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1f2630;
  --text: #e6edf3;
  --muted: #8b949e;
  --line: #30363d;
  --hot: #f85149;
  --warm: #d29922;
  --cold: #6e7681;
  --good: #3fb950;
  --link: #58a6ff;
  --ch-outbound: #58a6ff;
  --ch-inbound: #3fb950;
  --ch-unattributed: #6e7681;
  --sidebar-width: 200px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

/* ── sidebar shell ──────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  padding: 0 20px 16px 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.sidebar .brand h1 { margin: 0; font-size: 16px; font-weight: 600; }
.sidebar .brand .tag { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: background 0.1s ease, color 0.1s ease, border-left-color 0.1s ease;
}
.sidebar nav a:hover { color: var(--text); background: var(--panel-2); }
.sidebar nav a.active {
  color: var(--text);
  background: var(--panel-2);
  border-left-color: var(--link);
}
.sidebar nav a .nav-icon {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--line);
  flex-shrink: 0;
}
.sidebar nav a.active .nav-icon { background: var(--link); }
.sidebar .user {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}
.sidebar .user .email { color: var(--text); font-weight: 500; word-break: break-all; }
.sidebar .user form { margin: 0; }
.sidebar .user button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.sidebar .user button:hover { color: var(--text); }

.content { min-width: 0; }
.topbar {
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg);
}
.topbar .title h2 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar .title .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

main { padding: 24px; max-width: 1400px; margin: 0 auto; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav a { border-left: 0; border-bottom: 2px solid transparent; }
  .sidebar nav a.active { border-bottom-color: var(--link); border-left-color: transparent; }
}

/* ── filters ────────────────────────────────────────────────────────────── */
form.filters { display: flex; gap: 8px; align-items: center; }
form.filters select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}
form.filters button {
  background: var(--link);
  color: #fff;
  border: 0;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

/* ── counters ───────────────────────────────────────────────────────────── */
.counters {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1100px) { .counters { grid-template-columns: repeat(2, 1fr); } }
.counter {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
}
.counter .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.counter .value { font-size: 32px; font-weight: 700; margin-top: 6px; }
.counter .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.counter.positive .value { color: var(--good); }
.counter.qualified .value { color: var(--good); }

.counter.appts { display: flex; flex-direction: column; gap: 10px; }
.appts-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.appts-head .label { margin: 0; }
.pill-group {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}
.pill {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.pill:hover { color: var(--text); }
.pill.active[data-channel="outbound"]    { background: rgba(88, 166, 255, 0.18); color: var(--ch-outbound); }
.pill.active[data-channel="inbound"]     { background: rgba(63, 185, 80, 0.18);  color: var(--ch-inbound); }
.pill.active[data-channel="all"]         { background: rgba(230, 237, 243, 0.10); color: var(--text); }

.counter.appts .value { transition: color 0.2s ease; }
.counter.appts.ch-outbound .value { color: var(--ch-outbound); }
.counter.appts.ch-inbound  .value { color: var(--ch-inbound); }
.counter.appts.ch-all      .value { color: var(--text); }

.breakdown {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.breakdown .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.breakdown .dot.outbound     { background: var(--ch-outbound); }
.breakdown .dot.inbound      { background: var(--ch-inbound); }
.breakdown .dot.unattributed { background: var(--ch-unattributed); }

.mix-bar {
  display: flex;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
}
.mix-bar > span { display: block; height: 100%; transition: width 0.25s ease; }
.mix-bar .seg-outbound     { background: var(--ch-outbound); }
.mix-bar .seg-inbound      { background: var(--ch-inbound); }
.mix-bar .seg-unattributed { background: var(--ch-unattributed); }

.conversion { font-size: 12px; color: var(--muted); }
.conversion strong { color: var(--text); font-weight: 600; }

/* ── panel ──────────────────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.panel h2 { margin: 0 0 12px 0; font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sparkline-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sparkline { display: flex; flex-direction: column; gap: 4px; }
.sparkline .legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.sparkline .legend strong { color: var(--text); font-size: 16px; }
.sparkline svg { width: 100%; height: 50px; display: block; }

/* ── streams ────────────────────────────────────────────────────────────── */
.stream-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .stream-grid { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
td a { color: var(--link); text-decoration: none; }
td a:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge.hot { background: rgba(248, 81, 73, 0.15); color: var(--hot); }
.badge.warm { background: rgba(210, 153, 34, 0.15); color: var(--warm); }
.badge.interested { background: rgba(63, 185, 80, 0.15); color: var(--good); }
.badge.qualified { background: rgba(63, 185, 80, 0.15); color: var(--good); }
.badge.cold, .badge.neutral { background: rgba(110, 118, 129, 0.20); color: var(--cold); }
.badge.ooo, .badge.unknown { background: rgba(110, 118, 129, 0.20); color: var(--cold); }
.badge.bounce, .badge.error { background: rgba(248, 81, 73, 0.10); color: var(--cold); }

.icp-yes { color: var(--good); font-weight: 600; }
.icp-no { color: var(--muted); }

.snippet { color: var(--muted); font-size: 12px; max-width: 360px; }
.empty { color: var(--muted); font-style: italic; padding: 24px; text-align: center; }

.vert-tag { color: var(--muted); font-size: 11px; }

/* ── AI layers / per-agent health ───────────────────────────────────────── */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1100px) { .agents-grid { grid-template-columns: 1fr; } }
.agent-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cold);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-card.status-green  { border-left-color: var(--good); }
.agent-card.status-yellow { border-left-color: var(--warm); }
.agent-card.status-red    { border-left-color: var(--hot); }
.agent-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.agent-head .name { font-weight: 600; font-size: 14px; }
.agent-head .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--cold);
  box-shadow: 0 0 0 3px rgba(110, 118, 129, 0.15);
}
.agent-card.status-green  .dot { background: var(--good); box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.15); }
.agent-card.status-yellow .dot { background: var(--warm); box-shadow: 0 0 0 3px rgba(210, 153, 34, 0.18); }
.agent-card.status-red    .dot { background: var(--hot);  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.18); }
.agent-desc { color: var(--muted); font-size: 12px; }
.agent-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  font-size: 12px;
}
.agent-stats .stat { display: flex; flex-direction: column; gap: 2px; }
.agent-stats .stat .k { color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: 0.04em; }
.agent-stats .stat .v { color: var(--text); font-weight: 600; font-size: 14px; }
.agent-mix { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.agent-mix .pill-mini {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--muted);
}
.agent-mix .pill-mini strong { color: var(--text); margin-left: 4px; }
.agent-breach { font-size: 11px; color: var(--hot); }
.agent-foot { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.agent-foot a { color: var(--link); text-decoration: none; }
.agent-foot a:hover { text-decoration: underline; }

/* compact agent summary used on Overview tab */
.agents-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 1100px) { .agents-summary { grid-template-columns: 1fr; } }
.agents-summary .row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cold);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.agents-summary .row.status-green  { border-left-color: var(--good); }
.agents-summary .row.status-yellow { border-left-color: var(--warm); }
.agents-summary .row.status-red    { border-left-color: var(--hot); }
.agents-summary .row .info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.agents-summary .row .info .name { font-weight: 600; font-size: 13px; }
.agents-summary .row .info .sub { font-size: 11px; color: var(--muted); }
.agents-summary .row .stat-mini {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}
.agents-summary .row .stat-mini strong { color: var(--text); font-size: 13px; font-weight: 600; }

/* ── vertical scorecard ─────────────────────────────────────────────────── */
table.scorecard { width: 100%; }
table.scorecard th, table.scorecard td { padding: 8px 12px; }
table.scorecard th:not(:first-child),
table.scorecard td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
table.scorecard tbody tr:hover { background: var(--panel-2); }
table.scorecard td.v-name { text-transform: capitalize; font-weight: 500; }
table.scorecard td.rate { color: var(--muted); }
table.scorecard td.rate.good { color: var(--good); }
table.scorecard td.zero { color: var(--cold); }

/* ── login + link-sent ──────────────────────────────────────────────────── */
body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.card h1 { margin: 0 0 6px 0; font-size: 20px; }
.card .subtitle { color: var(--muted); margin: 0 0 24px 0; font-size: 13px; }
.card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.card input[type="email"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 16px;
}
.card button {
  width: 100%;
  padding: 10px 16px;
  background: var(--link);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.card .hint { color: var(--muted); font-size: 12px; margin-top: 16px; line-height: 1.5; }
.card a { color: var(--link); text-decoration: none; }

/* ── placeholder tabs ───────────────────────────────────────────────────── */
.placeholder {
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 48px 24px;
  text-align: center;
}
.placeholder h2 { margin: 0 0 8px 0; font-size: 16px; color: var(--text); }
.placeholder p { color: var(--muted); margin: 0; font-size: 13px; }
