/* ==========================================================================
   Keel components: reference CSS for Implentio OS Admin. Version 1.2, 2026-10-29.
   1.2 (look round 3): the 6 px step as a token, still empty states in a dashed frame, cards for tables on a phone,
   tabs as links, the range switch, the health strip, approval row actions, folded cards and Jump/Stop in the AI panel.
   1.1 folds in the components of the look rounds: breadcrumbs, the phone shell, KPI grid, connection-card states,
   step meter, chart axis and tooltips, alert line, horizontal and stacked bars, data bars, motion hosts, empty art,
   tier frames on action cards, the AI tier ladder and thinking row, version dialog, release timeline, sign-in.
   Load tokens.css first. Every value here comes from a token; no raw colors.
   Class names match components.md. The web app may copy this file as is.
   ========================================================================== */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-family: var(--font-sans); font-size: var(--fs-14); line-height: var(--lh-14);
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-size-adjust: 100%;
}
body { margin: 0; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent-fg); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: var(--focus-w) solid var(--focus-ring); outline-offset: var(--focus-offset); }
::selection { background: var(--accent-subtle); color: var(--text); }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.93em; }
.num { font-variant-numeric: tabular-nums; }
/* The hidden attribute always hides, also on components that set display (.btn, .field__error, .tab-panel). */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.icon {
  width: var(--icon-md); height: var(--icon-md); flex: none; vertical-align: -3px;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.icon--sm { width: var(--icon-sm); height: var(--icon-sm); vertical-align: -2px; }
.icon--lg { width: var(--icon-lg); height: var(--icon-lg); }
.icon--spin { animation: k-spin 0.9s linear infinite; }
@keyframes k-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon--spin { animation: none; } }

/* ---------- Type roles ---------- */
.t-page-title { font-size: var(--fs-20); line-height: var(--lh-20); font-weight: var(--fw-semibold); letter-spacing: var(--ls-tight); }
.t-section { font-size: var(--fs-16); line-height: var(--lh-16); font-weight: var(--fw-semibold); }
.t-card-title { font-size: var(--fs-14); line-height: var(--lh-14); font-weight: var(--fw-semibold); }
.t-body { font-size: var(--fs-14); line-height: var(--lh-14); }
.t-dense { font-size: var(--fs-13); line-height: var(--lh-13); }
.t-lede { font-size: var(--fs-14); line-height: var(--lh-14); color: var(--text-muted); max-width: var(--measure); }
.t-label { font-size: var(--fs-12); line-height: var(--lh-12); font-weight: var(--fw-medium); color: var(--text-muted); }
.t-meta { font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-subtle); }
.t-caps { font-size: var(--fs-11); line-height: var(--lh-11); font-weight: var(--fw-semibold); letter-spacing: var(--ls-caps); text-transform: uppercase; }
.t-muted { color: var(--text-muted); }
.t-subtle { color: var(--text-subtle); }

/* ---------- App shell ---------- */
.app {
  display: grid; min-height: 100vh;
  grid-template-columns: var(--nav-w) minmax(0, 1fr) var(--ai-w);
  grid-template-rows: var(--topbar-h) auto 1fr;
  grid-template-areas: "top top top" "banner banner banner" "nav main ai";
}
.app > .topbar { grid-area: top; }
.app > .pause-banner { grid-area: banner; }
.app > .nav { grid-area: nav; }
.app > .main { grid-area: main; }
.app > .ai-panel { grid-area: ai; }
/* A site without the AI panel (the control plane's staff site): the main column takes its place. */
.app--no-ai { grid-template-columns: var(--nav-w) minmax(0, 1fr); grid-template-areas: "top top" "banner banner" "nav main"; }
.main { min-width: 0; padding: var(--space-6) var(--content-pad) var(--space-12); }
.main__inner { max-width: var(--content-max); }
@media (max-width: 1279px) {
  .app { grid-template-columns: var(--nav-w) minmax(0, 1fr); grid-template-areas: "top top" "banner banner" "nav main"; }
  .app > .ai-panel {
    position: fixed; z-index: var(--z-panel); top: var(--topbar-h); right: 0; bottom: 0; width: min(var(--ai-w), 100vw);
    box-shadow: var(--shadow-3); transform: translateX(100%); transition: transform var(--dur-4) var(--ease-standard);
  }
  .app[data-ai="open"] > .ai-panel { transform: none; }
  .app:not([data-ai="open"]) > .ai-panel { box-shadow: none; } /* no shadow bleeding in from the closed drawer */
}
@media (max-width: 1023px) {
  .app { grid-template-columns: var(--nav-w-collapsed) minmax(0, 1fr); }
  .nav .nav-item__label, .nav .nav-group, .nav .count { display: none; }
  .nav .nav-item { justify-content: center; }
}
@media (max-width: 719px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "banner" "main"; }
  .app > .nav { display: none; }
  .app[data-nav="open"] > .nav { display: flex; position: fixed; z-index: var(--z-panel); top: var(--topbar-h); left: 0; bottom: 0; width: var(--nav-w); }
  /* The open drawer has the full menu width: its labels, group names and counts show again (the rail above hides them). */
  .app[data-nav="open"] > .nav .nav-item__label, .app[data-nav="open"] > .nav .nav-group { display: block; }
  .app[data-nav="open"] > .nav .count { display: inline-grid; }
  .app[data-nav="open"] > .nav .nav-item { justify-content: flex-start; }
  .main { padding: var(--space-4); }
}
/* The main column measures itself, so components adapt to the space they get (the AI panel takes 400 px). */
.main__inner { container-type: inline-size; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky); height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4);
  background: var(--surface-1); border-bottom: var(--bw) solid var(--border);
}
.topbar__spacer { flex: 1; }
.product { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: var(--fw-semibold); white-space: nowrap; color: var(--text); text-decoration: none; }
.product__mark {
  width: 22px; height: 22px; border-radius: var(--radius-sm); display: grid; place-items: center;
  background: var(--text); color: var(--bg); font: var(--fw-semibold) 10px/1 var(--font-mono); letter-spacing: 0;
}
.topbar .divider { width: 1px; height: 20px; background: var(--border); }
.user { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: var(--fs-13); }
.topbar { min-width: 0; }
.topbar__tenant { font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text-muted); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* When the bar is short of room, only the tenant name gives way (an ellipsis): the buttons and badges keep their size. */
.topbar > * { flex-shrink: 0; }
.topbar > .topbar__tenant { flex-shrink: 1; }
.product__name, .user__name { white-space: nowrap; }
/* Phone (< 720 px): a compact top bar, a menu button that opens the nav as a drawer, a scrim behind drawers. */
.scrim { display: none; }
@media (max-width: 719px) {
  .topbar { gap: var(--space-2); padding: 0 var(--space-2); }
  /* The tenant name stays (cut with an ellipsis when long): a person always sees where they act. The mode and Mock
     data (.topbar__wide) show at the head of the page menu instead (.nav-env). */
  .topbar .topbar__wide, .topbar .user__name { display: none; }
  .app[data-nav="open"] > .nav .nav-env { display: flex; }
  .app[data-nav="open"] > .nav { background: var(--surface-1); box-shadow: var(--shadow-3); overflow-y: auto; }
  .app[data-nav="open"] > .scrim, .app[data-ai="open"] > .scrim {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: calc(var(--z-panel) - 1); background: var(--overlay);
  }
  .app > .ai-panel { width: 100vw; }
  .pause-banner { flex-wrap: wrap; }
  /* Tables scroll inside their frame instead of squeezing every cell to one word per line. */
  .table-wrap:not(.table-wrap--flat) > .table { min-width: 36rem; }
}
/* A narrow phone (< 390 px): the Admin badge shows only its shield (the word stays for screen readers and in its
   title), so the tenant name keeps room beside Pause all. */
@media (max-width: 389px) {
  .topbar .topbar__role { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ---------- Side nav ---------- */
.nav { display: flex; flex-direction: column; gap: var(--space-half); padding: var(--space-3) var(--space-2); border-right: var(--bw) solid var(--border); background: var(--bg); overflow-y: auto; }
.nav-group { padding: var(--space-4) var(--space-2) var(--space-1); color: var(--text-subtle); }
.nav-group:first-child, .nav-env + .nav-group { padding-top: var(--space-1); }
/* The head of the phone menu: the tenant in full, the mode and Mock data. Hidden at other widths (the top bar has them). */
.nav-env { display: none; flex-direction: column; gap: var(--space-1h); padding: var(--space-1) var(--space-2) var(--space-3); margin-bottom: var(--space-1); border-bottom: var(--bw) solid var(--border); }
.nav-env__tenant { font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
.nav-env__badges { display: flex; flex-wrap: wrap; gap: var(--space-1h); }
.nav-item {
  display: flex; align-items: center; gap: var(--space-2); height: var(--control-h-md); padding: 0 var(--space-2);
  border-radius: var(--radius-md); color: var(--text-muted); text-decoration: none; font-size: var(--fs-13); font-weight: var(--fw-medium);
  transition: background var(--dur-1) var(--ease-standard), color var(--dur-1) var(--ease-standard);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-3); color: var(--text); }
.nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count {
  min-width: 20px; height: 18px; padding: 0 var(--space-1); border-radius: var(--radius-sm); display: inline-grid; place-items: center;
  font-size: var(--fs-11); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums;
  background: var(--neutral-subtle); color: var(--neutral-fg); border: var(--bw) solid var(--neutral-border);
}
.count--warn { background: var(--warn-subtle); color: var(--warn-fg); border-color: var(--warn-border); }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap; padding-bottom: var(--space-4); border-bottom: var(--bw) solid var(--border); }
.page-head__text { display: grid; gap: var(--space-1); min-width: 0; }
.page-head__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.section { margin-top: var(--space-8); }
.section__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
.section__foot { margin-top: var(--space-3); }
.section__note { display: flex; align-items: center; gap: var(--space-1h); margin-bottom: var(--space-2); color: var(--warn-fg); }
/* A note with more than one fact: each fact keeps its icon; only the warning one is amber. */
.section__note--plain { flex-wrap: wrap; gap: var(--space-1) var(--space-4); color: var(--text-muted); }
.section__note--plain > span { display: inline-flex; align-items: center; gap: var(--space-1h); }
.section__note--prose { display: block; }
.section__note-warn { color: var(--warn-fg); }
/* A section that folds away (done setup steps): a chevron that turns, the heading, a meta count. */
.disclosure > summary { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; list-style: none; padding: var(--space-1) 0; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary > .icon { color: var(--text-subtle); transition: transform var(--dur-2) var(--ease-standard); }
.disclosure[open] > summary { margin-bottom: var(--space-3); }
.disclosure[open] > summary > .icon { transform: rotate(90deg); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-half) var(--space-1); margin-bottom: var(--space-1); font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-subtle); }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1h); height: var(--control-h-md); padding: 0 var(--space-3);
  border: var(--bw) solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-1); color: var(--text);
  font: var(--fw-medium) var(--fs-13)/1 var(--font-sans); white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background var(--dur-1) var(--ease-standard), border-color var(--dur-1) var(--ease-standard), color var(--dur-1) var(--ease-standard);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-control); }
.btn:active { background: var(--surface-3); }
.btn--primary { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-solid-hover); border-color: var(--accent-solid-hover); }
.btn--primary:active { background: var(--accent-solid-active); border-color: var(--accent-solid-active); }
.btn--caution { background: var(--caution-solid); border-color: var(--caution-border); color: var(--on-caution); }
.btn--caution:hover { background: var(--caution-solid-hover); border-color: var(--caution-border); }
.btn--caution:active { background: var(--caution-solid); }
.btn--safety { background: transparent; border-color: var(--tier-s-border); color: var(--tier-s-fg); }
.btn--safety:hover { background: var(--tier-s-subtle); border-color: var(--tier-s-solid); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn--sm { height: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-12); }
.btn--lg { height: var(--control-h-lg); padding: 0 var(--space-4); font-size: var(--fs-14); }
.btn--icon { width: var(--control-h-md); padding: 0; }
.btn--icon.btn--sm { width: var(--control-h-sm); }
.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--surface-2); border-color: var(--border-subtle); color: var(--text-disabled); cursor: not-allowed;
}
.btn[aria-busy="true"] { cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
/* Shell toggles (after .btn, so they win): the AI panel toggle only when the panel is a drawer (below 1280 px), the
   page menu button only on a phone (below 720 px). */
.btn.ai-toggle, .btn.nav-toggle { display: none; }
@media (max-width: 1279px) { .btn.ai-toggle { display: inline-flex; } }
@media (max-width: 719px) { .btn.nav-toggle { display: inline-flex; } }

/* ---------- Form fields ---------- */
.field { display: grid; gap: var(--space-1); }
.field__label { font-size: var(--fs-12); line-height: var(--lh-12); font-weight: var(--fw-medium); color: var(--text-muted); }
.field__hint { font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-subtle); }
.field__error { display: flex; gap: var(--space-1); align-items: center; font-size: var(--fs-12); line-height: var(--lh-12); color: var(--bad-fg); min-height: var(--lh-12); }
.input, .textarea, .select {
  width: 100%; height: var(--control-h-md); padding: 0 10px; border: var(--bw) solid var(--border-control); border-radius: var(--radius-md);
  background: var(--field-bg); color: var(--text); font: var(--fw-regular) var(--fs-13)/var(--lh-13) var(--font-sans);
  transition: border-color var(--dur-1) var(--ease-standard);
}
.textarea { height: auto; min-height: 72px; padding: var(--space-1h) 10px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--text-subtle); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { outline: var(--focus-w) solid var(--focus-ring); outline-offset: 0; border-color: var(--focus-ring); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad-solid); }
.input:disabled { background: var(--surface-2); color: var(--text-disabled); border-color: var(--border-subtle); }
.input--mono { font-family: var(--font-mono); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent-solid); width: 16px; height: 16px; margin: 0; }

.switch {
  position: relative; width: 32px; height: 18px; flex: none; padding: 0; border-radius: var(--radius-full); cursor: pointer;
  background: var(--surface-3); border: var(--bw) solid var(--border-control); transition: background var(--dur-2) var(--ease-standard);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: var(--radius-full);
  background: var(--text-muted); transition: transform var(--dur-2) var(--ease-standard), background var(--dur-2) var(--ease-standard);
}
.switch[aria-checked="true"] { background: var(--accent-solid); border-color: var(--accent-solid); }
.switch[aria-checked="true"]::after { transform: translateX(14px); background: var(--on-accent); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }

/* Secure field: a value goes to the key store; nobody sees it again */
.secure-form { border: var(--bw) solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-1); overflow: hidden; }
.secure-form__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--surface-2); border-bottom: var(--bw) solid var(--border); color: var(--text-muted); }
.secure-form__body { display: grid; gap: var(--space-3); padding: var(--space-3); }
.secure-form__foot { padding: var(--space-2) var(--space-3) var(--space-3); color: var(--text-subtle); font-size: var(--fs-12); line-height: var(--lh-12); }
.secret { position: relative; }
.secret .input { padding-left: 30px; font-family: var(--font-mono); }
.secret > .icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); }
.secret-saved { display: flex; align-items: center; gap: var(--space-2); height: var(--control-h-md); padding: 0 10px; border: var(--bw) dashed var(--border-control); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-13); }
.secret-saved__dots { font-family: var(--font-mono); letter-spacing: 0.1em; color: var(--text-subtle); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1); height: 20px; padding: 0 var(--space-1h); border-radius: var(--radius-sm);
  border: var(--bw) solid var(--neutral-border); background: var(--neutral-subtle); color: var(--neutral-fg);
  font-size: var(--fs-12); line-height: 1; font-weight: var(--fw-medium); white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; vertical-align: 0; }
.badge__dot { width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; flex: none; }
.badge--ok { background: var(--ok-subtle); border-color: var(--ok-border); color: var(--ok-fg); }
.badge--warn { background: var(--warn-subtle); border-color: var(--warn-border); color: var(--warn-fg); }
.badge--bad { background: var(--bad-subtle); border-color: var(--bad-border); color: var(--bad-fg); }
.badge--info { background: var(--info-subtle); border-color: var(--info-border); color: var(--info-fg); }
.badge--test { background: transparent; border-style: dashed; border-color: var(--border-control); color: var(--text-muted); }
.badge--plain { background: transparent; border-color: var(--border); color: var(--text-muted); }

.tier-badge {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 var(--space-1h); border-radius: var(--radius-sm); border: var(--bw) solid;
  font-size: var(--fs-11); line-height: 1; font-weight: var(--fw-semibold); letter-spacing: var(--ls-caps); text-transform: uppercase; white-space: nowrap;
}
.tier-badge .icon { width: 12px; height: 12px; vertical-align: 0; stroke-width: 2; }
.tier-badge--t0 { color: var(--tier-0-fg); background: var(--tier-0-subtle); border-color: var(--tier-0-border); }
.tier-badge--t1 { color: var(--tier-1-fg); background: var(--tier-1-subtle); border-color: var(--tier-1-border); }
.tier-badge--t2 { color: var(--tier-2-fg); background: var(--tier-2-subtle); border-color: var(--tier-2-border); }
.tier-badge--t3 { color: var(--tier-3-fg); background: var(--tier-3-subtle); border-color: var(--tier-3-border); }
.tier-badge--ts { color: var(--tier-s-fg); background: var(--tier-s-subtle); border-color: var(--tier-s-border); }

.dot { display: inline-block; width: var(--dot); height: var(--dot); border-radius: var(--radius-full); background: var(--neutral-solid); flex: none; }
.dot--ok { background: var(--ok-solid); } .dot--warn { background: var(--warn-solid); } .dot--bad { background: var(--bad-solid); } .dot--info { background: var(--info-solid); }

/* ---------- Surfaces: card, KPI, list ---------- */
.card { background: var(--surface-1); border: var(--bw) solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); min-width: 0; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
.card__title { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--fw-semibold); min-width: 0; }
.card__body { display: grid; gap: var(--space-2); font-size: var(--fs-13); line-height: var(--lh-13); color: var(--text-muted); }
.card__foot { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.grid { display: grid; gap: var(--space-3); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid--cards { align-items: stretch; }
/* KPI tiles: 3 (or 4) across, 2 when the column is narrow; an odd last tile spans the row, so there is no hole. */
.grid--kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--kpis.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@container (max-width: 700px) { .grid--kpis.grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 520px) {
  .grid--kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

.kpi {
  display: grid; gap: var(--space-1); align-content: start; min-height: var(--kpi-min-h); min-width: 0; background: var(--surface-1); border: var(--bw) solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4); color: inherit; text-decoration: none;
  transition: background var(--dur-1) var(--ease-standard), border-color var(--dur-1) var(--ease-standard);
}
a.kpi:hover { border-color: var(--border-strong); background: var(--surface-2); }
.kpi__label { font-size: var(--fs-12); line-height: var(--lh-12); font-weight: var(--fw-medium); color: var(--text-muted); display: flex; align-items: center; gap: var(--space-1h); min-width: 0; }
.kpi__icon { color: var(--text-subtle); }
.kpi__dot { margin-left: auto; }
.kpi__value { font-size: var(--fs-24); line-height: var(--lh-24); font-weight: var(--fw-semibold); letter-spacing: var(--ls-tight); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi__sub { font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-subtle); min-width: 0; overflow-wrap: anywhere; }
@container (max-width: 520px) { .kpi { padding: var(--space-3); } .kpi__value { font-size: var(--fs-20); line-height: var(--lh-20); } }

.list { display: grid; background: var(--surface-1); border: var(--bw) solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: var(--bw) solid var(--border-subtle); min-width: 0; }
.list-row:first-child { border-top: 0; }
.list-row__icon { color: var(--text-subtle); flex: none; }
.list-row__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.list-row__title { font-weight: var(--fw-semibold); font-size: var(--fs-13); line-height: var(--lh-13); }
.list-row__sub { color: var(--text-muted); font-size: var(--fs-13); line-height: var(--lh-13); }
.list-row__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 719px) { .list-row { flex-wrap: wrap; } .list-row__actions { width: 100%; justify-content: flex-start; } }
/* A row that waits for the person (Home, "Needs you"). */
.list-row--warn { box-shadow: inset var(--bw-tier) 0 0 var(--warn-solid); }
.list-row--warn .list-row__icon { color: var(--warn-fg); }
.list-row--bad { box-shadow: inset var(--bw-tier) 0 0 var(--bad-solid); }
.list-row--bad .list-row__icon { color: var(--bad-fg); }
.card--flush { padding: 0; }
/* Approval row: the tier edge and badge, the title (a count when identical proposals are grouped), who and when,
   the older copies folded. */
.approval { align-items: flex-start; --tier-edge: transparent; box-shadow: inset var(--bw-tier) 0 0 var(--tier-edge); }
.approval--t0 { --tier-edge: var(--tier-0-solid); } .approval--t1 { --tier-edge: var(--tier-1-solid); }
.approval--t2 { --tier-edge: var(--tier-2-solid); } .approval--t3 { --tier-edge: var(--tier-3-solid); } .approval--ts { --tier-edge: var(--tier-s-solid); }
.approval--decided { --tier-edge: transparent; }
.approval--decided .list-row__title { color: var(--text-muted); font-weight: var(--fw-medium); }
.approval__tier { display: grid; justify-items: start; align-content: start; gap: var(--space-1); min-width: 2.75rem; padding-top: 1px; }
.approval__title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.approval__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1h); color: var(--text-muted); font-size: var(--fs-12); line-height: var(--lh-12); }
.approval__meta > span[aria-hidden] { color: var(--text-subtle); }
.approval .list-row__actions { padding-top: 1px; }
.approval__older { margin-top: var(--space-1); }
.approval__older > summary { display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; list-style: none; }
.approval__older > summary::-webkit-details-marker { display: none; }
.approval__older > summary:hover { color: var(--text-muted); }
.approval__older > summary > .icon { transition: transform var(--dur-2) var(--ease-standard); }
.approval__older[open] > summary > .icon { transform: rotate(90deg); }
.approval__older ul { list-style: none; margin: var(--space-2) 0 0; padding: 0 0 0 var(--space-3); border-left: 2px solid var(--border-subtle); display: grid; gap: var(--space-1); }
.approval__older li { display: flex; align-items: center; gap: var(--space-1h); color: var(--text-muted); font-size: var(--fs-12); line-height: var(--lh-12); }
.approval__older li .btn { margin-left: var(--space-1); }
/* Tier 1 rows: Approve, Reject and the card; after a click the buttons give way to the result (a badge, Undo). */
.approval__wait { display: inline-flex; align-items: center; gap: var(--space-1h); max-width: 16rem; }
.approval__result { margin-top: var(--space-1); color: var(--ok-fg); }
.approval__result--bad { color: var(--bad-fg); }
.approval[data-state] .approval__title { color: var(--text-muted); }
.approval[data-state="cancelled"] .approval__result { color: var(--text-muted); }
.approval[data-state] { --tier-edge: transparent; }
/* Approvals (round 2): one list of both kinds, each labeled; the facts of a waiting item (who asked, which account,
   who approves, what approval does); the exact change and a write's record fold out. */
.approval__kind { display: inline-flex; align-items: center; padding: 0 var(--space-1h); border: var(--bw) solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted); font-size: var(--fs-12); font-weight: var(--fw-medium); line-height: 18px; white-space: nowrap; }
.kv.approval__facts { margin: var(--space-2) 0 0; grid-template-columns: minmax(6.5rem, 8rem) minmax(0, 1fr); gap: var(--space-1) var(--space-3); }
.approval__facts dd { overflow-wrap: anywhere; }
.approval__exact, .approval__record { margin-top: var(--space-2); }
.approval__exact > summary, .approval__record > summary { display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; list-style: none; }
.approval__exact > summary::-webkit-details-marker, .approval__record > summary::-webkit-details-marker { display: none; }
.approval__exact > summary > .icon, .approval__record > summary > .icon { transition: transform var(--dur-2) var(--ease-standard); }
.approval__exact[open] > summary > .icon, .approval__record[open] > summary > .icon { transform: rotate(90deg); }
.approval__exact > .diff { margin-top: var(--space-1); }
.approval__label { margin: var(--space-3) 0 var(--space-1); }
.write-card .write-card__args { max-height: 16rem; overflow: auto; margin: 0; }
[data-vendor-payload], [data-write-payload] { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; overflow-x: auto; margin: var(--space-1) 0 0; }
.write-card__actions { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.approval[aria-busy="true"] { cursor: progress; }
/* A list's three states: loading (a spinner line), could not load (Retry), and empty (one line). */
.load-state { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border: var(--bw) solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1); color: var(--text-muted); font-size: var(--fs-13); line-height: var(--lh-13); }
.load-state > span { flex: 1; min-width: 12rem; }
.load-state--error { border-color: var(--bad-border); background: var(--bad-subtle); color: var(--bad-fg); }
.load-state + .load-state, .load-state + .list, .load-state + .section__note { margin-top: var(--space-2); }
.empty-line { display: flex; align-items: center; gap: var(--space-2); margin: 0; padding: var(--space-3) var(--space-4); border: var(--bw) dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--text-muted); font-size: var(--fs-13); line-height: var(--lh-13); }
/* People: a 32 px avatar, the name with "You", the email; role and last seen on the right. */
.person__name { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.person__side { display: grid; justify-items: end; gap: var(--space-1); text-align: right; }
@media (max-width: 719px) { .approval > .list-row__text { flex-basis: 100%; } .approval .list-row__actions { padding-left: 0; } }
@media (max-width: 719px) { .kv.approval__facts { grid-template-columns: minmax(0, 1fr); gap: 0; } .kv.approval__facts dd { margin-bottom: var(--space-1h); } }
@media (max-width: 719px) { .person__side { justify-items: start; text-align: left; width: 100%; padding-left: calc(32px + var(--space-3)); } }

.kv { display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr); gap: var(--space-2) var(--space-4); font-size: var(--fs-13); line-height: var(--lh-13); }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; min-width: 0; color: var(--text); overflow-wrap: anywhere; }

/* ---------- Connection card ---------- */
.conn { display: flex; flex-direction: column; gap: var(--space-3); }
.conn--backfill { border-color: var(--info-border); }
.conn--error { border-color: var(--bad-border); }
.conn__body { flex: 1; min-width: 0; }
.conn__foot { margin-top: auto; }
.conn__head { display: flex; align-items: center; gap: var(--space-3); }
.conn__logo {
  width: 32px; height: 32px; border-radius: var(--radius-md); display: grid; place-items: center; flex: none;
  background: var(--surface-3); color: var(--text); font: var(--fw-semibold) var(--fs-12)/1 var(--font-mono);
}
.conn__name { font-weight: var(--fw-semibold); }
.conn__meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-subtle); }
/* Each state has its own body, not only its badge: a note for error and waiting, a step meter while onboarding. */
.conn__note { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-2) var(--space-3); border: var(--bw) solid; border-radius: var(--radius-md); font-size: var(--fs-13); line-height: var(--lh-13); }
.conn__note > .icon { margin-top: 3px; }
.conn__note--bad { background: var(--bad-subtle); border-color: var(--bad-border); color: var(--bad-fg); }
.conn__note--warn { background: var(--warn-subtle); border-color: var(--warn-border); color: var(--warn-fg); }
.conn__cov-years { display: flex; justify-content: space-between; margin-top: var(--space-1); }
.steps-meter { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; }
.steps-meter__seg { height: 6px; border-radius: var(--radius-full); background: var(--surface-3); }
.steps-meter__seg--done { background: var(--ok-solid); }
.steps-meter__seg--now { background: var(--info-solid); }

/* ---------- Progress ---------- */
.progress { height: 6px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.progress__bar { height: 100%; width: var(--value, 0%); border-radius: var(--radius-full); background: var(--info-solid); transition: width var(--dur-3) var(--ease-linear); }
.progress--ok .progress__bar { background: var(--ok-solid); }
.progress--bad .progress__bar { background: var(--bad-solid); }
.progress--paused .progress__bar { background: repeating-linear-gradient(45deg, var(--warn-solid) 0 4px, transparent 4px 7px); }
.progress--indeterminate .progress__bar { width: 30%; animation: k-slide 1.4s var(--ease-standard) infinite; }
@keyframes k-slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .progress--indeterminate .progress__bar { animation: none; width: 100%; background: repeating-linear-gradient(45deg, var(--info-solid) 0 4px, transparent 4px 8px); } }
.backfill { display: grid; gap: var(--space-2); }
.backfill__head { display: flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: var(--fs-13); line-height: var(--lh-13); }
.backfill__head > .motion { width: 44px; height: 26px; border-radius: var(--radius-md); background: var(--info-subtle); border: var(--bw) solid var(--info-border); }
.backfill-row { display: grid; grid-template-columns: minmax(6.5rem, 9rem) minmax(60px, 1fr) auto; gap: var(--space-3); align-items: center; font-size: var(--fs-13); line-height: var(--lh-13); }
.backfill-row__name { display: inline-flex; align-items: center; gap: var(--space-1h); min-width: 0; }
.backfill-row__name .icon { color: var(--ok-fg); }
.backfill-row__nums { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Coverage grid ---------- */
.coverage { display: grid; grid-template-columns: minmax(7rem, 10rem) repeat(var(--cols, 8), minmax(18px, 1fr)); gap: 3px; align-items: center; font-size: var(--fs-12); line-height: var(--lh-12); }
.coverage-wrap { overflow-x: auto; }
.coverage__year { text-align: center; color: var(--text-muted); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.coverage__y-short { display: none; }
/* A narrow column: short years ('19), so the full years never run into each other. */
@container (max-width: 560px) {
  .coverage { grid-template-columns: minmax(5.5rem, 8rem) repeat(var(--cols, 8), minmax(16px, 1fr)); }
  .coverage__y-full { display: none; }
  .coverage__y-short { display: inline; }
}
.coverage__label { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: var(--space-2); }
.cov { height: 22px; border-radius: var(--radius-xs); }
.cov--full { background: var(--cov-full); }
.cov--partial { background: linear-gradient(to top, var(--cov-full) var(--pct, 50%), var(--cov-empty) var(--pct, 50%)); box-shadow: inset 0 0 0 1px var(--cov-full); }
.cov--missing { background: repeating-linear-gradient(45deg, var(--cov-missing-line) 0 1px, transparent 1px 5px); box-shadow: inset 0 0 0 1px var(--cov-missing-line); }
.cov--excluded { background: var(--cov-excluded); }
.cov--running { background: repeating-linear-gradient(45deg, var(--cov-running) 0 3px, transparent 3px 6px); box-shadow: inset 0 0 0 1px var(--cov-running); }
.cov--none { background: transparent; }
.coverage--strip { grid-template-columns: repeat(var(--cols, 8), minmax(10px, 1fr)); }
.coverage--strip .cov { height: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-muted); margin-top: var(--space-3); }
.legend__item { display: inline-flex; align-items: center; gap: var(--space-1h); }
.legend__item .cov { width: 14px; height: 14px; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface-1); border: var(--bw) solid var(--border); border-radius: var(--radius-lg); overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); line-height: var(--lh-13); }
.table th {
  position: sticky; top: 0; z-index: 1; height: 32px; padding: 0 var(--space-3); text-align: left; white-space: nowrap;
  background: var(--surface-1); border-bottom: var(--bw) solid var(--border); color: var(--text-muted); font-size: var(--fs-12); font-weight: var(--fw-medium);
}
.table td { height: var(--row-h); padding: var(--space-1) var(--space-3); border-bottom: var(--bw) solid var(--border-subtle); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr[aria-selected="true"] td { background: var(--accent-subtle); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .id { font-family: var(--font-mono); font-size: var(--fs-12); white-space: nowrap; }
.table .row-actions { opacity: 0; text-align: right; white-space: nowrap; }
.table tr:hover .row-actions, .table tr:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .table .row-actions { opacity: 1; } }
.th-sort { all: unset; cursor: pointer; display: inline-flex; gap: var(--space-1); align-items: center; }
.th-sort:focus-visible { outline: var(--focus-w) solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-xs); }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-top: var(--bw) solid var(--border); color: var(--text-subtle); font-size: var(--fs-12); }
.filters {
  display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-end; margin-bottom: var(--space-3);
  padding: var(--space-3); border: var(--bw) solid var(--border); border-radius: var(--radius-lg); background: var(--surface-1);
}
.filters .input { width: 16rem; }
.filters .field { min-width: 10rem; }
.table-wrap--flat { margin-top: var(--space-3); border: 0; border-radius: 0; background: transparent; }
.table .nowrap, .nowrap { white-space: nowrap; }
.row-link { width: 1%; text-align: right; }
/* A data bar in a number cell: the value on one scale per table (single series, --data-1). */
.databar { display: inline-block; width: 56px; height: 6px; margin-right: var(--space-2); border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; vertical-align: middle; }
.databar__bar { display: block; height: 100%; width: var(--value, 0%); background: var(--data-1); }
/* Audit table: the sentence, then what it changed on its own mono line; the reason under the confirmer. */
.audit-what { display: grid; gap: 2px; min-width: 0; }
.audit-what__target { font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-muted); overflow-wrap: anywhere; }
/* The ids of a row (the action and what it changed) for the audit trail: words first, the ids in a closed fold. */
.audit-ids { font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-subtle); }
.audit-ids > summary { display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; list-style: none; }
.audit-ids > summary::-webkit-details-marker { display: none; }
.audit-ids > summary:hover { color: var(--text-muted); }
.audit-ids > summary > .icon { transition: transform var(--dur-2) var(--ease-standard); }
.audit-ids[open] > summary > .icon { transform: rotate(90deg); }
.audit-ids code { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: var(--fs-12); overflow-wrap: anywhere; }
/* Home's Recent activity: one row per action; its steps (oldest first) in the same fold, before the ids. */
.audit-steps { display: grid; gap: 2px; margin: 2px 0 0; padding: 0; list-style: none; color: var(--text-muted); }
.audit-steps > li { display: flex; flex-wrap: wrap; gap: 0 var(--space-1h); }
.audit-steps time { color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.audit-reason { display: block; max-width: 16rem; color: var(--text-muted); font-size: var(--fs-12); line-height: var(--lh-12); }
.table--audit td { padding-top: var(--space-1h); padding-bottom: var(--space-1h); }
/* Four columns that fit next to the admin AI panel (a 616 px column at 1280 px): a fixed layout, the time in a fixed
   width, Who and Confirmed by in a share of the table, What takes the rest; every cell wraps, none is cut. */
.table--audit { table-layout: fixed; }
.table--audit th:nth-child(1) { width: 8.5rem; }
.table--audit th:nth-child(2) { width: 21%; }
.table--audit th:nth-child(4) { width: 23%; }
.table--audit th, .table--audit td { padding-right: var(--space-2); padding-left: var(--space-2); }
.table--audit th:first-child, .table--audit td:first-child { padding-left: var(--space-3); }
.table--audit th:last-child, .table--audit td:last-child { padding-right: var(--space-3); }
.table--audit td { vertical-align: top; overflow-wrap: anywhere; }
.table--audit .audit__when { font-variant-numeric: tabular-nums; }
.table--audit .who { white-space: normal; align-items: flex-start; }
.table--audit .who > .ai-mark, .table--audit .who > .avatar { margin-top: 1px; }
/* The tier as a small badge before the words; a second line of words starts under it. */
.audit-what__tier { margin-right: var(--space-1h); }
.audit-what__tier .tier-badge { height: 18px; vertical-align: 1px; }
/* Who confirmed and why, then the button that opens the action's card at the row's end. */
.audit-confirm { display: flex; align-items: flex-start; gap: var(--space-1); }
.audit-confirm__text { flex: 1; min-width: 0; }
.audit-confirm__card { flex: none; margin-top: -3px; }
.version { display: inline-flex; align-items: center; height: 20px; padding: 0 var(--space-1h); border-radius: var(--radius-sm); background: var(--surface-2); border: var(--bw) solid var(--border); color: var(--text-muted); font: var(--fw-medium) var(--fs-12)/1 var(--font-mono); }

/* ---------- Identity ---------- */
.avatar {
  width: 22px; height: 22px; border-radius: var(--radius-full); display: inline-grid; place-items: center; flex: none;
  background: var(--surface-3); color: var(--text-muted); font-size: var(--fs-11); font-weight: var(--fw-semibold);
}
.ai-mark {
  width: 22px; height: 22px; border-radius: var(--radius-sm); display: inline-grid; place-items: center; flex: none;
  background: var(--text); color: var(--bg); font: var(--fw-semibold) 10px/1 var(--font-mono);
}
.ai-mark--sm, .avatar--sm { width: 18px; height: 18px; font-size: 9px; }
.avatar--md { width: 32px; height: 32px; font-size: var(--fs-12); }
/* An agent (a workflow) in the audit's Who column: its bot mark in the avatar's circle. */
.avatar--agent .icon { width: 12px; height: 12px; }
/* Stacked (audit table): the mark, then the name over "for Ada" in two short lines. */
.who--stacked { align-items: flex-start; white-space: normal; }
.who--stacked > .ai-mark, .who--stacked > .avatar { margin-top: 1px; }
.who__text { display: grid; }
.who--stacked .who__for { font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-subtle); }
.who { display: inline-flex; align-items: center; gap: var(--space-1h); white-space: nowrap; }
.who__for { color: var(--text-muted); }

/* ---------- Source chip ---------- */
.source {
  display: inline-flex; align-items: center; gap: var(--space-1); height: 20px; padding: 0 var(--space-1h); border-radius: var(--radius-xs);
  background: var(--surface-2); border: var(--bw) solid var(--border); color: var(--text-muted);
  font: var(--fw-regular) var(--fs-12)/1 var(--font-mono); text-decoration: none; white-space: nowrap;
}
a.source:hover { border-color: var(--border-control); color: var(--text); }
.source .icon { width: 12px; height: 12px; vertical-align: 0; }
.sources { display: flex; flex-wrap: wrap; gap: var(--space-1); }

/* ---------- Diff ---------- */
.diff { background: var(--surface-2); border: var(--bw) solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; font: var(--fw-regular) var(--fs-12)/18px var(--font-mono); }
.diff__head { display: flex; justify-content: space-between; gap: var(--space-2); padding: var(--space-1h) var(--space-2); border-bottom: var(--bw) solid var(--border-subtle); color: var(--text-muted); }
.diff__head > :first-child { min-width: 0; overflow-wrap: anywhere; }
.diff__head > :last-child:not(:first-child) { flex: none; white-space: nowrap; }
.diff__line { display: grid; grid-template-columns: 16px minmax(0, 1fr); padding: 0 var(--space-2); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-muted); }
.diff__line::before { content: " "; color: var(--text-subtle); }
.diff__line--add { background: var(--diff-add-bg); color: var(--diff-add-fg); }
.diff__line--add::before { content: "+"; color: var(--diff-add-mark); }
.diff__line--del { background: var(--diff-del-bg); color: var(--diff-del-fg); }
.diff__line--del::before { content: "\2212"; color: var(--diff-del-mark); }

/* ---------- Action card (admin AI and page actions) ---------- */
.action-card {
  --tier-solid: var(--tier-1-solid); --tier-subtle: var(--tier-1-subtle); --tier-border: var(--border);
  container-type: inline-size;
  background: var(--surface-1); border: var(--bw) solid var(--tier-border); border-left: var(--bw-tier) solid var(--tier-solid);
  border-radius: var(--radius-md); overflow: hidden; font-size: var(--fs-13); line-height: var(--lh-13);
}
/* The frame says the tier too: tier 2 has a full amber frame, done cards a green one. */
.action-card--t1 { --tier-solid: var(--tier-1-solid); --tier-subtle: var(--tier-1-subtle); --tier-border: var(--tier-1-border); }
.action-card--t2 { --tier-solid: var(--tier-2-solid); --tier-subtle: var(--tier-2-subtle); --tier-border: var(--tier-2-solid); }
.action-card--t3 { --tier-solid: var(--tier-3-solid); --tier-subtle: var(--tier-3-subtle); --tier-border: var(--tier-3-border); }
.action-card--ts { --tier-solid: var(--tier-s-solid); --tier-subtle: var(--tier-s-subtle); --tier-border: var(--tier-s-border); }
.action-card[data-state="done"] { --tier-border: var(--ok-border); }
/* Head: tier badge, the rule in words ("Typed word + reason"), the time left. In a narrow card the rule takes its own line. */
.action-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--space-2); min-height: 32px; padding: var(--space-1h) var(--space-3); background: var(--tier-subtle); }
/* The rule wraps (never runs under the timer): at least 12em on the badge's line, else its own line. */
.action-card__rule { flex: 1 1 12em; min-width: 0; color: var(--text-muted); font-size: var(--fs-12); line-height: var(--lh-12); overflow-wrap: anywhere; }
.action-card__head > .t-meta { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
@container (max-width: 340px) { .action-card__rule { order: 3; flex-basis: 100%; } }
.action-card__body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); padding: var(--space-3); } /* never wider than the card (a long approver address, a narrow dialog) */
.action-card__title { font-size: var(--fs-14); line-height: var(--lh-14); font-weight: var(--fw-semibold); }
.action-card__flags { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.action-card__flags .badge { height: auto; min-height: 20px; padding-block: 3px; line-height: var(--lh-12); white-space: normal; overflow-wrap: anywhere; } /* a flag wraps (an approver's address) instead of being cut */
.action-card__impact { display: grid; gap: 2px; color: var(--text-muted); }
.plain-change { display: grid; gap: var(--space-2); }
.plain-change__item { background: var(--surface-2); border: var(--bw) solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-2); }
.plain-change__title { font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.plain-change__notes { display: grid; gap: 2px; margin: var(--space-1) 0 0; padding-left: var(--space-4); color: var(--text-muted); overflow-wrap: anywhere; }
.plain-change__exact > .diff { margin-top: var(--space-1); }
.plain-change__exact > summary { cursor: pointer; width: max-content; color: var(--text-subtle); font-size: var(--fs-12); line-height: var(--lh-12); }
.action-card__impact b { color: var(--text); font-weight: var(--fw-medium); }
.action-card__checks { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); color: var(--text-muted); font-size: var(--fs-12); }
.action-card__checks .ok { color: var(--ok-fg); } .action-card__checks .bad { color: var(--bad-fg); }
.action-card__confirm { display: grid; gap: var(--space-2); padding-top: var(--space-1); }
.action-card--t2 .action-card__confirm { padding: var(--space-3); border: var(--bw) solid var(--tier-2-border); border-radius: var(--radius-md); background: var(--tier-2-subtle); }
.action-card__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.action-card__foot { color: var(--text-subtle); font-size: var(--fs-12); line-height: var(--lh-12); }
.action-card__error { color: var(--bad-fg); font-size: var(--fs-12); min-height: 1em; }
.action-card__error:empty { display: none; }
/* Tier 3: the refusal with a ban icon, and the alternative as a button that wraps. */
.action-card__refusal { display: flex; gap: var(--space-2); align-items: flex-start; color: var(--text-muted); }
.action-card__refusal > .icon { margin-top: 2px; color: var(--tier-3-fg); }
.action-card__alt { height: auto; min-height: var(--control-h-sm); padding-top: 5px; padding-bottom: 5px; white-space: normal; text-align: left; line-height: var(--lh-12); }
.action-card__result { display: flex; gap: var(--space-2); align-items: center; padding: var(--space-2) var(--space-3); border-top: var(--bw) solid var(--border-subtle); }
.action-card__result--ok { color: var(--ok-fg); } .action-card__result--warn { color: var(--warn-fg); }
.action-card__result--bad { color: var(--bad-fg); } .action-card__result--muted { color: var(--text-muted); }
.action-card__result a { color: inherit; }
.action-card__notice { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-2); border-radius: var(--radius-sm); background: var(--warn-subtle); color: var(--warn-fg); border: var(--bw) solid var(--warn-border); }
.action-card[data-state="expired"]:not([data-renewable="true"]) .action-card__body, .action-card[data-state="cancelled"] .action-card__body { opacity: 0.6; }

/* Tier explainer rows (AI permissions page) */
.tiers { display: grid; gap: var(--space-3); }
.tier-row { display: grid; grid-template-columns: 12rem minmax(0, 1fr); align-items: start; gap: var(--space-2); padding: var(--space-4); background: var(--surface-1); border: var(--bw) solid var(--border); border-left: var(--bw-tier) solid var(--neutral-solid); border-radius: var(--radius-lg); }
.tier-row__badge .tier-badge { justify-self: start; }
.tier-row__body p { margin: var(--space-1) 0 0; }
@container (max-width: 560px) { .tier-row { grid-template-columns: minmax(0, 1fr); } }
.tier-row--t0 { border-left-color: var(--tier-0-solid); } .tier-row--t1 { border-left-color: var(--tier-1-solid); }
.tier-row--t2 { border-left-color: var(--tier-2-solid); } .tier-row--t3 { border-left-color: var(--tier-3-solid); }
.tier-row--ts { border-left-color: var(--tier-s-solid); }

/* ---------- Pause-all banner ---------- */
.pause-banner {
  position: sticky; top: var(--topbar-h); z-index: var(--z-banner); min-height: var(--banner-h);
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4);
  background: var(--warn-subtle); color: var(--text); border-bottom: var(--bw) solid var(--warn-border); font-size: var(--fs-13); line-height: var(--lh-13);
}
.pause-banner > .icon { color: var(--warn-fg); }
.pause-banner__text { flex: 1; min-width: 0; }
.pause-banner__text b { color: var(--warn-fg); font-weight: var(--fw-semibold); }

/* ---------- Admin AI panel ---------- */
.ai-panel { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; background: var(--surface-1); border-left: var(--bw) solid var(--border); min-width: 0; }
.ai-panel__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: var(--bw) solid var(--border); min-height: 48px; }
.ai-panel__title { flex: 1; min-width: 0; display: grid; }
.ai-panel__title b { font-size: var(--fs-13); line-height: var(--lh-13); }
.ai-panel__context { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1h) var(--space-3); border-bottom: var(--bw) solid var(--border-subtle); color: var(--text-subtle); font-size: var(--fs-12); }
.ai-panel__scroll { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ai-panel__msgs {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) var(--space-3);
}
/* Away from the end of the conversation: a pill that takes the person back; it says so when newer messages wait. */
.jump-latest { position: absolute; left: 50%; bottom: var(--space-3); transform: translateX(-50%); z-index: 2; border-radius: var(--radius-full); box-shadow: var(--shadow-2); }
.jump-latest[data-fresh] { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--on-accent); }
/* While the admin AI works, Send is Stop: a neutral solid square button. */
.composer__send--stop, .composer__send--stop:hover { background: var(--text); border-color: var(--text); color: var(--bg); }
/* A finished card folded to one line: chevron, tier, title, state. Open, it shows the whole card under the line. */
.card-fold { min-width: 0; border: var(--bw) solid var(--border); border-radius: var(--radius-md); background: var(--surface-1); }
.card-fold > summary > .badge, .card-fold > summary > .tier-badge { flex: none; }
.card-fold > summary { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; padding: var(--space-1) var(--space-2); cursor: pointer; list-style: none; font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-muted); }
.card-fold > summary::-webkit-details-marker { display: none; }
.card-fold > summary:hover { color: var(--text); }
.card-fold__chev { color: var(--text-subtle); transition: transform var(--dur-2) var(--ease-standard); }
.card-fold[open] > summary .card-fold__chev { transform: rotate(90deg); }
.card-fold__title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: var(--fw-medium); }
.card-fold[open] > summary { border-bottom: var(--bw) solid var(--border-subtle); }
.card-fold > .action-card { border: 0; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.ai-panel__chips { display: flex; flex-wrap: wrap; gap: var(--space-1h); padding: var(--space-2) var(--space-3); border-top: var(--bw) solid var(--border-subtle); }
/* A suggestion with a long name (a workflow's title) wraps inside the panel instead of widening the page. */
.ai-panel__chips .chip { max-width: 100%; height: auto; min-height: var(--control-h-sm); padding-block: var(--space-1); line-height: var(--lh-12); white-space: normal; overflow-wrap: anywhere; text-align: left; }
.composer { display: grid; gap: var(--space-2); padding: var(--space-2) var(--space-3) var(--space-3); border-top: var(--bw) solid var(--border); }
.composer__box { display: flex; align-items: flex-end; gap: var(--space-2); border: var(--bw) solid var(--border-control); border-radius: var(--radius-md); background: var(--field-bg); padding: var(--space-1); }
.composer__box:focus-within { outline: var(--focus-w) solid var(--focus-ring); outline-offset: 0; border-color: var(--focus-ring); }
.composer__box textarea { flex: 1; min-height: 24px; max-height: 160px; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); font: var(--fw-regular) var(--fs-13)/var(--lh-13) var(--font-sans); padding: var(--space-1) var(--space-1h); }
.composer__hint { color: var(--text-subtle); font-size: var(--fs-12); line-height: var(--lh-12); }
.composer__limit-error { display: block; color: var(--bad-fg); }

.msg { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-1h); min-width: 0; }
.msg__by { display: flex; align-items: center; gap: var(--space-1h); font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-muted); font-weight: var(--fw-medium); }
.msg__by time { color: var(--text-subtle); font-weight: var(--fw-regular); }
.msg__body { display: grid; gap: var(--space-2); font-size: var(--fs-13); line-height: var(--lh-13); color: var(--text); }
.msg__body p { margin: 0; }
/* The welcome: what each tier needs, as a ladder of tier badges. */
/* The ladder in the AI welcome: open until the person's first message, then a closed fold (on demand). */
.ladder-fold > summary { display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; list-style: none; color: var(--text-muted); font-weight: var(--fw-medium); }
.ladder-fold > summary::-webkit-details-marker { display: none; }
.ladder-fold > summary:hover { color: var(--text); }
.ladder-fold > summary > .icon { transition: transform var(--dur-2) var(--ease-standard); }
.ladder-fold[open] > summary { margin-bottom: var(--space-2); }
.ladder-fold[open] > summary > .icon { transform: rotate(90deg); }
.ladder { display: grid; gap: var(--space-1h); margin: 0; padding: 0; list-style: none; }
.ladder li { display: grid; grid-template-columns: 3.25rem minmax(0, 1fr); gap: var(--space-2); align-items: start; color: var(--text-muted); }
.ladder .tier-badge { justify-self: start; }
.ladder b { color: var(--text); font-weight: var(--fw-medium); }
.msg__time { color: var(--text-subtle); font-weight: var(--fw-regular); font-variant-numeric: tabular-nums; }
.msg__time::before { content: "\00b7"; margin-right: var(--space-1h); }
/* The person's words: a tinted bubble on the right (the accent tint is the user-message tint). The AI's: plain text. */
.msg--me { justify-items: end; }
.msg--me .msg__body { max-width: 88%; padding: var(--space-2) var(--space-3); background: var(--accent-subtle); border: var(--bw) solid var(--accent-border); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-xs) var(--radius-lg); }
.msg--me .msg__body::selection, .msg--me .msg__body ::selection { background: var(--accent-border); }
/* Thinking: the quiet ring round the AI mark breathes (motion "thinking"; still: the ring), the seconds count, and two
   lines pulse where the answer will come. */
.thinking { gap: var(--space-2); color: var(--text-muted); }
.thinking__mark { position: relative; display: inline-grid; place-items: center; width: 22px; height: 22px; margin: var(--space-1h) var(--space-1) var(--space-1h) var(--space-1h); }
.thinking__mark > .motion { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.thinking__ring { width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--info-border); }
/* The AI admin's head mark, as the agreed mock-up has it: the quiet ring with "AI" inside it (React and server shell). */
.thinking__ring--label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; font: var(--fw-semibold) 0.625rem/1 var(--font-mono); color: var(--info-fg); }
.thinking__time { color: var(--text-subtle); font-weight: var(--fw-regular); font-variant-numeric: tabular-nums; }
.thinking__lines { display: grid; gap: var(--space-1h); max-width: 85%; padding-left: 2px; }
.skeleton--short { width: 60%; }
.activity { display: flex; align-items: center; gap: var(--space-1h); color: var(--text-subtle); font-size: var(--fs-12); line-height: var(--lh-12); }
.activity code { color: var(--text-muted); }
.activity--stopped { color: var(--text-muted); }
.quote-data { padding: var(--space-2) var(--space-3); border-left: 2px solid var(--warn-border); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-muted); }
.quote-data__label { display: flex; align-items: center; gap: var(--space-1); margin-bottom: var(--space-1); color: var(--warn-fg); font-size: var(--fs-12); }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-1); height: var(--control-h-sm); padding: 0 10px; border-radius: var(--radius-md);
  background: var(--surface-2); border: var(--bw) solid var(--border); color: var(--text-muted); font: var(--fw-regular) var(--fs-12)/1 var(--font-sans); cursor: pointer; white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--border-control); }
.caret { display: inline-block; width: 7px; height: 14px; background: var(--text-muted); vertical-align: -2px; animation: k-blink 1s steps(2) infinite; }
@keyframes k-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .caret { animation: none; } }

/* ---------- Run timeline ---------- */
.run-steps { list-style: none; margin: 0; padding: 0; display: grid; }
.run-step { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); padding: var(--space-2) 0; }
.run-step::before { content: ""; position: absolute; left: 11px; top: 30px; bottom: -6px; width: 2px; background: var(--border); }
.run-step:last-child::before { display: none; }
.run-step__marker { width: 24px; height: 24px; border-radius: var(--radius-full); display: grid; place-items: center; background: var(--surface-2); border: var(--bw) solid var(--border-strong); color: var(--text-muted); font: var(--fw-medium) var(--fs-11)/1 var(--font-mono); z-index: 1; }
.run-step--ok .run-step__marker { border-color: var(--ok-border); color: var(--ok-fg); background: var(--ok-subtle); }
.run-step--bad .run-step__marker { border-color: var(--bad-solid); color: var(--bad-fg); background: var(--bad-subtle); }
.run-step--running .run-step__marker { border-color: var(--info-solid); color: var(--info-fg); background: var(--info-subtle); }
.run-step--skipped .run-step__marker { border-style: dashed; color: var(--text-subtle); }
.run-step__main { display: grid; gap: 4px; min-width: 0; font-size: var(--fs-13); line-height: var(--lh-13); }
.run-step__tool { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--text-muted); }
.run-step__out { color: var(--text); }
.run-step--bad .run-step__out { color: var(--bad-fg); }
.run-step__side { text-align: right; color: var(--text-subtle); font-size: var(--fs-12); line-height: var(--lh-12); font-variant-numeric: tabular-nums; white-space: nowrap; }
.run-head { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; color: var(--text-muted); font-size: var(--fs-13); }
.well { background: var(--surface-2); border: var(--bw) solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); font: var(--fw-regular) var(--fs-12)/18px var(--font-mono); color: var(--text-muted); white-space: pre-wrap; overflow: auto; max-height: 240px; }

/* ---------- Stepper and checklist (onboarding) ---------- */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
.stepper li { display: inline-flex; align-items: center; gap: var(--space-1h); color: var(--text-subtle); font-size: var(--fs-12); line-height: var(--lh-12); }
.stepper__n { width: 20px; height: 20px; border-radius: var(--radius-full); display: grid; place-items: center; border: var(--bw) solid var(--border-control); font: var(--fw-medium) var(--fs-11)/1 var(--font-mono); }
.stepper li[data-state="done"] { color: var(--text-muted); }
.stepper li[data-state="done"] .stepper__n { background: var(--ok-subtle); border-color: var(--ok-border); color: var(--ok-fg); }
.stepper li[aria-current="step"] { color: var(--text); font-weight: var(--fw-medium); }
.stepper li[aria-current="step"] .stepper__n { border: 2px solid var(--accent-solid); color: var(--accent-fg); }
/* Track: the steps on one line, joined by a line that turns green behind the done steps; labels under the numbers.
   In a narrow column only the numbers show (the step panel names the step). */
.stepper--track { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; }
.stepper--track li { position: relative; display: grid; justify-items: center; align-content: start; gap: var(--space-1h); padding: 0 2px; text-align: center; }
.stepper--track li + li::before { content: ""; position: absolute; top: 11px; left: calc(-50% + 16px); right: calc(50% + 16px); height: 2px; border-radius: 1px; background: var(--border); }
.stepper--track li[data-state="done"] + li::before { background: var(--ok-solid); }
.stepper--track .stepper__n { width: 24px; height: 24px; background: var(--surface-1); }
.stepper--track li[aria-current="step"] .stepper__n { box-shadow: 0 0 0 4px var(--accent-subtle); }
.stepper__n .icon { width: 12px; height: 12px; stroke-width: 2.5; }
@container (max-width: 560px) { .stepper--track .stepper__label { display: none; } }
.onboarding { display: grid; gap: var(--space-5); padding: var(--space-5); }
.step-panel { display: grid; gap: var(--space-4); padding-top: var(--space-5); border-top: var(--bw) solid var(--border-subtle); }
.step-panel__head { display: grid; gap: var(--space-1); }
.step-panel__head p { max-width: var(--measure); }
.check-step[data-state="current"] .check-step__tick { color: var(--accent-fg); }
.check-step { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: var(--space-3); align-items: start; padding: var(--space-3) 0; border-top: var(--bw) solid var(--border-subtle); }
.check-step:first-child { border-top: 0; }
.check-step__tick { width: 20px; height: 20px; border-radius: var(--radius-full); border: 1.5px solid var(--border-control); display: grid; place-items: center; color: transparent; }
.check-step[data-state="done"] .check-step__tick { background: var(--ok-subtle); border-color: var(--ok-solid); color: var(--ok-fg); }
.check-step[data-state="current"] .check-step__tick { border-color: var(--accent-solid); }
.check-step__desc { color: var(--text-muted); font-size: var(--fs-13); line-height: var(--lh-13); }
.check-step__desc code { color: var(--text); background: var(--surface-2); border-radius: var(--radius-xs); padding: 0 4px; }

/* ---------- Tabs, segmented, menu, tooltip ---------- */
.tabs { display: flex; gap: var(--space-4); border-bottom: var(--bw) solid var(--border); margin-bottom: var(--space-4); }
.tab { all: unset; cursor: pointer; padding: var(--space-2) 0; color: var(--text-muted); font-size: var(--fs-13); font-weight: var(--fw-medium); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent-solid); }
.tab:focus-visible { outline: var(--focus-w) solid var(--focus-ring); outline-offset: 2px; }
.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-md); background: var(--surface-2); border: var(--bw) solid var(--border); }
.segmented button { all: unset; cursor: pointer; height: 24px; padding: 0 10px; border-radius: var(--radius-sm); font-size: var(--fs-12); color: var(--text-muted); display: inline-flex; align-items: center; }
.segmented button[aria-pressed="true"] { background: var(--surface-1); color: var(--text); box-shadow: var(--shadow-1); }
/* The same control made of links (a range switch that works without script): the current one has aria-current. */
.segmented a { height: 24px; padding: 0 10px; border-radius: var(--radius-sm); font-size: var(--fs-12); font-weight: var(--fw-medium); color: var(--text-muted); display: inline-flex; align-items: center; text-decoration: none; }
.segmented a:hover { color: var(--text); }
.segmented a[aria-current="page"] { background: var(--surface-1); color: var(--text); box-shadow: var(--shadow-1); }
.section__head > .segmented { align-self: center; }
/* Tabs as links (Data: one tab per source). A count after the name; a source without data shows a dash. */
a.tab { display: inline-flex; align-items: center; gap: var(--space-1h); white-space: nowrap; }
.tabs--scroll { overflow-x: auto; scrollbar-width: none; }
.tabs--scroll::-webkit-scrollbar { display: none; }
.tab__count { display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 var(--space-1h); border-radius: var(--radius-full); background: var(--surface-2); border: var(--bw) solid var(--border-subtle); color: var(--text-muted); font-size: var(--fs-11); font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .tab__count { background: var(--accent-subtle); border-color: var(--accent-border); color: var(--accent-fg); }
.tab__count--none { color: var(--text-subtle); }
.tab-panel__meta { margin-bottom: var(--space-2); }
.menu { min-width: 200px; padding: var(--space-1); background: var(--surface-1); border: var(--bw) solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-2); z-index: var(--z-popover); }
.menu__item { display: flex; align-items: center; gap: var(--space-2); width: 100%; height: var(--control-h-md); padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: var(--fw-regular) var(--fs-13)/1 var(--font-sans); cursor: pointer; text-align: left; }
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-2); outline: 0; }
.menu__sep { height: 1px; margin: var(--space-1) 0; background: var(--border-subtle); }
.tooltip { max-width: 280px; padding: var(--space-1h) var(--space-2); border-radius: var(--radius-sm); background: var(--surface-inverse); color: var(--text-inverse); font-size: var(--fs-12); line-height: var(--lh-12); box-shadow: var(--shadow-2); z-index: var(--z-popover); }

/* ---------- Dialog and toast ---------- */
.dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: var(--bw) solid var(--border); border-radius: var(--radius-xl); background: var(--surface-1); color: var(--text); box-shadow: var(--shadow-3); }
.dialog::backdrop { background: var(--overlay); }
.dialog__head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-4) 0; }
.dialog__body { padding: var(--space-4); display: grid; gap: var(--space-3); }
.dialog__title { display: grid; gap: 2px; min-width: 0; }
.dialog__title > [tabindex="-1"]:focus { outline: none; } /* the title takes the focus on open; it is not a control */
/* Side dialog (a setting's versions): full height at the right edge; it slides in. */
.dialog--side {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(540px, 100vw); max-width: none; height: 100dvh; max-height: none; border-radius: 0; border-width: 0 0 0 var(--bw);
  display: none; flex-direction: column; transform: translateX(100%);
  transition: transform var(--dur-4) var(--ease-standard), overlay var(--dur-4) allow-discrete, display var(--dur-4) allow-discrete;
}
.dialog--side[open] { display: flex; transform: none; }
@starting-style { .dialog--side[open] { transform: translateX(100%); } }
.dialog--side .dialog__head { padding: var(--space-4); border-bottom: var(--bw) solid var(--border); }
.dialog--side .dialog__body { flex: 1; overflow-y: auto; align-content: start; }
/* Timeline: versions and releases, newest first; the current one has a filled green dot. */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline__item { position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); padding-bottom: var(--space-5); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before { content: ""; position: absolute; left: 7px; top: 20px; bottom: 4px; width: 2px; border-radius: 1px; background: var(--border); }
.timeline__item:last-child::before { display: none; }
.timeline__dot { width: 12px; height: 12px; margin: 4px 2px 0; border-radius: var(--radius-full); border: 2px solid var(--border-control); background: var(--surface-1); }
.timeline__item[data-current] .timeline__dot { border-color: var(--ok-solid); background: var(--ok-solid); box-shadow: 0 0 0 3px var(--ok-subtle); }
.timeline__main { display: grid; gap: var(--space-2); min-width: 0; font-size: var(--fs-13); line-height: var(--lh-13); }
.timeline__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); min-height: 20px; }
.timeline__name { font-weight: var(--fw-semibold); }
.timeline__note { color: var(--text-muted); }
.timeline__side { align-self: start; }
.timeline--releases .timeline__main { gap: 2px; }
@container (max-width: 560px) { .timeline__side { grid-column: 2 / -1; } }
.toasts { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: var(--z-toast); display: grid; gap: var(--space-2); }
.toast { display: flex; align-items: center; gap: var(--space-2); min-width: 260px; max-width: 420px; padding: var(--space-2) var(--space-3); background: var(--surface-1); border: var(--bw) solid var(--border-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-2); font-size: var(--fs-13); }
.toast--ok > .icon { color: var(--ok-fg); } .toast--bad > .icon { color: var(--bad-fg); } .toast--warn > .icon { color: var(--warn-fg); }

/* ---------- Empty, loading, error ---------- */
.empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-8) var(--space-4); text-align: center; color: var(--text-muted); }
/* In a section the empty state sits where the content would be: a dashed frame, still, a little less padding. A whole
   page that is empty (no data yet, 404) has no frame. Both are still. */
.empty:not(.empty--page) { padding: var(--space-6) var(--space-4); border: var(--bw) dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-1); }
.empty:not(.empty--page) .empty__tile { width: 40px; height: 40px; border-radius: var(--radius-lg); }
.empty:not(.empty--page) .empty__art { width: 40px; height: 40px; margin-bottom: var(--space-1); }
.empty p { max-width: 46ch; }
.empty .btn { margin-top: var(--space-2); }
/* A framed icon tile. */
.empty__art { position: relative; display: grid; place-items: center; width: var(--empty-tile); height: var(--empty-tile); margin-bottom: var(--space-2); }
.empty__tile { position: relative; display: grid; place-items: center; width: var(--empty-tile); height: var(--empty-tile); border-radius: var(--radius-xl); background: var(--surface-2); border: var(--bw) solid var(--border); color: var(--text-muted); }
.not-found { display: grid; justify-items: center; padding-top: var(--space-6); }
.empty > .icon { width: 24px; height: 24px; color: var(--text-subtle); }
.empty__title { color: var(--text); font-weight: var(--fw-semibold); }
.skeleton { border-radius: var(--radius-xs); background: var(--surface-3); height: 12px; animation: k-pulse 1.6s ease-in-out infinite; }
@keyframes k-pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.alert { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); border: var(--bw) solid var(--border); background: var(--surface-1); font-size: var(--fs-13); line-height: var(--lh-13); }
.alert--bad { border-color: var(--bad-border); background: var(--bad-subtle); } .alert--bad > .icon { color: var(--bad-fg); }
.alert--warn { border-color: var(--warn-border); background: var(--warn-subtle); } .alert--warn > .icon { color: var(--warn-fg); }
.alert--info { border-color: var(--info-border); background: var(--info-subtle); } .alert--info > .icon { color: var(--info-fg); }
.alert--ok { border-color: var(--ok-border); background: var(--ok-subtle); } .alert--ok > .icon { color: var(--ok-fg); }
.alert + .card, .alert + .health { margin-top: var(--space-3); }
/* An alert with one action at its end (the error alert's "Try again"). */
.alert--action { align-items: center; }
.alert--action > span { flex: 1; min-width: 0; }
.alert--action > .btn { flex: none; }

/* ---------- Charts ---------- */
.chart { display: grid; gap: var(--space-2); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding-bottom: 1px; border-bottom: var(--bw) solid var(--chart-axis); background-image: linear-gradient(var(--chart-grid) 1px, transparent 1px); background-size: 100% 25%; }
.bars__bar { flex: 1; min-width: 4px; height: var(--h, 0%); background: var(--data-1); border-radius: 4px 4px 0 0; }
.bars__bar:hover { filter: brightness(1.15); }
.chart__axis { display: flex; justify-content: space-between; color: var(--chart-label); font-size: var(--fs-11); line-height: var(--lh-11); font-variant-numeric: tabular-nums; }
/* A bar chart with a y-axis (round steps), gridlines, date labels, focusable bars with a tooltip, and an alert line. */
.chart--spend { margin: 0; gap: var(--space-3); }
.chart__caption { margin: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1) var(--space-3); }
.chart__plot { display: grid; grid-template-columns: var(--chart-y-w) minmax(0, 1fr); gap: var(--space-2); padding-top: var(--space-2); }
.chart__y { position: relative; height: var(--chart-h); color: var(--chart-label); font-size: var(--fs-11); line-height: 1; font-variant-numeric: tabular-nums; }
.chart__y span { position: absolute; right: 0; transform: translateY(-50%); }
.chart__y span:nth-child(1) { top: 0; } .chart__y span:nth-child(2) { top: 25%; } .chart__y span:nth-child(3) { top: 50%; }
.chart__y span:nth-child(4) { top: 75%; } .chart__y span:nth-child(5) { top: 100%; }
.chart__area { position: relative; min-width: 0; }
.chart--spend .bars { height: var(--chart-h); gap: var(--space-1h); padding-bottom: 0; }
.chart--dense .bars { gap: var(--space-half); }
.chart--dense .bars__bar { min-width: 2px; border-radius: 2px 2px 0 0; }
.chart__total { color: var(--text); font-weight: var(--fw-semibold); }
.chart--spend .bars__bar { position: relative; border-radius: 3px 3px 0 0; opacity: 0.78; outline-offset: 2px; transition: opacity var(--dur-1) var(--ease-standard); }
.chart--spend .bars__bar--now, .chart--spend .bars__bar:hover, .chart--spend .bars__bar:focus-visible { opacity: 1; filter: none; }
.chart--spend .bars__bar::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); padding: 4px var(--space-2); border-radius: var(--radius-sm);
  background: var(--surface-inverse); color: var(--text-inverse); font-size: var(--fs-12); line-height: var(--lh-12); white-space: nowrap; box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none; transition: opacity var(--dur-1) var(--ease-standard); z-index: 3;
}
.chart--spend .bars__bar:nth-child(-n + 3)::after { left: 0; transform: none; }
.chart--spend .bars__bar:nth-last-child(-n + 3)::after { left: auto; right: 0; transform: none; }
.chart--spend { overflow-x: clip; }
.chart--spend .bars__bar:hover::after, .chart--spend .bars__bar:focus-visible::after { opacity: 1; }
/* A bar over the alert keeps its series colour and gets an amber cap (the state is in the tooltip too). */
.chart--spend .bars__bar--over { box-shadow: inset 0 3px 0 var(--warn-solid); }
/* The alert: a dashed amber line across the plot; the caption carries its key (a dashed swatch, the value, the days
   over), so no label ever covers a bar. */
.chart__alert { position: absolute; left: 0; right: 0; bottom: var(--at, 0%); height: 0; border-top: 2px dashed var(--warn-solid); pointer-events: none; z-index: 2; }
.chart__alert-key { display: inline-flex; align-items: center; gap: var(--space-1h); color: var(--warn-fg); font-weight: var(--fw-medium); }
.chart__alert-swatch { display: inline-block; width: 16px; height: 0; border-top: 2px dashed var(--warn-solid); }
.chart__alert-note { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--warn-fg); }
.chart__x { display: flex; justify-content: space-between; padding-left: calc(var(--chart-y-w) + var(--space-2)); color: var(--chart-label); font-size: var(--fs-11); line-height: var(--lh-11); font-variant-numeric: tabular-nums; }
.chart__table summary { display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; }
.chart__table .table { margin-top: var(--space-2); }
/* Horizontal bars: one bar per item on one scale, the value at the end (single series, --data-1, no legend). */
.hbars { display: grid; gap: var(--space-2); }
.hbars__row { display: grid; grid-template-columns: minmax(5rem, 9rem) minmax(0, 1fr) minmax(4.5rem, auto); gap: var(--space-3); align-items: center; font-size: var(--fs-13); line-height: var(--lh-13); }
.hbars__label { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars__track { height: 14px; border-radius: var(--radius-xs); background: var(--surface-2); overflow: hidden; }
.hbars__bar { display: block; height: 100%; width: var(--value, 0%); background: var(--data-1); border-radius: var(--radius-xs); }
.hbars__value { text-align: right; color: var(--text); }
/* A stacked bar (parts of one total) in the fixed series order; "Other" is neutral. A table is its legend. */
.stack { display: flex; gap: 2px; height: 14px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.stack__seg { width: var(--value, 0%); min-width: 3px; }
.series-1 { background: var(--data-1); } .series-2 { background: var(--data-2); } .series-3 { background: var(--data-3); }
.series-4 { background: var(--data-4); } .series-other { background: var(--neutral-solid); }
.swatch { display: inline-block; width: 10px; height: 10px; margin-right: var(--space-2); border-radius: 2px; vertical-align: -1px; }

/* ---------- Motion: small CSS animations of a still ---------- */
/* The still (an icon, a ring or an inline SVG) is the page's own markup; data-motion names the motion that moves it.
   With reduced motion the still stays as it is. Always decorative (aria-hidden), and each state reads without motion. */
.motion { position: relative; display: inline-grid; place-items: center; flex: none; }
.motion--sync { width: 40px; height: 20px; color: var(--info-fg); }
.motion--done { width: 18px; height: 18px; color: var(--ok-fg); }
.motion--thinking { width: 34px; height: 34px; }
.motion--orbit { width: 160px; height: 160px; color: var(--text-subtle); }
@keyframes k-breathe { 50% { border-color: var(--info-solid); box-shadow: 0 0 0 var(--focus-w) var(--info-subtle); } }
@keyframes k-spin-back { to { transform: rotate(-360deg); } }
@keyframes k-pop { from { opacity: 0; transform: scale(0.4); } 60% { opacity: 1; transform: scale(1.15); } }
@media (prefers-reduced-motion: no-preference) {
  .motion[data-motion="thinking"] > .thinking__ring { animation: k-breathe 1.6s var(--ease-standard) infinite; }
  .motion[data-motion="sync"] > .icon { animation: k-spin 1.6s linear infinite; }
  .motion[data-motion="orbit"] > svg { animation: k-spin 24s linear infinite; }
  .motion[data-motion="retry"] > .icon { animation: k-spin-back 1.5s linear infinite; }
  .motion[data-motion="done"] > .icon { animation: k-pop 0.4s var(--ease-standard) both; }
}
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 5px; height: 5px; border-radius: var(--radius-full); background: var(--info-solid); opacity: 0.7; }

/* ---------- Health ---------- */
/* One row per part: name (and a detail when it says more than the state), the state as a badge, the last 24 hours as
   a strip of hourly cells, when it was checked. On a narrow column the strip takes its own line. */
.health-row { display: grid; grid-template-columns: minmax(9rem, 15rem) 6.5rem minmax(0, 1fr) 7rem; gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-4); border-top: var(--bw) solid var(--border-subtle); font-size: var(--fs-13); line-height: var(--lh-13); }
.health-row:first-child { border-top: 0; }
.health-row--head { padding-top: var(--space-2); padding-bottom: var(--space-2); background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.health-row--head + .health-row { border-top-color: var(--border); }
.health-row__part { display: grid; gap: 2px; min-width: 0; }
.health-row__name { font-weight: var(--fw-medium); }
.health-row__detail { color: var(--text-muted); font-size: var(--fs-12); line-height: var(--lh-12); }
.health-row > .badge { justify-self: start; }
.health-row__checked { text-align: right; white-space: nowrap; }
.hstrip { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: var(--space-half); height: 18px; max-width: 26rem; }
.hstrip__h { border-radius: 2px; background: var(--ok-solid); opacity: 0.45; }
.hstrip__h:last-child { opacity: 1; }
.hstrip__h--warn { background: var(--warn-solid); opacity: 1; }
.hstrip__h--bad { background: var(--bad-solid); opacity: 1; }
.hstrip__h--unknown { background: var(--surface-3); opacity: 1; }
@container (max-width: 640px) {
  .health-row { grid-template-columns: minmax(0, 1fr) 5.5rem; grid-template-areas: "part state" "strip checked"; row-gap: var(--space-1h); }
  .health-row--head + .health-row { border-top: 0; }
  .health-row > .health-row__part { grid-area: part; }
  .health-row > .badge { grid-area: state; justify-self: end; }
  .health-row > .hstrip, .health-row > span:empty { grid-area: strip; max-width: none; }
  .health-row > .health-row__checked { grid-area: checked; }
  .health-row--head { display: none; }
}
.problem__part { font-weight: var(--fw-medium); }

/* ---------- Tables as cards on a phone (audit log, recent problems) ---------- */
/* Below 600 px of column, each row is a card: no sideways scroll, the sentence gets the full width. */
@container (max-width: 600px) {
  .table-wrap:not(.table-wrap--flat) > .table--cards { min-width: 0; }
  .table--cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table--cards, .table--cards tbody { display: block; }
  .table--cards tr { display: grid; gap: var(--space-1h) var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); border-bottom: var(--bw) solid var(--border-subtle); }
  .table--cards tbody tr:last-child { border-bottom: 0; }
  .table--cards td, .table--cards tbody tr:last-child td { display: block; height: auto; padding: 0; border: 0; min-width: 0; }
  .table--cards tbody tr:hover td { background: transparent; }
  .table--cards .num { text-align: left; }
  .table--audit.table--cards tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who when" "what what" "confirm confirm"; }
  .table--audit.table--cards td { padding: 0; }
  .table--audit .audit__who { grid-area: who; }
  .table--audit .audit__when { grid-area: when; color: var(--text-subtle); font-size: var(--fs-12); text-align: right; }
  .table--audit .audit__what { grid-area: what; }
  .table--audit .audit__confirm { grid-area: confirm; color: var(--text-muted); font-size: var(--fs-12); line-height: var(--lh-12); }
  .table--audit .audit-confirm { align-items: center; }
  .table--audit .audit-confirm__text::before { content: "Confirmed by: "; color: var(--text-subtle); }
  .table--audit .audit-confirm__card { margin-top: 0; }
  .table--audit .audit-reason { max-width: none; }
  .table--audit .who--stacked .who__text { display: flex; flex-wrap: wrap; gap: 0 var(--space-1h); }
  .table--settings.table--cards tr { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "kind kind link" "key key key" "ver who when"; }
  .table--settings .set__kind { grid-area: kind; color: var(--text-subtle); }
  .table--settings .set__key { grid-area: key; font-weight: var(--fw-medium); overflow-wrap: anywhere; }
  .table--settings .set__ver { grid-area: ver; } .table--settings .set__who { grid-area: who; }
  .table--settings .set__when { grid-area: when; color: var(--text-subtle); font-size: var(--fs-12); }
  .table--settings .set__link { grid-area: link; width: auto; }
  .table--data.table--cards tr { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "name name badge" "rows rows rows" "since sync sync"; }
  .table--data .dt__name { grid-area: name; font-weight: var(--fw-medium); }
  .table--data .dt__badge { grid-area: badge; } .table--data .dt__badge:empty { display: none; }
  .table--data .dt__rows { grid-area: rows; display: flex; align-items: center; }
  .table--data .dt__rows .databar { flex: 1; max-width: 12rem; }
  .table--data .dt__since, .table--data .dt__sync { color: var(--text-muted); font-size: var(--fs-12); }
  .table--data .dt__since { grid-area: since; } .table--data .dt__sync { grid-area: sync; }
  .table--data .dt__since::before, .table--data .dt__sync::before { content: attr(data-label) " "; color: var(--text-subtle); }
  .table--problems.table--cards tr { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "part part state" "what what what" "when lasted lasted"; }
  .table--problems.table--cards td[data-label="Part"] { grid-area: part; }
  .table--problems.table--cards td[data-label="State"] { grid-area: state; }
  .table--problems.table--cards td[data-label="What"] { grid-area: what; }
  .table--problems.table--cards td[data-label="When"], .table--problems.table--cards td[data-label="Lasted"] { color: var(--text-muted); font-size: var(--fs-12); }
  .table--problems.table--cards td[data-label="When"] { grid-area: when; }
  .table--problems.table--cards td[data-label="Lasted"] { grid-area: lasted; }
  .table--problems.table--cards td[data-label="Lasted"]::before { content: "· lasted "; color: var(--text-subtle); }
}
/* The filter bar on a narrow column: every field and the button on its own full-width line. */
@container (max-width: 560px) {
  .filters .field, .filters .input { flex: 1 1 100%; width: 100%; min-width: 0; }
  .filters > .btn { width: 100%; }
}

/* ---------- Release changes (Settings) ---------- */
.release__changes > summary { display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; list-style: none; }
.release__changes > summary::-webkit-details-marker { display: none; }
.release__changes > summary:hover { color: var(--text-muted); }
.release__changes > summary > .icon { transition: transform var(--dur-2) var(--ease-standard); }
.release__changes[open] > summary > .icon { transform: rotate(90deg); }
.release__diffs { display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.row-badge { text-align: right; white-space: nowrap; }
