/* ============================================================================
   AI traffic view — live session monitor.

   Split from the design system because it is the only screen with a streaming
   surface: a live rail whose rows arrive, update in place, and age out.
   ========================================================================== */

/* --- Live indicator ------------------------------------------------------- */

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 9px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-muted);
}

.live-pill .pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--n-7);
}

.live-pill.on {
  border-color: var(--success-dim);
  color: var(--success);
}

.live-pill.on .pulse {
  background: var(--success);
  animation: livePulse 1.8s var(--ease) infinite;
}

.live-pill.off {
  border-color: var(--danger-dim);
  color: var(--danger);
}

.live-pill.off .pulse {
  background: var(--danger);
}

@keyframes livePulse {
  0% {
    box-shadow: 0 0 0 0 var(--success-dim);
  }
  70% {
    box-shadow: 0 0 0 7px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

/* --- Session activity ----------------------------------------------------- */

.session-name {
  display: flex;
  align-items: center;
  gap: 7px;
}

.session-lines {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.session-lines strong {
  white-space: nowrap;
}

.session-task {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text);
}

.turn-table .task-row td {
  padding: 5px var(--s-3);
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}

.task-row .task-title {
  font-weight: 550;
  color: var(--text);
  margin-right: var(--s-2);
}

.task-row .task-count {
  color: var(--text-dim);
}

.panel-task {
  margin: 2px 0 4px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60ch;
}

.session-model {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--text-muted);
}

.dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--n-7);
}

.dot-live {
  background: var(--success);
  animation: livePulse 1.8s var(--ease) infinite;
}

/* The stat reuses the dot inline, where it needs to sit on the baseline of a
   26px number rather than on a table row. */
.stat .dot-live {
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}

tbody tr.live {
  background: var(--success-dim);
}

tbody tr.live:hover {
  background: color-mix(in srgb, var(--success-dim) 70%, var(--surface-hover));
}

/* --- Session detail ------------------------------------------------------- */

.session-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.detail-section {
  margin-bottom: var(--s-5);
}

.detail-section > h3 {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: var(--s-3);
}

/* The Files read/write filter, pinned atop the Files pane: plain text, smaller
   than the tabs, so it reads as a filter on the open tab rather than more tabs. */
.tab-filter {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  padding-top: var(--s-3);
  background: var(--surface);
}

.tab-filter button {
  display: inline-flex;
  align-items: center;
  background: none;
  cursor: pointer;
  padding: 2px 6px;
  margin: 0;
  border: 0;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
}

.tab-filter button b {
  margin-left: 3px;
  font-weight: 600;
  color: inherit;
}

.tab-filter button:hover { color: var(--text); }

/* Coloured like the read and write counts in the session list, so the two
   are recognisable at a glance; the open one is filled. */
.tab-filter button[data-files-tab="read"] { color: var(--info); }
.tab-filter button[data-files-tab="write"] { color: var(--warn); }

.tab-filter button[data-files-tab="read"].active { background: var(--info-dim); }
.tab-filter button[data-files-tab="write"].active { background: var(--warn-dim); }

.tab-filter button:not(.active) { opacity: 0.7; }
.tab-filter button:not(.active):hover { opacity: 1; }
.tab-filter button.active b { color: inherit; }

/* Files as a two-column table: the folder once on the left, its files one
   per row on the right. */
.file-groups {
  display: grid;
  grid-template-columns: fit-content(40%) minmax(0, 1fr);
}

.file-groups > p,
.file-outside-head { grid-column: 1 / -1; }

.file-group { display: contents; }

.file-group-head,
.file-group-items {
  border-bottom: 1px solid var(--border);
  line-height: 18px;
}

.file-group-head {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  text-align: left;
  padding: 5px var(--s-4) 5px 0;
  font-size: 11px;
  color: var(--text-dim);
}

.file-group-items {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-item {
  padding: 5px 0;
  border-bottom: 1px solid var(--border-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text);
}

.file-item:last-child { border-bottom: 0; }

.file-item.dir,
.file-item.pattern {
  color: var(--text-muted);
}

.file-item.pattern { font-style: italic; }

.file-outside-head {
  margin-top: var(--s-2);
  padding-top: var(--s-3);
  border-top: 1px dashed var(--border-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--warn);
}

.file-group.outside .file-group-head { color: var(--warn); }

/* --- Sensitive groups ----------------------------------------------------- */

.sens-group {
  display: flex;
  flex-direction: column;
}

.sens-group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sens-group-head b {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.sens-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 7px var(--s-2);
  border-top: 1px solid var(--border-soft);
  font-size: 12.5px;
  list-style: none;
}

.sens-row::-webkit-details-marker { display: none; }

.sens-row-wrap > .sens-row { cursor: pointer; }
.sens-row-wrap > .sens-row:hover { background: var(--surface-hover); }

.sens-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.sens-origin {
  padding: 0 6px;
  border-radius: var(--r-sm);
  background: var(--warn-dim);
  font-size: 10.5px;
  color: var(--warn);
}

.sens-row b {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.sens-caret {
  width: 10px;
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.12s ease;
}

.sens-row-wrap[open] .sens-caret { transform: rotate(90deg); }

.sens-row-wrap .finding-values {
  margin: 0 0 var(--s-2);
  padding: 0 var(--s-2);
}

.sens-origin.sens-action.redacted,
.sens-origin.sens-action.restored {
  background: var(--accent-dim);
  color: var(--accent);
}

/* A reversible-redaction token in captured text. */
.redact-token {
  display: inline-block;
  padding: 0 6px;
  border-radius: var(--r-sm);
  background: var(--accent-dim);
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--accent);
  white-space: nowrap;
}

/* --- Transcript ----------------------------------------------------------- */

/* --- Agent marks ---------------------------------------------------------- */

/* One tinted tile per agent family. The tint is the recognition cue in a long
   list; the glyph disambiguates families that share a hue. */
.agent-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  box-sizing: border-box;
  padding: 3px;
  overflow: hidden;
  border-radius: var(--r-sm);
  border: 1px solid var(--agent-line, var(--border));
  background: var(--agent-bg, var(--surface-raised));
  color: var(--agent-fg, var(--text-muted));
}

/* The glyph fills the padded box rather than carrying a second, hidden
   margin of its own: the brand marks already vary in how much air they leave. */
.agent-mark .icon {
  width: 100%;
  height: 100%;
}

.tone-amber  { --agent-fg: #b45309; --agent-bg: #fef3c7; --agent-line: #fcd34d; }
.tone-indigo { --agent-fg: #4338ca; --agent-bg: #e0e7ff; --agent-line: #a5b4fc; }
.tone-violet { --agent-fg: #6d28d9; --agent-bg: #ede9fe; --agent-line: #c4b5fd; }
.tone-blue   { --agent-fg: #1d4ed8; --agent-bg: #dbeafe; --agent-line: #93c5fd; }
.tone-teal   { --agent-fg: #0f766e; --agent-bg: #ccfbf1; --agent-line: #5eead4; }
.tone-green  { --agent-fg: #15803d; --agent-bg: #dcfce7; --agent-line: #86efac; }
.tone-slate  { --agent-fg: #475569; --agent-bg: #e2e8f0; --agent-line: #cbd5e1; }


/* --- Session detail dialog ------------------------------------------------ */

/* The session dialog carries a turn table and five summary panes, which the
   shared 620px dialog width turned into one very long column. Widening it and
   splitting it in two is the whole fix: scrolling stays the dialog's own, as
   it is for every other dialog here. */

/* Turns get the room; the summary panes are reference material and sit beside
   them rather than pushing them down the page. The breakpoint is on the panel,
   not the window: the dialog is the thing that has to fit two columns, and it
   is always narrower than the viewport. */

/* --- MCP breakdown -------------------------------------------------------- */

.mcp-server {
  padding: var(--s-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--bg-sink);
}

.mcp-server + .mcp-server {
  margin-top: var(--s-3);
}

.mcp-tools {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Name, share of the server's calls, count. The bar is what makes a server's
   one hot function obvious without reading every number. */
.mcp-tool {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px 34px;
  align-items: center;
  gap: var(--s-2);
  font-size: 12px;
}

.mcp-tool b {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-weight: 600;
}

.mcp-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
}

.mcp-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.saving-row {
  grid-template-columns: minmax(0, 1fr) 52px 72px 18px;
}

.saving-row b {
  white-space: nowrap;
}

.saving-row .mcp-bar i {
  background: var(--success);
}

.saving-total {
  margin: 0;
}

.mcp-server-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.mcp-server-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

/* A workflow's decisions are a verdict count, not a share: badges, apart from its tags. */
.wf-decisions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.wf-tags-label {
  margin: var(--s-3) 0 var(--s-2);
}

.mcp-server-name strong {
  font-size: 13px;
  font-weight: 600;
}

.mcp-server-name .sub {
  font-size: 11px;
}

/* --- Aside scope ---------------------------------------------------------- */

/* Same voice as the Turns heading opposite. */
.aside-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.aside-title .mono {
  letter-spacing: 0;
  color: var(--text);
}

.scope-back {
  margin-left: auto;
  padding: 2px 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  cursor: pointer;
}

.scope-back:hover {
  color: var(--text);
  background: var(--surface-raised);
}

/* The table is the scroll area and the Turns title sits above it. When the
   column itself scrolled, rows slid through its top padding and showed above
   the pinned header. */
.panel-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

.panel-main > .detail-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.panel-main .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-bottom: var(--s-6);
}

/* The marker belongs on the row, so it goes on the first cell only: on every
   cell it draws a bar down each column boundary. */

/* The turn table is dense and lives in a narrow column, so the columns that
   can wrap are told not to and the model name gets the room it needs. */

/* --- Focused session ------------------------------------------------------ */

tr.focused > td {
  background: var(--accent-dim);
}

tr.focused > td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.ghost.small {
  padding: 3px 9px;
  font-size: 11.5px;
}

#live-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

/* --- Session drawer ------------------------------------------------------- */

/* A <dialog> rather than a bare aside: Esc, focus trapping and the backdrop
   come from the platform, and only the geometry has to be restyled into a
   right-hand drawer. */
#session-dialog {
  width: min(1180px, 94vw);
  max-width: none;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  box-shadow: -24px 0 60px rgba(3, 5, 8, 0.22);
}

#session-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: drawer-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

#session-dialog[open]::backdrop {
  animation: backdrop-in 220ms ease;
}

@keyframes drawer-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #session-dialog[open],
  #session-dialog[open]::backdrop {
    animation: none;
  }
}

.session-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border-soft);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}

.panel-title .agent-mark {
  width: 34px;
  height: 34px;
  flex: none;
}

.panel-title h2 {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 17px;
  letter-spacing: -0.02em;
}

.panel-title .session-id {
  font-size: 11.5px;
  color: var(--text-dim);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.panel-stats {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(max-content, 1fr);
  gap: var(--s-4);
  overflow-x: auto;
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-sink);
}

.panel-stats > .ps-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.panel-stats .ps-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.panel-stats .ps-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-stats .ps-icon {
  flex: none;
  width: 13px;
  height: 13px;
}

.panel-stats .has-errors .ps-label,
.panel-stats .has-errors strong {
  color: var(--danger);
}

.panel-stats .ps-label {
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-dim);
}

.panel-stats strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.panel-stats .ps-sub {
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.panel-stats .ps-sub .ps-mini {
  width: 12px;
  height: 12px;
  margin-right: 2px;
  vertical-align: -2px;
}

.panel-stats .ps-tool-icons {
  display: inline-flex;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
}

.panel-stats .ps-tool-icons .ps-mini {
  margin-right: 0;
}

/* "flat" stands where an amount would, so it reads exactly like one. */
.panel-stats strong > .muted {
  color: inherit;
  font-weight: inherit;
}

.saving-row .info-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: default;
}

.saving-row .info-mark svg {
  width: 14px;
  height: 14px;
}

.saving-row .info-mark:hover,
.saving-row .info-mark:focus-visible {
  color: var(--text);
}

.info-tooltip {
  position: absolute;
  z-index: 4;
  right: -8px;
  top: calc(100% + 7px);
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 450;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  pointer-events: none;
}

.info-tooltip[hidden] {
  display: none;
}

.info-tooltip.up {
  top: auto;
  bottom: calc(100% + 7px);
}

/* Placed against the viewport by toggleTooltip: its trigger sits in a row that scrolls. */
.info-tooltip.float {
  position: fixed;
  right: auto;
  bottom: auto;
  z-index: 60;
}

.gw-spend {
  display: inline-flex;
  align-items: center;
  cursor: default;
}

.gw-spend:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.info-tooltip b {
  font-weight: 600;
}

.info-tooltip > span + span {
  display: block;
  margin-top: 4px;
}

/* One gateway call source: its name, its amount at the right, the counts below. */
.info-tooltip .gw-spend-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.info-tooltip .gw-spend-row em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.info-tooltip small {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10.5px;
}

/* Turns take the width; the summary panes sit beside them and scroll with the
   drawer rather than pushing the table off the screen. */
/* Each column scrolls on its own, so the summary on the right stays in view
   while the turn list is walked. */
.panel-body {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: var(--s-5);
  padding: 0 var(--s-6);
  overflow: hidden;
  min-height: 0;
  flex: 1;
}

/* Title and tabs stay put; only the pane below them scrolls, for the same
   reason as the turn table opposite. */
.panel-aside {
  overflow: hidden;
  padding-top: var(--s-5);
}

.aside-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: var(--s-6);
}

.panel-main {
  padding-top: var(--s-5);
}

@media (max-width: 900px) {
  .panel-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    overflow-y: auto;
  }

  .panel-main,
  .panel-aside {
    overflow: visible;
  }

  .panel-main {
    display: block;
  }

  .panel-main .table-wrap,
  .aside-scroll {
    overflow-y: visible;
  }
}

.panel-main {
  min-width: 0;
}

.panel-aside {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-width: 0;
}

.panel-aside .detail-section,
.panel-main .detail-section {
  margin: 0;
}

.panel-main th,
.panel-main td {
  white-space: nowrap;
}

.panel-main tr.selected > td {
  background: var(--accent-dim);
}

.panel-main tr.selected > td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

/* A turn that just arrived flashes once, so a demo audience sees the row
   appear rather than having to diff the table themselves. */
.panel-main tr.fresh > td {
  animation: turn-flash 1.6s ease-out;
}

@keyframes turn-flash {
  from { background: var(--accent-dim); }
  to   { background: transparent; }
}

/* --- Session list cells --------------------------------------------------- */

.tokens {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.tok-sep {
  color: var(--text-dim);
}

.tok-out {
  color: var(--accent);
  font-weight: 600;
}

.tok-out.steered::after {
  content: "\2193";
  margin-left: 1px;
  font-size: 0.8em;
}

.tok-saved {
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--success-dim);
  color: var(--success);
  font-size: 0.85em;
  font-weight: 600;
}

.tok-cache {
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
}

.panel-stats .has-saved .ps-label,
.panel-stats .has-saved strong {
  color: var(--success);
}

/* Compression cost more than it saved: the share is negative, so the card
   must not read as a saving. */
.panel-stats .has-loss .ps-label,
.panel-stats .has-loss strong {
  color: var(--danger);
}

.panel-stats .has-saved strong,
.panel-stats .has-loss strong {
  white-space: nowrap;
}

.panel-stats .has-saved strong > .muted,
.panel-stats .has-loss strong > .muted {
  font-size: 0.6em;
  font-weight: 500;
  opacity: 0.8;
}

.tool-cell {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.tool-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 18px;
}

.mark-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mark-row .agent-mark {
  width: 22px;
  height: 22px;
  padding: 2.5px;
}

.file-cell {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.session-list td {
  vertical-align: middle;
}

/* Stacked badges doubled the row height for two short counts. */
.session-list .file-cell {
  flex-wrap: nowrap;
}

.file-cell {
  gap: 10px;
}

.icon-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.icon-count svg {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--text-dim);
}

.icon-count.sensitive { font-weight: 600; }
.icon-count.sensitive.danger,
.icon-count.sensitive.danger svg { color: var(--danger); }
.icon-count.sensitive.warning,
.icon-count.sensitive.warning svg { color: var(--warn); }
.icon-count.sensitive.info,
.icon-count.sensitive.info svg { color: var(--info); }

/* Only a live session gets a dot; an idle one keeps the slot so the names
   stay in one column. */
.session-name .dot:not(.dot-live) {
  visibility: hidden;
}

/* --- Model chips ---------------------------------------------------------- */

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 220px;
}

.model-chip .agent-mark {
  width: 22px;
  height: 22px;
  flex: none;
  padding: 2.5px;
}

.model-chip .truncate {
  font-size: 12.5px;
}

/* --- Brand marks ---------------------------------------------------------- */

/* A colour logo carries its own fills, so the tinted tile would fight it: the
   tile goes neutral and the mark is left alone. A monochrome logo (OpenAI,
   Cursor, OpenCode) draws in currentColor, which on the neutral tile has to be
   the text colour: a tone is a light-theme shade and all but vanishes on the
   dark one. The a-* and c-* glyphs keep their tinted tile, which is what makes
   an unbranded server still recognisable. */
.agent-mark.brand {
  --agent-bg: var(--surface);
  --agent-line: var(--border);
  background: var(--agent-bg);
  color: var(--text);
}

/* --- Icons ---------------------------------------------------------------- */

/* Without a base size an inline <svg><use> renders at the CSS default of
   300x150, which is how the menu button ended up taller than the page. The
   sidebar's own .ico rule covered the navigation but nothing else. */
.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.mobile-menu .icon {
  width: 20px;
  height: 20px;
}

/* --- Proportional sizes --------------------------------------------------- */

/* Discrete steps instead of an inline style: style-src 'self' blocks both a
   style attribute and the CSSOM write that produces one. */
.h-5 { height: 5%; }
.w-5 { width: 5%; }
.h-10 { height: 10%; }
.w-10 { width: 10%; }
.h-15 { height: 15%; }
.w-15 { width: 15%; }
.h-20 { height: 20%; }
.w-20 { width: 20%; }
.h-25 { height: 25%; }
.w-25 { width: 25%; }
.h-30 { height: 30%; }
.w-30 { width: 30%; }
.h-35 { height: 35%; }
.w-35 { width: 35%; }
.h-40 { height: 40%; }
.w-40 { width: 40%; }
.h-45 { height: 45%; }
.w-45 { width: 45%; }
.h-50 { height: 50%; }
.w-50 { width: 50%; }
.h-55 { height: 55%; }
.w-55 { width: 55%; }
.h-60 { height: 60%; }
.w-60 { width: 60%; }
.h-65 { height: 65%; }
.w-65 { width: 65%; }
.h-70 { height: 70%; }
.w-70 { width: 70%; }
.h-75 { height: 75%; }
.w-75 { width: 75%; }
.h-80 { height: 80%; }
.w-80 { width: 80%; }
.h-85 { height: 85%; }
.w-85 { width: 85%; }
.h-90 { height: 90%; }
.w-90 { width: 90%; }
.h-95 { height: 95%; }
.w-95 { width: 95%; }
.h-100 { height: 100%; }
.w-100 { width: 100%; }

/* --- Traffic dashboard ---------------------------------------------------- */

/* --- Efficiency savings --------------------------------------------------- */
.efficiency-savings-card { grid-column: 1 / -1; }
.efficiency-total { color: var(--success); font-size: 22px; font-variant-numeric: tabular-nums; }
.efficiency-total small { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.efficiency-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); margin: var(--s-4) 0; }
.efficiency-tile { display: grid; grid-template-columns: 1fr auto; gap: 4px var(--s-3); padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); }
.efficiency-tile span { grid-column: 1 / -1; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.efficiency-tile strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.efficiency-tile em { align-self: end; justify-self: end; padding: 4px 8px; border-radius: var(--r-sm); background: var(--surface-raised); color: var(--text-muted); font-size: 11px; font-style: normal; }
.efficiency-tile.cache { border-color: #e7d9ff; background: #fbf7ff; }
.efficiency-tile.cache strong, .efficiency-tile.cache span { color: #7627d7; }
.efficiency-tile.compression { border-color: #d5e3ff; background: #f5f8ff; }
.efficiency-tile.compression strong, .efficiency-tile.compression span { color: #2457d6; }
.efficiency-tile.routing { border-color: #ccefdc; background: #f3fcf7; }
.efficiency-tile.routing strong, .efficiency-tile.routing span { color: #218851; }
.efficiency-breakdown { padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-raised); }
.efficiency-breakdown h3 { margin: 0 0 var(--s-3); color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.efficiency-breakdown-row { display: flex; justify-content: space-between; gap: var(--s-3); padding: 6px 0; color: var(--text-muted); font-size: 12px; }
.efficiency-breakdown-row + .efficiency-breakdown-row { border-top: 1px solid var(--border-soft); }
.efficiency-breakdown-row strong { color: var(--text); font-weight: 500; }
.efficiency-empty { color: var(--text-dim); font-size: 12px; }
@media (max-width: 700px) { .efficiency-tiles { grid-template-columns: 1fr; } }

.topbar-tools {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.range-select,
.filter-input {
  height: 32px;
  /* The base form rule makes every input full width with a label above it.
     These sit inline in a toolbar, so both have to be undone or the three
     controls stack down the card. */
  width: auto;
  margin-top: 0;
  padding: 0 var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  /* Colour only: the shorthand would wipe the select's arrow. */
  background-color: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}

select.range-select,
select.filter-input {
  padding-right: 30px;
  cursor: pointer;
}

.table-filters {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.filter-input[type="search"] {
  min-width: 190px;
}

.table-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-4);
  border-top: 1px solid var(--border-soft);
}

.grid.thirds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--s-5);
}

/* --- Metric cards --------------------------------------------------------- */

.metric {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.spark {
  width: 74px;
  height: 28px;
  flex: none;
}

.spark polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.spark.ok polyline { stroke: var(--success); }
.spark.warn polyline { stroke: var(--warn); }
.spark.error polyline { stroke: var(--danger); }

/* --- Time series ---------------------------------------------------------- */

.chart-legend {
  display: flex;
  gap: var(--s-4);
  margin-bottom: var(--s-3);
  font-size: 11.5px;
  color: var(--text-muted);
}

.key::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
}

.key.in::before { background: var(--accent); }
.key.out::before { background: var(--success); }

.series {
  position: relative;
  height: 180px;
}

.series-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100%;
}

.series-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex: 1;
  height: 100%;
  min-width: 0;
}

.series-col .seg {
  display: block;
  width: 100%;
  border-radius: 2px 2px 0 0;
}

.seg.in { background: var(--accent); }
.seg.out { background: var(--success); }

/* --- Donut ---------------------------------------------------------------- */

.donut-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--s-4);
  align-items: center;
}

.donut {
  width: 120px;
  height: 120px;
  transform: rotate(-90deg);
}

.ring {
  fill: none;
  stroke-width: 14;
}

.ring.track { stroke: var(--border-soft); }
.ring.tone-blue { stroke: #2563eb; }
.ring.tone-green { stroke: #16a34a; }
.ring.tone-violet { stroke: #8b5cf6; }
.ring.tone-amber { stroke: #f59e0b; }
.ring.tone-teal { stroke: #0d9488; }

.donut-centre {
  position: absolute;
  left: 60px;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  line-height: 1.1;
}

.donut-centre strong {
  display: block;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.donut-centre small {
  font-size: 10.5px;
  color: var(--text-dim);
}

.donut-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.donut-legend li {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.donut-legend b {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.donut-legend em {
  font-style: normal;
  color: var(--text-dim);
  min-width: 34px;
  text-align: right;
}

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: none;
}

.swatch.tone-blue { background: #2563eb; }
.swatch.tone-green { background: #16a34a; }
.swatch.tone-violet { background: #8b5cf6; }
.swatch.tone-amber { background: #f59e0b; }
.swatch.tone-teal { background: #0d9488; }

.residency-card {
  min-width: 0;
  overflow: hidden;
  align-self: stretch;
}

.residency-card .card-head {
  flex-wrap: nowrap;
}

.residency-switch {
  display: inline-flex;
  flex: none;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
}

.residency-switch button {
  padding: 3px 8px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}

.residency-switch button:hover { color: var(--text); }
.residency-switch button.active { background: var(--surface-hover); color: var(--text); }
.residency-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.residency-donut {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: var(--s-3);
  padding-top: 0;
}

.residency-plot {
  position: relative;
  width: 154px;
  height: 154px;
}

.residency-plot .donut {
  width: 100%;
  height: 100%;
}

.residency-plot .donut-centre {
  left: 50%;
  top: 50%;
}

.residency-donut .donut-centre strong { font-size: 22px; }

.residency-donut .donut-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: var(--s-5);
  font-size: 11.5px;
}

.residency-donut .donut-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.residency-legend-label {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
  color: var(--text-muted);
}

.residency-donut .donut-legend b {
  margin-left: 0;
  font-size: 12px;
}

.residency-donut .donut-legend em {
  min-width: 0;
  font-size: 11px;
}

@media (max-width: 540px) {
  .residency-card .card-head { align-items: flex-start; }
  .residency-donut .donut-legend { gap: var(--s-3); }
}

/* --- Breakdown lists ------------------------------------------------------ */

.breakdown {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: var(--s-4) 0 0;
}

.breakdown li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 44px;
  align-items: center;
  gap: var(--s-3);
  font-size: 12.5px;
}

.breakdown li > span:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.breakdown .agent-mark {
  width: 18px;
  height: 18px;
  padding: 2px;
}

.breakdown b {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.fit-list li {
  cursor: pointer;
  border-radius: var(--r-sm);
  margin: 0 -6px;
  padding: 3px 6px;
}

.fit-list li:hover {
  background: var(--surface-raised);
}

.fit-tag {
  justify-self: start;
  font-size: 11px;
  color: var(--warn);
}

.fit-tag.undersized {
  color: var(--danger);
}

.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.chevron-cell {
  color: var(--text-dim);
  text-align: right;
}

/* --- Retention notice ------------------------------------------------------ */

/* Stated in the page, not only in the config file: a setting that makes the
   appliance keep the values it detects has to be visible to whoever is looking
   at those values. */
.notice {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: var(--s-4);
}

.notice.warning {
  border-color: var(--warn);
  background: var(--warn-dim);
  color: var(--text);
}

.notice strong { margin-right: 4px; }

/* Folded shut by default: the values are the sensitive thing on the page, and
   nobody reviewing a session should have somebody's data on screen until they
   ask for it. */
.finding-values {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0 var(--s-2) var(--s-3);
}

.finding-values code {
  padding: 1px 6px;
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  font-size: 11.5px;
  word-break: break-all;
}

/* --- Watchlist ------------------------------------------------------------ */

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.pattern-help {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  border: 1px solid var(--border-soft);
}

.pattern-help div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  font-size: 11px;
  color: var(--text-muted);
}

.pattern-help code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

/* A paused term keeps its row so it can be resumed, but must not read as
   something the appliance is currently watching for. */
.row-muted td {
  opacity: 0.55;
}

/* The switch is how the row is resumed, so it must not look disabled. */
.row-muted td:has(> .toggle) {
  opacity: 1;
}

.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
}

#params-dialog {
  width: min(640px, calc(100vw - 32px));
}

.confirm-dialog h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.confirm-dialog p {
  margin-top: var(--s-2);
  line-height: 1.5;
}

.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.danger-solid:hover {
  background: color-mix(in srgb, var(--danger) 88%, black);
  border-color: color-mix(in srgb, var(--danger) 88%, black);
}

.danger-solid:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.fit-badge {
  margin-left: 6px;
  font-size: 10.5px;
  padding: 1px 6px;
  vertical-align: 1px;
}

.fact-label {
  margin-right: 5px;
  color: var(--text-dim);
}

.diff-fact {
  display: inline-flex;
  align-items: center;
}

.diff-meter {
  display: inline-flex;
  gap: 2px;
  margin-left: 6px;
}

.diff-meter i {
  width: 4px;
  height: 10px;
  border-radius: 1px;
  background: var(--border);
}

.diff-meter i.on {
  background: var(--text-muted);
}

.detector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s-3) var(--s-4);
}

.detector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
}

.detector-row:hover {
  background: var(--surface-raised);
}

/* A checkbox drawn as a switch: native input, so focus and keyboard work. */
input.toggle {
  appearance: none;
  flex: none;
  position: relative;
  width: 30px;
  height: 17px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
}

input.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

input.toggle:checked {
  background: var(--accent);
}

input.toggle:checked::after {
  transform: translateX(13px);
}

input.toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input.toggle:disabled {
  opacity: 0.5;
  cursor: default;
}

.detector-row span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.detector-row strong {
  font-size: 13px;
  color: var(--text);
}

.detector-row small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.detector-row.off strong {
  color: var(--text-muted);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.table-action.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* The matched part of a watchlist value. Tinted rather than the browser's
   yellow, which reads as a search hit rather than a finding. */
.finding-values mark {
  background: var(--info-dim);
  color: var(--info);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 600;
}

.turn-error {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--danger-dim);
  background: var(--danger-dim);
  font-size: 12px;
}

.turn-error strong {
  color: var(--danger);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.turn-error p {
  margin: 4px 0 0;
  color: var(--text);
  line-height: 1.5;
}

.session-provider {
  color: var(--text-dim);
}

/* --- Session detail header facts ------------------------------------------ */

.panel-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.panel-facts > span + span::before,
.panel-facts > .session-id-chip + span::before {
  content: "\00b7";
  margin: 0 8px;
  color: var(--text-dim);
}

.session-id-chip {
  padding: 1px 6px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: copy;
}

.session-id-chip:hover { color: var(--text); border-color: var(--text-dim); }
.session-id-chip.copied { color: var(--success); border-color: var(--success); }

/* --- Failed turns --------------------------------------------------------- */

.turn-table td.turn-fail {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.turn-fail strong {
  color: var(--danger);
  font-weight: 600;
  margin-right: 8px;
}

.turn-fail span {
  color: var(--text-muted);
}

.turn-table .fail-code {
  color: var(--danger);
  font-weight: 600;
}

/* --- Session aside tabs --------------------------------------------------- */

/* Fixed above the scrolling pane. */
.aside-tabs {
  flex: none;
  display: flex;
  gap: var(--s-4);
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}

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

.aside-tabs button {
  flex: none;
  white-space: nowrap;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--s-2) 0;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

.aside-tabs button b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.aside-tabs button:hover { color: var(--text); }

.aside-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.aside-tabs button.active b { color: var(--text); }

.aside-tabs button.is-empty { color: var(--text-dim); }

.sev-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.sev-dot.danger { background: var(--danger); }
.sev-dot.warning { background: var(--warn); }
.sev-dot.info { background: var(--info); }

.aside-pane {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.aside-pane.hidden { display: none; }

/* --- Sessions / Requests switch ------------------------------------------- */

.view-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.view-head p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Reads as the card title: the two views are the same card seen two ways. */
.view-switch {
  display: flex;
  gap: var(--s-4);
}

.view-switch button {
  padding: 0 0 4px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-dim);
  cursor: pointer;
}

.view-switch button b {
  margin-left: 4px;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.view-switch button:hover { color: var(--text-muted); }

.view-switch button.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* --- Access --- */

/* Form labels set their own display, which would otherwise win over [hidden]. */
.form-grid [hidden],
.opt-actions[hidden] { display: none !important; }

.ac-status {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  border-left: 3px solid var(--info);
}

.ac-status.on { border-left-color: var(--danger); }

.ac-status-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--r-lg);
  background: var(--info-dim);
  color: var(--info);
}

.ac-status.on .ac-status-icon { background: var(--danger-dim); color: var(--danger); }
.ac-status-icon svg { width: 20px; height: 20px; }

.ac-status-text { flex: 1; min-width: 0; }
.ac-status-text strong { font-size: 15px; }
.ac-status-text p { margin: 2px 0 0; }

.ac-families p { margin: 2px 0 var(--s-3); }
.ac-families-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-3);
}

.ac-warning { border-color: var(--warn-dim); }
.ac-warning strong { color: var(--warn); }
.ac-warning ul { margin: var(--s-2) 0 0; padding-left: var(--s-5); color: var(--text-muted); }

.ac-defaults {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--s-3);
}

.ac-default {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-raised);
}

.ac-default strong { font-size: 13.5px; }
.ac-default .field-hint { margin: 2px 0 0; }
.ac-plugin-name { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.ac-plugin-logo { width: 24px; height: 24px; border-radius: 6px; flex: none; }

.ac-seg {
  display: inline-flex;
  flex: none;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
}

.ac-checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px var(--s-3);
  max-height: 180px;
  overflow: auto;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.ac-check {
  display: flex !important;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}

/* Access groups: cards, budget bars and the group editor. */
.ac-chip.allow { border-color: var(--success-dim); color: var(--success); }
.ac-chip.deny { border-color: var(--danger-dim); color: var(--danger); }

.ac-budget { display: flex; flex-direction: column; gap: 4px; }
.ac-bar { height: 6px; border-radius: var(--r-full); background: var(--surface-hover); overflow: hidden; }
.ac-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--med) var(--ease); }
.ac-bar.near i { background: var(--warn); }
.ac-bar.over i { background: var(--danger); }

.ac-aspect input[type="checkbox"]:not(.toggle) { width: auto; flex: none; margin: 0; padding: 0; accent-color: var(--accent); }
.ac-list { display: grid; grid-template-columns: minmax(160px, 220px) 1fr; gap: var(--s-3); align-items: start; }
.ac-list .ac-picks { grid-column: 1 / -1; }
.ac-picks { margin-top: var(--s-2); }
.ac-pick { cursor: pointer; font-family: var(--mono, ui-monospace, monospace); font-size: 12px; }
.ac-pick:hover { border-color: var(--accent-line); color: var(--accent); }
.ac-defaults { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: var(--s-2); margin-bottom: var(--s-3); }

.ac-seg { display: inline-flex; flex: none; padding: 2px; border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); }
.ac-seg-opt { display: inline-flex; margin: 0; cursor: pointer; }
.ac-seg-opt input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.ac-seg-opt span { padding: 3px 12px; border-radius: var(--r-full); font-size: 12.5px; color: var(--text-muted); }
.ac-seg-opt input:checked + span { background: var(--surface-hover); color: var(--text); }
.ac-seg-opt.allow input:checked + span { background: var(--success-dim); color: var(--success); }
.ac-seg-opt.deny input:checked + span { background: var(--danger-dim); color: var(--danger); }
.ac-seg-opt input:focus-visible + span { outline: 2px solid var(--accent); }

.ac-mcp-head { display: flex; gap: var(--s-3); align-items: end; margin-bottom: var(--s-2); }
.ac-mcp-head input[type="search"] { flex: 1; }
.ac-servers { display: flex; flex-direction: column; max-height: 440px; overflow: auto; padding: var(--s-2); border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: var(--s-3); }
.ac-cat { margin: var(--s-3) 0 var(--s-1); font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.ac-cat:first-child { margin-top: 0; }
.ac-server { display: grid; grid-template-columns: auto auto 1fr auto; gap: var(--s-2) var(--s-3); align-items: center; padding: 6px var(--s-2); border-radius: var(--r-md); }
.ac-server:hover { background: var(--surface-hover); }
.ac-server[hidden] { display: none; }
.ac-server-name { display: flex; flex-direction: column; min-width: 0; }
.ac-server-name small { font-size: 12px; }
.ac-ro, .ac-tool { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; white-space: nowrap; }
.ac-tools-wrap, .ac-tools-none { grid-column: 3 / -1; }
.ac-tools-wrap summary { cursor: pointer; font-size: 12.5px; color: var(--text-muted); }
.ac-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px var(--s-3); padding: var(--s-2) 0; }
.ac-tool code { font-size: 12px; }

.hdr-overrides { margin-top: var(--s-2); }
.hdr-overrides summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: var(--s-2); }
.hdr-overrides summary::-webkit-details-marker { display: none; }
.hdr-overrides summary::before { content: "\25b8"; color: var(--text-muted); transition: transform 0.15s; }
.hdr-overrides[open] summary::before { transform: rotate(90deg); }
.hdr-overrides .table-wrap { margin-top: var(--s-2); max-height: 360px; overflow: auto; }

/* Access table: every aspect cell is a button opening that aspect alone. */
.ac-table td { vertical-align: top; padding-top: var(--s-2); padding-bottom: var(--s-2); }
.ac-table th { white-space: nowrap; }
.ac-cell {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  width: 100%; min-width: 120px; min-height: 40px; padding: var(--s-2);
  border: 1px dashed transparent; border-radius: var(--r-md);
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.ac-cell:hover:not(:disabled) { border-color: var(--accent-line); background: var(--surface-hover); }
.ac-cell:focus-visible { outline: 2px solid var(--accent); }
.ac-cell:disabled { cursor: default; }
.ac-cell .chip-row { gap: 4px; }
.ac-name .ac-cell { min-width: 160px; }
.ac-name small { font-size: 12px; }
.ac-global-row { background: var(--accent-dim); }
.ac-table .ac-budget { min-width: 140px; width: 100%; }
.ac-aspect { display: flex; flex-direction: column; gap: var(--s-3); }
.ac-cell .chip, .ac-cell-static .chip { white-space: nowrap; }
.ac-cell-static {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  min-height: 40px; padding: var(--s-2); border: 1px solid transparent;
}
.ac-cell-static .chip-row { gap: 4px; }
.ac-table .muted { white-space: nowrap; }

/* --- Connection dialog: models the provider serves ----------------------- */

.model-picker {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.model-picker-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
}

.model-picker-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s-2);
}

.model-picker [hidden] {
  display: none !important;
}

.model-picker input {
  margin-top: 0;
}

.picker-label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--n-10);
}

.model-manual {
  display: flex;
  gap: var(--s-2);
}

.model-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 6px var(--s-4);
  max-height: 200px;
  overflow: auto;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.model-option input[type="checkbox"] {
  width: auto;
  flex: none;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.model-options .model-option {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

/* Declared after the grid rule above, which would otherwise win over the filter's [hidden]. */
.model-options .model-option[hidden] {
  display: none !important;
}

.model-option span {
  min-width: 0;
  margin-top: 0;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text);
}

.model-option .eu-toggle {
  flex: none;
  margin-top: 0;
  margin-left: auto;
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: transparent;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
}

.model-option .eu-toggle.on {
  border-color: var(--success-dim);
  color: var(--success);
}

.model-option .model-flags {
  display: flex;
  gap: 4px;
  flex: none;
}

.model-option .eu-toggle {
  white-space: nowrap;
  cursor: pointer;
}

/* A label, not a toggle: the type is changed in the model settings. */
.model-option .model-kind {
  cursor: default;
  color: var(--text);
}

.model-option .params-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
}

.model-option .params-toggle b {
  font-size: 10.5px;
  font-weight: 600;
}

.model-option .params-toggle.on {
  border-color: var(--warn-dim);
  color: var(--warn);
}

.model-option .price-warn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  font-size: 10.5px;
  font-weight: 600;
  border-color: var(--danger-dim);
  color: var(--danger);
}

.params-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px var(--s-4);
  margin: var(--s-3) 0;
}

.params-list .ac-check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
  row-gap: 2px;
}

.params-list .ac-check input {
  width: auto;
  margin: 0;
}

.params-list .ac-check span {
  margin: 0;
  font-size: 12.5px;
  color: var(--text);
}

.params-list small {
  grid-column: 2;
  font-size: 11px;
  line-height: 1.35;
}

.picker-label span {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-dim);
}

/* --- Model groups: members in priority order ------------------------------ */

.group-members,
.group-member-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: member;
}

.group-members {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.group-members li {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  padding: 6px var(--s-3);
  border-bottom: 1px solid var(--border-soft);
}

.group-members li:last-child { border-bottom: 0; }

.group-members li::before,
.group-member-list li::before {
  counter-increment: member;
  content: counter(member);
  flex: none;
  width: 1.4em;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.group-members li.muted::before { content: none; }

.group-member-name,
.group-member-list li {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  min-width: 0;
}

.group-member-name { flex: 1; }

.group-member-name .mono,
.group-member-list .mono {
  font-size: 12px;
  white-space: nowrap;
}

.group-name { white-space: nowrap; }

small.missing { color: var(--warn); }

.group-member-name small,
.group-member-list small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
}

.group-member-list li + li { margin-top: 2px; }

.model-manual select { flex: 1; min-width: 0; }

.conn-name {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

/* --- Optimizations -------------------------------------------------------- */

#opt-form .detector-grid + .form-grid,
#opt-form .form-grid + .detector-grid,
#opt-form .form-grid + .field-hint,
#gw-form .detector-grid + .form-grid {
  margin-top: var(--s-4);
}

/* The Save bar of the gateway settings, as wide as the cards above it. */
#gw-form .gw-foot { padding-block: var(--s-3); }
#gw-form .gw-foot .form-foot { margin-top: 0; }
#header-settings { display: block; margin-top: var(--s-5); }

#task-settings,
#gw-settings,
#db-settings,
#int-runtime:not(:empty) {
  margin-top: var(--s-5);
}

#license-banner:empty { display: none; }

#license-banner .notice {
  margin-bottom: var(--s-5);
}

.license-page { margin-top: var(--s-5); }

.license-details {
  display: grid;
  gap: var(--s-3);
  margin: 0;
}

.license-details > div,
.license-usage-row > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
}

.license-details dt,
.license-usage-row span {
  color: var(--text-muted);
  font-size: 12px;
}

.license-details dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  overflow-wrap: anywhere;
}

.license-usage {
  display: grid;
  gap: var(--s-5);
}

.license-usage-row {
  display: grid;
  gap: var(--s-2);
}

.license-meter {
  height: 7px;
  overflow: hidden;
  border-radius: var(--r-full);
  background: var(--surface-hover);
}

.license-meter i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.opt-actions {
  justify-content: flex-end;
  gap: var(--s-4);
}

/* Blocks stacked inside a card: switches, fields, notices and the actions row. */
.card > .detector-grid + *,
.card > .form-grid + *,
.card > .notice + *,
.card > * + .opt-actions {
  margin-top: var(--s-5);
}

.test-ok {
  color: var(--success);
}

.test-ok:empty {
  display: none;
}

#scan-slot:not(:empty) { margin-top: var(--s-5); }

.opt-actions .error:empty {
  display: none;
}

/* A field whose control is not a form element, styled like a label. */
.opt-field {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--n-10);
  min-width: 0;
}

.opt-field > span {
  display: block;
  font-weight: 400;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 1px;
}

/* --- Searchable model picker ---------------------------------------------- */

.mpick {
  position: relative;
  margin-top: var(--s-2);
  font-weight: 400;
}

.mpick [hidden] {
  display: none !important;
}

.mpick-button {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 9px 32px 9px 11px;
  background-color: var(--bg-sink);
  background-image: linear-gradient(45deg, transparent 50%, var(--n-8) 50%),
    linear-gradient(135deg, var(--n-8) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  text-align: left;
  transition: border-color var(--fast), box-shadow var(--fast);
}

.mpick-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mpick-button.placeholder span {
  color: var(--text-dim);
}

.mpick-button:hover {
  border-color: var(--n-6);
}

.mpick-button:focus-visible,
.mpick-button[aria-expanded="true"] {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.mpick-pop {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  padding: var(--s-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}

.mpick-search {
  margin-top: 0;
}

.mpick-list {
  max-height: 300px;
  overflow: auto;
  margin-top: var(--s-2);
}

.mpick-group + .mpick-group {
  margin-top: var(--s-2);
}

.mpick-group p {
  margin: 0;
  padding: 4px 8px 2px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.mpick-opt {
  display: block;
  width: 100%;
  padding: 6px 8px;
  background: none;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  text-align: left;
  overflow-wrap: anywhere;
}

.mpick-opt:hover,
.mpick-opt:focus-visible {
  outline: none;
  background: var(--surface-raised);
}

.mpick-opt[aria-selected="true"] {
  color: var(--accent);
  font-weight: 550;
}

.mpick-empty {
  margin: 0;
  padding: 8px;
  color: var(--text-dim);
}

/* --- Toasts --------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: var(--s-6);
  bottom: var(--s-6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--s-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text);
  animation: toast-in 180ms var(--ease);
  transition: opacity 280ms var(--ease), transform 280ms var(--ease);
}

.toast::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.toast.error::before { background: var(--danger); }

.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
}

/* Compression that cost more than it saved, once cache effects are priced in. */
.tok-saved.neg {
  background: var(--danger-dim);
  color: var(--danger);
}
.panel-stats .neg,
.saving-total.neg {
  color: var(--danger);
}

/* --- Gateway logs -------------------------------------------------------- */

.logs-intro { margin-bottom: var(--s-3); }

.logs-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}

.logs-toolbar .filter-input { min-width: min(280px, 100%); }

.logs-live {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
}

.logs-list {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.logs-list > .empty { margin: var(--s-5); }

.logs-row {
  border-bottom: 1px solid var(--border-soft);
  border-left: 3px solid transparent;
  cursor: pointer;
  outline: none;
}

.logs-row:last-child { border-bottom: 0; }
.logs-row:hover, .logs-row:focus-visible { background: var(--surface-hover); }
.logs-danger { border-left-color: var(--danger); }
.logs-warning { border-left-color: var(--warn); }

.logs-summary {
  display: grid;
  grid-template-columns: 92px 64px minmax(0, 1fr);
  align-items: start;
  gap: var(--s-3);
  min-width: 0;
  padding: var(--s-2) var(--s-4);
}

.logs-summary .badge { justify-self: start; }
.logs-time { color: var(--text-dim); padding-top: 2px; }
.logs-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.logs-message { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.logs-error {
  margin: 0;
  color: var(--danger);
  font-size: 12.5px;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.logs-warning .logs-error { color: var(--warn); }
.logs-preview {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--s-3);
  color: var(--text-muted);
  font-size: 11.5px;
  max-height: 2.8em;
  overflow: hidden;
}
.logs-preview span { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.logs-preview i { font-style: normal; color: var(--text-dim); }

.logs-attrs {
  display: grid;
  grid-template-columns: minmax(110px, 180px) minmax(0, 1fr);
  margin: 0;
  padding: 0 var(--s-4) var(--s-4);
  border-top: 1px solid var(--border-soft);
}

.logs-attr { display: contents; }
.logs-attr dt, .logs-attr dd { margin: 0; padding: var(--s-2) 0; border-bottom: 1px solid var(--border-soft); }
.logs-attr:last-child dt, .logs-attr:last-child dd { border-bottom: 0; }
.logs-attr dt { padding-right: var(--s-4); color: var(--text-dim); font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; }
.logs-attr dd { min-width: 0; color: var(--text); font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

.logs-value {
  max-height: 240px;
  margin: 0;
  overflow: auto;
  color: inherit;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  .logs-summary { grid-template-columns: 1fr auto; gap: var(--s-2); }
  .logs-time { grid-column: 1; }
  .logs-summary .badge { grid-column: 2; grid-row: 1; }
  .logs-body { grid-column: 1 / -1; }
  .logs-attrs { grid-template-columns: 1fr; }
  .logs-attr dt { padding-bottom: 0; }
  .logs-attr dd { padding-top: var(--s-1); }
}

/* Same horizontal padding as .health-pill so the avatar and username line up
   with the status dot column above. */
.session-user {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  padding: var(--s-2) var(--s-3);
}

.session-user:hover,
.session-user:focus-visible,
.session-user[aria-expanded="true"] {
  background: var(--surface-hover);
}

.session-avatar {
  width: 32px;
  height: 32px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
}

/* Name above, role badges below. */
.session-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.session-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.session-user-roles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

/* Role as plain dim text: a badge chip made the block look crooked. */
.session-user-role {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1;
}

.session-user-chevron {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--text-muted);
  transition: transform var(--fast);
}

.session-user[aria-expanded="true"] .session-user-chevron {
  transform: rotate(180deg);
}
body.viewer [data-write], body.read-only [data-write] { display: none !important; }

/* --- Integrations --------------------------------------------------------- */

/* auto-fill keeps a lone card at one column instead of stretching it. */
.grid.thirds.int-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); grid-auto-rows: 1fr; }
.int-title { display: flex; align-items: center; gap: var(--s-3); }
.int-logo { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.int-grid .int-card { display: flex; flex-direction: column; gap: var(--s-3); height: 100%; min-width: 0; }
.int-desc {
  margin: 0; color: var(--text-muted);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.int-progress { position: relative; height: 4px; border-radius: 2px; overflow: hidden; background: var(--accent-dim); }
.int-progress span { position: absolute; inset: 0 auto 0 0; width: 35%; border-radius: 2px; background: var(--accent); animation: int-progress 1.4s ease-in-out infinite; }
@keyframes int-progress {
  from { transform: translateX(-100%); }
  to   { transform: translateX(290%); }
}
@media (prefers-reduced-motion: reduce) {
  .int-progress span { animation: none; width: 100%; opacity: .5; }
}
.int-runtime { margin-bottom: var(--s-5); }
#int-runtime-notice:not(:empty) { margin-bottom: var(--s-5); }
.int-section { margin: var(--s-5) 0 var(--s-3); }
.int-disabled { opacity: .65; }

.int-advanced summary { cursor: pointer; color: var(--text-muted); margin-bottom: var(--s-2); }
/* Same info mark as the savings rows; the tooltip opens rightwards from a label. */
.int-fp { display: block; margin: var(--s-2) 0; font-family: var(--mono); word-break: break-all; font-size: 12px; }
.int-head { display: flex; align-items: center; gap: var(--s-3); }
.int-head .int-logo { width: 44px; height: 44px; border-radius: 12px; box-shadow: var(--shadow-sm); }
.int-name { flex: 1; min-width: 0; }
.int-name h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.int-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 3px; font-size: 12.5px; color: var(--text-muted); }
.int-meta .badge { font-size: 10.5px; padding: 1px 7px; }
.int-head > .toggle { flex: none; align-self: flex-start; margin-top: 4px; }
.int-foot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-2);
  margin: auto calc(-1 * var(--s-5)) calc(-1 * var(--s-5)); padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border-soft);
}
.int-foot > .muted { flex: 1; }
.int-configure { background: var(--n-4); border-color: var(--border-soft); color: var(--text); }
.int-configure:hover { background: var(--n-5); }
.int-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.int-icon { width: 32px; height: 32px; }
.int-icon .icon { width: 17px; height: 17px; }
.int-icon.danger:hover { color: var(--danger); background: var(--danger-dim); }
.int-icon:disabled { opacity: .4; pointer-events: none; }
.int-off .int-logo { filter: grayscale(1); opacity: .6; }
.int-off .int-desc { opacity: .7; }
.int-runtime-status { margin-top: var(--s-4); display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); }
.int-result { max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: var(--s-2) 0 0; }
.int-instance-head { display: flex; align-items: end; justify-content: space-between; gap: var(--s-3); margin: var(--s-6) 0 var(--s-3); }
.int-instance-head h2, .int-instance-head p { margin: 0; }
.int-instances .sub, #int-instances td > .sub { display: block; margin-top: 2px; }
#int-pipeline td > .sub { display: block; margin-top: 2px; }
#int-pipeline { margin-top: var(--s-6); }
#int-pipeline .card > .notice { margin: var(--s-3) var(--s-4) 0; }
.int-pipeline-advanced { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
.int-pipeline-advanced .detector-row { flex: 1; border: 0; padding: 0; }
.int-outcomes { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-top: var(--s-1); }
.int-form-section { margin-top: var(--s-5); }
.int-form-section > h3 { margin: 0 0 var(--s-3); font-size: 13px; color: var(--text-muted); }
.int-approval-summary { display: grid; gap: var(--s-4); margin-top: var(--s-4); }
.int-approval-item { border-top: 1px solid var(--border); padding-top: var(--s-3); }
.int-approval-item h3 { margin: 0 0 var(--s-2); font-size: 13px; }
.int-approval-item p { margin: var(--s-1) 0; }
.int-approval-list { display: grid; gap: var(--s-1); margin: 0; padding-left: var(--s-4); }
.int-approval-list code { overflow-wrap: anywhere; }
.int-approval-changed { margin: 0; }
.int-approval-changed p { margin: var(--s-1) 0 0; }

/* Users page. */
.usr-agent { max-width: 28rem; overflow-wrap: anywhere; }
.danger-text { color: var(--danger); margin: 0; }
#login-sso { display: grid; gap: 0.5rem; margin-top: 0.75rem; }

/* Plugin menu entries (integrations.js) join the nav's column; sub-entries
   line up with their parent's label. */
.sidebar nav .nav-plugins { display: contents; }
.sidebar nav button.nav-sub { padding-left: calc(var(--s-3) * 2 + 16px); font-size: 12.5px; }
/* A sub-entry with its own icon indents by one step so the icon sits under the parent's label. */
.sidebar nav button.nav-sub.nav-sub-icon { padding-left: calc(var(--s-3) * 2); }
.sidebar nav button.nav-sub-icon .ico { width: 15px; height: 15px; }
.sidebar nav .nav-plugin-group { display: contents; }
.sidebar nav .nav-plugin-children { display: contents; }
.sidebar nav .nav-plugin-children[hidden] { display: none; }
.sidebar nav button.nav-plugin-toggle { justify-content: flex-start; }
.sidebar nav .nav-plugin-toggle > span { flex: 1; min-width: 0; text-align: left; }
.sidebar nav .nav-plugin-chevron { width: 16px; height: 16px; margin-left: auto; transition: transform 120ms var(--ease); }
.sidebar nav .nav-plugin-toggle[aria-expanded="true"] .nav-plugin-chevron { transform: rotate(180deg); }
/* Duplicate instances of one plugin, listed under its warning. */
.int-dups { display: grid; gap: var(--s-2); margin: var(--s-2) 0; }
.int-dup { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.int-dup .sub { display: block; }
#int-pipeline .int-advanced > .card { margin-top: var(--s-2); }

/* Guardrails rule and policy picks under the plugin selector. */
.ac-guard { grid-column: 1 / -1; min-width: 0; margin-bottom: var(--s-2); padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg); }
.ac-default [data-ac-config] { margin-left: auto; }
/* minmax(0, 1fr): a wide table in a panel scrolls inside it, not the dialog. */
.ac-plugin-rows { grid-template-columns: minmax(0, 1fr); }
.ac-guard-unsaved { color: var(--warning, var(--danger)); font-weight: 600; }
.ac-guard-tables { display: grid; gap: var(--s-4); margin: var(--s-3) 0; min-width: 0; }
.ac-guard-tables .ui-rows { overflow-x: auto; }
/* Plugin settings a group changes: one column, a section per setup step. */
.ac-gs-section + .ac-gs-section { margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.ac-gs-title { margin: 0 0 var(--s-2); font-size: 14px; font-weight: 600; }
.ac-gs-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
.ac-gs-fields .field { margin: 0; }
.ac-gs-fields input[type="number"] { max-width: 180px; }
.ac-gs-intro { margin: 0 0 var(--s-3); }
/* A rows cell holding sub-rows (a level's routes): one line each, "from → to". */
.ui-sub { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); }
.ui-sub li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s-2); }
.ui-sub-arrow { color: var(--text-muted); }
/* The editor of a group setting is the panel's content: its label is the heading, its table uses the width. */
.ac-gs-fields .ui-editor > .field-label { font-size: 14px; font-weight: 600; }
.ac-gs-fields .ui-editor .field-hint { margin: 2px 0 var(--s-2); }
.ac-gs-fields .ui-rows { overflow-x: auto; }

/* Roles: the permission matrix, one row per area with its View and Change
   switches. It scrolls inside the dialog, so the title and the buttons stay
   in view; the header row stays put while it scrolls. */
.rol-matrix {
  max-height: min(56vh, 560px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

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

.rol-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface, var(--bg));
}

.rol-matrix td { padding: 7px 14px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
.rol-matrix th { padding: 6px 14px; text-align: left; }
.rol-matrix td strong { font-size: 13px; }
.rol-matrix td small { display: block; font-size: 12px; line-height: 1.35; }
.rol-matrix .rol-switch { width: 84px; text-align: center; }
.rol-matrix input.toggle { vertical-align: middle; }
.rol-matrix input.toggle:disabled:checked { opacity: 0.75; }

.params-section {
  margin: var(--s-4) 0 var(--s-1);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
}

.params-price {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2) var(--s-4);
  margin-top: var(--s-2);
}
.params-price p { grid-column: 1 / -1; margin: 0; font-size: 12.5px; }
.params-price label { display: block; }
.params-price input { width: 100%; margin-top: 4px; }
