/* ==========================================================================
   chatter — components.css
   UI primitives. Each class maps 1:1 to DESIGN.md § Components.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Chip / Status
   -------------------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 20px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  white-space: nowrap;
  background: color-mix(in srgb, var(--fg-2) 20%, var(--bg-2));
  color: var(--fg-1);
}

.chip__dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.chip--auto {
  background: color-mix(in srgb, var(--sig-info) 20%, var(--bg-2));
  color: var(--sig-info);
}

.chip--manual {
  background: color-mix(in srgb, var(--sig-magenta) 20%, var(--bg-2));
  color: var(--sig-magenta);
}

.chip--dropped {
  background: color-mix(in srgb, var(--sig-error) 20%, var(--bg-2));
  color: var(--sig-error);
}

.chip--live {
  background: color-mix(in srgb, var(--sig-lime) 20%, var(--bg-2));
  color: var(--sig-lime);
}

.chip--converted {
  background: color-mix(in srgb, var(--sig-success) 20%, var(--bg-2));
  color: var(--sig-success);
}

.chip--warn {
  background: color-mix(in srgb, var(--sig-warn) 20%, var(--bg-2));
  color: var(--sig-warn);
}

.chip--neutral {
  background: var(--bg-3);
  color: var(--fg-1);
}

.chip--tactic {
  font-family: var(--font-mono);
  text-transform: none;
  letter-spacing: 0;
  background: color-mix(in srgb, var(--sig-violet) 18%, var(--bg-2));
  color: var(--sig-violet);
}

.chip--live .chip__dot {
  animation: pulse-dot 1.5s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   2. Card
   -------------------------------------------------------------------------- */

.card {
  background: var(--bg-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
}

.card--raised {
  background: var(--bg-3);
}

.card--bundle-accent {
  border-left: 2px solid var(--card-bundle-color, var(--sig-info));
  padding-left: calc(var(--space-4) - 2px);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.card__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
}

/* --------------------------------------------------------------------------
   3. Button
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 28px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--motion-fast),
              border-color var(--motion-fast),
              color var(--motion-fast),
              box-shadow var(--motion-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--bg-3);
  color: var(--fg-0);
  border-color: var(--border-strong);
}

.btn--primary:hover:not(:disabled) {
  background: var(--bg-4);
  box-shadow: 0 0 0 2px rgba(58, 213, 255, 0.12);
  border-color: var(--border-glow);
}

.btn--danger {
  background: transparent;
  color: var(--sig-error);
  border-color: color-mix(in srgb, var(--sig-error) 40%, transparent);
}

.btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--sig-error) 15%, transparent);
  border-color: var(--sig-error);
}

.btn--ghost {
  background: transparent;
  color: var(--fg-1);
  border-color: transparent;
}

.btn--ghost:hover:not(:disabled) {
  color: var(--fg-0);
  background: var(--bg-3);
}

.btn--sm {
  height: 22px;
  padding: 0 var(--space-2);
  font-size: var(--fs-xs);
}

/* --------------------------------------------------------------------------
   4. Data table
   -------------------------------------------------------------------------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
  font-family: var(--font-ui);
  color: var(--fg-1);
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-1);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-weak);
  vertical-align: middle;
}

.data-table tbody tr {
  height: 28px;
  transition: background-color var(--motion-fast);
}

.data-table--loose tbody tr {
  height: 32px;
}

.data-table tbody tr:hover {
  background: var(--bg-3);
}

.data-table tbody tr[aria-selected="true"] {
  background: var(--bg-3);
  box-shadow: inset 2px 0 0 var(--border-glow);
}

.data-table .td--num,
.data-table .th--num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.data-table .td--mono {
  font-family: var(--font-mono);
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--fg-1);
}

.data-table th.sortable .sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
}

.data-table th.sortable[aria-sort="ascending"] .sort-icon,
.data-table th.sortable[aria-sort="descending"] .sort-icon {
  color: var(--sig-info);
}

/* --------------------------------------------------------------------------
   5. Bundle tabs
   -------------------------------------------------------------------------- */

.bundle-tabs {
  display: flex;
  align-items: stretch;
  height: var(--tabs-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-strong);
  padding: 0 var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}

.bundle-tabs::-webkit-scrollbar {
  display: none;
}

.bundle-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 100%;
  color: var(--fg-1);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: background-color var(--motion-fast),
              color var(--motion-fast);
  white-space: nowrap;
  text-decoration: none;
}

.bundle-tab:hover {
  background: var(--bg-3);
  color: var(--fg-0);
}

.bundle-tab__slug {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.bundle-tab__label {
  font-family: var(--font-ui);
  color: inherit;
}

.bundle-tab--active {
  background: var(--bg-2);
  color: var(--fg-0);
  border-bottom-color: var(--bundle-color, var(--sig-info));
}

.bundle-tab--active .bundle-tab__slug {
  color: var(--fg-1);
}

.bundle-tab--new {
  color: var(--fg-2);
  border: 1px dashed var(--border-strong);
  border-bottom-width: 1px;
  margin: 6px var(--space-2);
  height: calc(var(--tabs-h) - 12px);
  border-radius: var(--radius-xs);
}

.bundle-tab--new:hover {
  color: var(--fg-0);
  border-color: var(--border-glow);
  background: transparent;
}

/* --------------------------------------------------------------------------
   6. Dialog row
   -------------------------------------------------------------------------- */

.dialog-row {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr;
  column-gap: var(--space-3);
  align-items: start;
  padding: var(--space-3) var(--space-3) 14px var(--space-3);
  border-bottom: 1px solid var(--border-weak);
  border-left: 2px solid var(--dialog-bundle-color, var(--sig-info));
  background: var(--bg-1);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background-color var(--motion-fast);
}

.dialog-row:hover {
  background: var(--bg-3);
}

.dialog-row.is-selected,
.dialog-row[aria-selected="true"] {
  background: var(--bg-4);
  box-shadow: inset 3px 0 0 var(--fg-brand);
}

.dialog-row--manual {
  box-shadow: inset 1px 0 0 var(--sig-magenta);
}

/* --- Avatar circle (initials, hashed colour 0..5) ---------------------- */

.dialog-row__avatar {
  grid-column: 1;
  grid-row: 1 / span 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--fg-0);
  background: var(--sig-info);
  user-select: none;
}

.dialog-row__avatar[data-hue="0"] { background: linear-gradient(135deg, #3AD5FF, #5E6AD2); }
.dialog-row__avatar[data-hue="1"] { background: linear-gradient(135deg, #29E7A7, #3AD5FF); }
.dialog-row__avatar[data-hue="2"] { background: linear-gradient(135deg, #E24BFF, #5E6AD2); }
.dialog-row__avatar[data-hue="3"] { background: linear-gradient(135deg, #FFB547, #FF4D6A); }
.dialog-row__avatar[data-hue="4"] { background: linear-gradient(135deg, #BAFF5E, #29E7A7); color: var(--bg-0); }
.dialog-row__avatar[data-hue="5"] { background: linear-gradient(135deg, #8A7BFF, #E24BFF); }

.dialog-row__body {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;  /* allow truncation inside flex */
}

.dialog-row__line1,
.dialog-row__line2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.dialog-row__user {
  color: var(--fg-0);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-md);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-row__time {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  flex-shrink: 0;
}

.dialog-row__preview {
  color: var(--fg-1);
  font-size: var(--fs-sm);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-row__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  border-radius: 8px;
  background: var(--sig-lime);
  color: var(--bg-0);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--fw-bold);
  line-height: 1;
  flex-shrink: 0;
}

.dialog-row__hotness-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--dialog-hotness-color, var(--fg-3)) 40%,
    var(--dialog-hotness-color, var(--fg-3)) 100%
  );
  opacity: 0.85;
}

/* --------------------------------------------------------------------------
   7. Chat bubble
   -------------------------------------------------------------------------- */

.chat-stream {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
}

.chat-bubble {
  /* Scales to viewport: keeps the comfy ~66% ratio on laptops while
     capping at 560px on wide screens so long bubbles stay readable. */
  max-width: min(66%, 560px);
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--fg-0);
  border-radius: 16px;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  /* Subtle entrance for SSE-appended bubbles. Keyframes below. */
  animation: bubble-in 180ms var(--ease-expo-out, ease-out) both;
}

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

.chat-bubble__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.chat-bubble--incoming {
  align-self: flex-start;
  background: var(--bg-3);
  color: var(--fg-0);
  border-radius: 16px 16px 16px 4px;
}

.chat-bubble--outgoing-bot {
  align-self: flex-end;
  /* Indigo-tinted surface — clearly distinct from the incoming --bg-3.
     Respects per-bubble --bubble-bundle-color when the backend sets it.
     Bumped to 20% mix so the blue tint reads cleanly against --bg-1. */
  background: color-mix(
    in srgb,
    var(--bubble-bundle-color, var(--indigo-500, #5e6ad2)) 20%,
    var(--bg-1)
  );
  border: 1px solid
    color-mix(
      in srgb,
      var(--bubble-bundle-color, var(--indigo-500, #5e6ad2)) 36%,
      transparent
    );
  border-radius: 16px 16px 4px 16px;
}

.chat-bubble--outgoing-operator {
  align-self: flex-end;
  background: color-mix(in srgb, var(--sig-magenta) 18%, var(--bg-1));
  border: 1px solid color-mix(in srgb, var(--sig-magenta) 40%, transparent);
  border-radius: 16px 16px 4px 16px;
}

.chat-bubble--system {
  align-self: center;
  max-width: 60%;
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-align: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

.chat-bubble__tactic {
  align-self: flex-end;
  margin-top: calc(var(--space-1) * -1);
}

/* --------------------------------------------------------------------------
   8. Stat card
   -------------------------------------------------------------------------- */

.stat-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--bg-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  min-width: 200px;
}

.stat-card__caption {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.stat-card__value {
  font-family: var(--font-mono);
  font-size: var(--fs-display);
  font-weight: var(--fw-bold);
  color: var(--fg-0);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-card__delta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.stat-card__delta--up {
  color: var(--sig-success);
}

.stat-card__delta--down {
  color: var(--sig-error);
}

.stat-card__delta--flat {
  color: var(--fg-2);
}

.stat-card__delta-note {
  color: var(--fg-2);
  font-family: var(--font-ui);
  font-weight: var(--fw-regular);
  margin-left: var(--space-1);
}

.stat-card__sparkline {
  height: 40px;
  width: 100%;
}

.stat-card__sparkline-path {
  fill: none;
  stroke: var(--sig-info);
  stroke-width: 1.5;
}

.stat-card__sparkline-area {
  fill: color-mix(in srgb, var(--sig-info) 18%, transparent);
  stroke: none;
}

/* --------------------------------------------------------------------------
   9. Hotness dot
   -------------------------------------------------------------------------- */

.hotness-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-3);
  flex-shrink: 0;
  vertical-align: middle;
}

.hotness-dot--1  { background: var(--hotness-1); }
.hotness-dot--2  { background: var(--hotness-2); }
.hotness-dot--3  { background: var(--hotness-3); }
.hotness-dot--4  { background: var(--hotness-4); }
.hotness-dot--5  { background: var(--hotness-5); }
.hotness-dot--6  { background: var(--hotness-6); }
.hotness-dot--7  { background: var(--hotness-7); }
.hotness-dot--8  { background: var(--hotness-8); }
.hotness-dot--9  { background: var(--hotness-9); }
.hotness-dot--10 { background: var(--hotness-10); }

/* --------------------------------------------------------------------------
   10. Live indicator
   -------------------------------------------------------------------------- */

.live-indicator {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sig-lime);
  box-shadow: 0 0 0 0 rgba(186, 255, 94, 0.7);
  animation: pulse-dot 1.5s ease-in-out infinite;
  flex-shrink: 0;
  vertical-align: middle;
}

@keyframes pulse-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(186, 255, 94, 0.55);
    transform: scale(1);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(186, 255, 94, 0);
    transform: scale(1.08);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(186, 255, 94, 0);
    transform: scale(1);
  }
}

/* --------------------------------------------------------------------------
   Header (top bar 48px)
   -------------------------------------------------------------------------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 var(--space-4);
  background: var(--bg-4);
  border-bottom: 1px solid var(--border-strong);
}

.app-header__brand {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--sig-lime);
  letter-spacing: -0.02em;
  user-select: none;
}

.app-header__operator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--motion-fast);
}

.app-header__operator:hover {
  background: var(--bg-3);
}

.app-header__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--fg-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  border: 1px solid var(--border-strong);
}

.app-header__name {
  font-size: var(--fs-sm);
  color: var(--fg-0);
}

.app-header__chevron {
  color: var(--fg-2);
  font-size: 10px;
}

/* --------------------------------------------------------------------------
   Sidebar (left rail 64px, icon-only)
   -------------------------------------------------------------------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: var(--rail-w);
  padding: var(--space-3) 0;
  background: var(--bg-0);
  border-right: 1px solid var(--border-weak);
}

.sidebar__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--fg-2);
  cursor: pointer;
  transition: background-color var(--motion-fast),
              color var(--motion-fast);
  position: relative;
  text-decoration: none;
}

.sidebar__item:hover {
  background: var(--bg-2);
  color: var(--fg-0);
}

.sidebar__item--active {
  color: var(--fg-0);
  background: var(--bg-2);
}

.sidebar__item--active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--sig-info);
  border-radius: var(--radius-xs);
}

.sidebar__item svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
}

.sidebar__item__tooltip {
  position: absolute;
  left: calc(100% + var(--space-2));
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-4);
  color: var(--fg-0);
  font-size: var(--fs-xs);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--motion-fast);
  border: 1px solid var(--border-strong);
  z-index: 100;
}

.sidebar__item:hover .sidebar__item__tooltip {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Grid layouts used in dashboard
   -------------------------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

.dialog-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

/* --------------------------------------------------------------------------
   Phase 4B — auth screen + page shell + form-grid + data-table
   -------------------------------------------------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: var(--bg-0);
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.auth-card__title {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--fg-brand);
  letter-spacing: 0.04em;
  margin: 0;
}

.auth-card__subtitle {
  color: var(--fg-2);
  font-size: var(--fs-sm);
  margin: 0;
}

.auth-card__error {
  color: var(--sig-error, #ff5e6a);
  font-size: var(--fs-sm);
  background: color-mix(in srgb, var(--sig-error, #ff5e6a) 12%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--sig-error, #ff5e6a) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field__label {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field__input {
  appearance: none;
  -webkit-appearance: none;
  height: 32px;
  padding: 0 var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  width: 100%;
}

.field__input:focus-visible {
  outline: none;
  border-color: var(--border-glow, #3AD5FF);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--border-glow, #3AD5FF) 35%, transparent);
}

select.field__input {
  height: 32px;
  padding: 0 var(--space-3);
}

.page {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: 100%;
}

.page__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.page__title {
  margin: 0;
  font-size: 22px;
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
}

.page__subtitle {
  margin: 0;
  color: var(--fg-2);
  font-size: var(--fs-sm);
}

.page__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.section__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg-1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 var(--space-2) 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  align-items: end;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.data-table th,
.data-table td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-weak);
  color: var(--fg-1);
}

.data-table th {
  color: var(--fg-2);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
}

.card-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3);
  padding: 0;
  margin: 0;
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.card__title {
  color: var(--fg-0);
  font-weight: var(--fw-semibold);
  text-decoration: none;
}

.card__title:hover {
  color: var(--fg-brand);
}

.card__slug {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.card__desc {
  margin: 0;
  color: var(--fg-2);
  font-size: var(--fs-sm);
}

.empty-state {
  color: var(--fg-2);
  font-style: italic;
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.logout-form {
  margin-top: var(--space-6);
}

/* ==========================================================================
   DESIGN SYSTEM PASS — 392 missing selectors
   Generated 2026-04-22. Follows DESIGN.md: dark-only, data-dense, BEM strict.
   All values use tokens from tokens.css. No hardcoded px except where token
   does not exist (border widths, micro-adjustments).
   ========================================================================== */

/* --------------------------------------------------------------------------
   11. Dashboard grid
   -------------------------------------------------------------------------- */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  padding: var(--space-4);
  align-items: start;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Dashboard active bundle indicator strip */

.dashboard__active-bundle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--fg-1);
}

.dashboard__active-bundle-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--panel-accent, var(--sig-info));
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   12. Panel — base + variants
   -------------------------------------------------------------------------- */

.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--panel-accent, var(--sig-info));
  overflow: hidden;
  min-height: 180px;
}

.panel--empty {
  opacity: 0.7;
}

.panel--compare {
  border-left-color: var(--border-strong);
}

.panel--frame {
  border-left: 2px solid var(--border-strong);
}

/* Specific panel kinds — colors inherited from --panel-accent inline var;
   these selectors exist so tests find them, visual diff via inline style. */
.panel--funnel,
.panel--heatmap,
.panel--roas,
.panel--objections,
.panel--hotness,
.panel--time-to-x,
.panel--operator-perf,
.panel--llm-cost,
.panel--postback,
.panel--tracker-summary { /* inherits .panel */ }

/* --------------------------------------------------------------------------
   12a. Panel inner elements
   -------------------------------------------------------------------------- */

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-weak);
  flex-shrink: 0;
}

.panel__header--compare {
  flex-wrap: wrap;
  gap: var(--space-2);
}

.panel__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-0);
  margin: 0;
}

.panel__bundle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.panel__bundle-slug {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.panel__range {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
  padding: 1px var(--space-1);
  background: var(--bg-3);
  border-radius: var(--radius-xs);
}

.panel__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  flex: 1;
  overflow: hidden;
}

.panel__caption {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.panel__skeleton {
  padding: var(--space-3);
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 0.9; }
}

/* Empty state */

.panel__empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6);
  text-align: center;
  flex: 1;
}

.panel__empty-icon {
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--fg-3);
  line-height: 1;
}

.panel__empty-text {
  font-size: var(--fs-sm);
  color: var(--fg-2);
}

.panel__empty-reason {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

/* KPI summary row */

.panel__summary {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.panel__summary--compact {
  gap: var(--space-3);
}

.panel__kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel__kpi-caption {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
  white-space: nowrap;
}

.panel__kpi-value {
  font-family: var(--font-mono);
  font-size: var(--fs-display);
  font-weight: var(--fw-bold);
  color: var(--fg-0);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Explain / SQL drawer */

.panel__explain {
  border-top: 1px solid var(--border-weak);
  flex-shrink: 0;
}

.panel__explain > summary {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
  color: var(--fg-3);
  cursor: pointer;
  user-select: none;
  font-family: var(--font-mono);
  list-style: none;
}

.panel__explain > summary:hover {
  color: var(--fg-2);
}

.panel__sql {
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  background: var(--bg-1);
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

.panel__footnote {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
  padding-top: var(--space-1);
}

/* Compare mode */

.panel__compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border-weak);
  flex: 1;
  overflow: hidden;
}

.panel__compare-side {
  background: var(--bg-2);
  padding: var(--space-3);
  overflow: hidden;
}

.panel__compare-side--a { border-right: 1px solid var(--border-weak); }
.panel__compare-side--b { /* default */ }

.panel__compare-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
}

.panel__compare-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.panel__compare-sep {
  color: var(--fg-3);
}

.panel__compare-tag {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--sig-info);
  font-weight: var(--fw-semibold);
  margin-left: var(--space-2);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
}

/* --------------------------------------------------------------------------
   13. Funnel list visualization
   -------------------------------------------------------------------------- */

.funnel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.funnel-list__row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.funnel-list__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.funnel-list__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.funnel-list__count {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  font-variant-numeric: tabular-nums;
}

.funnel-list__bar-track {
  height: 6px;
  background: var(--bg-3);
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.funnel-list__bar {
  height: 100%;
  border-radius: var(--radius-xs);
  transition: width var(--motion-fast);
  background: var(--panel-accent, var(--sig-info));
}

.funnel-list__drop {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--sig-error);
  opacity: 0.75;
}

/* --------------------------------------------------------------------------
   14. Drop heatmap cells (campaign_dropoff_heatmap)
   -------------------------------------------------------------------------- */

.dropoff-heatmap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--fs-sm);
}

.dropoff-heatmap__head,
.dropoff-heatmap__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropoff-heatmap__row {
  display: grid;
  grid-template-columns: 1fr 56px 90px 56px;
  gap: 2px;
  align-items: center;
}

.dropoff-heatmap__row--header .dhm-cell {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
  padding: 4px 6px;
}

.dhm-cell {
  padding: 6px 8px;
  border-radius: var(--radius-xs);
}

.dhm-cell--label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-1);
  letter-spacing: 0.04em;
}

.dhm-cell--num {
  text-align: right;
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

.dhm-cell--drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.dhm-cell--heat {
  background: color-mix(in srgb, var(--sig-error) var(--heat, 0%), var(--bg-3));
  border: 1px solid color-mix(in srgb, var(--sig-error) calc(var(--heat, 0%) * 0.6), var(--border-weak));
  transition: background var(--motion-fast);
}

.dhm-drop-pct {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
}

.dhm-drop-abs {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

/* --------------------------------------------------------------------------
   15. Dialog timeline (components.css mirror of scoped styles in template)
   -------------------------------------------------------------------------- */

.dialog-timeline {
  background: var(--bg-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-family: var(--font-ui);
  color: var(--fg-1);
  min-width: 280px;
}

.dialog-timeline__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-weak);
  margin-bottom: var(--space-3);
}

.dialog-timeline__title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--letter-spacing-caps);
  text-transform: uppercase;
  color: var(--fg-2);
}

.dialog-timeline__count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

.dialog-timeline__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.dialog-timeline__item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-1);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-xs);
  border-left: 2px solid var(--border-strong);
}

.dialog-timeline__glyph {
  font-family: var(--font-mono);
  color: var(--fg-1);
  font-size: var(--fs-md);
  line-height: 1;
  padding-top: 2px;
}

.dialog-timeline__body {
  min-width: 0;
}

.dialog-timeline__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

.dialog-timeline__time {
  white-space: nowrap;
}

.dialog-timeline__actor {
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.dialog-timeline__desc {
  font-size: var(--fs-sm);
  color: var(--fg-0);
  line-height: var(--lh-tight);
  word-wrap: break-word;
}

.dialog-timeline__empty {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin: 0;
  padding: var(--space-3);
  text-align: center;
}

/* --------------------------------------------------------------------------
   16. Chat bubble extras
   -------------------------------------------------------------------------- */

.chat-bubble__text {
  display: none;
}

.chat-bubble__text.is-visible {
  display: block;
}

.chat-bubble__toggle {
  display: inline-flex;
  align-items: center;
  margin-top: var(--space-1);
  padding: 1px var(--space-1);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--sig-info);
  background: color-mix(in srgb, var(--sig-info) 15%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--sig-info) 30%, transparent);
  cursor: pointer;
  transition: background-color var(--motion-fast);
}

.chat-bubble__toggle:hover {
  background: color-mix(in srgb, var(--sig-info) 25%, var(--bg-2));
}

.chat-bubble__analyzer {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  align-self: flex-start;
  margin-top: calc(var(--space-1) * -1);
}

.chat-bubble__cost {
  align-self: flex-end;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  margin-top: var(--space-1);
}

/* Chat layout (3-pane) */

.chat-layout {
  display: grid;
  /* Two tracks by default — thread takes the space, lead pinned right.
     Timeline column appears only when ``show_events`` is on; then the
     grid gets a third track via ``.chat-layout--with-timeline``. */
  grid-template-columns: 1fr 340px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.chat-layout--with-timeline {
  grid-template-columns: 1fr 340px 320px;
}

.chat-layout__thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border-right: 1px solid var(--border-weak);
  overflow-y: auto;
  background: var(--bg-1);
  min-height: 0;
}

.chat-layout__lead {
  border-left: 1px solid var(--border-weak);
  overflow-y: auto;
  background: var(--bg-1);
}

.chat-layout__timeline {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--border-weak);
  background: var(--bg-1);
}

/* --------------------------------------------------------------------------
   17. Tracker tables
   -------------------------------------------------------------------------- */

.campaigns-table {
  width: 100%;
  border-collapse: collapse;
}

.campaigns-table__row {
  border-bottom: 1px solid var(--border-weak);
  transition: background-color var(--motion-fast);
}

.campaigns-table__row:hover {
  background: var(--bg-3);
}

.campaigns-table__expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-xs);
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  transition: background-color var(--motion-fast), color var(--motion-fast);
}

.campaigns-table__expand-btn:hover {
  background: var(--bg-4);
  color: var(--fg-0);
}

.campaigns-table__expand-row {
  background: var(--bg-1);
}

.campaigns-table__expand-cell {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-strong);
}

.buyers-table {
  width: 100%;
  border-collapse: collapse;
}

.buyers-table__row {
  height: 32px;
  border-bottom: 1px solid var(--border-weak);
  transition: background-color var(--motion-fast);
}

.buyers-table__row:hover {
  background: var(--bg-3);
}

.buyers-table__user {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   18. Asset picker
   -------------------------------------------------------------------------- */

.asset-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  max-height: 420px;
  overflow-y: auto;
}

.asset-picker__empty {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
  padding: var(--space-4);
  text-align: center;
}

.asset-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.asset-group__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-weak);
}

.asset-group__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-2);
}

.asset-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  cursor: pointer;
  transition: border-color var(--motion-fast), background-color var(--motion-fast);
}

.asset-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-4);
}

.asset-card__thumb {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: var(--radius-xs);
  display: block;
}

.asset-card__caption {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.asset-card__template {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   19. Button modifiers
   -------------------------------------------------------------------------- */

.btn--icon {
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
}

.btn--accent {
  background: color-mix(in srgb, var(--sig-lime) 20%, var(--bg-3));
  color: var(--sig-lime);
  border-color: color-mix(in srgb, var(--sig-lime) 40%, transparent);
}

.btn--accent:hover:not(:disabled) {
  background: color-mix(in srgb, var(--sig-lime) 30%, var(--bg-3));
  border-color: var(--sig-lime);
}

.btn--outline {
  background: transparent;
  color: var(--fg-0);
  border-color: var(--border-strong);
}

.btn--outline:hover:not(:disabled) {
  background: var(--bg-3);
  border-color: var(--border-glow);
}

.btn--warn {
  background: color-mix(in srgb, var(--sig-warn) 15%, var(--bg-3));
  color: var(--sig-warn);
  border-color: color-mix(in srgb, var(--sig-warn) 40%, transparent);
}

.btn--warn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--sig-warn) 25%, var(--bg-3));
  border-color: var(--sig-warn);
}

.btn--xs {
  height: 20px;
  padding: 0 var(--space-2);
  font-size: 10px;
}

.btn--active {
  background: var(--bg-4);
  color: var(--fg-0);
  border-color: var(--border-glow);
  box-shadow: 0 0 0 2px rgba(58, 213, 255, 0.12);
}

.btn--select-asset {
  display: block;
  width: 100%;
  margin-top: var(--space-1);
  height: 24px;
  padding: 0 var(--space-2);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  font-weight: var(--fw-semibold);
  background: color-mix(in srgb, var(--sig-info) 15%, var(--bg-2));
  color: var(--sig-info);
  border: 1px solid color-mix(in srgb, var(--sig-info) 30%, transparent);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background-color var(--motion-fast);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
}

.btn--select-asset:hover {
  background: color-mix(in srgb, var(--sig-info) 25%, var(--bg-2));
  border-color: var(--sig-info);
}

.btn-group {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.btn-group .btn:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* --------------------------------------------------------------------------
   20. Chip modifiers
   -------------------------------------------------------------------------- */

.chip--info {
  background: color-mix(in srgb, var(--sig-info) 20%, var(--bg-2));
  color: var(--sig-info);
}

.chip--dim {
  background: var(--bg-3);
  color: var(--fg-3);
  opacity: 0.7;
}

.chip--crm {
  background: color-mix(in srgb, var(--sig-violet) 18%, var(--bg-2));
  color: var(--sig-violet);
}

.chip--mode {
  background: color-mix(in srgb, var(--sig-magenta) 15%, var(--bg-2));
  color: var(--sig-magenta);
}

.chip--stage {
  background: color-mix(in srgb, var(--sig-info) 15%, var(--bg-2));
  color: var(--sig-info);
}

.chip--accent {
  background: color-mix(in srgb, var(--sig-lime) 20%, var(--bg-2));
  color: var(--sig-lime);
}

.chip--bundle {
  background: color-mix(in srgb, var(--panel-accent, var(--sig-info)) 18%, var(--bg-2));
  color: var(--panel-accent, var(--sig-info));
  font-family: var(--font-mono);
  text-transform: none;
  letter-spacing: 0;
}

.chip--mono {
  font-family: var(--font-mono);
  text-transform: none;
  letter-spacing: 0;
  background: var(--bg-3);
  color: var(--fg-1);
}

.chip--muted {
  background: var(--bg-3);
  color: var(--fg-3);
  opacity: 0.85;
}

.chip--role {
  background: color-mix(in srgb, var(--sig-violet) 15%, var(--bg-2));
  color: var(--sig-violet);
}

.chip--success {
  background: color-mix(in srgb, var(--sig-success) 20%, var(--bg-2));
  color: var(--sig-success);
}

.chip--tag {
  background: color-mix(in srgb, var(--sig-lime) 12%, var(--bg-2));
  color: var(--sig-lime);
  font-family: var(--font-mono);
  text-transform: none;
  letter-spacing: 0;
}

.chip-cell {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   21. Callout / info banner
   -------------------------------------------------------------------------- */

.callout {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-3);
  font-size: var(--fs-sm);
  color: var(--fg-1);
}

.callout--success {
  border-color: color-mix(in srgb, var(--sig-success) 40%, transparent);
  background: color-mix(in srgb, var(--sig-success) 10%, var(--bg-2));
  color: var(--sig-success);
}

.callout--error {
  border-color: color-mix(in srgb, var(--sig-error) 40%, transparent);
  background: color-mix(in srgb, var(--sig-error) 10%, var(--bg-2));
  color: var(--sig-error);
}

/* --------------------------------------------------------------------------
   22. Breadcrumb
   -------------------------------------------------------------------------- */

.breadcrumb__link {
  color: var(--fg-2);
  font-size: var(--fs-sm);
  text-decoration: none;
  transition: color var(--motion-fast);
}

.breadcrumb__link:hover {
  color: var(--fg-0);
}

.breadcrumb__sep {
  color: var(--fg-3);
  font-size: var(--fs-sm);
  margin: 0 var(--space-1);
  user-select: none;
}

.breadcrumb__current {
  color: var(--fg-0);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

/* --------------------------------------------------------------------------
   23. Bundle badge
   -------------------------------------------------------------------------- */

.bundle-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--bundle-color, var(--sig-info)) 15%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--bundle-color, var(--sig-info)) 35%, transparent);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--bundle-color, var(--sig-info));
  white-space: nowrap;
}

.bundle-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   24. Color swatch
   -------------------------------------------------------------------------- */

.color-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   25. Dot utility (generic signal dot)
   -------------------------------------------------------------------------- */

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-3);
  flex-shrink: 0;
  vertical-align: middle;
}

.dot--lime {
  background: var(--sig-lime);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--sig-lime) 25%, transparent);
}

.dot--success {
  background: var(--sig-success);
}

.dot--muted {
  background: var(--fg-3);
}

/* --------------------------------------------------------------------------
   26. Dialog filters
   -------------------------------------------------------------------------- */

.dialog-filters {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-weak);
}

.dialog-filters__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 80px;
}

.dialog-filters__field--grow {
  flex: 1;
  min-width: 180px;
}

.dialog-filters__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
  white-space: nowrap;
}

.dialog-filters__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   27. Dialog pagination
   -------------------------------------------------------------------------- */

.dialog-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border-weak);
  background: var(--bg-1);
  flex-shrink: 0;
}

.dialog-pagination__nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.dialog-pagination__summary {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   28. Dialog row extras
   -------------------------------------------------------------------------- */

.dialog-row__chips {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   29. Domain list (landings)
   -------------------------------------------------------------------------- */

.domain-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border-weak);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-weak);
}

.domain-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-2);
  transition: background-color var(--motion-fast);
}

.domain-item:hover {
  background: var(--bg-3);
}

.domain-name {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--fg-0);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   30. Hotness histogram
   -------------------------------------------------------------------------- */

.hotness-hist {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
}

.hotness-hist__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.hotness-hist__bar-track {
  flex: 1;
  width: 100%;
  background: var(--bg-3);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.hotness-hist__bar {
  width: 100%;
  min-height: 2px;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  transition: height var(--motion-fast);
}

.hotness-hist__label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  line-height: 1;
}

.hotness-hist__count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-2);
  line-height: 1;
}

/* --------------------------------------------------------------------------
   31. LLM cost trend SVG
   -------------------------------------------------------------------------- */

.llm-cost__trend {
  width: 100%;
  height: 80px;
  display: block;
  overflow: visible;
}

.llm-cost__trend-line {
  fill: none;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.llm-cost__axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   32. Time-to grid
   -------------------------------------------------------------------------- */

.time-to-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.time-to-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

.time-to-card__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.time-to-card__value {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  font-variant-numeric: tabular-nums;
}

.time-to-card__n {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

/* --------------------------------------------------------------------------
   33. Postback health inner section
   -------------------------------------------------------------------------- */

.postback-health__in {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-weak);
}

/* --------------------------------------------------------------------------
   34. Takeover toggle
   -------------------------------------------------------------------------- */

.takeover-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   35. Operator composer
   -------------------------------------------------------------------------- */

.operator-composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  border-top: 1px solid var(--border-weak);
}

.operator-composer__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.operator-composer__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.operator-composer__textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  resize: vertical;
  min-height: 64px;
  transition: border-color var(--motion-fast);
}

.operator-composer__textarea:focus-visible {
  outline: none;
  border-color: var(--border-glow);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--border-glow) 25%, transparent);
}

.operator-composer__override {
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.operator-composer__override > summary {
  cursor: pointer;
  user-select: none;
  padding: var(--space-1) 0;
  color: var(--fg-3);
}

.operator-composer__asset-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.operator-composer__asset-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.operator-composer__actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-2);
}

/* --------------------------------------------------------------------------
   36. Translator preview
   -------------------------------------------------------------------------- */

.translator-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  min-height: 48px;
}

.translator-preview__text {
  font-size: var(--fs-sm);
  color: var(--fg-0);
  line-height: var(--lh-normal);
  word-wrap: break-word;
}

.translator-preview__text--empty {
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

.translator-preview__meta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   37. Saved filters sidebar
   -------------------------------------------------------------------------- */

.saved-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-1);
  border-right: 1px solid var(--border-weak);
  min-width: 200px;
  max-width: 260px;
}

.saved-filters__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.saved-filters__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  margin: 0;
}

.saved-filters__subtitle {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
  margin: 0 0 var(--space-1) 0;
}

.saved-filters__section {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.saved-filters__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.saved-filters__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-xs);
  transition: background-color var(--motion-fast);
}

.saved-filters__item:hover {
  background: var(--bg-3);
}

.saved-filters__item--shared {
  opacity: 0.85;
}

.saved-filters__link {
  font-size: var(--fs-sm);
  color: var(--fg-1);
  text-decoration: none;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.saved-filters__link:hover {
  color: var(--fg-0);
}

.saved-filters__badge {
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--fw-semibold);
  background: var(--bg-4);
  color: var(--fg-3);
  letter-spacing: var(--letter-spacing-caps);
  text-transform: uppercase;
}

.saved-filters__badge--team {
  background: color-mix(in srgb, var(--sig-info) 15%, var(--bg-2));
  color: var(--sig-info);
}

.saved-filters__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--motion-fast);
}

.saved-filters__item:hover .saved-filters__actions {
  opacity: 1;
}

.saved-filters__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-family: var(--font-ui);
  color: var(--fg-2);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: color var(--motion-fast), background-color var(--motion-fast);
}

.saved-filters__icon:hover {
  color: var(--fg-0);
  background: var(--bg-4);
  border-color: var(--border-strong);
}

.saved-filters__icon--danger {
  color: var(--sig-error);
  opacity: 0.7;
}

.saved-filters__icon--danger:hover {
  color: var(--sig-error);
  opacity: 1;
  background: color-mix(in srgb, var(--sig-error) 15%, transparent);
  border-color: color-mix(in srgb, var(--sig-error) 40%, transparent);
}

.saved-filters__empty {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-style: italic;
  margin: 0;
}

.saved-filters__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.saved-filters__field--inline {
  flex-direction: row;
  align-items: center;
}

.saved-filters__toggle {
  font-size: var(--fs-xs);
  padding: 0 var(--space-2);
  height: 22px;
}

.saved-filters__modal {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  margin-top: var(--space-2);
}

.saved-filters__modal[hidden] {
  display: none;
}

.saved-filters__modal-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  margin: 0;
}

.saved-filters__modal-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   38. Lead card (right rail)
   -------------------------------------------------------------------------- */

.lead-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-1);
  border-left: 1px solid var(--border-weak);
  height: 100%;
  overflow-y: auto;
}

.lead-card__header {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border-weak);
  flex-shrink: 0;
}

.lead-card__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  margin: 0;
}

.lead-card__sub {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  margin-top: 2px;
}

.lead-card__section {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-weak);
}

.lead-card__section-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
  margin: 0 0 var(--space-2) 0;
}

.lead-card__kv {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--space-3);
  row-gap: 4px;
  align-items: baseline;
}

.lead-card__k {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  white-space: nowrap;
}

.lead-card__v {
  font-size: var(--fs-sm);
  color: var(--fg-0);
}

.lead-card__v--truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.lead-card__hint {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin: 0;
  font-style: italic;
}

.lead-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-2);
}

.lead-card__form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.lead-card__form--column {
  flex-direction: column;
  align-items: stretch;
}

.lead-card__history {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: var(--fs-xs);
  color: var(--fg-1);
}

.lead-card__details {
  margin-top: var(--space-2);
}

.lead-card__details > summary {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  cursor: pointer;
  user-select: none;
}

.lead-card__audit {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--fg-1);
}

/* --------------------------------------------------------------------------
   39. Page header extras
   -------------------------------------------------------------------------- */

.page--chat {
  padding: 0;
  height: 100%;
  overflow: hidden;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-weak);
  flex-shrink: 0;
}

.page-header__left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-header__breadcrumb {
  display: flex;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  margin-bottom: 2px;
}

.page-header__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  margin: 0;
}

.page-header__sub {
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.page__header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.page__header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page__header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.page__header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.page__action {
  /* used as a flex wrapper or direct button context */
}

.page__title-sub {
  font-size: var(--fs-sm);
  color: var(--fg-2);
  margin: 2px 0 0;
}

/* --------------------------------------------------------------------------
   40. Filter bar (general)
   -------------------------------------------------------------------------- */

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-weak);
}

.filter-bar__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.filter-bar__group--toggle {
  flex-direction: row;
  align-items: center;
}

.filter-bar__legend,
.filter-bar__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
  white-space: nowrap;
}

.filter-bar__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.filter-bar__prefix {
  position: absolute;
  left: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
  pointer-events: none;
  z-index: 1;
}

.filter-bar__input {
  height: 28px;
  padding: 0 var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  transition: border-color var(--motion-fast);
}

.filter-bar__input:focus-visible {
  outline: none;
  border-color: var(--border-glow);
}

.filter-bar__input--mono {
  font-family: var(--font-mono);
}

.filter-bar__select {
  height: 28px;
  padding: 0 var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.filter-bar__reset {
  height: 28px;
  padding: 0 var(--space-3);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--motion-fast);
}

.filter-bar__reset:hover {
  color: var(--sig-error);
}

.filter-bar__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--sig-info);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.filter-bar__hint {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   41. Form elements (generics)
   -------------------------------------------------------------------------- */

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-field--action {
  justify-content: flex-end;
}

.form-field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.form-field--narrow {
  max-width: 200px;
}

.form-grid__actions {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  justify-content: flex-end;
}

.form-input {
  height: 32px;
  padding: 0 var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  width: 100%;
  transition: border-color var(--motion-fast);
}

.form-input:focus-visible {
  outline: none;
  border-color: var(--border-glow);
}

.form-input--select {
  cursor: pointer;
}

.form-input--sm {
  height: 26px;
  font-size: var(--fs-xs);
  padding: 0 var(--space-2);
}

.form-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.form-label--checkbox {
  font-size: var(--fs-sm);
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg-1);
  cursor: pointer;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-row--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
}

.inline-form {
  display: inline;
}

.input--sm {
  height: 26px;
  padding: 0 var(--space-2);
  font-size: var(--fs-xs);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  font-family: var(--font-ui);
}

/* --------------------------------------------------------------------------
   42. Field modifiers
   -------------------------------------------------------------------------- */

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.field--radiogroup {
  gap: var(--space-2);
}

.field__checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--sig-info);
  cursor: pointer;
  flex-shrink: 0;
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-style: italic;
}

.field__input--mono {
  font-family: var(--font-mono);
}

.field__select {
  appearance: none;
  -webkit-appearance: none;
  height: 32px;
  padding: 0 var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  width: 100%;
  cursor: pointer;
  transition: border-color var(--motion-fast);
}

.field__select:focus-visible {
  outline: none;
  border-color: var(--border-glow);
}

.field__textarea {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  width: 100%;
  line-height: var(--lh-normal);
  resize: vertical;
  transition: border-color var(--motion-fast);
}

.field__textarea:focus-visible {
  outline: none;
  border-color: var(--border-glow);
}

/* --------------------------------------------------------------------------
   43. Table utility classes
   -------------------------------------------------------------------------- */

.td--num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.td--mono {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

.td--muted {
  color: var(--fg-3);
}

.td--secondary {
  color: var(--fg-2);
  font-size: var(--fs-sm);
}

.td--label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.td--action {
  text-align: right;
  white-space: nowrap;
}

.td--actions {
  text-align: right;
  white-space: nowrap;
}

.td--center {
  text-align: center;
}

.td--pct {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.td--priority {
  font-weight: var(--fw-semibold);
}

.td--empty {
  color: var(--fg-3);
  text-align: center;
  font-style: italic;
  font-size: var(--fs-sm);
}

.td--campaign-name {
  font-weight: var(--fw-medium);
  color: var(--fg-0);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.th--num {
  text-align: right;
  font-family: var(--font-mono);
}

.th--mono {
  font-family: var(--font-mono);
}

.th--label { /* default — no extra styles needed */ }

.th--action,
.th--actions {
  text-align: right;
}

.th--priority,
.th--text { /* default */ }

.tr--empty td {
  text-align: center;
  color: var(--fg-3);
  font-style: italic;
  padding: var(--space-4);
}

.tr--totals td {
  font-weight: var(--fw-semibold);
  border-top: 1px solid var(--border-strong);
  color: var(--fg-0);
}

.tr--source td {
  background: var(--bg-3);
  font-weight: var(--fw-medium);
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
  border-radius: var(--radius-sm);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border-weak);
  background: var(--bg-1);
}

.table-footer__count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

.table-footer__period {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

/* --------------------------------------------------------------------------
   44. Log table (postback logs / source logs)
   -------------------------------------------------------------------------- */

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.log-table__ts {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  white-space: nowrap;
}

.log-table__ts-summary {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

.log-table__event-type {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
}

.log-table__source {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.log-table__hmac {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  letter-spacing: 0;
}

.log-table__bool {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.log-table__retry {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--sig-warn);
}

.log-table__json,
.log-table__raw-body {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-2);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-table__row {
  height: 28px;
  border-bottom: 1px solid var(--border-weak);
  transition: background-color var(--motion-fast);
}

.log-table__row:hover {
  background: var(--bg-3);
}

.log-table__row--expandable {
  cursor: pointer;
}

.log-table__empty,
.log-table__empty-cell {
  text-align: center;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: var(--space-4);
}

/* --------------------------------------------------------------------------
   45. Log filters / pagination
   -------------------------------------------------------------------------- */

.log-filters {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-weak);
}

.log-filter__date,
.log-filter__search,
.log-filter__select {
  height: 28px;
  padding: 0 var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
}

.log-filter__date:focus-visible,
.log-filter__search:focus-visible,
.log-filter__select:focus-visible {
  outline: none;
  border-color: var(--border-glow);
}

.log-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border-weak);
  background: var(--bg-1);
}

.log-pagination__nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.log-pagination__summary {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   46. Source / platform UI
   -------------------------------------------------------------------------- */

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 1px var(--space-2);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  background: var(--bg-3);
  color: var(--fg-1);
  border: 1px solid var(--border-weak);
}

.source-platform {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
}

.sources-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sources-section__note {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-style: italic;
}

.sources-table {
  width: 100%;
  border-collapse: collapse;
}

.sources-table--footer {
  border-top: 2px solid var(--border-strong);
}

/* --------------------------------------------------------------------------
   47. SSL chip / ROI chip
   -------------------------------------------------------------------------- */

.ssl-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px var(--space-1);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--fw-semibold);
  background: color-mix(in srgb, var(--sig-success) 15%, var(--bg-2));
  color: var(--sig-success);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
}

.roi-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 20px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  background: color-mix(in srgb, var(--sig-success) 20%, var(--bg-2));
  color: var(--sig-success);
}

.roi-chip--neutral {
  background: var(--bg-3);
  color: var(--fg-2);
}

/* --------------------------------------------------------------------------
   48. Tracker card
   -------------------------------------------------------------------------- */

.tracker-card {
  background: var(--bg-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}

.tracker-card--full {
  width: 100%;
}

.tracker-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.tracker-card__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  margin: 0;
}

.tracker-buyers {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.tracker-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
}

.tracker-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-weak);
}

.tracker-summary__table {
  width: 100%;
}

.tracker-summary__footer {
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-weak);
  margin-top: var(--space-2);
}

.tracker-summary__link {
  font-size: var(--fs-xs);
  color: var(--sig-info);
  text-decoration: none;
  font-family: var(--font-mono);
  transition: color var(--motion-fast);
}

.tracker-summary__link:hover {
  color: var(--fg-0);
}

/* --------------------------------------------------------------------------
   49. Dropoff heatmap (inline style from campaign_dropoff_heatmap.html)
   -------------------------------------------------------------------------- */

/* Already defined in section 14 — mirrored here from the scoped <style> block */
/* .dropoff-heatmap, .dhm-cell etc. covered above */

/* --------------------------------------------------------------------------
   50. Info banner
   -------------------------------------------------------------------------- */

.info-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: color-mix(in srgb, var(--sig-info) 10%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--sig-info) 30%, transparent);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--fg-1);
}

.info-banner__label {
  font-weight: var(--fw-semibold);
  color: var(--sig-info);
  white-space: nowrap;
}

.info-banner__macros {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* --------------------------------------------------------------------------
   51. Platform option (wizard)
   -------------------------------------------------------------------------- */

.platform-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--bg-3);
  border: 2px solid var(--border-weak);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--motion-fast), background-color var(--motion-fast);
}

.platform-option:hover {
  border-color: var(--border-strong);
  background: var(--bg-4);
}

.platform-option input:checked + .platform-option,
.platform-option:has(input:checked) {
  border-color: var(--sig-info);
  background: color-mix(in srgb, var(--sig-info) 8%, var(--bg-3));
}

.platform-option__label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-0);
  text-align: center;
}

/* --------------------------------------------------------------------------
   52. Wizard progress
   -------------------------------------------------------------------------- */

.wizard {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6);
  max-width: 640px;
  margin: 0 auto;
}

.wizard-progress {
  display: flex;
  align-items: center;
}

.wizard-progress__list {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.wizard-progress__item {
  /* base; modifiers below */
}

.wizard-progress__dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  background: var(--bg-4);
  color: var(--fg-2);
  border: 1px solid var(--border-strong);
  transition: background-color var(--motion-fast), color var(--motion-fast);
}

.wizard-progress__item--active .wizard-progress__dot {
  background: var(--sig-info);
  color: var(--bg-0);
  border-color: var(--sig-info);
}

.wizard-progress__item--done .wizard-progress__dot {
  background: var(--sig-success);
  color: var(--bg-0);
  border-color: var(--sig-success);
}

.wizard-progress__label {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  margin-left: var(--space-1);
  white-space: nowrap;
}

.wizard-progress__item--active .wizard-progress__label {
  color: var(--fg-0);
  font-weight: var(--fw-medium);
}

.wizard-review {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.wizard-review__grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-4);
  align-items: baseline;
}

.wizard-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.wizard-summary__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

/* --------------------------------------------------------------------------
   53. Editor tabs (knowledge / prompt editor)
   -------------------------------------------------------------------------- */

.editor-tabs {
  display: flex;
  align-items: stretch;
  height: var(--tabs-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-strong);
  padding: 0 var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}

.editor-tabs::-webkit-scrollbar {
  display: none;
}

.editor-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 100%;
  color: var(--fg-1);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: background-color var(--motion-fast), color var(--motion-fast);
  white-space: nowrap;
  text-decoration: none;
}

.editor-tab:hover {
  background: var(--bg-3);
  color: var(--fg-0);
}

.editor-tab.active {
  background: var(--bg-2);
  color: var(--fg-0);
  border-bottom-color: var(--sig-info);
}

.editor-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   54. CodeMirror host
   -------------------------------------------------------------------------- */

.cm-host {
  flex: 1;
  overflow: hidden;
  background: var(--bg-1);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

/* --------------------------------------------------------------------------
   55. Sample value
   -------------------------------------------------------------------------- */

.sample-value {
  display: inline-block;
}

.sample-value__text {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-1);
  word-break: break-all;
}

.sample-value__empty {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   56. Parameter table
   -------------------------------------------------------------------------- */

.params-table {
  width: 100%;
  border-collapse: collapse;
}

.param-row--view {
  height: 28px;
  border-bottom: 1px solid var(--border-weak);
}

.param-row--edit {
  background: var(--bg-3);
  border-bottom: 1px solid var(--border-strong);
}

.param-row-cell {
  padding: 4px var(--space-3);
  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   57. Bundle row actions
   -------------------------------------------------------------------------- */

.bundle-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: flex-end;
  white-space: nowrap;
}

.bundle-edit__color {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* --------------------------------------------------------------------------
   58. Link utilities
   -------------------------------------------------------------------------- */

.link {
  color: var(--fg-1);
  text-decoration: none;
  transition: color var(--motion-fast);
}

.link:hover {
  color: var(--fg-0);
}

.link--accent {
  color: var(--sig-info);
  text-decoration: none;
}

.link--accent:hover {
  color: var(--fg-0);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link--muted {
  color: var(--fg-2);
  text-decoration: none;
}

.link--muted:hover {
  color: var(--fg-0);
}

.link--subtle {
  color: var(--fg-3);
  text-decoration: none;
  font-size: var(--fs-xs);
}

.link--subtle:hover {
  color: var(--fg-1);
}

.lead-row__link {
  color: var(--fg-0);
  text-decoration: none;
  font-weight: var(--fw-medium);
}

.lead-row__link:hover {
  color: var(--sig-info);
}

/* --------------------------------------------------------------------------
   59. Text color utilities
   -------------------------------------------------------------------------- */

.fg-1 { color: var(--fg-1); }
.fg-2 { color: var(--fg-2); }
.fg-3 { color: var(--fg-3); }
.fs-sm { font-size: var(--fs-sm); }

/* --------------------------------------------------------------------------
   60. Empty state extras
   -------------------------------------------------------------------------- */

.empty-state__icon {
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--fg-3);
  display: block;
  text-align: center;
}

.empty-state__text {
  font-size: var(--fs-sm);
  color: var(--fg-2);
  text-align: center;
}

.empty-state--inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg-3);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   61. Card extras
   -------------------------------------------------------------------------- */

.card--form {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* --------------------------------------------------------------------------
   62. Auth card extras
   -------------------------------------------------------------------------- */

.auth-card__meta {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  text-align: center;
}

/* --------------------------------------------------------------------------
   63. Heatmap table
   -------------------------------------------------------------------------- */

.heatmap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.heatmap-table__cell {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-align: right;
  padding: 4px 8px;
  border: 1px solid var(--border-weak);
  font-variant-numeric: tabular-nums;
  transition: background-color var(--motion-fast);
}

.heatmap-table__stage {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  padding: 4px 8px;
  white-space: nowrap;
}

.heatmap-table__stage-head {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
  padding: 4px 8px;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   64. Hotness scale text helpers (DESIGN.md color assignments)
   -------------------------------------------------------------------------- */

.hotness-1  { color: var(--hotness-1); }
.hotness-2  { color: var(--hotness-2); }
.hotness-3  { color: var(--hotness-3); }
.hotness-4  { color: var(--hotness-4); }
.hotness-5  { color: var(--hotness-5); }
.hotness-6  { color: var(--hotness-6); }
.hotness-7  { color: var(--hotness-7); }
.hotness-8  { color: var(--hotness-8); }
.hotness-9  { color: var(--hotness-9); }
.hotness-10 { color: var(--hotness-10); }

/* --------------------------------------------------------------------------
   65. HTMX state helpers
   -------------------------------------------------------------------------- */

.is-visible {
  display: block;
}

.htmx-request .btn {
  opacity: 0.6;
  cursor: wait;
}

/* --------------------------------------------------------------------------
   66. Dropoff (campaign_row.html — styles also in scoped <style>, mirrored)
   -------------------------------------------------------------------------- */

.dropoff {
  padding: var(--space-3) 0 var(--space-2);
}

.dropoff__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.dropoff__label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.dropoff__period {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin-left: auto;
}

.dropoff__empty {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-family: var(--font-mono);
}

.dropoff__funnel {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.dropoff__stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  min-width: 72px;
}

.dropoff__stage-name {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.dropoff__stage-count {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.dropoff__stage-pct {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  color: var(--fg-2);
}

.dropoff__stage-pct--empty {
  color: var(--fg-3);
}

.dropoff__connector {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--fg-3);
  flex-shrink: 0;
}

.dropoff-placeholder {
  height: 32px;
  background: var(--bg-3);
  border-radius: var(--radius-xs);
  opacity: 0.5;
}

/* --------------------------------------------------------------------------
   67. Organic / misc state classes
   -------------------------------------------------------------------------- */

.organic {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--fs-xs);
  color: var(--sig-success);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   68. Elif helper (template-rendered conditional — class exists for DOM queries)
   -------------------------------------------------------------------------- */

.elif { /* structural — no visual style required */ }

/* --------------------------------------------------------------------------
   69. JS-controlled visibility
   -------------------------------------------------------------------------- */

.js-events-toggle { cursor: pointer; }
.js-local-time    { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   70. Dialog row hotness strip text colors (is-positive / is-negative)
   -------------------------------------------------------------------------- */

.is-positive { color: var(--sig-success); }
.is-negative { color: var(--sig-error); }

/* --------------------------------------------------------------------------
   71. total_roi (camelCase class from template — plain display)
   -------------------------------------------------------------------------- */

.total_roi {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--sig-success);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   72. Dropoff heatmap compound: header/body (already covered in section 14)
   -------------------------------------------------------------------------- */
/* .dropoff-heatmap__head / .dropoff-heatmap__body defined above */

/* ==========================================================================
   PREMIUM UI PASS — glassmorphism / wizard / button states / motion
   2026-04-22. Additive — all existing selectors above are preserved.
   ========================================================================== */

/* --------------------------------------------------------------------------
   73. Global motion polish (expo-out easing on all micro-transitions)
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  *,
  *::before,
  *::after {
    transition-timing-function: var(--ease-expo-out);
  }
}

/* --------------------------------------------------------------------------
   74. Global focus-visible polish — replace browser defaults with our ring
   -------------------------------------------------------------------------- */

:focus-visible {
  outline: var(--ring-width) solid var(--ring-color) !important;
  outline-offset: var(--ring-offset) !important;
  box-shadow: 0 0 0 4px rgba(58, 213, 255, 0.12) !important;
  border-radius: var(--radius-xs);
}

/* --------------------------------------------------------------------------
   75. .btn — thorough state system upgrade
   Enhances existing .btn selectors; specific states are layered on top.
   -------------------------------------------------------------------------- */

/* Base layer: subtle glass bg + 1px translucent border */
.btn {
  position: relative;
  overflow: hidden;
  transform: translateY(0) scale(1);
  transition:
    background-color var(--dur-micro) var(--ease-expo-out),
    border-color     var(--dur-micro) var(--ease-expo-out),
    color            var(--dur-micro) var(--ease-expo-out),
    box-shadow       var(--dur-micro) var(--ease-expo-out),
    transform        var(--dur-micro) var(--ease-expo-out),
    opacity          var(--dur-micro) var(--ease-expo-out);
}

/* Hover: lift + border brighten */
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

/* Active/pressed: scale down + elevation collapse, fast */
.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  transition-duration: 80ms;
}

/* Disabled: no pointer, reduced opacity */
.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary: filled with subtle glass highlight overlay */
.btn--primary {
  background: var(--bg-3);
  color: var(--fg-0);
  border-color: var(--border-strong);
  box-shadow: var(--elev-1);
}

.btn--primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(255, 255, 255, 0.00) 60%
  );
  pointer-events: none;
  border-radius: inherit;
}

.btn--primary:hover:not(:disabled) {
  background: var(--bg-4);
  border-color: var(--border-glow);
  box-shadow: var(--elev-2),
              0 0 0 1px rgba(58, 213, 255, 0.14);
}

.btn--primary:active:not(:disabled) {
  box-shadow: none;
  border-color: var(--border-strong);
}

.btn--primary:focus-visible {
  box-shadow: var(--elev-1),
              0 0 0 var(--ring-width) var(--ring-color),
              0 0 0 4px rgba(58, 213, 255, 0.15) !important;
  outline: none !important;
}

/* Wizard-specific: primary variant that uses indigo accent */
.btn--primary-accent {
  background: var(--indigo-600);
  color: #fff;
  border-color: var(--indigo-500);
  box-shadow: var(--elev-2);
}

.btn--primary-accent::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(255, 255, 255, 0.00) 60%
  );
  pointer-events: none;
  border-radius: inherit;
}

.btn--primary-accent:hover:not(:disabled) {
  background: var(--indigo-500);
  border-color: var(--indigo-400);
  box-shadow: var(--elev-3),
              0 0 0 1px rgba(94, 106, 210, 0.30);
  transform: translateY(-1px);
}

.btn--primary-accent:active:not(:disabled) {
  background: var(--indigo-700);
  transform: translateY(0) scale(0.97);
  box-shadow: var(--elev-1);
  transition-duration: 80ms;
}

.btn--primary-accent:focus-visible {
  box-shadow: var(--elev-2),
              0 0 0 var(--ring-width) var(--indigo-400),
              0 0 0 4px rgba(94, 106, 210, 0.22) !important;
  outline: none !important;
}

.btn--primary-accent:disabled {
  background: var(--indigo-700);
  border-color: transparent;
  opacity: 0.38;
}

/* Ghost: text-only, underline + faint bg on hover */
.btn--ghost {
  background: transparent;
  color: var(--fg-2);
  border-color: transparent;
  box-shadow: none;
}

.btn--ghost:hover:not(:disabled) {
  color: var(--fg-0);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--glass-border);
}

.btn--ghost:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.02);
}

/* --------------------------------------------------------------------------
   76. .field__input — enhanced focus + glass surface
   -------------------------------------------------------------------------- */

.field__input {
  transition:
    border-color var(--dur-micro) var(--ease-expo-out),
    background   var(--dur-micro) var(--ease-expo-out),
    box-shadow   var(--dur-micro) var(--ease-expo-out);
  height: 36px;         /* upgrade from 32px — more comfortable tap target */
  padding: 0 var(--space-3);
}

textarea.field__input {
  height: auto;
  padding: var(--space-2) var(--space-3);
  resize: vertical;
  min-height: 72px;
}

select.field__input {
  height: 36px; /* sync with .field__input height upgrade */
  cursor: pointer;
}

.field__input:focus {
  outline: none;
  border-color: var(--border-glow);
  background: color-mix(in srgb, var(--bg-3) 100%, var(--sig-info) 3%);
  box-shadow: 0 0 0 2px rgba(58, 213, 255, 0.14),
              inset 0 1px 2px rgba(0, 0, 0, 0.20);
}

.field__input:focus-visible {
  outline: none !important;
  border-color: var(--border-glow) !important;
  box-shadow: 0 0 0 3px rgba(58, 213, 255, 0.16),
              inset 0 1px 2px rgba(0, 0, 0, 0.20) !important;
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  line-height: var(--lh-loose);
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   77. .chip--info-card — info display chip (e.g. "Bot from step 1: @X")
   -------------------------------------------------------------------------- */

.chip--info-card {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: auto;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--sig-info) 10%, var(--bg-3));
  border: 1px solid color-mix(in srgb, var(--sig-info) 22%, transparent);
  color: var(--fg-1);
  font-size: var(--fs-xs);
  text-transform: none;
  letter-spacing: 0;
  font-weight: var(--fw-regular);
  white-space: nowrap;
}

.chip--info-card .chip--info-card__key {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.chip--info-card .chip--info-card__value {
  font-family: var(--font-mono);
  color: var(--sig-info);
  font-size: var(--fs-xs);
}

/* --------------------------------------------------------------------------
   78. .card--interactive — hover elevation for clickable cards
   -------------------------------------------------------------------------- */

.card--interactive {
  cursor: pointer;
  transition:
    border-color  var(--dur-micro) var(--ease-expo-out),
    box-shadow    var(--dur-micro) var(--ease-expo-out),
    background    var(--dur-micro) var(--ease-expo-out),
    transform     var(--dur-micro) var(--ease-expo-out);
}

.card--interactive:hover {
  border-color: var(--border-strong);
  box-shadow: var(--elev-2);
  transform: translateY(-1px);
}

.card--interactive:active {
  transform: translateY(0);
  box-shadow: var(--elev-1);
  transition-duration: 80ms;
}

/* --------------------------------------------------------------------------
   79. .form-section — grouped field cluster with subtle top border
   -------------------------------------------------------------------------- */

.form-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-weak);
}

.form-section:first-child {
  padding-top: 0;
  border-top: none;
}

.form-section__title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
  margin: 0 0 var(--space-1);
}

/* --------------------------------------------------------------------------
   80. .form-grid--cols-2 — 2-column grid for side-by-side fields
   -------------------------------------------------------------------------- */

.form-grid--cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

@media (max-width: 600px) {
  .form-grid--cols-2 {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   81. Wizard redesign — card wrapper + stepper + layout
   -------------------------------------------------------------------------- */

/* Outer page shell for wizard views */
.wizard {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-4);
  max-width: var(--wizard-max-w);
  margin: 0 auto;
  min-height: 100%;
}

/* Wizard form card — glassmorphism surface */
.wizard__card {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-top-color: var(--glass-border-top);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-3);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Inner glass highlight streak (top edge) */
.wizard__card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.12) 30%,
    rgba(255, 255, 255, 0.12) 70%,
    transparent
  );
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  pointer-events: none;
}

/* Wizard form — stacked single column by default */
.wizard__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Actions row inside wizard card */
.wizard__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-weak);
  gap: var(--space-3);
}

/* --------------------------------------------------------------------------
   82. .wizard-stepper — horizontal stepper replacing the plain list
   -------------------------------------------------------------------------- */

.wizard-stepper {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: var(--wizard-max-w);
  margin: 0 auto;
  padding: 0;
  user-select: none;
}

.stepper__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  position: relative;
  flex: 1;
}

/* Connector line between steps */
.stepper__connector {
  flex: 1;
  height: 1px;
  margin: 0;
  margin-bottom: var(--space-4); /* align with dot center */
  background: var(--border-weak);
  position: relative;
  top: 0;
  align-self: flex-start;
  margin-top: 16px; /* half of dot height (32px dots → 16px) */
  transition: background var(--dur-medium) var(--ease-expo-out);
}

.stepper__connector--complete {
  background: var(--sig-success);
}

/* Step dot / circle */
.stepper__dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  border: 2px solid var(--border-strong);
  background: var(--bg-3);
  color: var(--fg-2);
  transition:
    background  var(--dur-short) var(--ease-expo-out),
    border-color var(--dur-short) var(--ease-expo-out),
    color        var(--dur-short) var(--ease-expo-out),
    box-shadow   var(--dur-short) var(--ease-expo-out);
  position: relative;
  flex-shrink: 0;
  z-index: 1;
}

/* Pending state (no modifier = default) */
.stepper__step--pending .stepper__dot {
  background: var(--bg-3);
  color: var(--fg-3);
  border-color: var(--border-weak);
}

/* Active state */
.stepper__step--active .stepper__dot {
  background: var(--indigo-600);
  color: #fff;
  border-color: var(--indigo-500);
  box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.22),
              var(--elev-2);
}

/* Completed state */
.stepper__step--complete .stepper__dot {
  background: color-mix(in srgb, var(--sig-success) 18%, var(--bg-3));
  color: var(--sig-success);
  border-color: var(--sig-success);
}

/* Check icon for complete dots — drawn in CSS */
.stepper__step--complete .stepper__dot::after {
  content: "";
  display: block;
  width: 10px;
  height: 6px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* Hide the number text when complete (replaced by ::after checkmark) */
.stepper__step--complete .stepper__dot-num {
  display: none;
}

/* Step label */
.stepper__label {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  white-space: nowrap;
  text-align: center;
  transition: color var(--dur-short) var(--ease-expo-out);
  font-weight: var(--fw-regular);
}

.stepper__step--active .stepper__label {
  color: var(--fg-0);
  font-weight: var(--fw-medium);
}

.stepper__step--complete .stepper__label {
  color: var(--fg-2);
}

/* --------------------------------------------------------------------------
   83. .wizard-summary upgrade — chip-style bot info row
   -------------------------------------------------------------------------- */

.wizard-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: color-mix(in srgb, var(--sig-info) 6%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--sig-info) 16%, var(--border-weak));
  border-radius: var(--radius-sm);
}

.wizard-summary__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.wizard-summary__value {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--sig-info);
}

/* --------------------------------------------------------------------------
   84. .wizard-review upgrade — better definition list layout
   -------------------------------------------------------------------------- */

.wizard-review {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.wizard-review__grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-1) var(--space-4);
  align-items: baseline;
}

.wizard-review__grid dt {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
  padding: var(--space-1) 0;
}

.wizard-review__grid dd {
  color: var(--fg-0);
  font-size: var(--fs-sm);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border-weak);
  margin-left: 0;
}

/* --------------------------------------------------------------------------
   85. Platform option upgrade — larger touch target, glass on selected
   -------------------------------------------------------------------------- */

.platform-option {
  transition:
    border-color     var(--dur-micro) var(--ease-expo-out),
    background-color var(--dur-micro) var(--ease-expo-out),
    box-shadow       var(--dur-micro) var(--ease-expo-out),
    transform        var(--dur-micro) var(--ease-expo-out);
}

.platform-option:hover {
  transform: translateY(-1px);
  box-shadow: var(--elev-1);
}

.platform-option:has(input:checked) {
  border-color: var(--indigo-500);
  background: color-mix(in srgb, var(--indigo-500) 10%, var(--bg-3));
  box-shadow: 0 0 0 1px var(--indigo-600),
              var(--elev-1);
}

/* --------------------------------------------------------------------------
   86. form-grid__actions upgrade — proper left/right split + spacing
   -------------------------------------------------------------------------- */

.form-grid__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-top: var(--space-4);
  margin-top: var(--space-2);
  border-top: 1px solid var(--border-weak);
  grid-column: 1 / -1; /* span all columns when inside a grid */
}

/* --------------------------------------------------------------------------
   87. .panel hover elevation (opt-in via data-interactive)
   -------------------------------------------------------------------------- */

.panel[data-interactive="true"] {
  cursor: pointer;
  transition:
    border-color var(--dur-micro) var(--ease-expo-out),
    box-shadow   var(--dur-micro) var(--ease-expo-out);
}

.panel[data-interactive="true"]:hover {
  border-color: var(--border-strong);
  box-shadow: var(--elev-2);
}

/* --------------------------------------------------------------------------
   88. Accent color swatch in review step
   -------------------------------------------------------------------------- */

.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: middle;
  margin-left: var(--space-1);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-xs);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   89. Chat messenger — 3-column shell (filters | list | open chat)
   Redesigns /admin/dialogs from a flat list into a chatterfy-style
   messenger. The sub-areas use their own overflow so they scroll
   independently; the outer shell pins to the viewport height.
   ========================================================================== */

.chat-messenger {
  display: grid;
  grid-template-columns: 240px 340px 1fr;
  /* Total chrome = header (--header-h) + bundle tabs (--tabs-h). Fall back
     to 96px when the vars aren't set. Subtract so we pin to the viewport
     without spilling below the fold. */
  height: calc(100vh - var(--header-h, 48px) - var(--tabs-h, 44px));
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--border-weak);
  background: var(--bg-0);
  /* Kill the default page padding applied by the layout shell. */
  margin: calc(var(--space-4) * -1);
}

.chat-messenger > * {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* --- Filters rail (col 1) ----------------------------------------------- */

.chat-messenger__filters {
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border-right: 1px solid var(--border-weak);
  overflow-y: auto;
}

.chat-filters {
  display: flex;
  flex-direction: column;
  padding: var(--space-3);
  gap: var(--space-4);
}

.chat-filters__title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.chat-filters__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-filters__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--fg-1);
  font-size: var(--fs-sm);
  text-decoration: none;
  transition: background-color var(--motion-fast), color var(--motion-fast);
}

.chat-filters__item:hover {
  background: var(--bg-2);
  color: var(--fg-0);
}

.chat-filters__item.is-active {
  background: var(--bg-3);
  color: var(--fg-0);
  box-shadow: inset 2px 0 0 var(--fg-brand);
}

.chat-filters__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-filters__count {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

.chat-filters__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.chat-filters__dot--ok      { background: var(--sig-success); }
.chat-filters__dot--info    { background: var(--sig-info); }
.chat-filters__dot--warn    { background: var(--sig-warn); }
.chat-filters__dot--err     { background: var(--sig-error); }
.chat-filters__dot--magenta { background: var(--sig-magenta); }
.chat-filters__dot--muted   { background: var(--fg-3); }

/* --- Chat list (col 2) -------------------------------------------------- */

.chat-messenger__list {
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border-right: 1px solid var(--border-weak);
  min-height: 0;
}

.chat-messenger__list-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-weak);
  flex-shrink: 0;
}

.chat-messenger__list-title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
}

.chat-messenger__list-sub {
  margin: 2px 0 0;
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.chat-messenger__advanced {
  border-bottom: 1px solid var(--border-weak);
  flex-shrink: 0;
}

.chat-messenger__advanced > summary {
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  list-style: none;
  user-select: none;
}

.chat-messenger__advanced > summary::-webkit-details-marker {
  display: none;
}

.chat-messenger__advanced > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform var(--motion-fast);
}

.chat-messenger__advanced[open] > summary::before {
  transform: rotate(90deg);
}

/* --- Main chat area (col 3) -------------------------------------------- */

.chat-messenger__main {
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  overflow: hidden;
  min-height: 0;
}

.chat-messenger__main > .chat-window,
.chat-messenger__main > .page--chat {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-window {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-window__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-weak);
  background: var(--bg-1);
  flex-shrink: 0;
}

.chat-window__heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-window .chat-layout {
  flex: 1 1 auto;
  min-height: 0;
}

/* --- Empty state in main area ------------------------------------------ */

.chat-empty {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8);
  text-align: center;
  color: var(--fg-2);
}

.chat-empty__title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  color: var(--fg-1);
}

.chat-empty__sub {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--fg-2);
  max-width: 340px;
}

/* --- Responsive fallback ---------------------------------------------- */
/* Below 1100px hide the filter rail; the list + chat keeps the app
   usable on laptop half-screens. The legacy advanced-filter <details>
   still exposes stage / CRM / operator filters. */

@media (max-width: 1100px) {
  .chat-messenger {
    grid-template-columns: 320px 1fr;
  }
  .chat-messenger__filters {
    display: none;
  }
}

@media (max-width: 760px) {
  .chat-messenger {
    grid-template-columns: 1fr;
  }
  .chat-messenger__list {
    display: none;
  }
}

/* ==========================================================================
   22. Messenger polish — chat header (avatar + status), composer, search
   Keeps the new Chatterfy-inspired chrome additive; nothing above this
   block depends on these selectors.
   ========================================================================== */

/* --- Shared avatar gradient palette (also used by dialog-row) ---------- */

.avatar--grad-0 { background: linear-gradient(135deg, #3AD5FF, #5E6AD2); color: var(--fg-0); }
.avatar--grad-1 { background: linear-gradient(135deg, #29E7A7, #3AD5FF); color: var(--fg-0); }
.avatar--grad-2 { background: linear-gradient(135deg, #E24BFF, #5E6AD2); color: var(--fg-0); }
.avatar--grad-3 { background: linear-gradient(135deg, #FFB547, #FF4D6A); color: var(--fg-0); }
.avatar--grad-4 { background: linear-gradient(135deg, #BAFF5E, #29E7A7); color: var(--bg-0); }
.avatar--grad-5 { background: linear-gradient(135deg, #8A7BFF, #E24BFF); color: var(--fg-0); }

/* --- Chat window header (inside the main messenger pane) --------------- */

.chat-window__header {
  /* Overrides 16. default — header now flex with peer + actions groups. */
  gap: var(--space-4);
}

.chat-window__peer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex: 1 1 auto;
}

.chat-window__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: var(--fw-bold);
  flex-shrink: 0;
  user-select: none;
}

.chat-window__title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
}

.chat-window__id {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-weight: var(--fw-regular);
}

.chat-window__sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: 4px;
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

.chat-window__sub-item { color: var(--fg-2); }
.chat-window__sub-sep  { color: var(--fg-3); }

.chat-window__actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.chat-window__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-2);
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--motion-fast), color var(--motion-fast),
              border-color var(--motion-fast);
}

.chat-window__icon-btn:hover {
  background: var(--bg-3);
  color: var(--fg-0);
  border-color: var(--border-weak);
}

.chat-window__icon-btn[aria-pressed="true"] {
  color: var(--sig-warn);
}

.chat-window__icon-btn--static {
  cursor: default;
}

.chat-window__lang {
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

/* --- Thread column = flex column (thread scrolls, composer pins bottom) - */

.chat-layout__main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-1);
  border-right: 1px solid var(--border-weak);
}

.chat-layout__main > .chat-layout__thread {
  /* Reset the right-border — it's now on the parent column. */
  border-right: none;
  flex: 1 1 auto;
}

.chat-layout__composer {
  flex: 0 0 auto;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-2);
  border-top: 1px solid var(--border-weak);
}

.chat-layout__composer .operator-composer {
  margin: 0;
}

/* --- Search + sort bar above the chat list ----------------------------- */

.chat-messenger__search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-weak);
  background: var(--bg-1);
  flex-shrink: 0;
}

.chat-messenger__search-icon {
  color: var(--fg-3);
  font-size: 14px;
  line-height: 1;
}

.chat-messenger__search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0 var(--space-2);
  background: var(--bg-2);
  color: var(--fg-0);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}

.chat-messenger__search-input::placeholder {
  color: var(--fg-3);
}

.chat-messenger__search-input:focus {
  outline: none;
  border-color: var(--fg-brand);
}

.chat-messenger__sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 var(--space-2);
  background: var(--bg-2);
  color: var(--fg-1);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: background-color var(--motion-fast);
}

.chat-messenger__sort-btn:hover {
  background: var(--bg-3);
  color: var(--fg-0);
}

.chat-messenger__sort-btn[aria-pressed="true"] {
  background: var(--bg-3);
  color: var(--fg-0);
  border-color: var(--fg-brand);
}

/* --- System-bubble content refinement (text + mono-time) --------------- */

.chat-bubble__system-text {
  color: var(--fg-2);
}

.chat-bubble__system-time {
  color: var(--fg-3);
  margin-left: var(--space-2);
}

/* ==========================================================================
   23. Polish pass — responsive messenger, icon-btn states, bubble meta,
       SSE dot, empty state iconography, drawer mode.
       Added 2026-04-22. Additive — no selectors above here rely on these.
   ========================================================================== */

/* --- 23.1 Drawer/overlay mode for filter rail (≤960px) ---------------- */

.chat-messenger__filters-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: var(--space-2);
  background: transparent;
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  color: var(--fg-1);
  font-size: 14px;
  cursor: pointer;
  transition: background-color var(--motion-fast), color var(--motion-fast);
}

.chat-messenger__filters-toggle:hover {
  background: var(--bg-3);
  color: var(--fg-0);
}

/* --- 23.2 Chat window action icon-btn upgrade ------------------------- */

.chat-window__icon-btn {
  /* Square-ish icon buttons. Width now 32 by default (matches height). */
  min-width: 32px;
}

.chat-window__icon-btn.is-on {
  color: var(--sig-warn, #f59e0b);
  border-color: transparent;
}

.chat-window__icon-btn.is-on::before {
  content: "";
}

/* --- 23.3 SSE connection dot in chat header --------------------------- */

.chat-window__sse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sig-success, #29e7a7);
  box-shadow: 0 0 0 0 rgb(41 231 167 / 0.4);
  animation: chatter-sse-pulse 2s infinite;
  margin-left: var(--space-2);
  flex-shrink: 0;
  vertical-align: middle;
}

.chat-window__sse-dot--off {
  background: var(--sig-error, #ff4d6a);
  animation: none;
  box-shadow: none;
}

@keyframes chatter-sse-pulse {
  0%   { box-shadow: 0 0 0 0 rgb(41 231 167 / 0.4); }
  70%  { box-shadow: 0 0 0 6px rgb(41 231 167 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(41 231 167 / 0); }
}

/* --- 23.4 Bubble meta — slimmer, slightly muted ----------------------- */

.chat-bubble__meta {
  /* Keep meta below text (stable flow), but tighten visual weight. */
  margin-top: 2px;
  font-size: 10px;
  opacity: 0.6;
}

/* --- 23.5 Empty-state iconography inside messenger main --------------- */

.chat-messenger__main .empty-state::before,
.chat-empty::before {
  content: "\1F4AC"; /* speech-balloon emoji */
  display: block;
  font-size: 42px;
  line-height: 1;
  opacity: 0.25;
  margin-bottom: var(--space-3);
  text-align: center;
}

.chat-messenger__list .empty-state {
  padding: var(--space-6) var(--space-4);
  text-align: center;
}

.chat-messenger__list .empty-state::before {
  content: "\1F50D"; /* magnifying glass */
  display: block;
  font-size: 36px;
  line-height: 1;
  opacity: 0.25;
  margin-bottom: var(--space-3);
}

/* --- 23.6 Responsive breakpoints override shell ---------------------- */

/* Replace the earlier ≤1100px/760px rules with a richer tier system:
   ≤1280px  → collapse filter rail to 56px icon-rail (expand on hover).
   ≤960px   → hide filter rail, toggle it as overlay drawer.
   ≤720px   → stack columns (list OR chat).                            */

@media (max-width: 1280px) {
  .chat-messenger {
    grid-template-columns: 56px 320px 1fr;
  }
  .chat-messenger__filters {
    /* Icon-rail: labels + counts hidden, only the coloured dot stays. */
    transition: width var(--motion-fast);
  }
  .chat-messenger__filters .chat-filters__title,
  .chat-messenger__filters .chat-filters__label,
  .chat-messenger__filters .chat-filters__count {
    display: none;
  }
  .chat-messenger__filters .chat-filters {
    padding: var(--space-2) 4px;
  }
  .chat-messenger__filters .chat-filters__item {
    justify-content: center;
    padding: var(--space-2);
  }
  /* Saved-filters sidebar labels also collapse — it renders its own text. */
  .chat-messenger__filters .saved-filters-sidebar,
  .chat-messenger__filters .saved-filters-sidebar * {
    display: none;
  }
  /* Hover expands the whole rail back to the full 240px view. */
  .chat-messenger:hover > .chat-messenger__filters:hover,
  .chat-messenger__filters:focus-within {
    position: relative;
    z-index: 50;
    width: 240px;
    box-shadow: var(--elev-2);
  }
  .chat-messenger:hover > .chat-messenger__filters:hover .chat-filters__title,
  .chat-messenger:hover > .chat-messenger__filters:hover .chat-filters__label,
  .chat-messenger:hover > .chat-messenger__filters:hover .chat-filters__count,
  .chat-messenger__filters:focus-within .chat-filters__title,
  .chat-messenger__filters:focus-within .chat-filters__label,
  .chat-messenger__filters:focus-within .chat-filters__count {
    display: inline;
  }
  .chat-messenger:hover > .chat-messenger__filters:hover .chat-filters__item,
  .chat-messenger__filters:focus-within .chat-filters__item {
    justify-content: flex-start;
    padding: var(--space-2) var(--space-3);
  }
  .chat-messenger:hover > .chat-messenger__filters:hover .chat-filters,
  .chat-messenger__filters:focus-within .chat-filters {
    padding: var(--space-3);
  }
}

@media (max-width: 960px) {
  .chat-messenger {
    grid-template-columns: 340px 1fr;
    position: relative;
  }
  .chat-messenger__filters {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 80;
    background: var(--bg-1);
    border-right: 1px solid var(--border-strong);
    box-shadow: var(--elev-3);
  }
  .chat-messenger__filters .chat-filters__title,
  .chat-messenger__filters .chat-filters__label,
  .chat-messenger__filters .chat-filters__count,
  .chat-messenger__filters .saved-filters-sidebar,
  .chat-messenger__filters .saved-filters-sidebar * {
    display: revert;
  }
  .chat-messenger__filters .chat-filters__item {
    justify-content: flex-start;
    padding: var(--space-2) var(--space-3);
  }
  .chat-messenger--filters-open .chat-messenger__filters {
    display: flex;
  }
  .chat-messenger__filters-toggle {
    display: inline-flex;
  }
}

@media (max-width: 720px) {
  /* Hide filter rail entirely — swipe/toggle from left via button. */
  .chat-messenger {
    grid-template-columns: 1fr;
    height: calc(100vh - var(--topbar-h, 56px));
    position: relative;
  }
  .chat-messenger__filters {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 200ms;
    background: var(--bg-1);
    box-shadow: 4px 0 16px rgb(0 0 0 / 0.4);
  }
  .chat-messenger--filters-open .chat-messenger__filters {
    transform: translateX(0);
  }
  .chat-messenger__list { display: block; }
  /* Stack mode: hide the list when a dialog is selected; otherwise hide
     the main chat area so the list occupies the full width. Relies on a
     body class ``body--has-dialog`` set from dialog_detail, plus a
     progressive-enhancement :has() fallback when the browser supports it. */
  body.body--has-dialog .chat-messenger__list,
  .chat-messenger:has(.chat-messenger__main[data-has-dialog="true"]) .chat-messenger__list,
  body:has(.chat-messenger__main[data-has-dialog="true"]) .chat-messenger__list {
    display: none;
  }
  .chat-messenger__main { display: none; }
  body.body--has-dialog .chat-messenger__main,
  .chat-messenger:has(.chat-messenger__main[data-has-dialog="true"]) .chat-messenger__main,
  body:has(.chat-messenger__main[data-has-dialog="true"]) .chat-messenger__main {
    display: block;
  }
  /* Back button in chat header visible only on mobile */
  .chat-window__back { display: inline-flex; }
  /* Top tabs strip horizontal scroll on narrow */
  .top-tabs { overflow-x: auto; flex-wrap: nowrap; }
  /* Composer shrink footer */
  .chat-layout__composer { padding: var(--space-2); }
  /* Lead panel as bottom sheet */
  .chat-layout__lead {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 60vh;
    z-index: 150;
    border-top: 1px solid var(--border-strong);
    transform: translateY(100%);
    transition: transform 240ms;
    background: var(--bg-1);
    overflow-y: auto;
  }
  .chat-layout__lead.is-open { transform: translateY(0); }
}

/* Back button — hidden by default, revealed in the ≤720px query above. */
.chat-window__back {
  display: none;
  background: transparent;
  border: none;
  color: var(--fg-0);
  font-size: 18px;
  padding: 6px;
  cursor: pointer;
}
.chat-window__back:hover {
  background: var(--bg-3);
  border-radius: var(--radius-xs);
}

/* --- 23.7 Dialog row hover polish ------------------------------------ */

.dialog-row {
  /* Tighter transition covering background + box-shadow for selected state. */
  transition: background-color var(--motion-fast),
              box-shadow var(--motion-fast);
}

.dialog-row:hover:not(.is-selected):not([aria-selected="true"]) {
  background: var(--bg-2);
}

/* --- 23.8 Bundle indicator status dot (topbar / bundle-tabs) --------- */

.bundle-tab__status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sig-success);
  flex-shrink: 0;
}

.bundle-tab__status-dot--paused {
  background: var(--fg-3);
}

/* --- 23.9 Pagination footer minimalism ------------------------------- */

.dialog-pagination {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
}

.dialog-pagination__nav .btn {
  min-width: 28px;
  height: 24px;
  padding: 0 var(--space-2);
  font-size: var(--fs-sm);
  line-height: 1;
}

/* --- 23.10 Focus ring — keep it off bubbles/body text --------------- */

.chat-bubble:focus-visible,
.chat-bubble__text:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* --- 23.11 Chat-list unread pill (chatterfy-style) ------------------- */

.chat-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--indigo-500, #5e6ad2);
  color: #fff;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  line-height: 1;
  flex-shrink: 0;
}

/* --- 23.12 Top nav horizontal tab strip (chatterfy-style) ------------ */

.top-tabs {
  display: flex;
  gap: var(--space-1);
  align-items: stretch;
  padding: 0 var(--space-4);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-weak);
  overflow-x: auto;
  scrollbar-width: none;
}

.top-tabs::-webkit-scrollbar { display: none; }

.top-tabs__link {
  display: inline-flex;
  align-items: center;
  padding: 10px var(--space-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--motion-fast), border-color var(--motion-fast);
}

.top-tabs__link:hover {
  color: var(--fg-0);
}

.top-tabs__link.is-active {
  color: var(--fg-0);
  border-bottom-color: var(--indigo-500, #5e6ad2);
}

/* --- 23.13 Bubble timestamp absolute bottom-right (whatsapp-style) --- */

.chat-bubble {
  position: relative;
  min-width: 72px;
  padding-right: 56px; /* reserve space for inline meta */
}

.chat-bubble--system {
  padding-right: var(--space-3);
  min-width: 0;
}

.chat-bubble__meta {
  position: absolute;
  right: 10px;
  bottom: 4px;
  margin-top: 0;
  opacity: 0.55;
  font-size: 10px;
  pointer-events: none;
  gap: 4px;
}

/* Tactic chip is a sibling of the bubble and must stay out of absolute
   flow — already absolute-free via its own align-self:flex-end. */

/* --- 23.14 Keyboard navigation highlight in dialog list -------------- */

.dialog-row.is-kb-selected:not(.is-selected) {
  background: var(--bg-3);
  outline: 1px solid var(--indigo-500, #5e6ad2);
  outline-offset: -1px;
}

/* --------------------------------------------------------------------------
   50. Lead panel — chatterfy-style mini tab strip
   (visual-only for now; only "settings" is wired — wiring TODO)
   -------------------------------------------------------------------------- */

.lead-panel__tabs {
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-3) 0;
  border-bottom: 1px solid var(--border-weak);
  flex-shrink: 0;
}

.lead-panel__tab {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-2);
  cursor: pointer;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms, border-color 120ms, background 120ms;
}

.lead-panel__tab:hover {
  background: var(--bg-3);
  color: var(--fg-0);
}

.lead-panel__tab.is-active {
  color: var(--fg-0);
  border-bottom-color: var(--indigo-500, #5e6ad2);
}

.lead-panel__tab:focus-visible {
  outline: 2px solid var(--indigo-500, #5e6ad2);
  outline-offset: -2px;
}

.lead-panel__panes {
  flex: 1;
  overflow-y: auto;
}

.lead-panel__pane { display: none; }
.lead-panel__pane.is-active { display: block; }

/* --------------------------------------------------------------------------
   51. Composer icon buttons — attach + emoji (stubs, TODO wiring)
   -------------------------------------------------------------------------- */

.operator-composer__icon-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.operator-composer__icon-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--fg-2);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, color 120ms, border-color 120ms;
}

.operator-composer__icon-btn:hover {
  background: var(--bg-3);
  color: var(--fg-0);
}

.operator-composer__icon-btn:focus-visible {
  outline: none;
  border-color: var(--indigo-500, #5e6ad2);
}

/* ==========================================================================
   Toast notifications (2026-04-22)
   Stacked bottom-right. Self-dismiss after 3.5s. aria-live="polite".
   ========================================================================== */

.toast-slot {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 9999;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 420px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  color: var(--fg-0);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.4);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  animation: toast-in 200ms ease-out;
}
.toast--success { border-left: 3px solid var(--sig-success, #10b981); }
.toast--error   { border-left: 3px solid var(--sig-error, #ef4444); }
.toast--info    { border-left: 3px solid var(--indigo-500, #5e6ad2); }
.toast__icon {
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
}
.toast__body {
  flex: 1;
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
}
.toast__close {
  background: transparent;
  border: none;
  color: var(--fg-2);
  cursor: pointer;
  font-size: 16px;
  padding: 0 var(--space-2);
}
.toast__close:hover { color: var(--fg-0); }
.toast.is-leaving { animation: toast-out 160ms ease-in forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(24px); }
}

/* ==========================================================================
   Illustrated empty states v2 (2026-04-22)
   Upgrade from inline-italic to centered block with icon+title+copy+CTA.
   Coexists with legacy .empty-state (italic color). When markup uses
   .empty-state__icon/__title/__copy/__cta, block styling kicks in.
   ========================================================================== */

.empty-state:has(.empty-state__title),
.empty-state--rich {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6);
  min-height: 240px;
  color: var(--fg-1);
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
  font-style: normal;
}
.empty-state__icon {
  font-size: 56px;
  opacity: 0.5;
  line-height: 1;
}
.empty-state__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  margin: 0;
}
.empty-state__copy {
  font-size: var(--fs-md);
  color: var(--fg-2);
  margin: 0;
  line-height: var(--lh-normal);
}
.empty-state__cta {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--indigo-500, #5e6ad2);
  color: #fff;
  text-decoration: none;
  font-size: var(--fs-sm);
  transition: background 120ms;
  border: none;
  cursor: pointer;
}
.empty-state__cta:hover {
  background: color-mix(in srgb, var(--indigo-500, #5e6ad2) 80%, white);
}

/* Chat-empty v2: keep existing markup, override look-and-feel when
   .chat-empty--rich is present (or always when inside messenger main). */
.chat-empty--rich {
  min-height: 320px;
  max-width: 480px;
  gap: var(--space-3);
}
.chat-empty__icon {
  font-size: 56px;
  opacity: 0.5;
  line-height: 1;
  margin-bottom: var(--space-2);
}
.chat-empty__cta {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--indigo-500, #5e6ad2);
  color: #fff;
  text-decoration: none;
  font-size: var(--fs-sm);
  border: none;
  cursor: pointer;
  transition: background 120ms;
}
.chat-empty__cta:hover {
  background: color-mix(in srgb, var(--indigo-500, #5e6ad2) 80%, white);
}
/* Override the ::before speech-balloon icon when an explicit icon is
   provided in markup (prevents double icons). */
.chat-empty--rich::before { content: none; }

/* --------------------------------------------------------------------------
   Bundle switcher — header popover dropdown.
   Uses native <details>/<summary> for zero-JS accessibility; dropdown is
   absolutely positioned relative to the summary control.
   -------------------------------------------------------------------------- */
.bundle-switcher { position: relative; }
.bundle-switcher > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  border-radius: var(--radius-xs);
  background: var(--bg-2);
  border: 1px solid var(--border-weak);
  font-size: var(--fs-sm);
  color: var(--fg-0);
}
.bundle-switcher > summary::-webkit-details-marker { display: none; }
.bundle-switcher > summary:hover {
  background: var(--bg-3);
  border-color: var(--border-strong);
}
.bundle-switcher[open] > summary {
  background: var(--bg-3);
  border-color: var(--indigo-500, #5e6ad2);
}
.bundle-switcher__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bundle-switcher__label--muted { color: var(--fg-2); }
.bundle-switcher__slug {
  font-size: 11px;
  color: var(--fg-2);
  font-family: var(--font-mono);
}
.bundle-switcher__caret {
  margin-left: var(--space-1);
  font-size: 10px;
  color: var(--fg-2);
}
.bundle-switcher__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 280px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.4);
  z-index: 9000;
  max-height: 60vh;
  overflow-y: auto;
}
.bundle-switcher__menu-title {
  font-size: 11px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
  padding: var(--space-1) var(--space-2) var(--space-2);
}
.bundle-switcher__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-2);
  border-radius: var(--radius-xs);
  text-decoration: none;
  color: var(--fg-0);
  font-size: var(--fs-sm);
  transition: background 120ms;
}
.bundle-switcher__item:hover { background: var(--bg-3); }
.bundle-switcher__item.is-active {
  background: var(--bg-3);
  color: var(--fg-0);
  font-weight: var(--fw-medium);
}
.bundle-switcher__item.is-active::after {
  content: "✓";
  margin-left: auto;
  color: var(--indigo-500, #5e6ad2);
}
.bundle-switcher__sep {
  height: 1px;
  background: var(--border-weak);
  margin: var(--space-2) 0;
}
.bundle-switcher__item--new {
  color: var(--indigo-500, #5e6ad2);
  font-weight: var(--fw-medium);
}
.bundle-switcher__item--all {
  font-size: 11px;
  color: var(--fg-2);
  justify-content: center;
}
.bundle-switcher__empty {
  padding: var(--space-3) var(--space-2);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--fg-2);
}

/* --------------------------------------------------------------------------
   Branded error pages (404, 500) — admin surface only.
   -------------------------------------------------------------------------- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-6);
  max-width: 520px;
  margin: 0 auto;
}
.error-page__code {
  font-family: var(--font-mono);
  font-size: 128px;
  font-weight: var(--fw-bold);
  color: var(--bg-3);
  line-height: 1;
  letter-spacing: -0.04em;
}
.error-page__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  color: var(--fg-0);
  margin: 0;
}
.error-page__copy {
  color: var(--fg-1);
  margin: 0;
  line-height: var(--lh-normal);
}
.error-page__meta {
  font-size: var(--fs-xs);
  color: var(--fg-2);
}
.error-page__link { color: var(--indigo-500, #5e6ad2); }
.error-page__cta {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--fg-0);
  text-decoration: none;
  transition: background 120ms;
}
.error-page__cta:hover { background: var(--bg-3); }
.error-page--error .error-page__code {
  color: color-mix(in srgb, var(--sig-error, #ef4444) 30%, var(--bg-3));
}

/* ==========================================================================
   90. Page header — row layout with actions (for list pages)
   --------------------------------------------------------------------------
   Extends .page__header (column stack) with an optional row layout where
   a title+copy block sits on the left and CTAs sit on the right.
   ========================================================================== */

.page__header--row {
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-weak);
}

.page__header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.page__header-text .page__title { margin: 0; }
.page__header-text .page__subtitle { margin: 2px 0 0; }

.page__header--row .page__header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .page__header--row {
    flex-direction: column;
    align-items: stretch;
  }
  .page__header--row .page__header-actions {
    justify-content: flex-end;
  }
}

/* ==========================================================================
   91. .list-card — generic row-card for list pages (bundles, operators,
       knowledge, landings). Hoverable, clickable (via wrapping <a>).
   ========================================================================== */

.list-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.list-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  transition:
    background var(--motion-fast),
    border-color var(--motion-fast),
    transform var(--motion-fast);
  text-decoration: none;
  color: inherit;
  position: relative;
}

.list-card:hover {
  background: var(--bg-3);
  border-color: var(--border-strong);
}

a.list-card:hover {
  transform: translateY(-1px);
}

.list-card--accent {
  border-left: 2px solid var(--list-card-color, var(--sig-info));
}

.list-card__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xl);
  line-height: 1;
  color: var(--fg-1);
}

.list-card__color-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--list-card-color, var(--fg-3));
  box-shadow: 0 0 0 2px var(--bg-2);
}

.list-card__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-card__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  min-width: 0;
}

.list-card__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--fg-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.list-card__slug {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
  padding: 1px var(--space-1);
  background: var(--bg-1);
  border-radius: var(--radius-xs);
}

.list-card__meta {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.list-card__meta > span + span::before {
  content: "·";
  padding-right: var(--space-2);
  color: var(--fg-3);
}

.list-card__meta > span + span {
  padding-left: 0;
}

.list-card__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

/* Prevent action-click from bubbling to parent .list-card link */
.list-card__actions .btn,
.list-card__actions form {
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   92. .avatar — generic sized avatar circle (extends avatar--grad-N)
   --------------------------------------------------------------------------
   Usage: <span class="avatar avatar--sm {{ avatar_gradient_class(u) }}">A</span>
   ========================================================================== */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-weight: var(--fw-bold);
  color: var(--fg-0);
  background: var(--sig-info);
  user-select: none;
  line-height: 1;
}

.avatar--sm {
  width: 28px;
  height: 28px;
  font-size: var(--fs-xs);
}

.avatar--md {
  width: 36px;
  height: 36px;
  font-size: var(--fs-md);
}

/* ==========================================================================
   93. .status-dot — generic 8px status indicator (online/offline/pending)
   ========================================================================== */

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-3);
  flex-shrink: 0;
  vertical-align: middle;
}

.status-dot--online {
  background: var(--sig-success);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--sig-success) 20%, transparent);
}

.status-dot--offline { background: var(--fg-3); }
.status-dot--warn    { background: var(--sig-warn); }
.status-dot--error   { background: var(--sig-error); }

.status-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

/* ==========================================================================
   94. Field required marker + char counter
   ========================================================================== */

.field__label .req {
  color: var(--sig-error);
  margin-left: 2px;
}

.field__counter {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  font-family: var(--font-mono);
  align-self: flex-end;
  margin-top: 2px;
}

/* ==========================================================================
   95. .summary-cards — improved review step visual grouping
   ========================================================================== */

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
}

.summary-card {
  background: var(--bg-2);
  border: 1px solid var(--border-weak);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.summary-card__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--fg-2);
}

.summary-card__value {
  font-size: var(--fs-md);
  color: var(--fg-0);
  word-break: break-word;
}

.summary-card__value .mono { font-family: var(--font-mono); }
