/*
 * Control-plane stylesheet for the Mero UI + HTMX frontend.
 *
 * Load order: /vendor/mero/mero.css, then this file. Mero styles every
 * component through zero-specificity :where() rules and --mero-* tokens, so
 * this file (1) declares Origo's tokens (copied from public/styles.css
 * @layer tokens, DESIGN.md), (2) maps the --mero-* tokens onto them, and
 * (3) adds the control-plane shell and page parts. The tenant app keeps
 * /styles.css; the control plane no longer loads it.
 *
 * Themes: the pre-paint script sets html[data-theme] and color-scheme from
 * localStorage["theme"], like the tenant app. Origo tokens are light-dark()
 * pairs and Mero reads the same data-theme attribute, so one mapping covers
 * both themes.
 */

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    padding: 0;
  }
  /* Dialogs keep the UA margin:auto, which centres them in the top layer. */
  :where(*:not(dialog)) {
    margin: 0;
  }
}

/* ── Origo tokens (public/styles.css @layer tokens) ───────────────────────── */
:root {
  color-scheme: light;
  --color-primary: #5e6ad2;
  --color-primary-hover: #4f5bc0;
  /* Destructive Red: borders and fills only. As text it is 3.9:1 on white;
     red text uses --mero-danger, which keeps ≥ 4.6:1 in both themes. */
  --color-danger: #e5484d;
  --color-success: #30a46c;
  /* Text on a Control Violet fill: ≥ 4.5:1 on #5e6ad2 in both themes (white is 4.70:1). */
  --color-on-primary: light-dark(#fbfbff, #ffffff);
  --color-bg: light-dark(#f9f9fb, #1a1a1f);
  --color-surface: light-dark(#ffffff, #232329);
  --color-surface-raised: light-dark(#f4f4f6, #2a2a30);
  --color-border: light-dark(#ebebef, #333339);
  --color-border-subtle: light-dark(#f2f2f5, #2a2a30);
  /* Control boundaries (WCAG 1.4.11): ≥ 3:1 on the surface and on the raised
     input background in both themes. */
  --color-control-border: light-dark(#8a8a94, #74747f);
  --color-text: light-dark(#1c1c1e, #ededef);
  /* Muted text: ≥ 4.5:1 on surface and raised surface in both themes. */
  --color-text-secondary: light-dark(#6e6e76, #9a9aa3);
  --color-text-tertiary: light-dark(#a0a0a8, #5c5c66);
  /* Compact (tenant) navigation palette. */
  --color-sidebar-bg: light-dark(#f9f9fb, #202027);
  --color-sidebar-border: light-dark(#ebebef, #34343c);
  --color-sidebar-text: light-dark(#52525c, #c7c7d1);
  --color-sidebar-text-hover: light-dark(#26262c, #f0f0f4);
  --color-sidebar-hover-bg: light-dark(#f0f0f4, #292930);
  --color-sidebar-active-bg: light-dark(#eaeaf7, #343449);
  /* Active nav label: darker violet on light, lighter tint on dark (≥ 4.5:1 on the active bg). */
  --color-sidebar-active-text: light-dark(#4c54b4, #c6caff);
  /* Inline links and Mero's accent: Pressed Control Violet on light (≥ 5:1 on
     the surface, raised surface and every alert tint, where Control Violet
     falls to 4.1:1); its lighter tint keeps 4.5:1 on dark surfaces. */
  --color-link: light-dark(var(--color-primary-hover), #aeb4ff);
  /* Status badge pairs (.badge-* in styles.css), ≥ 4.5:1 in both themes. */
  --status-gray-bg: light-dark(#f0f0f2, #333339);
  --status-gray-fg: light-dark(#5b5b64, #b4b4be);
  --status-blue-fg: light-dark(#3b4fc0, #8b9cf5);
  --status-amber-fg: light-dark(#856404, #f5c842);
  --status-red-fg: light-dark(#c0392b, #f58b8b);
  --status-green-fg: light-dark(#1a7f42, #5ec98b);

  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --radius: 6px;
  --ease-out-origo: cubic-bezier(0.16, 1, 0.3, 1);
}
html[data-theme="dark"] {
  color-scheme: dark;
}
html[data-theme="light"] {
  color-scheme: light;
}

/* ── Mero → Origo token bridge ─────────────────────────────────────────────
   html[data-theme] (0,1,1) outranks Mero's own [data-theme="dark"] (0,1,0), so
   these win in both themes; the values themselves are light-dark() pairs. */
html,
html[data-theme] {
  --mero-font: var(--font-body);
  --mero-radius: var(--radius);
  /* DESIGN.md: 6px for panels and cards. */
  --mero-radius-panel: var(--radius);
  --mero-control-height: 2rem;
  --mero-control-padding-inline: 0.625rem;
  --mero-control-gap: 0.25rem;
  --mero-ease: var(--ease-out-origo);
  --mero-bg: var(--color-bg);
  --mero-surface: var(--color-surface);
  --mero-raised: var(--color-surface-raised);
  /* One step past raised, so hover stays visible on raised surfaces. */
  --mero-hover: light-dark(#ebebef, #34343b);
  --mero-line: var(--color-border);
  --mero-control-line: var(--color-control-border);
  --mero-text: var(--color-text);
  --mero-primary: var(--color-primary);
  --mero-primary-ink: var(--color-on-primary);
  --mero-accent: var(--color-link);
  --mero-accent-ink: light-dark(var(--color-on-primary), #1a1a2e);
  --mero-switch-active: var(--color-primary);
  /* Mero tints badges (15%) and alerts (9%) with the tone itself, so each
     status ink is the Origo status colour moved just far enough (toward black
     on light, white on dark) to keep ≥ 4.6:1 on that tint over both the
     surface and the raised surface. Unchanged where the Origo ink already does. */
  --mero-muted: light-dark(#606067, #a9a9b1);
  --mero-success: light-dark(#176e39, var(--status-green-fg));
  --mero-warning: light-dark(#7a5c04, var(--status-amber-fg));
  --mero-danger: light-dark(#ad3327, var(--status-red-fg));
  --mero-info: light-dark(var(--status-blue-fg), #95a5f6);
  /* light-dark() takes colours only, so each theme's layer is made transparent
     in the other; a light-dark() around the whole list computes to none. */
  --mero-shadow:
    0 8px 24px light-dark(rgba(0, 0, 0, 0.12), transparent),
    inset 0 0 1px 0 light-dark(transparent, rgba(255, 255, 255, 0.3));
}
/* Only without a reduced-motion preference: under reduce, mero.css sets both to 0ms. */
@media (prefers-reduced-motion: no-preference) {
  html,
  html[data-theme] {
    --mero-fast: 150ms;
    --mero-enter: 200ms;
  }
}

/* WCAG 1.4.11: Mero marks the selected tab with a surface fill and a --mero-line ring, each
   about 1.1:1 against the tab list in both themes. A 2px bar in the text colour along the
   bottom is the ≥ 3:1 indicator. It is a background layer, so Mero's own ring and shadow stay
   as Mero sets them; it sits 1px up because the inset ring paints over the bottom pixel. Mero's rule is :where(.mero-tab)[aria-selected="true"] at (0,1,0); this
   ties it and wins on load order (Mero's background shorthand resets background-image).
   Workaround for rubenlangeweg/mero-ui#60 (X3 item 13): remove after the re-vendor that
   ships a ≥ 3:1 selected-tab indicator (X2). */
:where(.mero-tab):is([aria-selected="true"], [aria-current="page"]) {
  background-image: linear-gradient(var(--mero-text), var(--mero-text));
  background-position: left 0 bottom 1px;
  background-repeat: no-repeat;
  background-size: 100% 2px;
}

html,
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
:where(a:not([class*="mero-"])) {
  color: inherit;
}
code,
kbd,
.mono {
  font-family: var(--font-mono);
}
.mono {
  font-size: 0.75rem;
}

/* ── Mero components at Origo density (DESIGN.md: compact forms and tables) ── */
.mero-button {
  font-weight: 500;
  font-size: 0.8125rem;
  padding: 0.3rem 0.75rem;
  gap: 0.25rem;
}
.mero-button-sm {
  --_height: 1.75rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}
.mero-button-primary {
  box-shadow: none;
}
.mero-button-primary:hover:not(:disabled, [aria-disabled="true"]) {
  background: var(--color-primary-hover);
}
/* Mero darkens a hover with 12% of the text colour, which drops the danger
   label to 3.9:1 (light) and 3.5:1 (dark). Lighten the tint instead
   (≥ 5.5:1) and outline it in the danger ink so hover stays distinct. */
.mero-button-danger:hover:not(:disabled, [aria-disabled="true"]) {
  background: color-mix(in srgb, var(--mero-danger) 9%, var(--mero-surface));
  border-color: var(--mero-danger);
}
.mero-button-ghost {
  color: var(--color-text-secondary);
}
.mero-button-ghost:hover:not(:disabled, [aria-disabled="true"]) {
  background: var(--color-surface-raised);
  color: var(--color-text);
}
.mero-input,
.mero-select,
.mero-textarea {
  font-size: 0.875rem;
}
.mero-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}
.mero-badge {
  padding: 0.0625rem 0.4rem;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9999px;
  line-height: 1.5;
  white-space: nowrap;
}
.mero-menu-item {
  font-size: 0.8125rem;
}

/* One visible focus treatment everywhere (WCAG 2.4.7). */
:where(a, button, input, select, textarea, summary, [tabindex], [role="row"]):focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── App shell: the tenant app's compact navigation (styles.css
   .app-layout[data-navigation-mode="compact"]), rebuilt on Mero parts. ── */
:root {
  --shell-content-bg: light-dark(#ffffff, #1a1a1f);
}
.cp-shell {
  display: flex;
  min-height: 100vh;
  background: var(--shell-content-bg);
}
.cp-sidebar {
  width: 218px;
  flex-shrink: 0;
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-sidebar-border);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.cp-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1.25rem 1rem;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--color-sidebar-text-hover);
}
.cp-goto {
  margin: 0 0.75rem 0.75rem;
}
.cp-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 0;
  padding: 0 0.75rem 0.75rem;
}
.cp-nav-secondary {
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-sidebar-border);
}
.nav-group + .nav-group {
  margin-top: 0.5rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 36px;
  margin: 2px 0;
  padding: 0 0.75rem;
  border-radius: 6px;
  color: var(--color-sidebar-text);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition:
    background 150ms,
    color 150ms;
}
.nav-item svg {
  opacity: 0.7;
  flex-shrink: 0;
}
.nav-item:hover {
  background: var(--color-sidebar-hover-bg);
  color: var(--color-sidebar-text-hover);
}
.nav-item[aria-current="page"] {
  background: var(--color-sidebar-active-bg);
  color: var(--color-sidebar-active-text);
  font-weight: 600;
}
.nav-item:hover svg,
.nav-item[aria-current="page"] svg {
  opacity: 1;
}
.cp-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--color-sidebar-border);
}
.cp-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--shell-content-bg);
}
.cp-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 58px;
  padding: 0 2rem;
  background: var(--shell-content-bg);
  border-bottom: 1px solid var(--color-border);
}
.cp-header h1 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cp-content {
  padding: 1.875rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cp-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 100001;
  background: var(--color-primary);
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
  transition:
    transform 400ms var(--ease-out-origo),
    opacity 200ms;
}
.cp-progress[data-active="true"] {
  transform: scaleX(0.7);
  opacity: 1;
}

@media (max-width: 1024px) {
  .cp-sidebar {
    display: none;
  }
  .cp-header {
    padding: 0 1rem;
  }
  .cp-content {
    padding: 1.25rem 1rem;
  }
}

.table-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

/* Forced colours strip backgrounds and shadows, which carry the selected
   navigation item and view tab, and the fill of meters and progress bars. */
@media (forced-colors: active) {
  /* An underline marks the selection, so the focus outline stays distinct. */
  .nav-item[aria-current="page"] {
    text-decoration: underline 2px;
    text-underline-offset: 0.25em;
  }
  .mero-meter,
  .mero-progress {
    forced-color-adjust: none;
    border: 1px solid CanvasText;
    background: Canvas;
  }
  .mero-meter::-webkit-meter-bar {
    background: Canvas;
  }
  .mero-meter::-webkit-meter-optimum-value,
  .mero-meter::-webkit-meter-suboptimum-value,
  .mero-meter::-webkit-meter-even-less-good-value,
  .mero-progress::-webkit-progress-value {
    background: Highlight;
  }
  .mero-meter::-moz-meter-bar,
  .mero-progress::-moz-progress-bar {
    background: Highlight;
  }
}

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

/* ── Login (public shell) ─────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--color-bg);
}
.login-stage {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.login-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.login-brand {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}
.login-brand-sub {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
}
.login-card {
  padding: 1.5rem;
  box-shadow: light-dark(0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.24));
}
.login-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  color: var(--color-text-tertiary);
  font-size: 0.75rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--color-border);
}

/* ── Page kit (tenant .form-container) ── */
/* A small label above a value that is not in a description list (release
   transition sides, "Latest grant"). Mero core has no such label yet. */
.cp-eyebrow {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}
.form-page {
  max-width: 800px;
  width: 100%;
}
.form-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1.5rem;
}
.form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}
.form-section:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}
.form-section-title {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
}
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}
.detail-page {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 1100px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
.text-secondary {
  color: var(--color-text-secondary);
}
.cell-title {
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}
a.cell-title:hover {
  text-decoration: underline;
}

/* ── UX pass: record pages, lists, command menu ─────────────────────────── */

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}

.overview-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 14px;
  color: var(--color-text-secondary);
}
.overview-counts a {
  color: inherit;
  text-decoration: none;
}
.overview-counts a:hover {
  color: var(--color-text);
}
.overview-counts strong {
  color: var(--color-text);
  font-weight: 600;
}

.cp-activity {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}
.cp-activity-item {
  text-decoration: none;
}
.cp-activity-item:hover {
  text-decoration: underline;
}

/* Danger zone: closed until the operator chooses the destructive action. */
.danger-zone {
  border: 1px solid color-mix(in srgb, var(--color-danger) 35%, var(--color-border));
  border-radius: 6px;
  background: var(--color-surface);
}
.danger-zone > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 600;
}
.danger-zone > summary::-webkit-details-marker {
  display: none;
}
.danger-zone[open] > summary {
  border-bottom: 1px solid var(--color-border);
}
.danger-zone > .danger-zone-body {
  padding: 1rem;
}

/* ── Mero integration: shell parts ─────────────────────────────────────────── */
.cp-drawer-toggle {
  display: none;
}
@media (max-width: 1024px) {
  .cp-drawer-toggle {
    display: inline-flex;
  }
}
.cp-drawer .cp-brand {
  color: var(--color-text);
}
.cp-goto {
  display: flex;
  gap: 0.25rem;
}
.cp-goto .mero-button-outline {
  flex: 1;
  justify-content: space-between;
}
.nav-group ul {
  list-style: none;
}
.cp-account {
  width: 100%;
  justify-content: flex-start;
  gap: 0.5rem;
  padding-inline: 0.25rem;
  font-size: 0.8125rem;
  color: var(--color-sidebar-text-hover);
}
.cp-account .mero-avatar {
  inline-size: 1.75rem;
  block-size: 1.75rem;
}
.cp-account-email {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-account-menu {
  min-width: 15rem;
}
.filter-menu {
  max-height: min(26rem, 60vh);
  overflow: auto;
  min-width: 14rem;
}
.cp-drawer {
  --mero-panel-bg: var(--color-sidebar-bg);
  width: min(280px, 85vw);
  padding: 0;
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
}
.cp-drawer .cp-nav {
  min-height: auto;
}
.cp-drawer-close {
  position: absolute;
  inset-block-start: 0.75rem;
  inset-inline-end: 0.75rem;
}
.cp-command {
  width: min(640px, calc(100vw - 2rem));
  padding: 0;
}
.cp-command .mero-combo {
  padding: 0.75rem;
}
.cp-command .mero-input {
  font-size: 15px;
  min-height: 2.5rem;
}
.cp-command .mero-combo-list {
  position: static;
  max-height: min(420px, 55vh);
  overflow: auto;
  margin-top: 0.5rem;
  box-shadow: none;
  border: 0;
}
.cp-command .mero-option {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 14px;
}
.cp-command .cmdk-detail {
  color: var(--color-text-secondary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}
.cmdk-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-secondary);
}
.cp-content:focus {
  outline: none;
}

/* ── Lists: toolbar, filters, table density, cards ─────────────────────────── */
.toolbar-main {
  flex: 1 1 24rem;
  min-width: 0;
}
.toolbar-search {
  flex: 0 1 20rem;
  min-width: 12rem;
}
.toolbar-search-input {
  width: 100%;
}
.filter-chips .mero-filter-chips {
  list-style: none;
  gap: 0.375rem;
}
.filter-clear {
  font-size: 13px;
}
.cp-table {
  width: 100%;
}
.cp-table-caption {
  text-align: left;
}
/* Desktop column headers only: below 48rem Mero turns the header links into
   the cards' sort row, styled by Mero. */
@media (width >= 48rem) {
  .cp-table thead th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--color-text-secondary);
    background: var(--color-surface-raised);
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 1rem;
    text-align: left;
    white-space: nowrap;
  }
}
.cp-table tbody :is(th, td) {
  padding: 0.5rem 1rem;
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  vertical-align: middle;
  border-top: 1px solid var(--color-border-subtle);
}
.cp-table tbody tr:hover :is(th, td) {
  background: var(--color-surface-raised);
}
.cp-table .cell-title {
  font-weight: 600;
}
.row-menu {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
}
.row-menu-trigger {
  min-width: 28px;
  color: var(--color-text-secondary);
}
.row-menu .mero-field-error {
  white-space: normal;
  width: max-content;
  max-width: min(22rem, 70vw);
  text-align: right;
  font-size: 12px;
}
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
/* Card-mode helper: the phone cards' reset link. */
.cp-sort-reset {
  display: none;
}
.cp-sort-reset {
  margin: 0;
  padding: 0.625rem 0.875rem 0;
  font-size: 13px;
}
@media (width < 48rem) {
  .cp-sort-reset {
    display: block;
  }
  /* Search and "+ Filter" share one row at control height. */
  .toolbar-search {
    flex: 1 1 12rem;
  }
  .filter-chips > .mero-button {
    --_height: var(--mero-control-height);
    padding-inline: 0.75rem;
    font-size: 0.8125rem;
    border: 1px solid var(--color-control-border);
  }
}
/* Phone cards (Mero .mero-table-cards below 48rem): compact Origo spacing. */
@container mero-table-cards (min-width: 0px) {
  /* Mero's sort row and its label sit inside the card's padding. */
  .cp-table :is(caption, thead) {
    padding-inline: 0.875rem;
  }
  .cp-table tbody tr {
    border-top: 1px solid var(--color-border-subtle);
    padding: 0.625rem 0.875rem;
  }
  .cp-table tbody :is(th, td) {
    border: 0;
    padding: 0.125rem 0;
    background: transparent !important;
  }
  .row-menu {
    align-items: flex-start;
  }
}

/* ── Forms, notices, identifiers ──────────────────────────────────────────── */
.form-field {
  min-width: 0;
}
.required-mark {
  color: var(--mero-danger);
}
.cp-notice {
  font-size: 14px;
}
.cp-notice-body > * + * {
  margin-top: 0.25rem;
}
.cp-identifier {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
}
.cp-identifier code {
  overflow-wrap: anywhere;
}
.cp-copy {
  --_height: 1.5rem;
  padding: 0 0.375rem;
  font-size: 11px;
}

/* ── Page groups: each page group appends its own rules below its marker. ── */
/* @group accounts */
.acc-section,
.acc-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}
.acc-column {
  gap: 1rem;
}
.acc-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.acc-policy {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1.5rem;
}
.acc-form-end {
  display: flex;
  justify-content: flex-end;
}
.acc-when {
  display: contents;
}
.acc-when[hidden] {
  display: none;
}
.acc-small {
  font-size: 12px;
}
.acc-flush {
  margin: 0;
}
.acc-break {
  overflow-wrap: anywhere;
}
.acc-notes {
  white-space: pre-wrap;
}
.acc-danger-text {
  color: var(--mero-danger);
}
.cell-sub {
  font-weight: 400;
  margin-inline-start: 0.375rem;
}
.usage-over {
  color: var(--mero-danger);
}
.acc-plan-form > .form-page + .form-page {
  margin-top: 1.25rem;
}
/* @group environments-list */
.neon-fleet {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 14px;
}
.neon-fleet-count {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.neon-fleet-count strong {
  font-size: 1rem;
}
.neon-fleet .mero-meter {
  inline-size: 100%;
}
.neon-fleet-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}
.env-cell {
  display: inline-flex;
  flex-direction: column;
}
.env-cell-slug {
  font-size: 12px;
  font-weight: 400;
}
.env-engine {
  align-items: center;
  white-space: nowrap;
}
.env-engine .mono {
  font-size: 12px;
}
.env-delete-id {
  display: block;
  margin-top: 0.5rem;
  overflow-wrap: anywhere;
}
.env-create-error {
  margin-bottom: 1rem;
}
/* Wizard step position (kit StepList): an <ol> with aria-current="step". */
.cp-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
  counter-reset: cp-step;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}
.cp-steps li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  counter-increment: cp-step;
}
.cp-steps li[aria-current="step"] {
  color: var(--color-text);
  font-weight: 600;
}
.cp-steps li::before {
  /* Decorative: the empty alt text keeps screen readers to the label and aria-current. */
  content: counter(cp-step) / "";
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.cp-steps li[aria-current="step"]::before,
.cp-steps li[data-done]::before {
  border-color: var(--color-primary);
  /* --color-primary is about 3.7:1 on the dark background; the number is small text. */
  color: var(--color-link);
}
.env-create-heading {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}
.env-create-heading:focus {
  outline: none;
}
.env-create-wizard .form-actions form {
  display: contents;
}
.env-create-submit {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}
.env-create-submit [data-mero-action-status]:empty {
  display: none;
}
.env-create-recover {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}
.env-create-recover[hidden] {
  display: none;
}
.env-create-recover p {
  margin: 0;
}
.env-create-note {
  margin: 0.75rem 0 0;
}
/* @group environment-record */
.env-stack-tight {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  align-items: flex-start;
}
.env-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1.25rem;
}
.env-muted {
  margin: 0;
  font-size: 14px;
}
.env-small {
  font-size: 12px;
}
.env-block {
  display: block;
}
.env-break {
  overflow-wrap: anywhere;
}
.env-measure {
  max-width: 640px;
}
.env-truncate {
  display: block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.env-subheading {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}
.env-ruled {
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}
.env-split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 14px;
}
.env-split-top {
  align-items: flex-start;
}
.env-split-ruled {
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}
.env-actions,
.env-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}
.env-two-up {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 1100px) {
  .env-two-up {
    grid-template-columns: minmax(0, 1fr);
  }
}
.env-confirm {
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 14px;
}
.env-confirm .mero-checkbox {
  margin-top: 0.2rem;
}
.env-transition {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.env-transition-inline {
  align-items: center;
}
.env-transition-side {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.375rem;
}
.env-transition-arrow {
  padding-top: 1.5rem;
  color: var(--color-text-secondary);
}
.env-transition-inline .env-transition-arrow {
  padding-top: 0;
}
@media (max-width: 640px) {
  .env-transition {
    grid-template-columns: minmax(0, 1fr);
  }
  .env-transition-arrow {
    display: none;
  }
}
.env-operation-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.env-operation-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 14px;
}
.env-operation-list li + li {
  border-top: 1px solid var(--color-border);
}
/* A Mero disclosure at the foot of a flush panel: its summary lines up with
   the list items above it, and the panel border closes it. */
.env-operations-more {
  border-block-start: 1px solid var(--color-border);
  border-block-end: 0;
}
.env-operations-more > summary {
  padding-inline: 1rem;
}
.env-operations-more > .env-operation-list {
  border-top: 1px solid var(--color-border);
}
.env-operation-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.25rem;
}
.readiness-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.readiness-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.375rem 0;
  font-size: 14px;
}
.readiness-mark {
  width: 1rem;
  flex: none;
  text-align: center;
  font-weight: 600;
  color: var(--color-text-secondary);
}
.readiness-list li[data-readiness="ready"] .readiness-mark {
  color: var(--color-success);
}
.readiness-list li[data-readiness="blocked"] .readiness-mark {
  color: var(--mero-danger);
}
.readiness-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
}
.readiness-text strong {
  font-weight: 500;
}
.env-subtable .cp-table {
  min-width: 560px;
}
.env-subtable .cp-table tbody th {
  font-weight: 500;
}
@media (max-width: 768px) {
  .env-subtable .cp-table {
    min-width: 0;
  }
}
.env-danger-summary {
  font-weight: 500;
  color: var(--mero-danger);
}
.env-focus-target:focus {
  outline: none;
}
.env-focus-target:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.env-narrow {
  max-width: 800px;
}
.env-label-note {
  font-weight: 400;
}
.env-gap-top {
  margin-top: 1rem;
}
[data-env-lifecycle-message]:empty {
  display: none;
}
.env-delete-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
}
.env-span-2 {
  grid-column: 1 / -1;
}
@media (max-width: 640px) {
  .env-delete-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
.env-record [hidden],
.env-deploy [hidden] {
  display: none !important;
}
/* A stage heading takes focus only to move the reading position. */
.env-deploy h2[tabindex="-1"]:focus {
  outline: none;
}
/* An action's outcome reads on its own line above the buttons. */
.env-deploy .form-actions:has([data-mero-action-status]) {
  flex-wrap: wrap;
}
.env-deploy .form-actions [data-mero-action-status] {
  flex-basis: 100%;
  order: -1;
}
.env-deploy .form-actions [data-mero-action-status]:empty {
  display: none;
}
/* @group releases */
.release-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.rollout-halt-reason {
  margin: 0;
  font-size: 14px;
}
.rollout-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.rollout-controls .form-hint {
  margin: 0;
}
.release-deploy [hidden] {
  display: none;
}
.rd-intro {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  font-size: 14px;
}
.rd-intro p {
  margin: 0;
}
.rd-panel-note {
  font-size: 12px;
  font-weight: 400;
}
.rd-table-wrap {
  border-top: 1px solid var(--color-border);
}
.rd-table td {
  vertical-align: top;
}
/* Mero keeps table cells on one line. Two full release IDs and the server's
   detail text wrap instead, so status, detail and operation stay on screen. */
.rd-table td.rd-transition,
.rd-table td.rd-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 10rem;
}
.rd-table td.rd-transition {
  font-size: 12px;
}
.rd-check {
  width: 2.5rem;
}
.rd-env {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  min-width: 0;
}
.rd-env strong {
  font-weight: 500;
}
.rd-env .mono,
.rd-small,
.rd-detail {
  font-size: 12px;
}
.rd-detail {
  color: var(--color-text-secondary);
}
.rd-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.rd-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 14px;
}
.rd-label-hint {
  font-weight: 400;
}
/* @group operations-access */
.op-short-id {
  font-weight: 400;
  font-size: 12px;
  margin-left: 0.25rem;
}
.op-pager {
  width: 100%;
}
.op-progress {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.op-progress:empty,
#op-stale:empty {
  display: none;
}
.op-progress-title {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}
.op-id {
  font-size: 12px;
  font-weight: 400;
}
.op-status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.op-status-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}
.op-status-text strong {
  font-size: 1rem;
}
.op-status-text span {
  font-size: 14px;
}
/* Full width: Mero caps a field that holds a meter or progress bar at 16rem. */
.cp-field-full {
  inline-size: 100%;
}
.op-percent {
  font-variant-numeric: tabular-nums;
}
.op-hint,
.mcp-text,
.notice-text {
  margin: 0;
  font-size: 14px;
}
.op-message {
  margin: 0;
}
.op-recovery {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}
.op-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.75rem;
}
.op-actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}
.op-actions-hint {
  margin: 0;
  text-align: right;
}
.op-diagnostics {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 13px;
}
.op-sub-id {
  display: block;
  font-size: 12px;
}
.op-resource {
  display: inline-flex;
  flex-direction: column;
}
.op-resource-kind {
  font-size: 12px;
}
.op-digest {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.op-digest-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.op-digest-value {
  flex: 1;
  min-width: 0;
  align-self: center;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.op-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.role-form {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.role-select {
  width: auto;
}
.role-form .mero-field-error {
  flex-basis: 100%;
  margin: 0;
  font-size: 12px;
}
.user-ban {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
}
.user-ban-note {
  font-size: 12px;
}
.users-heading {
  margin-top: 0.5rem;
}
.secret-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 14px;
}
.secret-value {
  user-select: all;
  overflow-wrap: anywhere;
}
#api-key-form-wrap[hidden] {
  display: none;
}
.token-block {
  display: block;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface-raised);
  font-size: 13px;
  overflow-wrap: anywhere;
  user-select: all;
}
.danger-text {
  color: var(--mero-danger);
}
.copy-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface-raised);
}
.copy-row-value {
  flex: 1;
  min-width: 0;
  align-self: center;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.copy-row-block {
  white-space: pre-wrap;
}
.mcp-tab-panel {
  padding-top: 0.75rem;
}
.mcp-tab-panel[hidden] {
  display: none;
}
.mcp-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}
.mcp-tools code {
  font-size: 13px;
}
.mcp-field-note {
  display: block;
  margin-top: 0.25rem;
  font-size: 14px;
}
.notice-page {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}
.login-notice {
  margin-top: 0.75rem;
}
.login-form {
  margin-top: 1rem;
}
.login-submit {
  width: 100%;
}
