/* releases.gestalt — Admin-UI (ADR-011, F13).
 *
 * Series design language. The Studio's back-office apps (ops.gestalt,
 * releases.gestalt, …) are one product family and are meant to be recognised as
 * such: same monochrome slate base, same hairline borders, one single elevation
 * (shadow-card), colour used ONLY as status semantics, same shell (fixed 240 px
 * sidebar + translucent sticky topbar + breadcrumb), same control metrics.
 *
 * Source of truth for the language:
 *   ops.gestalt  client/tailwind.config.js   (brand scale, status, shadow, radius)
 *   ops.gestalt  client/src/index.css        (CSS custom properties, focus, scrollbar)
 *   ops.gestalt  docs/design/design_specification_v1.md §5.1 (status semantics)
 * The contract itself is documented here: docs/ux/design-series.md.
 *
 * Still hand-written on purpose: no build step, no framework, no CSS preprocessor
 * (ADR-011 — a bundler for one stylesheet would be over-architecture).
 */

/* ─── 1. Tokens ─────────────────────────────────────────────────────────────
 * Names follow the ops.gestalt palette one-to-one (brand-N = the monochrome
 * scale), so a value can be compared between the two apps without a lookup. */

:root {
  color-scheme: light;

  /* Monochrome brand scale (ops: tailwind `brand`, slate-based) */
  --brand-50: #f8fafc;
  --brand-100: #f1f5f9;
  --brand-200: #e2e8f0;
  --brand-300: #cbd5e1;
  --brand-400: #94a3b8;
  --brand-500: #64748b;
  --brand-600: #475569;
  --brand-700: #334155;
  --brand-800: #1e293b;
  --brand-900: #0f172a;

  /* Surfaces and ink */
  --bg-app: var(--brand-50);
  --bg-surface: #ffffff;
  --bg-subtle: var(--brand-100);
  --bg-hover: var(--brand-50);
  --bg-elevated: rgba(
    255,
    255,
    255,
    0.8
  ); /* topbar: blur comes from the layer */
  --ink: var(--brand-800);
  --ink-strong: var(--brand-900);
  --ink-muted: var(--brand-500);
  --ink-faint: var(--brand-400);
  --line: var(--brand-200);
  --line-soft: var(--brand-100);
  --line-strong: var(--brand-300);

  /* Primary action: monochrome, never a brand hue (ops PrimaryButton) */
  --btn-primary-bg: var(--brand-600);
  --btn-primary-bg-hover: var(--brand-700);
  --btn-primary-ink: #ffffff;
  --btn-ghost-ink: var(--brand-500);
  --btn-ghost-ink-hover: var(--brand-700);

  /* Status semantics (design_specification_v1 §5.1). These four hues are the
   * only colours in the interface: up / degraded / down / maintenance. */
  --status-up: #10b981;
  --status-degraded: #f59e0b;
  --status-down: #ef4444;
  --status-info: #3b82f6;

  --ok-bg: #ecfdf5;
  --ok-ink: #047857;
  --ok-ring: rgba(5, 150, 105, 0.2);
  --warn-bg: #fffbeb;
  --warn-ink: #b45309;
  --warn-ring: rgba(217, 119, 6, 0.2);
  --bad-bg: #fef2f2;
  --bad-ink: #b91c1c;
  --bad-ring: rgba(220, 38, 38, 0.2);
  --info-bg: #eff6ff;
  --info-ink: #1d4ed8;
  --info-ring: rgba(37, 99, 235, 0.2);
  --neutral-bg: var(--brand-100);
  --neutral-ink: var(--brand-600);
  --neutral-ring: rgba(148, 163, 184, 0.25);

  --danger: #dc2626;
  --danger-hover: #b91c1c;

  /* Metrics (ops: w-60 sidebar, h-14 topbar, px-8 main, gap-4 between blocks) */
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --content-max: 1120px;
  --content-pad: 32px;
  --stack: 16px;

  /* Radii: 12 cards, 8 controls, pill for status */
  --radius-card: 12px;
  --radius-control: 8px;
  --radius-pill: 999px;

  /* One elevation only — hairline-soft, never heavy (ops shadow.card) */
  --shadow-card: 0 1px 2px 0 rgb(15 23 42 / 0.05);
  --shadow-popover:
    0 12px 32px -12px rgb(15 23 42 / 0.16), 0 2px 8px -2px rgb(15 23 42 / 0.06);

  --font-sans:
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Dark mode: the same semantics on the slate-900 base (ops dark palette).
 * Driven by the OS setting only — releases.gestalt ships no theme toggle,
 * because JS on this surface is limited to clipboard + confirm (ADR-011). */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg-app: var(--brand-900);
    --bg-surface: #1e293b;
    --bg-subtle: rgba(148, 163, 184, 0.12);
    --bg-hover: rgba(148, 163, 184, 0.08);
    --bg-elevated: rgba(15, 23, 42, 0.8);
    --ink: var(--brand-200);
    --ink-strong: #f8fafc;
    --ink-muted: var(--brand-400);
    --ink-faint: var(--brand-500);
    --line: #334155;
    --line-soft: rgba(51, 65, 85, 0.6);
    --line-strong: #475569;

    --btn-primary-bg: var(--brand-200);
    --btn-primary-bg-hover: #e2e8f0;
    --btn-primary-ink: var(--brand-900);
    --btn-ghost-ink: var(--brand-400);
    --btn-ghost-ink-hover: var(--brand-200);

    --ok-bg: rgba(16, 185, 129, 0.1);
    --ok-ink: #34d399;
    --ok-ring: rgba(52, 211, 153, 0.22);
    --warn-bg: rgba(245, 158, 11, 0.1);
    --warn-ink: #fbbf24;
    --warn-ring: rgba(251, 191, 36, 0.22);
    --bad-bg: rgba(239, 68, 68, 0.1);
    --bad-ink: #f87171;
    --bad-ring: rgba(248, 113, 113, 0.22);
    --info-bg: rgba(59, 130, 246, 0.1);
    --info-ink: #60a5fa;
    --info-ring: rgba(96, 165, 250, 0.22);
    --neutral-bg: rgba(148, 163, 184, 0.12);
    --neutral-ink: var(--brand-400);
    --neutral-ring: rgba(148, 163, 184, 0.22);

    --danger: #ef4444;
    --danger-hover: #dc2626;

    --shadow-card: 0 1px 2px 0 rgb(2 6 23 / 0.4);
  }
}

/* ─── 2. Base ────────────────────────────────────────────────────────────── */

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgb(15 23 42 / 0.12);
}

@media (prefers-color-scheme: dark) {
  ::selection {
    background: rgb(226 232 240 / 0.2);
  }
}

a {
  color: var(--ink-strong);
  text-decoration-color: var(--line-strong);
  text-underline-offset: 2px;
}

/* Keyboard users get the target first; nobody else sees it (ops Layout) */
.skip {
  position: absolute;
  left: -9999px;
  z-index: 60;
  padding: 8px 16px;
  border-radius: var(--radius-control);
  background: var(--ink-strong);
  color: var(--bg-surface);
  font-weight: 500;
  text-decoration: none;
}

.skip:focus {
  left: 16px;
  top: 16px;
}

a:hover {
  text-decoration-color: currentColor;
}

/* One focus ring for the whole family (ops index.css) */
:focus-visible {
  outline: 2px solid var(--ink-faint);
  outline-offset: 2px;
  border-radius: 4px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

/* ─── 3. Shell: sidebar + topbar + main ─────────────────────────────────── */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--line);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
}

/* Series signature: a 28 px rounded tile, inverse fill, one stroke glyph */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-control);
  background: var(--ink-strong);
  color: var(--bg-surface);
  flex-shrink: 0;
}

.brand-mark svg {
  width: 16px;
  height: 16px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nav {
  padding: 12px;
  display: grid;
  gap: 2px;
}

.nav-group + .nav-group {
  margin-top: 16px;
}

.nav-group-label {
  padding: 0 12px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-control);
  color: var(--ink-muted);
  font-size: 14px;
  text-decoration: none;
  transition:
    background-color 120ms ease,
    color 120ms ease;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--ink);
  text-decoration: none;
}

.nav-item.active {
  background: var(--bg-subtle);
  color: var(--ink-strong);
  font-weight: 500;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.who {
  display: grid;
  gap: 2px;
  padding: 0 12px 4px;
  min-width: 0;
}

.who-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.who-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: var(--ink-muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    color 120ms ease;
}

.signout svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.signout:hover {
  background: var(--bg-hover);
  color: var(--ink);
}

.version {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  flex-shrink: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--topbar-h);
  margin-left: var(--sidebar-w);
  padding: 0 var(--content-pad);
  background: var(--bg-elevated);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.env {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  background: var(--bg-surface);
}

.main {
  margin-left: var(--sidebar-w);
  padding: 20px var(--content-pad) 48px;
  max-width: calc(
    var(--content-max) +
    var(--sidebar-w) +
    var(--content-pad) *
    2
  );
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  min-width: 0;
}

.crumbs > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumbs a {
  color: var(--ink-muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--ink);
}

.crumbs .sep {
  color: var(--brand-300);
}

.crumbs [aria-current] {
  color: var(--ink);
  font-weight: 500;
}

/* ─── 4. Page header ─────────────────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 20px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--ink-strong);
}

.page-head .actions {
  flex-shrink: 0;
  padding-top: 2px;
}

/* An identifier inside a title stays monospaced but keeps the hierarchy. */
.page-head h1 .mono {
  font-size: 0.72em;
  color: var(--ink-muted);
}

.page-sub {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-muted);
}

h2 {
  margin: 32px 0 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-strong);
}

h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-strong);
}

.muted {
  color: var(--ink-muted);
}

.hint {
  margin: 0 0 20px;
  color: var(--ink-muted);
  max-width: 70ch;
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ─── 5. Cards ──────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 24px;
  margin: 0 0 var(--stack);
}

.card > :first-child {
  margin-top: 0;
}
.card > :last-child {
  margin-bottom: 0;
}

.card-head {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-strong);
}

.card-body {
  padding: 16px 24px;
}

/* Key/value reading of a detail page (ops: InstanceInfoGrid) */
.kv {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 8px 24px;
  font-size: 14px;
}

.kv dt {
  color: var(--ink-muted);
}

.kv dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* Stat cards (ops Dashboard): label, value, sub-line */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.cards .card {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 20px 24px;
  margin: 0;
}

.card-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
}

.card-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--ink-strong);
}

.card-sub {
  font-size: 12px;
  color: var(--ink-muted);
}

/* Audit I-2.3: the counter is the entry point into the filtered list. */
.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.card-link .card-label,
.card-link .card-value {
  pointer-events: none;
  transition: color 120ms ease;
}

.card-link:hover {
  text-decoration: none;
}

.card-link:hover .card-label,
.card-link:hover .card-value {
  color: var(--ink-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ─── 6. Buttons ────────────────────────────────────────────────────────── */

a.button,
button,
button.button,
button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

a.button:hover,
button.button:hover,
button.primary:hover {
  background: var(--btn-primary-bg-hover);
  text-decoration: none;
}

button:disabled,
.button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Secondary: hairline card button (ops RefreshButton) */
a.secondary,
button.secondary {
  background: var(--bg-surface);
  border-color: var(--line);
  color: var(--ink-muted);
  box-shadow: var(--shadow-card);
}

a.secondary:hover,
button.secondary:hover {
  background: var(--bg-hover);
  color: var(--ink);
}

/* Quiet: no chrome, reads as a link-action */
a.ghost,
button.ghost,
.button.ghost {
  background: none;
  border-color: transparent;
  color: var(--btn-ghost-ink);
  box-shadow: none;
}

a.ghost:hover,
button.ghost:hover {
  background: var(--bg-hover);
  color: var(--btn-ghost-ink-hover);
}

/* Destructive: the only saturated red in the surface */
a.button.danger,
button.button.danger,
button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

a.button.danger:hover,
button.button.danger:hover,
button.danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.actions form {
  margin: 0;
}

/* ─── 7. Forms ──────────────────────────────────────────────────────────── */

form.stack {
  display: grid;
  gap: 16px;
  max-width: 520px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 500;
  color: var(--ink);
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="date"],
input[type="search"],
select,
textarea {
  font: inherit;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--bg-surface);
  color: var(--ink);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.25);
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-faint);
}

select:invalid,
select option[disabled] {
  color: var(--ink-faint);
}

.field-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 400;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px 20px;
  display: grid;
  gap: 12px;
  background: var(--bg-surface);
}

legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}

/* Filter toolbar above lists */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.filters input[type="text"],
.filters input[type="date"],
.filters select {
  width: auto;
  max-width: 240px;
  padding: 8px 12px;
}

.filters input.wide {
  max-width: 280px;
}

/* ─── 8. Flash / alerts ─────────────────────────────────────────────────── */

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  margin-bottom: 20px;
  font-size: 14px;
  max-width: 80ch;
}

.flash.error {
  background: var(--bad-bg);
  border-color: var(--bad-ring);
  color: var(--bad-ink);
}

/* A notice here always means "read this now" (one-time secrets): amber, the
 * series' degraded hue — not a confirmation green. */
.flash.notice {
  background: var(--warn-bg);
  border-color: var(--warn-ring);
  color: var(--warn-ink);
}

.flash.info {
  background: var(--info-bg);
  border-color: var(--info-ring);
  color: var(--info-ink);
}

/* ─── 9. Tables ─────────────────────────────────────────────────────────── */

/* The frame lives on the wrapper so the corner radius survives the table. */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  overflow-x: auto;
  margin-bottom: var(--stack);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  padding: 12px 24px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
}

.table thead {
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  color: var(--ink);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr {
  transition: background-color 120ms ease;
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

/* Empty state inside a table (ops EmptyState, without the icon) */
.table td[colspan] {
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-muted);
}

/* Table inside a card (detail pages): the card is already the frame. */
.card .table th:first-child,
.card .table td:first-child {
  padding-left: 0;
}

.card .table th:last-child,
.card .table td:last-child {
  padding-right: 0;
}

.card .table td {
  padding-top: 10px;
  padding-bottom: 10px;
}

/* ─── 10. Status badges ─────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--neutral-bg);
  color: var(--neutral-ink);
  box-shadow: inset 0 0 0 1px var(--neutral-ring);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: middle;
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
  box-shadow: inset 0 0 0 1px var(--ok-ring);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
  box-shadow: inset 0 0 0 1px var(--warn-ring);
}

.badge.bad {
  background: var(--bad-bg);
  color: var(--bad-ink);
  box-shadow: inset 0 0 0 1px var(--bad-ring);
}

.badge.info {
  background: var(--info-bg);
  color: var(--info-ink);
  box-shadow: inset 0 0 0 1px var(--info-ring);
}

/* Leading status dot, as in ops lists */
.badge.dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── 11. Secrets, hashes, JSON ─────────────────────────────────────────── */

/* One-time output: the block is meant to be selected and copied, once. */
.secret {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-subtle);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: 14px 16px;
  display: block;
  word-break: break-all;
  user-select: all;
  margin: 12px 0;
}

.copy-inline {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.6;
  cursor: pointer;
  transition:
    color 120ms ease,
    border-color 120ms ease;
}

.copy-inline:hover {
  color: var(--ink-strong);
  border-color: var(--line-strong);
}

.json {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 20px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 var(--stack);
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-subtle);
  border-radius: 4px;
  padding: 1px 5px;
}

.license-id {
  margin: 0 0 16px;
  color: var(--ink-muted);
}

/* ─── 12. Pagination ────────────────────────────────────────────────────── */

.pagination {
  margin-top: 24px;
}

.pagination ul {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-control);
  font-size: 14px;
  color: var(--ink-muted);
  text-decoration: none;
  transition:
    background-color 120ms ease,
    color 120ms ease;
}

.pagination a:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}

.pagination .active span,
.pagination li.active a {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  font-weight: 500;
}

.pagination .disabled span,
.pagination li.disabled span {
  color: var(--ink-faint);
  cursor: default;
  background: none;
}

/* ─── 13. Auth surface ──────────────────────────────────────────────────── */

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-inner {
  width: 100%;
  max-width: 384px;
}

.auth-brand {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
  margin-bottom: 32px;
}

.auth-brand .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-card);
  margin-bottom: 12px;
}

.auth-brand .brand-mark svg {
  width: 20px;
  height: 20px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink-strong);
}

.auth-brand p {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-muted);
}

.login-card {
  padding: 24px;
}

.auth-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 0;
  color: var(--ink-faint);
}

.login-card form {
  gap: 16px;
}

.login-card .button,
.login-card button[type="submit"] {
  width: 100%;
}

/* ─── 14. Responsive ────────────────────────────────────────────────────── */

/* Below the sidebar breakpoint the rail becomes a top strip. ops.gestalt uses
 * a JS drawer here; this surface keeps JS to clipboard + confirm (ADR-011), so
 * the same content reflows with CSS only. */
@media (max-width: 1023px) {
  :root {
    --content-pad: 20px;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-scroll {
    overflow: visible;
  }

  .nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 12px;
  }

  .nav-group {
    display: flex;
    gap: 4px;
  }

  .nav-group + .nav-group {
    margin-top: 0;
    padding-left: 8px;
    border-left: 1px solid var(--line);
  }

  .nav-group-label,
  .who,
  .version {
    display: none;
  }

  .nav-item {
    padding: 8px 10px;
    white-space: nowrap;
  }

  .sidebar-footer {
    margin-top: 0;
    border-top: 0;
    padding: 0 12px 8px;
  }

  .topbar,
  .main {
    margin-left: 0;
  }

  .topbar {
    position: static;
    padding: 0 var(--content-pad);
  }
}

@media (max-width: 700px) {
  /* Keep the columns and scroll sideways instead of crushing every cell. */
  .table {
    min-width: 720px;
  }

  .table th,
  .table td {
    padding: 12px 14px;
  }
}

@media (max-width: 640px) {
  /* ops index.css: larger touch targets, no iOS zoom-on-focus */
  button,
  [role="button"],
  a {
    min-height: 40px;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .page-head h1 {
    font-size: 20px;
  }

  .card,
  .card-head,
  .card-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .table th,
  .table td {
    padding-left: 16px;
    padding-right: 16px;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .kv dd {
    margin-bottom: 12px;
  }
}

@media print {
  .sidebar,
  .topbar {
    display: none;
  }
  .main {
    margin: 0;
    padding: 0;
  }
}
