/* soul-mesh admin console.
   Tokens mirror the soullogic.io design system (soulLogicMS global.css) so the
   console reads as the same product family. Fonts are self-hosted because the
   CSP allows no origin but this one. */

/* @fontsource-variable/{inter,space-grotesk,jetbrains-mono}@5.3.0, latin
   subset, variable weight. SIL OFL 1.1; licenses in fonts/. */
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* Ink and surfaces */
  --bg: #07090e;
  --bg-top: #0a0e16;
  --surface: #0f141d;
  --surface-2: #141b27;
  --surface-3: #1a2231;
  --border: #2a3342;
  --border-strong: #3a4558;

  /* Text. --text-faint is lifted from the site's #6b788d, which is under
     4.5:1 on every surface here; #7d8aa0 clears AA on --surface-3. */
  --text: #eef2f8;
  --text-muted: #97a3b6;
  --text-faint: #7d8aa0;

  /* Accent: one loud colour, used with restraint */
  --accent: #35e1f1;
  --accent-soft: rgba(53, 225, 241, 0.12);
  --accent-line: rgba(53, 225, 241, 0.32);
  --accent-2: #6b8bff;
  --on-accent: #03222a;
  --glow: rgba(53, 225, 241, 0.28);

  /* Signal */
  --ok: #43d98c;
  --ok-soft: rgba(67, 217, 140, 0.12);
  --ok-line: rgba(67, 217, 140, 0.32);
  --warn: #f4be4f;
  --warn-soft: rgba(244, 190, 79, 0.12);
  --warn-line: rgba(244, 190, 79, 0.34);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.12);
  --danger-line: rgba(251, 113, 133, 0.38);
  --on-danger: #2a0a10;

  /* Type */
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Rhythm */
  --sidebar-w: 15rem;
  --content-max: 76rem;
  --gutter: clamp(1rem, 3vw, 2.5rem);
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 120ms;
  --t: 180ms;
  --t-slow: 260ms;
}

/* ---------- reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 22rem) var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.55;
  font-feature-settings: "ss01", "cv01";
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: var(--accent);
}

img,
svg {
  display: block;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

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

[hidden] {
  display: none !important;
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-variant-ligatures: none;
}

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

.faint {
  color: var(--text-faint);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

/* ---------- shell ---------- */
/* The sidebar's panel is painted on the shell as well, so it runs the full
   height of a long page behind the sticky sidebar. */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  background: linear-gradient(90deg, var(--surface) calc(var(--sidebar-w) - 1px), var(--border) 0, var(--border) var(--sidebar-w), transparent 0);
}

.shell:has(.sidebar[hidden]) {
  background: none;
}

/* Without the sidebar (signed out, loading, failed to load) the content takes
   the full width rather than falling into the sidebar's column. */
.sidebar[hidden] + .main-col {
  grid-column: 1 / -1;
}

.main-col {
  grid-column: 2;
}

body[data-mode="signin"] .topbar,
body[data-mode="loading"] .identity {
  visibility: hidden;
}

body[data-mode="signin"] .content {
  max-width: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  padding: 1.25rem 1rem 1.5rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.25rem 0.4rem;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.brand img {
  width: 2rem;
  height: 2rem;
  flex: none;
}

.brand-name {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-name small {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0;
  color: var(--text-muted);
}

.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  min-height: 3.5rem;
  padding: 0.6rem var(--gutter);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 9, 14, 0.86);
  backdrop-filter: blur(10px);
}

.topbar-brand {
  display: none;
  margin-right: auto;
}

.identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.identity #username {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Request-in-flight indicator: a hairline along the bottom of the top bar,
   shown only while a mutation or reload is outstanding. */
.busy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--t) var(--ease);
}

.busy::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: busy 1.1s var(--ease) infinite;
}

body[data-busy] .busy {
  opacity: 1;
}

@keyframes busy {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

.content {
  width: 100%;
  max-width: var(--content-max);
  padding: clamp(1.5rem, 3vw, 2.5rem) var(--gutter) 4rem;
}

main:focus {
  outline: none;
}

/* ---------- navigation ----------
   The section list is drawn as a circuit trace, the motif of the Soul Logic
   mark: one rail per group, a node per section, the current one lit. */
.nav-group + .nav-group {
  margin-top: 1.25rem;
}

.nav-label {
  display: block;
  margin: 0 0 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-faint);
}

.nav-list {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list::before {
  content: "";
  position: absolute;
  top: 0.9rem;
  bottom: 0.9rem;
  left: 1.05rem;
  width: 1px;
  background: var(--border);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.45rem 0.6rem 0.45rem 0.6rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-node {
  position: relative;
  flex: none;
  width: 0.5625rem;
  height: 0.5625rem;
  margin-left: 0.17rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease);
}

.nav-item:hover .nav-node {
  border-color: var(--accent-line);
}

.nav-item[aria-current="page"] {
  color: var(--text);
  background: var(--surface-2);
}

.nav-item[aria-current="page"] .nav-node {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 12px var(--glow);
}

.nav-text {
  flex: 1;
  min-width: 0;
}

.nav-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.nav-flag {
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-pill);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ---------- page header ---------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-bottom: 1.75rem;
}

.page-head h1 {
  font-size: clamp(1.6rem, 2.4vw, 2rem);
}

.page-head p {
  max-width: 72ch;
  margin-top: 0.55rem;
  color: var(--text-muted);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.page-actions > .btn {
  min-height: 2.4rem;
}

.stack > * + * {
  margin-top: 1.5rem;
}

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-top) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2vw, 1.5rem);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
}

.card-desc {
  margin-top: 0.3rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  max-width: 70ch;
}

.subhead {
  margin-bottom: 0.75rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1.25rem 2rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  padding: 0.7rem 1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

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

tbody tr {
  transition: background var(--t-fast) var(--ease);
}

tbody tr:hover {
  background: rgba(20, 27, 39, 0.6);
}

@media (max-width: 1280px) {
  th,
  td {
    padding: 0.65rem 0.7rem;
  }
}

@media (max-width: 1200px) {
  :root {
    --sidebar-w: 12.5rem;
  }
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.actions {
  text-align: right;
  white-space: nowrap;
}

td.actions .btn + .btn {
  margin-left: 0.4rem;
}

.cell-main {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.cell-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.3rem;
}

.truncate {
  display: inline-block;
  max-width: clamp(10ch, 12vw, 18ch);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.lines {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

time[title] {
  cursor: help;
  text-decoration: underline dotted var(--border-strong);
  text-underline-offset: 3px;
}

/* ---------- pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.12rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
}

.pill--plain::before {
  display: none;
}

.pill--ok {
  color: var(--ok);
  border-color: var(--ok-line);
  background: var(--ok-soft);
}

.pill--warn {
  color: var(--warn);
  border-color: var(--warn-line);
  background: var(--warn-soft);
}

.pill--danger {
  color: var(--danger);
  border-color: var(--danger-line);
  background: var(--danger-soft);
}

/* Hollow dot for "off but fine" states: disabled policy, expired key. */
.pill--off::before {
  background: none;
  box-shadow: inset 0 0 0 1.5px currentColor;
}

.pill--accent {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.pill.mono {
  font-family: var(--font-mono);
  font-weight: 400;
}

.text-warn {
  color: var(--warn);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.25rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
    box-shadow var(--t) var(--ease);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--sm {
  min-height: 1.9rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.8125rem;
}

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

.btn--primary:hover:not(:disabled) {
  box-shadow: 0 8px 26px -10px var(--glow);
}

.btn--secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn--secondary:hover:not(:disabled) {
  border-color: var(--accent-line);
  color: var(--accent);
}

.btn--danger {
  background: transparent;
  border-color: var(--danger-line);
  color: var(--danger);
}

.btn--danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn--danger-solid {
  background: var(--danger);
  color: var(--on-danger);
}

.btn--danger-solid:hover:not(:disabled) {
  box-shadow: 0 8px 26px -10px rgba(251, 113, 133, 0.45);
}

.btn--quiet {
  min-height: 0;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
}

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

.btn svg {
  width: 1rem;
  height: 1rem;
  flex: none;
}

/* ---------- forms ---------- */
.form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr));
  gap: 1rem 1.25rem;
  align-items: start;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

/* Aligned to the top and offset by one label line, so a hint or an error
   under the field does not drag the button down with it. */
.form--inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
}

.form--inline > .btn,
.form--inline > .check {
  min-height: 2.4rem;
  margin-top: 1.61rem;
}

.form--inline .field {
  flex: 1 1 14rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field--wide {
  grid-column: 1 / -1;
}

.field label,
.field .label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.field .optional {
  font-weight: 400;
  color: var(--text-faint);
}

.hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.field-error {
  font-size: 0.78rem;
  color: var(--danger);
}

input[type="text"],
input[type="number"],
input[type="month"],
textarea,
select {
  width: 100%;
  min-height: 2.4rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

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

input:hover,
textarea:hover,
select:hover {
  border-color: var(--border-strong);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

input[aria-invalid="true"]:focus-visible,
textarea[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

input.mono,
textarea.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

select {
  appearance: none;
  padding-right: 2.2rem;
  /* Chevron as a data: URI, which the CSP's img-src allows. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%2397a3b6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.4rem;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.checks .check {
  min-height: 2rem;
}

/* ---------- chips (group members) ---------- */
.members {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
  padding: 0.3rem 0.4rem 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: 0.8125rem;
}

.chip-kind {
  color: var(--text-faint);
  font-size: 0.75rem;
}

.chip .btn--quiet {
  border-radius: 50%;
}

.chip .btn--quiet:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.chip--locked {
  padding-right: 0.75rem;
}

/* ---------- banner and toasts ---------- */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--danger-line);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--text);
  font-size: 0.875rem;
}

.banner-icon {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.1rem;
  color: var(--danger);
}

.banner-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toasts {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  max-width: min(26rem, calc(100vw - 2.5rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 0.75rem 0.8rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-3);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.8);
  font-size: 0.875rem;
  pointer-events: auto;
  animation: toast-in var(--t-slow) var(--ease);
}

.toast-icon {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.1rem;
  color: var(--ok);
}

.toast-text {
  flex: 1;
  overflow-wrap: anywhere;
}

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

/* ---------- states: empty, loading, error ---------- */
.state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 1.75rem 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: rgba(15, 20, 29, 0.5);
}

.state-title {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0;
}

.state p {
  max-width: 64ch;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.state--error {
  border-style: solid;
  border-color: var(--danger-line);
}

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

.state code {
  font-size: 0.8rem;
  color: var(--text);
}

.loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.skeleton span {
  height: 2.6rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------- one-time secret reveal ----------
   The only glowing element in the console: this render is the last moment the
   plaintext exists anywhere an operator can copy it from. */
.reveal {
  position: relative;
  padding: clamp(1.25rem, 2.4vw, 1.75rem);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: radial-gradient(120% 140% at 0% 0%, rgba(53, 225, 241, 0.1) 0%, transparent 55%),
    linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  box-shadow: 0 0 0 1px rgba(53, 225, 241, 0.06), 0 24px 60px -30px var(--glow);
}

.reveal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
}

.reveal-head h2 {
  font-size: 1.2rem;
}

.reveal-icon {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--accent);
}

.secret-row + .secret-row {
  margin-top: 0.85rem;
}

.secret-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.secret {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.secret code {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
  user-select: all;
}

.secret--key code {
  color: var(--accent);
  font-size: 0.95rem;
}

.reveal-body {
  margin-top: 1.1rem;
}

.reveal-warning {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  font-size: 0.875rem;
}

.reveal-warning svg {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.1rem;
  color: var(--warn);
}

.reveal-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.1rem;
}

/* ---------- confirmation dialog ---------- */
dialog.confirm {
  width: min(30rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.9);
}

dialog.confirm[open] {
  animation: dialog-in var(--t) var(--ease);
}

dialog.confirm::backdrop {
  background: rgba(3, 5, 9, 0.72);
  backdrop-filter: blur(2px);
}

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

.confirm-body {
  padding: 1.4rem 1.5rem 1.25rem;
}

.confirm-body h2 {
  font-size: 1.2rem;
}

.confirm-body p {
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.confirm-subject {
  display: inline-block;
  margin-top: 0.9rem;
}

.confirm-note {
  margin-top: 0.9rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--text);
  font-size: 0.85rem;
}

.confirm-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.9rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- billing ---------- */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.summary strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  margin-right: 0.35rem;
}

/* ---------- docs ---------- */
.docs-layout {
  display: grid;
  grid-template-columns: minmax(0, 68ch) minmax(12rem, 15rem);
  gap: 3rem;
  align-items: start;
}

.docs-toc {
  position: sticky;
  top: 5rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
  font-size: 0.8125rem;
}

.docs-toc p {
  margin-bottom: 0.5rem;
  color: var(--text-faint);
  font-weight: 500;
}

.docs-toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-toc li + li {
  margin-top: 0.4rem;
}

.docs-toc a {
  color: var(--text-muted);
  text-decoration: none;
}

.docs-toc a:hover {
  color: var(--accent);
}

.docs section + section {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.docs section {
  scroll-margin-top: 5rem;
}

.docs h2 {
  margin-bottom: 0.9rem;
  font-size: 1.3rem;
}

.docs p {
  margin-bottom: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.docs p:last-child {
  margin-bottom: 0;
}

.docs strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- sign-in ---------- */
.signin {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 8rem);
}

.signin-card {
  width: min(26rem, 100%);
  padding: 2.25rem 2rem 2rem;
  text-align: center;
}

.signin-card img {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1.25rem;
}

.signin-card h1 {
  font-size: 1.6rem;
}

.signin-card p {
  margin: 0.6rem 0 1.5rem;
  color: var(--text-muted);
}

.signin-card .btn {
  width: 100%;
  min-height: 2.75rem;
}

.signin-alt {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.signin-alt:hover {
  color: var(--accent);
}

/* ---------- key/value lists (identity provider status) ---------- */
.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.6rem 1.75rem;
  margin: 0;
  font-size: 0.875rem;
}

.kv-row {
  display: contents;
}

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

.kv dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

/* ---------- identity provider setup page ---------- */
textarea {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.45;
}

input[type="file"] {
  width: 100%;
  padding: 0.55rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
}

input[type="file"]::file-selector-button {
  margin-right: 0.85rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

input[type="file"][aria-invalid="true"] {
  border-color: var(--danger);
}

.setup-top {
  display: flex;
  align-items: center;
  padding: 0.9rem var(--gutter);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 9, 14, 0.7);
}

.setup-top .brand {
  margin: 0;
}

.setup {
  max-width: 52rem;
  margin: 0 auto;
  padding: clamp(1.75rem, 4vw, 3rem) var(--gutter) 5rem;
}

.setup:focus {
  outline: none;
}

.setup-intro {
  margin-bottom: 0;
}

.setup-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  position: relative;
  padding-left: 2.9rem;
  counter-increment: step;
}

.steps > li + li {
  margin-top: 1.35rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--border);
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
}

.steps > li + li::before {
  top: 1.35rem;
}

.steps h3 {
  padding-top: 0.3rem;
  font-size: 1.02rem;
}

.steps p {
  margin-top: 0.4rem;
  max-width: 68ch;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.steps strong {
  color: var(--text);
  font-weight: 600;
}

.crumbs {
  display: inline;
  color: var(--text);
  font-weight: 500;
}

.crumb-sep {
  display: inline;
  margin: 0 0.35rem;
  color: var(--accent);
}

.values {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.value-row {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem 0.75rem;
}

.value-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.value-row code {
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
  user-select: all;
}

.value-row .btn {
  min-height: 2.25rem;
}

.seg {
  display: inline-flex;
  align-self: flex-start;
  flex-wrap: wrap;
  gap: 0.2rem;
  padding: 0.22rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
}

.seg label {
  position: relative;
  padding: 0.42rem 0.95rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg label:has(input:checked) {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

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

.form-sub {
  display: grid;
  gap: 1rem;
}

.card > .banner {
  margin-bottom: 1.25rem;
}

.reveal--done {
  border-color: var(--ok-line);
  background: radial-gradient(120% 140% at 0% 0%, rgba(67, 217, 140, 0.1) 0%, transparent 55%),
    linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  box-shadow: 0 0 0 1px rgba(67, 217, 140, 0.06), 0 24px 60px -30px rgba(67, 217, 140, 0.25);
}

.reveal--done .reveal-icon {
  color: var(--ok);
}

.reveal-text {
  margin: 0.75rem 0 1.1rem;
  max-width: 68ch;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .value-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .value-label {
    grid-column: 1 / -1;
  }
  .kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.2rem;
  }
  .kv dd {
    margin-bottom: 0.55rem;
  }
}

/* ---------- narrow screens ---------- */
@media (max-width: 1100px) {
  .docs-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .docs-toc {
    display: none;
  }
}

/* Below a narrow laptop the sidebar becomes a scrolling strip under the top
   bar; the trace motif needs vertical room, so it gives way to an underline. */
@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    background: none;
  }
  /* The top bar comes before the section strip on a narrow screen. */
  .main-col {
    display: contents;
  }
  .topbar {
    order: -1;
  }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 11;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 0;
    padding: 0 var(--gutter);
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand {
    display: none;
  }
  .topbar {
    position: static;
  }
  .topbar-brand {
    display: flex;
  }
  #tabs {
    display: flex;
    gap: 0.25rem;
  }
  .nav-group + .nav-group {
    margin-top: 0;
  }
  .nav-label,
  .nav-list::before,
  .nav-node {
    display: none;
  }
  .nav-list {
    display: flex;
  }
  .nav-item {
    width: auto;
    padding: 0.85rem 0.7rem;
    border-radius: 0;
    white-space: nowrap;
    box-shadow: inset 0 -2px 0 transparent;
  }
  .nav-item:hover {
    background: none;
  }
  .nav-item[aria-current="page"] {
    background: none;
    box-shadow: inset 0 -2px 0 var(--accent);
  }
  .identity .who {
    display: none;
  }
}
