/* ---------- ChannelsConnect dashboard — pipeboard-inspired ---------- */

:root,
[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #fafaf9;
  --bg-sidebar: #0b0d10;
  --bg-sidebar-hover: #161a1f;
  --bg-elevated: #ffffff;
  --border: #e8e8e6;
  --border-soft: #f0efed;
  --text: #14171a;
  --text-soft: #5b6068;
  --text-faint: #6b7079;
  --text-on-dark: #e6e8eb;
  --text-on-dark-faint: #8a909a;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --warn: #d97706;
  --danger: #dc2626;
  --good: #059669;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 18, 22, 0.04);
  --shadow: 0 1px 3px rgba(15, 18, 22, 0.06), 0 4px 12px rgba(15, 18, 22, 0.04);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-sidebar: #050708;
  --bg-sidebar-hover: #11161c;
  --bg-elevated: #161b22;
  --border: #30363d;
  --border-soft: #21262d;
  --text: #e6edf3;
  --text-soft: #9da7b3;
  --text-faint: #8b949e;
  --accent: #58a6ff;
  --accent-soft: #1f2a3f;
  --warn: #f0a868;
  --danger: #ff8080;
  --good: #7ddc9b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="navy"] {
  --bg: #0b1426;
  --bg-soft: #112038;
  --bg-sidebar: #060d1a;
  --bg-sidebar-hover: #102040;
  --bg-elevated: #112038;
  --border: rgba(190, 210, 255, 0.18);
  --border-soft: rgba(190, 210, 255, 0.08);
  --text: #e6ecff;
  --text-soft: #c4cfee;
  --text-faint: #a8b5d4;
  --text-on-dark: #e6ecff;
  --text-on-dark-faint: #a8b5d4;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.16);
  --warn: #fbbf24;
  --danger: #f87171;
  --good: #34d399;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="gray"] {
  --bg: #1c1c1e;
  --bg-soft: #2c2c2e;
  --bg-sidebar: #0a0a0c;
  --bg-sidebar-hover: #1f1f22;
  --bg-elevated: #2c2c2e;
  --border: rgba(255, 255, 255, 0.14);
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #f2f2f7;
  --text-soft: #d1d1d6;
  --text-faint: #aeaeb2;
  --text-on-dark: #f2f2f7;
  --text-on-dark-faint: #aeaeb2;
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.16);
  --warn: #ff9f0a;
  --danger: #ff453a;
  --good: #30d158;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] { color-scheme: light; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) { color-scheme: dark; }

/* Smooth theme switch — animates color/bg tokens only when the user clicks,
   then auto-removes the class so layout interactions stay snappy. */
html.theme-transition,
html.theme-transition * {
  transition: background-color 220ms ease, color 220ms ease, border-color 220ms ease, box-shadow 220ms ease !important;
}
@media (prefers-reduced-motion: reduce) {
  html.theme-transition,
  html.theme-transition * { transition: none !important; }
}
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .badge-intent { background: #1f2a3f; color: #79b8ff; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .badge-channel { background: #2c2540; color: #b392f0; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .badge-priority-hot { background: #3a1f1f; color: #ff8080; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .badge-priority-warm { background: #3a2a1f; color: #ffaa66; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .badge-priority-cold { background: #1f2a3a; color: #79b8ff; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .badge-fit-strong { background: #1f3a2a; color: #7ddc9b; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .badge-fit-possible { background: #3a3520; color: #d1b65a; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .badge-status-sent { background: #1f3a2a; color: #7ddc9b; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .badge-status-queued { background: #1f2a3f; color: #79b8ff; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .badge-status-failed { background: #3a1f1f; color: #ff8080; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .login-body { background: #0d1117; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) thead th { background: var(--bg-soft); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-feature-settings: 'cv11', 'ss01', 'ss02';
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- App shell ---------- */
#app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px;
  border-bottom: 1px solid #20252c;
  margin-bottom: 16px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: white;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  letter-spacing: -0.02em;
}
.brand-title { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-on-dark-faint); margin-top: 2px; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 14px;
}
.nav-group:last-child { margin-bottom: 0; }
.nav-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-on-dark-faint);
  opacity: 0.55;
  padding: 6px 12px 4px;
  font-weight: 600;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--text-on-dark-faint);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 80ms, color 80ms;
}
.nav a:hover { background: var(--bg-sidebar-hover); color: var(--text-on-dark); }
.nav a.active {
  background: var(--bg-sidebar-hover);
  color: white;
}
.nav .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
}
.nav a.active .dot { opacity: 1; background: var(--accent); }

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid #20252c;
}
.status-pill {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-on-dark-faint);
  padding: 4px 8px;
  background: var(--bg-sidebar-hover);
  border-radius: 4px;
  align-self: flex-start;
}
.status-pill.ok { color: #34d399; }
.status-pill.bad { color: #f87171; }

/* ---------- Theme picker (sidebar foot) ---------- */
.theme-picker {
  display: flex;
  gap: 6px;
  padding: 4px 0;
}
.theme-picker .swatch {
  flex: 1 1 0;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.theme-picker .swatch:hover { transform: translateY(-1px); border-color: rgba(255,255,255,0.4); }
.theme-picker .swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-picker .swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.theme-picker .swatch[data-theme-swatch="light"] { background: linear-gradient(135deg, #ffffff 0%, #e4e4e7 100%); }
.theme-picker .swatch[data-theme-swatch="dark"]  { background: linear-gradient(135deg, #09090b 0%, #27272a 100%); }
.theme-picker .swatch[data-theme-swatch="navy"]  { background: linear-gradient(135deg, #0b1426 0%, #1e3a6f 100%); }
.theme-picker .swatch[data-theme-swatch="gray"]  { background: linear-gradient(135deg, #1c1c1e 0%, #4a4a4d 100%); }

.logout-form { margin: 0; }
.link-btn {
  background: none;
  border: none;
  color: var(--text-on-dark-faint);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: white; }
.ver { font-size: 11px; color: var(--text-on-dark-faint); opacity: 0.7; }

/* ---------- Content ---------- */
.content {
  padding: 32px 40px;
  max-width: 1280px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.topbar .muted { margin: 4px 0 0; font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; }

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 500;
}
.stat-value {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.stat-trend {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-soft);
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-head .muted { font-size: 12px; }
.card-body { padding: 14px 18px; }
.card-body.flush { padding: 0; }

/* ---------- Breakdowns ---------- */
.breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.bd-rows { display: flex; flex-direction: column; gap: 8px; padding: 14px 18px; }
.bd-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.bd-row .bd-bar {
  grid-column: 1 / -1;
  height: 4px;
  background: var(--border-soft);
  border-radius: 2px;
  overflow: hidden;
}
.bd-row .bd-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  font-size: 13px;
}
tbody tr:hover { background: var(--bg-soft); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  background: var(--border-soft);
  color: var(--text-soft);
}
.badge-channel { background: #eef2ff; color: #3730a3; }
.badge-intent { background: var(--accent-soft); color: var(--accent); }
.badge-priority-hot { background: #fef2f2; color: #b91c1c; }
.badge-priority-warm { background: #fff7ed; color: #c2410c; }
.badge-priority-cold { background: #f0f9ff; color: #075985; }
.badge-fit-strong { background: #ecfdf5; color: #047857; }
.badge-fit-possible { background: #fefce8; color: #a16207; }
.badge-fit-weak { background: #f5f5f4; color: #57534e; }
.badge-fit-unknown { background: #f5f5f4; color: #78716c; }
.badge-status-sent { background: #ecfdf5; color: #047857; }
.badge-status-queued { background: #eff6ff; color: #2563eb; }
.badge-status-failed { background: #fef2f2; color: #b91c1c; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--text);
  color: white;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { filter: brightness(0.85); }
.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-soft); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(0.9); }

/* ---------- Conversations ---------- */
.thread-list { display: flex; flex-direction: column; }
.thread-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}
.thread-item:hover { background: var(--bg-soft); }
.thread-item .who { font-weight: 500; font-size: 13.5px; }
.thread-item .when { font-size: 11px; color: var(--text-faint); }
.thread-item .meta { font-size: 11px; color: var(--text-soft); margin-top: 2px; }

.msg-list { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.msg {
  border-left: 3px solid var(--border);
  padding: 10px 14px;
  background: var(--bg-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.msg-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.msg-body { font-size: 13.5px; white-space: pre-wrap; }
.msg-reply {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

/* ---------- Settings ---------- */
.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.setting-row:last-child { border-bottom: none; }
.setting-name { font-weight: 500; font-size: 13.5px; }
.setting-desc { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.setting-input input, .setting-input select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  min-width: 200px;
}
.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 100ms;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 120ms;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(18px); }
.toggle.danger.on { background: var(--danger); }

.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- Kanban (Pipeline page) ---------- */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 8px;
}
.kanban-col {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kanban-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
}
.kanban-col-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kanban-col-head .count {
  font-size: 12px;
  color: var(--text-faint);
  background: var(--border-soft);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.kanban-col.hot .kanban-col-head h3 { color: #b91c1c; }
.kanban-col.warm .kanban-col-head h3 { color: #c2410c; }
.kanban-col.cold .kanban-col-head h3 { color: #075985; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .kanban-col.hot .kanban-col-head h3 { color: #ff8080; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .kanban-col.warm .kanban-col-head h3 { color: #ffaa66; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .kanban-col.cold .kanban-col-head h3 { color: #79b8ff; }
.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 80ms, box-shadow 80ms, border-color 80ms;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kanban-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.kanban-card .who {
  font-weight: 500;
  font-size: 13px;
  line-height: 1.3;
}
.kanban-card .body {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kanban-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-faint);
}

/* ---------- Health page tiles ---------- */
.health-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.health-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.health-tile.ok { border-left: 3px solid var(--good); }
.health-tile.warn { border-left: 3px solid var(--warn); }
.health-tile.danger { border-left: 3px solid var(--danger); }
.health-tile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.health-tile h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.health-pill {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}
.health-pill.ok { background: #ecfdf5; color: #047857; }
.health-pill.warn { background: #fef3c7; color: #92400e; }
.health-pill.danger { background: #fee2e2; color: #991b1b; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .health-pill.ok { background: #1f3a2a; color: #7ddc9b; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .health-pill.warn { background: #3a2a1f; color: #ffaa66; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .health-pill.danger { background: #3a1f1f; color: #ff8080; }
.health-metric {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.health-detail {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.5;
}

/* ---------- Big stat row (Analytics) ---------- */
.big-stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.big-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.big-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 500;
}
.big-stat-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.025em;
}
.big-stat-foot {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-soft);
}

/* ---------- Mini-pipeline preview (Overview) ---------- */
.mini-pipeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.mini-col {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mini-col-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.mini-col-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mini-col-head .count {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.mini-col.hot .mini-col-head h3 { color: #b91c1c; }
.mini-col.warm .mini-col-head h3 { color: #c2410c; }
.mini-col.cold .mini-col-head h3 { color: #075985; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .mini-col.hot .mini-col-head h3 { color: #ff8080; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .mini-col.warm .mini-col-head h3 { color: #ffaa66; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .mini-col.cold .mini-col-head h3 { color: #79b8ff; }
.mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
  cursor: pointer;
  gap: 8px;
}
.mini-row:last-child { border-bottom: none; }
.mini-row:hover .mini-name { color: var(--accent); }
.mini-row .mini-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.mini-row .mini-time {
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}

/* ---------- Patch notes ---------- */
.patchnote {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.patchnote:last-child { border-bottom: none; }
.patchnote-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.patchnote-id {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
}
.patchnote-type {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
}
.patchnote-type.NEW { background: var(--accent-soft); color: var(--accent); }
.patchnote-type.FIX { background: #fee2e2; color: #b91c1c; }
.patchnote-type.UPD { background: #fef3c7; color: #92400e; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .patchnote-type.FIX { background: #3a1f1f; color: #ff8080; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .patchnote-type.UPD { background: #3a2a1f; color: #ffaa66; }
.patchnote-body h4 {
  margin: 0 0 4px;
  font-size: 13.5px;
  font-weight: 600;
}
.patchnote-body p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.5;
}

@media (max-width: 600px) {
  .mini-pipeline { grid-template-columns: 1fr; }
}

/* ---------- Architecture page ---------- */
.arch-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
  min-height: 700px;
}
.arch-canvas {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.arch-canvas-inner {
  padding: 22px 18px 60px;
  position: relative;
  min-width: 900px;
}
.arch-canvas-scroller {
  overflow-x: auto;
  width: 100%;
}
.arch-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 6px 12px 18px;
  font-size: 11px;
  color: var(--text-soft);
}
.arch-legend-item { display: flex; align-items: center; gap: 6px; }
.arch-legend-swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.arch-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(135px, 1fr));
  gap: 16px 18px;
  position: relative;
  z-index: 2;
}
.arch-lane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.arch-lane-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-weight: 700;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border-soft);
}
.arch-node {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  position: relative;
  cursor: pointer;
  transition: all 120ms;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.arch-node:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.arch-node-label { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.arch-node-sub { font-size: 10.5px; color: var(--text-soft); line-height: 1.4; }

/* Lane color coding (left border accent) */
.arch-node[data-cat="actor"] { border-left: 3px solid #d946ef; }
.arch-node[data-cat="surface"] { border-left: 3px solid #facc15; }
.arch-node[data-cat="ingest"] { border-left: 3px solid #22c55e; }
.arch-node[data-cat="process"] { border-left: 3px solid #3b82f6; }
.arch-node[data-cat="storage"] { border-left: 3px solid #a855f7; }
.arch-node[data-cat="action"] { border-left: 3px solid #f97316; }
.arch-node[data-cat="external"] { border-left: 3px solid #14b8a6; }

/* Flow highlight state */
.arch-canvas.has-flow .arch-node { opacity: 0.25; transition: opacity 200ms; }
.arch-canvas.has-flow .arch-node.in-flow {
  opacity: 1;
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--accent-soft) 100%);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 0 18px -4px var(--accent);
}
.arch-node .step-badge {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 22px; height: 22px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.arch-node.in-flow .step-badge { display: flex; }

/* Arrow overlay */
.arch-arrows {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.arch-arrows path {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
  opacity: 0.35;
}
.arch-canvas.has-flow .arch-arrows path { opacity: 0.08; }
.arch-canvas.has-flow .arch-arrows path.in-flow {
  opacity: 0.9;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  animation: arch-march 0.8s linear infinite;
}
@keyframes arch-march {
  to { stroke-dashoffset: -20; }
}
.arch-canvas.has-flow .arch-node.in-flow {
  animation: arch-node-pulse 1.6s ease-in-out infinite;
}
@keyframes arch-node-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 18px -4px var(--accent); }
  50% { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 24px -2px var(--accent); }
}

/* Zoom controls */
.arch-zoom {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 5;
}
.arch-zoom button {
  width: 28px; height: 28px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  display: grid;
  place-items: center;
}
.arch-zoom button:hover { background: var(--bg-soft); border-color: var(--accent); }

/* Test buttons on flows */
.arch-flow-actions { display: flex; gap: 6px; margin-top: 6px; }
.arch-flow-test {
  font-size: 10.5px;
  padding: 3px 8px;
  background: var(--good);
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}
.arch-flow-test:hover { background: #047857; }
.arch-flow-test[disabled] { opacity: 0.4; cursor: not-allowed; }

/* Node detail modal */
.arch-node-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 22, 0.6);
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
}
.arch-node-modal-card {
  background: var(--bg-elevated);
  border-radius: 10px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}
.arch-node-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
}
.arch-node-modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.arch-ref-section h4 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
}
.arch-ref-item {
  display: block;
  padding: 6px 10px;
  background: var(--bg-soft);
  border-radius: 4px;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-soft);
  text-decoration: none;
}
.arch-ref-item:hover { color: var(--accent); background: var(--accent-soft); }
.arch-ref-item .ref-fn { color: var(--accent); }

/* Sidebar */
.arch-sidebar { display: flex; flex-direction: column; gap: 14px; }
.arch-flow-list { display: flex; flex-direction: column; }
.arch-flow {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  transition: background 80ms;
}
.arch-flow:last-child { border-bottom: none; }
.arch-flow:hover { background: var(--bg-soft); }
.arch-flow.selected {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}
.arch-flow-label { font-size: 13px; font-weight: 500; }
.arch-flow-sub { font-size: 11.5px; color: var(--text-soft); margin-top: 2px; }
.arch-step {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.arch-step:last-child { border-bottom: none; }
.arch-step-num {
  width: 22px; height: 22px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.arch-step-body { font-size: 12px; line-height: 1.5; color: var(--text-soft); }
.arch-step-node { font-weight: 600; color: var(--text); display: block; margin-bottom: 2px; }

/* Tile view for GHL contacts */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding: 16px;
}
.tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 120ms;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.tile-head { display: flex; gap: 10px; align-items: center; }
.tile-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.tile-name {
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.2;
}
.tile-company {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
}
.tile-row { font-size: 11.5px; color: var(--text-soft); display: flex; gap: 4px; }
.tile-row .tile-icon { width: 12px; opacity: 0.5; flex-shrink: 0; }
.tile-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.tile-foot {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-faint);
  padding-top: 6px;
  border-top: 1px dashed var(--border-soft);
}

@media (max-width: 1100px) {
  .arch-layout { grid-template-columns: 1fr; }
}

/* ---------- Empty page state ---------- */
.placeholder-page {
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 32px;
  text-align: center;
}
.placeholder-page .glyph {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.placeholder-page h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.placeholder-page p {
  margin: 0 auto;
  max-width: 480px;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.6;
}

/* ---------- Mobile fixes for grouped nav + kanban ---------- */
@media (max-width: 900px) {
  .nav-group-label { display: none; }
  .nav-group { margin-bottom: 0; flex-direction: row; }
}
@media (max-width: 600px) {
  .kanban { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: 1fr; }
  .big-stat-row { grid-template-columns: repeat(2, 1fr); }
}
.empty {
  padding: 48px 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.empty h3 { margin: 0 0 8px; font-size: 15px; color: var(--text-soft); font-weight: 500; }

.warn-banner {
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #78350f;
}
.warn-banner strong { color: #92400e; }
.warn-banner.danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}
.warn-banner.danger strong { color: #7f1d1d; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .warn-banner {
  background: #3a2f1a;
  border-color: #5a4520;
  color: #f5c98c;
}
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .warn-banner strong { color: #ffd9a8; }
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .warn-banner.danger {
  background: #3a1f1f;
  border-color: #5a2a2a;
  color: #ff9d9d;
}
:is([data-theme="dark"],[data-theme="navy"],[data-theme="gray"]) .warn-banner.danger strong { color: #ffb8b8; }

/* ---------- Login ---------- */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--bg-soft);
  font-family: var(--font);
  margin: 0;
}
.login-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.login-card p.muted { margin: 0 0 8px; font-size: 13px; color: var(--text-soft); }
.login-card input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
}
.login-card button {
  background: var(--text);
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.login-card button:hover { filter: brightness(0.85); }
.login-card .brand-mark {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: white;
  font-weight: 700;
  font-size: 11px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 4px;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.25);
}
.brand-logo-sm {
  width: 36px;
  height: 36px;
  margin: 0;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.login-foot { font-size: 11px; color: var(--text-faint); text-align: center; margin: 8px 0 0; }
.login-card.error { border-color: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: auto;
    flex-direction: row;
    gap: 12px;
    padding: 10px 12px;
    align-items: center;
  }
  .sidebar .brand { border: none; padding: 0; margin: 0; flex-shrink: 0; }
  .sidebar .brand-text { display: none; }
  .sidebar .nav { flex-direction: row; overflow-x: auto; flex: 1; gap: 4px; }
  .sidebar .nav a { padding: 7px 10px; white-space: nowrap; font-size: 12.5px; }
  .sidebar .nav .dot { display: none; }
  .sidebar-foot { display: none; }
  .content { padding: 16px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; padding-bottom: 14px; margin-bottom: 14px; }
  .topbar-actions { flex-wrap: wrap; width: 100%; }
  .setting-input input, .setting-input select { min-width: 0; width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 22px; }
  .breakdown { grid-template-columns: 1fr; }
  /* Tables: scroll horizontally rather than blowing up the viewport */
  .card-body.flush { overflow-x: auto; }
  table { min-width: 600px; }
  /* Touch targets — 44pt minimum */
  .btn, .btn-ghost { min-height: 36px; padding: 8px 14px; }
  .nav a { min-height: 38px; }
}

@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 18px; }
  /* Detail modal — go full screen */
  #app + div[style*="position:fixed"] > div { max-width: 100% !important; max-height: 100vh !important; border-radius: 0 !important; }
}

.evt-modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
}
.evt-modal-head {
  background: var(--bg-elevated);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
button:focus-visible,
.btn:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
