/* ── Variables ───────────────────────────────────────────────── */
:root {
  --bg: #F4F6F9;
  --bg-deep: #EBEEF3;
  --card: #FFFFFF;
  --card-hover: #F8FAFC;
  --border: #E2E8F0;
  --border-faint: #EDF2F7;
  --accent: #2AABEE;
  --accent-dim: rgba(42, 171, 238, 0.1);
  --accent-glow: rgba(42, 171, 238, 0.05);
  --ok: #16A34A;
  --warn: #D97706;
  --danger: #DC2626;
  --converted: #CA8A04;
  --qualified: #0D9488;
  --text: #111827;
  --text-dim: #4B5563;
  --text-faint: #9CA3AF;
  --font: 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --shadow-1: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.1), 0 2px 6px rgba(0,0,0,0.07);
  --shadow-3: 0 8px 24px rgba(0,0,0,0.14), 0 4px 10px rgba(0,0,0,0.08);
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #root { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Scrollbars ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E0; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #A0AEC0; }
* { scrollbar-width: thin; scrollbar-color: #CBD5E0 transparent; }

/* ── App shell ───────────────────────────────────────────────── */
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}
.main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 16px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; width: 240px; flex-shrink: 0; }
.topbar-center { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.logo { display: flex; align-items: center; gap: 9px; }
.logo-mark {
  width: 30px; height: 30px;
  background: rgba(42, 171, 238, 0.1);
  border: 1px solid rgba(42, 171, 238, 0.3);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
}
.logo-name .logo-dim { color: var(--text-faint); font-weight: 400; }
.logo-sub { font-size: 10px; color: var(--text-faint); letter-spacing: 0.01em; margin-top: 1px; }

.status-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}
.status-pill.status-ok {
  color: var(--ok);
  background: rgba(46, 204, 113, 0.08);
  border-color: rgba(46, 204, 113, 0.2);
}
.status-pill.status-warn {
  color: var(--warn);
  background: rgba(243, 156, 18, 0.08);
  border-color: rgba(243, 156, 18, 0.2);
}
.status-pill.status-danger {
  color: var(--danger);
  background: rgba(231, 76, 60, 0.08);
  border-color: rgba(231, 76, 60, 0.2);
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  position: relative;
  flex-shrink: 0;
}
.status-pill.status-ok .status-dot::after,
.status-pill.status-warn .status-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  animation: ring-ping 2.2s ease-out infinite;
  opacity: 0;
}
.status-pill.status-warn .status-dot::after { animation-delay: 0.4s; }
@keyframes ring-ping {
  0%   { transform: scale(0.7); opacity: 0.7; }
  100% { transform: scale(2.2); opacity: 0; }
}

.topbar-meta { display: flex; flex-direction: column; align-items: flex-end; }
.topbar-meta-label { font-size: 9px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.topbar-meta-val { font-size: 12px; font-weight: 600; color: var(--text); }
.topbar-meta-val.accent { color: var(--accent); }

.token-meter { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.token-meter-row {
  display: flex; align-items: baseline; gap: 2px;
  font-family: var(--mono); font-size: 11px;
}
.token-meter-num { font-weight: 500; color: var(--text); }
.token-meter-slash { color: var(--text-faint); }
.token-meter-budget { color: var(--text-faint); }
.token-meter-unit { font-size: 9px; color: var(--text-faint); margin-left: 2px; }
.token-meter-bar {
  height: 4px; background: var(--border);
  border-radius: 999px; overflow: hidden;
  position: relative;
}
.token-meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.6s ease;
  position: relative;
}
.token-meter-fill.is-high {
  background: var(--danger);
}

/* ── Left nav ────────────────────────────────────────────────── */
.leftnav {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--card);
  overflow-y: auto;
  overflow-x: hidden;
}

.leftnav-account {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border-faint);
  flex-shrink: 0;
}
.account-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.account-name { font-size: 12px; font-weight: 600; color: var(--text); }
.account-handle { font-size: 11px; color: var(--accent); }
.account-phone { font-size: 10px; color: var(--text-faint); font-family: var(--mono); }

.leftnav-nav {
  display: flex; flex-direction: column;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-faint);
  flex-shrink: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  transition: color 0.12s, background 0.12s;
  position: relative;
  border-radius: 0;
}
.nav-item:hover { background: rgba(42, 171, 238, 0.06); color: var(--text); }
.nav-item.is-active {
  color: var(--accent);
  background: rgba(42, 171, 238, 0.1);
}
.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item span:first-of-type { flex: 1; }
.nav-badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: white;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.nav-badge-soft {
  background: rgba(42, 171, 238, 0.15);
  color: var(--accent);
}

.leftnav-stats {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-faint);
  flex-shrink: 0;
}
.stats-title {
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.statcard {
  padding: 7px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 7px;
  margin-bottom: 5px;
}
.statcard-big { padding: 10px 12px; }
.statcard-value {
  font-size: 22px; font-weight: 700; line-height: 1.1;
  font-family: var(--mono);
  color: var(--text);
}
.statcard-big .statcard-value { font-size: 28px; color: var(--accent); }
.statcard-label { font-size: 10px; color: var(--text-faint); margin-top: 2px; }
.statcard-sub { color: var(--text-faint); }
.statcard-ok .statcard-value { color: var(--ok); }
.statcard-warn { background: rgba(243,156,18,0.06); border-color: rgba(243,156,18,0.2); }
.statcard-warn .statcard-value { color: var(--warn); }
.statcard-danger { background: rgba(231,76,60,0.06); border-color: rgba(231,76,60,0.18); }
.statcard-danger .statcard-value { color: var(--danger); }
.statcard-accent .statcard-value { color: var(--accent); }

.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 5px;
}
.stats-grid .statcard { margin-bottom: 0; padding: 7px 9px; }
.stats-grid .statcard-value { font-size: 18px; }

.stats-row { display: flex; gap: 5px; }
.ministat {
  flex: 1;
  padding: 7px 9px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 7px;
  text-align: center;
}
.ministat-val { font-size: 14px; font-weight: 700; font-family: var(--mono); color: var(--text); }
.ministat-lbl { font-size: 9px; color: var(--text-faint); margin-top: 2px; }

.leftnav-system {
  padding: 10px 12px 14px;
  flex-shrink: 0;
}
.syshealth-title {
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 7px;
}
.syshealth-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-dim);
  margin-bottom: 3px;
}
.syshealth-val { font-family: var(--mono); font-size: 11px; color: var(--text); }
.syshealth-ok { color: var(--ok) !important; }
.syshealth-bar {
  height: 3px; background: var(--border);
  border-radius: 999px; overflow: hidden;
  margin-bottom: 8px;
}
.syshealth-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.5s ease;
}

/* Make page-wrapper divs fill the flex column (not the dashboard grid) */
.main > div:not(.dash-grid) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Dashboard grid ──────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Conversation monitor (centre) ──────────────────────────── */
.convmon {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg);
}
.convmon-header {
  padding: 12px 14px 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-faint);
}
.convmon-title-row {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.convmon-title { font-size: 14px; font-weight: 700; }
.convmon-count { font-size: 11px; color: var(--text-faint); }

.convmon-search {
  display: flex; align-items: center; gap: 7px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  margin-bottom: 10px;
  color: var(--text-faint);
}
.convmon-search:focus-within {
  border-color: rgba(42, 171, 238, 0.4);
  color: var(--text-dim);
}
.convmon-search input {
  flex: 1; background: transparent; border: none; outline: none;
  padding: 7px 0; font-size: 12.5px; color: var(--text);
}
.convmon-search input::placeholder { color: var(--text-faint); }
.convmon-search kbd {
  font-size: 10px; font-family: var(--mono);
  background: var(--border); color: var(--text-faint);
  padding: 1px 4px; border-radius: 3px;
}

.convmon-tabs {
  display: flex; gap: 2px;
  padding-bottom: 0;
}
.tab {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px;
  background: transparent; border: none;
  font-size: 12px; font-weight: 500;
  color: var(--text-faint);
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tab.tab-warn.is-active { color: var(--warn); border-bottom-color: var(--warn); }
.tab-count {
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px;
  background: rgba(136, 153, 170, 0.15);
  color: var(--text-faint);
  font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.tab.is-active .tab-count { background: var(--accent-dim); color: var(--accent); }
.tab.tab-warn.is-active .tab-count { background: rgba(243, 156, 18, 0.12); color: var(--warn); }

.convmon-list {
  flex: 1; overflow-y: auto;
}
.convmon-empty {
  padding: 32px 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}

.convrow {
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%; padding: 9px 14px;
  background: transparent; border: none;
  border-bottom: 1px solid var(--border-faint);
  text-align: left; cursor: pointer;
  transition: background 0.1s;
}
.convrow:hover { background: rgba(42, 171, 238, 0.04); }
.convrow.is-selected {
  background: rgba(42, 171, 238, 0.09);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}
.convrow.is-selected .convrow-name { color: var(--accent); }

.convrow-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
  margin-top: 1px;
}
.convrow-body { flex: 1; min-width: 0; }
.convrow-line1 {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 6px; margin-bottom: 2px;
}
.convrow-name { font-size: 13px; font-weight: 600; color: var(--text); truncate: clip; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convrow-time { font-size: 10px; color: var(--text-faint); flex-shrink: 0; }
.convrow-line2 {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin-bottom: 3px;
}
.convrow-preview {
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.convrow-ai-prefix { color: var(--text-faint); }
.convrow-meta { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.convrow-flag { color: var(--warn); display: flex; }
.convrow-line3 {
  display: flex; align-items: center; gap: 6px;
}
.convrow-lang { font-size: 12px; }
.convrow-tokens { font-size: 10px; color: var(--text-faint); font-family: var(--mono); display: flex; align-items: center; gap: 2px; }
.convrow-aibadge {
  font-size: 9px; color: var(--accent);
  background: var(--accent-dim); border-radius: 3px; padding: 0 4px;
  display: flex; align-items: center; gap: 2px;
}
.convrow-icp { font-size: 10px; color: var(--text-faint); margin-left: auto; }

.status-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.05em;
  padding: 1px 6px; border-radius: 3px;
  border: 1px solid;
  white-space: nowrap;
}

/* ── Typing indicator ────────────────────────────────────────── */
.typing-inline { display: inline-flex; align-items: baseline; gap: 1px; }
.typing-dot {
  display: inline-block;
  animation: typing-blink 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-blink {
  0%, 60%, 100% { opacity: 0.25; }
  30% { opacity: 1; }
}

.bubble-typing .typing-dot {
  font-size: 18px; line-height: 1;
  color: var(--text-faint);
}

/* ── Detail column ───────────────────────────────────────────── */
.detail {
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.detail-empty {
  display: flex; align-items: center; justify-content: center;
  flex: 1;
  color: var(--text-faint);
  font-size: 13px;
}

/* ── Thread ──────────────────────────────────────────────────── */
.thread {
  display: flex; flex-direction: column;
  height: 60%;
  min-height: 200px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.thread-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.thread-header-left { display: flex; align-items: center; gap: 9px; }
.thread-header-right { display: flex; align-items: center; gap: 6px; }
.thread-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.thread-name { font-size: 13px; font-weight: 600; color: var(--text); }
.thread-flag { font-size: 13px; }
.thread-sub {
  font-size: 11px; color: var(--text-faint);
  display: flex; align-items: center; gap: 4px;
}
.thread-status-dot {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ok);
}

.thread-flag-banner {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 14px;
  background: rgba(243, 156, 18, 0.08);
  border-bottom: 1px solid rgba(243, 156, 18, 0.2);
  font-size: 12px; color: var(--warn);
  flex-shrink: 0;
}
.thread-takeover-banner {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 14px;
  background: rgba(42, 171, 238, 0.08);
  border-bottom: 1px solid rgba(42, 171, 238, 0.2);
  font-size: 12px; color: var(--accent);
  flex-shrink: 0;
}

.thread-scroll {
  flex: 1; overflow-y: auto;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 3px;
}

.thread-readonly-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  font-size: 10px; color: var(--text-faint);
  background: var(--bg-deep);
  border-top: 1px solid var(--border-faint);
  flex-shrink: 0;
}

/* ── Chat bubbles ────────────────────────────────────────────── */
.bubble-row {
  display: flex;
  margin-bottom: 3px;
}
.bubble-row-ai { justify-content: flex-end; }
.bubble-row-them { justify-content: flex-start; }

.bubble {
  max-width: 78%;
  padding: 7px 11px 5px;
  font-size: 12.5px;
  line-height: 1.45;
  position: relative;
}
.bubble-them {
  background: #F0F2F5;
  border-radius: 3px 16px 16px 16px;
  color: var(--text);
}
.bubble-ai {
  background: #D9EFFD;
  border-radius: 16px 3px 16px 16px;
  color: #0D3A5C;
}
.bubble-flagged {
  border: 1px solid rgba(243, 156, 18, 0.5);
}
.bubble-flag-tag {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; color: var(--warn);
  margin-bottom: 4px;
}
.bubble-text { word-break: break-word; }
.bubble-meta {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 4px; margin-top: 3px;
}
.bubble-time {
  font-size: 10px;
  font-family: var(--mono);
  opacity: 0.55;
}
.bubble-ticks { opacity: 0.7; display: flex; }

.bubble-debug {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  margin-top: 5px;
  padding: 4px 7px;
  border-radius: 4px;
  background: rgba(0,0,0,0.05);
  font-size: 9.5px; font-family: var(--mono);
  color: var(--text-faint);
}
.dbg-model { display: flex; align-items: center; gap: 3px; color: var(--accent); }
.dbg-sep { opacity: 0.4; }

/* ── Lead panel ──────────────────────────────────────────────── */
.leadpanel {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.leadpanel-tabs {
  display: flex;
  padding: 0 14px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.paneltab {
  padding: 9px 12px 8px;
  background: transparent; border: none;
  font-size: 12px; font-weight: 500;
  color: var(--text-faint);
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}
.paneltab:hover { color: var(--text); }
.paneltab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.leadpanel-body {
  flex: 1; overflow-y: auto;
  padding: 12px 14px;
}

/* Profile tab */
.profile-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 12px;
}
.pfield {}
.pfield-label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.pfield-value { font-size: 12px; color: var(--text); font-weight: 500; }

.profile-icp { margin-bottom: 12px; }
.profile-icp-row {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-dim);
  margin-bottom: 5px;
}
.profile-icp-val { font-weight: 700; font-family: var(--mono); color: var(--accent); }
.icp-bar { display: flex; gap: 2px; }
.icp-cell {
  flex: 1; height: 5px; border-radius: 2px;
  background: var(--border);
  transition: background 0.15s;
}
.icp-cell:nth-child(-n+3).is-on  { background: #2AABEE; }
.icp-cell:nth-child(4).is-on,
.icp-cell:nth-child(5).is-on      { background: #2AB8C8; }
.icp-cell:nth-child(6).is-on,
.icp-cell:nth-child(7).is-on      { background: #3FD3C0; }
.icp-cell:nth-child(8).is-on,
.icp-cell:nth-child(9).is-on      { background: #35D498; }
.icp-cell:nth-child(10).is-on     { background: #2ECC71; }

.profile-facts {}
.profile-facts-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  margin-bottom: 7px;
}
.btn-link {
  display: flex; align-items: center; gap: 3px;
  background: transparent; border: none;
  font-size: 11px; color: var(--accent);
  padding: 0;
}
.profile-facts-empty { font-size: 11px; color: var(--text-faint); padding: 4px 0; }
.profile-facts-list { display: flex; flex-wrap: wrap; gap: 5px; }
.fact-tag {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: rgba(42, 171, 238, 0.1);
  border: 1px solid rgba(42, 171, 238, 0.2);
  border-radius: 999px;
  font-size: 11px; color: var(--accent);
}
.fact-tag-x {
  background: transparent; border: none;
  color: rgba(42, 171, 238, 0.5); padding: 0;
  display: flex; align-items: center;
}
.fact-tag-x:hover { color: var(--accent); }

/* Context tab */
.ctxtab { display: flex; flex-direction: column; gap: 10px; }
.ctx-section {}
.ctx-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 5px;
  display: flex; align-items: center; gap: 6px;
}
.ctx-pill {
  background: var(--border); color: var(--text-dim);
  padding: 1px 6px; border-radius: 999px;
  font-size: 10px; font-weight: 500; letter-spacing: 0;
}
.ctx-card {
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11.5px; color: var(--text-dim);
  line-height: 1.5;
}
.ctx-card.mono { font-family: var(--mono); font-size: 11px; }
.ctx-chunks { display: flex; flex-direction: column; gap: 4px; }
.chunk {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 5px;
}
.chunk-l { display: flex; flex-direction: column; gap: 2px; }
.chunk-type {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--accent); opacity: 0.8;
}
.chunk-title { font-size: 11.5px; color: var(--text); }
.chunk-score { font-size: 12px; font-family: var(--mono); font-weight: 600; color: var(--ok); }
.ctx-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ctx-stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 4px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 5px; text-align: center;
}
.ctx-stat-val { font-size: 14px; font-weight: 700; font-family: var(--mono); color: var(--text); }
.ctx-stat-lbl { font-size: 9px; color: var(--text-faint); margin-top: 2px; }

/* Actions tab */
.actions { display: flex; flex-direction: column; gap: 0; position: relative; }
.actions::before {
  content: '';
  position: absolute; left: 7px; top: 8px; bottom: 8px;
  width: 1px; background: var(--border);
}
.action-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 7px 0;
  position: relative;
}
.action-dot {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--border);
  flex-shrink: 0; margin-top: 2px;
  position: relative; z-index: 1;
}
.action-send .action-dot { border-color: var(--accent); }
.action-recv .action-dot { border-color: var(--ok); }
.action-status .action-dot { border-color: var(--converted); }
.action-next .action-dot { border-color: var(--warn); }
.action-find .action-dot { border-color: var(--text-faint); }
.action-body { flex: 1; min-width: 0; }
.action-label { font-size: 12px; font-weight: 500; color: var(--text); }
.action-sub { font-size: 11px; color: var(--text-faint); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-time { font-size: 10px; color: var(--text-faint); font-family: var(--mono); flex-shrink: 0; margin-top: 2px; }
.actions-cta { padding-top: 8px; }

/* ── Pages: shared ───────────────────────────────────────────── */
@keyframes pageIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .page { animation: pageIn 0.22s ease-out; }
}
.page {
  flex: 1; overflow-y: auto;
  padding: 24px 28px;
}
.page-header { margin-bottom: 22px; }
.page-header h1 {
  font-size: 22px; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
}
.page-subhead { font-size: 12px; color: var(--text-faint); }

/* Stub page */
.page-stub {
  display: flex; align-items: center; justify-content: center;
}
.stub-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 40px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-dim); text-align: center;
  max-width: 340px;
}
.stub-card h2 { font-size: 18px; font-weight: 700; color: var(--text); }
.stub-card p { font-size: 13px; }

/* ── Analytics page ──────────────────────────────────────────── */
.page-analytics { padding: 20px 24px; }
.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.kpi {
  padding: 12px 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px;
  border-left: 3px solid var(--border);
  box-shadow: var(--shadow-1);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  cursor: default;
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: rgba(42,171,238,0.4);
}
.kpi-label {
  font-size: 9.5px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 6px;
  font-weight: 600;
}
.kpi-value {
  font-size: 1.85rem; font-weight: 700;
  font-family: var(--mono); color: var(--text);
  margin-bottom: 5px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-row-bottom { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi-sub { font-size: 10px; color: var(--text-faint); }
.kpi-trend {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 10px; font-weight: 700;
  font-family: var(--mono);
  padding: 1px 5px; border-radius: 4px;
}
.kpi-up   { color: var(--ok);     background: rgba(22,163,74,0.1); }
.kpi-down { color: var(--danger); background: rgba(220,38,38,0.1); }
.kpi .kpi-row { display: flex; align-items: center; gap: 6px; }

.chart-row { display: grid; gap: 12px; margin-bottom: 12px; }
.chart-row-2 { grid-template-columns: 1.35fr 1fr; }
.chart-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.chartcard {
  padding: 14px 16px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.chartcard:hover {
  border-color: rgba(42,171,238,0.3);
  box-shadow: var(--shadow-2);
}
.chartcard-wide { margin-bottom: 12px; }
.chartcard-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 12px;
}
.chartcard-title {
  font-size: 10.5px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 3px;
}
.chartcard-sub { font-size: 11px; color: var(--text-faint); }
.chartcard-legend { display: flex; align-items: center; gap: 12px; }
.leg { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); }
.leg-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.chart { display: block; overflow: visible; }

.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut-legend { display: flex; flex-direction: column; gap: 5px; }
.donut-leg-row { display: flex; align-items: center; gap: 7px; font-size: 11px; }
.donut-leg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.donut-leg-lbl { flex: 1; color: var(--text-dim); }
.donut-leg-val { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text); }

.costtable {
  width: 100%; border-collapse: collapse;
  font-size: 11.5px; margin-top: 12px;
}
.costtable th {
  padding: 5px 10px;
  text-align: left;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
}
.costtable td {
  padding: 6px 10px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-faint);
  font-family: var(--mono);
}
.costtable tbody tr:hover td { background: rgba(42, 171, 238, 0.04); color: var(--text); }
.costtable td:first-child { color: var(--text-faint); }

/* ── Memory page ─────────────────────────────────────────────── */
.page-memory { display: flex; flex-direction: column; padding: 0; }
.page-memory .page-header { padding: 20px 24px 0; }
.memory-grid {
  display: grid; grid-template-columns: 1fr 1.5fr 1fr;
  flex: 1; min-height: 0;
  border-top: 1px solid var(--border);
  overflow: hidden;
}
.memory-col {
  display: flex; flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.memory-col:last-child { border-right: none; }
.memory-col-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.col-title { font-size: 13px; font-weight: 600; color: var(--text); }
.col-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.col-pill {
  background: rgba(243, 156, 18, 0.12);
  color: var(--warn);
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
}
.memory-list { flex: 1; overflow-y: auto; }
.memory-item {
  display: flex; flex-direction: column; gap: 3px;
  width: 100%; padding: 10px 14px;
  background: transparent; border: none;
  border-bottom: 1px solid var(--border-faint);
  text-align: left; cursor: pointer;
  transition: background 0.1s;
}
.memory-item:hover { background: rgba(42, 171, 238, 0.04); }
.memory-item.is-selected { background: rgba(42, 171, 238, 0.08); }
.memory-type {
  display: inline-flex; align-items: center;
  font-size: 9px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 3px; border: 1px solid;
  width: fit-content;
}
.memory-item-title { font-size: 12.5px; color: var(--text); font-weight: 500; }
.memory-item-meta { font-size: 10px; color: var(--text-faint); }

.memory-col-edit { flex: 1; }
.memory-editor {
  flex: 1;
  display: block;
  width: 100%;
  min-height: 180px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-faint);
  resize: none;
  outline: none;
  font-size: 12.5px; color: var(--text);
  line-height: 1.6;
}
.memory-editor:focus { background: rgba(42, 171, 238, 0.02); }
.memory-meta-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 16px;
}
.meta-field { display: flex; flex-direction: column; gap: 4px; }
.meta-field label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.meta-field select, .meta-field input[type=range] {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 5px; padding: 4px 7px;
  color: var(--text); outline: none;
  font-size: 12px;
}
.meta-field select { appearance: none; }
.meta-field input[type=range] { padding: 4px 0; accent-color: var(--accent); }
.meta-val { color: var(--accent); font-family: var(--mono); }
.meta-readonly { font-size: 12px; color: var(--text-dim); }
.memory-col-actions { display: flex; gap: 6px; align-items: flex-start; }
.memory-empty {
  display: flex; align-items: center; justify-content: center;
  flex: 1; color: var(--text-faint); font-size: 12px;
}

.insights-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.insight {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-faint);
}
.insight-fact { font-size: 12.5px; color: var(--text); line-height: 1.45; margin-bottom: 5px; }
.insight-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; margin-bottom: 6px;
}
.insight-from { color: var(--accent); }
.insight-conf {
  display: flex; align-items: center; gap: 5px;
}
.insight-conf-bar {
  width: 54px; height: 5px; border-radius: 999px;
  background: var(--border); overflow: hidden;
}
.insight-conf-fill {
  height: 100%; border-radius: inherit;
}
.insight-conf-num {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
}
.insight-time { color: var(--text-faint); margin-left: auto; }
.insight-actions { display: flex; gap: 6px; }
.btn-keep {
  display: flex; align-items: center; gap: 3px;
  padding: 3px 9px; border-radius: 4px;
  background: rgba(46, 204, 113, 0.12);
  border: 1px solid rgba(46, 204, 113, 0.25);
  color: var(--ok); font-size: 11px; font-weight: 500;
  transition: background 0.12s;
}
.btn-keep:hover { background: rgba(46, 204, 113, 0.2); }
.btn-discard {
  display: flex; align-items: center; gap: 3px;
  padding: 3px 9px; border-radius: 4px;
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.2);
  color: var(--danger); font-size: 11px; font-weight: 500;
  transition: background 0.12s;
}
.btn-discard:hover { background: rgba(231, 76, 60, 0.18); }

/* ── Personality page ────────────────────────────────────────── */
.page-personality { max-width: 820px; }
.settings-stack { display: flex; flex-direction: column; gap: 0; }
.settings-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
}
.settings-section-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 18px 12px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-faint);
}
.settings-section-head h2 { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.settings-section-sub { font-size: 11px; color: var(--text-faint); }
.settings-section-body {
  padding: 14px 18px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--card);
}

.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; }
.field-wide { flex: 2; }
.field label {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint);
}
.field input, .field textarea {
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text); font-size: 12.5px;
  outline: none; resize: vertical;
  transition: border-color 0.12s;
}
.field input:focus, .field textarea:focus { border-color: rgba(42, 171, 238, 0.4); }
.field-textarea textarea { min-height: 80px; }

.preset-row { display: flex; gap: 8px; margin-bottom: 4px; }
.preset {
  flex: 1; padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  text-align: left; cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.preset:hover { background: var(--card-hover); }
.preset.is-selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.preset-name { font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.preset-sub { font-size: 10.5px; color: var(--text-faint); }
.preset.is-selected .preset-sub { color: rgba(42, 171, 238, 0.7); }

.toggle-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s;
}
.toggle-row:hover { background: var(--card-hover); }
.toggle-label { font-size: 12.5px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.toggle-sub { font-size: 11px; color: var(--text-faint); }
.toggle {
  width: 36px; height: 20px; border-radius: 10px;
  background: var(--border);
  position: relative; flex-shrink: 0;
  transition: background 0.15s;
  margin-top: 1px;
}
.toggle.is-on { background: var(--accent); }
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.15s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.toggle.is-on .toggle-thumb { transform: translateX(16px); }

.rules-col {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px; overflow: hidden;
}
.rules-col-title {
  padding: 7px 12px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.rules-do { color: var(--ok); background: rgba(46, 204, 113, 0.05); border-bottom: 1px solid rgba(46, 204, 113, 0.1); }
.rules-dont { color: var(--danger); background: rgba(231, 76, 60, 0.05); border-bottom: 1px solid rgba(231, 76, 60, 0.1); }
.rule-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-faint);
}
.rule-do .rule-mark { color: var(--ok); font-weight: 700; }
.rule-dont .rule-mark { color: var(--danger); font-weight: 700; }
.rule-text { flex: 1; font-size: 12px; color: var(--text); }
.rule-edit {
  background: transparent; border: none;
  color: var(--text-faint); padding: 2px;
  opacity: 0;
  transition: opacity 0.1s;
}
.rule-row:hover .rule-edit { opacity: 1; }
.rules-add {
  display: flex; align-items: center; gap: 4px;
  width: 100%; padding: 7px 12px;
  background: transparent; border: none;
  font-size: 11px; color: var(--text-faint);
  transition: color 0.1s;
}
.rules-add:hover { color: var(--accent); }

.slider-card {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
}
.slider-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 8px;
}
.slider-label { font-size: 12.5px; font-weight: 500; color: var(--text); }
.slider-sub { font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.slider-val { font-size: 14px; font-weight: 700; font-family: var(--mono); color: var(--accent); }
.slider-card input[type=range] { width: 100%; accent-color: var(--accent); }
.slider-conf-track {
  position: relative; height: 4px;
  background: var(--border);
  border-radius: 999px; margin-bottom: 4px; overflow: hidden;
}
.slider-conf-cover {
  position: absolute; right: 0; top: 0; bottom: 0;
  background: var(--border);
}
.conf-scale {
  display: flex; justify-content: space-between;
  font-size: 9px; font-family: var(--mono); color: var(--text-faint);
  margin-top: 3px;
}

.settings-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 0 4px;
}
.btn-lg { padding: 9px 20px !important; font-size: 13px !important; }

/* ── Shared buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  border-radius: 6px; border: 1px solid transparent;
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn-primary {
  background: var(--accent); color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: #1A9BD8; border-color: #1A9BD8; }
.btn-ghost {
  background: var(--card); color: var(--text-dim);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--card-hover); color: var(--text); border-color: #2E3E56; }
.btn-warn {
  background: rgba(243, 156, 18, 0.12); color: var(--warn);
  border-color: rgba(243, 156, 18, 0.25);
}
.btn-warn:hover { background: rgba(243, 156, 18, 0.2); }
.btn-icon {
  padding: 5px 7px;
  background: transparent; color: var(--text-faint);
  border-color: transparent;
}
.btn-icon:hover { background: var(--card); color: var(--text); }
.accent { color: var(--accent); }

/* ── Shortcuts FAB + modal ───────────────────────────────────── */
.shortcuts-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-faint); font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.shortcuts-fab:hover { background: var(--card-hover); color: var(--text); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 300px; max-width: 420px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.modal-body { padding: 14px 16px; }

.shortcuts-grid { display: flex; flex-direction: column; gap: 6px; }
.shortcut-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.shortcut-keys { display: flex; gap: 4px; }
.shortcut-keys kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 22px; padding: 0 6px;
  background: var(--border); border-radius: 4px;
  font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--text);
  border-bottom: 2px solid rgba(0,0,0,0.4);
}
.shortcut-label { font-size: 12.5px; color: var(--text-dim); }

/* ── Density modifiers ───────────────────────────────────────── */
[data-density=compact] .convrow { padding: 6px 12px; }
[data-density=compact] .nav-item { padding: 6px 14px; }
[data-density=compact] .statcard { padding: 5px 8px; }
[data-density=compact] .statcard-big { padding: 7px 10px; }
[data-density=compact] .statcard-value { font-size: 18px; }
[data-density=compact] .statcard-big .statcard-value { font-size: 24px; }
[data-density=compact] .thread-header { padding: 7px 12px; }
[data-density=compact] .leadpanel-body { padding: 9px 12px; }
[data-density=compact] .thread-scroll { padding: 8px 12px; }

[data-density=airy] .convrow { padding: 12px 16px; }
[data-density=airy] .nav-item { padding: 10px 16px; }
[data-density=airy] .statcard { padding: 10px 12px; }
[data-density=airy] .statcard-big { padding: 14px 16px; }
[data-density=airy] .leftnav { width: 260px; }
[data-density=airy] .topbar-left { width: 260px; }

/* ── Sparkline ───────────────────────────────────────────────── */
.sparkline { display: block; }

/* ── Leads page ─────────────────────────────────────────────── */
.page-leads { display: flex; flex-direction: column; gap: 16px; }

.leads-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.lead-kpi {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 10px;
  box-shadow: var(--shadow-1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.lead-kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.lead-kpi-icon { opacity: 0.85; flex-shrink: 0; }
.lead-kpi-value {
  font-size: 1.55rem; font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}
.lead-kpi-label { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.leads-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
.leads-filters { display: flex; gap: 6px; flex-wrap: wrap; }

.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px; font-weight: 500; color: var(--text-dim);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.filter-chip:hover { background: var(--card-hover); color: var(--text); }
.filter-chip.is-active { background: var(--card-hover); color: var(--text); border-color: var(--accent); }

.chip-count {
  font-size: 10px; font-weight: 600;
  padding: 1px 5px;
  background: var(--border);
  border-radius: 999px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.leads-toolbar-right { display: flex; align-items: center; gap: 8px; }

.leads-search {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-faint);
  transition: border-color 0.12s;
}
.leads-search:focus-within { border-color: var(--accent); }
.leads-search input {
  background: transparent; border: none; outline: none;
  font-size: 12.5px; color: var(--text);
  width: 160px;
}
.leads-search input::placeholder { color: var(--text-faint); }

.leads-table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  box-shadow: var(--shadow-1);
}
.leads-table {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px;
}
.leads-table thead tr {
  border-bottom: 1px solid var(--border);
}
.leads-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint);
  white-space: nowrap;
}
.leads-table th.th-sort { cursor: pointer; user-select: none; }
.leads-table th.th-sort:hover { color: var(--text-dim); }
.leads-table th.is-sorted { color: var(--accent); }
.sort-arrow { margin-left: 3px; font-size: 10px; }
.th-lead { min-width: 200px; }

.lead-row {
  border-bottom: 1px solid var(--border-faint);
  transition: background 0.1s;
}
.lead-row:last-child { border-bottom: none; }
.lead-row:hover { background: rgba(42, 171, 238, 0.04); }
.lead-row td { padding: 10px 14px; vertical-align: middle; }

.td-lead { display: flex; align-items: center; gap: 10px; }
.lead-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.lead-name { font-size: 13px; font-weight: 600; color: var(--text); }
.lead-handle { font-size: 11px; color: var(--text-faint); margin-top: 1px; }

.lead-status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}

.lead-icp-row { display: flex; align-items: center; gap: 7px; }
.lead-icp-bar { display: flex; gap: 2px; }
.lead-icp-cell {
  width: 6px; height: 14px; border-radius: 2px;
  background: var(--border);
}
.lead-icp-num {
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  min-width: 14px;
}

.lead-stage {
  font-size: 11.5px; color: var(--text-dim);
  background: var(--bg); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px;
}
.lead-time { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.lead-cost {
  font-size: 12px; font-family: var(--mono);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.lead-row-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.1s; }
.lead-row:hover .lead-row-actions { opacity: 1; }

.leads-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  padding: 48px;
  color: var(--text-faint); font-size: 13px;
}

/* ── System Settings page ────────────────────────────────────── */
.page-settings { display: flex; flex-direction: column; gap: 0; }

.sys-status-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: rgba(46, 204, 113, 0.05);
  border: 1px solid rgba(46, 204, 113, 0.15);
  border-radius: 7px;
  margin-bottom: 12px;
  font-size: 12.5px;
}
.sys-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0;
}
.sys-dot-ok   { background: var(--ok); box-shadow: 0 0 5px rgba(46, 204, 113, 0.5); }
.sys-dot-warn { background: var(--warn); box-shadow: 0 0 5px rgba(243, 156, 18, 0.5); }
.sys-dot-err  { background: var(--danger); box-shadow: 0 0 5px rgba(231, 76, 60, 0.5); }
.sys-status-text { font-weight: 500; color: var(--ok); }
.sys-status-since { margin-left: auto; font-size: 11px; color: var(--text-faint); }

.masked-field {
  display: flex; align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}
.masked-input {
  flex: 1; background: transparent; border: none !important; outline: none;
  padding: 6px 10px;
  font-family: var(--mono); font-size: 12px; color: var(--text-dim);
  letter-spacing: 0.02em;
}
.masked-toggle {
  border-radius: 0 !important;
  border-left: 1px solid var(--border) !important;
  height: 100%; padding: 0 9px !important;
}

.webhook-status-val {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 0;
  font-size: 12.5px; color: var(--ok);
}

.danger-zone {
  border: 1px solid rgba(231, 76, 60, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(231, 76, 60, 0.03);
}
.danger-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(231, 76, 60, 0.12);
}
.danger-row:last-child { border-bottom: none; }
.danger-row-text { flex: 1; }
.danger-label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.danger-sub { font-size: 11.5px; color: var(--text-faint); max-width: 480px; }
.danger-confirm { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.danger-sure { font-size: 12px; color: var(--danger); font-weight: 500; white-space: nowrap; }

.btn-danger {
  background: rgba(231, 76, 60, 0.12);
  color: var(--danger);
  border-color: rgba(231, 76, 60, 0.3);
}
.btn-danger:hover { background: rgba(231, 76, 60, 0.22); border-color: rgba(231, 76, 60, 0.5); }
