/* Ported to the React build from css/agents.css — tokens reconciled to the
   Pursuit DS 2026 canonical sheet (legacy --border/--radius/--secondary names
   replaced; see react/css/bridge.css for remaining aliases). */

/* Card-body wrapper used in the multi-section "Schedule & Delivery" card.
   Slightly different padding so the fl-section overlines line up with
   the toolbar title above. */
.agent-card-body { padding-bottom: 12px; }
.agent-card-body > .fl-section { padding: 16px 18px 4px; }
.agent-card-body > .cfg-body { padding: 0 18px 4px; }
.agent-card-body > .cfg-body + .fl-section { border-top: 1px solid var(--hairline); margin-top: 8px; padding-top: 14px; }

/* Saved-state indicator that sits in the .fw-toolbar action slot. */
.agent-saved-indicator {
  font: 400 12px/1 var(--font-body);
  color: var(--ps-secondary-700);
  display: inline-flex; align-items: center; gap: 4px;
}
.agent-saved-indicator i { width: 13px; height: 13px; }

/* Body padding inside a config-section card. The .fw-items wrapper
   already gives padding 0 8px 12px; we add a touch more on either
   side for the form-style content. */
.cfg-body { padding: 0 18px 16px; }

/* === Source query — the agent Filters summary. Chips reuse the Search
       bar's .filter-chip styling (see .filter-chip--readonly) so the
       filter vocabulary reads identically across Search and Agents. */
.qs-list {
  display: flex; flex-direction: column; gap: 8px;
  padding: 0 2px;
}
.qs-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px; align-items: baseline;
}
.qs-key {
  font: 500 11px/1.3 var(--font-mono);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted-foreground);
  padding-top: 6px;
}
.qs-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-width: 0;
}
/* Read-only variant of the Search bar's .filter-chip used in the agent
   Filters summary: same segmented field · op · value pill, but not
   interactive (editing is via "Edit filters"), so drop the pointer
   cursor and hover/focus affordances. */
.filter-chip--readonly { cursor: default; }
.filter-chip--readonly:hover { background: var(--accent); }
.qs-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 2px 0;
  margin-top: 4px;
  border-top: 1px dashed var(--hairline);
}
.qs-meta { font-size: 12px; color: var(--muted-foreground); }
.qs-meta strong { color: var(--foreground); font-weight: 600; }

/* === Scoring criteria — uses the same `.dv-table-wrap` chrome the
       Detail-view tables use (white card + primary-tinted thead). */
.crit-table {
  background: var(--card);
  border: 1px solid #ffffff;
  border-top-width: 1.5px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(20,20,23,0.04);
  overflow: hidden;
}
.crit-thead {
  display: grid;
  grid-template-columns: 1fr 90px 130px 32px;
  gap: 12px;
  padding: 9px 14px;
  background: var(--accent);
  border-bottom: 1px solid var(--ps-primary-100);
  font: 500 11px/1.3 var(--font-mono);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted-foreground);
}
.crit-thead-weight { text-align: center; }
/* Scoring-criteria empty state — instruction + example criterion types */
.crit-empty { padding: 2px 2px 4px; }
.crit-empty-lead {
  font: 400 13px/1.55 var(--font-body); color: var(--muted-foreground);
  margin: 0 0 14px; max-width: 60ch;
}
.crit-empty-examples { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.crit-eg { display: flex; align-items: flex-start; gap: 10px; }
.crit-eg-glyph {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--ps-primary-600);
}
.crit-eg-glyph i { width: 15px; height: 15px; }
.crit-eg-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.crit-eg-title { font: 600 13px/1.3 var(--font-body); color: var(--foreground); }
.crit-eg-desc { font: 400 12.5px/1.4 var(--font-body); color: var(--muted-foreground); }
.crit-empty-foot {
  font: 400 12px/1.45 var(--font-body); color: var(--ps-tertiary-700, var(--muted-foreground));
  margin: 0; padding-top: 2px;
}
.crit-row {
  display: grid;
  grid-template-columns: 1fr 90px 130px 32px;
  gap: 12px; align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
}
.crit-row:last-child { border-bottom: 0; }
.crit-row:hover { background: rgba(77,95,255,0.03); }
.crit-text { min-width: 0; }
.crit-name { font: 500 13.5px/1.3 var(--font-body); color: var(--foreground); }
.crit-desc { font: 400 12px/1.4 var(--font-body); color: var(--muted-foreground); margin-top: 2px; }
.crit-kind {
  display: inline-flex; align-items: center; gap: 4px;
  font: 600 10px/1.1 var(--font-mono);
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 4px;
  background: #d0e0d6; color: var(--ps-secondary-700);
  width: max-content;
}
.crit-kind.penalty { background: #f6c7c9; color: #8a181f; }
.crit-weight {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.crit-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ps-neutral-150);
  border: 0; padding: 0; cursor: pointer;
  transition: background 0.12s, transform 0.12s;
}
.crit-dot.filled { background: var(--ps-primary-500); }
.crit-row.penalty-row .crit-dot.filled { background: #c92027; }
.crit-dot:hover { transform: scale(1.18); }
.crit-remove {
  width: 28px; height: 28px; border: 0;
  background: transparent; border-radius: 6px;
  color: var(--ps-neutral-300);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.crit-remove:hover { background: #fef2f3; color: var(--destructive); }
.crit-remove i { width: 14px; height: 14px; }
.crit-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--hairline);
  background: rgba(77,95,255,0.02);
}

/* === Schedule — reuses .dv-segmented from the Detail page === */
.sched-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sched-label { font-size: 13px; color: var(--muted-foreground); }
.sched-field {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  font-size: 14px; font-weight: 500;
  background: var(--card);
  border: 0.5px solid #fff; border-top-width: 1px;
  box-shadow: 0 1px 1.75px rgba(0,0,0,0.05);
  border-radius: 8px;
  color: var(--foreground);
}
.sched-field i { color: var(--muted-foreground); }
.dow-chips { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.dow {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  font: 600 12px/1 var(--font-body);
  background: var(--card);
  border: 0.5px solid #fff; border-top-width: 1px;
  box-shadow: 0 1px 1.75px rgba(0,0,0,0.05);
  border-radius: 6px;
  color: var(--muted-foreground);
  cursor: pointer;
}
.dow.on {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

/* === Delivery — .fl-item rows with toggleable .active state === */
.delivery-list { display: flex; flex-direction: column; gap: 4px; padding: 4px 0 0; }
.delivery-list .fl-item { padding: 10px 10px; }
.delivery-list .fl-item .fl-glyph {
  width: 28px; height: 28px; border-radius: 6px;
  background: #fff;
  border: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-foreground); flex-shrink: 0;
}
.delivery-list .fl-item .fl-glyph i { width: 14px; height: 14px; }
.delivery-list .fl-item.active .fl-glyph {
  background: #fff; border-color: var(--ps-primary-75); color: var(--primary);
}
.fl-name-primary {
  font: 500 13.5px/1.3 var(--font-body); color: var(--foreground);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fl-item-detail {
  font: 400 12px/1.3 var(--font-body);
  color: var(--muted-foreground);
  margin-top: 1px;
}
.fl-item-detail input {
  background: transparent; border: 0;
  border-bottom: 1px dotted var(--hairline);
  font: inherit; padding: 1px 2px;
  width: 180px; outline: none;
}
.fl-item-detail input:focus { border-bottom-color: var(--primary); color: var(--foreground); }
.fl-item.active .fl-item-detail { color: var(--accent-foreground); opacity: 0.85; }
/* Play-row toggle switch (replaces the old On/Off text badge). The whole
   row is still the click target — the switch is a visual affordance that
   reflects .fl-item.active. */
.fl-toggle {
  position: relative; flex-shrink: 0;
  width: 38px; height: 22px; border-radius: 999px;
  background: var(--ps-neutral-200);
  transition: background 160ms ease;
}
.fl-toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 18, 33, 0.28);
  transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fl-item.active .fl-toggle { background: var(--ps-primary-500); }
.fl-item.active .fl-toggle .fl-toggle-knob { transform: translateX(16px); }

/* === Config-card footer === */
.cfg-foot-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--hairline);
  background: var(--ps-neutral-100);
  flex-shrink: 0;
}
.cfg-foot-meta { font-size: 12px; color: var(--muted-foreground); }
.cfg-foot-meta strong { color: var(--foreground); font-weight: 600; }
.cfg-foot-meta .saved {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 12px;
  color: var(--ps-secondary-700);
}
.cfg-foot-meta .saved i { width: 13px; height: 13px; }

/* === Live preview subhead pill === */
.preview-subhead {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted-foreground);
  padding: 0 18px 12px;
  flex-shrink: 0;
}
.live-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: 999px;
  background: var(--ps-primary-60); color: var(--ps-primary-700);
  font: 600 11px/1 var(--font-body); letter-spacing: 0.02em;
}
.live-pill .live-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ps-primary-500);
  animation: live 1.4s ease-in-out infinite;
}
@keyframes live { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* === Agent filter editor (inline) ==========================================
   When the user clicks "Edit filters" on the agent's Filters card, that
   card EXPANDS to host the existing Search filter panel. Scoring
   Criteria and Schedule & Delivery hide; Live preview stays on the
   right and updates from the editing filter set in real time.
   The Search filter elements (#search-bar-wrap, .ss-section, #field-list)
   get re-parented into the editor card via moveSearchFilterUIIntoAgent
   and restored to their static homes when editing exits. */
.agent-cfg-col.editing .agent-cfg-stack > section:not(.agent-filter-editor),
.agent-cfg-col.editing .agent-cfg-footer { display: none; }

/* Right column stacks: 7-day perf chart (fixed height) over Results
   Preview (fills remaining space). */
.agent-preview-col {
  display: flex; flex-direction: column;
  min-height: 0;
  gap: 18px;
}
.agent-perf-card { flex: 0 0 auto; height: auto; }
.agent-perf-card .fw-toolbar { align-items: flex-start; }
.agent-perf-body { padding: 4px 14px 14px; }
.perf-chart {
  width: 100%;
  height: 130px;
  display: block;
  overflow: visible;
}
/* Two-series line chart palette — green for positive, warm coral for
   dismissed. Filled areas underneath each line for a subtle volume cue. */
.perf-chart .line-hits      { stroke: #43825c; stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.perf-chart .line-dismissed { stroke: #c97a59; stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.perf-chart .area-hits      { fill: rgba(67,130,92, 0.14); }
.perf-chart .area-dismissed { fill: rgba(201,122,89, 0.10); }
.perf-chart .dot-hits       { fill: #43825c; }
.perf-chart .dot-dismissed  { fill: #c97a59; }
.perf-chart .grid-line      { stroke: var(--hairline); stroke-width: 0.6; stroke-dasharray: 2 3; }
.perf-chart .day-label {
  font: 600 9px/1 var(--font-mono);
  letter-spacing: 0.04em;
  fill: var(--muted-foreground);
  text-transform: uppercase;
}
.perf-legend {
  display: flex; gap: 14px;
  font: 400 11.5px/1 var(--font-body);
  color: var(--muted-foreground);
}
.perf-legend strong { color: var(--foreground); font-weight: 600; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { width: 10px; height: 2px; border-radius: 2px; }
.legend-swatch.swatch-hits      { background: #43825c; }
.legend-swatch.swatch-dismissed { background: #c97a59; }
.agent-res-card-host { flex: 1; min-height: 0; }
.agent-filter-editor { flex: 1; min-height: 0; }
.agent-filter-editor .fw-toolbar { padding-bottom: 12px; }
.afe-actions { display: flex; gap: 8px; align-items: center; }
.afe-actions .btn-secondary-cta { padding: 7px 14px; font-size: 13px; }
.afe-actions .btn-secondary-cta .icon-frame { width: 18px; height: 18px; }
.afe-body {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}
.afe-search-bar-slot {
  padding: 0 18px 6px;
  flex-shrink: 0;
}
.afe-search-bar-slot > #search-bar-wrap {
  margin: 0;
}
.afe-search-bar-slot:empty {
  display: none;
}
/* The inline filter editor (Agents / Templates / instance territory) reuses
   the Search filter panel, but it's purely for DEFINING filter criteria —
   so hide the Search-page-only chrome inside it: the entire smart-search
   bar (search input, leading glyph, filter chips, Clear all) and the
   saved-search combo. Only the field list (Filter columns) remains. The
   main Search page is unaffected (no .agent-filter-editor ancestor). */
.agent-filter-editor .ss-section { display: none; }
.agent-filter-editor .afe-search-bar-slot { display: none; }
.afe-field-list-slot {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 0 0 8px;
  display: flex; flex-direction: column;
}
/* When elements are re-parented into the agent filter editor, undo
   the `[data-mode="agent"]` blanket-hide rules so they're actually
   visible inside the editor. */
.app-frame[data-mode="agent"] .agent-filter-editor .search-bar-wrap { display: block; }
.app-frame[data-mode="agent"] .agent-filter-editor #field-list { display: flex; }
/* Same un-hide for the Templates page (admin template filter editor). */
.app-frame[data-mode="templates"] .agent-filter-editor .search-bar-wrap { display: block; }
.app-frame[data-mode="templates"] .agent-filter-editor #field-list { display: flex; }
/* Locked fields (already defined by a template) are hidden from the
   instance territory editor's field list via this class added in JS. */
.agent-filter-editor .fl-item.fl-item--locked-hide { display: none; }
/* Hide Contacts-side filter rows inside the agent filter editor.
   Agents currently search Signals; Contact filters wouldn't apply
   to a signal record. The "Contacts" section header is removed by
   a JS pass in renderAgentPage so an orphan label doesn't show. */
.agent-filter-editor .fl-item[data-field-id^="contact."] { display: none; }
.agent-filter-editor .fl-section.fl-section--hidden { display: none; }
/* The re-parented .ss-section + #field-list lose their .floating-widget
   container, so re-apply the spacing they'd normally get there. */
.afe-field-list-slot > .ss-section { margin: 0 8px 4px; }
.afe-field-list-slot > #field-list { padding: 0 8px 12px; }
/* Instantiated FilterPanel mounted in the inline editor slot. */
.afe-field-list-slot > .filter-panel { padding: 0 8px 12px; }
.filter-panel .fp-field-list { display: block; }
/* Mounted at the top of .page-header when the Search page is being
   used as an agent's filter editor. Reuses the indigo accent palette
   so it reads as a temporary "mode" overlay, not a permanent toolbar. */
.agent-edit-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  margin: 0 0 12px;
  background: var(--ps-primary-60);
  border: 1px solid var(--ps-primary-100);
  border-radius: 10px;
}
.agent-edit-banner .aeb-text {
  display: flex; align-items: center; gap: 8px;
  font: 500 13.5px/1.3 var(--font-body);
  color: var(--ps-primary-700);
  min-width: 0;
}
.agent-edit-banner .aeb-text strong { font-weight: 600; color: var(--ps-primary-800); }
.agent-edit-banner .aeb-text i { color: var(--ps-primary-500); }
.agent-edit-banner .aeb-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.agent-edit-banner .aeb-actions .btn-secondary-cta {
  padding: 7px 14px; font-size: 13px;
}
.agent-edit-banner .aeb-actions .btn-secondary-cta .icon-frame { width: 18px; height: 18px; }
/* While editing an agent's filters, suppress the regular Save-Search
   chrome so the only commit affordances are the banner's Save / Cancel.
   `data-editing-agent` is stamped on .app-frame by renderAgentEditingBanner. */
.app-frame[data-editing-agent="true"] #save-search-split { display: none; }
.agent-res-list {
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px 14px 14px;
}
.agent-res-card {
  background: var(--card);
  border: 1px solid #ffffff;
  border-top: 1.5px solid #ffffff;
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(20,20,23,0.04);
  display: flex; flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.agent-res-card:hover {
  box-shadow: 0 1px 2px rgba(20,20,23,0.04), 0 6px 18px rgba(77,95,255,0.07);
}
.agent-res-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
}
.agent-res-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.agent-res-account {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 0; padding: 0;
  font: 600 14.5px/1.25 var(--font-body);
  color: var(--foreground);
  text-align: left;
  width: max-content; max-width: 100%;
  cursor: pointer;
}
.agent-res-account:hover { color: var(--ps-primary-700); }
.agent-res-title {
  background: transparent; border: 0; padding: 0;
  font: 500 15px/1.35 var(--font-body);
  color: var(--ps-primary-500);
  text-align: left;
  cursor: pointer;
}
.agent-res-title:hover { text-decoration: underline; }
.agent-res-head-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  flex: 0 0 auto;
}
.agent-res-date {
  font: 600 11px/1.3 var(--font-mono);
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.score-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  font: 600 10.5px/1.1 var(--font-mono);
  letter-spacing: 0.06em; text-transform: uppercase;
  border-radius: 4px;
  border: 1px solid;
}
.score-pill .score-n { font-weight: 700; font-size: 12px; letter-spacing: 0; }
.score-pill.tier-high { background: #e6f0ec; color: var(--ps-secondary-700); border-color: #cee0d4; }
.score-pill.tier-mid  { background: var(--ps-primary-60); color: var(--ps-primary-700); border-color: var(--ps-primary-100); }
.score-pill.tier-low  { background: var(--ps-neutral-100); color: var(--ps-neutral-500); border-color: var(--ps-neutral-150); }
.agent-res-synopsis {
  font: 400 13.5px/1.55 var(--font-body);
  color: var(--foreground);
}
.agent-res-sigtype-inline {
  margin-right: 8px;
  vertical-align: 2px;
  display: inline-flex;
}
.agent-res-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted-foreground);
}
.agent-res-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ps-neutral-250); }
.agent-res-meta .value { font-family: var(--font-mono); color: var(--foreground); font-weight: 600; }
.agent-res-reasons {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--hairline);
  align-items: center;
}
.agent-res-reasons-label {
  font: 600 10px/1.1 var(--font-mono);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ps-neutral-300);
  padding: 3px 0;
  margin-right: 2px;
}
.reason {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: 11.5px; font-weight: 500;
  background: var(--ps-neutral-115, #f2f2f3);
  color: var(--muted-foreground);
  border-radius: 4px;
}
.reason.up { background: #e6f0ec; color: var(--ps-secondary-700); }
.reason.down { background: #fef2f3; color: #b00009; }
.reason i { width: 10px; height: 10px; }

/* Re-rank flash */
@keyframes agentResFlash {
  0%   { box-shadow: 0 0 0 0 rgba(77,95,255,0); background: var(--card); }
  20%  { box-shadow: 0 0 0 3px var(--ps-primary-100); background: var(--ps-primary-60); }
  100% { box-shadow: 0 0 0 0 rgba(77,95,255,0); background: var(--card); }
}
.agent-res-card.flash { animation: agentResFlash 0.6s ease-out; }

/* Right-column footer */
.agent-res-foot-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--hairline);
  background: var(--ps-neutral-100);
  flex-shrink: 0;
}
.agent-res-foot-meta { font: 400 12px/1 var(--font-body); color: var(--muted-foreground); }

/* Inbound from Inbox: the global search slot also shows in agent mode
   so users can jump to Search from anywhere. */
.app-frame[data-mode="agent"] .global-search-slot { display: flex; }

/* ========================================================================
   CENTRALIZED AGENT MANAGEMENT — Templates (admin) + managed Instances
   (members). The Templates page + member instance detail reuse the same
   full-width chrome-hiding the Agents page uses, so mirror those rules
   for data-mode="templates".
   ======================================================================== */
.app-frame[data-mode="templates"] .ss-section,
.app-frame[data-mode="templates"] #field-list,
.app-frame[data-mode="templates"] .page-title-row,
.app-frame[data-mode="templates"] .search-bar-wrap,
.app-frame[data-mode="templates"] .entity-row,
.app-frame[data-mode="templates"] #save-search-split,
.app-frame[data-mode="templates"] #create-agent-btn,
.app-frame[data-mode="templates"] #records-nav { display: none; }
.app-frame[data-mode="templates"] .floating-widget-spacer { display: none; }
.app-frame[data-mode="templates"] .body { padding: 0; gap: 0; }
.app-frame[data-mode="templates"] .content-panel { padding: 0; }
.app-frame[data-mode="templates"] .page-header { display: none; }

/* ---- Role / "Viewing as" switcher (sidebar footer) -------------------- */
.role-switch {
  position: relative;
  margin: 0 8px 6px;
}
.role-switch-btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--ps-primary-825);
  border: 1.5px solid #f0616d;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  color: var(--sidebar-foreground);
}
.role-switch-btn:hover { background: var(--ps-primary-800); border-color: #f47a84; }
.role-switch-testlabel {
  display: block;
  font: 600 8.5px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase;
  color: #f0616d; margin-bottom: 3px;
}
.role-switch-avatar {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font: 600 11px/1 var(--font-mono); letter-spacing: 0.02em;
  background: var(--ps-quaternary-500); color: #fff;
}
.role-switch-avatar.admin { background: var(--ps-primary-400); }
.role-switch-meta { flex: 1 1 auto; min-width: 0; }
.role-switch-name {
  font: 500 12.5px/1.2 var(--font-body); color: var(--sidebar-foreground);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.role-switch-role {
  font: 400 11px/1.2 var(--font-body); color: var(--ps-nav-text-muted, #9aa0c4);
  margin-top: 2px;
}
.role-switch-chev { color: var(--ps-nav-text-muted, #9aa0c4); flex-shrink: 0; }
.role-switch-pop {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px);
  background: var(--popover);
  border: 1px solid var(--divider);
  border-radius: 10px;
  box-shadow: var(--shadow-xl);
  padding: 6px;
  z-index: 60;
}
.role-switch-pop[hidden] { display: none; }
.role-switch-pop-head {
  font: 600 9.5px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted-foreground); padding: 6px 8px 4px;
}
.role-opt {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: 7px;
  background: transparent; border: 0; cursor: pointer; text-align: left;
}
.role-opt:hover { background: var(--accent); }
.role-opt.active { background: var(--ps-primary-60); }
.role-opt-avatar {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font: 600 10.5px/1 var(--font-mono);
  background: var(--ps-quaternary-500); color: #fff;
}
.role-opt-avatar.admin { background: var(--ps-primary-500); }
.role-opt-meta { flex: 1 1 auto; min-width: 0; }
.role-opt-name { font: 500 13px/1.2 var(--font-body); color: var(--foreground); }
.role-opt-role { font: 400 11.5px/1.2 var(--font-body); color: var(--muted-foreground); margin-top: 2px; }
.role-opt-check { color: var(--primary); flex-shrink: 0; }
.role-opt-check[hidden] { visibility: hidden; }

/* ---- Governance markers (lock / open) --------------------------------- */
.gov-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font: 500 10.5px/1 var(--font-mono); letter-spacing: 0.03em;
  padding: 3px 8px 3px 6px; border-radius: 20px;
  white-space: nowrap;
}
.gov-badge i { width: 11px; height: 11px; }
.gov-badge.locked { background: var(--ps-neutral-150); color: var(--ps-neutral-500); }
.gov-badge.open   { background: var(--ps-secondary-50); color: var(--ps-secondary-700); }
.gov-badge.inherited { background: var(--ps-primary-60); color: var(--ps-primary-700); }

/* Status row on a member instance detail: the Enabled/Disabled pill plus an
   "Assigned to you" governance badge, inline. */
.detail-status-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.detail-status-row .agent-status-pill { margin-bottom: 0; align-self: auto; }

/* A locked config card is dimmed + non-interactive, with a small lock
   chip in the toolbar. Reuses .floating-widget chrome. */
.cfg-locked-card .agent-card-body,
.cfg-locked-card .cfg-body,
.cfg-locked-card .crit-table,
.cfg-locked-card .delivery-list,
.cfg-locked-card .qs-list { opacity: 0.78; pointer-events: none; }
.cfg-locked-card .crit-foot { display: none; }
.cfg-lock-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font: 600 10px/1.1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 5px 9px; border-radius: 4px; white-space: nowrap;
  background: var(--ps-neutral-300); color: #fff;
}
.cfg-lock-chip i, .cfg-lock-chip svg { width: 11px; height: 11px; }

/* ---- Templates index (admin) ------------------------------------------ */
.tpl-index-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.tpl-card-foot {
  display: flex; align-items: center; gap: 14px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--divider);
}
.tpl-foot-stat { display: flex; flex-direction: column; gap: 3px; }
.tpl-foot-label {
  font: 600 9.5px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted-foreground);
}
.tpl-foot-value { font: 500 13px/1.2 var(--font-body); color: var(--foreground); }
.tpl-foot-value.mono { font-family: var(--font-mono); }
.tpl-avatars { display: flex; align-items: center; }
.tpl-avatars .av {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font: 600 9.5px/1 var(--font-mono); color: #fff;
  background: var(--ps-quaternary-500);
  border: 1.5px solid var(--card); margin-left: -7px;
}
.tpl-avatars .av:first-child { margin-left: 0; }
.tpl-avatars .av.more { background: var(--ps-neutral-300); }
.tpl-pub-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font: 600 10px/1.1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 5px 9px; border-radius: 4px; white-space: nowrap;
}
.tpl-pub-pill i, .tpl-pub-pill svg { width: 11px; height: 11px; }
.tpl-pub-pill.on    { background: #21893c; color: #fff; }
.tpl-pub-pill.draft { background: #9e7a0d; color: #fff; }
.tpl-pub-pill.off   { background: var(--ps-neutral-300); color: #fff; }
/* Canonical placement for the agent status pill — sits ABOVE the agent
   name in the detail head, left-aligned. Used by every agent-detail
   surface (admin agent editor, member instance view) via
   agentStatusPillHTML() so status never drifts in look or position. */
.agent-status-pill { align-self: flex-start; margin-bottom: 8px; }

/* Scoring summary chips on template cards */
.tpl-crit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tpl-crit-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font: 400 12px/1 var(--font-body);
  padding: 4px 9px; border-radius: 7px;
  background: var(--ps-neutral-100); color: var(--ps-neutral-600);
}
.tpl-crit-chip i { width: 11px; height: 11px; }
.tpl-crit-chip.boost   i { color: var(--ps-secondary-600); }
.tpl-crit-chip.penalty i { color: var(--ps-destructive); }

/* ---- Subscribers / assignees panel (admin template editor) ------------ */
.sub-list { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.sub-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
}
.sub-row:hover { background: var(--muted); }
.sub-row--locked { cursor: default; }

/* Round select checkbox — mirrors the data-table .cb-box selection control
   used elsewhere in the app. Hidden native input + custom circular box. */
.sub-row .cb-wrap {
  position: relative; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.sub-row .row-check { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.sub-row .cb-box {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--ps-neutral-200);
  background: var(--primary-foreground, #fcfcfd);
  color: var(--primary-foreground); stroke: none;
  transition: background 100ms, border-color 100ms;
}
.sub-row:not(.sub-row--locked):hover .cb-box { border-color: var(--primary); }
.sub-row .cb-box.checked { background: var(--primary); border-color: var(--primary); }
.sub-row .cb-box.locked { background: var(--ps-neutral-300); border-color: var(--ps-neutral-300); }
.sub-row .cb-box i, .sub-row .cb-box svg { width: 12px; height: 12px; }
.sub-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font: 600 11px/1 var(--font-mono); color: #fff;
  background: var(--ps-quaternary-500);
}
.sub-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.sub-name { font: 500 13.5px/1.2 var(--font-body); color: var(--foreground); }
.sub-detail { font: 400 11.5px/1.3 var(--font-body); color: var(--muted-foreground); margin-top: 2px; }
.sub-detail .terr { color: var(--ps-secondary-700); font-weight: 500; }
.sub-origin {
  display: inline-flex; align-items: center; gap: 4px;
  font: 500 10px/1 var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 5px; flex-shrink: 0;
}
.sub-origin.assigned   { background: var(--ps-primary-60); color: var(--ps-primary-700); }
.sub-origin.subscribed { background: var(--ps-secondary-50); color: var(--ps-secondary-700); }
.sub-remove {
  width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; cursor: pointer; color: var(--muted-foreground);
}
.sub-remove:hover { background: var(--ps-destructive-soft); color: var(--ps-destructive); }
.sub-remove i, .sub-remove svg { width: 15px; height: 15px; }
.sub-empty { padding: 18px 12px; text-align: center; font: 400 12.5px/1.5 var(--font-body); color: var(--muted-foreground); }

/* ---- Assign-to-people combobox (admin pushes instances to people) ------ */
.asg-combo .ve-tag-chip { white-space: nowrap; }
.asg-combo .ve-combo-list { margin-top: 8px; max-height: 240px; }
.asg-combo .ve-combo-item { padding: 8px 10px; }
.asg-opt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.asg-opt-name { font: 500 13.5px/1.2 var(--font-body); color: var(--foreground); }
.asg-opt-detail { font: 400 11.5px/1.3 var(--font-body); color: var(--muted-foreground); }
.ve-combo-item:hover .asg-opt-detail, .ve-combo-item.active .asg-opt-detail { color: var(--accent-foreground); }
/* Locked chips = people who already hold this agent; muted + non-removable. */
.ve-tag-chip.asg-chip-locked {
  background: var(--muted); color: var(--muted-foreground);
  border-color: var(--hairline); padding-right: 9px;
}
.ve-tag-chip.asg-chip-locked i, .ve-tag-chip.asg-chip-locked svg { opacity: 0.7; }
.asg-chip-state {
  font: 600 9px/1 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted-foreground); margin-left: 2px;
  padding-left: 6px; border-left: 1px solid var(--hairline);
}

/* ---- Catalog (member subscribe view) ---------------------------------- */
.cat-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--divider);
}
.cat-owner { display: flex; align-items: center; gap: 8px; font: 400 12px/1.2 var(--font-body); color: var(--muted-foreground); }
.cat-owner .av {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font: 600 9px/1 var(--font-mono); color: #fff; background: var(--ps-primary-400);
}
.cat-sub-state { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 var(--font-body); color: var(--ps-secondary-700); }
.cat-sub-state i { width: 14px; height: 14px; }

/* Managed-instance card badge on the Agents index */
.aix-managed {
  display: inline-flex; align-items: center; gap: 4px;
  font: 600 10px/1.1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  padding: 5px 9px; border-radius: 4px; white-space: nowrap;
}
.aix-managed i, .aix-managed svg { width: 11px; height: 11px; }
/* Ownership badges share the solid-pill treatment of .tpl-pub-pill but use
   the brand-blue family so "source" (assigned vs subscribed) reads as a
   different axis from lifecycle status (green/amber/gray). */
.aix-managed.assigned   { background: #2e3999; color: #fff; }
.aix-managed.subscribed { background: #3e4ccc; color: #fff; }
.agent-index-section-label {
  font: 600 10px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted-foreground); margin: 8px 0 2px;
  display: flex; align-items: center; gap: 7px;
}
.agent-index-section-label .count {
  background: var(--ps-neutral-125); color: var(--ps-neutral-500);
  padding: 1px 7px; border-radius: 10px; font-size: 9.5px;
}

/* The "Browse templates" tile (mirrors .agent-index-new but secondary) */
.tpl-browse-tile {
  background: transparent;
  border: 2px dashed var(--ps-secondary-300);
  border-radius: 16px;
  padding: 22px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.tpl-browse-tile:hover { background: var(--ps-secondary-50); border-color: var(--ps-secondary-500); }
.tpl-browse-tile .bt-icon {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--ps-secondary-50); color: var(--ps-secondary-600);
}
.tpl-browse-tile .bt-icon i { width: 18px; height: 18px; }
.tpl-browse-tile .bt-text { display: flex; flex-direction: column; gap: 3px; }
.tpl-browse-tile .bt-text strong { font: 600 14.5px/1.2 var(--font-body); color: var(--ps-secondary-700); }
.tpl-browse-tile .bt-text span { font: 400 12px/1.3 var(--font-body); color: var(--ps-secondary-600); }

/* Read-only open-filter (territory) card on the member instance — the one
   editable surface. Emphasized with a soft green frame. */
.open-filter-card { border: 1.5px solid var(--ps-secondary-200) !important; }
/* ===== Account page form ===== */
.acct-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px;
  padding: 8px 0 4px;
}
.acct-field { display: flex; flex-direction: column; gap: 7px; }
.acct-label { font: 600 13px/1 var(--font-body); color: var(--ps-secondary-700, #475569); }
.acct-input {
  font: 400 15px/1.3 var(--font-body); color: var(--foreground);
  padding: 11px 14px; border: 1px solid var(--ps-neutral-200, #e3e3e6);
  border-radius: 10px; background: var(--card); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.acct-input::placeholder { color: var(--ps-tertiary-500, #b0b0b8); }
.acct-input:focus { border-color: var(--ps-primary-400); box-shadow: 0 0 0 3px var(--ps-primary-60); }
.acct-actions-row { display: flex; align-items: center; gap: 10px; padding: 14px 0 4px; }
.open-filter-card .fw-toolbar { background: var(--ps-secondary-50); border-radius: 14px 14px 0 0; }
.open-filter-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 26px 18px; text-align: center;
  color: var(--muted-foreground); font: 400 13px/1.5 var(--font-body);
}
.open-filter-empty .ofe-icon {
  width: 38px; height: 38px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ps-secondary-50); color: var(--ps-secondary-600);
}
.open-filter-empty .ofe-illustration {
  width: 160px; height: auto; display: block;
  margin-bottom: 2px;
}
.open-filter-empty .ofe-cta { margin-top: 6px; }
/* Read-only assigned-territory display on the Account page (SF / admin). */
.acct-terr-assigned { display: flex; flex-direction: column; gap: 14px; }
.acct-terr-block { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ======================================================================
   RIGHT-COLUMN SEGMENTED CONTROL (Results Preview / Performance) — sits
   atop the right column on enabled agents, toggling which card shows. */
.agent-right-segwrap { display: flex; }
.agent-right-segwrap .dv-segmented { display: flex; width: 100%; }
.agent-right-segwrap .dv-seg { flex: 1; justify-content: center; }

/* ======================================================================
   PERFORMANCE CARD — last-30-day impact for an enabled agent. */
.perf-card .perf-head-right {
  display: inline-flex; align-items: center; gap: 7px;
  font: 400 11.5px/1 var(--font-body); color: var(--muted-foreground);
}
.perf-trend {
  display: inline-flex; align-items: center; gap: 3px;
  font: 600 11.5px/1 var(--font-mono);
  padding: 3px 7px; border-radius: 999px;
}
.perf-trend.up   { color: #2c6e49; background: #e7f3ec; }
.perf-trend.down { color: #b4232a; background: #fdecec; }
.perf-trend i, .perf-trend svg { width: 12px; height: 12px; }

.perf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.perf-stat {
  border: 1px solid var(--hairline); border-radius: 10px;
  padding: 14px 12px; text-align: center; background: var(--ps-neutral-50, #fafafb);
}
.perf-stat-value { font: 700 24px/1.05 var(--font-body); letter-spacing: -0.01em; color: var(--foreground); }
.perf-stat-label { margin-top: 4px; font: 500 11.5px/1.2 var(--font-body); color: var(--muted-foreground); }

.perf-bar-label {
  display: flex; align-items: baseline; justify-content: space-between;
  font: 600 10.5px/1 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted-foreground); margin-bottom: 8px;
}
.perf-bar-total { font-weight: 500; letter-spacing: 0.02em; text-transform: none; }
.perf-bar {
  display: flex; gap: 2px; height: 9px; border-radius: 999px; overflow: hidden;
  background: var(--ps-neutral-150); margin-bottom: 12px;
}
.perf-seg { display: block; height: 100%; border-radius: 2px; }
.perf-seg--unread    { background: var(--ps-primary-500); }
.perf-seg--reviewed  { background: var(--ps-neutral-300); }
.perf-seg--saved     { background: #e0a210; }
.perf-seg--dismissed { background: var(--ps-neutral-200); }
.perf-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.perf-legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  font: 400 12.5px/1.2 var(--font-body); color: var(--foreground);
}
.perf-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.perf-dot--unread    { background: var(--ps-primary-500); }
.perf-dot--reviewed  { background: var(--ps-neutral-300); }
.perf-dot--saved     { background: #e0a210; }
.perf-dot--dismissed { background: var(--ps-neutral-200); }

/* Shared filter / territory editor modal (openFilterEditorModal). Wider
   than the default modal so the filter panel has room; its value-editor
   popover floats above the scrim via the global .editor-popover z-index. */
.fe-modal { width: 580px; max-width: calc(100vw - 32px); max-height: 88vh; display: flex; flex-direction: column; }
.fe-modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.fe-modal-sub { font: 400 13px/1.5 var(--font-body); color: var(--muted-foreground); margin-bottom: 10px; }
.open-filter-empty strong { color: var(--foreground); font-weight: 600; display: block; }

/* Threshold slider (template editor) */
.thr-row { display: flex; align-items: center; gap: 14px; padding: 4px 2px; }
.thr-slider { flex: 1 1 auto; accent-color: var(--ps-primary-500); height: 4px; }
.thr-val { font: 600 15px/1 var(--font-mono); color: var(--ps-primary-700); min-width: 34px; text-align: right; }

/* Penalty = absolute filter: no weight, an "Excludes match" indicator. */
.crit-abs { justify-content: flex-start; }
.crit-abs-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font: 500 11px/1 var(--font-mono); letter-spacing: 0.02em;
  padding: 4px 9px 4px 7px; border-radius: 20px;
  background: var(--ps-destructive-soft); color: var(--ps-destructive);
  white-space: nowrap;
}
.crit-abs-pill i { width: 11px; height: 11px; }
.crit-penalty-note {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--ps-destructive-soft);
  border: 1px solid var(--ps-destructive-ring);
  font: 400 12.5px/1.45 var(--font-body); color: var(--ps-neutral-600);
}
.crit-penalty-note i { color: var(--ps-destructive); flex-shrink: 0; margin-top: 1px; }
.crit-penalty-note strong { color: var(--foreground); font-weight: 600; }


