:root {
  /* === Admin-specific tokens === */

  /* Admin-specific layout */
  --sidebar-width: 260px;
  --header-height: 56px;

  /* === Status-badge category palette === */

  /* Monitoring service/instance/deployment status */
  --badge-bg-mon-status-healthy:  rgba(34, 197, 94, 0.15);
  --badge-fg-mon-status-healthy:  #4ade80;
  --badge-bg-mon-status-degraded: rgba(245, 158, 11, 0.15);
  --badge-fg-mon-status-degraded: #fbbf24;
  --badge-bg-mon-status-down:     rgba(239, 68, 68, 0.15);
  --badge-fg-mon-status-down:     #f87171;
  --badge-bg-mon-status-unknown:  rgba(148, 163, 184, 0.15);
  --badge-fg-mon-status-unknown:  #94a3b8;
  --badge-bg-mon-status-starting: rgba(59, 130, 246, 0.15);
  --badge-fg-mon-status-starting: #60a5fa;
  --badge-bg-mon-status-paused:   rgba(156, 163, 175, 0.15);
  --badge-fg-mon-status-paused:   #9ca3af;
  --badge-bg-mon-status-sleeping: rgba(34, 211, 238, 0.15);
  --badge-fg-mon-status-sleeping: #22d3ee;

  /* Monitoring queue chip (neutral surface tint) */
  --badge-bg-mon-queue: var(--secondary-surface);
  --badge-fg-mon-queue: var(--text-secondary);

  /* Catalog item chips (Enterprise / Agency / Developer) */
  --badge-bg-catalog-item-enterprise: rgba(245, 158, 11, 0.15);
  --badge-fg-catalog-item-enterprise: #fbbf24;
  --badge-bg-catalog-item-agency:     rgba(168, 85, 247, 0.15);
  --badge-fg-catalog-item-agency:     #c084fc;
  --badge-bg-catalog-item-developer:  rgba(59, 130, 246, 0.15);
  --badge-fg-catalog-item-developer:  #60a5fa;
}

/* Universal reset lives in static.minxi.ai/css/reset.css — it
   enumerates HTML elements explicitly rather than using `*` so the
   catalogue components' :host rules win the cascade (Context
   tiebreaker, Cascade Level 5 § 7). Don't redeclare a universal
   `* { margin: 0; padding: 0 }` here. */

body {
  font-family: var(--font-family);
  background: linear-gradient(180deg, var(--background-start), var(--background-end));
  background-attachment: fixed;
  color: var(--text-primary);
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Pre-paint auth-state drive: when `<html data-authed>` is set (by
   the synchronous head script that reads the JWT from localStorage),
   the body widens to sidebar + main from frame 1. No JS-driven
   reveal, no :has() re-evaluation race, no layout shift on load.
   When `data-authed` is absent, body stays single-column and the
   sidebar is `display: none` -- the login dialog occupies the
   viewport via .showModal(). */
html[data-authed] body {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

body > aside {
  grid-row: 1;
  grid-column: 1;
  background: var(--side-nav-bg, transparent);
  border-right: 1px solid var(--border-soft);
  display: none;        /* default: pre-auth, sidebar hidden */
  flex-direction: column;
  overflow-y: auto;
  padding: var(--space-md) 0;
}
html[data-authed] body > aside {
  display: flex;
}

body > aside > header {
  padding: 0 var(--space-md) var(--space-md);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: var(--space-md);
}
body > aside > header > strong {
  display: block;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}
body > aside > header > p {
  margin: var(--space-xs) 0 0;
  font-size: var(--font-size-xs);
  letter-spacing: var(--letter-spacing-caps);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

body > aside > nav {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Sidebar section groups — native <details><summary>. CSS-customised
   to hide the default disclosure triangle in favour of a tinted hover
   surface + chevron rotation on [open]. Items inside each <details>
   are direct <a> siblings — no <ul>, no <li>, no nested <nav> — so
   the structure stays flat: nav > a (Dashboard) / nav > details > a
   (category items). */
body > aside > nav details {
  margin: 0;
  display: flex;
  flex-direction: column;
}
body > aside > nav details > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-xs);
  letter-spacing: var(--letter-spacing-caps);
  text-transform: uppercase;
  color: var(--text-tertiary);
  user-select: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
body > aside > nav details > summary::-webkit-details-marker {
  display: none;
}
body > aside > nav details > summary::after {
  content: "▸";
  margin-left: auto;
  font-size: 0.7em;
  color: var(--text-tertiary);
  transition: transform var(--transition-fast);
}
body > aside > nav details[open] > summary::after {
  transform: rotate(90deg);
}
body > aside > nav details > summary:hover {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

body > aside > footer {
  margin-top: auto;
  padding: var(--space-md);
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Main content — direct body child. Sits in the second grid column
   when authed (sidebar takes col 1), or the only column when not. */
body > main {
  grid-row: 1;
  grid-column: 1;
  padding: var(--space-lg);
  min-width: 0;
  overflow-y: auto;
}
html[data-authed] body > main {
  grid-column: 2;
}

/* Permanent page header — `main > header` is the app shell's title
   area, owning a single <h1> for the LCP element across the whole
   SPA lifetime. Page modules update its textContent via
   lib/page-header.js (setPageHeader) without destroying or replacing
   the <h1>, so LCP stays pinned to the initial first paint.

   Structural selectors only (no `data-page-header-shell` or
   `class="page-header"` — per audit-23 wave G these re-describe what
   the HTML already says). Optional siblings:
     main > header > p  -- subtitle / description
     main > header > *  -- action buttons, status badges, etc., appended
                           after the description by setPageHeader. */
main > header {
  margin: 0 0 1.5rem;
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}
main > header > h1 {
  margin: 0;
  font-size: var(--font-size-xl, 1.5rem);
  line-height: 1.2;
  color: var(--text-primary);
}
main > header > p {
  margin: 0.25rem 0 0;
  flex-basis: 100%;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  /* Clamp to two lines with whole-word truncation. -webkit-line-clamp
     is the cross-browser way to get word-aware truncation (truncating
     at a line break, not mid-character). Falls back to no-clamp on the
     very few engines without `-webkit-box` (none in our supported set
     at time of writing — every Chromium + WebKit + Firefox 68+). */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* The header <p> is meta-only (detail shells' dynamic fact lines). The
   router clears it on every navigation; reclaim its row entirely when
   no page fills it (static route prose lives in the help tip instead). */
main > header > p:empty {
  display: none;
}

/* === Page content section =========================================
 * `main > section` is the persistent page-content target (owned by
 * lib/page-header.js setPageContent). Page modules put their top-
 * level content directly inside — kpi-grids, articles, navs, tables
 * — and every child aligns to the section's left edge (no extra
 * wrapper indenting). */
main > section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* === Dashboard surface ============================================ */

/* Trends article: two minxi-chart children side by side, stacking on
 * narrow viewports. Each chart owns its own <figcaption> header (via
 * the chart's `caption` attribute / shadow DOM), so the article needs
 * no extra heading element. */
.dash-trends {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 0;
}

/* Shortcuts: <nav> with anchor children laid out in a flex row. */
.dash-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.dash-shortcut {
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem;
  border: 1px solid var(--border-medium, rgba(255,255,255,0.08));
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
}
.dash-shortcut:hover,
.dash-shortcut:focus-visible {
  background: var(--surface-raised, rgba(255,255,255,0.04));
}
.dash-shortcut > strong {
  font-size: var(--font-size-sm);
  font-weight: 600;
}
.dash-shortcut > span {
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
}

/* Support dashboard org-search input row. */
.dash-search { display: flex; gap: 0.75rem; }
.dash-search > input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--surface-base, rgba(0,0,0,0.2));
  border: 1px solid var(--border-medium, rgba(255,255,255,0.1));
  color: var(--text-primary);
  font: inherit;
}

/* === Pre-auth <dialog> ============================================
 * Native top-layer rendering, focus trap + ESC handling from the
 * platform. Centered both axes via explicit `inset: 0; margin: auto`
 * for cross-browser robustness. Content pre-rendered in HTML so the
 * dialog opens before any module loads (no flash of the body /
 * loading area behind the modal). */
dialog[data-login] {
  inset: 0;
  margin: auto;
  width: min(440px, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 0;
  background: var(--surface-card, var(--primary-surface));
  border: 1px solid var(--border-medium, var(--border-color));
  color: var(--text-primary);
}
dialog[data-login]::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
}

dialog[data-login] > form {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 3rem 3rem 2rem;
}

/* Brand header — icon + wordmark + subtitle */
dialog[data-login] > form > header {
  text-align: center;
  margin-bottom: 2.5rem;
}
dialog[data-login] > form > header > img {
  display: block;
  margin: 0 auto 1.25rem;
  width: 64px;
  height: 64px;
}
dialog[data-login] > form > header > strong {
  display: block;
  margin: 0 0 0.5rem;
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  color: var(--accent-primary);
  letter-spacing: -0.02em;
}
dialog[data-login] > form > header > p {
  margin: 0;
  font-size: var(--font-size-xs);
  letter-spacing: var(--letter-spacing-caps);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* Body — help text + CTA + error slot */
dialog[data-login] > form > section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
dialog[data-login] > form > section > p {
  margin: 0;
  font-size: var(--font-size-sm);
  line-height: 1.6;
  color: var(--text-secondary);
  text-align: center;
}
dialog[data-login] > form > section > p > strong {
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}

/* CTA — plain styled <a> so it works without any JS upgrade. */
.login-cta {
  display: block;
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: var(--accent-primary);
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-caps);
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.login-cta:hover,
.login-cta:focus-visible {
  background: var(--accent-primary-hover, var(--accent-primary));
  filter: brightness(1.1);
}
.login-cta:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Error slot — hidden when empty (uses :empty selector). */
dialog[data-login] > form > section > output {
  display: none;
}
dialog[data-login] > form > section > output:not(:empty) {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--surface-muted, var(--secondary-surface));
  border-left: 3px solid #f87171;
  font-size: var(--font-size-sm);
  text-align: left;
  color: var(--text-primary);
}

/* Footer — "Internal access only" line. */
dialog[data-login] > form > footer {
  text-align: center;
  font-size: var(--font-size-xs);
  letter-spacing: var(--letter-spacing-caps);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--background-start);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent-primary);
}

.form-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--background-start);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  outline: none;
  cursor: pointer;
  color-scheme: dark;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-group select option {
  background: var(--background-start);
  color: var(--text-primary);
}

.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--background-start);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  outline: none;
  resize: vertical;
  min-height: 4rem;
  color-scheme: dark;
}

.form-group textarea:focus {
  border-color: var(--accent-primary);
}

.required {
  color: var(--accent-primary);
  font-weight: 600;
}

.btn-primary {
  padding: 0.5rem 1.5rem;
  background: var(--accent-gradient);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* .login-error removed — error display is now the <output> element
   inside the pre-auth dialog (see dialog[data-login] > form > section
   > output rules above). */

/* App shell layout */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
  overflow-y: auto;
}

/* Sidebar nav links — every <a> inside the sidebar's <nav>, whether
   it's the top-level Dashboard link or a category item inside a
   <details>. Structure is flat: nav > a (Dashboard), nav > details > a
   (category items). The deeper-nesting selector below adds the indent
   that signals "this link belongs to the group above". */
body > aside > nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  border-left: 3px solid transparent;
}

body > aside > nav a:hover {
  background: var(--secondary-surface);
  color: var(--text-primary);
}

/* Active link — state attribute, not a class. aria-current="page"
   is the platform-native marker the router sets via setAttribute. */
body > aside > nav a[aria-current="page"] {
  color: var(--accent-primary);
  background: var(--secondary-surface);
  border-left-color: var(--accent-primary);
}

body > aside > nav .nav-icon {
  width: 1.25rem;
  text-align: center;
  font-size: var(--font-size-base);
}

/* Top-level Dashboard link — direct child of <nav>, slightly heavier
   to distinguish it from the categorised items below. */
body > aside > nav > a {
  font-weight: var(--font-weight-semibold);
  margin-bottom: 0.25rem;
}

/* Sidebar category groups — built on native <details>+<summary>.
   The disclosure widget, keyboard handling, focus, and `[open]`
   state are all platform-native. CSS only handles appearance.
   Base rules + chevron rotation live under `body > aside > nav` (above);
   these are the per-category-summary refinements. */
body > aside > nav details > summary {
  padding: 0.75rem 1.5rem 0.375rem;
  font-size: 0.6875rem;
  font-weight: var(--font-weight-semibold);
}
body > aside > nav details[open] > summary {
  color: var(--accent-primary);
}
body > aside > nav details[open] > summary::after {
  color: var(--accent-primary);
}
/* Indent category items so the disclosure grouping is visually clear. */
body > aside > nav details > a {
  padding-left: 2rem;
}

/* Sidebar footer */

/* User-info element — the <minxi-identity-chip data-user-info> that
 * navigation.js paints into the sidebar footer (a link to the staff
 * member's own profile once the /me fetch resolves, a plain chip
 * before then). All the visual treatment — avatar, name, secondary,
 * hover affordance — lives in the component's shadow DOM. Only the
 * footer-level spacing + reserved geometry (so the async profile
 * paint doesn't shift layout) stays here. */
[data-user-info] {
  margin-bottom: 0.75rem;
  min-height: 44px;
}

/* ------------------------------------------------------------------
 * Read-only mode (lib/permissions.js)
 * ------------------------------------------------------------------
 * Applied to main when the active route is readable but not
 * writable for the current scope set. Visual cues help staff
 * understand why controls aren't responsive — without this, a
 * disabled button looks like a frontend bug.
 * ------------------------------------------------------------------ */
main.read-only {
  position: relative;
}
main.read-only::before {
  content: "Read-only — your scope set doesn't grant write access here";
  position: sticky;
  top: 0;
  z-index: 5;
  display: block;
  background: rgba(251, 191, 36, 0.08);
  border-bottom: 1px solid rgba(251, 191, 36, 0.25);
  color: var(--color-warning, #fbbf24);
  font-size: 0.75rem;
  font-weight: var(--font-weight-medium, 500);
  letter-spacing: 0.02em;
  padding: 0.4rem 1rem;
  text-align: center;
}
main.read-only [data-perm-disabled="1"] {
  opacity: 0.55;
  filter: saturate(0.7);
  cursor: not-allowed !important;
}
[data-perm-hidden="1"] {
  display: none !important;
}

/* The "Min" assistant trigger + slide-out panel styles moved to the
   shared catalogue component <minxi-assistant-panel> (Shadow-DOM-
   encapsulated at static.minxi.ai/js/components/minxi-assistant-panel.js).
   main.js configures the Min persona + copy + backend; nothing to
   style here. */

main.read-only button[data-perm-disabled="1"]:hover,
main.read-only input[data-perm-disabled="1"]:hover,
main.read-only select[data-perm-disabled="1"]:hover,
main.read-only textarea[data-perm-disabled="1"]:hover {
  /* no hover effect on disabled controls */
  filter: saturate(0.7);
}

/* === Sidebar footer rows =========================================
 * Workspace link (a[data-workspace-trigger]) and Sign Out
 * (button[data-logout]) -- a coherent vertical stack styled via
 * structural selectors. No bespoke .workspace-icon-trigger /
 * .btn-logout classes. The Docs trigger is the <minxi-docs>
 * catalogue element's ::part(trigger), styled identically inside
 * the component shadow DOM so the three rows read as one stack.
 * Brutalist: rectangular, thin border, tonal hover via design
 * tokens. */
body > aside > footer > a,
body > aside > footer > button {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-soft);
  border-radius: 0;
  font-family: inherit;
  font-size: var(--font-size-xs);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition-fast),
              border-color var(--transition-fast),
              background var(--transition-fast);
}
body > aside > footer > a:hover,
body > aside > footer > button:hover {
  color: var(--text-primary);
  border-color: var(--border-medium);
  background: var(--surface-hover);
}
body > aside > footer > a:focus-visible,
body > aside > footer > button:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Leftmost span: glyph (?, ↗, etc). Same column width across rows
 * so the labels align vertically. */
body > aside > footer > a > span:first-child,
body > aside > footer > button > span:first-child {
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
  color: var(--accent-primary);
  font-weight: var(--font-weight-semibold);
}

/* Middle span: label. Takes the remaining width so a trailing
 * span (keyboard-hint chip) sits flush right. */
body > aside > footer > a > span:nth-child(2),
body > aside > footer > button > span:nth-child(2) {
  flex: 1;
  font-weight: var(--font-weight-medium);
}

/* Trailing span: keyboard-hint chip (only the Docs button uses
 * this slot today). Monospace + thin border. */
body > aside > footer > a > span:nth-child(3),
body > aside > footer > button > span:nth-child(3) {
  flex-shrink: 0;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border-soft);
  color: var(--text-tertiary);
}

/* Sign Out -- destructive hover treatment. */
body > aside > footer > button[data-logout]:hover {
  color: var(--accent-danger, #f87171);
  border-color: var(--accent-danger, #f87171);
}

/* Main content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem;
  height: 100vh;
  overflow-y: auto;
}

/* Page header */
.page-header {
  margin-bottom: 2rem;
}

.page-header h2 {
  margin: 0 0 0.25rem;
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

/* Dashboard cards */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--primary-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  border-color: rgba(255, 192, 203, 0.4);
  /* shadow removed per minxi brutalist design (2026-05-19) */
}

.card-title {
  font-size: 0.8125rem;
  /* Explicit normal weight: heading elements (h2+) default to bold,
     so .card-title needs to opt out — the visual is a small label,
     not a bold heading. The class is element-agnostic by design so
     pages can use <h2 class="card-title"> for proper sectioning
     semantics without the visual changing. */
  font-weight: var(--font-weight-normal, 400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 0 0 0.75rem;
}

.card-value {
  font-size: 2rem;
  font-weight: var(--font-weight-bold);
  margin: 0;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0;
}

/* Status indicators */
.status-healthy {
  color: var(--color-success);
}

.status-warning {
  color: var(--color-warning);
}

.status-error {
  color: var(--color-danger);
}

.status-error-pulse {
  color: var(--color-danger);
  animation: pulse-danger 2s ease-in-out infinite;
}

@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-info {
  color: var(--color-info, #60a5fa);
}

/* Data table */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
}

.filter-select {
  padding: 0.5rem 0.75rem;
  background: var(--primary-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
  cursor: pointer;
  color-scheme: dark;
}

.filter-select option {
  background: var(--background-start);
  color: var(--text-primary);
}

.filter-select:focus {
  border-color: var(--accent-primary);
}

.search-group {
  flex: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--primary-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-primary);
}

/* Card header row */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.card-header-row .card-title {
  margin-bottom: 0;
}

/* =====================================================================
 * Utility classes (audit-2026-05-26 inline-style sweep).
 *
 * Five classes that retire the highest-frequency inline-style residue
 * across the page modules — after replacing every available pattern
 * with catalogue components first. Hits were 80+ instances of
 * monospace cells, 50+ right-aligned numeric cells, 31+ error-coloured
 * text, recurring vertical stacks + code-block textareas.
 * ===================================================================== */

/* Vertical stack — replaces inline `display:flex;flex-direction:column;gap:1rem`. */
.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.stack-tight { display: flex; flex-direction: column; gap: 0.5rem; }

/* Inline monospace cell — replaces inline `font-family:var(--font-mono);font-size:var(--font-size-xs|sm)`. */
.cell-mono   { font-family: var(--font-mono); font-size: var(--font-size-sm); }
.cell-mono-xs { font-family: var(--font-mono); font-size: var(--font-size-xs); }

/* Right-aligned numeric block — replaces inline `display:block;text-align:right;font-family:var(--font-mono);font-size:var(--font-size-sm)`. */
.cell-num {
  display: block;
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
}

/* Error / danger text colour — replaces inline `color:#f87171`. */
.text-danger { color: var(--color-danger, #f87171); }

/* Secondary / tertiary text colour utilities — replace 134+ inline
   `color:var(--text-tertiary)` + 53+ inline `color:var(--text-secondary)` hits. */
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--accent-primary); }

/* Text-size + text-alignment utilities — replace 60+ inline
   `font-size:var(--font-size-xs|sm)` and 45+ inline `text-align:right` hits.
   Composable with the colour utilities above:
     class="text-xs text-tertiary" ≡ inline `font-size:xs; color:tertiary`. */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-right { text-align: right; }

/* Margin utilities — replace recurring inline `margin-bottom:1rem` /
   `margin-top:1rem` / `margin-bottom:1.5rem` etc. Step values match the
   --space-* tokens so swapping is mechanical. Composable with other
   utilities. Use sparingly — prefer wrapping siblings in `.stack`. */
.mb-0    { margin-bottom: 0; }
.mb-half { margin-bottom: 0.5rem; }
.mb-1    { margin-bottom: 1rem; }
.mb-1-5  { margin-bottom: 1.5rem; }
.mt-half { margin-top: 0.5rem; }
.mt-1    { margin-top: 1rem; }
.mt-1-5  { margin-top: 1.5rem; }

/* Horizontal scroll containers — replaces inline `overflow-x:auto` on
   table wrappers and code blocks too wide to fit. */
.overflow-x-auto { overflow-x: auto; }

/* Horizontal cluster — replaces inline `display:flex;align-items:center;gap:N`.
   Three gap sizes for tight / default / loose presentations. */
.cluster        { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.cluster-tight  { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.cluster-loose  { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* Right-aligned actions row — replaces inline
   `display:flex;justify-content:flex-end;gap:0.5rem` (footer button rows). */
.actions-row    { display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }

/* Flex-grow utility — `<div class="flex-1">` for elements that should
   absorb remaining horizontal space inside a flex container. */
.flex-1 { flex: 1; min-width: 0; }

/* Visibility / text-flow utilities. */
.hidden { display: none; }
.nowrap { white-space: nowrap; }

/* Success text colour — replaces inline `color:var(--color-success)`. */
.text-success { color: var(--color-success, #10b981); }

/* Font-weight utilities — replaces inline `font-weight:var(--font-weight-medium)`. */
.fw-medium     { font-weight: var(--font-weight-medium, 500); }
.fw-semibold   { font-weight: var(--font-weight-semibold, 600); }
.fw-bold       { font-weight: var(--font-weight-bold, 700); }

/* Monospace ID display — replaces the recurring "small grey monospace
   identifier" pattern (35+ inline hits combining font-mono + xs + tertiary). */
.cell-id {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

/* Pre-formatted code / JSON dump — replaces the wide-textarea-as-JSON-viewer pattern. */
.code-block {
  display: block;
  max-height: 24rem;
  overflow: auto;
  margin: 0;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  color: inherit;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs, 0.75rem);
  white-space: pre;
}

/* =====================================================================
   Semantic element-type classes (the "lego blocks" of the admin UI)
   ---------------------------------------------------------------------
   Each class names a recurring UI ELEMENT TYPE — not a primitive
   styling rule. The goal: when you want to paint a "callout" reach
   for `.callout`, not a chain of `.p-1 .text-sm .border .rounded`
   atomics. Composition of atomics is just inline styling with extra
   syntax; these element-classes are the real reusable vocabulary
   of the admin UI.
   ===================================================================== */

/* Callout / info box — bordered, padded note block. Variants tint
   for intent. Used wherever the page needs to highlight a status
   note, prerequisite, or annotation that isn't strong enough to be
   its own <minxi-card>. */
.callout {
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  line-height: 1.55;
}
.callout-info    { background: rgba(99, 102, 241, 0.06); border-color: rgba(99, 102, 241, 0.2); }
.callout-warning { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.25); }
.callout-danger  { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.25); }
.callout-success { background: rgba(34, 197, 94, 0.08); border-color: rgba(34, 197, 94, 0.25); }

/* Icon-row — bordered list-item with a small icon column + content.
   Used for suggestion lists, capability surfaces, and similar "row
   of named things" views. */
.icon-row {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
}

/* Form-row — a horizontally arranged group of form controls that
   wraps. Default for filter strips at the top of list pages and
   inline edit toolbars. Children typically `.form-field-1x` /
   `.form-field-2x` for sizing. */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

/* Meta strip — an inline row of small secondary metadata
   (e.g. "Updated 2h ago · by alice@minxi.ai"). Used in card
   subtitles, list-row trailing metadata, audit-log row footers. */
.meta {
  display: flex;
  gap: 1rem;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  flex-wrap: wrap;
}

/* Chart frame — fixed-height positioned wrapper for an inline
   <canvas>. 200px matches the standard KPI-chart visual weight. */
.chart-frame {
  height: 200px;
  position: relative;
}

/* Dialog action footer — button row at the bottom of a
   <minxi-dialog> body. */
.dialog-actions {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Progress track — hairline-bar container behind a fill child. The
   fill element sets its own width%. */
.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

/* Soft inset panel — for sub-card emphasis blocks (e.g. the audit-
   log row-detail panel). */
.panel-soft {
  padding: 1rem;
  background: rgba(15, 23, 42, 0.4);
  border-radius: var(--radius-md, 6px);
}

/* Overline / caption label — small uppercase letter-spaced heading
   used above grouped content and as KPI labels. */
.overline {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

/* Loading pulse dot — small animated indicator next to "in progress"
   / "live" labels. */
.dot-pulse {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: pulse 1.5s infinite;
}

/* Form-field flex sizing — for fields living inside a `.form-row`.
   1x is the standard width for short single-value inputs (text,
   select); 2x for longer text fields. */
.form-field-1x { flex: 1; min-width: 140px; margin: 0; }
.form-field-2x { flex: 2; min-width: 200px; margin: 0; }

/* Inline-form action button — THE convention for a minxi-button that
   shares a .form-row line with labeled inputs (e.g. an "Add" submit at
   the end of an inline create form):

     <minxi-form-field label="&#8203;" class="form-row-action">
       <minxi-button …></minxi-button>
     </minxi-form-field>

   The zero-width-space-labelled form-field wrapper gives the button the
   SAME chrome as its sibling fields (label line above, reserved help
   line below → correct vertical position), and the shared
   --form-control-h token below gives every control on the line the
   SAME height (.form-input is padding-driven to ~this height; the
   button reads it via minxi-button's --button-height hook). Like the
   .form-field-1x/-2x siblings, the wrapper zeroes minxi-form-field's
   host margin-bottom — the row's gap owns spacing inside rows; the
   component keeps its margin everywhere else. Never hand-tune button
   padding to chase input height — set both from the token. */
.form-row { --form-control-h: 2.75rem; }
.form-row .form-input:not(textarea) {
  height: var(--form-control-h);
  box-sizing: border-box;
}
.form-row .form-row-action { flex: 0 0 auto; margin: 0; }
.form-row .form-row-action minxi-button { --button-height: var(--form-control-h); }

/* Card-section — a padded content block inside a <minxi-card> body
   when the card hosts multiple distinct sections. The 1.25rem
   padding matches the catalogue card's default content padding. */
.card-section { padding: 1.25rem; }

/* Divided row — a horizontal-padded list item that ends in a hairline
   border, used for stacked list rows inside a card. Compose with
   `.row-between` (or equivalent inline layout) when the row has a
   left-content + right-action shape. */
.divided-row {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

/* Section header row — title on the left, action(s) on the right,
   with the standard 0.75rem bottom margin before the section body. */
.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

/* Card subtitle — the small secondary line of text that sits directly
   under a card title (or any heading) to introduce the content. */
.card-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0 0 0.75rem;
}

/* Field label — the small caption that sits above a form input,
   labelling what the input is for. Already provided as <minxi-form-field>'s
   default label slot — this class is for ad-hoc labels in places
   where the form-field component isn't structurally appropriate. */
.field-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

/* Hint — the small caption that sits BELOW a form input, explaining
   constraints or accepted values. Tertiary colour, smallest size. */
.hint {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  margin-top: 0.25rem;
}

/* Icon-row clickable variant — same as .icon-row but cursors as
   pointer and aligns items to top (for entries with multi-line
   content). */
.icon-row-clickable {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  cursor: pointer;
}

/* Design-system primitive completions surfaced by the per-page audit
   (wave B): symmetric additions to the existing colour / margin /
   alignment / weight scales — NOT new atomic utilities, just filling
   the obvious gaps in the existing scales the design system already
   established (.text-secondary/.tertiary/.danger/.success but no
   .text-primary; .mt-half/.mt-1/.mt-1-5 but no .mt-0; .text-right
   but no .text-center; .fw-medium/.semibold/.bold but no .fw-normal). */
.text-primary  { color: var(--text-primary); }
.text-center   { text-align: center; }
.mt-0          { margin-top: 0; }
.fw-normal     { font-weight: 400; }

/* Inline code chip — replaces the recurring inline
   `<code style="background:rgba(255,255,255,0.06);padding:0.1rem 0.4rem;
   border-radius:0.25rem;font-size:var(--font-size-xs)">` used for
   {{template_variables}}, effort values, model ids, and other code
   tokens that live inside prose. */
.code-inline {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.45rem;
  border-radius: 0.25rem;
  font-family: var(--font-mono, monospace);
  font-size: var(--font-size-xs);
}

/* Radio / checkbox row — clickable picker label with leading control
   and content. The `.radio-card` variant adds border + padding for
   the "picker card" presentation (one card per option). */
.radio-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  cursor: pointer;
}
.radio-card {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  cursor: pointer;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

/* Cross-cutting additions surfaced by wave-C per-file audit ---------- */

/* Vertical margin scale completion — symmetric to .mb-* / .mt-* sets
   that the design system already established. Several agents (and
   prior pages) referenced .my-half / .my-1 expecting them to exist;
   formalising here. */
.my-half { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.my-1    { margin-top: 1rem;   margin-bottom: 1rem; }

/* Row with title-on-left + action-on-right, no surrounding spacing —
   the catalogue already has .actions-row (footer right-align) and
   .cluster (center-align flexible group); .row-between covers the
   recurring "two pieces, push them apart" shape that uses justify-
   content:space-between. */
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* Listing row — the stacked vertical-list row pattern that lives
   inside a `padding=none` <minxi-card>: horizontal padding + a
   hairline bottom border. Compose with .row-between when the row
   has a left-content + right-action shape (replaces 3 sites in
   operations/moderation alone; pattern recurs across audit logs,
   decision feeds, activity timelines). */
.listing-row {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-color);
}
.listing-row:last-child { border-bottom: none; }

/* Key/value detail-row grid — recurring across staff profile,
   API-key detail, custom-domain detail, etc. Fixed-width label
   column + flexible value column. */
.kv-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem 1rem;
}

/* Markdown body — wrapper for the local renderMarkdown() output.
   Element-scoped descendant selectors so the inline-styled headings
   / lists / tables / paragraphs that helper emits stop being inline.
   Referenced (but missing) on several analytics surfaces. */
.markdown-body h2     { margin: 1.25rem 0 0.5rem; font-size: 1.05rem; }
.markdown-body h3     { margin: 1rem 0 0.5rem;    font-size: var(--font-size-base, 1rem); }
.markdown-body h4     { margin: 0.75rem 0 0.5rem; font-size: var(--font-size-sm); }
.markdown-body hr     { border: 0; border-top: 1px solid var(--border-color); margin: 1rem 0; }
.markdown-body ul,
.markdown-body ol     { margin: 0.5rem 0; padding-left: 1.25rem; }
.markdown-body li     { margin: 0.2rem 0; }
.markdown-body p      { margin: 0.5rem 0; line-height: 1.55; }
.markdown-body table  { width: 100%; border-collapse: collapse; margin: 0.75rem 0; }
.markdown-body th,
.markdown-body td     { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border-color); text-align: left; vertical-align: top; }
.markdown-body code   { background: rgba(255, 255, 255, 0.06); padding: 0.1rem 0.4rem; border-radius: 0.25rem; font-family: var(--font-mono, monospace); font-size: var(--font-size-xs); }
.markdown-body pre    { background: rgba(0, 0, 0, 0.4); padding: 0.5rem; border-radius: 4px; font-family: var(--font-mono); font-size: var(--font-size-xs); overflow: auto; white-space: pre; }

/* Cross-cutting additions surfaced by wave-D / wave-E per-file audit -- */

/* Field-grid — auto-fit responsive grid for detail-shell field clusters
   (NOT KPI/stat tiles, which use <minxi-kpi-grid>). 220px minimum cell
   width covers most label/value cases; .field-grid-wide expands to
   280px for longer-value fields. Replaces the recurring inline
   `display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
   gap:1rem` pattern across support/domains, ap2/mandates, finance/
   compliance/overview, etc. */
.field-grid       { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }

/* Compare-pair — explicit 2-column equal-width grid, distinct from
   .kv-grid (which is 140px label + flex value) and .field-grid (which
   is auto-fit responsive). Used wherever two sibling panels sit
   side-by-side with no priority between them. */
.compare-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Word-break atomic — recurring on UUID / opaque-id readouts where
   the value can overflow narrow containers. Distinct from .nowrap
   (which suppresses wrapping); .break-all allows wrapping at any
   character. */
.break-all  { word-break: break-all; }
.break-word { word-break: break-word; }

/* Italic — small atomic to round out the typography scale alongside
   .fw-normal / .fw-medium / .fw-semibold / .fw-bold. */
.fst-italic { font-style: italic; }

/* Section heading — `<h3>` that introduces a sub-section within a
   page (sized between the card-title and body text). Replaces the
   recurring inline `margin:1.5rem 0 0.5rem;font-size:1.05rem`
   pattern in analytics/marketplace, analytics/socials, analytics/
   catalog, prompts, and similar. */
.section-heading {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
}
/* The section sub-description (sectionHeading helper's <p>) — breathing
   room before the metric grid / content block that follows it. */
.section-heading + p {
  margin: 0 0 0.75rem;
}

/* Buttons */
.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-family);
  transition: all var(--transition-fast);
}

.btn-small:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.btn-action {
  background: transparent;
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.btn-action:hover {
  background: var(--accent-primary);
  color: var(--text-on-accent);
}

/* AI Suggest inline status */
.suggest-status {
  margin-left: 0.75rem;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  transition: opacity 0.15s ease, color 0.3s ease;
  opacity: 1;
}

.suggest-status.suggest-fade-out {
  opacity: 0;
}

.suggest-status.suggest-ok {
  color: var(--accent-primary, #34d399);
}

.suggest-status.suggest-warn {
  color: var(--warning, #fbbf24);
}

.suggest-status.suggest-fail {
  color: var(--danger, #f87171);
}

.suggest-status.suggest-thinking {
  color: var(--text-secondary);
  font-style: italic;
}

.btn-secondary {
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  cursor: pointer;
  font-family: var(--font-family);
}

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.btn-danger {
  padding: 0.5rem 1.5rem;
  background: transparent;
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  cursor: pointer;
}

.btn-danger:hover {
  background: var(--color-danger);
  color: white;
}

.btn-warning {
  padding: 0.5rem 1.5rem;
  background: transparent;
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  cursor: pointer;
}

.btn-warning:hover {
  background: var(--color-warning);
  color: white;
}

.btn-success {
  padding: 0.5rem 1.5rem;
  background: transparent;
  color: #4ade80;
  border: 1px solid #4ade80;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  cursor: pointer;
}

.btn-success:hover {
  background: #4ade80;
  color: #0f172a;
}

.btn-save {
  width: auto;
  padding: 0.5rem 1.5rem;
}

.btn-back {
  padding: 0.375rem 0.75rem;
  font-size: var(--font-size-sm);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-back:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-transform: capitalize;
}

/* Status badges (active/inactive) */

/* Detail card (staff detail, etc.) */

.detail-row {
  display: flex;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
  align-items: center;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  width: 140px;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.detail-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  max-width: 600px;
}

.detail-actions .btn-primary,
.detail-actions .btn-danger,
.detail-actions .btn-success {
  width: auto;
  padding: 0.5rem 1.5rem;
}

/* Form card (inline forms on dedicated pages) */
.form-card {
  max-width: 500px;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

.form-actions .btn-primary,
.form-actions .btn-secondary {
  width: auto;
  padding: 0.5rem 1.5rem;
}

/* Clickable table rows */
.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-transform: capitalize;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 2rem;
}

.modal-content {
  background: var(--primary-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

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

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

/* Dialog system — animations and variants */
.dialog-overlay {
  /* Confirmation / alert dialogs ALWAYS sit above any other modal
     (page-level detail modals, picker modals, social-compose previews,
     etc.). Without this they inherit `.modal { z-index:100 }` and end
     up behind larger detail sheets that use a higher inline z-index. */
  z-index: 9000;
  opacity: 0;
  transition: opacity 0.15s ease;
  backdrop-filter: blur(2px);
}

.dialog-overlay.dialog-visible {
  opacity: 1;
}

.dialog-overlay.dialog-closing {
  opacity: 0;
}

.dialog-content {
  transform: scale(0.95) translateY(8px);
  transition: transform 0.15s ease, opacity 0.15s ease;
  /* shadow removed per minxi brutalist design (2026-05-19) */
}

.dialog-visible .dialog-content {
  transform: scale(1) translateY(0);
}

.dialog-closing .dialog-content {
  transform: scale(0.95) translateY(8px);
}

.dialog-title-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.dialog-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Variant colors */
.dialog-danger .dialog-icon { color: var(--danger, #e74c3c); }
.dialog-danger .dialog-header { border-bottom-color: rgba(231, 76, 60, 0.3); }

.dialog-warning .dialog-icon { color: var(--warning, #f0ad4e); }
.dialog-warning .dialog-header { border-bottom-color: rgba(240, 173, 78, 0.3); }

.dialog-success .dialog-icon { color: var(--success, #27ae60); }
.dialog-success .dialog-header { border-bottom-color: rgba(39, 174, 96, 0.3); }

.dialog-info .dialog-icon { color: var(--accent-primary, #3b82f6); }

.dialog-message {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Type-to-confirm field */
.dialog-confirm-field {
  margin-top: 1.25rem;
}

.dialog-confirm-label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.dialog-confirm-label strong {
  color: var(--danger, #e74c3c);
  font-family: monospace;
  letter-spacing: 0.5px;
}

.dialog-confirm-input {
  font-family: monospace;
  letter-spacing: 0.5px;
}

/* Toast notifications are now the shared <minxi-toast> CDN component
   (self-styled in shadow DOM, theme-aware). The former .toast / #toast-container
   styles were removed with the bespoke dialog.toast() (toast consolidation). */

/* Form inputs inside modals */
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--background-start);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-primary);
}

.form-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Tabs */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

/* Audit-03e batch 28 — outer org-detail tab strip stays visible while
 * scrolling long content (Ledger pages, Recipes lists). Sticky requires
 * a solid background so content doesn't bleed through. */
.tab-bar.tab-bar-sticky {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--primary-bg, #0f1115);
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* Audit-03e batch 28 — segmented control variant for second-level tabs
 * inside an outer .tab-bar (e.g. Wallets sub-views: Summary / Ledger /
 * Reserves / Withdrawals inside the Wallets tab of the org detail page).
 * Visually distinct from the underline-style outer tabs so the hierarchy
 * is unambiguous. */
.tab-bar.tab-bar-segmented {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
  background: var(--surface-hover, rgba(255, 255, 255, 0.02));
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.tab-bar.tab-bar-segmented .tab-btn {
  padding: 0.4rem 0.9rem;
  border-bottom: none;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.tab-bar.tab-bar-segmented .tab-btn:hover {
  background: var(--surface-hover, rgba(255, 255, 255, 0.04));
}

.tab-bar.tab-bar-segmented .tab-btn.active {
  background: var(--accent-primary);
  color: var(--bg-on-accent, #0f1115);
  border-bottom-color: transparent;
}

/* Config specific */
.config-key {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
}

.config-value {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
  transition: color var(--transition-fast);
}

.config-value:hover {
  color: var(--accent-primary);
}

/* Config page — collapsible sections via native <details>/<summary>.
   The disclosure semantics + open/close + keyboard handling are owned
   by the browser; CSS only theming. */
section.config-section {
  margin-bottom: 0.5rem;
}

.config-section-summary {
  list-style: none;  /* hide the default disclosure marker (Firefox) */
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  cursor: pointer;
  user-select: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  transition: color var(--transition-fast);
}
.config-section-summary::-webkit-details-marker { display: none; }
.config-section-summary::marker { content: ""; }
.config-section-summary:hover { color: var(--accent-primary); }
.config-section-summary::before {
  /* Custom chevron — rotates 90° when the parent <details> is open. */
  content: "\25B6";
  font-size: 0.625rem;
  color: var(--text-secondary);
  display: inline-block;
  width: 1rem;
  text-align: center;
  transition: transform var(--transition-fast);
}
details[open] > .config-section-summary::before { transform: rotate(90deg); }

.config-section-summary .config-section-label {
  /* The h2.card-title default top margin would push the chevron+badge
     out of the summary's flex baseline — zero it inside the summary. */
  margin: 0;
  flex: 0 0 auto;
}

.config-section-icon {
  font-size: 1rem;
}

.config-section-body {
  border-top: 1px solid var(--border-color);
  margin-top: 0.5rem;
}

/* Config entry row */
.config-entry {
  display: grid;
  grid-template-columns: minmax(200px, 1.5fr) minmax(120px, 2fr) minmax(120px, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.625rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}

.config-entry:last-child {
  border-bottom: none;
}

.config-entry:hover {
  background: rgba(255, 255, 255, 0.02);
}

.config-entry-key {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
}

.config-key-prefix {
  color: var(--text-secondary);
}

.config-key-name {
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}

.config-entry-value {
  min-width: 0;
}

.config-entry-meta {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.config-entry-actions {
  text-align: right;
}

/* Unset config entries */
.config-entry-unset {
  opacity: 0.65;
}

.config-entry-unset:hover {
  opacity: 1;
}

.config-value-unset {
  font-style: italic;
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  cursor: default;
}

.config-key-desc {
  display: block;
  font-family: var(--font-sans, sans-serif);
  font-size: 0.625rem;
  font-weight: normal;
  color: var(--text-secondary);
  margin-top: 0.125rem;
  opacity: 0.8;
}

.config-hint {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin: 0 0 0.5rem 0;
}

/* Audit trail table */
.config-audit-table {
  table-layout: auto;
}

.config-audit-table th:nth-child(1) { width: 120px; white-space: nowrap; }
.config-audit-table th:nth-child(2) { width: 120px; }
.config-audit-table th:nth-child(3) { width: 220px; }
.config-audit-table th:nth-child(4) { }

.config-audit-user {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-xs);
}

.config-audit-row {
  cursor: default;
}

.config-audit-reason-cell {
  overflow: hidden;
}

.config-audit-reason {
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  display: inline;
  margin-right: 0.5rem;
}

.config-audit-detail-toggle {
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  opacity: 0.6;
  vertical-align: middle;
}

.config-audit-detail-toggle:hover {
  opacity: 1;
}

.config-audit-detail-row > td {
  padding: 0 1rem 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.015);
}

.config-audit-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  max-width: 700px;
}

.config-audit-val-group {
  min-width: 0;
}

.config-audit-val-label {
  display: block;
  font-size: 0.625rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.config-audit-val-pre {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  max-height: 120px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.15);
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* Type badge in edit modal */
.config-type-badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-md);
  font-size: 0.625rem;
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  vertical-align: middle;
  margin-left: 0.375rem;
}

/* JSON editor */
.config-json-editor {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  line-height: 1.6;
  min-height: 120px;
  tab-size: 2;
}

/* Validation message */
.config-validation-msg {
  display: none;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: var(--font-size-xs);
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
}

/* Config audit header with search */
.config-audit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.5rem;
}

/* Config pagination */
.config-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

.config-pagination-info {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  min-width: 80px;
  text-align: center;
}

/* Config mini-form for structured objects */
.config-fields-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.config-field-row {
  display: grid;
  grid-template-columns: minmax(100px, auto) 1fr;
  gap: 0.5rem;
  align-items: center;
}

.config-field-label {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  text-align: right;
  padding-right: 0.25rem;
}

.config-field-input {
  padding: 0.5rem 0.75rem;
  background: var(--background-start);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  transition: border-color var(--transition-fast);
}

.config-field-input:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.config-field-input[type="checkbox"] {
  width: auto;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

/* Inline structured value display */
.config-value-fields {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  max-width: 200px;
  overflow: hidden;
}

.config-value-chip {
  display: inline-block;
  padding: 0.0625rem 0.375rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.config-value-chip-key {
  color: var(--text-secondary);
}

.config-value-chip-val {
  color: var(--text-primary);
}

/* Detail sections */
.detail-section {
  margin-top: 1.5rem;
}

/* Danger zone */
.card-danger {
  border-color: rgba(239, 68, 68, 0.3);
}

.danger-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Note composer */
.note-composer {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.note-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0;
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--font-size-sm);
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.note-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.note-input:disabled {
  opacity: 0.6;
}

.note-composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

.note-hint {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary, var(--text-secondary));
}

/* Notes */
.note-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.note-item:last-child {
  border-bottom: none;
}

.note-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.note-author {
  font-weight: 600;
  color: var(--text-primary);
}

.note-date {
  color: var(--text-secondary);
}


.note-actions {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.note-item:hover .note-actions {
  opacity: 1;
}

.note-action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--font-size-xs);
  padding: 0.125rem 0.375rem;
  border-radius: 0;
  transition: color 0.15s, background 0.15s;
}

.note-action-btn:hover {
  color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.1);
}

.note-action-delete:hover {
  color: var(--danger, #e74c3c);
  background: rgba(231, 76, 60, 0.1);
}

.note-body {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.note-editing {
  white-space: normal;
}

.note-edit-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--accent-primary);
  border-radius: 0;
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--font-size-sm);
  resize: vertical;
  box-sizing: border-box;
}

.note-edit-input:focus {
  outline: none;
}

.note-edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Links */
.link-text {
  color: var(--accent-primary);
  text-decoration: none;
  cursor: pointer;
}

.link-text:hover {
  text-decoration: underline;
}

/* Cell subtitle */
.cell-subtitle {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* SQL preview */

/* Warning text */
.text-warning {
  color: var(--color-warning);
  font-size: var(--font-size-sm);
  margin-top: 0.5rem;
}

/* Deploy + Error item styles are in the Monitoring Page section below */

/* Data table hover */
.data-table tbody tr:hover {
  background: var(--secondary-surface);
}

/* Row selection */
.data-table tbody tr.row-selected {
  background: rgba(var(--minxi-accent-primary-rgb, 139, 92, 246), 0.12);
}

.data-table tbody tr.row-selected:hover {
  background: rgba(var(--minxi-accent-primary-rgb, 139, 92, 246), 0.18);
}

.data-table tbody tr.org-row {
  cursor: pointer;
}

/* Checkbox column */

/* Sortable column headers */

/* Bulk actions bar */
.bulk-actions-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  margin-bottom: 0.75rem;
  background: rgba(var(--minxi-accent-primary-rgb, 139, 92, 246), 0.1);
  border: 1px solid rgba(var(--minxi-accent-primary-rgb, 139, 92, 246), 0.3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.bulk-count {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-right: 0.5rem;
}

/* Table info (row count) */
.table-info {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

/* Pagination bar */
.pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.375rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

/* Disabled button */
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* SSE connection indicator */
.sse-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.sse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  display: inline-block;
}

.sse-indicator.sse-connected {
  background: var(--color-success);
  /* glow removed per minxi brutalist design */
}

.sse-indicator.sse-connecting,
.sse-indicator.sse-reconnecting {
  background: var(--color-warning);
  animation: sse-pulse 1.5s ease-in-out infinite;
}

.sse-indicator.sse-disconnected {
  background: var(--text-secondary);
}

@keyframes sse-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Skip to content link (accessibility) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--accent-primary);
  color: var(--text-on-accent);
  padding: 0.75rem 1.5rem;
  z-index: 300;
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
  border-radius: 0 0 var(--radius-md) 0;
}

.skip-link:focus {
  top: 0;
}

/* Focus visible styles (accessibility) */
*:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (forced-colors: active) {
  .status-badge,
  .badge {
    border: 1px solid currentColor;
  }

  .sse-indicator {
    border: 1px solid currentColor;
  }

  body > aside > nav a[aria-current="page"] {
    border-left-color: Highlight;
  }
}

/* === Monitoring Page === */

/* Two-column grid for monitoring panels */
.mon-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
/* Equal-height panes: <minxi-card> now fills its stretched grid/flex cell
   globally (see minxi-card.js .card height:100%), so adjacent panes here
   match without a per-class rule. */

/* Metrics mini-cards grid (database metrics) */

/* Section labels inside cards */
.mon-section-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: var(--font-weight-semibold);
  margin: 1rem 0 0.5rem;
}

/* Compact table variant */
.mon-compact-table {
  min-width: auto;
  font-size: var(--font-size-xs);
}

.mon-compact-table th,
.mon-compact-table td {
  padding: 0.5rem 0.6rem;
}

/* Service type badges */
.mon-badge-type-web {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.mon-badge-type-worker {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

/* Error severity badges */
.mon-badge-severity-critical {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.mon-badge-severity-error {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.mon-badge-severity-warning {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
}

.mon-badge-severity-info {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

/* Queue failure items */
.mon-failure-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.mon-failure-item:last-child {
  border-bottom: none;
}

.mon-failure-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.mon-failure-name {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

/* Deploy items */
.deploy-item {
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border-color);
}

.deploy-item:last-child {
  border-bottom: none;
}

.deploy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.deploy-service {
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}

.deploy-meta {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Queue accordion groups */
.queue-accordion {
  margin-bottom: 0.5rem;
}
.queue-accordion-btn {
  width: 100%;
  text-align: left;
  background: var(--secondary-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  transition: background 0.15s;
}
.queue-accordion-btn:hover {
  background: var(--hover-bg, rgba(255,255,255,0.05));
}
.queue-accordion-arrow {
  font-size: 0.65rem;
  color: var(--text-secondary);
  transition: transform 0.15s;
  display: inline-block;
  width: 0.75rem;
}
.queue-accordion-summary {
  margin-left: auto;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: normal;
}
.queue-accordion-body {
  padding: 0.25rem 0 0;
}

/* Error items */
.error-item {
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border-color);
}

.error-item:last-child {
  border-bottom: none;
}

.error-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.error-service {
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}

.error-time {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-left: auto;
}

.error-message {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-top: 0.25rem;
  word-break: break-word;
}

/* Koyeb Infrastructure */

.koyeb-period-selector {
  display: inline-flex;
  gap: 0;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.koyeb-period-btn {
  padding: 0.375rem 1rem;
  font-size: var(--font-size-xs);
  border: none;
  border-right: 1px solid var(--border-color);
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.koyeb-period-btn:last-child {
  border-right: none;
}

.koyeb-period-btn:hover {
  background: var(--secondary-surface);
  color: var(--text-primary);
}

.koyeb-period-active {
  background: var(--accent-primary);
  color: var(--text-on-accent);
}

.koyeb-period-active:hover {
  background: var(--accent-primary);
  color: var(--text-on-accent);
}

/* External Services */
.ext-services-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.ext-service-card {
  background: var(--primary-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: box-shadow var(--transition-fast);
}

.ext-service-card:hover {
  /* glow removed per minxi brutalist design */
}

.ext-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ext-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ext-dot-healthy {
  background: var(--color-success);
  /* glow removed per minxi brutalist design */
}

.ext-dot-inactive {
  background: #6b7280;
}

.ext-dot-warning {
  background: var(--color-warning);
  /* glow removed per minxi brutalist design */
}

.ext-dot-down {
  background: var(--color-danger);
  /* glow removed per minxi brutalist design */
}

.ext-card-name {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  display: block;
}

.ext-card-subtitle {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  display: block;
}

.ext-metrics-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.ext-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
}

.ext-metric-label {
  color: var(--text-secondary);
}

.ext-metric-value {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

.ext-metric-danger {
  color: var(--color-danger);
}

/* Responsive */
@media (max-width: 768px) {
  .mon-two-col {
    grid-template-columns: 1fr;
  }

  .ext-services-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .ext-services-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── PWA standalone + phone shell (mobile-readiness, 2026-06) ─────
 * The ≤600px block makes the sidebar a slide-in drawer (off-screen by
 * default, hamburger toggles it open) so phone content fills the
 * viewport. The earlier "top-stacked at max-height: 45vh" pattern
 * intruded on half the screen and the footer (Workspace + Sign Out)
 * sat where content should be — replaced 2026-06-12 per user report.
 *
 * Safe-area insets are no-ops (env() = 0) outside notched standalone.
 * The data-table `min-width: 600px` is intentionally kept (tables need
 * room) — we let them scroll horizontally inside their container.
 */

@supports (padding: env(safe-area-inset-top)) {
  html[data-authed] body > aside {
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
  }
  body > main {
    padding-top: max(var(--space-lg, 1.5rem), env(safe-area-inset-top, 0));
    padding-right: max(var(--space-lg, 1.5rem), env(safe-area-inset-right, 0));
    padding-bottom: max(var(--space-lg, 1.5rem), env(safe-area-inset-bottom, 0));
  }
}

/* Hamburger toggle: fixed-position, visible only at ≤600px. The button
 * is placed once in the HTML; CSS hides it on wider viewports so the
 * tablet/desktop shell is unaffected. */
button[data-nav-toggle] {
  display: none;
  position: fixed;
  top: max(0.5rem, env(safe-area-inset-top, 0));
  left: max(0.5rem, env(safe-area-inset-left, 0));
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border-color, rgba(255,255,255,0.08));
  border-radius: var(--radius-md, 0.4rem);
  color: var(--text-primary, #e6edf3);
  cursor: pointer;
  z-index: 101;
  padding: 0;
  font-family: inherit;
  font-size: 1.25rem;
  line-height: 1;
}
button[data-nav-toggle]:hover { border-color: var(--accent-primary, #a855f7); }
button[data-nav-toggle]:focus-visible {
  outline: 2px solid var(--accent-primary, #a855f7);
  outline-offset: 2px;
}

/* Backdrop: dim layer behind the drawer. Sits on the same z-stack as
 * the aside (which uses z-index: 100 in drawer mode) but one below. */
[data-nav-backdrop] {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99;
  cursor: pointer;
}

/* Phone shell (≤600px) — sidebar becomes an off-screen drawer that
 * slides in from the left when the hamburger is tapped. Content fills
 * the entire viewport so the previously-obscured top half is reclaimed. */
@media (max-width: 600px) {
  html[data-authed] body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  html[data-authed] body > aside {
    position: fixed;
    top: 0;
    left: 0;
    width: min(300px, 85vw);
    height: 100vh;
    max-height: none;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.45);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-right: 1px solid var(--border-color);
    border-bottom: none;
    /* The desktop aside is transparent (--side-nav-bg) because it sits on
     * the page's own gradient. As a floating drawer it overlays content,
     * so it needs an opaque background matching the page theme. */
    background: linear-gradient(180deg, var(--background-start, #0a0014), var(--background-end, #0d001c));
  }
  html[data-authed] body > aside[data-mobile-open] {
    transform: translateX(0);
  }
  html[data-authed] body > main {
    grid-row: 1;
    grid-column: 1;
    padding: 3.5rem 1rem 1rem;
  }
  /* Show the hamburger + backdrop only at this breakpoint. */
  button[data-nav-toggle] { display: inline-flex; }
  body > aside[data-mobile-open] ~ [data-nav-backdrop] { display: block; }
  /* When the drawer is open, lock body scroll so the underlying page
   * doesn't move while interacting with the drawer. */
  html[data-authed] body:has(aside[data-mobile-open]) {
    overflow: hidden;
  }
  /* Tables stay readable by allowing horizontal scroll inside their
   * own wrapper rather than blowing out the viewport. */
  main :where(table, .data-table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
