/* Shared portal design for public and authenticated pages. Self-hosted assets,
 * system fonts, responsive layouts and visible keyboard focus in both themes.
 */

:root {
  color-scheme: light dark;

  /* Cream page, charcoal text, maroon for anything that acts. */
  --portal-bg: #f2f0ec;
  --portal-surface: #fffdf9;
  --portal-border: #b1a5ab;
  --portal-text: #27222a;
  --portal-muted: #615864;
  --portal-accent: #60032a;
  --portal-accent-text: #fffaf3;
  --portal-focus: #ec003e;
  --portal-danger: #ba0031;
  --portal-space: 1rem;
  /* The brand rounds generously; buttons are pills and panels are soft. */
  --portal-radius: 0.5rem;
  --portal-radius-pill: 100vw;
  /*
   * Two widths, because "full width" and "readable" are different problems.
   *
   * The shell is how wide the page may get. The measure is how wide a line of
   * prose may get, and it stays: a paragraph run to 1600px is not a
   * spacious design, it is an unreadable one. So the shell widens and prose
   * keeps its own bound inside it, which is what lets cards, tables and
   * side-by-side detail use the room a desktop actually has.
   */
  --portal-shell: 78rem;
  --portal-measure: 68ch;
  --portal-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  /* The brand's own fallback for its display face. */
  --portal-font-display: var(--portal-font);
}

/* The same dark palette applies before and after sign-in. */
@media (prefers-color-scheme: dark) {
  :root {
    --portal-bg: #201a21;
    --portal-surface: #2c242c;
    --portal-border: #8a7787;
    --portal-text: #f6edf3;
    --portal-muted: #cbb9c8;
    --portal-accent: #efc4d5;
    --portal-accent-text: #350a1e;
    /* Red on maroon is too close to read as a focus ring; sand is not. */
    --portal-focus: #cdb197;
    --portal-danger: #ff9d9d;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Never below the browser default, so a user's own text size is respected. */
  font-size: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--portal-bg);
  color: var(--portal-text);
  font-family: var(--portal-font);
  font-size: 1rem;
  /* The brand's own "loose" tracking token, 0.025em. */
  letter-spacing: 0.025em;
  line-height: 1.55;
}

/* Reachable by keyboard only until focused, then fully visible. */
.portal-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 1rem;
  background: var(--portal-accent);
  color: var(--portal-accent-text);
  z-index: 10;
}

.portal-skip-link:focus {
  left: 0;
}

.portal-page {
  max-width: var(--portal-shell);
  margin: 0 auto;
  padding: calc(var(--portal-space) * 1.5) var(--portal-space)
    calc(var(--portal-space) * 3);
}

/*
 * Prose keeps the measure the shell gave up.
 *
 * Applied to the paragraph rather than the container so a panel can hold both a
 * sentence and a full-width grid without either fighting the other. Anything
 * that is not a line of text — a card grid, a settings block, a table — is
 * deliberately not bounded here.
 */
.portal-page p,
.portal-page .portal-steps > li {
  max-width: var(--portal-measure);
}

/* A block that is structure rather than prose takes the width it is given. */
.portal-page .portal-setup,
.portal-page .portal-actions {
  max-width: none;
}

/*
 * The masthead carries the wordmark and is the way back to the start from every
 * page. It is a link, not a heading, so the one `h1` a page owns stays its own.
 */
.portal-masthead {
  border-bottom: 1.5px solid var(--portal-border);
  padding-bottom: 0.75rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: calc(var(--portal-space) * 1.5);
}

.portal-wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  text-decoration: none;
  color: var(--portal-text);
}

.portal-wordmark:hover .portal-wordmark__name,
.portal-wordmark:focus-visible .portal-wordmark__name {
  color: var(--portal-accent);
}

/*
 * The mark inherits `color`, so it is maroon on cream and cream on maroon with
 * no second asset and no theme-specific copy.
 */
.portal-wordmark__mark {
  display: block;
  color: var(--portal-accent);
}

.portal-wordmark__mark svg {
  display: block;
  width: 6.5rem;
  height: auto;
}

/*
 * Sentence case, not capitals. The brand site uses no uppercase element
 * anywhere, and small uppercase text is also harder to read.
 */
.portal-wordmark__product {
  font-size: 0.9375rem;
  color: var(--portal-muted);
}

/* Present for assistive technology, absent for everybody else. */
.portal-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.portal-header {
  border-bottom: 1px solid var(--portal-border);
  padding-bottom: var(--portal-space);
  margin-bottom: calc(var(--portal-space) * 1.5);
}

/*
 * Headings use the display face at the brand's own heading settings: normal
 * tracking and 1.3 leading. The tight tracking token exists on the site but is
 * not what its headings use.
 */
.portal-header h1 {
  font-family: var(--portal-font-display);
  font-size: 1.9rem;
  line-height: 1.3;
  letter-spacing: normal;
  margin: 0 0 0.25rem;
}

.portal-lede {
  color: var(--portal-muted);
  margin: 0;
}

.portal-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--portal-space);
  margin: var(--portal-space) 0 0;
  padding: 0;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin: calc(var(--portal-space) * 2) 0 var(--portal-space);
}

h3 {
  font-size: 1.05rem;
  margin: calc(var(--portal-space) * 1.5) 0 0.25rem;
}

p {
  margin: 0 0 var(--portal-space);
}

a {
  color: var(--portal-accent);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* Focus is never removed; it is made obvious. */
:focus-visible {
  outline: 3px solid var(--portal-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.portal-steps {
  list-style: none;
  counter-reset: portal-step;
  margin: 0;
  padding: 0;
}

.portal-steps > li {
  counter-increment: portal-step;
  position: relative;
  padding: var(--portal-space) 0 var(--portal-space) 2.75rem;
  border-top: 1px solid var(--portal-border);
}

.portal-steps > li::before {
  content: counter(portal-step);
  position: absolute;
  left: 0;
  top: var(--portal-space);
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--portal-accent);
  color: var(--portal-accent-text);
  font-weight: 600;
  font-size: 0.95rem;
}

.portal-steps h3 {
  margin-top: 0;
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--portal-space);
  align-items: center;
  margin: calc(var(--portal-space) * 1.5) 0;
}

/* The brand's calls to action are pills. */
.portal-button {
  border-radius: var(--portal-radius-pill);
  display: inline-block;
  /* Comfortably above the 24x24 CSS-pixel minimum target size. */
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.6rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--portal-radius);
  background: var(--portal-accent);
  color: var(--portal-accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.portal-button--secondary {
  background: transparent;
  color: var(--portal-text);
  border-color: var(--portal-border);
}

.portal-hint {
  color: var(--portal-muted);
  font-size: 0.95rem;
  margin: 0;
}

.portal-panel {
  background: var(--portal-surface);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  padding: var(--portal-space);
  margin: 0 0 var(--portal-space);
}

/*
 * The generated client settings block.
 *
 * It had no rule at all, so it fell back to the browser default `pre`: no
 * wrapping and no overflow handling, and the longest line — a binding id inside
 * an http_headers map — ran straight out of its panel and off the page.
 *
 * The lines are not free to wrap. This is TOML a person pastes into a client,
 * and a soft wrap in the middle of a quoted value reads as though the value
 * contains a newline. So the block scrolls within itself instead, which keeps
 * the settings verbatim and keeps the sideways scroll off the document.
 */
.portal-setup {
  margin: 0 0 var(--portal-space);
  padding: var(--portal-space);
  background: var(--portal-bg);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  /* `max-width` rather than `width`: the panel is the bound, not the content. */
  max-width: 100%;
  overflow-x: auto;
  /* Scrolling is only reachable by keyboard if the region can hold focus; the
     markup already sets tabindex, and this keeps that focus visible. */
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9375rem;
  line-height: 1.5;
  tab-size: 2;
}

.portal-status {
  font-weight: 600;
}

.portal-status--unavailable {
  color: var(--portal-danger);
}

.portal-footer {
  margin-top: calc(var(--portal-space) * 3);
  padding-top: var(--portal-space);
  border-top: 1px solid var(--portal-border);
  color: var(--portal-muted);
  font-size: 0.95rem;
}

.portal-footer ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--portal-space);
  margin: 0;
  padding: 0;
}

.portal-colophon {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem;
  margin: var(--portal-space) 0 0;
  font-size: 0.875rem;
}

.portal-copyright {
  color: var(--portal-muted);
}

/* Wider viewports get more breathing room, not a different structure. */
@media (min-width: 40rem) {
  .portal-page {
    padding: calc(var(--portal-space) * 2.5) calc(var(--portal-space) * 2)
      calc(var(--portal-space) * 4);
  }

  .portal-header h1 {
    font-size: 2rem;
  }
}

/*
 * A desktop gets a desktop's page.
 *
 * The type scale grows once, at the width where a heading has room to be a
 * heading, and the masthead separates from the content it sits above. Nothing
 * reflows into a different structure: a narrow window and a wide one show the
 * same page with different amounts of room, which is what keeps the phone-width
 * and keyboard journeys meaningful at every size.
 */
@media (min-width: 64rem) {
  .portal-page {
    padding: calc(var(--portal-space) * 3) calc(var(--portal-space) * 2.5)
      calc(var(--portal-space) * 5);
  }

  .portal-header h1 {
    font-size: 2.6rem;
  }

  .portal-header {
    margin-bottom: calc(var(--portal-space) * 2);
  }

  .portal-lede {
    font-size: 1.0625rem;
  }

  .portal-masthead {
    margin-bottom: calc(var(--portal-space) * 2.5);
    padding-bottom: var(--portal-space);
  }

  /*
   * The detail page reads as two columns: what this connection is on the left,
   * what can be done to it on the right. `start` alignment rather than stretch,
   * so a short panel does not grow to match a tall one.
   */
  .portal-detail {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: calc(var(--portal-space) * 2);
    align-items: start;
  }

  .portal-detail > * {
    margin-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Connection management ---------------------------------------------------- */

/*
 * Connections tile rather than stack.
 *
 * `auto-fill` with a minimum, so one connection is a card of honest size rather
 * than a band across the whole window, and a dozen fill the row. The minimum is
 * wide enough for the longest fact label and its value on one line.
 */
/*
 * Connections tile rather than stack, but only where there is room.
 *
 * One column below the breakpoint, a track-based grid above it. The breakpoint
 * does the narrow-screen work that `minmax(min(22rem, 100%), 1fr)` would
 * otherwise do, and is preferred here only because it states the intent
 * plainly: below this width, one column.
 *
 * A row did once collapse to a single full-width track with two empty ones
 * beside it, and the percentage form was suspected. That could not be
 * reproduced in isolation — both forms size identically — so the cause is
 * unknown and is not being blamed on the percentage. The assertion that no
 * track is empty lives in the browser journey precisely because the failure was
 * observed once and is not understood.
 */
.portal-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--portal-space);
  align-items: start;
}

@media (min-width: 56rem) {
  .portal-cards {
    grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
  }
}

.portal-cards > li {
  margin: 0;
}

.portal-cards h3 {
  margin-top: 0;
}

.portal-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem var(--portal-space);
  margin: 0 0 var(--portal-space);
}

.portal-facts dt {
  color: var(--portal-muted);
}

.portal-facts dd {
  margin: 0;
}

.portal-form {
  margin: 0 0 calc(var(--portal-space) * 2);
}

.portal-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.35rem 1.5rem;
}

.portal-summary dt { color: var(--portal-muted); }
.portal-summary dd { margin: 0 0 0.8rem; min-width: 0; overflow-wrap: anywhere; }
.portal-panel p { overflow-wrap: anywhere; }
.portal-form > label { display: block; font-weight: 600; margin-top: 1rem; }
.portal-form > input:not([type="hidden"]),
.portal-form > textarea {
  display: block;
  width: 100%;
  max-width: 42rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  margin: 0.4rem 0 1rem;
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  background: var(--portal-bg);
  color: var(--portal-text);
  font: inherit;
}
.portal-form > textarea { min-height: 5rem; resize: vertical; }

@media (min-width: 40rem) {
  .portal-summary { grid-template-columns: minmax(9rem, 14rem) minmax(0, 1fr); }
}

.portal-field {
  display: grid;
  gap: 0.25rem;
  margin: 0 0 var(--portal-space);
}

.portal-field label {
  font-weight: 600;
}

.portal-field input,
.portal-field select {
  /* Comfortably above the minimum target size, and never below 16px so a
     mobile browser does not zoom the page when the field is focused. */
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  color: var(--portal-text);
  background: var(--portal-bg);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
}

.portal-fieldset {
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  padding: var(--portal-space);
  margin: 0 0 var(--portal-space);
}

.portal-fieldset legend {
  padding: 0 0.5rem;
  font-weight: 600;
}

@media (min-width: 40rem) {
  .portal-cards {
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  }
}

/* Application workspace: compact chrome, deliberate columns and local dialogs. */
[hidden] { display: none !important; }
.portal-breadcrumbs { margin: 0 0 1rem; font-size: 0.875rem; }
.portal-breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; margin: 0; }
.portal-breadcrumbs li { display: flex; gap: 0.5rem; min-width: 0; overflow-wrap: anywhere; }
.portal-breadcrumbs li + li::before { content: "/"; color: var(--portal-muted); }
.portal-breadcrumbs a { text-decoration: none; }
.portal-breadcrumbs [aria-current] { color: var(--portal-muted); }
.portal-ui {
  letter-spacing: 0;
  line-height: 1.45;
  font-size: 0.9375rem;
}
.portal-ui .portal-page { max-width: none; min-height: 100dvh; padding: 0; display: flex; flex-direction: column; }
.portal-ui .portal-masthead { margin: 0; padding: 0.8rem 1.75rem; align-items: center; gap: 2rem; background: var(--portal-surface); border-bottom-width: 1px; }
.portal-ui .portal-wordmark { display: flex; flex-direction: row; align-items: center; gap: 1rem; }
.portal-ui .portal-wordmark__mark svg { width: 5.25rem; }
.portal-app-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 1.5rem; }
.portal-app-nav a { font-weight: 600; text-decoration: none; }
.portal-account { margin-left: auto; font-size: 0.8125rem; color: var(--portal-muted); overflow-wrap: anywhere; }
.portal-ui main { padding: 1.2rem 1.75rem 1.5rem; flex: 1; min-width: 0; }
.portal-ui h1 { font-family: var(--portal-font); font-size: clamp(1.5rem, 2vw, 2rem); line-height: 1.2; letter-spacing: -0.025em; margin: 0; }
.portal-ui h2 { font-family: var(--portal-font); font-size: 1.125rem; line-height: 1.3; margin: 0 0 0.75rem; }
.portal-ui h3 { font-size: 1rem; margin: 0 0 0.5rem; }
.portal-ui .portal-header { margin: 0 0 1.25rem; padding: 0; border: 0; }
.portal-ui .portal-lede { margin: 0.5rem 0 0; font-size: 0.9375rem; color: var(--portal-muted); }
.portal-ui .portal-header > .portal-button { margin-top: 1rem; }
.portal-ui .portal-panel { padding: 1.15rem; margin: 0 0 1rem; border: 1px solid var(--portal-border); border-radius: 0.65rem; background: var(--portal-surface); }
.portal-ui .portal-panel > :last-child { margin-bottom: 0; }
.portal-ui p { margin-top: 0; }
.portal-ui .portal-hint { font-size: 0.8125rem; line-height: 1.45; color: var(--portal-muted); }
.portal-ui .portal-button { padding: 0.5rem 0.8rem; min-height: 2.5rem; font-size: 0.875rem; }
.portal-ui .portal-actions { gap: 0.6rem; margin: 0.7rem 0; }
.portal-ui .portal-footer { padding: 0.65rem 1.75rem; margin: 0; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: 0.75rem; border-top: 1px solid var(--portal-border); }
.portal-ui .portal-footer ul { gap: 1rem; }
.portal-ui .portal-footer p { margin: 0; }
.portal-ui .portal-colophon { display: none; }
.portal-ui .portal-cards { list-style: none; padding: 0; margin: 0; gap: 1rem; }
.portal-ui .portal-facts { grid-template-columns: 7rem minmax(0, 1fr); gap: 0.4rem 1rem; margin: 0.8rem 0; }
.portal-ui .portal-facts dd { overflow-wrap: anywhere; }
.portal-workspace { display: grid; grid-template-columns: minmax(18rem, 0.85fr) minmax(0, 2fr); gap: 1.2rem; align-items: start; }
.portal-workspace > *, .portal-workspace-details > * { min-width: 0; }
.portal-workspace-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.portal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.portal-toolbar .portal-actions { margin: 0; }
.portal-toolbar .portal-actions > span { display: none; }
.portal-toolbar [data-portal-status]:empty, [data-portal-status]:empty { display: none; }
.portal-toolbar [data-portal-status]:not(:empty) { flex-basis: 100%; margin: 0.3rem 0; }
.portal-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 1rem; }
.portal-section-heading h2, .portal-section-heading p { margin: 0; }
.portal-section-heading h2 + p { margin-top: 0.35rem; }
.portal-section-heading > a { flex-shrink: 0; font-size: 0.8125rem; }
.portal-account-facts { display: grid; gap: 0.25rem; margin: 0; }
.portal-account-facts dt { color: var(--portal-muted); font-size: 0.8125rem; }
.portal-account-facts dd { margin: 0 0 0.8rem; overflow-wrap: anywhere; font-weight: 500; }
.portal-account-facts dd:last-child { margin-bottom: 0; }
.portal-badge, .portal-count { display: inline-block; padding: 0.2rem 0.5rem; border: 1px solid var(--portal-border); border-radius: 0.4rem; background: var(--portal-bg); font-size: 0.75rem; font-weight: 600; white-space: normal; }
.portal-count { margin-left: 0.35rem; min-width: 1.5rem; text-align: center; }
.portal-link-button { padding: 0.3rem; border: none; background: transparent; color: var(--portal-accent); font: inherit; font-size: 0.8125rem; text-decoration: underline; cursor: pointer; }
.portal-access .portal-fieldset { border: 0; padding: 0; margin: 0; }
.portal-access legend { font-size: 0.8125rem; padding: 0; margin-bottom: 0.45rem; }
.portal-compact-choice { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0 1rem 0.5rem 0; min-height: 2rem; }
.portal-compact-choice input { accent-color: var(--portal-accent); }
.portal-empty-inline { padding: 2.5rem 1rem; text-align: center; color: var(--portal-muted); border: 1px dashed var(--portal-border); border-radius: 0.4rem; max-width: none !important; }
.portal-table-wrap { overflow-x: auto; }
.portal-client-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.portal-client-table th, .portal-client-table td { text-align: left; vertical-align: middle; padding: 0.85rem 0.65rem; border-bottom: 1px solid var(--portal-border); }
.portal-client-table thead th { font-size: 0.75rem; color: var(--portal-muted); font-weight: 600; background: var(--portal-bg); }
.portal-client-table th[scope="row"] { min-width: 9rem; max-width: 19rem; overflow-wrap: anywhere; }
.portal-client-table tbody tr:last-child > * { border-bottom: 0; }
.portal-cell-note { display: block; font-size: 0.75rem; font-weight: 400; color: var(--portal-muted); margin-top: 0.3rem; }
.portal-inline-form { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.portal-inline-form select { max-width: 100%; min-height: 2.5rem; padding: 0.4rem; border: 1px solid var(--portal-border); border-radius: 0.35rem; color: var(--portal-text); background: var(--portal-surface); font: inherit; }
.portal-inline-form [role="status"] { flex-basis: 100%; margin: 0; }
.portal-dialog { width: min(44rem, calc(100vw - 2rem)); max-height: calc(100dvh - 3rem); overflow: auto; padding: 1.5rem; background: var(--portal-surface); color: var(--portal-text); border: 1px solid var(--portal-border); border-radius: 0.9rem; box-shadow: 0 1.5rem 6rem #0006; }
.portal-dialog::backdrop { background: #160a16a6; backdrop-filter: blur(3px); }
.portal-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.portal-dialog-heading h2 { margin: 0; }
.portal-dialog-close { float: right; margin-left: 1rem; }
.portal-dialog .portal-header { padding-right: 4rem; }
.portal-dialog .portal-panel { padding: 1rem 0; border: none; border-top: 1px solid var(--portal-border); border-radius: 0; }
.portal-dialog .portal-form { margin: 0; }
.portal-dialog .portal-setup { max-height: 17rem; overflow: auto; font-size: 0.8125rem; padding: 0.8rem; }
.portal-ui .portal-summary { gap: 0.4rem 1rem; margin: 0.6rem 0; }
.portal-ui .portal-summary dd { margin-bottom: 0.3rem; }
.portal-operator-workspace, .portal-ui main:has(#ops-counts) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-content: start; align-items: start; }
.portal-ui main:has(#ops-detail) > nav, .portal-ui main:has(#ops-detail) > header,
.portal-ui main:has(#ops-counts) > nav, .portal-ui main:has(#ops-counts) > header { grid-column: 1 / -1; }
.portal-ui main:has(#ops-counts) .portal-panel { margin: 0; }
.portal-operator-workspace > div { min-width: 0; }
.portal-ui .portal-form { max-width: none; }
.portal-ui main:has(#portal-permission-summary) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-content: start; }
.portal-ui main:has(#portal-permission-summary) > .portal-breadcrumbs,
.portal-ui main:has(#portal-permission-summary) > header,
.portal-ui main:has(#portal-permission-summary) > section:has(.portal-client-table) { grid-column: 1 / -1; }
.portal-ui main:has(#portal-permission-summary) .portal-panel { margin: 0; }
@media (min-width: 90rem) {
  .portal-workspace { grid-template-columns: minmax(20rem, 26rem) minmax(0, 1fr); }
  .portal-ui .portal-cards { grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr)); }
}
@media (max-width: 62rem) {
  .portal-workspace { grid-template-columns: minmax(0, 1fr); }
  .portal-workspace-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .portal-workspace-heading { align-items: start; }
  .portal-ui .portal-masthead { gap: 1rem; }
  .portal-account { display: none; }
}
@media (max-width: 40rem) {
  .portal-ui main { padding: 1rem; }
  .portal-ui .portal-masthead { padding: 0.8rem 1rem; }
  .portal-app-nav { gap: 1rem; font-size: 0.8125rem; }
  .portal-ui .portal-wordmark { gap: 0.7rem; }
  .portal-workspace-details, .portal-ui main:has(#portal-permission-summary) { display: block; }
  .portal-operator-workspace, .portal-ui main:has(#ops-counts) { display: block; }
  .portal-ui main:has(#ops-detail) .portal-panel, .portal-ui main:has(#ops-counts) .portal-panel { margin-bottom: 1rem; }
  .portal-workspace-heading, .portal-section-heading { flex-wrap: wrap; }
  .portal-client-table, .portal-client-table tbody, .portal-client-table tr, .portal-client-table td, .portal-client-table th[scope="row"] { display: block; width: 100%; max-width: none; }
  .portal-client-table thead { display: none; }
  .portal-client-table tr { padding: 0.5rem 0; border-bottom: 1px solid var(--portal-border); }
  .portal-client-table th, .portal-client-table td { border: 0; padding: 0.4rem 0; }
  .portal-client-table td:nth-child(2)::before { content: "Permission limit"; display: block; color: var(--portal-muted); font-size: 0.75rem; margin-bottom: 0.4rem; }
  .portal-client-table td:nth-child(3)::before { content: "Current access: "; font-size: 0.75rem; }
  .portal-dialog { width: calc(100vw - 1rem); padding: 1rem; max-height: calc(100dvh - 1rem); }
  .portal-ui .portal-footer { padding: 0.75rem 1rem; }
}

/* Public pages use the same chrome, with layouts suited to setup and reference. */
.portal-public .portal-colophon { display: flex; gap: 1rem; flex-wrap: wrap; font-size: inherit; }
.portal-public .portal-copyright { display: inline; }
.portal-public .portal-breadcrumbs:has(ol:empty) { display: none; }
.portal-welcome { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1.25rem; align-items: stretch; }
.portal-ui .portal-welcome > .portal-panel { margin: 0; padding: 1.75rem; }
.portal-welcome-intro { display: flex; flex-direction: column; align-items: start; }
.portal-eyebrow { color: var(--portal-accent); font-size: 0.8125rem; font-weight: 600; }
.portal-ui .portal-welcome .portal-lede { margin-top: 0.85rem; font-size: 1rem; }
.portal-ui .portal-welcome .portal-actions { margin: 1rem 0 0.65rem; }
.portal-welcome .portal-actions .portal-hint { flex-basis: 100%; }
.portal-welcome-note { margin: auto 0 0; padding-top: 1.75rem; color: var(--portal-muted); font-size: 0.875rem; }
.portal-ui .portal-steps > li { max-width: none; padding-top: 0.9rem; padding-bottom: 0.9rem; }
.portal-ui .portal-steps > li:last-child { padding-bottom: 0; }
.portal-ui .portal-steps p { margin-bottom: 0; }
.portal-ui .portal-steps p + p { margin-top: 0.75rem; }
.portal-ui .portal-steps > li::before { top: 0.9rem; }
.portal-info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.portal-info-grid .portal-panel { margin: 0; }
.portal-help-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(18rem, 1fr); gap: 1.25rem; align-items: start; }
.portal-help-layout > * { min-width: 0; }
.portal-preparation { padding: 0.8rem; background: var(--portal-bg); border-radius: 0.4rem; margin-bottom: 1rem; }
.portal-preparation summary { font-weight: 600; cursor: pointer; }
.portal-ui .portal-preparation p { margin: 0.5rem 0 0; }
.portal-prompt { margin: 0.6rem 0 1.1rem; padding: 0.75rem 1rem; border-left: 3px solid var(--portal-accent); background: var(--portal-bg); overflow-wrap: anywhere; }
.portal-ui .portal-message { max-width: 46rem; padding: 1.5rem; }
@media (max-width: 52rem) {
  .portal-welcome, .portal-help-layout, .portal-info-grid { grid-template-columns: minmax(0, 1fr); }
  .portal-ui .portal-welcome > .portal-panel { padding: 1.15rem; }
}
