/* ─────────────────────────────────────────────────────────────────────
   Theme tokens are defined in static/css/themes.css.
   This file consumes those tokens to style components — it should not
   define new color values. To add or change a theme, edit themes.css.
   ───────────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 285px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

.sidebar-nav-scroll {
  /* Nav claims the majority of vertical space; footer/rewards stack below. */
  flex: 1 1 58%;
  min-height: 180px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -16px;
  padding: 0 16px;
}

/* Account/footer stack at the bottom of the sidebar. Capped height + internal
   scroll so admin config (view-as, theme, etc.) never crushes the nav. */
.sidebar-footer {
  flex: 0 1 auto;
  max-height: 38%;
  min-height: 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--border);
  overflow-y: auto;
}

/* Compact config blocks inside the footer */
.sidebar-config-user {
  display: none;
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-config-user #user-name { font-weight: 600; }
.sidebar-config-user #user-category-display { color: var(--text-muted); font-size: 11px; }
.sidebar-config-user-sep { color: var(--text-muted); margin: 0 4px; }

.sidebar-config-block { margin-bottom: 6px; }
.sidebar-config-block:last-child { margin-bottom: 0; }

.sidebar-config-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.sidebar-config-input,
.sidebar-config-select {
  width: 100%;
  box-sizing: border-box;
  font-size: 11px;
  padding: 4px 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.sidebar-config-check {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-secondary);
  cursor: pointer;
}
.sidebar-config-check input { cursor: pointer; }
.sidebar-config-check-hint { color: var(--text-muted); font-weight: 400; }

.sidebar-config-active-row {
  display: none;
  margin-top: 4px;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.sidebar-config-active-label {
  font-size: 10px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.sidebar-config-exit-btn {
  font-size: 10px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-config-source {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sidebar-config-prefs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 6px;
}
.sidebar-config-pref { min-width: 0; }
.sidebar-footer .theme-picker { padding: 2px; }
.sidebar-footer .theme-picker-option {
  width: 24px;
  height: 24px;
  font-size: 13px;
}
.sidebar-config-logout {
  width: 100%;
  margin-top: 4px;
  font-size: 11px;
  padding: 5px 8px;
}

#view-as-client-results {
  max-height: 100px;
}

.sidebar-footer::-webkit-scrollbar {
  width: 6px;
}

.sidebar-footer::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Compact sidebar on vertically constrained displays */
@media (max-height: 760px) {
  .sidebar {
    padding: 12px 16px;
  }

  .logo {
    padding-bottom: 12px;
    margin-bottom: 12px;
  }

  .sidebar-footer {
    padding: 6px 0 0;
    max-height: 34%;
  }

  .sidebar-nav-scroll {
    min-height: 140px;
    flex-basis: 62%;
  }

  .nav-section {
    margin-bottom: 10px;
  }
}

.sidebar-nav-scroll::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar-nav-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  flex-shrink: 0;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: contain;
}

.logo-text {
  font-weight: 700;
  font-size: 18px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-section { margin-bottom: 16px; }

.nav-label {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 12px;
  margin-bottom: 4px;
}

/* Collapsible nav sections — buckets that auto-collapse on every page load
   and remember which individual items the user has clicked ("pinned"), so a
   collapsed bucket still surfaces just the modules they actually use.
   Pinning state lives in localStorage; see static/js/shared.js. */
.nav-label-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  margin: 0 0 4px;
  transition: var(--transition);
  gap: 8px;
}
.nav-label-toggle:hover { background: rgba(255,255,255,0.06); }
.nav-label-toggle > span:first-child { flex: 1; min-width: 0; }
.nav-section-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.nav-collapse-chevron {
  transition: transform 0.2s ease;
  opacity: 0.5;
  flex-shrink: 0;
}
.nav-collapsible.collapsed .nav-collapse-chevron { transform: rotate(-90deg); }

/* "+N" overflow pill: makes it obvious that a collapsed bucket still
   contains tools the user hasn't pinned yet. Hidden when expanded or
   when there's nothing extra to surface (count=0 → hidden via JS). */
.nav-section-overflow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1.4;
  display: none;
}
.nav-collapsible.collapsed .nav-section-overflow.has-overflow { display: inline-flex; }
.nav-label-toggle:hover .nav-section-overflow { color: var(--text-secondary); border-color: var(--border-light); }

/* The .nav-collapsible-items wrapper is just a grouping container now;
   visibility is decided per-item below so pinned items can stay visible
   even when the bucket header is collapsed. */
.nav-collapsible .nav-collapsible-items { overflow: hidden; }

/* When collapsed: hide every item EXCEPT pinned ones and the active page
   (the active page is always visible so users see "where they are"). */
.nav-collapsible.collapsed .nav-collapsible-items > .nav-item:not(.nav-item-pinned):not(.active) {
  display: none;
}

/* Fully shut (user clicked to close a bucket that still had pinned/active
   "inventory" sticking out): hide EVERY item, so the bucket collapses to just
   its header. Toggled by toggleNavSection() in static/js/shared.js. */
.nav-collapsible.nav-shut .nav-collapsible-items > .nav-item {
  display: none;
}

/* Pinned item — small unpin (×) button on hover, only when bucket expanded.
   Keeping the item itself visually identical to non-pinned items keeps the
   default look uncluttered; the pin state is implied by "this is showing
   even though the bucket is collapsed". */
.nav-item-unpin {
  margin-left: auto;
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.nav-item-unpin:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.nav-collapsible:not(.collapsed) .nav-item.nav-item-pinned:hover .nav-item-unpin { display: inline-flex; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: linear-gradient(135deg, var(--accent-dark), var(--accent)); color: white; }
.nav-item svg {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  flex-shrink: 0;
  display: block;
  opacity: 0.8;
}
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  font-size: var(--font-xs);
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 600;
}

/* Main Content */
.main {
  margin-left: 285px;
  min-height: 100vh;
  padding: 24px 32px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.header h1 { font-size: 28px; font-weight: 700; color: var(--text-primary); }
/* Color pass: subtle accent lead-in on the standard page title, matching
   the section-header cue. Token-driven so it recolors with the theme. */
.header h1:not(.no-accent) { position: relative; padding-left: 16px; }
.header h1:not(.no-accent)::before {
  content: ""; position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 0.78em; border-radius: 3px;
  background: var(--gradient-primary);
}
.header-actions { display: flex; gap: 12px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

.btn-success { background: linear-gradient(135deg, #059669, var(--success)); color: white; }
.btn-danger { background: linear-gradient(135deg, #dc2626, var(--error)); color: white; }
.btn-purple { background: linear-gradient(135deg, #7c3aed, var(--purple)); color: white; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
}

.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); }

.stat-card.mini {
  padding: 12px 16px;
  text-align: center;
  background: var(--bg-secondary);
}
.stat-card.mini .stat-value { font-size: var(--font-3xl); }
.stat-card.mini .stat-label { font-size: var(--font-xs); margin-top: 4px; }

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-light); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.stat-icon.cyan { background: rgba(6, 182, 212, 0.15); color: var(--cyan); }
.stat-icon svg { width: 22px; height: 22px; }

.stat-label { font-size: var(--font-sm); color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 32px; font-weight: 700; font-family: 'JetBrains Mono', monospace; margin-bottom: 4px; }
.stat-change { font-size: var(--font-sm); display: flex; align-items: center; gap: 4px; }
.stat-change.positive { color: var(--success); }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 24px; }

/* ═══════════════════════════════════════════════════════════════════════
   COLOR PASS — theme-token-driven accents on shared components.
   Every hue below is a theme token (--chart-1..5, --accent, gradients),
   so pastel / sage / midnight / demo all recolor automatically — nothing
   is hardcoded and nothing fights a theme. Purely decorative: semantic
   modifier classes (.stat-icon.green, .kpi-value.danger, …) still win.
   Opt a card OUT with the .no-accent class.
   ═══════════════════════════════════════════════════════════════════════ */

/* KPI / stat cards: a slim colored top stripe. When cards sit in a row the
   stripe cycles the chart ramp, so a KPI band reads as a spectrum instead
   of a run of gray boxes. */
.stat-card, .kpi-card { position: relative; }
.stat-card:not(.no-accent)::before,
.kpi-card:not(.no-accent)::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--stripe, var(--accent));
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0.85;
}
.stats-grid > .stat-card:nth-child(5n+1)::before,
.kpi-row   > .kpi-card:nth-child(5n+1)::before  { --stripe: var(--chart-1); }
.stats-grid > .stat-card:nth-child(5n+2)::before,
.kpi-row   > .kpi-card:nth-child(5n+2)::before  { --stripe: var(--chart-2); }
.stats-grid > .stat-card:nth-child(5n+3)::before,
.kpi-row   > .kpi-card:nth-child(5n+3)::before  { --stripe: var(--chart-3); }
.stats-grid > .stat-card:nth-child(5n+4)::before,
.kpi-row   > .kpi-card:nth-child(5n+4)::before  { --stripe: var(--chart-4); }
.stats-grid > .stat-card:nth-child(5n+5)::before,
.kpi-row   > .kpi-card:nth-child(5n+5)::before  { --stripe: var(--chart-5); }

/* Section / card headers: a short colored lead-in bar before the title,
   the same cue the engineering + audio pages use to anchor a section. */
.card-header .card-title:not(.no-accent) {
  position: relative;
  padding-left: 12px;
}
.card-header .card-title:not(.no-accent)::before {
  content: "";
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 0.95em;
  border-radius: 2px;
  background: var(--gradient-primary);
}

/* Active tab underline — gradient ramp on the shared underline-style tab bars
   used across dept pages, pipeline, event ops, outflow, etc. Pill-style tabs
   (.explorer-tab.active, .pipeline-tab.active) already fill with accent. */
.dept-tab.active,
.pm-tab.active,
.eo-tab.active,
.pl-tab.active,
.of-tab.active,
.sa-tab.active,
.sa-edit-tab.active,
.se-tab.active,
.ah-tab.active,
.cx-tab.active,
.eng-tab-active {
  position: relative;
  color: var(--accent);
  border-bottom-color: transparent;
}
.dept-tab.active::after,
.pm-tab.active::after,
.eo-tab.active::after,
.pl-tab.active::after,
.of-tab.active::after,
.sa-tab.active::after,
.sa-edit-tab.active::after,
.se-tab.active::after,
.ah-tab.active::after,
.cx-tab.active::after,
.eng-tab-active::after {
  content: "";
  position: absolute;
  left: 18%; right: 18%; bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--gradient-primary);
}

/* Stat icons without an explicit color class inherit the card stripe hue */
.stats-grid > .stat-card:nth-child(5n+1) .stat-icon:not(.blue):not(.green):not(.purple):not(.cyan) { background: var(--accent-subtle); color: var(--chart-1); }
.stats-grid > .stat-card:nth-child(5n+2) .stat-icon:not(.blue):not(.green):not(.purple):not(.cyan) { background: var(--success-bg-subtle); color: var(--chart-2); }
.stats-grid > .stat-card:nth-child(5n+3) .stat-icon:not(.blue):not(.green):not(.purple):not(.cyan) { background: var(--warning-bg-subtle); color: var(--chart-3); }
.stats-grid > .stat-card:nth-child(5n+4) .stat-icon:not(.blue):not(.green):not(.purple):not(.cyan) { background: var(--purple-bg-subtle); color: var(--chart-4); }
.stats-grid > .stat-card:nth-child(5n+5) .stat-icon:not(.blue):not(.green):not(.purple):not(.cyan) { background: var(--cyan-bg-subtle); color: var(--chart-5); }

/* Card hover: faint tinted lift keyed to each card's stripe */
.stat-card:not(.no-accent):hover,
.kpi-card:not(.no-accent):hover {
  border-color: var(--border-light);
  box-shadow: 0 6px 20px -6px rgba(var(--accent-rgb), 0.18);
}

/* Grids */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }

/* Dataset List */
.dataset-list { display: flex; flex-direction: column; gap: 12px; }

.dataset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: var(--transition);
}

.dataset-item:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-bg-subtle);
}
.dataset-info { display: flex; align-items: center; gap: 16px; }

.dataset-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.dataset-icon.venues { background: rgba(59, 130, 246, 0.15); }
.dataset-icon.leads { background: rgba(16, 185, 129, 0.15); }
.dataset-icon.accounts { background: rgba(139, 92, 246, 0.15); }

.dataset-name { font-weight: 600; margin-bottom: 2px; }
.dataset-meta { font-size: var(--font-sm); color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.dataset-status { display: flex; align-items: center; gap: 8px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.success { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.warning { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.status-dot.error { background: var(--error); box-shadow: 0 0 8px var(--error); }

/* Table */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  text-align: left;
  padding: 14px 16px;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: var(--font-base);
}

.data-table tr:hover td { background: var(--bg-secondary); }
.data-table .mono { font-family: 'JetBrains Mono', monospace; font-size: var(--font-sm); }

/* Tags */
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: var(--font-xs);
  font-weight: 600;
  margin: 2px;
}

.tag.blue { background: rgba(59, 130, 246, 0.2); color: var(--accent-light); }
.tag.green { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.tag.purple { background: rgba(139, 92, 246, 0.2); color: var(--purple); }
.tag.cyan { background: rgba(6, 182, 212, 0.2); color: var(--cyan); }
.tag.pink { background: rgba(236, 72, 153, 0.2); color: var(--pink); }
.tag.orange { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

/* Log Console */
.log-console {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--font-sm);
  max-height: 400px;
  overflow-y: auto;
}

/* NOTE: do NOT use display:flex on .log-line — flex items are treated as
   block-level for copy/paste in Chrome, which doubles the line count when
   users export the console (each <span> becomes its own text line). Inline-block
   on .log-time keeps the visual column alignment without that copy artifact. */
.log-line { padding: 4px 0; }
.log-time { color: var(--text-muted); display: inline-block; min-width: 92px; }
.log-msg { color: var(--text-secondary); }
.log-msg.success { color: var(--success); }
.log-msg.error { color: var(--error); }
.log-msg.warning { color: var(--warning); }
.log-msg.step-transition {
  color: var(--accent);
  font-weight: 600;
  border-top: 1px solid var(--border);
  padding-top: 4px;
  margin-top: 4px;
}

/* Progress */
.progress-container { margin: 20px 0; }
.progress-bar { height: 8px; background: var(--bg-secondary); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--purple)); border-radius: 4px; transition: width 0.3s ease; }
.progress-text { font-size: var(--font-sm); color: var(--text-muted); margin-top: 8px; text-align: center; }

/* Filters */
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-label { font-size: var(--font-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; }

.filter-input, .filter-select {
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
}

.filter-input:focus, .filter-select:focus { outline: none; border-color: var(--accent); }

.filter-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* Responsive filter grid */
@media (max-width: 1200px) {
  #filter-panel-body > div[style*="grid-template-columns: repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 768px) {
  #filter-panel-body > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}
.filter-label { font-size: var(--font-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* Multiselect dropdown */
.multiselect {
  position: relative;
  width: 100%;
}
.multiselect-trigger {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--font-base);
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
}
.multiselect-trigger:hover { border-color: var(--accent); }
.multiselect-trigger.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
.multiselect-trigger .placeholder { color: var(--text-muted); }
.multiselect-trigger .selected-preview {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.multiselect-trigger .count-badge {
  background: var(--accent);
  color: var(--text-on-accent);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: var(--font-xs);
  font-weight: 600;
  flex-shrink: 0;
}
.multiselect-trigger .arrow {
  color: var(--text-muted);
  font-size: var(--font-xs);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.multiselect-trigger.active .arrow { transform: rotate(180deg); }
.multiselect-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  max-height: 320px;
  overflow: hidden;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
}
.multiselect-dropdown.open { display: flex; flex-direction: column; }
.multiselect-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}
.multiselect-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}
.multiselect-search input:focus { outline: none; border-color: var(--accent); }
.multiselect-search input::placeholder { color: var(--text-muted); }
.multiselect-options { 
  padding: 6px 0; 
  overflow-y: auto; 
  flex: 1;
  min-height: 0;
}
.multiselect-option {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--font-base);
  transition: background 0.15s;
  white-space: nowrap;
}
.multiselect-option:hover { background: var(--bg-tertiary); }
.multiselect-option.selected { background: rgba(59, 130, 246, 0.15); }
.multiselect-option .checkbox {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.multiselect-option:hover .checkbox { border-color: var(--accent); }
.multiselect-option.selected .checkbox {
  background: var(--accent);
  border-color: var(--accent);
}
.multiselect-option.selected .checkbox::after {
  content: '✓';
  color: white;
  font-size: 11px;
  font-weight: bold;
}
.multiselect-option.excluded { background: rgba(239, 68, 68, 0.12); }
.multiselect-option.excluded .checkbox {
  background: var(--danger, #ef4444);
  border-color: var(--danger, #ef4444);
}
.multiselect-option.excluded .checkbox::after {
  content: '✕';
  color: white;
  font-size: 11px;
  font-weight: bold;
}
.multiselect-option.excluded .option-label {
  text-decoration: line-through;
  opacity: 0.7;
}
.multiselect-option .option-label { flex: 1; min-width: 0; }
.multiselect-option .option-count {
  color: var(--text-muted);
  font-size: var(--font-xs);
  flex-shrink: 0;
  margin-left: 8px;
}
.multiselect-actions {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  flex-shrink: 0;
}
.multiselect-actions button {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.15s;
}
.multiselect-actions button:hover { background: var(--bg-tertiary); border-color: var(--border-light); }
.multiselect-actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.multiselect-actions button.primary:hover { background: var(--accent-dark); }

/* Ensure filter groups don't clip dropdowns */
.filter-group { overflow: visible !important; }
#filter-panel-body { overflow: visible !important; }
#filter-panel-body > div { overflow: visible !important; }
#hierarchy-filter-panel { overflow: visible !important; }
#hierarchy-filter-panel .card-body { overflow: visible !important; }

/* ═══════════════════════════════════════════════════════════════════════
   FILTER PANEL SECTIONS - Organized, Labeled, Idiot-Proof
   ═══════════════════════════════════════════════════════════════════════ */

.filter-panel-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: visible;
}

.filter-panel-section.collapsed .filter-section-content {
  display: none;
}

.filter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  border-radius: 10px;
  transition: background 0.15s;
}

.filter-section-header:hover {
  background: var(--bg-tertiary);
}

.filter-section-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-section-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
}

.filter-section-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.filter-section-name {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.filter-section-desc {
  font-size: var(--font-xs);
  color: var(--text-muted);
  font-weight: 400;
}

.filter-section-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-section-badge {
  background: var(--accent);
  color: var(--text-on-accent);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: var(--font-2xs);
  font-weight: 600;
  display: none;
}

.filter-section-badge.active {
  display: inline-block;
}

.filter-section-toggle {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.filter-panel-section.collapsed .filter-section-toggle {
  transform: rotate(-90deg);
}

.filter-section-content {
  padding: 0 16px 16px 16px;
  overflow: visible;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.filter-section-grid {
  display: grid;
  gap: 12px;
  overflow: visible;
}

.filter-section-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.filter-section-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.filter-section-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.filter-section-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 1200px) {
  .filter-section-grid.cols-4,
  .filter-section-grid.cols-5 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .filter-section-grid { grid-template-columns: 1fr !important; }
}

/* Filter group with help tooltip */
.filter-group-enhanced {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  overflow: visible;
  position: relative;
}

/* Ensure enhanced groups in grids work */
.filter-section-grid .filter-group-enhanced {
  overflow: visible;
}

.filter-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  cursor: help;
  position: relative;
}

.filter-help:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #1e293b;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 400;
  color: #e2e8f0;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  z-index: 10000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  line-height: 1.5;
  text-transform: none;
  letter-spacing: normal;
}

.filter-help:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 4px;
  border: 6px solid transparent;
  border-top-color: #1e293b;
  z-index: 10001;
}

/* ── KPI Card Tooltips ─────────────────────────────────────── */
[data-kpi-tip] {
  position: relative;
  cursor: help;
}
[data-kpi-tip]::after {
  content: attr(data-kpi-tip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  border: 1px solid var(--border-light, #334155);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 400;
  font-family: 'Inter', sans-serif;
  color: #e2e8f0;
  white-space: normal;
  width: max-content;
  max-width: 300px;
  z-index: 10000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  line-height: 1.55;
  text-transform: none;
  letter-spacing: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
}
[data-kpi-tip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #0f172a;
  z-index: 10001;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
[data-kpi-tip]:hover::after,
[data-kpi-tip]:hover::before {
  opacity: 1;
}

/* Color-coded section borders */
.filter-panel-section.section-venue {
  border-left: 4px solid #10b981;
}
.filter-panel-section.section-contact {
  border-left: 4px solid #3b82f6;
}
.filter-panel-section.section-account {
  border-left: 4px solid #8b5cf6;
}
.filter-panel-section.section-attribution {
  border-left: 4px solid #f59e0b;
}
.filter-panel-section.section-tags {
  border-left: 4px solid #ec4899;
}
.filter-panel-section.section-search {
  border-left: 4px solid #6b7280;
}

/* Collapsed state styling */
.filter-panel-section.collapsed {
  opacity: 0.85;
}
.filter-panel-section.collapsed:hover {
  opacity: 1;
}

/* Section with active filters gets subtle glow */
.filter-panel-section:has(.filter-section-badge.active) {
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3);
}

/* Section color accents for icons */
.section-venue .filter-section-icon { color: #10b981; }
.section-contact .filter-section-icon { color: #3b82f6; }
.section-account .filter-section-icon { color: #8b5cf6; }
.section-attribution .filter-section-icon { color: #f59e0b; }
.section-tags .filter-section-icon { color: #ec4899; }
.section-search .filter-section-icon { color: #6b7280; }

/* Subsection divider */
.filter-subsection {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.filter-subsection-label {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Quick filter tip callouts */
.filter-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(59, 130, 246, 0.08);
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.filter-tip-icon {
  font-size: 14px;
  flex-shrink: 0;
}

/* Actions row */
.filter-actions-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
}

/* Page sections */

/* Categorization Results */
.result-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}

.result-item:hover { border-color: var(--accent); }
.result-title { font-weight: 600; margin-bottom: 8px; }
.result-meta { font-size: var(--font-sm); color: var(--text-muted); margin-bottom: 12px; }
.result-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.result-description { font-size: var(--font-sm); color: var(--text-secondary); margin-top: 12px; max-height: 60px; overflow: hidden; }

/* Data Explorer */
.explorer-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.explorer-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.explorer-tab.active { background: var(--accent); color: var(--text-on-accent); }
.explorer-tab .tab-count {
  font-size: var(--font-xs);
  padding: 2px 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
}
.explorer-tab.active .tab-count { background: rgba(255,255,255,0.3); }

/* Pipeline Tabs */
.pipeline-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-base);
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}
.pipeline-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.pipeline-tab.active { background: var(--accent); color: white; }
.pipeline-content { display: none; }
.pipeline-content.active { display: block; }

.filter-section { margin-bottom: 16px; }
.filter-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
}
.filter-option:hover { background: var(--bg-tertiary); }
.filter-option input[type="checkbox"] { margin: 0; }
.filter-option .count { color: var(--text-muted); margin-left: auto; font-size: 11px; }

.explorer-table th { cursor: pointer; user-select: none; white-space: nowrap; }
.explorer-table th:hover { background: var(--bg-tertiary); }
.explorer-table th .sort-icon { opacity: 0.4; margin-left: 4px; }
.explorer-table th.sorted .sort-icon { opacity: 1; color: var(--accent); }
.explorer-table td { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.explorer-table td.wrap { white-space: normal; max-width: 400px; }
.explorer-table tr.clickable { cursor: pointer; }
.explorer-table tr.clickable:hover td { background: var(--bg-secondary); }

.modal { position: relative; background: var(--bg-primary); border-radius: 12px; width: 90%; max-width: 900px; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.modal-overlay { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.7); }
.modal-overlay.active { display: flex; }
.modal-content { position: relative; background: var(--bg-primary); border-radius: 12px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; padding: 0; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }

.detail-section { margin-bottom: 24px; }
.detail-section h4 { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.detail-item { background: var(--bg-secondary); padding: 12px; border-radius: 8px; }
.detail-item .label { font-size: var(--font-xs); color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.detail-item .value { font-size: var(--font-base); color: var(--text-primary); word-break: break-word; }

/* Venue detail modal */
.venue-detail-modal { max-width: 600px; padding: 24px; }
.venue-detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.venue-detail-grid .detail-item { background: var(--bg-secondary); padding: 10px; border-radius: 6px; }
.venue-detail-grid .detail-label { font-size: var(--font-xs); color: var(--text-muted); display: block; margin-bottom: 4px; }
.venue-detail-grid .detail-value { font-size: var(--font-sm); color: var(--text-primary); }
.detail-label { font-size: var(--font-xs); color: var(--text-muted); font-weight: 600; text-transform: uppercase; }

/* Venue info button */
.btn-icon { background: none; border: none; padding: 4px 8px; cursor: pointer; opacity: 0.5; transition: opacity 0.2s; font-size: 14px; }
.btn-icon:hover { opacity: 1; }
.venue-row:hover .btn-icon { opacity: 0.8; }
.venue-row.is-session { background: var(--bg-tertiary); }
.venue-row.is-session:hover { background: var(--bg-secondary); }

/* Venue Summary Card - Compact collapsed */
.venue-summary-card {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  margin: 2px 0 4px 0;
}
.venue-summary-grid {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 10px;
}
.venue-summary-main { }
.venue-desc, .venue-speakers {
  margin-bottom: 12px;
}
.venue-desc p, .venue-speakers p {
  margin: 6px 0 0 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.desc-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}
.venue-summary-meta {
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 12px;
}
.meta-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
}
.meta-label { color: var(--text-muted); }
.meta-value { color: var(--text-primary); font-weight: 500; }
.meta-link {
  display: block;
  margin-top: 12px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: 6px;
  text-align: center;
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  transition: background 0.2s;
}
.meta-link:hover { background: var(--accent); color: white; }
.venue-tags {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.mini-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg-primary);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-secondary);
}
.mini-tag .confidence-dot { width: 6px; height: 6px; border-radius: 50%; }
.tag-conf { opacity: 0.6; font-size: var(--font-2xs); }

/* ─────────────────────────────────────────────────────────────────────
   Theme-specific variable definitions live in static/css/themes.css.
   The blocks below are per-component contrast/visual patches that
   apply when a specific theme is active. They fire via the
   .pastel-mode bridge class which static/js/theme_toggle.js applies
   when the pastel theme is selected.

   New theme-wide tokens (e.g. --gradient-primary) are now in themes.css,
   so most of these patches will be removed over time as components
   migrate to consuming tokens directly.
   ───────────────────────────────────────────────────────────────────── */

.pastel-mode .nav-item.active {
    background: var(--gradient-primary);
    color: var(--text-on-accent);
}

.pastel-mode .nav-badge,
.pastel-mode .btn-primary,
.pastel-mode .btn-success,
.pastel-mode .btn-danger,
.pastel-mode .btn-purple,
.pastel-mode .explorer-tab.active,
.pastel-mode .pipeline-tab.active,
.pastel-mode .tag-chip.active,
.pastel-mode .filter-logic-operator.active,
.pastel-mode .multiselect-option .checkbox.checked::after,
.pastel-mode .filter-section-badge {
  color: #fff !important;
}

/* Pastel mode: Ensure selected/count badges have contrast */
.pastel-mode .multiselect-trigger .count {
  background: var(--accent-dark);
  color: #fff;
}

.pastel-mode .filter-chip {
  color: #fff;
}

/* Pastel mode: Fix hierarchy and data table text */
.pastel-mode .hierarchy-row .row-title,
.pastel-mode .hierarchy-row .row-subtitle,
.pastel-mode .data-table td,
.pastel-mode .data-table th,
.pastel-mode .lead-contact-row .contact-name,
.pastel-mode .lead-contact-row .contact-meta {
  color: var(--text-primary);
}

/* Pastel mode: Additional overrides for inline white text */
.pastel-mode .tag,
.pastel-mode .mini-tag {
  color: var(--text-primary);
}

.pastel-mode .tag.blue,
.pastel-mode .tag.green,
.pastel-mode .tag.purple,
.pastel-mode .tag.cyan,
.pastel-mode .tag.pink,
.pastel-mode .tag.orange {
  color: var(--text-primary);
}

/* Pastel mode: Fix background colors on filter chips and active states */
.pastel-mode [style*="background: var(--accent)"],
.pastel-mode [style*="background:var(--accent)"] {
  color: #fff !important;
}

/* Pastel mode: Improve readability of muted text */
.pastel-mode .text-muted,
.pastel-mode [style*="color: var(--text-muted)"] {
  color: #9d174d !important;
}

/* Pastel mode: Explorer tabs */
.pastel-mode .explorer-tabs {
  background: #fdf2f8 !important;
}

.pastel-mode .explorer-tab {
  color: #881337;
}

.pastel-mode .explorer-tab:hover {
  background: #fce7f3;
}

.pastel-mode .explorer-tab.active {
  background: linear-gradient(135deg, #f472b6, #db2777) !important;
  color: #fff !important;
}

.pastel-mode .explorer-tab .tab-count {
  background: rgba(255, 255, 255, 0.25);
}

/* Pastel mode: Better contrast for sidebar */
.pastel-mode .sidebar {
  background: #fdf2f8;
  border-color: #fbcfe8;
}

/* Pastel mode: Header/card backgrounds */  
.pastel-mode .header,
.pastel-mode .card {
  background: #fff;
  border-color: #fecdd3;
}

/* Pastel mode: Modal headers with gradients need white text */
.pastel-mode .modal-header[style*="background: linear-gradient"] h3 {
  color: #fff !important;
}

/* Pastel mode: Intelligence pages contrast fixes */
.pastel-mode .mac-card { --mac-bg: #fff; --mac-border: #fecdd3; --mac-text: #881337; --mac-muted: #9d174d; --mac-accent: #db2777; }
.pastel-mode .mac-chip { background: rgba(219,39,119,.08); color: #881337; }
.pastel-mode .mac-summary-bar { background: linear-gradient(135deg, rgba(244,114,182,.1) 0%, transparent 60%); }
.pastel-mode .mac-section-header { color: #9d174d; }
.pastel-mode .mac-kpi { background: rgba(219,39,119,.06); }
.pastel-mode .mac-bi-tag { background: rgba(219,39,119,.1); color: #9d174d; }
.pastel-mode .ri-expand-panel { background: rgba(244,114,182,.06); border-left-color: #db2777; }
.pastel-mode .ri-forensic-num { background: rgba(219,39,119,.12); color: #db2777; }
.pastel-mode .ri-filter-bar { background: #fff; border-color: #fecdd3; }
.pastel-mode .ri-filter-select, .pastel-mode .gi-filter-select { background: #fff5f7; border-color: #fecdd3; color: #881337; }
.pastel-mode .ei-table-container { background: #fff; border-color: #fecdd3; }
.pastel-mode .ei-brand-card { background: #fff; border-color: #fecdd3; }
.pastel-mode .ei-select { background: #fff5f7; border-color: #fecdd3; color: #881337; }
.pastel-mode .ei-search { background: #fff5f7; border-color: #fecdd3; color: #881337; }
.pastel-mode .ei-matrix-state-btn { color: #881337; }
.pastel-mode .ei-matrix-state-btn.active { background: rgba(219,39,119,.1); color: #db2777; }
.pastel-mode .ei-matrix-card { background: #fff; border-color: #fecdd3; }
.pastel-mode .ei-explainer { background: #fff; border-color: #fecdd3; border-left-color: #db2777; color: #9d174d; }
.pastel-mode .ei-opp-state { background: rgba(16,185,129,.1); color: #065f46; }
.pastel-mode .ei-opp-cat { background: rgba(59,130,246,.1); color: #1e40af; }
.pastel-mode .ei-opp-event { background: rgba(168,85,247,.1); color: #6b21a8; }
.pastel-mode .gi-card { background: #fff; border-color: #fecdd3; }
.pastel-mode .gi-explainer { border-left-color: #db2777; }
.pastel-mode .gi-funnel-label { color: #fff; }
.pastel-mode .gi-bar-label { color: #881337; }
.pastel-mode .gi-bar-count { color: #9d174d; }
.pastel-mode .si-kpi-card { background: #fff; border-color: #fecdd3; }
.pastel-mode .sys-summary { background: #fff; border-color: #fecdd3; }
.pastel-mode .sys-summary-stat { background: #fff5f7; }
.pastel-mode .sys-model-card { background: #fff; border-color: #fecdd3; }
.pastel-mode .sys-docs-table th { background: #fff5f7; }
.pastel-mode .sys-docs-feat { background: #fff5f7; }
.pastel-mode .sys-freshness-card { background: #fff; border-color: #fecdd3; }
.pastel-mode .sys-plan-block { background: #fff5f7; border-color: #fecdd3; }
.pastel-mode .sys-plan-model-name { color: #e11d48; border-bottom-color: #fecdd3; }
.pastel-mode .sys-plan-param { background: #fff; color: #9d174d; }
.pastel-mode .sys-plan-rec:hover { background: rgba(225,29,72,.04); }
.pastel-mode .sys-plan-invalid { background: rgba(239,68,68,.08); }
.pastel-mode .sys-model-headline { background: #fff0f3; border-left-color: #e11d48; color: #9d174d; }
.pastel-mode .sys-metric-chip { font-weight: 600; }
.pastel-mode .sys-chip-good { background: #d1fae5; color: #065f46; }
.pastel-mode .sys-chip-warn { background: #fef3c7; color: #92400e; }
.pastel-mode .sys-chip-bad { background: #fee2e2; color: #991b1b; }
.pastel-mode .sys-chip-info { background: #e0e7ff; color: #3730a3; }
.pastel-mode .sys-feat-tag { background: #fff5f7; color: #881337; }
.pastel-mode .sys-feat-imp { color: #9d174d; }
.pastel-mode .sys-summary-llm code { background: #fff5f7; color: #9d174d; }
.pastel-mode .sys-summary-llm h2, .pastel-mode .sys-summary-llm h3 { color: #881337; }
.pastel-mode .ri-forensic-text { color: #881337; }
.pastel-mode .ri-forensic-step { color: #9d174d; }
.pastel-mode .ri-forensic-num { background: rgba(219,39,119,.12); color: #db2777; }
.pastel-mode .ri-forensic-chips { border-top-color: #fecdd3; }
.pastel-mode .ri-expand-loading { color: #9d174d; }
.pastel-mode .gi-expand-panel { background: rgba(244,114,182,.06); border-left-color: #db2777; }

/* ── Pastel mode: contrast fixes for components that haven't been
   tokenized yet. Each entry below is a candidate for removal once the
   underlying component switches to var(--accent-bg)/var(--accent-on-subtle).
   ─────────────────────────────────────────────────────────────────── */

/* Generic catch-all for any not-yet-tokenized "*-badge" / "*-view-btn"
   /"*-owner-chip" classes still using hard-coded blue rgba. Once a
   component is tokenized, these wildcards become harmless no-ops. */
.pastel-mode .stat-badge,
.pastel-mode [class*="-badge"]:not(.oh-badge):not(.ah-badge):not(.ah-msp-verdict-badge) {
  background: rgba(190,24,93,.12);
  color: #9d174d;
}
.pastel-mode [class*="-view-btn"]:not(.ah-view-btn):not(.oh-view-btn) {
  background: rgba(190,24,93,.1);
  color: #be185d;
}
.pastel-mode [class*="-view-btn"]:not(.ah-view-btn):not(.oh-view-btn):hover {
  background: rgba(190,24,93,.18);
}
.pastel-mode [class*="-owner-chip"]:not(.ah-wh-owner-chip):not(.oh-owner-chip) {
  background: rgba(190,24,93,.1);
  color: #9d174d;
}

/* Stat icon circles */
.pastel-mode .stat-icon.blue {
  background: rgba(190,24,93,.12);
  color: #be185d;
}

/* Tags — use stronger backgrounds in pastel mode */
.pastel-mode .tag.blue { background: rgba(59,130,246,.15); color: #1d4ed8; }
.pastel-mode .tag.green { background: rgba(16,185,129,.15); color: #065f46; }
.pastel-mode .tag.purple { background: rgba(139,92,246,.15); color: #5b21b6; }
.pastel-mode .tag.cyan { background: rgba(6,182,212,.15); color: #0e7490; }
.pastel-mode .tag.pink { background: rgba(236,72,153,.15); color: #9d174d; }
.pastel-mode .tag.orange { background: rgba(245,158,11,.15); color: #92400e; }

/* Generic: any inline rgba(59,130,246,...) tinted elements */
.pastel-mode [style*="rgba(59,130,246"] {
  color: #be185d !important;
}
.pastel-mode [style*="rgba(59, 130, 246"] {
  color: #be185d !important;
}

/* btn-outline in pastel (used in account brief, etc.) */
.pastel-mode .btn-outline,
.pastel-mode .btn-create-opp {
  color: #be185d;
  border-color: rgba(190,24,93,.3);
}
.pastel-mode .btn-outline:hover,
.pastel-mode .btn-create-opp:hover {
  background: rgba(190,24,93,.08);
}

/* Filter chips / pills with accent backgrounds */
.pastel-mode .filter-chip {
  background: #be185d;
  color: #fff;
}

/* Multiselect trigger count */
.pastel-mode .multiselect-trigger .count {
  background: #be185d;
  color: #fff;
}

/* Search inputs in pastel */
.pastel-mode .ah-search,
.pastel-mode .oh-search,
.pastel-mode input[type="text"],
.pastel-mode input[type="search"],
.pastel-mode select {
  color: #881337;
}

/* Nav item badges */
.pastel-mode .nav-badge {
  background: #be185d;
  color: #fff;
}

/* Pipeline/explorer active tabs already handled — ensure gradient contrast */
.pastel-mode .pipeline-tab.active {
  background: linear-gradient(135deg, #be185d, #f472b6) !important;
  color: #fff !important;
}

/* Home page + owner hub: inline-styled badges/pills (most common pattern) */
.pastel-mode .rep-row [style*="background:rgba(59"],
.pastel-mode .rep-row [style*="background: rgba(59"],
.pastel-mode tr [style*="background:rgba(59"],
.pastel-mode tr [style*="background: rgba(59"] {
  background: rgba(190,24,93,.1) !important;
  color: #9d174d !important;
}

/* Owner Hub + Admin Hub: components tokenized — no per-theme patches needed.
   .oh-badge, .oh-owner-badge, .oh-proposal-type.pipeline, .oh-stage-early,
   .oh-viewas-back, .oh-chip.active, .oh-scope-toggle button.active,
   .oh-qa-btn.primary, .ah-badge, .ah-team-chip.active, .ah-view-btn,
   .ah-wh-owner-chip, .ah-wh-btn.edit, .ah-msp-verdict-badge.ready_to_send
   all consume var(--accent-bg) / var(--accent-on-subtle) directly. */

/* Components that still hard-code colors: */
.pastel-mode .oh-event-acct {
  background: rgba(190,24,93,.08);
}
.pastel-mode .oh-link {
  color: #be185d;
}

/* Event Operations pastel overrides */
.pastel-mode .eo-tag-new .eo-stag {
  background: rgba(190,24,93,.15);
}
.pastel-mode .eo-sessions-badge {
  background: rgba(190,24,93,.1);
}

/* Tag Manager pastel overrides */
.pastel-mode .tm-kpi-accent {
  background: rgba(190,24,93,.08);
}
.pastel-mode .tm-gap-type {
  background: rgba(190,24,93,.08);
}

/* Home page pastel overrides */
.pastel-mode .home-card-icon.blue {
  background: rgba(190,24,93,.12);
}
.pastel-mode .home-role-badge.client {
  background: rgba(190,24,93,.1);
  border-color: rgba(190,24,93,.25);
}

/* ── End pastel contrast fixes ───────────────────────────────────────────── */

.spark-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  display: flex;
  overflow: hidden;
  margin-top: 6px;
  width: 100px;
}
.spark-segment { height: 100%; transition: width 0.3s; min-width: 3px; }
.spark-label { font-size: var(--font-2xs); color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }

/* Tag Category Chips */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: var(--font-sm);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
}
.tag-chip:hover { 
  background: var(--bg-tertiary);
  border-color: var(--primary);
}
.tag-chip.active {
  background: var(--primary);
  color: var(--text-on-accent);
  border-color: var(--primary);
}
.tag-chip .chip-count {
  background: rgba(255,255,255,0.2);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: var(--font-xs);
  font-weight: 500;
}
.tag-chip:not(.active) .chip-count {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}
.tag-chip .confidence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.conf-high { background: #22c55e; }

/* Tag Logic Toggle */
.tag-logic-btn {
  background: transparent;
  color: var(--text-muted);
}
.tag-logic-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.tag-logic-btn.active {
  background: var(--primary);
  color: white;
}

/* Filter Expression Operators */
.filter-logic-operator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  font-size: var(--font-2xs);
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  margin: 0 2px;
}
.filter-logic-operator.and {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.filter-logic-operator.or {
  background: var(--primary);
  color: white;
  border: 1px solid var(--primary);
}
.filter-logic-operator.and_not {
  background: var(--danger, #e74c3c);
  color: white;
  border: 1px solid var(--danger, #e74c3c);
}
.filter-logic-operator:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.filter-logic-operator.tag-internal {
  font-size: var(--font-2xs);
  padding: 1px 6px;
}
.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 6px;
  border: 1px dashed var(--primary);
}

/* Advanced Query Builder */
.query-group {
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  position: relative;
}
.query-group.highlight {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}
.query-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.query-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.query-group-delete {
  margin-left: auto;
  padding: 2px 8px;
  font-size: 10px;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 4px;
  cursor: pointer;
}
.query-group-delete:hover {
  background: var(--danger);
  color: white;
}
.query-group-content {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.query-condition {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg-secondary);
  border-radius: 6px;
  font-size: 11px;
  border: 1px solid var(--border);
}
.query-condition-field {
  color: var(--primary);
  font-weight: 600;
}
.query-condition-value {
  color: var(--text-primary);
}
.query-condition-remove {
  cursor: pointer;
  color: var(--text-muted);
  margin-left: 4px;
}
.query-condition-remove:hover {
  color: var(--danger);
}

/* Negate toggle button */
.query-negate-btn {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.query-negate-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}
.query-negate-btn.negate-active {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* Negated condition display */
.query-condition-negated {
  border-color: var(--danger) !important;
  background: rgba(239, 68, 68, 0.08) !important;
}
.query-negate-indicator {
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-right: 2px;
  flex-shrink: 0;
}
.query-group-operator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}
.query-add-condition {
  padding: 4px 8px;
  font-size: 10px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
}
.query-add-condition:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.query-value-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  background: rgba(139, 92, 246, 0.15);
  border-radius: 4px;
}

/* Advanced Query Builder - Layout & Containers */
#advanced-filter-mode {
  animation: fadeIn 0.15s ease;
}
#query-groups-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.query-group {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.query-condition-editor {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 8px;
}
.query-condition-editor select,
.query-condition-editor input {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.query-condition-editor select {
  max-width: 200px;
}
.query-condition-editor input {
  width: 200px;
}
.query-condition-values {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.query-condition-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.query-condition-actions button {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.query-condition-actions .btn-done {
  background: var(--primary);
  color: white;
  border: none;
}
.query-condition-actions .btn-cancel {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.query-preview-section {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border-radius: 6px;
  border: 1px solid var(--border);
}
#query-preview {
  width: 100%;
  min-height: 60px;
  font-size: 11px;
  font-family: monospace;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  resize: vertical;
}
.query-account-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 150px;
  overflow-y: auto;
  z-index: 100;
}
.account-search-result {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}
.account-search-result:hover {
  background: var(--bg-secondary);
}
.account-search-result:last-child {
  border-bottom: none;
}

.conf-medium { background: #f59e0b; }
.conf-low { background: #ef4444; }

/* Hierarchy View */
.stat-mini { font-size: var(--font-md); color: var(--text-secondary); }
.stat-mini span { font-weight: 600; color: var(--text-primary); font-size: var(--font-xl); }

.breadcrumb { font-size: 13px; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { color: var(--text-muted); margin: 0 8px; }

/* Hierarchy Mode Toggle */
.toggle-mode-btn {
  padding: 6px 12px;
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.toggle-mode-btn:hover {
  background: var(--bg-secondary);
  color: var(--text);
}
.toggle-mode-btn.active {
  background: var(--accent);
  color: var(--bg);
}

/* Lead-first hierarchy styles */
.lead-contact-row {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.lead-contact-row:hover { background: var(--bg-secondary); }
.lead-contact-row.expanded { background: var(--bg-secondary); border-bottom: none; }
.lead-contact-row .expand-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  font-size: 14px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.lead-contact-row.expanded .expand-icon { transform: rotate(90deg); }
.lead-contact-row .contact-info { flex: 1; }
.lead-contact-row .contact-name { font-weight: 600; font-size: var(--font-md); margin-bottom: 2px; }
.lead-contact-row .contact-meta { font-size: var(--font-sm); color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.lead-contact-row .engagement-stats {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: var(--font-sm);
}
.lead-contact-row .engagement-stats .stat-value { font-weight: 600; color: var(--accent); margin-right: 4px; }

.hierarchy-row {
  display: flex;
  align-items: center;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.hierarchy-row:hover { background: var(--bg-secondary); }
.hierarchy-row.expanded { background: var(--bg-secondary); border-bottom: none; }

.hierarchy-row .expand-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-right: 6px;
  transition: transform 0.2s;
  font-size: 10px;
}
.hierarchy-row.expanded .expand-icon { transform: rotate(90deg); }

.hierarchy-row .row-info { flex: 1; min-width: 0; }
.hierarchy-row .row-title { font-weight: 500; font-size: var(--font-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.hierarchy-row .row-subtitle { font-size: var(--font-xs); color: var(--text-muted); line-height: 1.2; }

.hierarchy-row .row-stats {
  display: flex;
  gap: 12px;
  font-size: var(--font-xs);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.hierarchy-row .row-stats .stat-value { font-weight: 600; color: var(--accent); font-size: var(--font-sm); margin-right: 2px; }

.hierarchy-children {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  padding: 2px 0;
  box-shadow: inset 0 1px 2px -1px rgba(0,0,0,0.1);
}

/* Business Intelligence Card - Compact collapsed state */
.intel-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.05) 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 4px;
  padding: 4px 10px;
  margin: 2px 8px 2px 36px;
  font-size: 11px;
}
.intel-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  font-weight: 500;
  color: var(--accent);
  font-size: 11px;
  line-height: 1.2;
}
.intel-card-header .icon { font-size: 12px; }
.intel-summary {
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 6px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.15);
  border-radius: 4px;
  font-size: 11px;
}
.intel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.intel-item {
  background: rgba(0,0,0,0.1);
  border-radius: 8px;
  padding: 10px 14px;
}
.intel-item-label {
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.intel-item-value {
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.4;
}
.intel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.intel-tag {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
}
.intel-no-data {
  color: var(--text-muted);
  font-style: italic;
  padding: 12px;
  text-align: center;
}
.hierarchy-children .hierarchy-row {
  padding-left: 28px;
  padding-top: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.hierarchy-children .hierarchy-children .hierarchy-row {
  padding-left: 44px;
  background: rgba(0,0,0,0.1);
}

.lead-row {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 1fr 1fr 0.8fr 40px 50px;
  gap: 8px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  align-items: center;
}
.lead-row:hover { background: var(--bg-secondary); }
.lead-row.header {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 9px;
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 3px 12px;
}
.sort-header { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 4px; }
.sort-header:hover { color: var(--text-primary); }

/* Sticky active filters bar */
#hierarchy-active-filters {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

/* Sticky context header for leads - shows when scrolling */
.sticky-context-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, rgba(26, 34, 52, 0.98) 0%, rgba(17, 24, 39, 0.98) 100%);
  border-bottom: 2px solid var(--accent);
  display: none;
  flex-direction: column;
  font-size: 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.sticky-context-header.visible { display: flex; }
.sticky-context-header .context-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(59, 130, 246, 0.05);
}
.sticky-context-header .context-account {
  color: var(--accent-light);
  font-weight: 600;
  flex-shrink: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sticky-context-header .context-category {
  color: var(--purple);
  font-size: 11px;
  padding: 2px 8px;
  background: rgba(139, 92, 246, 0.15);
  border-radius: 4px;
  flex-shrink: 0;
}
.sticky-context-header .context-venue {
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.sticky-context-header .context-separator {
  color: var(--text-muted);
  flex-shrink: 0;
}
.sticky-context-header .context-stats {
  color: var(--accent);
  font-size: 11px;
  flex-shrink: 0;
  font-weight: 600;
  padding: 2px 8px;
  background: rgba(59, 130, 246, 0.15);
  border-radius: 4px;
}
.sticky-context-header .context-lead-headers {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 1fr 1fr 0.8fr 50px 60px;
  gap: 16px;
  padding: 8px 24px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-secondary);
}

/* Floating Action Buttons Container */
.floating-actions {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  gap: 8px;
  align-items: center;
}
.floating-action-btn {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  opacity: 0.95;
  backdrop-filter: blur(8px);
}
.floating-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  opacity: 1;
  background: var(--bg-tertiary);
}
.floating-action-btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}
.floating-action-btn.primary:hover {
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
}
.floating-action-btn.filter-hidden {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, rgba(34, 197, 94, 0.1) 100%);
  border-color: var(--success);
  color: var(--success);
}

/* Sticky Filter Panel Header */
.filter-panel-header-sticky {
  position: sticky;
  top: 0;
  z-index: 150;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border-bottom: 1px solid var(--border);
  margin: -1px -1px 0 -1px;
  padding: 12px 20px !important;
  border-radius: 8px 8px 0 0;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.filter-panel-header-sticky .card-title {
  font-size: 14px;
}

/* Highlight active filters bar when filters are applied */
#hierarchy-active-filters.has-filters {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
}

/* Chat Layout - Complete Buildout */
.chat-layout { display: grid; grid-template-columns: 280px 1fr; height: calc(100vh - 100px); gap: 0; }

.chat-sidebar { 
  background: var(--bg-secondary); 
  border-right: 1px solid var(--border); 
  overflow-y: auto; 
  padding: 16px;
}
.sidebar-header { margin-bottom: 16px; }
.sidebar-header h3 { margin: 0 0 4px 0; font-size: 16px; }
.sidebar-subtitle { font-size: 11px; color: var(--text-muted); }

/* Per-user conversation history list */
.chat-sessions-panel {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.chat-sessions-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.chat-new-session-btn { font-size: 11px; padding: 3px 10px; }
.chat-sessions-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.chat-session-empty { font-size: 11px; color: var(--text-muted); padding: 6px 4px; }
.chat-session-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 9px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent; transition: background 0.15s, border-color 0.15s;
}
.chat-session-item:hover { background: var(--bg-tertiary); }
.chat-session-item.active { background: var(--bg-tertiary); border-color: var(--primary); }
.chat-session-main { flex: 1; min-width: 0; }
.chat-session-title {
  font-size: 12px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-session-item.active .chat-session-title { color: var(--text-primary); }
.chat-session-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.chat-session-del {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px; line-height: 1; padding: 0 2px;
  opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.chat-session-item:hover .chat-session-del { opacity: 1; }
.chat-session-del:hover { color: var(--error); }

.prompt-category { margin-bottom: 8px; }
.prompt-category-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: var(--bg-tertiary); border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background 0.2s;
}
.prompt-category-header:hover { background: var(--bg-primary); }
.prompt-category-header .expand-icon { transition: transform 0.2s; }
.prompt-category.expanded .expand-icon { transform: rotate(90deg); }

.prompt-category-items { display: none; padding: 8px 0 0 12px; }
.prompt-category.expanded .prompt-category-items { display: block; }

.prompt-item {
  padding: 8px 12px; margin-bottom: 4px; border-radius: 6px;
  font-size: 12px; color: var(--text-secondary); cursor: pointer;
  transition: all 0.2s;
}
.prompt-item:hover { background: var(--accent); color: white; }

/* Dossier search in prompt library */
.dossier-search-trigger { position: relative; }
.dossier-search-trigger:hover { background: var(--bg-primary); color: var(--text-primary); }
.dossier-search-panel {
  margin-top: 8px; padding: 0; background: var(--bg-secondary);
  border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden;
}
.dossier-search-input {
  width: 100%; padding: 8px 10px; border: none; border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary); color: var(--text-primary); font-size: 12px; outline: none;
  box-sizing: border-box;
}
.dossier-search-results { max-height: 240px; overflow-y: auto; }
.dsr-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; cursor: pointer; font-size: 12px; transition: background 0.15s;
}
.dsr-item:hover { background: var(--accent); color: white; }
.dsr-name { font-weight: 500; }
.dsr-team { font-size: 10px; opacity: 0.7; }
.dsr-empty { padding: 10px; font-size: 11px; color: var(--text-muted); font-style: italic; }

/* Dossier — selected account + model picker */
.dsr-selected-account { padding: 10px; }
.dsr-selected-name {
  font-weight: 600; font-size: 13px; color: var(--text-primary);
  padding-bottom: 6px; border-bottom: 1px solid var(--border-color); margin-bottom: 8px;
}
.dsr-model-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.dsr-model-grid { display: flex; flex-direction: column; gap: 4px; }
.dsr-model-option {
  display: flex; flex-direction: column; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border-color); cursor: pointer; transition: all 0.15s;
}
.dsr-model-option:hover { border-color: var(--accent); background: rgba(59,130,246,0.06); }
.dsr-model-default { border-color: var(--accent); background: rgba(59,130,246,0.04); }
.dsr-model-header { display: flex; justify-content: space-between; align-items: center; }
.dsr-model-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.dsr-model-cost { font-size: 11px; font-weight: 600; color: var(--accent); }
.dsr-model-desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* Dimensional Analysis search panel */
.dimensional-search-panel {
  margin-top: 8px; padding: 0; background: var(--bg-secondary);
  border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden;
}
.dimensional-search-input {
  width: 100%; padding: 8px 10px; border: none; border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary); color: var(--text-primary); font-size: 12px; outline: none;
  box-sizing: border-box;
}
.dimensional-search-results { max-height: 240px; overflow-y: auto; }

/* Model tag in chat messages */
.chat-model-tag {
  display: inline-block; padding: 1px 6px; margin-right: 6px; border-radius: 3px;
  font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
  background: rgba(59,130,246,0.12); color: var(--accent); border: 1px solid rgba(59,130,246,0.25);
  vertical-align: middle;
}

/* Event Series sidebar items */
.event-series-list { padding: 0 12px 12px; overflow-y: auto; max-height: 40vh; }
.event-series-item {
  padding: 8px 10px; margin-bottom: 6px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-tertiary, rgba(0,0,0,0.02));
  transition: all 0.15s;
}
.event-series-item:hover { border-color: var(--accent); background: var(--bg-primary); }
.es-name { font-weight: 600; font-size: 12px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.es-meta { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-secondary); }
.es-footer { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.es-risk-badge { color: var(--error, #ef4444); font-weight: 600; }
.event-series-loading, .event-series-empty { padding: 16px 12px; font-size: 12px; color: var(--text-muted); text-align: center; }

.chat-main { display: flex; flex-direction: column; background: var(--bg-primary); }

.chat-header-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg-secondary);
}
.chat-subtitle { margin: 4px 0 0 0; font-size: 11px; color: var(--text-muted); }
.chat-actions { display: flex; align-items: center; gap: 12px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.chat-messages { flex: 1; overflow-y: auto; padding: 20px; }

.chat-input-area { padding: 16px 20px; border-top: 1px solid var(--border); background: var(--bg-secondary); }
.chat-input { flex: 1; }
.chat-input-wrapper .btn { display: flex; align-items: center; gap: 6px; }

.chat-hints { margin-top: 10px; font-size: 11px; color: var(--text-muted); display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.chat-input-wrapper { display: flex; gap: 12px; align-items: center; }
.hint-chip {
  display: inline-block; padding: 4px 10px; margin-left: 6px;
  background: var(--bg-tertiary); border-radius: 12px; cursor: pointer;
  transition: all 0.2s;
}
.hint-chip:hover { background: var(--accent); color: white; }

.message { margin-bottom: 20px; }
.message.user { display: flex; justify-content: flex-end; }
.message.user .message-content { 
  background: linear-gradient(135deg, var(--accent), #7c3aed); 
  color: white; max-width: 70%; border-radius: 16px 16px 4px 16px;
}
.message.assistant .message-content { 
  background: var(--bg-secondary); max-width: min(920px, 92%); border-radius: 16px 16px 16px 4px;
}
.message-content {
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.6;
}

/* Assistant markdown prose */
.chat-prose {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.chat-prose > *:first-child { margin-top: 0; }
.chat-prose > *:last-child { margin-bottom: 0; }
.chat-prose p { margin: 0.45em 0; }
.chat-prose h2 {
  font-size: 17px; font-weight: 700; color: var(--text-primary);
  margin: 1.1em 0 0.35em; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.chat-prose h3, .chat-prose .chat-section-heading {
  font-size: 15px; font-weight: 700; color: var(--text-primary);
  margin: 1em 0 0.3em;
}
.chat-prose h4 { font-size: 14px; font-weight: 700; color: var(--text-primary); margin: 0.85em 0 0.25em; }
.chat-prose h5 { font-size: 13px; font-weight: 700; color: var(--text-primary); margin: 0.75em 0 0.2em; }
.chat-prose strong { color: var(--text-primary); font-weight: 600; }
.chat-prose em { color: var(--text-secondary); }
.chat-prose code {
  background: var(--bg-tertiary); padding: 1px 5px; border-radius: 4px;
  font-size: 12px; color: var(--accent);
}
.chat-prose ul, .chat-prose ol {
  margin: 0.35em 0 0.5em;
  padding-left: 1.35em;
}
.chat-prose li { margin: 0.12em 0; }
.chat-prose li > ul, .chat-prose li > ol { margin: 0.15em 0 0.25em; }
.chat-prose hr {
  border: none; border-top: 1px solid var(--border);
  margin: 0.85em 0;
}
.chat-prose .chat-data-table {
  width: auto;
  max-width: 100%;
  margin: 0.6em 0;
  font-size: 13px;
}
.chat-prose .chat-data-table th,
.chat-prose .chat-data-table td {
  padding: 6px 14px;
}
.chat-prose .chat-data-table.chat-table--2col th:last-child,
.chat-prose .chat-data-table.chat-table--2col td:last-child {
  text-align: right;
  white-space: nowrap;
}

/* Chat Data Views */
.chat-data-table { 
  width: 100%; margin: 12px 0; border-collapse: collapse; 
  font-size: 12px; background: var(--bg-tertiary); border-radius: 8px; overflow: hidden;
}
.chat-data-table th { 
  background: var(--bg-primary); padding: 10px 12px; text-align: left; 
  font-weight: 600; color: var(--text-muted); font-size: 11px; text-transform: uppercase;
}
.chat-data-table td { padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-data-table tr:hover { background: var(--bg-primary); }

.chat-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 12px 0; }
.chat-stat-item { 
  background: var(--bg-tertiary); padding: 14px; border-radius: 8px; text-align: center;
}
.chat-stat-value { font-size: 24px; font-weight: 700; color: var(--accent); }
.chat-stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.chat-bar { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.chat-bar-fill { height: 20px; background: var(--accent); border-radius: 4px; min-width: 4px; }
.chat-bar-label { font-size: 12px; color: var(--text-secondary); min-width: 120px; }
.chat-bar-value { font-size: 12px; color: var(--text-muted); }

/* Reasoning steps (Gemini-like thinking UI) */
.reasoning-container {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-tertiary);
}
.reasoning-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--bg-secondary);
  font-size: 12px;
  color: var(--text-muted);
  transition: background 0.15s;
}
.reasoning-header:hover { background: var(--bg-primary); }
.reasoning-header .icon { transition: transform 0.2s; }
.reasoning-header.expanded .icon { transform: rotate(90deg); }
.reasoning-header .badge {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}
.reasoning-steps {
  display: none;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
}
.reasoning-steps.show { display: block; }
.reasoning-step {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.reasoning-step:first-child { border-top: none; }
.reasoning-step-icon {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  flex-shrink: 0;
}
.reasoning-step-content { flex: 1; }
.reasoning-step-title { font-weight: 600; color: var(--text-primary); }
.reasoning-step-detail { color: var(--text-muted); margin-top: 2px; word-break: break-word; }

/* Tool call styling */
.reasoning-step.tool-call { background: rgba(139, 92, 246, 0.1); }
.reasoning-step.tool-result { background: rgba(16, 185, 129, 0.1); }
.reasoning-step.deep-research { background: rgba(59, 130, 246, 0.1); }

/* Deep research status card */
.research-status-card {
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.research-status-card .research-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(59, 130, 246, 0.3);
  border-top-color: var(--accent-blue, #3b82f6);
  border-radius: 50%;
  animation: research-spin 0.8s linear infinite;
}
.research-status-card.completed {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}
.research-status-card.completed .research-spinner {
  display: none;
}
.research-status-card .research-check {
  display: none;
  color: var(--success, #10b981);
  font-weight: bold;
}
.research-status-card.completed .research-check { display: inline; }
.research-status-label { font-weight: 600; color: var(--text-primary); }
.research-status-detail { color: var(--text-muted); }
@keyframes research-spin {
  to { transform: rotate(360deg); }
}

/* ─── Deliverable artifact cards (chat) ───────────────────────────────
 * Rendered by static/js/chat.js::renderArtifactCard when a chat tool
 * (generate_event_sales_kit, generate_sponsor_tearsheet, etc.) returns
 * a structured artifact via SSE `event: artifact`. Each card sits above
 * the prose response so the user sees the deliverable before the model
 * finishes synthesizing. */
.artifact-card {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent-violet);
  font-size: 13px;
}
.artifact-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.artifact-kind-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-violet);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.artifact-card-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.3;
}
.artifact-card-subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}
.artifact-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 10px;
}
.artifact-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 12px;
}
.artifact-stat-label { color: var(--text-muted); }
.artifact-stat-value { font-weight: 600; color: var(--text-primary); }
.artifact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.artifact-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-primary);
  transition: background 0.12s, border-color 0.12s;
}
.artifact-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-violet);
}
.artifact-btn-primary {
  background: var(--accent-violet);
  border-color: var(--accent-violet);
  color: #fff;
}
.artifact-btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.artifact-talking-points {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary, var(--text-primary));
}
.artifact-talking-points ul {
  margin: 4px 0 0 18px;
  padding: 0;
}
.artifact-talking-points li { margin: 2px 0; }
.artifact-elevator {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  border-left: 2px solid var(--accent-violet);
  font-size: 12px;
  color: var(--text-primary);
}
.artifact-whynow {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary, var(--text-primary));
}
.artifact-email-subject {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-primary);
}
.artifact-email-body {
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-primary);
  max-height: 320px;
  overflow-y: auto;
  line-height: 1.5;
}
.artifact-audience-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.4;
}
.artifact-audience-external {
  background: rgba(16, 185, 129, 0.10);
  color: var(--success, #10b981);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.artifact-audience-internal {
  background: rgba(245, 158, 11, 0.10);
  color: var(--warning, #f59e0b);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ZoomInfo contacts artifact (kind='zi_contacts') — grouped per-account
 * card produced by AITools.discover_contacts. Each row deep-links to
 * /entity-creation?mode=contact&zi_contact_id=... which auto-opens the
 * existing verify/enrich/push drawer. */
.zi-groups {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.zi-group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.zi-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-primary);
}
.zi-group-name { display: inline-flex; align-items: center; gap: 8px; }
.zi-group-counts {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}
.zi-count-sf { color: var(--accent-violet); }
.zi-count-zi { color: var(--success, #10b981); }
.zi-count-sep { opacity: 0.5; }

.zi-group-hybrid .zi-section {
  border-top: 1px solid var(--border);
}
.zi-group-hybrid .zi-section:first-of-type { border-top: 0; }
.zi-section-head {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 8px;
}
.zi-section-sf .zi-section-head { color: var(--accent-violet); }
.zi-section-zi .zi-section-head { color: var(--success, #10b981); }
.zi-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 0 5px;
  font-size: 10.5px;
  font-weight: 600;
  border-radius: 9px;
  background: var(--bg-secondary);
  color: inherit;
}
.zi-section-empty-msg {
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
}
.zi-row-sf .zi-row-name { color: var(--accent-violet); }
.zi-row-flag-activity { color: var(--accent-amber, #f59e0b); }
.zi-row-open-sf {
  color: var(--accent-violet);
}
.zi-row-open-sf:hover {
  background: var(--accent-violet);
  color: #fff;
  border-color: var(--accent-violet);
}
.zi-sf-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-violet);
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.zi-rows {
  display: flex;
  flex-direction: column;
}
.zi-row {
  display: grid;
  grid-template-columns: 24px 1.4fr 2fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.zi-row-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
}
.zi-row-chk {
  cursor: pointer;
  width: 14px;
  height: 14px;
  margin: 0;
}
.zi-row-chk-disabled {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px dashed var(--border);
  border-radius: 2px;
  background: transparent;
}
.zi-row-chk-placeholder {
  color: var(--text-muted);
  opacity: 0.4;
  font-size: 8px;
  line-height: 1;
}
.zi-row:last-child { border-bottom: 0; }
.zi-row-name { font-weight: 500; color: var(--text-primary); }
.zi-row-title { color: var(--text-secondary, var(--text-muted)); }
.zi-row-flags {
  display: inline-flex;
  gap: 4px;
  color: var(--text-muted);
  font-size: 13px;
}
.zi-row-flag {
  display: inline-block;
  width: 18px;
  text-align: center;
}
.zi-row-open {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent-violet);
  border: 1px solid var(--border);
  background: var(--bg);
  text-decoration: none;
  white-space: nowrap;
}
.zi-row-open:hover {
  background: var(--accent-violet);
  color: #fff;
  border-color: var(--accent-violet);
}
.zi-row-open-disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}
.zi-row-open-disabled:hover {
  background: var(--bg);
  color: var(--text-muted);
  border-color: var(--border);
}
.zi-card-foot {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px dashed var(--border);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ZI bulk-action bar — sits below the groups, above the compliance
 * footer. Sticky-feeling but not actually position:sticky so it doesn't
 * fight the chat-scroll container. Only rendered when totalZi > 0. */
.zi-bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.zi-bulk-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.zi-bulk-all input { cursor: pointer; }
.zi-bulk-spacer { flex: 1 1 auto; }
.zi-bulk-status {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-right: 8px;
  min-height: 16px;
  white-space: nowrap;
}
.zi-bulk-status-info    { color: var(--accent-violet); }
.zi-bulk-status-success { color: var(--success, #10b981); }
.zi-bulk-status-warn    { color: var(--accent-amber, #f59e0b); }
.zi-bulk-status-error   { color: var(--danger, #ef4444); }
.zi-bulk-cancel,
.zi-bulk-export,
.zi-bulk-push {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
}
.zi-bulk-cancel:hover:not([disabled]),
.zi-bulk-export:hover:not([disabled]) {
  background: var(--bg-secondary);
  border-color: var(--accent-violet);
  color: var(--accent-violet);
}
.zi-bulk-push {
  background: var(--accent-violet);
  color: #fff;
  border-color: var(--accent-violet);
}
.zi-bulk-push:hover:not([disabled]) {
  filter: brightness(1.05);
}
.zi-bulk-push-disabled,
.zi-bulk-cancel[disabled],
.zi-bulk-push[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}
.zi-bulk-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 0 5px;
  margin-right: 4px;
  font-weight: 700;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.18);
}

/* Per-group "Select all in this account" checkbox in the ZI section
 * head — small, secondary, non-distracting. */
.zi-group-select {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: lowercase;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 8px;
  user-select: none;
}
.zi-group-select input { cursor: pointer; width: 12px; height: 12px; }

/* Per-row outcome chip — replaces the Open button after a bulk push.
 * Tones mirror the entity-creation page (Synced=success / Push
 * failed=error / Needs parent=warn). */
.zi-row-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
}
.zi-row-chip-success {
  background: rgba(16, 185, 129, 0.10);
  color: var(--success, #10b981);
  border-color: rgba(16, 185, 129, 0.35);
}
a.zi-row-chip-success:hover { filter: brightness(1.08); }
.zi-row-chip-warn {
  background: rgba(245, 158, 11, 0.10);
  color: var(--accent-amber, #f59e0b);
  border-color: rgba(245, 158, 11, 0.35);
}
.zi-row-chip-error {
  background: rgba(239, 68, 68, 0.10);
  color: var(--danger, #ef4444);
  border-color: rgba(239, 68, 68, 0.35);
}

/* Banner that appears below the bulk bar when one or more rows came
 * back needs_parent — surfaces a deep link to /entity-creation
 * pre-filled with the parent company names so the rep can push the
 * Accounts there (we don't bulk-push parents from chat — they need
 * full enriched payloads we don't carry in this context). */
.zi-bulk-needs-parent {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--accent-amber, #f59e0b);
}
.zi-bulk-needs-parent-msg { flex: 1 1 auto; line-height: 1.4; }
.zi-bulk-needs-parent-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-amber, #f59e0b);
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.zi-bulk-needs-parent-btn:hover { filter: brightness(1.05); }

/* Confirm modal used by ZIBulk.confirm — minimal in-DOM dialog,
 * appended to <body> on first use. Reused thereafter. */
.zi-modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
}
.zi-modal {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  background: var(--bg-card, var(--bg-secondary));
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 22px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}
.zi-modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}
.zi-modal-body {
  font-size: 13px;
  color: var(--text-secondary, var(--text-muted));
  line-height: 1.5;
}
.zi-modal-list {
  margin: 8px 0 4px 18px;
  padding: 0;
}
.zi-modal-list li { margin: 4px 0; }
.zi-modal-foot {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.zi-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.zi-modal-btn {
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-primary);
  cursor: pointer;
}
.zi-modal-btn:hover { background: var(--bg-secondary); }
.zi-modal-confirm {
  background: var(--accent-violet);
  color: #fff;
  border-color: var(--accent-violet);
}
.zi-modal-confirm:hover { filter: brightness(1.05); }
.zi-modal-btn-danger {
  background: var(--danger, #ef4444);
  border-color: var(--danger, #ef4444);
}

/* Deep links from agent responses */
a.deep-link {
  color: var(--accent-violet);
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
  font-family: var(--font-mono, monospace);
  font-size: 0.9em;
}
a.deep-link:hover {
  color: var(--accent);
  text-decoration-style: solid;
}

a.chat-link {
  color: var(--accent-violet);
  text-decoration: underline;
}
a.chat-link:hover {
  color: var(--accent);
}

/* Explorer query blocks in chat */
.explorer-query-block {
  margin: 14px 0 8px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-violet);
  border-radius: 8px;
}
.explorer-query-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}
.explorer-query-text code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}
.explorer-query-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  gap: 0;
}

/* Welcome message */
.welcome-card { background: var(--bg-secondary); border-radius: 12px; padding: 20px; }
.welcome-title { font-size: 18px; margin: 0 0 8px 0; }
.welcome-subtitle { color: var(--text-muted); margin: 0 0 16px 0; font-size: 13px; }

/* ETL Controls */
.etl-controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }

.etl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.etl-btn:hover { border-color: var(--accent); background: var(--bg-card); }
.etl-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.etl-btn .icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
}

.etl-btn .label { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.etl-btn .desc { font-size: 12px; color: var(--text-muted); }

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

.award-sortable-th:hover {
  color: var(--text-primary) !important;
  background: var(--bg-tertiary, rgba(255,255,255,0.05));
}

.sort-arrow {
  font-size: 9px;
  opacity: 0.3;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  50% { opacity: 0.85; box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 26px;
  transition: var(--transition);
}
.switch .slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(22px); background: white; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 12px; }

.toast {
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }

@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.animate-in { animation: fadeIn 0.3s ease forwards; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* Model badge */
.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0.2));
  border: 1px solid var(--purple);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--purple);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 { margin: 0; font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* API Key Item Styles */
.api-key-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.api-key-item:hover { background: var(--bg-card-hover); }
.api-key-item:last-child { border-bottom: none; }

.api-key-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-right: 16px;
}

.api-key-icon.account { background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1)); }
.api-key-icon.admin { background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1)); }
.api-key-icon.inactive { background: rgba(107, 114, 128, 0.2); filter: grayscale(1); opacity: 0.6; }

.api-key-info { flex: 1; min-width: 0; }
.api-key-name { font-weight: 600; margin-bottom: 4px; }
.api-key-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 16px; flex-wrap: wrap; }

.api-key-stats { text-align: right; margin-right: 16px; }
.api-key-usage { font-weight: 600; font-family: 'JetBrains Mono', monospace; }
.api-key-last-used { font-size: 11px; color: var(--text-muted); }

.api-key-actions { display: flex; gap: 8px; }

.scope-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.scope-badge.account { background: rgba(59, 130, 246, 0.15); color: var(--accent); }
.scope-badge.admin { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.scope-badge.internal { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.scope-badge.client { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

/* Login Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.login-header {
  text-align: center;
  margin-bottom: 32px;
}
.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}
.login-header p {
  color: var(--text-muted);
  font-size: 14px;
}
.login-form .filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  width: 100%;
}
.login-form .filter-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  box-sizing: border-box;
}
.login-form .btn {
  box-sizing: border-box;
}

/* ── Account Detail Modal (Explorer) ─────────────────────── */
.acct-ml-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-secondary, #0f172a);
  border-radius: 10px;
  border: 1px solid var(--border, #334155);
}
.acct-ml-card {
  text-align: center;
  padding: 8px 4px;
}
.acct-ml-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 4px;
}
.acct-ml-val {
  font-size: 16px;
  font-weight: 700;
}
.acct-section {
  margin-bottom: 16px;
}
.acct-section h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #94a3b8);
  margin: 0 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border, #334155);
}
.acct-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 16px;
}
.acct-kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  font-size: 13px;
}
.acct-k { color: var(--text-muted, #94a3b8); }
.acct-v { font-weight: 600; }
.acct-rev-timeline {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 100px;
  padding: 8px 0;
}
.acct-rev-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  position: relative;
  justify-content: flex-end;
}
.acct-rev-bar {
  width: 100%;
  max-width: 40px;
  background: var(--accent-muted, #1e40af);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
}
.acct-rev-predicted {
  background: repeating-linear-gradient(
    135deg,
    var(--accent, #3b82f6) 0px, var(--accent, #3b82f6) 3px,
    transparent 3px, transparent 6px
  );
  border: 1px dashed var(--accent, #3b82f6);
}
.acct-rev-yr {
  font-size: 10px;
  color: var(--text-muted, #94a3b8);
  margin-top: 4px;
}
.acct-rev-amt {
  font-size: 10px;
  font-weight: 600;
  position: absolute;
  top: -2px;
  white-space: nowrap;
}
.acct-rev-mix {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.acct-rev-mix-tag {
  font-size: 11px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent, #3b82f6);
  padding: 2px 8px;
  border-radius: 10px;
}
.acct-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.acct-stat {
  text-align: center;
  padding: 8px;
  background: var(--bg-secondary, #0f172a);
  border-radius: 6px;
  border: 1px solid var(--border, #334155);
}
.acct-stat-val {
  font-size: 16px;
  font-weight: 700;
}
.acct-stat-label {
  font-size: 10px;
  color: var(--text-muted, #94a3b8);
  margin-top: 2px;
}
.acct-sub-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.acct-sub-card {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid var(--border, #334155);
  display: flex;
  gap: 8px;
  align-items: center;
}
.acct-sub-name { font-weight: 700; }
.acct-sub-active { background: rgba(34, 197, 94, 0.1); color: #22c55e; border-color: rgba(34, 197, 94, 0.3); }
.acct-sub-renewal { background: rgba(59, 130, 246, 0.1); color: #3b82f6; border-color: rgba(59, 130, 246, 0.3); }
.acct-sub-expired { background: rgba(239, 68, 68, 0.08); color: #ef4444; border-color: rgba(239, 68, 68, 0.2); }
.acct-sub-none { opacity: 0.4; }
.acct-chevron { transition: transform 0.2s; }
.acct-chevron-open { transform: rotate(180deg); }

/* ═══ Voice Features ═══ */
.btn-mic {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border, #334155);
  background: var(--bg-secondary, #0f172a);
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-mic:hover {
  border-color: var(--primary, #6366f1);
  color: var(--primary, #6366f1);
  background: rgba(99, 102, 241, 0.08);
}
.btn-mic.listening {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.btn-speak, .btn-export {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: all 0.15s;
  position: absolute;
  bottom: 8px;
  opacity: 0.5;
}
.btn-speak { right: 8px; }
.btn-export { right: 40px; }
.message.assistant:hover .btn-speak,
.message.assistant:hover .btn-export { opacity: 0.8; }
.btn-speak.playing { opacity: 1; }
.btn-speak:hover,
.btn-export:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary, #6366f1);
}
.btn-export:disabled { opacity: 0.4; cursor: wait; }
.btn-speak.playing {
  color: var(--primary, #6366f1);
  animation: speak-pulse 1s ease-in-out infinite;
}
@keyframes speak-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.message.assistant .message-content { position: relative; }

.model-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-secondary, #0f172a);
  color: var(--text-secondary, #94a3b8);
  border: 1px solid var(--border, #334155);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.model-select:hover, .model-select:focus {
  border-color: var(--primary, #6366f1);
  color: var(--text-primary, #e2e8f0);
  outline: none;
}
.model-select option {
  background: var(--bg-primary, #020617);
  color: var(--text-primary, #e2e8f0);
  padding: 4px 8px;
}

/* ---- Shared: Delta indicators ---- */
.delta-up { color: #22c55e; }
.delta-down { color: #ef4444; }
.delta-neutral { color: var(--text-muted, #94a3b8); }

/* ---- Shared: SHAP factor chips ---- */
.shap-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.shap-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 4px; font-size: 11px;
  line-height: 1.3; white-space: nowrap;
}
.shap-chip.up { background: rgba(34,197,94,0.12); color: #22c55e; }
.shap-chip.down { background: rgba(239,68,68,0.12); color: #ef4444; }
.shap-chip .shap-arrow { font-size: 9px; }
.shap-chip .shap-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; }
.shap-chip .shap-val { font-weight: 600; font-size: 10px; opacity: 0.85; }

/* ---- Shared: Horizontal bar ---- */
.hbar { height: 8px; border-radius: 4px; background: var(--bg-tertiary, #1e293b); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.hbar-fill.accent { background: var(--primary, #6366f1); }
.hbar-fill.success { background: #22c55e; }
.hbar-fill.warning { background: #f59e0b; }
.hbar-fill.danger { background: #ef4444; }

/* ---- Shared: KPI cards (reusable) ---- */
.kpi-row { display: grid; gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--bg-secondary, #0f172a);
  border: 1px solid var(--border, #334155);
  border-radius: 12px; padding: 20px;
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted, #94a3b8); margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text-primary, #e2e8f0); }
.kpi-value.accent { color: var(--primary, #6366f1); }
.kpi-value.success { color: #22c55e; }
.kpi-value.danger { color: #ef4444; }
.kpi-value.warning { color: #f59e0b; }
.kpi-sub { font-size: 12px; color: var(--text-muted, #94a3b8); margin-top: 4px; }

/* ---- Shared: Expandable row detail ---- */
.row-detail { background: var(--bg-tertiary, #1e293b); border-top: 1px solid var(--border, #334155); padding: 12px 16px; }
.row-detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

.voice-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-muted, #94a3b8);
  cursor: pointer; user-select: none; flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #334155);
  background: var(--bg-secondary, #0f172a);
  transition: all 0.2s;
}
.voice-toggle input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--primary, #6366f1);
  cursor: pointer;
}
.voice-toggle:hover {
  color: var(--text-secondary, #cbd5e1);
  border-color: var(--primary, #6366f1);
  background: rgba(99, 102, 241, 0.06);
}
.voice-toggle svg { opacity: 0.6; }
.voice-toggle:has(input:checked) {
  border-color: var(--primary, #6366f1);
  color: var(--primary, #6366f1);
  background: rgba(99, 102, 241, 0.08);
}
.voice-toggle:has(input:checked) svg { opacity: 1; }

/* Personalized Mode Toggle */
#personalized-toggle-wrap #personalized-toggle:checked ~ #personalized-slider {
  background: var(--accent, #3b82f6);
}
#personalized-toggle-wrap #personalized-toggle:checked ~ #personalized-knob {
  transform: translateX(12px);
}
.personalized-active-banner {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--accent, #3b82f6);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* iframe embed previews (?embed=1) — walkthrough console, future embeds */
body.embed-mode .sidebar,
body.embed-mode .sidebar-backdrop,
body.embed-mode .mobile-bottom-nav,
body.embed-mode .mobile-more-sheet,
body.embed-mode .mobile-more-backdrop,
body.embed-mode #rewards-sidebar-module,
body.embed-mode #notification-bell,
body.embed-mode #pwa-install-banner,
body.embed-mode .mobile-hamburger {
  display: none !important;
}
body.embed-mode .main {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 100vh;
}
body.embed-mode #readiness-overlay,
body.embed-mode #auth-loading {
  display: none !important;
}
