/* Hallmark · genre: modern-minimal · macrostructure: Data Console (app-scope, adapted)
 * theme: Cobalt (adapted) · nav: N9 Edge-aligned minimal · footer: none
 * design-system: design.md · designed-as-app
 */

html, body {
  overflow-x: clip;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink-2);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: normal;
  letter-spacing: -0.01em;
  color: var(--color-ink);
  margin: 0 0 var(--space-sm);
}

h1 { font-size: var(--text-display); }
h2 { font-size: var(--text-display-s); }
h3 { font-size: var(--text-lg); }

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
}

/* -- app bar (nav: N9 edge-aligned minimal) -- */

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-paper);
  border-bottom: 1px solid var(--color-rule);
  flex-wrap: wrap;
}

.app-bar__brand {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink);
  white-space: nowrap;
}

.app-bar__brand:hover {
  text-decoration: none;
}

.app-bar__nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.app-bar__nav a {
  color: var(--color-ink-2);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-3xs) 0;
  border-bottom: 2px solid transparent;
  transition: border-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}

.app-bar__nav a:hover {
  color: var(--color-ink);
  text-decoration: none;
  border-color: var(--color-rule-2);
}

.app-bar__nav a.is-active {
  color: var(--color-ink);
  border-color: var(--color-accent);
}

.app-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.lang-form {
  display: inline;
}

/* Outranks button[type="submit"] (0,1,1) — a bare .lang-btn (0,1,0) lost and rendered filled. */
button.lang-btn {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--color-ink-3);
  background: transparent;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-control);
  padding: var(--space-3xs) var(--space-2xs);
  cursor: pointer;
  transition: border-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}

button.lang-btn:hover {
  color: var(--color-ink);
  border-color: var(--color-rule-2);
  background: var(--color-paper-2);
}

.app-bar__actions > a {
  font-size: var(--text-sm);
  font-weight: 500;
}

/* -- page shell -- */

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-2xl);
}

.page-header {
  margin-bottom: var(--space-lg);
}

.page-header .context {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-3);
  margin-bottom: var(--space-3xs);
}

/* -- surfaces -- */

.card {
  background: var(--color-paper);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-card);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.card > h2:first-child,
.card > h3:first-child {
  margin-top: 0;
}

/* A card heading is the one heading in this system that carries admin-entered free text (the
   portal's catalog names one application per card), and `html, body { overflow-x: clip }`
   above absorbs whatever a long unbroken name overflows — so it is CLIPPED silently, with no
   scrollbar to reveal the rest. Same guard `.menu-card__title` and `.landing__panel h1`
   already carry, kept off bare `h2` so page titles nobody types stay unaffected. */
.card > h2 {
  overflow-wrap: anywhere;
}

/* The same clip, one element down. A card's lead paragraph carries the OTHER admin-entered free
   text on the portal's catalog (`@application.Description`), and it was left unguarded when the
   heading above was fixed — same card, same 318px content box, same silent `overflow-x: clip`.
   Measured from the box model at a 400px viewport: main contributes 2x --space-sm of padding
   (368px), the card 2x1px of border and 2x --space-md of padding, leaving 318px; at --text-sm
   (13px) a single unbroken run clips past roughly 44 characters, and the 62-character token
   PortalCatalogPageTests seeds needs >=370px — at least 52px of it invisible, with no scrollbar
   to reveal it because the card is not a scroll container.
   Scoped to a card's own paragraph, not to `.muted`: that class also dresses cells INSIDE
   `.table-scroll`, which scrolls rather than clips, and `anywhere` there would break a quantity
   mid-digit for no gain. The selector is structural, so the markup must keep this element a
   `p.muted` direct child of `.card` — pinned by PortalCatalogPageTests, since a wrapper element
   would drop this guard with no visible symptom. */
.card > p.muted {
  overflow-wrap: anywhere;
}

/* -- tables -- */

/* tabindex="0" in the markup makes this focusable, since a scroll container that only
   responds to a pointer is unreachable for a keyboard user. The focus ring is what tells
   them the arrow keys will now scroll the table. */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-card);
  margin-bottom: var(--space-md);
}

.table-scroll:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 32rem;
  background: var(--color-paper);
  font-size: var(--text-sm);
}

.card table {
  min-width: 24rem;
}

th, td {
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-rule);
  vertical-align: middle;
  /* Containing block for .visually-hidden: without it the absolutely-positioned span
     resolves against the initial containing block, escaping .table-scroll and widening
     the document past the viewport on narrow screens. */
  position: relative;
}

th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-3);
  background: var(--color-paper-2);
  border-bottom: 1px solid var(--color-rule-2);
  white-space: nowrap;
}

/* A row header names what every cell in its row answers about, so it is content and not the
   column chrome `th` above is: without this it inherited mono/12px/uppercase/ink-3 and a
   feature name read as a label. Background and border go back to the td voice too, or the
   first column of the matrix would carry a paper-2 stripe and a heavier rule than the cells
   beside it. */
tbody th[scope="row"] {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--color-ink-2);
  background: transparent;
  border-bottom-color: var(--color-rule);
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Matches `tbody tr:last-child td`, which names only td and would leave the row header of the
   last row drawing a rule the rest of that row has dropped. */
tbody tr:last-child th[scope="row"] {
  border-bottom: none;
}

/* The catalog's plan column head is priced purchase-decision content, not a data-column label.
   design.md scopes mono to status badges, slugs, feature keys, version numbers and currency
   codes — a localized plan name is none of those — and `text-transform: uppercase` does not
   translate: "Plan Empresarial" rendered "PLAN EMPRESARIAL". Wrapping is allowed here because
   the head carries free text of a length nobody in this repo controls. */
th.plan-col {
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  color: var(--color-ink);
  white-space: normal;
  overflow-wrap: anywhere;
}

/* The whole head row aligns with the wrapped plan names rather than floating in the middle of
   whatever the tallest column head turned out to be. Scoped with :has() so it reaches only a
   header row that actually carries a plan column. */
thead tr:has(.plan-col) th {
  vertical-align: top;
}

.plan-col__name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-ink);
}

/* Version numbers are one of the roles design.md does keep in mono. */
.plan-col__version {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink-3);
}

/* Commercial copy under a plan's price, and what a feature covers under its name. Both are
   secondary to the thing they explain, so they take the muted voice at the small size, and both
   are blocks so they wrap inside their own cell instead of stretching the head row sideways —
   the table already scrolls inside .table-scroll, so a long description widens nothing outside
   it. max-width keeps a paragraph-length description from turning a column into a column of
   prose; the cell measures the same either way. */
.plan-col__description,
.feature-row__description {
  display: block;
  max-width: 28ch;
  margin-top: var(--space-2xs);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  text-transform: none;
  color: var(--color-ink-3);
  white-space: normal;
  overflow-wrap: anywhere;
}

tbody tr {
  transition: background-color var(--dur-short) var(--ease-out);
}

tbody tr:hover {
  background: var(--color-paper-2);
}

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

td .mono, td.mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
}

/* -- badges (status) -- */

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2em 0.6em;
  border-radius: var(--radius-badge);
  white-space: nowrap;
  color: var(--color-neutral);
  background: var(--color-neutral-bg);
}

.badge[data-status="active"] {
  color: var(--color-success);
  background: var(--color-success-bg);
}

.badge[data-status="draft"] {
  color: var(--color-warning);
  background: var(--color-warning-bg);
}

.badge[data-status="deprecated"],
.badge[data-status="archived"] {
  color: var(--color-neutral);
  background: var(--color-neutral-bg);
}

/* Consumption past the contracted limit (portal usage, 7.6). The semantic danger pair the banner
   already uses — no new token, so design.md's contrast math still covers it. */
.badge[data-status="over-limit"] {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* The portal's billing messages (add-customer-organizations 13.5): four states, and a never-sent
   message must not read like a failed one, so it gets its own pair rather than the danger pair a
   bounce uses. Pending keeps the neutral default. */
.badge[data-status="message-accepted"] {
  color: var(--color-success);
  background: var(--color-success-bg);
}

.badge[data-status="message-failed"] {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

.badge[data-status="message-neversent"] {
  color: var(--color-warning);
  background: var(--color-warning-bg);
}

/* A message kind is two or three words; broken mid-word at phone width it cannot be read. */
.message-kind {
  white-space: nowrap;
}

/* The message states are sentences ("No enviado: sin contacto de cobranza"), unlike the one-word
   badges elsewhere: they wrap rather than run off the card at phone width. */
.badge[data-status^="message-"] {
  white-space: normal;
  display: inline-block;
  max-width: 14rem;
  border-radius: var(--radius-control);
}

/* The one-message send of a never-sent billing message sits under its state, not beside it. */
.message-action {
  margin-top: 0.375rem;
}

/* Where it will go: the contact's address, which can be longer than a phone is wide, so it may
   break inside the address rather than push the state off screen. */
.message-resend-to {
  display: block;
  margin-top: 0.25rem;
  max-width: 14rem;
  overflow-wrap: anywhere;
}

/* -- forms -- */

form p {
  margin: 0 0 var(--space-sm);
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink);
  margin-bottom: var(--space-3xs);
}

input, select, textarea {
  font-family: var(--font-body);
  font-size: var(--text-md);
  color: var(--color-ink);
  background: var(--color-paper);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-control);
  padding: var(--space-2xs) var(--space-xs);
  width: 100%;
  max-width: 22rem;
  transition: border-color var(--dur-short) var(--ease-out);
}

input[type="checkbox"] {
  width: auto;
  max-width: none;
}

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

input:focus-visible, select:focus-visible, textarea:focus-visible,
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

form.inline {
  display: inline;
}

/* -- buttons -- */

button {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--text-sm);
  line-height: 1.2;
  border-radius: var(--radius-control);
  padding: var(--space-2xs) var(--space-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-short) var(--ease-out),
              border-color var(--dur-short) var(--ease-out),
              color var(--dur-short) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

/* The accent fill is the default for a submit, but must lose to anything explicitly styled:
   the language toggles and .btn-outline are submits too. Excluding them by name keeps this
   rule from out-specifying their own rules further down the file. */
button[type="submit"]:not(.lang-btn):not(.btn-outline):not(.btn-danger-outline) {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}

button[type="submit"]:not(.lang-btn):not(.btn-outline):not(.btn-danger-outline):hover {
  background: var(--color-accent-hover);
}

button[type="submit"]:not(.lang-btn):not(.btn-outline):not(.btn-danger-outline):active {
  transform: translateY(1px);
}

button[type="submit"]:disabled {
  background: var(--color-neutral-bg);
  color: var(--color-ink-3);
  cursor: not-allowed;
  transform: none;
}

/* Status-change buttons (Deprecate / Archive) read as secondary, reversible actions */
.row-actions button[type="submit"],
td button[type="submit"],
/* a.btn-outline: a link dressed as the secondary button, for the actions that are a navigation
   and not a submit — "Archivar" on the plans list leads to a confirmation page, and "Cancelar"
   on that page leads back. Same rule as the button so the two read as one control family. */
button.btn-outline,
a.btn-outline {
  background: transparent;
  color: var(--color-ink-2);
  border-color: var(--color-rule-2);
}

.row-actions button[type="submit"]:hover,
td button[type="submit"]:hover,
button.btn-outline:hover,
a.btn-outline:hover {
  border-color: var(--color-ink-3);
  color: var(--color-ink);
  background: var(--color-paper-2);
}

button.lang-btn:active,
.row-actions button[type="submit"]:active,
td button[type="submit"]:active,
button.btn-outline:active {
  transform: translateY(1px);
}

/* -- filter form (compare page) -- */

.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-sm);
}

/* A sentence about the form row directly above it, set on its own line so it never widens a
   field. */
.form-hint {
  margin: var(--space-3xs) 0 var(--space-sm);
  font-size: var(--text-sm);
}

/* -- accent link-button (landing CTA, empty-state CTA) -- */

.btn-accent {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.2;
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border-radius: var(--radius-control);
  padding: var(--space-2xs) var(--space-md);
  white-space: nowrap;
  transition: background-color var(--dur-short) var(--ease-out);
}

.btn-accent:hover {
  background: var(--color-accent-hover);
  color: var(--color-accent-ink);
  text-decoration: none;
}

/* -- dashboard menu -- */

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.menu-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  min-width: 0;
  padding: var(--space-md);
  background: var(--color-paper);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-card);
  color: var(--color-ink-2);
  transition: border-color var(--dur-short) var(--ease-out),
              background-color var(--dur-short) var(--ease-out);
}

.menu-card:hover {
  border-color: var(--color-accent);
  background: var(--color-paper-2);
  text-decoration: none;
}

.menu-card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-ink);
  overflow-wrap: anywhere;
}

.menu-card__desc {
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}

.menu-card__meta {
  margin-top: var(--space-2xs);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-3);
}

/* -- empty state -- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md);
  border: 1px dashed var(--color-rule-2);
  border-radius: var(--radius-card);
  background: var(--color-paper-2);
  margin-bottom: var(--space-md);
}

.empty-state p {
  margin: 0;
  color: var(--color-ink-2);
  font-size: var(--text-sm);
}

/* -- landing / sign-in -- */

.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: var(--space-lg) var(--space-sm);
}

.landing__panel {
  width: 100%;
  max-width: 34rem;
  padding: var(--space-xl) var(--space-lg);
  background: var(--color-paper);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-card);
}

.landing__brand {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-3);
  margin-bottom: var(--space-sm);
}

.landing__back {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--color-ink-2);
  text-decoration: none;
  margin-bottom: var(--space-sm);
}

.landing__back:hover,
.landing__back:focus-visible {
  color: var(--color-ink);
  text-decoration: underline;
}

.landing__panel h1 {
  font-size: var(--text-display);
  overflow-wrap: anywhere;
  margin-bottom: var(--space-xs);
}

.landing__intro {
  color: var(--color-ink-2);
  margin: 0 0 var(--space-lg);
}

.landing__langs {
  display: flex;
  gap: var(--space-2xs);
  margin-top: var(--space-xl);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-rule);
}

.landing__langs form {
  display: inline;
}

/* The verification resend under the denial panel: one field and one secondary button, spaced as
   a small form of its own rather than run into the retry CTA above it. */
.landing__resend {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  margin-top: var(--space-lg);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-rule);
}

.landing__resend input[type="email"] {
  width: 100%;
}

.landing__resend button {
  align-self: flex-start;
}

.landing__resend-outcome {
  margin: 0;
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-card);
  background: var(--color-paper-2);
  color: var(--color-ink);
  font-size: var(--text-sm);
}

/* ---------- Portal contracting (customer-self-service-portal section 4) ---------- */
.portal-held {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}

.portal-held .badge {
  margin-left: var(--space-2xs);
}

/* The actions row sits under the matrix in the same columns; forms are inline so a cell holds
   exactly one control, and the row header takes the body voice like the feature rows do. */
tfoot .portal-actions th[scope="row"] {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--color-ink-3);
  background: transparent;
}

tfoot .portal-actions td {
  vertical-align: middle;
}

tfoot .portal-actions form {
  display: inline;
}

.portal-cancel {
  margin-top: var(--space-sm);
}

.portal-cancel summary {
  cursor: pointer;
  color: var(--color-ink-2);
}

.portal-cancel form {
  margin-top: var(--space-2xs);
}

/* The trial sentence under the held line, and the one-line note under a Contract button. */
.portal-trial {
  display: block;
  margin-top: var(--space-3xs);
}

.portal-trial strong {
  display: block;
  color: var(--color-warning);
}

.portal-trial-note {
  display: block;
  margin-top: var(--space-3xs);
  font-size: var(--text-xs);
}

/* -- a11y -- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* -- inline messages -- */

.banner {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-danger);
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-radius: var(--radius-control);
  font-size: var(--text-sm);
  margin-bottom: var(--space-md);
}

/* The success variant of the message above. After .banner on purpose: both are one class,
   so the later rule wins, and above it a success notice rendered in the error red. */
.banner--ok {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: var(--color-success);
}

/* A pending payment (add-payment-retries-and-grace): not an error the customer made on this page,
   and not a success, so neither the red nor the green above. */
.banner--warn {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: var(--color-warning);
}

/* -- offered billing periods (admin plan form, add-plan-billing-periods) --
   One row per period: whether it is offered, and its price beside it. */

fieldset.period-offers {
  border: 0;
  margin: 0 0 var(--space-sm);
  padding: 0;
}

.period-offers legend {
  padding: 0;
  margin-bottom: var(--space-3xs);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink);
}

.period-offers__row {
  display: grid;
  grid-template-columns: minmax(8rem, max-content) minmax(0, 12rem);
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-2xs);
}

.period-offers__row label {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  margin: 0;
  font-weight: 400;
}

/* -- monthly / annual switch (portal catalog, add-plan-billing-periods) --
   A segmented control of two radios above an application's plans. It switches with CSS alone: the
   card hides every [data-period] that is not the selected one, so the prices shown and the contract
   form posted follow the switch with no script. Without :has() support both periods stay visible,
   each labelled, which is still correct. The accent marks the selected option only, never a fill
   of the whole control. */

fieldset.period-toggle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2xs) var(--space-sm);
  margin: 0 0 var(--space-md);
  padding: 0;
  border: 0;
}

.period-toggle__legend {
  float: left;
  padding: 0;
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink);
}

/* The two options as ONE control: no gap and no wrap between them, whatever the width. */
.period-toggle__options {
  display: inline-flex;
  flex-wrap: nowrap;
}

.period-toggle__option {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: var(--space-3xs) var(--space-sm);
  border: 1px solid var(--color-rule-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-2);
  background: var(--color-paper);
  cursor: pointer;
  transition: background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}

/* The two options read as one control: shared edge, rounded only at its ends. */
.period-toggle__option + .period-toggle__option {
  margin-left: -1px;
}

.period-toggle__option:first-child {
  border-radius: var(--radius-control) 0 0 var(--radius-control);
}

.period-toggle__option:last-child {
  border-radius: 0 var(--radius-control) var(--radius-control) 0;
}

/* The radio stays in the accessibility tree and keyboard order; only its dot is not drawn. */
.period-toggle__option input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.period-toggle__option:hover {
  color: var(--color-ink);
  background: var(--color-paper-2);
}

.period-toggle__option:has(input:checked) {
  z-index: 1;
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-paper-2);
}

.period-toggle__option:has(input:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.card:has(.period-toggle input[value="monthly"]:checked) [data-period="yearly"],
.card:has(.period-toggle input[value="yearly"]:checked) [data-period="monthly"] {
  display: none;
}

.period-price {
  display: block;
}

.period-price__monthly,
.period-price__none {
  display: block;
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-ink-3);
}

/* -- stored payment methods (portal account) --
   At most two rows — the Organization's own method and the account's default — each a hairline row
   with the method's name, its meta line and a status badge saying which one is charged. */

.saved-methods {
  list-style: none;
  margin: 0 0 var(--space-sm);
  padding: 0;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-card);
}

.saved-method {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
}

.saved-method + .saved-method {
  border-top: 1px solid var(--color-rule);
}

.saved-method__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  min-width: 0;
}

.saved-method__name {
  font-weight: 600;
  color: var(--color-ink);
  overflow-wrap: anywhere;
}

.saved-method__digits {
  margin-left: var(--space-3xs);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.saved-method__meta {
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}

.saved-method .badge {
  flex: none;
}

/* A kept card: its badge and the one action that makes it the method in use again. */
.saved-method__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2xs) var(--space-sm);
}

.saved-method__actions form {
  margin: 0;
}

/* -- card capture (add-openpay-payment-processor 8.1) --
   The one form on the console that takes card details, so it is set apart as its own hairline panel
   and sized to a card's data rather than to the page: number and name full width, expiry and CVV side
   by side. Errors sit under the field they are about; the accent stays on the one action. */

.card-capture__replace > summary {
  display: inline-block;
  cursor: pointer;
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: var(--space-2xs);
}

.card-capture__replace > summary:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.card-capture__replace[open] > summary {
  margin-bottom: var(--space-xs);
}

.card-capture {
  max-width: 28rem;
  padding: var(--space-md);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-card);
  background: var(--color-paper);
}

.card-capture input {
  max-width: none;
}

.card-capture__field {
  margin-bottom: var(--space-sm);
}

.card-capture__label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2xs);
}

.card-capture__brand {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 var(--space-2xs);
  border-radius: var(--radius-badge);
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
}

.card-capture__number {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* Expiry (month + year) takes three fifths, the CVV and its hint the rest; they stack on a narrow phone. */
.card-capture__row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.card-capture fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.card-capture legend {
  padding: 0;
  margin-bottom: var(--space-3xs);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink);
}

.card-capture__pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2xs);
}

/* Month and Year sit under the "Expiry" legend, so their own labels are the quieter tier. */
.card-capture__sublabel {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-ink-2);
}

/* The CVV label lines up with the legend beside it, then drops its input to the same baseline as
   month and year, whose sublabels take one more line. */
.card-capture__field--cvv {
  margin-bottom: 0;
}

.card-capture__cvv-label {
  margin-bottom: calc(var(--space-3xs) + var(--text-xs) * 1.5 + var(--space-3xs));
}

.card-capture__hint,
.card-capture__error {
  margin: var(--space-3xs) 0 0;
  font-size: var(--text-xs);
}

.card-capture__hint {
  color: var(--color-ink-3);
}

.card-capture__error {
  color: var(--color-danger);
  font-weight: 500;
}

.card-capture input[aria-invalid="true"] {
  border-color: var(--color-danger);
}

.card-capture .banner {
  margin-bottom: var(--space-sm);
}

.card-capture__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-sm);
}

.card-capture__secure {
  font-size: var(--text-xs);
  color: var(--color-ink-3);
}

.card-capture button[aria-busy="true"] {
  cursor: progress;
}

@media (max-width: 420px) {
  .card-capture {
    padding: var(--space-sm);
  }

  .card-capture__row {
    grid-template-columns: minmax(0, 1fr);
  }

  .card-capture__cvv-label {
    margin-bottom: var(--space-3xs);
  }

  .card-capture__field--cvv input {
    max-width: 8rem;
  }
}

.portal-past-due p {
  margin: var(--space-2xs) 0 0;
}

/* The charge attempts of a past-due subscription, opened under its count. */
.attempt-list {
  margin: var(--space-2xs) 0 0;
  padding-left: var(--space-sm);
}

/* Secondary explanatory copy — measures 4.97:1 on paper-2, so it clears AA. */
.muted {
  color: var(--color-ink-3);
  font-size: var(--text-sm);
}

.muted .badge,
.muted .mono {
  margin-right: var(--space-2xs);
}

.cmp-dash {
  color: var(--color-ink-3);
}

.cmp-yes {
  color: var(--color-success);
  font-weight: 500;
}

.cmp-no {
  color: var(--color-ink-3);
}

details > summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--color-accent);
  padding: var(--space-2xs) 0;
}

details[open] > summary {
  margin-bottom: var(--space-xs);
}

/* -- responsive -- */

@media (max-width: 640px) {
  .app-bar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-xs);
  }

  .app-bar__nav,
  .app-bar__actions {
    gap: var(--space-sm);
  }

  main {
    padding: var(--space-md) var(--space-sm) var(--space-xl);
  }

  input, select, textarea {
    max-width: none;
  }
}

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

/* ---------- Indicators dashboard (add-admin-subscription-analytics) ----------
   Charts are inline SVG drawn by the server and scaled by viewBox; text inside them wears the
   console's ink tokens, never a series colour (dataviz: text wears text tokens). Series colours
   are assigned by POSITION in a fixed order — accent, success, danger — and the page decides
   which measure sits in which slot, so a filter can never repaint a survivor. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  min-width: 0;
  padding: var(--space-md);
  background: var(--color-paper);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-card);
}

.stat__label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-3);
}

.stat__value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-ink);
  overflow-wrap: anywhere;
}

.stat--danger .stat__value {
  color: var(--color-danger);
}

.stat__meta {
  font-size: var(--text-sm);
  color: var(--color-ink-3);
}

/* A chart and its table side by side when there is room, stacked when there is not. The table
   is the accessible and copy-pastable form; the chart is the glanceable one. */
.chart-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));
  gap: var(--space-md);
  align-items: start;
  margin-bottom: var(--space-md);
}

/* Chart text is sized in viewBox units, so it scales with the rendered width: a 640-unit chart
   stretched across a wide page doubles its type, and squeezed onto a phone shrinks it past
   reading. The chart is therefore held between 35rem and 40rem (1:1 with its viewBox at the top)
   and scrolls inside its figure below that, the way a wide table scrolls inside .table-scroll.
   tabindex="0" in the markup makes the figure keyboard-scrollable for the same reason. */
.chart-figure {
  margin: 0;
  min-width: 0;
  overflow-x: auto;
}

.chart-figure:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.chart {
  display: block;
  width: 100%;
  min-width: 35rem;
  max-width: 40rem;
  height: auto;
}

/* A month row header ("oct. 2025") is a short fixed-shape label, not free text: the general
   row-header rule lets it break anywhere, which on a phone split it into "oct. / 20 / 25". The
   trend tables scroll inside .table-scroll, so holding it on one line widens nothing outside.
   Selector repeats `tbody th[scope="row"]` to outrank that rule rather than follow it.
   `.date` is the same shape for a day ("21/09/2026", the portal's invoice and payment rows),
   which broke as "21/09/2 / 026" at 360px for the same reason. */
tbody th[scope="row"].month,
tbody th[scope="row"].date {
  white-space: nowrap;
  overflow-wrap: normal;
}

.chart text {
  font-family: var(--font-body);
  font-size: 12px;
  fill: var(--color-ink-2);
}

.chart .chart-value {
  fill: var(--color-ink);
  font-weight: 500;
}

.chart-bar {
  fill: var(--color-accent);
}

.chart-row:hover .chart-bar {
  fill: var(--color-accent-hover);
}

.chart-grid {
  stroke: var(--color-rule);
  stroke-width: 1;
}

.chart-series polyline {
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-series circle {
  stroke: var(--color-paper);
  stroke-width: 2;
}

.chart-series-1 polyline { stroke: var(--color-accent); }
.chart-series-1 circle, .chart-swatch.chart-series-1 { fill: var(--color-accent); background: var(--color-accent); }
.chart-series-2 polyline { stroke: var(--color-success); }
.chart-series-2 circle, .chart-swatch.chart-series-2 { fill: var(--color-success); background: var(--color-success); }
.chart-series-3 polyline { stroke: var(--color-danger); }
.chart-series-3 circle, .chart-swatch.chart-series-3 { fill: var(--color-danger); background: var(--color-danger); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin: var(--space-2xs) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}

.chart-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: var(--space-3xs);
  border-radius: 2px;
  vertical-align: -1px;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Category navigation (add-application-categories-navigation) ----------
   A two-column shell: the left menu (category > subcategory > application) beside the page. The
   menu is the app's own chrome, so it wears the app bar's voice — paper ground, hairline rule,
   ink text — and the accent only on what is interactive or current, never as a fill. Collapse is
   native <details>; nav.js only adds live filtering and the narrow-screen toggle. */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

/* Only when the menu actually rendered: the component renders nothing for a viewer who fails the
   surface's policy (anonymous admin pages), and an empty column would still take 15rem. */
/* 17rem rather than 15: each level now carries a chevron and the subcategories a count, and at 15
   a two-word subcategory name wrapped beside them. */
.shell:has(> .shell__side .side-nav) {
  grid-template-columns: 17rem minmax(0, 1fr);
}

.shell__side:not(:has(.side-nav)) {
  display: none;
}

.shell__side {
  border-right: 1px solid var(--color-rule);
  min-width: 0;
}

.shell > main {
  width: 100%;
  min-width: 0;
}

.side-nav {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  /* A hairline-weight scrollbar in the rule colour: the default one sat on the menu as a grey bar
     the full height of the screen, louder than anything inside it. */
  scrollbar-width: thin;
  scrollbar-color: var(--color-rule-2) transparent;
  padding: var(--space-md) var(--space-xs) var(--space-lg) var(--space-sm);
  font-size: var(--text-sm);
}

.side-nav__heading {
  margin: 0 0 var(--space-xs);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-3);
}

.side-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Top-level categories are separated by a hairline, so a long tree reads as groups at a glance. */
.side-nav__tree > li + li {
  margin-top: var(--space-2xs);
  padding-top: var(--space-2xs);
  border-top: 1px solid var(--color-rule);
}

/* Nested levels indent on a hairline guide that drops from the parent's chevron, so depth reads
   without a second colour. */
.side-nav details ul {
  margin-left: var(--space-2xs);
  padding-left: var(--space-3xs);
  border-left: 1px solid var(--color-rule);
}

/* Every row — group or link — shares one box: same padding, radius and hover, so the eye can run
   down the column without the text edge jumping between levels. */
.side-nav details > summary,
.side-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) var(--space-2xs);
  border-radius: var(--radius-control);
  overflow-wrap: anywhere;
  transition: background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}

/* A group is a disclosure, and now says so. display:flex removed the browser's own triangle, which
   left nothing to tell a viewer the groups fold; the chevron is drawn in CSS so it inherits the
   row's colour and turns with the group. */
.side-nav details > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  color: var(--color-ink);
  font-weight: 600;
}

.side-nav details > summary::-webkit-details-marker {
  display: none;
}

.side-nav details > summary::before {
  content: "";
  flex: none;
  width: 0.4em;
  height: 0.4em;
  margin-inline: 0.1em 0.15em;
  border-right: 1.5px solid var(--color-ink-3);
  border-bottom: 1.5px solid var(--color-ink-3);
  transform: rotate(-45deg);
  transition: transform var(--dur-short) var(--ease-out);
}

.side-nav details[open] > summary::before {
  transform: rotate(45deg);
}

.side-nav details > summary:hover,
.side-nav a:hover {
  background: var(--color-paper-2);
  color: var(--color-ink);
  text-decoration: none;
}

/* The global focus rule names a, button and form fields; a summary is focusable too and fell back
   to the browser's black box. Inset, because the menu scrolls and an outset ring is clipped. */
.side-nav details > summary:focus-visible,
.side-nav a:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: -2px;
}

.side-nav details details > summary {
  color: var(--color-ink-2);
  font-weight: 500;
}

.side-nav__label {
  flex: 1 1 auto;
  min-width: 0;
}

.side-nav__count {
  flex: none;
  min-width: 1.5em;
  padding: 0 var(--space-3xs);
  border-radius: var(--radius-badge);
  background: var(--color-neutral-bg);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  color: var(--color-neutral);
}

.side-nav a {
  color: var(--color-ink-2);
}

/* Current: an accent edge plus ink weight, not a filled pill — the accent marks, never floods. */
.side-nav a[aria-current] {
  color: var(--color-ink);
  font-weight: 500;
  box-shadow: inset 2px 0 0 var(--color-accent);
  background: var(--color-paper-2);
}

.side-nav__none,
.side-nav__empty {
  padding: var(--space-3xs) var(--space-2xs);
  color: var(--color-ink-3);
  font-size: var(--text-xs);
}

.side-nav__status {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink-3);
}

.side-nav__screens {
  margin: var(--space-3xs) 0 var(--space-2xs) var(--space-xs);
  padding-left: var(--space-3xs);
  border-left: 1px solid var(--color-rule);
}

.side-nav__configure {
  margin-top: var(--space-md);
  font-size: var(--text-xs);
}

/* Touch screens get rows a finger can hit: about 44px, the platform guideline, instead of ~26px. */
@media (pointer: coarse) {
  .side-nav details > summary,
  .side-nav a {
    min-height: calc(var(--space-lg) + var(--space-xs));
  }
}

/* -- top-bar search -- */

.app-bar__search {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  flex: 1 1 16rem;
  max-width: 28rem;
}

.app-bar__search input[type="search"] {
  max-width: none;
  padding: var(--space-3xs) var(--space-xs);
  font-size: var(--text-sm);
}

/* The narrow-screen toggle exists only once nav.js has run (html.js); without script the menu
   stacks above the page instead, so there is nothing to toggle. */
.nav-toggle {
  display: none;
  align-items: center;
  gap: var(--space-2xs);
}

/* The toggle carries the same chevron as the groups it opens, turning with aria-expanded. */
.nav-toggle::after {
  content: "";
  width: 0.4em;
  height: 0.4em;
  margin-top: -0.2em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--dur-short) var(--ease-out);
}

.nav-toggle[aria-expanded="true"]::after {
  margin-top: 0.2em;
  transform: rotate(-135deg);
}

/* -- filter bar (applications list, portal catalog) -- */

.category-filter {
  margin-bottom: var(--space-md);
}

fieldset.category-filter,
.category-filter fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
}

.category-filter legend {
  padding: 0;
  margin-bottom: var(--space-2xs);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-3);
}

.category-filter__group {
  min-width: 0;
}

.category-filter__group > label {
  font-weight: 600;
}

.category-filter label {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  font-weight: 400;
  color: var(--color-ink-2);
  margin: 0 0 var(--space-3xs);
}

.category-filter__group ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--space-sm);
}

.category-filter__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

/* Links beside a button in a control row read at the button's size, not body size. */
.category-filter__actions a,
section.card > .row-actions a {
  font-size: var(--text-sm);
  font-weight: 500;
}

.result-count {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}

/* -- destructive (category delete): the console's first delete, see design.md CTA voice -- */

button.btn-danger-outline[type="submit"] {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger);
}

button.btn-danger-outline[type="submit"]:hover {
  background: var(--color-danger-bg);
}

@media (max-width: 960px) {
  .shell:has(> .shell__side .side-nav) {
    grid-template-columns: minmax(0, 1fr);
  }

  .shell__side {
    border-right: 0;
    border-bottom: 1px solid var(--color-rule);
  }

  .side-nav {
    position: static;
    max-height: none;
  }

  .js .nav-toggle {
    display: inline-flex;
  }

  .js .shell__side:not(.is-open) {
    display: none;
  }
}

@media (max-width: 640px) {
  /* The app bar stacks into a column here, where flex-basis is a HEIGHT: the desktop
     lex: 1 1 16rem made the search form 16rem tall. */
  .app-bar__search {
    flex: 0 0 auto;
    max-width: none;
  }

  .js .nav-toggle {
    align-self: flex-start;
  }
}