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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: var(--lh-body);
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 1023px) {
  body {
    overflow-x: clip;
  }
}

/* .page-shell lives in layout.css. The block that stood here called itself a
   fallback "if layout.css is missing" — every one of the 32 pages loads it, and
   site.css loads later, so the fallback was in fact always the winner. */

[hidden] {
  display: none !important;
}

/* `flex: none`, not `0 0 1em`: with a fixed 1em basis, every rule that sized an
   icon by `width` lost inside a flex parent — the basis set the width, the rule
   set the height, and 60 icons rendered non-square (chip chevrons 12×18,
   notification dots 16×8) until 2026-11-05. Now `width` sizes it everywhere. */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Secondary icon inside dense content — a table row, a badge, an inline hint.
   Had no rule until 2026-08-01 while markup used it in ~15 places expecting it
   to be smaller, so it simply rendered at full size. Stays em-relative, so it
   still tracks whatever text it sits next to. */
.icon--sm {
  width: 0.85em;
  height: 0.85em;
  flex: 0 0 0.85em;
}

/* Keeps an icon's slot so rows with and without the icon line up (the
   nameserver list in the domain inspector), painting nothing. */
.icon--placeholder {
  visibility: hidden;
}

/* Inside a control, `.btn .icon` (0,2,0) sets 1.25em and outranks the bare
   modifier — so `icon icon--sm` on a button chevron kept rendering full size.
   Third instance of the same specificity trap in this pass; the lesson is that
   defining a modifier is not the same as making it win. */
.btn .icon.icon--sm,
.btn-icon .icon.icon--sm,
.btn-chip .icon.icon--sm {
  width: 0.85em;
  height: 0.85em;
  flex: 0 0 0.85em;
}

/* Placeholder for icon spacing in dropdowns (keeps alignment when no icon) */
.icon-placeholder {
  width: 1em;
  height: 1em;
  flex: 0 0 1em;
  display: inline-flex;
}

/* Mono-иконки наследуют цвет текста — работает и в dark */
.icon[data-icon^="mono/"] svg,
.icon[data-icon^="mono/"] use {
  fill: currentColor;
  stroke: none;
  width:inherit;
}
/* Mono icons inherit color automatically via SVG fill="currentColor" */

/* Icon Ring - Promotional icon wrapper with border
   ============================================

   Usage:
   <div class="icon-ring">
     <span class="icon" data-icon="mono/plus"></span>
   </div>

   Variants:
   .icon-ring--brand   - brand accent
   .icon-ring--cf      - Cloudflare orange accent
   .icon-ring--success - success accent
   .icon-ring--info    - info accent
   .icon-ring--warning - warning accent
   .icon-ring--danger  - danger accent

   Merged 2026-08-01 from two separate systems. A second .icon-ring block lived
   ~2000 lines below this one and, at equal specificity, won: the ring rendered
   at 2.25rem (not the 3rem declared here) and every variant's wash came from a
   hand-copied rgba literal instead of a token. Measured on the live page, that
   meant two real defects. The washes were frozen at the DARK theme's colours,
   so in light theme a #0E7B4C glyph sat on a wash mixed from #18C27A; and
   --info/--warning/--danger existed only in the lower block, which set `color`
   on the ring, where `.icon-ring .icon { color: var(--text) }` below overrode
   it — a red ring around a body-grey glyph. --warning's literal (#F59E0B)
   matched neither theme's token.

   Sizes below are the ones that actually rendered (2.25rem ring, 12%/25% wash),
   so the merge changed no geometry; the colours now follow the theme, which is
   a deliberate visual change in light theme.
   ============================================ */

.icon-ring {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  border: 1px solid var(--border-subtle);
  transition: background 200ms ease, border-color 200ms ease;
}

.icon-ring .icon {
  font-size: 1rem;
  width: 1.5em;
  height: 1.5em;
  color: var(--text);
}

/* Colour variants — wash and glyph read the same token, so they move together
   when a token is retuned and when the theme flips. Add a variant as a pair. */
.icon-ring--brand {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  border-color: color-mix(in srgb, var(--brand) 25%, transparent);
}

.icon-ring--brand .icon {
  color: var(--brand);
}

.icon-ring--cf {
  background: color-mix(in srgb, var(--accent-cf) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent-cf) 25%, transparent);
}

.icon-ring--cf .icon {
  color: var(--accent-cf);
}

.icon-ring--success {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  border-color: color-mix(in srgb, var(--success) 25%, transparent);
}

.icon-ring--success .icon {
  color: var(--success);
}

.icon-ring--info {
  background: color-mix(in srgb, var(--info) 12%, transparent);
  border-color: color-mix(in srgb, var(--info) 25%, transparent);
}

.icon-ring--info .icon {
  color: var(--info);
}

.icon-ring--warning {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  border-color: color-mix(in srgb, var(--warning) 25%, transparent);
}

.icon-ring--warning .icon {
  color: var(--warning);
}

.icon-ring--danger {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}

.icon-ring--danger .icon {
  color: var(--danger);
}

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

/* Typography helpers */
.text-display {
  font-size: clamp(2rem, 3.2vw, 3rem);
  line-height: 1.1;
  font-weight: var(--fw-bold);
  margin: 0;
}

.text-title {
  font-size: var(--fs-xl);
  line-height: 1.25;
  font-weight: var(--fw-semibold);
  margin: 0 0 var(--space-2);
}

.text-body {
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--text-main);
  margin: 0;
}

.text-lead {
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 var(--space-3);
}

.text-lg {
  font-size: var(--fs-lg);
  line-height: 1.4;
  font-weight: var(--fw-semibold);
  margin: 0;
}

.text-sm {
  font-size: var(--fs-sm);
}

.h1 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
  margin: 0;
}

.h2 {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  margin: 0;
}

.h3 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin: 0;
}

.h4 {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  margin: 0;
}

.h5 {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  margin: 0;
}

/* A colour utility sets colour. The 0.25rem top margin it used to carry stays
   only on muted TEXT BLOCKS (p, div, li, dd): with no `p { margin: 0 }` reset in
   this CSS, that rule is also what replaces the browser's 1em paragraph margins,
   and dropping it moved 131 of 165 muted blocks (measured 2026-11-05).
   `:where(…)` keeps the specificity of the old `.muted, .text-muted` (0,1,0)
   and this position in the file, so every text block cascades exactly as
   before. A muted span, small, summary or icon no longer gets a margin from its
   colour — that margin is what pushed flex children off-centre (and why
   `.text-subtle` was invented). The `.muted` alias left on 2026-11-08. */
.text-muted {
  color: var(--text-muted);
}

:where(p, div, li, dd).text-muted {
  margin: 0.25rem 0 0;
}

/* =========================
   Utility Classes
   ========================= */

/**
 * Color utilities
 * Use these classes to apply semantic colors to text elements.
 * Available in all components (buttons, badges, icons, text).
 */
.text-center {
  text-align: center;
}

/* Numeric/action columns. Used in 10 places (tables, drawers) and, until
   2026-07-28, defined nowhere — those columns silently rendered left-aligned. */
.text-right {
  text-align: right;
}

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

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

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

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

.text-subtle {
  /* Muted color WITHOUT the legacy top-margin that .text-muted carries — safe
     on icons / flex children (e.g. a nested badge status icon). */
  color: var(--text-muted);
}

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

.text-cf {
  color: var(--accent-cf);
}

/**
 * Inline editing pattern
 *
 * Usage example:
 * <div class="detail-row" data-edit-field="fieldname">
 *   <dt class="detail-label">Label</dt>
 *   <dd>
 *     <!-- View mode -->
 *     <div class="detail-value" data-view-mode>
 *       <span>Value</span>
 *       <button class="btn-inline" type="button" data-edit-trigger>
 *         <span class="icon" data-icon="mono/pencil-circle"></span>
 *       </button>
 *     </div>
 *     <!-- Edit mode -->
 *     <div class="detail-edit" data-edit-mode hidden>
 *       <input type="text" class="input" data-edit-input />
 *       <div class="btn-group">
 *         <button class="btn btn--sm btn--primary" data-save-btn>Save</button>
 *         <button class="btn btn--sm btn--ghost" data-cancel-btn>Cancel</button>
 *       </div>
 *     </div>
 *   </dd>
 * </div>
 *
 * JavaScript should toggle [hidden] attribute on data-view-mode / data-edit-mode elements.
 */
.btn-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0; /* a fixed target: long text beside it must not squeeze it */
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--r-field);
  transition: all 150ms ease;
}

.btn-inline:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.btn-inline .icon {
  width: 1rem;
  height: 1rem;
}

.detail-edit {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-self: start;
  width: 100%;
}

/* =========================
   Components
   ========================= */

.app-alert {
  position: absolute; /* Positioned within .utility-bar */
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--indicator-thickness); /* Sit above utility-bar border, don't overlap */
  z-index: var(--z-global-notice);
  background: var(--panel);
  /* No border needed - utility-bar border provides visual separation */
  transform: translateY(-100%);
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  /* Fade out first, then slide up */
  transition:
    opacity 200ms ease,
    transform 300ms ease 200ms;
  /* Match utility-bar inner padding for visual consistency */
  display: flex;
  align-items: center;
}

.app-alert[data-state='visible'],
.app-alert[data-notice='visible'] {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  /* Fade in, then slide down */
  transition:
    opacity 200ms ease,
    transform 300ms ease;
}

.app-alert__inner {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--page-gutter-desktop);
  padding-block: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--inline-gap);
}

.app-alert__content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--text-main);
}

.app-alert__text {
  margin: 0;
  font-size: var(--fs-md);
  line-height: 1.4;
}

/* Icons inherit color from parent automatically */

.app-alert__icon svg {
  width: 1.1em;
  height: 1.1em;
}

.app-alert__close {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.app-alert__close:hover,
.app-alert__close:focus-visible {
  color: var(--text-main);
  background: var(--bg-soft);
}

.app-alert__close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Cards */
.card {
  --card-bg: var(--panel);
  --card-border: var(--border-subtle);
  --card-radius: var(--radius-lg);
  --card-pad-x: var(--space-4);
  --card-pad-y: var(--space-4);
  --card-gap: var(--space-3);
  --card-shadow: var(--shadow-soft);
  --card-divider: 1px solid var(--card-border);

  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

.card__media {
  display: block;
  border-radius: calc(var(--card-radius) - 1px) calc(var(--card-radius) - 1px) 0 0;
  overflow: hidden;
  line-height: 0;
  margin: -1px -1px 0 -1px;
}

.card__media img,
.card__media picture,
.card__media svg {
  width: 100%;
  height: auto;
  display: block;
}

.card__header,
.card__body,
.card__footer {
  padding: var(--card-pad-y) var(--card-pad-x);
  margin: 0;
}

/* Merged 2026-08-01 — this selector was declared twice in a row, which is the
   exact shape the StyleGuide warns about even when, as here, the two blocks set
   different properties and nothing was actually broken. */
.card__header {
  border-bottom: var(--card-divider);
  padding-top: calc(var(--card-pad-y) - var(--space-2));
  padding-bottom: calc(var(--card-pad-y) - var(--space-2));
}

/* A header that folds its card open and shut (Namecheap domains in Edit
   integration) — the whole bar is the click target. */
.card__header--toggle {
  cursor: pointer;
}

.card__footer {
  border-top: var(--card-divider);
}

.card__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin: 0 0 var(--space-1);
}

.card__actions {
  display: flex;
  align-items: center;
  gap: var(--inline-gap);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}

.card__meta {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.card--panel {
  --card-bg: var(--panel);
  --card-border: var(--border-subtle);
  --card-shadow: var(--shadow-subtle);
}

.card--soft {
  --card-bg: var(--bg-soft);
  --card-border: var(--border-subtle);
  --card-shadow: none;
}

.card--ghost {
  --card-bg: transparent;
  --card-border: transparent;
  --card-shadow: none;
}

.card--compact {
  --card-pad-x: var(--space-3);
  --card-pad-y: var(--space-3);
  --card-gap: var(--space-2);
}

.card--emphasis {
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
  background: color-mix(in srgb, var(--card-bg) 70%, var(--primary-soft));
}

.card--accent {
  position: relative;
  overflow: hidden;
}

.card--accent::before {
  content: '';
  position: absolute;
  inset: 0;
  border-left: 4px solid var(--accent, var(--primary));
  border-radius: inherit;
  pointer-events: none;
}

/* Accent card, but with error color for 404 */
.card--accent-danger {
  --accent: var(--danger);
}

.card--accent-cf {
  --accent: var(--accent-cf);
}

.card--interactive {
  cursor: pointer;
  transition: border-color var(--transition-md), box-shadow var(--transition-md), background-color var(--transition-md);
}

.card--interactive:hover,
.card--interactive:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  background: color-mix(in srgb, var(--card-bg) 88%, var(--bg-elevated));
}

.card-section {
  padding: var(--space-4) 0 0;
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-4);
}

.card-section:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.card__header > *:first-child,
.card__body > *:first-child,
.card__footer > *:first-child {
  margin-top: 0;
}

.card__header > *:last-child,
.card__body > *:last-child,
.card__footer > *:last-child {
  margin-bottom: 0;
}

.list--spaced {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0;
}

.list--spaced > li + li {
  margin-top: var(--space-2);
}

/* Icons in lists and headings */
.list--spaced .icon,
.list--ruled .icon,
.h5 .icon,
h5 .icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  margin-right: 0.375em;
}

.list--spaced .icon[data-icon*="check"],
.list--ruled .icon[data-icon*="check"],
.h5 .icon[data-icon*="check"],
h5 .icon[data-icon*="check"] {
  color: var(--success);
}

.list--spaced .icon[data-icon*="close"],
.list--ruled .icon[data-icon*="close"],
.h5 .icon[data-icon*="close"],
h5 .icon[data-icon*="close"] {
  color: var(--danger);
}

.list--ruled {
  list-style: decimal;
  padding-left: 1.25rem;
  margin: 0;
}

.list--ruled > li + li {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: var(--card-divider, 1px solid var(--border-subtle));
}

/* Notice type colors - applied via utility-bar[data-border-flash] instead of app-alert border */
.app-alert--error .app-alert__icon {
  color: var(--danger);
}

.app-alert--success .app-alert__icon {
  color: var(--ok);
}

.app-alert--info .app-alert__icon {
  color: var(--brand);
}

.app-alert--warning .app-alert__icon {
  color: var(--warning);
}

.app-alert--danger .app-alert__icon {
  color: var(--danger);
}

@media (max-width: 768px) {
  .app-alert__inner {
    padding-inline: var(--page-gutter-mobile);
    align-items: flex-start;
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, 0.75rem);
}

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




.stack--xs {
  --stack-gap: var(--space-1);
}

.stack--sm {
  --stack-gap: var(--space-2);
}

.stack--md {
  --stack-gap: var(--space-4);
}

/* lg < xl, as the names say. Until 2026-11-05 they were the other way round
   (lg = --space-6, xl = --space-5); the five usages (four files) were renamed with the swap,
   so no gap on screen moved. */
.stack--lg {
  --stack-gap: var(--space-5);
}

.stack--xl {
  --stack-gap: var(--space-6);
}

/* Inline stack (horizontal) */
.stack-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.stack-inline--xs {
  gap: var(--space-1);
}

.stack-inline--sm {
  gap: var(--space-2);
}

.stack-inline--md {
  gap: var(--space-3);
}

/* .stack-list lives in layout.css, with this gap carried over. */

/* Prevent buttons from stretching to full width in column stacks */
.stack-list > .btn {
  align-self: flex-start;
}

.stack-list--xs {
  gap: var(--space-1);
}

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

.cluster {
  display: flex;
  align-items: center;
  gap: var(--inline-gap);
  flex-wrap: wrap;
}

.cluster--wrap {
  flex-wrap: wrap;
}

/* One line, never wraps. A .text-truncate child is white-space: nowrap, so its
   min-content width is the whole string; without min-width: 0 it cannot shrink
   and a long domain pushes the badge beside it onto a second line. */
.cluster--nowrap {
  flex-wrap: nowrap;
}

.cluster--nowrap > .text-truncate {
  min-width: 0;
}

/* Gap variants on the same scale as the documented .stack--* ones. Both were
   used with no rule behind them. Note --sm lands on --space-2, which is what
   --inline-gap already is: it states the default rather than changing it, and
   only --xs actually tightens. */
.cluster--xs {
  gap: var(--space-1);
}

.cluster--sm {
  gap: var(--space-2);
}

.cluster--md {
  gap: var(--space-3);
}

.cluster--lg {
  gap: var(--space-4);
}

.cluster--center {
  justify-content: center;
}

.cluster--between {
  justify-content: space-between;
  width: 100%;
}

.cluster--top {
  align-items: flex-start;
}

/* Text of different sizes on one line — a heading and the badge beside it.
   `center` lines up the boxes, not the letters: a 14px title next to a padded
   12px badge measured 1.1px apart (add-domains drawer, 2026-09-15). An icon in
   such a row belongs INSIDE the heading, where `.h5 .icon` sets its
   vertical-align; a bare icon item has no baseline of its own and would ride
   on its bottom edge. */
.cluster--baseline {
  align-items: baseline;
}

/* Promotional card layout - stacks vertically on mobile */
@media (max-width: 768px) {
  .cluster--promo {
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
  }

  .cluster--promo .stack {
    text-align: center;
  }
}

/* Card grid layout */
.card-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

.card-grid--2col {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card-grid--3col {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

@media (min-width: 1024px) {
  .card-grid--2col {
    grid-template-columns: repeat(2, 1fr);
  }

  .card-grid--3col {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* A third-party logo on a light plate (StyleGuide → Cards → "Logo tile").
   Light in BOTH themes on purpose: brand marks are drawn for a white page, and
   a dark one (FB-killa's #1D1D1D) vanishes on the dark card. */
.logo-tile {
  flex-shrink: 0;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  padding: var(--space-1);
  object-fit: contain;
  background: var(--gray-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

/* ===== Header stack ====================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--bg);
  border-bottom: 1px solid var(--border-subtle);
  /* Isolate stacking context for utility-bar positioning */
  isolation: isolate;
  /* Smooth transform for scroll hide/show */
  transition: transform 0.3s ease;
  transform: translateY(0);
}

/* Hide header when scrolling down */
.site-header.header-hidden {
  transform: translateY(-100%);
}

/* Compensate for absolutely positioned utility-bar */
.site-header + * {
  margin-top: 60px; /* Approximate utility-bar height */
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--inline-gap);
  padding-block: var(--space-2);
  position: relative;
  z-index: var(--z-indicator);
  background: var(--bg);
  border-bottom: 1px solid var(--border-subtle);
}

.primary-nav {
  display: flex;
  gap: var(--space-1);
  justify-content: center;
  flex: 1;
}

/* On dashboard pages the top bar is focused on the dashboard nav and the
   user-account utility — marketing links (Features/Pricing/Docs) would
   crowd it. The marketing nav stays visible on every public-layout page,
   regardless of auth state, so a logged-in user browsing /pricing or
   /features still sees the marketing section. */
body.layout-dashboard .primary-nav--public {
  display: none;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--inline-gap);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: var(--fw-semibold);
  text-decoration: none;
  color: var(--text-main);
}

.brand__logo {
  width: 1.75rem;
  height: 1.75rem;
  display: block;
}

.brand__text {
  line-height: 1;
}

.primary-nav a {
  color: var(--text-main);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

/* Tighter horizontal padding for the top nav so the longer RU labels (9 items
   when a logged-in user is on a content/docs page: app nav + marketing nav)
   fit inside the page-shell instead of overflowing the right gutter. */
.primary-nav a {
  padding-inline: var(--space-2);
}

.primary-nav a:hover {
  color: var(--brand);
  border-color: var(--border-subtle);
  background: var(--bg-soft);
}

/* icon button (compact, keeps header height tight) */
.btn-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(1em + 1.25rem);
  height: calc(1em + 1.25rem);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-pill);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
}

.btn-icon--compact {
  width: calc(1em + 1.25rem);
  height: calc(1em + 1.25rem);
  display: inline-grid;
  place-items: center;
}

/* Row-action button for dense tables. The size ladder here varies the rem part,
   not the em part, so the glyph keeps tracking its text: 0.75rem here, 1.25rem
   base, 2rem for --lg. Had no rule until 2026-08-01, so it rendered at the base
   36px inside 50px table rows — a button taking two thirds of the row height. */
.btn-icon--sm {
  width: calc(1em + 0.75rem);
  height: calc(1em + 0.75rem);
}

.btn-icon--lg {
  width: calc(1em + 2rem);
  height: calc(1em + 2rem);
  font-size: var(--fs-lg);
}

/* Icon button color variants */
.btn-icon.btn--primary,
.btn-icon--primary {
  background: var(--primary);
  color: var(--btn-text-on-dark);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}

.btn-icon.btn--primary:hover,
.btn-icon--primary:hover {
  background: var(--primary-hover);
}

.btn-icon.btn--success {
  background: var(--success);
  color: var(--btn-text-on-dark);
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
}

:root[data-theme="dark"] .btn-icon.btn--success {
  color: var(--btn-text-on-bright);
}

.btn-icon.btn--success:hover {
  background: color-mix(in srgb, var(--success) 88%, #000 6%);
}

.btn-icon.btn--info {
  background: var(--info, var(--primary));
  color: var(--btn-text-on-dark);
  border-color: color-mix(in srgb, var(--info, var(--primary)) 40%, transparent);
}

.btn-icon.btn--info:hover {
  background: color-mix(in srgb, var(--info, var(--primary)) 88%, #000 6%);
}

/* Danger hover variant (icon turns red on hover, no background change) */
.btn-icon--danger-hover:hover .icon {
  color: var(--danger);
}

.btn .icon,
.btn-icon .icon,
.btn-chip .icon,
.role-icon .icon {
  width: 1.25em;
  height: 1.25em;
}

.utility-bar .btn-icon .icon {
  color: var(--text);
}

.utility-bar .btn-icon:hover .icon {
  color: var(--primary);
}

.utility-bar {
  background: var(--panel);
  border-bottom: var(--indicator-thickness) solid var(--border-subtle);
  position: absolute; /* Also creates positioning context for .loading-bar */
  top: 100%;
  left: 0;
  right: 0;
  z-index: var(--z-base);
  transition: transform 0.3s ease, border-color 300ms ease;
  transform: translateY(0);
  overflow: visible; /* Allow dropdowns to overflow - was: hidden */
}

/* Hide utility-bar when scrolling down (first level to hide) */
.utility-bar.utility-bar-hidden {
  transform: translateY(-100%);
}

/* Border flash - colored border after loading completes with notice */
.utility-bar[data-border-flash='success'] {
  border-bottom-color: var(--success);
}

.utility-bar[data-border-flash='error'] {
  border-bottom-color: var(--danger);
}

.utility-bar[data-border-flash='info'] {
  border-bottom-color: var(--info);
}

/* Loading indicator bar (animated border with shimmer effect) */
.loading-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--indicator-thickness);
  background: var(--brand);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: var(--z-indicator);
  overflow: hidden;
}

.loading-bar[data-loading='true'],
.loading-bar[data-loading='flushing'] {
  opacity: 0.4; /* Base opacity for background color */
}

.loading-bar[data-loading='true']::before,
.loading-bar[data-loading='flushing']::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--brand) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s ease-in-out infinite;
}

/* Flushing state: shimmer runs once and fades out */
.loading-bar[data-loading='flushing']::before {
  animation: shimmer 1.5s ease-in-out 1; /* Run once, not infinite */
}

/* Color variants - Brand (blue) */
.loading-bar[data-type='brand'] {
  background: var(--brand);
}
.loading-bar[data-type='brand']::before {
  background: linear-gradient(90deg,
    transparent 0%,
    var(--brand) 50%,
    transparent 100%
  );
}

/* Cloudflare (orange) */
.loading-bar[data-type='cf'] {
  background: var(--accent-cf);
}
.loading-bar[data-type='cf']::before {
  background: linear-gradient(90deg,
    transparent 0%,
    var(--accent-cf) 50%,
    transparent 100%
  );
}

/* Success (green) */
.loading-bar[data-type='success'] {
  background: var(--success);
}
.loading-bar[data-type='success']::before {
  background: linear-gradient(90deg,
    transparent 0%,
    var(--success) 50%,
    transparent 100%
  );
}

/* Error (red) */
.loading-bar[data-type='error'] {
  background: var(--danger);
}
.loading-bar[data-type='error']::before {
  background: linear-gradient(90deg,
    transparent 0%,
    var(--danger) 50%,
    transparent 100%
  );
}

/* Info (blue) */
.loading-bar[data-type='info'] {
  background: var(--info);
}
.loading-bar[data-type='info']::before {
  background: linear-gradient(90deg,
    transparent 0%,
    var(--info) 50%,
    transparent 100%
  );
}

.utility-bar__inner {
  display: flex;
  align-items: center;
  gap: var(--inline-gap);
  padding-block: var(--space-2);
}

.utility-left {
  flex: 1 1 auto;
  min-width: 0;
}

.utility-right {
  display: flex;
  gap: var(--inline-gap);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumbs .crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: inherit;
  text-decoration: none;
}

.breadcrumbs .crumb:is(:hover, :focus) {
  color: var(--text);
}

.breadcrumbs .sep {
  opacity: 0.6;
}

.badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.75rem;
}

.lang-switcher {
  position: relative;
  display: inline-block;
  margin-left: 0.5rem;
}

/* Dropdown essentials scoped to the lang switcher. Public pages load only
   theme/layout/site — the dropdown component lives in tables.css, which they
   don't load — so without these the menu can't show/hide. All vars resolve
   from theme.css + layout.css (both loaded on public pages). */
.lang-switcher .dropdown__menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: max-content;
  width: max-content;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: var(--space-2) 0;
  display: none;
  z-index: var(--z-dropdown, 20);
}
.lang-switcher .dropdown__menu--align-left {
  left: 0;
  right: auto;
}
.lang-switcher.dropdown--open .dropdown__menu {
  display: block;
}
.lang-switcher .dropdown__item {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  text-align: left;
}
.lang-switcher .dropdown__item:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

/* Arrow keys move focus through dropdown rows (301-ui#297); without a mark
   the walk was invisible. Here, not in tables.css with the rest of the
   dropdown: the public pages load site.css only, and their language menu is
   a listbox too. The ring is the house one (`.btn-chip:focus-visible`), drawn
   inside the row — outside it the menu's own edge would clip it. */
.dropdown__item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.lang-switcher__trigger {
  gap: 0.4em;
}
.lang-flag {
  display: inline-block;
  width: 1.1rem;
  height: calc(1.1rem * 2 / 3); /* exact 3:2 — matches the 513×342 flag viewBox */
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 12%, transparent);
  flex-shrink: 0;
  vertical-align: middle;
}
.lang-flag img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lang-switcher__item {
  display: flex;
  align-items: center;
  gap: 0.5em;
}
.lang-switcher__item.is-active {
  font-weight: 600;
}

/* Controls row layout is defined in layout.css */

/* Hide primary nav when burger menu appears (at same breakpoint as burger shows) */
@media (max-width: 1023px) {
  .primary-nav {
    display: none;
  }

  /* Mobile nav drawer for public pages */
  body.mobile-menu-open:not(.layout-dashboard) .primary-nav:not([hidden]) {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-3) var(--page-gutter-mobile);
    gap: 0;
    box-shadow: var(--shadow-md);
    z-index: var(--z-dropdown);
  }

  body.mobile-menu-open:not(.layout-dashboard) .primary-nav a {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
  }
}

@media (max-width: 768px) {
  .utility-bar__inner {
    flex-wrap: wrap;
    row-gap: var(--space-1);
  }

  .utility-right {
    margin-left: auto;
  }

  .breadcrumbs .crumb:first-child [data-i18n="layout.nav.home"] {
    display: none;
  }
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  font-weight: var(--fw-semibold);
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 2rem 0;
  margin-top: auto; /* Push to bottom if using flex layout */
}

.footer-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.footer-brand {
  flex: 0 0 auto;
}

.footer-brand .text-muted {
  margin-top: 0.25rem;
  font-size: 0.875rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: flex-end;
}

.footer-nav .btn-chip {
  font-size: 0.875rem;
  text-decoration: none;
}

/* Ensure chip links work like buttons */
a.btn-chip {
  text-decoration: none;
}

.footer-legal {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-4);
}

.footer-legal a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-legal a:hover {
  color: var(--text-main);
}

.footer-legal .separator {
  opacity: 0.5;
}

/* Mobile: hide chip navigation in footer (will be in mobile menu) */
@media (max-width: 768px) {
  .footer-nav {
    display: none;
  }

  .footer-grid {
    justify-content: center;
  }

  .footer-brand {
    text-align: center;
  }

  .footer-legal {
    font-size: 0.75rem;
    gap: 0.5rem;
    padding: var(--space-3) 0 0;
    margin-top: var(--space-3);
  }
}

/*!
  * UI System 1.0 — Unified control recipe
  * Single source of truth for sizing across buttons, chips, tabs, inputs and the
  * table search bar. Variants must not override padding or height.
  */
/* Unified control recipe — SINGLE SOURCE OF TRUTH */
.control,
.select--control,
.table-search,
.btn,
.btn-chip,
.tabs__trigger {
  font-size: var(--fs-control);
  line-height: var(--lh-control);
  padding-block: var(--control-pad-y);
  padding-inline: var(--control-pad-x);
  min-height: var(--control-min-height);
  box-sizing: border-box;
}

.control,
.select--control,
.table-search,
.btn,
.btn-chip,
.tabs__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  white-space: nowrap;
}

.control,
.select--control,
.btn,
.btn-chip,
.tabs__trigger {
  justify-content: center;
}

.btn,
.btn-chip,
.table-search {
  border-width: var(--border-1);
  border-style: solid;
  border-color: transparent;
  border-radius: var(--r-pill);
}

/* Radius: pill vs field */
.tabs__trigger {
  border-radius: var(--control-radius);
}

.input,
.select,
.select--control,
.textarea {
  border-radius: var(--r-field);
}

/* @migration
   Legacy spacing and radius aliases have been removed; use --space-* and
   --control-radius with the unified control tokens.
   Legacy classes: .btn-ghost/.btn-danger → .btn.btn--ghost/.btn.btn--danger.
*/

.btn {
  font-weight: var(--fw-medium);
  text-decoration: none;
  color: inherit;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-md);
}

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

/* Turnstile loading state - animated shimmer effect */
.btn[data-turnstile-pending]:disabled {
  position: relative;
  overflow: hidden;
  opacity: 1;
  cursor: wait;
}

.btn[data-turnstile-pending]:disabled::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 50%,
    transparent 100%
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn--sm {
  font-size: calc(var(--fs-control) * var(--control-scale-sm));
  padding-block: calc(var(--control-pad-y) * var(--control-scale-sm));
  padding-inline: calc(var(--control-pad-x) * var(--control-scale-sm));
  min-height: calc(var(--control-min-height) * var(--control-scale-sm));
}

.btn--lg {
  font-size: calc(var(--fs-control) * 1.05);
  padding-block: calc(var(--control-pad-y) * var(--control-scale-lg));
  padding-inline: calc(var(--control-pad-x) * var(--control-scale-lg));
  min-height: calc(var(--control-min-height) * var(--control-scale-lg));
}

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

.btn--primary:hover {
  background: var(--primary-hover);
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
}

.btn--ghost {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn--ghost:hover {
  background: var(--panel);
  border-color: var(--border-strong);
  color: var(--text-main);
}

.btn--cf {
  background: var(--accent-cf-bg, var(--accent-cf));
  color: var(--btn-text-on-dark);
  border-color: var(--accent-cf-soft, transparent);
}

.btn--cf:hover {
  background: var(--accent-cf-bg-hover, var(--accent-cf-hover));
}

/* Fill is --danger-solid, not --danger: white on the dark theme's #FF4F6E is
   3.18:1 and failed AA; --danger stays for red TEXT and icons (301-ui#276). */
.btn--danger {
  background: var(--danger-solid);
  color: var(--btn-text-on-dark);
  border-color: color-mix(in srgb, var(--danger-solid) 40%, transparent);
}

.btn--danger:hover {
  background: color-mix(in srgb, var(--danger-solid) 88%, #000 6%);
}

.btn--success {
  background: var(--success);
  color: var(--btn-text-on-dark);
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
}

/* Dark theme: bright green (#18C27A) needs dark text — white is only 2.32:1 */
:root[data-theme="dark"] .btn--success {
  color: var(--btn-text-on-bright);
}

.btn--success:hover {
  background: color-mix(in srgb, var(--success) 88%, #000 6%);
}

.btn--info {
  background: var(--info, var(--primary));
  color: var(--btn-text-on-dark);
  border-color: color-mix(in srgb, var(--info, var(--primary)) 40%, transparent);
}

.btn--info:hover {
  background: color-mix(in srgb, var(--info, var(--primary)) 88%, #000 6%);
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--primary);
  padding: 0;
  height: auto;
  min-height: auto;
  gap: var(--space-1);
  font-weight: 500;
}

.btn-link:hover {
  color: color-mix(in srgb, var(--primary) 88%, #fff 12%);
  text-decoration: underline;
  background: transparent;
}

.btn-link--sm {
  font-size: var(--fs-sm);
}

/* Icon sizing unified above */

/* Chevron of a dropdown chip: turns when its menu opens. */
.btn-chip__chevron {
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.dropdown__trigger[aria-expanded="true"] .btn-chip__chevron {
  transform: rotate(180deg);
}

.btn-chip--dropdown:hover .btn-chip__chevron {
  opacity: 1;
}

/* Dropdown item badge positioning */
.dropdown__item .badge {
  margin-left: auto;
}

html[data-theme="light"] .btn--ghost {
  background: var(--bg);
  color: var(--text-main);
  border-color: color-mix(in srgb, var(--text-main) 10%, transparent);
}

html[data-theme="light"] .btn--ghost:hover {
  background: var(--bg);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
  color: var(--primary);
}

/* =========================
   Segmented / chip buttons
   (inherits unified control sizing: no extra height/padding overrides)
   ========================= */

.btn-chip-group {
  display: inline-flex;
  padding: calc(var(--space-1) / 2);
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  gap: calc(var(--space-1) / 2);
}

.btn-chip {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text);
  font-weight: var(--fw-medium);
  cursor: pointer;
  text-decoration: none;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

.btn-chip:hover {
  background: var(--bg-soft);
  border-color: var(--brand);
  color: var(--text);
}

/* Icon sizing unified above */
.btn-chip svg {
  width: 0.875em;
  height: 0.875em;
  flex: 0 0 0.875em;
}

/* The `.btn-chip`-scoped pair is there to WIN: `.btn-chip .icon` (0,2,0) set
   the height to 1.25em while this rule's basis kept the width at 0.875em, so
   every chip chevron was a 12×18 box (measured 2026-11-05). */
.btn-chip__icon,
.btn-chip__chevron,
.btn-chip .btn-chip__icon,
.btn-chip .btn-chip__chevron {
  width: 0.875em;
  height: 0.875em;
  flex: 0 0 0.875em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit; /* Inherit from .btn-chip for proper currentColor flow */
}

.btn-chip__label {
  line-height: inherit;
  white-space: nowrap;
}

/* Table filter chip: the label carries the chosen value ("Project: …"), so cap it.
   38vw keeps a phone row as wide as the old 20-character cut — the filter row
   (.controls-row__filters) does not shrink, so the chip has to. */
[data-filter-id] .btn-chip__label {
  max-width: min(14rem, 38vw);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badge inside chip — align with control recipe */
.btn-chip .badge {
  font-size: 0.7em;
  line-height: 1;
  padding: 0.2em 0.5em;
  margin-inline: 0;
}

/* Small chip variant (sm scale) */
.btn-chip--sm {
  font-size: calc(var(--fs-control) * var(--control-scale-sm));
  padding-block: calc(var(--control-pad-y) * var(--control-scale-sm));
  padding-inline: calc(var(--control-pad-x) * var(--control-scale-sm));
  min-height: calc(var(--control-min-height) * var(--control-scale-sm));
}

.btn-chip--ghost {
  background: var(--panel);
  color: var(--text);
}

.btn-chip--input {
  display: inline-flex;
  align-items: center;
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text);
}

.btn-chip--input:focus-within {
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 40%, transparent);
}

.btn-chip--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--btn-text-on-dark);
}

.btn-chip--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--btn-text-on-dark);
}

.btn-chip--cf {
  background: var(--accent-cf-soft);
  border-color: transparent;
  color: var(--accent-cf-bg);
}

.btn-chip--cf:hover {
  background: var(--accent-cf-bg);
  color: var(--btn-text-on-dark);
}

.btn-chip--dropdown {
  color: var(--text);
}

/* Preserve color variants when combined with dropdown */
.btn-chip--primary.btn-chip--dropdown {
  color: var(--btn-text-on-dark);
}

.btn-chip--dropdown.is-open {
  background: var(--panel);
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

/* Keep primary color even when open */
.btn-chip--primary.btn-chip--dropdown.is-open {
  background: var(--primary);
  border-color: var(--brand);
  color: var(--btn-text-on-dark);
}

.btn-chip.is-active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
}

.btn-chip > * {
  margin: 0;
}

.btn-chip:focus-visible,
.tabs__trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ============================================
   TABS COMPONENT (segmented control)
   Core component — lives in site.css so it styles on every page
   (auth/landing loads site.css but not tables.css). Same engine and
   markup contract as the section tabs (`src/ui/tabs.ts`); only the look
   differs. A segmented control switches a MODE, section tabs switch a
   SECTION (StyleGuide → Tabs).
   ============================================ */

/* Tabs navigation track */
.tabs__nav {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-2);
  /* Recessed track, theme-aware (was undefined --panel-subtle → invisible).
     Tint the card toward the text colour so it reads as a sunken groove in
     light AND dark, against the raised active pill (--bg + border + shadow). */
  background: color-mix(in srgb, var(--text) 7%, var(--bg-elevated));
  box-shadow: inset 0 0 0 1px var(--border-subtle);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}

/* Tabs trigger layout/state — sizing comes from the unified control recipe above */
.tabs__trigger {
  flex: 1;
  background: transparent;
  /* Visible outline on BOTH segments (incl. the inactive one) so each reads
     as a button; the active pill still stands out via --bg fill + shadow. */
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-md);
}

.tabs__trigger:hover {
  background: var(--panel);
  color: var(--text);
}

.tabs__trigger.is-active {
  background: var(--bg);
  /* Stronger than --border-subtle (6%): the subtle token was invisible in
     dark, leaving the active pill defined only by bg contrast. --border-strong
     gives a crisp edge in both themes. */
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Tabs panels — shown and hidden by the `hidden` attribute, like `.tab-panel`. */
.tabs__panel {
  padding-top: var(--space-3);
}

.btn-icon--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-icon--ghost:hover {
  /* A wash of the theme's own text colour: light over dark, dark over light.
     The white rgba it replaced was invisible on the light theme (301-ui#276). */
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text);
}

.btn-icon--neutral {
  background: var(--panel);
  border-color: var(--border-subtle);
  color: var(--text-muted);
}

.btn-icon--neutral:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
  color: var(--text);
}

/* ========================================
   PAGE-SPECIFIC: AUTH / LOGIN
   ======================================== */

.auth-shell {
  padding: 0 0 var(--space-6);
}

.auth-hero__header {
  margin-bottom: var(--space-4);
}

.auth-hero__header .h1 {
  margin: 0 0 var(--space-2);
}

.auth-hero {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}

/* Let grid tracks shrink below their content's min-content width so a wide
   child (e.g. the auth card) can't blow the row past the viewport on mobile. */
.auth-hero > * {
  min-width: 0;
}

/* Feature cards — landing-style with icon rings */
.feature-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
}

.feature-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.feature-card p {
  margin: var(--space-1) 0 0;
}


.auth-hero__steps .text-muted {
  margin: 0 0 var(--space-3);
}

/* Quick Start — full content width below the hero */
.auth-hero__steps--wide {
  margin-top: var(--space-5);
}

/* How It Works — SEO prose block (logged-out landing) */
.how-it-works {
  position: relative;
  isolation: isolate;
  max-width: 760px;
  margin: var(--space-6) 0 0;
}

/* Ambient brand accent behind the block — pure CSS, themes via --brand, sits
   behind the prose at low alpha and fades at the edges so it never hurts
   readability. Replaces a heavier stock-banner background. */
.how-it-works::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -2.5rem -5rem;
  pointer-events: none;
  background:
    radial-gradient(
      70% 140% at 10% -15%,
      color-mix(in srgb, var(--brand) 18%, transparent),
      transparent 62%
    ),
    radial-gradient(
      60% 130% at 94% 120%,
      color-mix(in srgb, var(--brand) 14%, transparent),
      transparent 60%
    );
  -webkit-mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent);
}

.how-it-works__lead {
  font-size: var(--fs-md);
  line-height: 1.6;
}

.how-it-works__links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}

/* Contact form page */
.contact-form-wrap {
  max-width: 580px;
}

@media (max-width: 768px) {
  .auth-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-card {
    padding: 1rem;
  }

  /* Trim the decorative glow's horizontal bleed on mobile — the -5rem
     inset-inline pushes the scroll area past the viewport (390px → 454px). */
  .how-it-works::before {
    inset-inline: -1rem;
  }
}

.auth-grid {
  display: grid;
  gap: var(--stack-gap);
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  align-items: start;
}

.auth-card {
  background: var(--bg-elevated);
  border: var(--border-width) var(--border-style) var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: none;
  position: relative;
}

.auth-grid > .auth-card {
  margin-top: 0;
}

.auth-card h1 {
  margin: 0 0 var(--space-2);
}

.auth-card .auth-subtitle {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
}

.auth-section__header {
  margin: 0 0 var(--space-4);
}

.auth-title {
  margin: 0 0 var(--space-2);
}

/* "Forgot password?" and friends under the sign-in button. */
.auth-form__links {
  margin-top: var(--space-3);
}

.auth-subtitle {
  margin: 0;
  color: var(--text-muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.field label,
.field-label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}

.field-hint {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin: -0.25rem 0 0;
}

/* A link line under a field's input (the geo extension in the TDS editor).
   Unlike .field-hint it keeps the paragraph's own bottom margin. */
.field-link {
  margin-top: 0.25em;
}

/* Required-field marker. Was written as `field__required` for months with no
   rule behind it, so the asterisk inherited the label's muted grey and read as
   decoration. Red is the convention users already know. */
.field-required {
  color: var(--danger);
  font-weight: var(--fw-medium);
}

.input {
  font-size: var(--fs-control);
  line-height: var(--lh-control);
  padding-block: var(--control-pad-y);
  padding-inline: var(--control-pad-x);
  min-height: var(--control-min-height);
  border: var(--border-1) solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  -webkit-appearance: none;
  appearance: none;
  transition:
    border-color var(--transition-md),
    box-shadow var(--transition-md),
    background var(--transition-md);
}

/* A spam trap: off-screen for people, present for form-filling bots. The
   wrapper also carries aria-hidden and the input tabindex="-1". */
.form-honeypot {
  position: absolute;
  left: -9999px;
}

.input:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--brand), transparent 80%);
}

.field[data-status='error'] .input,
.field[data-status='error'] .textarea,
.input.is-error,
.textarea.is-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--danger), transparent 85%);
}

.field[data-status='success'] .input,
.field[data-status='success'] .textarea {
  border-color: var(--ok);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--ok), transparent 88%);
}

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

.textarea {
  font-size: var(--fs-control);
  line-height: var(--lh-control);
  padding-block: var(--control-pad-y);
  padding-inline: var(--control-pad-x);
  border: var(--border-1) solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  -webkit-appearance: none;
  appearance: none;
  resize: vertical;
  min-height: calc(3 * 1em * var(--lh-control) + 2 * var(--control-pad-y) + 2px);
  transition:
    border-color var(--transition-md),
    box-shadow var(--transition-md),
    background var(--transition-md);
}

.field-error {
  color: var(--danger);
  font-size: var(--fs-sm);
  margin: -0.25rem 0 0;
}

.field-success {
  color: var(--success);
  font-size: var(--fs-sm);
  margin: -0.25rem 0 0;
}

/* The middle tone: not wrong, worth a look (a "fair" password, an unusual value). */
.field-warning {
  color: var(--warning);
  font-size: var(--fs-sm);
  margin: -0.25rem 0 0;
}

/* Collapsible field group (native <details>) */
.field-details {
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-field);
  padding: var(--space-2) var(--space-3);
}

.field-details__summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.field-details__summary::-webkit-details-marker {
  display: none;
}

.field-details__summary::before {
  content: '›';
  font-size: 1.1em;
  transition: transform 150ms ease;
}

.field-details[open] > .field-details__summary::before {
  transform: rotate(90deg);
}

.field-details__body {
  padding-top: var(--space-3);
}

.field-details__body .field:last-child {
  margin-bottom: 0;
}

.password-field {
  position: relative;
}

.password-field .input {
  width: 100%;
  padding-right: calc(var(--control-pad-x) + 1.4em);
}

.password-toggle {
  position: absolute;
  inset-inline-end: 0.5em;
  top: 50%;
  transform: translateY(-50%);
  height: 1.2rem;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
}

.password-toggle .icon {
  width: 1rem;
  height: 1rem;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--inline-gap);
  margin-top: var(--stack-gap);
}

/* Tabs handle Login↔Register switching, so each view keeps a single primary
   action — stretch it full-width. */
.auth-actions > .btn:only-child {
  flex: 1 1 100%;
}

.auth-actions .btn {
  flex: 1 1 0;
  min-width: 11.25rem;
}

.auth-social {
  margin-top: var(--space-4);
}

/* The register "one click" social fieldset needs breathing room from the
   primary action above it (its legend sits right on the top border). */
.auth-form .fieldset-group {
  margin-top: var(--space-4);
}

/* Inside that fieldset the legend already provides the heading + spacing, so
   drop the social block's standalone top margin. */
.fieldset-group > .auth-social {
  margin-top: 0;
}

.auth-social__buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Line under the provider buttons saying where the password is actually typed.
   Centred against the full-width buttons above it; the muted size comes from
   the utility classes on the element itself. */
.auth-social__note {
  margin-top: var(--space-3);
  margin-bottom: 0;
  text-align: center;
}

.btn--social {
  gap: var(--space-2);
  justify-content: flex-start;
}

.btn--social [data-social-label] {
  line-height: 1.2;
}


.btn--social-google {
  background: #fff; /* брендовый white ok */
  color: var(--text);
  border-color: rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] .btn--social-google {
  background: var(--panel);
  border-color: var(--border-subtle);
}

.btn--social-github {
  background: #0f1116;
  color: #fff;
  border-color: var(--gray-700);
}

.btn--social-github:hover {
  background: #1a1d24;
  border-color: var(--gray-600);
  color: #fff;
}

html[data-theme="light"] .btn--social-github {
  background: #0f1116;
}

.btn--social-yandex {
  background: #fff;
  color: var(--text);
  border-color: rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] .btn--social-yandex {
  background: var(--panel);
  border-color: var(--border-subtle);
}

.auth-social__buttons .btn--social {
  width: 100%;
  justify-content: center;
}

.auth-status {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: var(--bg-soft);
  color: var(--text-main);
}

.auth-status[data-turnstile-status] {
  margin-top: var(--space-5);
  padding: var(--space-4);
  gap: var(--space-2);
  display: flex;
  justify-content: center;
  align-items: center;
}

.auth-status[data-turnstile-status] .turnstile-widget {
  width: 100%;
  max-width: 100%;
  min-height: 65px;
  overflow: hidden;
}

.auth-status[data-type='error'] {
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
  color: var(--danger);
  background: var(--bg-danger);
}

.auth-status[data-type='success'] {
  border-color: color-mix(in srgb, var(--success) 60%, transparent);
  color: var(--success);
  background: var(--bg-success);
}

.auth-status[data-type='loading'],
.auth-status[data-type='pending'] {
  color: var(--text-muted);
}

/* Idle = the default "enter your email…" hint. Don't state the obvious — the
   block only appears for real feedback (pending/error/success). */
.auth-status[data-type='idle'] {
  display: none;
}

.auth-form {
  display: flex;
  flex-direction: column;
}

.auth-form > .auth-status:first-child {
  margin-top: 0;
}

.avatar-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar-ring {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.avatar-icon {
  width: 1.75rem;
  height: 1.75rem;
  display: block;
}

.avatar-meta {
  color: var(--text-muted);
  margin: 0;
}

/* Avatar preview in auth forms — pinned at the card's top-right, level with
   the tabs. The full-width segmented .tabs__nav reserves room on its right
   (see .auth-card > .tabs__nav below) so the avatar never overlaps it. */
.auth-form .avatar-preview {
  position: absolute;
  /* Card padding (1.75rem) puts the avatar's TOP level with the tab row, but the
     4rem avatar is taller than the tab strip, so its centre drifted below. Pull
     up by the strip's overhang (≈ one --space-2) to centre it on the tab row. */
  top: calc(1.75rem - var(--space-2));
  right: 1.75rem;
  flex-direction: row;
  gap: 0;
  align-items: center;
  z-index: var(--z-elevated);
}

.auth-form .avatar-ring {
  width: 4rem;
  height: 4rem;
}

.auth-form .avatar-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
}

.auth-form .avatar-meta {
  display: none; /* Hide text label - email is visible in input */
}

/* Reserve space on the segmented control so the top-right avatar clears it */
.auth-card > .tabs__nav {
  margin-inline-end: calc(4rem + var(--space-3));
}

/* Hide avatar on tablets and mobile to prevent layout issues */
@media (max-width: 1024px) {
  .auth-form .avatar-preview {
    display: none;
  }

  .auth-card > .tabs__nav {
    margin-inline-end: 0;
  }
}

@media (max-width: 640px) {

  .auth-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ========================================
   SHARED COMPONENTS
   ======================================== */

/* Text utilities */
.text-xs {
  font-size: var(--fs-xs);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em; /* em-relative, matches the badge's em padding; tight space before a trailing status icon */
  padding-inline: 0.75em;
  padding-block: 0.15em;
  border-radius: var(--r-pill);
  border: 1px solid transparent;

  font-size: var(--fs-xs);
  line-height: 1.6;
  font-weight: var(--fw-medium);
  white-space: nowrap;

  background-color: color-mix(in srgb, var(--text) 3%, transparent);
  color: var(--text);
}

/* Secondary badge for dense rows — a locale tag beside a domain, a count in the
   sidebar. Font size is already the smallest token, so compactness comes from
   padding; shrinking the text further would undo the contrast work above.
   Had no rule until 2026-08-01: `badge--sm` and a plain badge measured
   pixel-identical, so every author who reached for it got nothing. */
.badge--sm {
  padding-inline: 0.5em;
  padding-block: 0.05em;
  gap: 0.2em;
}

.badge--pill {
  border-radius: var(--r-pill);
}

.badge--circle {
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
}

.badge + .badge {
  margin-left: var(--space-1);
}

.badge--neutral {
  background-color: color-mix(in srgb, var(--text) 2%, transparent);
  border-color: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--muted);
}

.badge--success {
  background-color: color-mix(in srgb, var(--ok) 12%, transparent);
  border-color: color-mix(in srgb, var(--ok) 50%, transparent);
  color: var(--ok);
}

.badge--danger {
  background-color: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  color: var(--danger);
}

/* Same fix as --brand below, same reason: --primary is darker than its own wash,
   which measured 3.17:1 in dark theme. --primary-hover is the higher-contrast
   primary in both themes → 5.69:1. */
.badge--primary {
  background-color: var(--primary-soft);
  border-color: color-mix(in srgb, var(--blue-neon) 50%, transparent);
  color: var(--primary-hover);
}

/* Same pair as --primary above, so the same fix: --primary on --primary-soft
   measured 3.17:1 in dark. Missed on the first pass because the contrast sweep
   rendered eight variants and this was the ninth — a reminder that "all the
   badges I could see" is not the same set as "all the badges". */
.badge.badge--info {
  background-color: var(--primary-soft);
  border-color: color-mix(in srgb, var(--blue-neon) 50%, transparent);
  color: var(--primary-hover);
}

.badge--ok {
  background-color: color-mix(in srgb, var(--ok) 12%, transparent);
  border-color: color-mix(in srgb, var(--ok) 50%, transparent);
  color: var(--ok);
}

.badge--warning {
  background-color: color-mix(in srgb, var(--warning) 12%, transparent);
  border-color: color-mix(in srgb, var(--warning) 50%, transparent);
  color: var(--warning);
}

/* Text is --primary-hover, not --brand. Every other dark badge pairs a light
   accent wash with light accent text; brand alone used --primary (#3475C0),
   which is darker than its own wash and measured 2.79:1 on the /redirects rows
   — the "Target" badge on every acceptor row failed AA. --primary-hover is the
   higher-contrast primary in BOTH themes (#4DA3FF dark, #003682 light), so one
   token fixes dark without dulling light. Raising the wash alpha would have made
   it worse: the wash is lighter than the text, so more of it cuts contrast.
   The wash is the brand blue #4DA3FF (owner, 2026-11-04) at 13%: lighter than
   the old #5E8BFF, so 16% of it dropped contrast 5.85 → 5.68; 13% is 5.99. */
.badge--brand {
  background-color: color-mix(in srgb, var(--blue-neon) 13%, transparent);
  border-color: color-mix(in srgb, var(--blue-neon) 55%, transparent);
  color: var(--primary-hover);
}

.badge--cf {
  background-color: color-mix(in srgb, var(--orange-500) 15%, transparent);
  border-color: color-mix(in srgb, var(--orange-500) 55%, transparent);
  color: var(--orange-500);
}

:root[data-theme='light'] .badge {
  background-color: color-mix(in srgb, var(--text) 5%, var(--bg));
  border-color: color-mix(in srgb, var(--text) 18%, transparent);
  color: var(--text);
}

:root[data-theme='light'] .badge--neutral {
  background-color: color-mix(in srgb, var(--text) 5%, var(--bg));
  border-color: color-mix(in srgb, var(--text) 22%, transparent);
  color: var(--muted);
}

:root[data-theme='light'] .badge--success {
  /* 16% put the wash at rgb(216,234,226) and the text at 4.24:1 — under AA.
     A lighter wash raises contrast, because here the text is the darker of the
     two. This is the app's most common badge ("Active"), on its lightest theme. */
  background-color: color-mix(in srgb, var(--ok) 9%, var(--bg));
  border-color: color-mix(in srgb, var(--ok) 42%, transparent);
  color: var(--ok);
}

/* Light-theme badges: the text is the darker of the two, so contrast is bought by
   darkening the text rather than washing out the fill. Measured on the card/table
   backdrop these badges actually sit on: --danger alone gave 3.79:1, and dropping
   the fill far enough to fix it (4%) left an almost-white badge with no identity.
   Darkening the text keeps the fill and clears AA. */
:root[data-theme='light'] .badge--danger {
  background-color: color-mix(in srgb, var(--danger) 16%, var(--bg));
  border-color: color-mix(in srgb, var(--danger) 44%, transparent);
  color: color-mix(in srgb, var(--danger) 85%, var(--gray-950));
}

:root[data-theme='light'] .badge--ok {
  background-color: color-mix(in srgb, var(--ok) 9%, var(--bg));
  border-color: color-mix(in srgb, var(--ok) 42%, transparent);
  color: var(--ok);
}

:root[data-theme='light'] .badge--warning {
  background-color: color-mix(in srgb, var(--warning) 16%, var(--bg));
  border-color: color-mix(in srgb, var(--warning) 42%, transparent);
  color: color-mix(in srgb, var(--warning) 85%, var(--gray-950));
}

:root[data-theme='light'] .badge--brand {
  background-color: color-mix(in srgb, var(--brand) 14%, var(--bg));
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
  color: var(--brand);
}

:root[data-theme='light'] .badge--cf {
  background-color: color-mix(in srgb, var(--accent-cf-bg) 14%, var(--bg));
  border-color: color-mix(in srgb, var(--accent-cf-bg) 40%, transparent);
  color: color-mix(in srgb, var(--accent-cf-bg) 85%, var(--gray-950));
}

/* --primary had no light rule, so `:root[data-theme='light'] .badge` (0,3,0)
   beat `.badge--primary` (0,1,0) and the badge rendered as a grey neutral —
   found by the badge-contrast sweep, 2026-11-05. Same pair as --info. */
:root[data-theme='light'] .badge--primary,
:root[data-theme='light'] .badge.badge--info {
  background-color: color-mix(in srgb, var(--primary) 12%, transparent);
  border-color: color-mix(in srgb, var(--primary) 50%, transparent);
  color: var(--primary);
}

/* Link buttons */
.link-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: var(--fs-sm);
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: var(--radius);
}

.link-button:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.link-button--sm {
  font-size: var(--fs-xs);
}

/* ============================================
   Links (global styles)
   ============================================ */
.link {
  color: var(--primary);
  text-decoration: none;
  transition: color 150ms ease;
}

.auth-card .link {
  color: var(--blue-neon);
}

.link:hover {
  color: var(--primary-hover);
}

.link--sm {
  font-size: var(--fs-sm);
}

/* A link with icons beside its text (an extension store link). */
.link--icon {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

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

.link--muted:hover {
  color: var(--primary);
}

/* CTA / navigational link with a trailing arrow that nudges on hover
   (Google-style). Pure CSS — no extra markup, just add the class. The arrow
   inherits the link colour, so it's theme-aware. Use ONLY on action links
   ("Manage billing →"), never on inline body links where it reads as broken. */
.link--arrow::after {
  content: "\2192";
  display: inline-block;
  margin-inline-start: 0.3em;
  transition: transform 150ms ease;
}

.link--arrow:hover::after {
  transform: translateX(0.2em);
}

/* ============================================
   Dashboard Layout System
   ============================================ */
:root {
  /* Sidebar dimensions (reactive to collapsed state) */
  --sidebar-width: 280px;
  --sidebar-width-collapsed: 72px;
  --sidebar-transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout heights */
  --header-height: 96px;          /* site-header + utility-bar */
  --footer-height: 120px;

  /* Dashboard grid */
  --dashboard-gap: 1.5rem;        /* = --space-5 */
}

/* Dashboard Shell: Grid that reacts to sidebar state */
.dashboard-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas: "sidebar content";
  gap: var(--dashboard-gap);
  align-items: start;
  min-height: calc(100dvh - var(--header-height) - var(--footer-height));
}

/* Collapsed state: Grid adjusts automatically */
body.sidebar-collapsed .dashboard-shell {
  grid-template-columns: var(--sidebar-width-collapsed) 1fr;
}

/* Sidebar */
.sidebar {
  grid-area: sidebar;
  position: sticky;
  top: var(--header-height);
  max-height: calc(100dvh - var(--header-height));
  background: var(--panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  transition: width var(--sidebar-transition);
}

/* Верхняя зона сайдбара */
.sidebar__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

/* Mobile close button (visible on mobile, hidden on desktop) */
.sidebar__close-mobile {
  display: inline-grid;
}

.sidebar__toggle-desktop {
  display: none;
}

@media (min-width: 1024px) {
  .sidebar__close-mobile {
    display: none;
  }

  .sidebar__toggle-desktop {
    display: inline-grid;
  }
}

/* Навигация */
.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sidebar .navitem {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  position: relative;
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  color: var(--text-muted);
  text-decoration: none;
  /* Merged 2026-08-01 from a second `.sidebar .navitem` block twenty lines below.
     That block won, so this one's `var(--transition-fast)` (120ms) never applied —
     the sidebar has been animating at a hardcoded 200ms. Kept at 200ms here so
     nothing changes speed today; the token discrepancy is now visible instead of
     buried in a duplicate. Neither --transition-fast (120ms) nor --transition-md
     (160ms) matches it, so picking one is a deliberate call, not a cleanup. */
  transition:
    background 200ms ease,
    color 200ms ease,
    transform 150ms ease;
}

.sidebar .navitem .icon {
  flex-shrink: 0;
}

.sidebar .navitem .label {
  flex: 1;
  min-width: 0;
}

.sidebar .navitem:hover {
  background: var(--bg-soft);
  color: var(--text);
  transform: translateX(2px);
}

/* Active state with left accent bar */
.sidebar .navitem.is-active {
  background: var(--bg-soft);
  color: var(--text);
}

.sidebar .navitem.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}

/* Focus visible (accessibility) */
.sidebar .navitem:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.sidebar__spacer {
  flex: 1 1 auto;
}

/* ============================================
   Sidebar Collapse Animations
   ============================================ */

/* Labels fade out on collapse */
.sidebar .label {
  opacity: 1;
  transition: opacity 200ms ease-in-out;
}

body.sidebar-collapsed .sidebar .label {
  opacity: 0;
  pointer-events: none;
}

/* Badges visible in expanded state */
.sidebar .navitem .badge {
  opacity: 1;
  pointer-events: auto;
}

/* Hide badges in collapsed state (only notification icons shown) */
body.sidebar-collapsed .sidebar .navitem .badge {
  display: none;
}

/* Notification icon (alert dot) */
.sidebar .navitem .notification-icon {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--warning);
  display: flex;
  align-items: center;
}

.sidebar .navitem .notification-icon .icon {
  width: 0.5rem;
  height: 0.5rem;
}

.sidebar .navitem .notification-icon--danger {
  color: var(--danger);
}

.sidebar .navitem .notification-icon--warning {
  color: var(--warning);
}

.sidebar .navitem .notification-icon--success {
  color: var(--success);
}

.sidebar .navitem .notification-icon--primary {
  color: var(--primary);
}

/* Notification icon in dropdowns */
.dropdown__item .notification-icon {
  flex-shrink: 0;
  color: var(--warning);
  display: flex;
  align-items: center;
}

.dropdown__item .notification-icon .icon {
  width: 0.5rem;
  height: 0.5rem;
}

.dropdown__item .notification-icon--danger {
  color: var(--danger);
}

.dropdown__item .notification-icon--warning {
  color: var(--warning);
}

.dropdown__item .notification-icon--success {
  color: var(--success);
}

.dropdown__item .notification-icon--primary {
  color: var(--primary);
}

/* Notification icon in tables */
.table .notification-icon,
.domain-cell .notification-icon {
  flex-shrink: 0;
  color: var(--warning);
  display: flex;
  align-items: center;
}

.table .notification-icon .icon,
.domain-cell .notification-icon .icon {
  width: 0.5rem;
  height: 0.5rem;
}

.table .notification-icon--danger,
.domain-cell .notification-icon--danger {
  color: var(--danger);
}

.table .notification-icon--warning,
.domain-cell .notification-icon--warning {
  color: var(--warning);
}

.table .notification-icon--success,
.domain-cell .notification-icon--success {
  color: var(--success);
}

.table .notification-icon--primary,
.domain-cell .notification-icon--primary {
  color: var(--primary);
}

/* Checkbox field (for checkbox + domain-cell layout) */
.checkbox-field {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  cursor: pointer;
}

.checkbox-field input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 0.25em; /* Fine-tune vertical alignment with text baseline */
}

/* ============================================
   Toggle (on/off switch) — 301-ui#273
   A real <input type="checkbox" role="switch"> underneath: keyboard (Space),
   form value and screen-reader state come from the browser; the track and
   thumb are only its look. For settings that are "on / off", where a
   checkbox reads worse. Built only on theme tokens (ported from OTP.pink).
   ============================================ */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.toggle__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.toggle__track {
  position: relative;
  flex-shrink: 0;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  transition: background-color 150ms ease;
}

.toggle__thumb {
  position: absolute;
  top: 50%;
  left: 0.125rem;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  background: var(--text-muted);
  transform: translateY(-50%);
  transition: transform 150ms ease, background-color 150ms ease;
}

.toggle__input:checked + .toggle__track {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle__input:checked + .toggle__track .toggle__thumb {
  background: var(--btn-text-on-dark);
  transform: translate(1rem, -50%);
}

.toggle__input:focus-visible + .toggle__track {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.toggle__input:disabled + .toggle__track,
.toggle__input:disabled ~ .toggle__label {
  opacity: 0.5;
  cursor: not-allowed;
}


/* Show notification icon in collapsed state */
body.sidebar-collapsed .sidebar .navitem .notification-icon {
  opacity: 1;
  pointer-events: auto;
  position: absolute;
  right: var(--space-2);
}

/* Hide scrollbars in collapsed sidebar — only icons visible */
body.sidebar-collapsed .sidebar {
  overflow: hidden;
}

/* Navitems adjust padding and center icons on collapse */
body.sidebar-collapsed .sidebar .navitem {
  position: relative;
  justify-content: center;
  padding: var(--space-2);
  gap: 0; /* Remove gap when collapsed */
}

/* Toggle button icon transition */
.sidebar [data-sidebar-toggle] .icon {
  transition: opacity 150ms ease;
}

/* ============================================
   Tooltips for Collapsed State
   ============================================ */
/* The `position: relative` this block used to repeat is already set on
   `.sidebar .navitem` above — it was a second declaration of the same selector
   setting a value that was already in force. Removed 2026-08-01. */

/* The collapsed sidebar's labels are TOOLTIPS from `src/ui/tooltip.ts`, not a
   pseudo-element.
   There used to be a `::after { content: attr(data-tooltip) }` pair here, and it
   never showed anything: the collapsed sidebar sets `overflow: hidden` (to hide
   its scrollbar) a few rules above, and the tooltip is drawn 8px past the item's
   right edge. Measured on the live page 2026-08-22 — sidebar right edge at 421,
   tooltip origin at 420, so all but one pixel was clipped. An ancestor's overflow
   wins over any z-index, so the CSS could not be rescued; the JS tooltip renders
   into a fixed-position element on <body> and escapes the clip by construction.
   A nav item is still a link, so it keeps the pointer cursor that the global
   `[data-tooltip] { cursor: help }` would otherwise take away — in BOTH states,
   since the attribute is on the item whether the sidebar is collapsed or not. */
.sidebar .navitem[data-tooltip] {
  cursor: pointer;
}

/* Dashboard Content */
/* padding-bottom guarantees content column is taller than the sidebar
   (whose max-height = 100dvh − header-height), so sticky works on every page. */
.dashboard-content {
  grid-area: content;
  min-width: 0;
  width: 100%;
  min-height: calc(100dvh - var(--header-height));
  padding-bottom: var(--dashboard-gap);
}

/* Fill height variant — block layout so sticky card shares the same
   containing block (viewport) as the sidebar.  flex caused sticky to
   resolve relative to the flex container, offsetting the card. */
.dashboard-content--fill-height {
  min-height: calc(100dvh - var(--header-height));
}

.dashboard-content--fill-height .table-scroll {
  min-height: 50lvh; /* Minimum space for dropdowns */
}

/* ============================================
   STICKY PANELS — two variants, pick by panel count

   This used to be `.dashboard-content--fill-height .card`, which pinned EVERY
   card on the page. That is right for a table page, which has exactly one card:
   its header and filters stay put while the table body scrolls. It is wrong the
   moment a page has two. On /postbacks all three panels pinned to the same
   offset, and since they shared `z-index: 1`, DOM order decided the paint order
   — the panel you were scrolling toward covered the one you had just passed.
   Measured: "Live" and "Conversions" both sat at top=792, so the Live panel's
   five KPI figures were unreachable behind the Conversions panel. Sticky is
   supposed to preserve context, and it was hiding content instead.

   So the choice is now explicit in the markup:
   - `.card--sticky` — the whole card pins. ONE per view.
   - `.card--sticky-header` — only the header pins, the body scrolls under it.
     Safe with any number of panels: a header is short, and each arriving header
     displaces the previous one instead of covering a neighbour's body.
   ============================================ */

.card--sticky {
  position: sticky;
  /* The chrome's visible height (header-scroll.ts), not the fixed 96px. */
  top: var(--chrome-height, var(--header-height));
  transition: top 0.3s ease;
  /* Deliberately BELOW --z-dropdown (20), and measured: this card used to carry
     --z-sticky (30), which outranks every menu opened OUTSIDE it. The menus in
     `.page-header` are exactly that — the sync chip on /streams and /redirects,
     "Add integration" on /integrations — and the card starts ~32px below where
     they open, so the card covered everything past the first item. On
     /integrations that left three of four choices unclickable; elementFromPoint
     at the second item returned the card's search input, not the menu.
     The card only ever has to paint over the in-flow content it scrolls across,
     which any positioned element already does; --z-elevated keeps it above the
     page's own layers while real popovers keep winning over it. If something
     ever needs to sit under this card, lower that element instead of raising
     this back. */
  z-index: var(--z-elevated);
}

.card--sticky-header > .card__header {
  position: sticky;
  top: var(--chrome-height, var(--header-height));
  transition: top 0.3s ease;
  /* Deliberately NO z-index, and this is the load-bearing part.
     A z-index here would make the header a stacking context, which traps any
     dropdown opened inside it: the next panel's header is a later context of
     the same rank and would paint over the whole thing, menu included. And
     using --z-sticky (30) would be worse still — it outranks --z-dropdown (20),
     so a stuck header would cover menus opened in other panels' bodies.
     Without a z-index the header is still positioned, so it paints over the
     in-flow body it scrolls across, while real popovers keep winning over it.
     If a body element ever needs to sit UNDER the header, give that element a
     lower z-index rather than raising this one. */
  /* The body passes underneath, so the header needs its own fill — inherited
     from .card, so it follows the panel variant and the theme. */
  background: var(--card-bg);
  border-top-left-radius: var(--card-radius);
  border-top-right-radius: var(--card-radius);
}

/* An empty card must not pin its header.
   Reported 2026-08-04 with a screenshot of /postbacks: the "Conversions" title
   and its filter chips sat BELOW their own "No conversions yet" text. Measured
   on the live page, that is what pinning does to a tall, sparse card — the body
   keeps scrolling while the header stops, so at scrollY 500 the body already
   starts at 74px with the header pinned at 96, and the centred empty state ends
   up above the title. Normally the site chrome hides that band; where the chrome
   is shorter than --header-height it does not, and the card reads as broken.
   A card with nothing in it has nothing worth keeping in view, so it does not
   pin at all. Pinning returns by itself once rows arrive and the empty state is
   hidden — which is exactly when a stationary filter bar starts to earn its
   keep. */
.card--sticky-header:has(.empty-state:not([hidden])) > .card__header {
  position: static;
}

/* While this header has something open — the Conversions filter on /postbacks is
   the live case — lift it to the dropdown rank so the menu clears the NEXT
   panel's header. Without this the menu is covered: measured in both themes at
   two scroll positions, the next header wins on tree order even though the menu
   carries --z-dropdown and this header carries no z-index at all. Pinning the
   header is what creates the situation; nothing overlaps without it.
   No JS needed — dropdown.ts already maintains aria-expanded. */
.card--sticky-header > .card__header:has([aria-expanded='true']) {
  z-index: var(--z-dropdown);
}

/* Mobile: nothing pins. The header is already an overlay and the viewport is
   too short to spend on a pinned strip. */
@media (max-width: 1023px) {
  .card--sticky,
  .card--sticky-header > .card__header {
    position: static;
  }
}

/* Mobile: adjust min-height for smaller header/footer */
@media (max-width: 1023px) {
  .dashboard-content {
    min-height: calc(100dvh - 180px);
  }
}

@media (max-width: 768px) {
  .dashboard-content {
    min-height: calc(100dvh - 160px);
  }
}

/* Dashboard Overview — data tiles.
   Health + Expiring sit side-by-side as equal-width tiles; the Plan card
   (.overview-cards__wide) spans the full row beneath. Hidden cards drop out
   of grid flow, so the layout stays balanced when a card has no data.
   This is the overview's answer to "fill the width intentionally" — a
   deliberate tiled composition rather than a thin full-width stack. */
.overview-cards {
  display: grid;
  /* Up to three equal tiles in one responsive row (auto-fit). Hidden cards
     drop out of flow and the rest rebalance: 3 → a row of three, 2 → an even
     pair, 1 → full width. No spanning card (a full-width span keeps empty
     tracks alive and would strand a lone tile at half width), and no media
     query — auto-fit drops columns on its own when the row can't hold a 280px
     tile. */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--stack-gap);
  align-items: start;
}

/* The reserved .stats-grid defaults to a 6-column page layout; the Performance
   card only has 3 metrics, so fit-to-content here. Higher specificity than the
   base .stats-grid media query, so it wins at every width. Also zero the
   page-level bottom margin. */
[data-card-performance] .stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 0;
}

/* Overview cards fade in as their API calls resolve, instead of popping. */
@keyframes overview-card-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.overview-card-reveal {
  animation: overview-card-in 240ms ease-out both;
}


/* .page-header lives in layout.css; this override moved into --section-gap. */

/* Add horizontal padding to prevent page-header from touching edges */
.dashboard-content .page-header {
  padding-inline: var(--page-gutter-desktop);
}

@media (max-width: 1023px) {
  .dashboard-content .page-header {
    padding-inline: var(--page-gutter-mobile);
  }
}

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

.page-header .text-muted {
  margin: 0;
}

.docs-page-header {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-2) 0 var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
}

.docs-page-header .h1 {
  max-width: 100%;
  line-height: 1.15;
  text-wrap: pretty;
}

.docs-page-header .text-lead {
  max-width: 54rem;
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  text-wrap: pretty;
}

.docs-faq {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.docs-faq__item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-subtle);
  overflow: clip;
}

.docs-faq__summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  list-style: none;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--text-main);
}

.docs-faq__summary::-webkit-details-marker {
  display: none;
}

.docs-faq__summary::before {
  content: '+';
  flex: 0 0 auto;
  color: var(--primary);
  font-size: 1.125rem;
  line-height: 1;
}

.docs-faq__item[open] > .docs-faq__summary {
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-soft);
}

.docs-faq__item[open] > .docs-faq__summary::before {
  content: '-';
}

.docs-faq__body {
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.docs-faq__body p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.docs-faq__body p + p {
  margin-top: var(--space-2);
}

@media (max-width: 900px) {
  .docs-page-header {
    padding-bottom: 0;
  }

  .docs-page-header .h1 {
    font-size: var(--fs-xl);
    line-height: 1.15;
  }

  .docs-page-header .text-lead {
    max-width: 100%;
    font-size: 0.98rem;
  }

  .docs-faq__summary,
  .docs-faq__body {
    padding-inline: var(--space-3);
  }
}
/* .grid-2 lives in layout.css, with this auto-fit template carried over. */

/* Utility classes */
.panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--bg-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: var(--space-3);
}

/* Spacing inside a panel is the gap, as the StyleGuide promises. Without this
   a <p> kept the browser's 1em margins on top of it: a one-line note measured
   73px tall (add-domains drawer, 2026-09-15). Same reset `.stack` has. */
.panel > * {
  margin-block: 0;
}

/* The postback drawer's mapping-incomplete banner sits directly above the edit
   tabs (drawer__body has no gap), so give it breathing room below when shown. */
[data-mapping-incomplete-banner] {
  margin-bottom: var(--space-3);
}

/* Status panels — neutral surface + a subtle semantic corner glow. The status
   colour signals state through border + glow, it does NOT dominate the fill
   (see StyleGuide "Status panels"). Glow/tint strength comes from theme tokens
   (--panel-glow / --panel-tint) so one recipe serves both themes. Icons are
   not part of this component. */
.panel--success { --panel-accent: var(--success); }
.panel--info    { --panel-accent: var(--primary); }
.panel--warning { --panel-accent: var(--warning); }
.panel--danger  { --panel-accent: var(--danger); }

.panel--success,
.panel--info,
.panel--warning,
.panel--danger {
  --panel-fill:
    radial-gradient(
      125% 130% at 0% 0%,
      color-mix(in srgb, var(--panel-accent) var(--panel-glow), transparent),
      transparent 62%
    ),
    var(--bg-soft);
  background: var(--panel-fill);
  border-color: color-mix(in srgb, var(--panel-accent) 32%, transparent);
}

/* Compact — near-flat for dense layouts (tables, drawer lists, mobile):
   less decoration, tighter padding. */
.panel--compact:is(.panel--success, .panel--info, .panel--warning, .panel--danger) {
  background: color-mix(in srgb, var(--panel-accent) var(--panel-tint), var(--bg-soft));
  border-color: color-mix(in srgb, var(--panel-accent) 22%, transparent);
  padding: var(--space-2) var(--space-3);
}

/* Interactive status panels: hover/focus emphasises the border (and a faint
   matching shadow), keeping the same fill so hover never reads as a different
   severity. Overrides the generic .panel--interactive:hover background below. */
:is(.panel--success, .panel--info, .panel--warning, .panel--danger).panel--interactive:hover,
:is(.panel--success, .panel--info, .panel--warning, .panel--danger).panel--interactive:focus-visible {
  background: var(--panel-fill);
  border-color: color-mix(in srgb, var(--panel-accent) 50%, transparent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--panel-accent) 14%, transparent);
}

.panel--interactive {
  cursor: pointer;
  transition: border-color var(--transition-md), box-shadow var(--transition-md), background-color var(--transition-md);
}

.panel--interactive:hover,
.panel--interactive:focus-visible {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  background: color-mix(in srgb, var(--bg-soft) 88%, var(--bg-elevated));
}

/* Hover and focus looked the same, so from the keyboard a panel had only the
   browser's own ring. The house ring, like every other control (2026-11-05). */
.panel--interactive:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.panel--interactive.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

/* NOTE: `.cluster` used to be redeclared here, identically to its definition
   ~2700 lines above but with a hardcoded gap. Same specificity, later in the
   file, so it silently won — which meant every `.cluster--*` gap variant
   declared next to the real rule was dead on arrival. Removed rather than
   merged: the earlier declaration is the documented one. */

/* Step indicators */
/* Horizontal step flow - for wizards, setup flows, progress indicators */
.step-flow {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.step-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--bg-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
}

.step-number {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  background: var(--primary);
  color: var(--bg);
  border-radius: 50%;
  font-weight: 600;
  font-size: var(--fs-xs);
  flex-shrink: 0;
}

.step-number--cf {
  background: var(--accent-cf);
  color: var(--btn-text-on-dark);
}

.step-text {
  color: var(--text);
  white-space: nowrap;
}

.step-separator {
  color: var(--text-muted);
  font-size: 1rem;
  user-select: none;
}

/* Interactive step pill (link variant) */
.step-pill--link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.step-pill--link:hover {
  border-color: var(--border-strong);
}
.step-pill--link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-color: var(--border-strong);
}

/* Hover swap layers */
.step-number__count {
  transition: opacity var(--transition-fast);
}
.step-number__icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
  width: auto;
  height: auto;
  flex: none;
}
.step-number__icon svg {
  width: 0.625rem;
  height: 0.625rem;
}
.step-pill--link:hover .step-number__count { opacity: 0; }
.step-pill--link:hover .step-number__icon { opacity: 1; }

/* Completed step */
.step-number--done {
  background: var(--ok);
}

/* Vertical step list - for compact instructions, checklists */
.step-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.step-item {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.step-item .badge {
  flex-shrink: 0;
}

/* ============================================
   Sidebar Search (Menu Filter)
   ============================================ */
.sidebar-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--r-pill);
  padding: var(--space-1) var(--space-2);
  min-width: 0;
  transition: border-color 200ms ease, background 200ms ease;
}

.sidebar-search:focus-within {
  border-color: var(--brand);
  background: var(--input-bg);
}

.sidebar-search .icon {
  color: var(--muted);
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  font-size: 0.875rem;
}

.sidebar-search__input {
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: var(--fs-sm);
  line-height: 1.4;
  outline: none;
  min-width: 0;
}

.sidebar-search__input::placeholder {
  color: var(--muted);
}

/* Hide search in collapsed sidebar */
body.sidebar-collapsed .sidebar-search {
  display: none;
}

/* Prevent iOS zoom on focus */
@supports (-webkit-touch-callout: none) {
  .sidebar-search__input {
    font-size: 1rem;
  }
}

/* ============================================
   Metric Pill (Compact Progress Indicator)
   ============================================
   Small visual meter for compact metrics (usage, freshness, coverage).
   Use cases: CF KV limits, token age, quota indicators in tight spaces.

   Usage:
   <div class="metric-pill">
     <div class="metric-pill__track">
       <div class="metric-pill__fill" style="--metric-fill: 0.75"></div>
     </div>
   </div>
   ============================================ */
.metric-pill {
  display: inline-block;
  width: 100%;
}

.metric-pill__track {
  position: relative;
  width: 100%;
  height: 0.375rem;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-soft));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 20%, transparent);
  overflow: hidden;
}

.metric-pill__fill {
  --metric-fill: 1;
  position: absolute;
  inset: 1px;
  border-radius: var(--r-pill);
  background: var(--primary);
  transform-origin: left center;
  transform: scaleX(var(--metric-fill));
  transition: transform 0.3s ease;
}

/* Variants for different metric types */
.metric-pill--success .metric-pill__track {
  background: color-mix(in srgb, var(--success) 8%, var(--bg-soft));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--success) 20%, transparent);
}

.metric-pill--success .metric-pill__fill {
  background: var(--success);
}

.metric-pill--warning .metric-pill__track {
  background: color-mix(in srgb, var(--warning) 8%, var(--bg-soft));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warning) 20%, transparent);
}

.metric-pill--warning .metric-pill__fill {
  background: var(--warning);
}

.metric-pill--danger .metric-pill__track {
  background: color-mix(in srgb, var(--danger) 8%, var(--bg-soft));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 20%, transparent);
}

.metric-pill--danger .metric-pill__fill {
  background: var(--danger);
}

.metric-pill__label {
  display: inline-block;
  margin-left: var(--space-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Date range variant - vertical layout with text above track */
.metric-pill--date {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  width: auto;
}

.metric-pill--date .metric-pill__label {
  margin-left: 0;
  order: -1; /* Label appears above track */
}

.metric-pill--date .metric-pill__track {
  width: 100%;
  min-width: 12rem;
}

/* When inside page-header actions, align to top instead of center */
.page-header__actions .metric-pill--date {
  align-self: flex-start;
}

/* ============================================
   Section tabs — `.tabs[data-tabs]` > `.tab` + `.tab-panel`
   (the segmented control is `.tabs__nav` above; one engine for both,
   `src/ui/tabs.ts`)
   ============================================ */
.tabs[data-tabs] {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  /* A row that outgrows its container scrolls inside itself instead of pushing
     the page sideways: /admin's six referral tabs overflowed a 390px phone by
     105px (measured 2026-09-28). */
  overflow-x: auto;
  scrollbar-width: thin;
}

.tabs[data-tabs] > .tab {
  /* One line per label — a wrapped "Affiliate / payouts" reads as two tabs. */
  flex-shrink: 0;
  white-space: nowrap;
}

.tab {
  position: relative;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: var(--r-field) var(--r-field) 0 0;

  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);

  cursor: pointer;
  transition:
    color var(--transition-fast),
    border-color var(--transition-fast),
    background var(--transition-fast);
}

.tab:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.tab.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel {
  display: block;
}

.tab-panel[hidden] {
  display: none;
}

/* Mobile accordion — replaces tabs on small screens */
.mobile-accordion-group {
  display: none;
}

.mobile-accordion {
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  overflow: hidden;
}


.mobile-accordion > summary {
  padding: var(--space-3) var(--space-4);
  font-weight: var(--fw-medium);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-accordion > summary::-webkit-details-marker {
  display: none;
}

.mobile-accordion > summary::after {
  content: '';
  width: 0.5em;
  height: 0.5em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--transition-fast);
  opacity: 0.5;
  flex-shrink: 0;
}

.mobile-accordion[open] > summary::after {
  transform: rotate(-135deg);
}

.mobile-accordion > .mobile-accordion__body {
  padding: var(--space-2) var(--space-4) var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.mobile-accordion-group > .mobile-accordion {
  border-radius: var(--radius);
}

.mobile-accordion-group > .mobile-accordion + .mobile-accordion {
  margin-top: 0;
}

@media (max-width: 768px) {
  .desktop-tabs {
    display: none;
  }
  .mobile-accordion-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }
}

/* ============================================
   Pricing Grid
   ============================================ */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

/* Subgrid: tier, price, description, CTA, fine print. The rows are shared across
   the cards, so every CTA sits on one line even when only one card has fine print. */
.pricing-card {
  display: grid;
  grid-row: span 5;
  grid-template-rows: subgrid;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-lg);
}

.pricing-card--featured {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.pricing-card__tier {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.pricing-card__price {
  font-size: 2.25rem;
  font-weight: var(--fw-bold);
  line-height: 1;
}

.pricing-card__price-unit {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: var(--fw-normal);
}

.pricing-card__description {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.pricing-card__cta {
  width: 100%;
}

.pricing-card__fine {
  display: grid;
  gap: var(--space-1);
}

@media (max-width: 768px) {
  .pricing-grid {
    grid-template-columns: 1fr;
  }
}

/* Pricing comparison table */
.pricing-table {
  width: 100%;
  border-collapse: collapse;
}

.pricing-table th,
.pricing-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.pricing-table th {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pricing-table th:not(:first-child),
.pricing-table td:not(:first-child) {
  text-align: center;
}

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

@media (max-width: 768px) {
  .pricing-table {
    font-size: var(--fs-sm);
  }
  .pricing-table th,
  .pricing-table td {
    padding: var(--space-2) var(--space-2);
  }
}

/* ============================================
   Mobile Menu Button
   ============================================ */
.burger-button {
  display: none; /* Hidden by default on desktop */
}

@media (max-width: 1023px) {
  .burger-button {
    display: flex; /* Show on all pages at mobile */
  }
}

/* Logo switching: compact on mobile when burger appears */
.brand--compact {
  display: none; /* Hidden on desktop */
}

@media (max-width: 1023px) {
  .brand--full {
    display: none; /* Hide full logo on mobile */
  }

  .brand--compact {
    display: flex; /* Show compact logo on mobile */
  }
}

/* ============================================
   Responsive Layout
   ============================================ */

/* Tablet: Reduce sidebar width */
@media (min-width: 1024px) and (max-width: 1279px) {
  :root {
    --sidebar-width: 240px;
    --sidebar-width-collapsed: 64px;
    --dashboard-gap: 1rem;
  }
}

/* Tablet: Add padding for centered content */
@media (min-width: 768px) and (max-width: 1023px) {
  .page-shell.dashboard-shell {
    padding-inline: var(--space-4);
  }
}

/* Mobile: Single column, sidebar as overlay drawer */
@media (max-width: 1023px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "content";
    gap: 0;
  }

  .sidebar {
    /* Remove from grid flow */
    position: fixed;
    top: 0;
    left: 0;
    height: 100svh; /* Small viewport height - stable, doesn't change with keyboard */
    width: var(--sidebar-width);
    z-index: var(--z-sidebar);
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 300ms ease-in-out;
  }

  /* Hide search on mobile to prevent keyboard issues */
  .sidebar-search {
    display: none;
  }

  /* Hide desktop toggle button on mobile (drawer doesn't need it) */
  .sidebar [data-sidebar-toggle] {
    display: none;
  }

  /* Open state (mobile drawer) */
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* Overlay backdrop */
  body.sidebar-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-sidebar-overlay);
    animation: fadeIn 200ms ease;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* Body scroll lock when sidebar open */
  body.sidebar-open {
    overflow: hidden;
  }

  /* Remove extra padding from dashboard-content on mobile */
  /* .page-shell already provides sufficient padding */
  .dashboard-content {
    padding-inline: 0;
    width: auto; /* Override desktop width: 100% - grid handles sizing */
  }
}

/* Hide header and utility-bar when sidebar is open (any screen size) */
body.sidebar-open .site-header {
  transform: translateY(-100%);
}

body.sidebar-open .utility-bar {
  transform: translateY(-100%);
}

/* Desktop: Full layout */
@media (min-width: 1280px) {
  :root {
    --sidebar-width: 280px;
    --sidebar-width-collapsed: 72px;
    --dashboard-gap: 1.5rem;
  }
}

/* ============================================
   Account Page
   ============================================ */
.card__header--with-avatar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.account-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border-subtle);
  background: var(--gray-50);
  object-fit: cover;
  flex-shrink: 0;
}

/* Inline edit styles moved to global "Utility Classes" section */

.password-change-form {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}

.btn-group {
  display: flex;
  gap: var(--inline-gap);
  flex-wrap: nowrap;
}

/* Fieldset group — bordered section with legend on border line */
.fieldset-group {
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin: 0;
  /* A fieldset's default floor is min-content: one long unbreakable line (a
     postback URL in a `.text-truncate` code box) pushed the source drawer's
     URLs tab 11px past a 390px screen. At 0 it fits its container and the
     truncation inside does its job (measured, postback-recipe harness). */
  min-width: 0;
}

.fieldset-group:first-child {
  margin-top: var(--space-2);
}

/* Hugs its content (a compact table) instead of spanning the parent.
   `min-width: 0` undoes the fieldset's default min-content floor, so a long
   currency list wraps instead of pushing the card wider than a phone. */
.fieldset-group--fit {
  width: fit-content;
  max-width: 100%;
  min-width: 0;
}

.fieldset-group > legend {
  padding: 0 var(--space-2);
  margin-left: calc(var(--space-2) * -1);
}

.fieldset-group > .textarea,
.fieldset-group > .input {
  width: 100%;
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
}

.detail-row {
  display: grid;
  /* minmax(0, 1fr): without the 0-min the value column floors at its content's
     min-content size, so a long unbreakable URL overflows the drawer (breaks
     layout, adds a horizontal scrollbar) instead of letting .text-truncate clip. */
  grid-template-columns: 140px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
}

.detail-row--center {
  align-items: center;
}

/* Outline variant: keeps the semantic colour of the button it modifies but
   drops the fill. Only the [data-*] state rules below existed, so a plain
   `.btn.btn--danger.btn--outline` rendered as a fully solid danger button —
   which is how the Delete action in the edit drawers ended up shouting louder
   than the primary Save beside it. Colour comes from the base modifier, so
   this stays one rule rather than one per variant. */
.btn.btn--outline {
  background: transparent;
  border-color: currentColor;
}

.btn.btn--outline.btn--danger {
  color: var(--danger);
}

.btn.btn--outline.btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* Toggle button with data-enabled / data-status state coloring */
.btn--outline[data-enabled="true"],
.btn--outline[data-status="active"] {
  border-color: var(--ok);
}

.btn--outline[data-enabled="true"] > .icon,
.btn--outline[data-status="active"] > .icon {
  color: var(--ok);
}

.btn--outline[data-enabled="false"],
.btn--outline[data-status="revoked"],
.btn--outline[data-status="expired"],
.btn--outline[data-status="error"] {
  border-color: var(--danger);
}

.btn--outline[data-enabled="false"] > .icon,
.btn--outline[data-status="revoked"] > .icon,
.btn--outline[data-status="expired"] > .icon,
.btn--outline[data-status="error"] > .icon {
  color: var(--danger);
}

/* Dropdown chip with data-status border coloring */
.btn-chip[data-status="active"]  { border-color: var(--ok); }
.btn-chip[data-status="paused"]  { border-color: var(--warning); }
.btn-chip[data-status="archived"]{ border-color: var(--text-muted); }
.btn-chip[data-status="301"]     { border-color: var(--ok); }
.btn-chip[data-status="302"]     { border-color: var(--warning); }

.detail-row dd {
  margin: 0;
}

/* Note: Inline editing uses .btn-inline pattern (see "Utility Classes" section) */

/* Auth methods list — Account settings → Login methods card */
.auth-methods-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.auth-method {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  min-width: 0;
}

.auth-method:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.auth-method:first-child {
  padding-top: 0;
}

.auth-method__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}

.auth-method__main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1 1 auto;
  min-width: 0;
}

.auth-method__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--border-strong);
}

.auth-method__dot--linked {
  background: var(--ok);
}

.auth-method__icon {
  font-size: 1.25rem;
  flex: 0 0 auto;
  color: var(--text);
}

.auth-method__note {
  margin: 0;
  /* Indent under provider name: dot (0.5rem) + gap + icon (1.25rem) + gap */
  padding-left: calc(0.5rem + var(--space-3) + 1.25rem + var(--space-3));
  color: var(--text-muted);
  font-size: 0.875rem;
}

.auth-method__actions {
  display: flex;
  gap: var(--space-2);
  flex: 0 0 auto;
}

/* Postbacks page utilities */
.input--flex {
  flex: 1 1 auto;
  /* min-width: 0 lets the code/input shrink inside a flex .cluster so a long
     URL keeps its Copy sibling on the same line instead of wrapping it
     beneath. Without this, the Copy button drops to a new row whenever the
     URL exceeds the container width. */
  min-width: 0;
  user-select: all;
  overflow-wrap: anywhere;
}
.field--fill { flex: 1 1 0; min-width: 0; }

/* QR box — square white plate for a scannable code (crypto deposit address,
   Telegram deep link). White on purpose: a QR drawn on a dark theme surface
   does not scan. The SVG comes from `generateQrSvg()` and fills the plate.
   Lives here, not in drawers.css, because dialogs use it too and the account
   page does not load drawers.css. */
.qr-box {
  display: block;
  width: min(240px, 100%);
  margin-inline: auto;
  aspect-ratio: 1 / 1;
  background: #fff;
  border-radius: var(--radius);
  padding: var(--space-2);
  box-shadow: 0 0 0 1px var(--border-subtle);
}

.qr-box svg {
  display: block;
  width: 100%;
  height: 100%;
}
.panel--code {
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  max-height: 20rem;
  overflow: auto;
}

/* Editable monospace textarea — paired with .input on JSON-paste fields */
.input--code {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  resize: vertical;
}

/* A short number beside a wider input in a .cluster (a TDS variant weight). */
.input--narrow {
  width: 5rem;
}

/* Clickable conversion rows on the postbacks page open a detail drawer */
tr[data-conversion-id] {
  cursor: pointer;
}

/* One line, no ellipsis — a short date or an amount that must not break. */
.text-nowrap {
  white-space: nowrap;
}

/* Free text in a table cell that may hold one long token (a provider's
   "11.142061281337048 USD"): it wraps anywhere instead of setting the
   column's minimum width. */
.text-break {
  overflow-wrap: anywhere;
}

/* Truncate-with-ellipsis for table cells (use with explicit max-width) */
.text-truncate {
  max-width: 24rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A narrower clip for a name or an email that shares a row with other
   columns (admin lists). After .text-truncate on purpose: same specificity,
   so the later rule is the one that wins. */
.text-truncate--sm {
  max-width: 12rem;
}

/* Unstyled list — strips bullet + padding so the parent stack/cluster
   controls layout. Use when an <ul> is needed for semantics but visual
   structure comes from container utilities (e.g. .stack, .cluster). */
.list--bare {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Postbacks Live — two columns of compact-table frames: totals on the left,
   the per-event breakdown over the sources on the right. Three frames in one
   row need ~1000px and the card is ~860 (the dashboard caps at 1200 with the
   sidebar), so the right column stacks. On a narrow card it wraps under. */
.live-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3);
}

.live-summary__side {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 0;
  max-width: 100%;
}

/* Frames start level: `.fieldset-group:first-child` adds a top margin that
   would drop the first one below its neighbour. */
.live-summary .fieldset-group {
  margin: 0;
}

.detail-label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  margin: 0;
}

.detail-value {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-md);
  color: var(--text);
  margin: 0;
  min-width: 0; /* grid child: allow shrink so long URLs truncate, not overflow */
  word-break: break-word;
}

/* The url+copy .cluster inside a detail-value must also shrink, else its
   min-content (the long URL) keeps the value column wide and overflows.
   nowrap keeps the Copy button on the same row as the (truncating) URL
   instead of dropping it to a second line. */
.detail-value .cluster {
  min-width: 0;
  flex-wrap: nowrap;
}

/* Prose variant — dt/dd carry paragraph-style description with inline <code>
   or <strong> markers (e.g. the /docs/postbacks guide). Switches .detail-value
   back to block so inline children flow as text instead of becoming flex
   items. Widen the label column to give long canonical keys room. */
.detail-list--prose .detail-row {
  grid-template-columns: minmax(160px, 200px) minmax(0, 1fr);
  align-items: start;
}
.detail-list--prose .detail-value {
  display: block;
  line-height: 1.6;
}
.detail-list--prose .detail-label {
  padding-top: 0.125rem;
}

.detail-value--mono {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .detail-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .detail-label {
    font-size: var(--fs-xs);
  }
}

/* ============================================
   Dialog (Confirmation Modals)
   ============================================

   Centered modal dialogs for critical actions and confirmations.
   Unlike drawers (side panels for forms/details), dialogs are used for:
   - Confirmation prompts (delete, disconnect, etc.)
   - Critical Cloudflare actions (.btn--cf)
   - Alerts and short messages

   Usage:
   <div class="dialog" data-dialog="name" hidden>
     <div class="dialog__overlay"></div>
     <div class="dialog__panel">
       <header class="dialog__header">
         <h2 class="dialog__title">Title</h2>
         <button class="btn-close" data-dialog-close>×</button>
       </header>
       <div class="dialog__body">Content</div>
       <footer class="dialog__footer">
         <button class="btn btn--danger">Confirm</button>
         <button class="btn btn--ghost" data-dialog-close>Cancel</button>
       </footer>
     </div>
   </div>
*/

.dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.dialog[hidden] {
  display: none;
}

.dialog__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.dialog__panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dialogFadeIn 0.2s ease-out;
}

/* Dialog accent variants with left border
   Uses same pattern as .card--accent for consistency */

.dialog--danger .dialog__panel::before,
.dialog--warning .dialog__panel::before,
.dialog--cf .dialog__panel::before,
.dialog--info .dialog__panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-left: 4px solid currentColor;
  border-radius: inherit;
  pointer-events: none;
}

.dialog--danger .dialog__panel::before {
  color: var(--danger);
}

.dialog--warning .dialog__panel::before {
  color: var(--warning);
}

.dialog--cf .dialog__panel::before {
  color: var(--accent-cf);
}

.dialog--info .dialog__panel::before {
  color: var(--primary);
}

@keyframes dialogFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-3);
}

.dialog__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin: 0;
}

.dialog__body {
  padding: var(--space-4);
  color: var(--text-muted);
}

.dialog__body strong {
  color: var(--text);
  font-weight: var(--fw-medium);
}

/* "Type the name to confirm" block under a destructive dialog's text. */
.dialog__confirm {
  margin-top: var(--space-3);
}

/* A scrollable pick-one list inside a dialog body.
   `.dialog__panel` is `overflow: hidden` (it clips the ::before inset border to
   the panel radius), so an absolutely positioned `.dropdown__menu` opened from
   inside a dialog is cut off at the panel edge — which is why the choice here is
   a list in the flow rather than a popover. Rows reuse `.dropdown__item`; that
   class outside a `.dropdown` container is inert as far as the global dropdown
   handler is concerned. */
.dialog__options {
  max-height: 40vh;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

/* A raw URL shown in a dialog (the Telegram deep link) has no break
   opportunities; without this it pushes the panel wider than the viewport. */
.dialog__body .link {
  min-width: 0;
  overflow-wrap: anywhere;
}

.dialog__footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  background: var(--panel);
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
  .dialog {
    padding: var(--space-3);
  }

  .dialog__panel {
    max-width: 100%;
  }

  .dialog__header,
  .dialog__body,
  .dialog__footer {
    padding: var(--space-3);
  }
}

/* Domain Preview List */
.domain-preview-list {
  max-height: 300px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: var(--space-2);
}

.domain-preview-item {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
  transition: background var(--transition-fast);
}

.domain-preview-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Right-hand detail of a preview row (a Namecheap expiry date). */
.domain-preview-item__meta {
  margin-left: auto;
}

/* ============================================
   Close button — the × of every dialog and drawer
   (drawers.css enlarges it below 768px)
   ============================================ */

.btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0; /* a fixed target: a long drawer title must not squeeze it */
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--r-field);
  transition: all 150ms ease;
}

.btn-close:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.btn-close .icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* ============================================
   CUSTOM TOOLTIPS
   Rich tooltips for status badges and complex info
   ============================================ */

/* Elements with tooltips get help cursor */
[data-tooltip] {
  cursor: help;
}

.tooltip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-field);
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-sm);
  line-height: 1.5;
  box-shadow: var(--shadow-md);
  max-width: 280px;
  word-wrap: break-word;
  animation: tooltip-fade-in 150ms ease;
}

@keyframes tooltip-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tooltip content sections */
.tooltip__header {
  font-weight: var(--fw-semibold);
  color: var(--text);
  margin-bottom: var(--space-1);
}

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

.tooltip__footer {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-xs);
  /* --text-muted, not --text-subtle: at 12px this is normal-size text needing
     4.5:1, and subtle on --bg-elevated measures 4.34:1 in light theme. The
     token's "darkened for AA" note holds against pure white, but bg-elevated
     is #F7F7F8 and that margin is gone. Muted gives 5.06:1, and matches
     .tooltip__body beside it. */
  color: var(--text-muted);
}

/* Color variants matching badge colors */
.tooltip--success .tooltip__header {
  color: var(--success);
}

.tooltip--danger .tooltip__header {
  color: var(--danger);
}

.tooltip--warning .tooltip__header {
  color: var(--warning);
}

/* ============================================================================
   TDS (Traffic Distribution System) Components
   ============================================================================ */

/* ============================================
   TDS Onboarding Section
   ============================================ */

/* TDS Checklist */
.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ============================================
   TDS Rule Editor Screen (/streams?rule=…) — StyleGuide "Editor Screen"
   ============================================ */

/* The editor takes the list's place, not the page's: the page header (Apply)
   stays. Hiding the list's own blocks rather than wrapping them keeps the
   list's sticky card a child of .dashboard-content — inside a wrapper only as
   tall as itself, position: sticky would have nowhere to travel. */
.dashboard-content[data-rule-screen-open] > :not(.page-header, .rule-screen) {
  display: none;
}

.rule-screen {
  min-width: 0;
  container: rule-screen / inline-size;
}

/* One column by default: form, then the summary, then Save — so the summary is
   read before saving. Two columns from 860px of CONTENT width (form ≥ ~536 +
   summary 300 + gap): the content column is ~895px at a 1440 window with the
   sidebar out, and ~878 with a classic scrollbar, so the common laptop gets
   both; at a 1024 window it is ~766 and stays single (rule 13 in CLAUDE.md). */
.rule-screen__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "form" "summary" "actions";
  gap: var(--block-gap);
}

.rule-screen__form {
  grid-area: form;
  min-width: 0;
}

.rule-screen__summary {
  grid-area: summary;
  min-width: 0;
}

.rule-screen__actions {
  grid-area: actions;
}

@container rule-screen (min-width: 860px) {
  .rule-screen__body {
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-areas: "form summary" "actions summary";
    align-items: start;
  }

  /* Pinned (.card--sticky pins from a 1024 WINDOW up): a long MAB list scrolls
     inside the card rather than running below the window, out of reach. Only
     there — below 1024 the sidebar turns overlay, the editor widens past 860
     again (~868 at a 900 window) and the card is in the flow: a capped card in
     the flow would hide its own end. */
  @media (min-width: 1024px) {
    .rule-screen__summary {
      max-height: calc(100dvh - var(--chrome-height, var(--header-height)) - var(--space-4));
      overflow-y: auto;
    }
  }
}

/* Stacked, the summary is part of the flow and must not pin: .card--sticky
   switches off only below a 1024px WINDOW, while this column is already
   stacked at 1024–1200 (content 734–910). */
@container rule-screen (max-width: 859.98px) {
  .rule-screen .rule-screen__summary {
    position: static;
  }
}

.rule-summary {
  display: grid;
  gap: var(--space-4);
}

.rule-summary__label {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.rule-summary__list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A line of the summary is a button to the field behind it. */
.rule-summary__target {
  display: block;
  width: 100%;
  padding: var(--space-1);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.rule-summary__target:hover {
  background: color-mix(in srgb, var(--text) 4%, transparent);
}

.rule-summary__target:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.rule-summary__url {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
}

.rule-summary__url > .url-parts {
  flex: 1;
  min-width: 0;
}

.rule-summary__notes {
  display: grid;
  gap: var(--space-1);
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* URL parts — StyleGuide "URL parts (.url-part)". */
.url-parts {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.8;
  overflow-wrap: anywhere;
}

/* A pill broken over two lines keeps its ends on both. */
.url-part {
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

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

.url-part--param {
  font-weight: var(--fw-semibold);
}

.url-part--literal {
  color: var(--text);
}

.url-part--macro,
.url-part--unknown,
.url-part--added {
  padding: 0 0.3em;
  border-radius: var(--r-pill);
}

/* Full text colour on the washes, set rather than inherited: in the muted
   notes line an inherited colour fell to 3.7:1 on the warning wash (light). */
.url-part--macro {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--text);
}

.url-part--unknown {
  background: color-mix(in srgb, var(--warning) 24%, transparent);
  color: var(--text);
}

.url-part--added {
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
}

.url-part--overwritten {
  text-decoration: line-through;
  text-decoration-color: var(--warning);
}

/* =========================================================================
   Site Search (command palette) — see docs/StyleGuide.md "Site Search"
   Input in utility-bar__inner; ⌘K popover with compact result cards.
   ========================================================================= */

/* Search-hit highlight + keycap (also used outside search if ever needed) */
mark {
  background: var(--mark-bg);
  color: var(--mark-fg);
  border-radius: var(--radius-xs);
  padding: 0 0.15em;
}

kbd {
  display: inline-flex;
  align-items: center;
  font: inherit;
  font-size: 0.82em;
  line-height: 1;
  padding: 0.2em 0.45em;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: var(--border-1) solid var(--border-subtle);
  border-radius: var(--radius-xs);
}

/* Wrapper — centered in the utility bar, grows to fill the gap */
.search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 560px;
  margin-inline: auto;
}

/* Trigger row — unified field (no fixed height), icon + input + ⌘K hint */
.search-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding-block: var(--control-pad-y);
  padding-inline: var(--space-3);
  background: var(--input-bg);
  border: var(--border-1) solid var(--input-border);
  border-radius: var(--r-field);
  color: var(--text-muted);
  cursor: text;
  transition: border-color var(--transition-md);
}
.search-trigger:focus-within {
  border-color: var(--input-border-focus);
}
.search-trigger > .icon {
  flex: none;
  font-size: 1.1em;
  color: var(--text-subtle);
}
.search-trigger__input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
}
.search-trigger__input::placeholder {
  color: var(--text-subtle);
}
/* Suppress the native type=search clear button — we provide our own × in the
   mobile overlay; without this it doubles up on focus. */
.search-trigger__input::-webkit-search-cancel-button,
.search-trigger__input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}
.search-trigger__hint {
  flex: none;
  display: inline-flex;
  gap: 2px;
}

/* Popover — reuses dropdown surface tokens */
.search-palette {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  right: 0;
  display: none;
  background: var(--bg-elevated);
  border: var(--border-1) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: var(--z-dropdown, 20);
}
.search.is-open .search-palette {
  display: block;
}

.search-palette__results {
  max-height: min(60vh, 480px);
  overflow-y: auto;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Compact result card — base .card.card--interactive + this for layout/density */
.search-result {
  display: block;
  padding: var(--space-2) var(--space-3);
  text-decoration: none;
  color: inherit;
}
.search-result__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.search-result__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result__excerpt {
  margin: 0.15rem 0 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Keyboard-active row mirrors hover */
.search-result.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

/* Footer with kbd hints */
.search-palette__footer {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-top: var(--border-1) solid var(--border-subtle);
  font-size: var(--fs-xs);
  color: var(--text-subtle);
}
.search-palette__footer .cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

/* States */
.search-empty,
.search-loading,
.search-no-results {
  padding: var(--space-5) var(--space-3);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* Close button (used only in the mobile full-screen overlay) */
.search-mobile-toggle { display: none; }
.search-trigger__close {
  display: none;
  flex: none;
  padding: 0.15em;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.search-trigger__close .icon { font-size: 1.15em; }

/* Mobile: utility bar is too narrow — hide the inline field; a magnify button
   in the header opens search as a full-screen overlay (JS toggles the body class). */
@media (max-width: 1023px) {
  .search--inline { display: none; }
  .search-mobile-toggle { display: inline-flex; }

  body.search-mobile-open { overflow: hidden; }
  body.search-mobile-open .search--inline {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1000);
    margin: 0;
    max-width: none;
    padding: var(--space-3);
    gap: var(--space-3);
    background: var(--bg);
  }
  body.search-mobile-open .search-trigger__hint { display: none; }
  body.search-mobile-open .search-trigger__close { display: inline-flex; }
  body.search-mobile-open .search-palette {
    position: static;
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    border: 0;
    box-shadow: none;
    background: transparent;
  }
  body.search-mobile-open .search-palette__results { max-height: none; height: 100%; }
}


/* ── Decorative mesh layer (trigons-lite) ─────────────────────────────────
   Opted into per page by placing `<div id="trigons-bg">`; the loader in
   `src/ui/trigons-bg.ts` does nothing without it. Scoped with :has() so no
   page needs a body class it would otherwise not carry.

   The layer is positioned, so it paints above static in-flow content — the
   page chrome has to be lifted explicitly or the mesh covers the text. That
   is the whole trick, and forgetting it is how a background becomes a veil. */
body:has(#trigons-bg) > main,
body:has(#trigons-bg) > footer {
  position: relative;
  z-index: var(--z-base);
}

/* The header is deliberately absent from the list above: it is already
   `position: sticky` with `--z-header`, so it paints over the mesh on its own.
   Including it downgraded it to `relative` / `--z-base` and the header stopped
   sticking — caught in the browser, not by a test. */

/* Text never sits on the mesh: the content column keeps a solid surface and the
   decoration lives in the desktop gutters. This is the whole point of the
   layout — a background that runs under prose is a veil, not a background. */
body:has(#trigons-bg) > main {
  background: var(--bg);
}

#trigons-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* Isolates the canvas from the page's layout and paint work. */
  contain: strict;
}

/* Below the loader's own threshold there are no gutters left for the mesh to
   live in, and a phone is the last place a decorative canvas belongs. The two
   numbers must stay equal — a mismatch renders a canvas CSS has hidden. */
@media (max-width: 1023px) {
  #trigons-bg { display: none; }
}

/* ── Mesh texture (trigons-lite pattern) ──────────────────────────────────
   A seamless triangle tile as a plain background-image. No canvas, no script,
   no LCP candidate — which is why it, and not the animated mesh, goes on the
   pages that have to be fast. The tile itself lives in `--mesh-tile` so it
   follows the theme; see `theme.css` for how it is generated.

   Deliberately not `background-attachment: fixed`: that forces a repaint of
   the whole layer on every scroll frame, which is the one way a static
   background can cost as much as an animated one. */
.surface-mesh {
  background-image: var(--mesh-tile);
  background-repeat: repeat;
}

/* ── Variants that were used before they existed ──────────────────────────
   Each of these sat in the markup with no rule behind it, which renders as
   silence: the declaration is there, the element looks like the base, and
   nothing says why. Found by walking the pinned list in
   `tests/css/class-references.test.ts` (backlog item 24). */

/* Semantic colour for a standalone icon. Both live uses are `mono/alert-circle`
   in a warning row, where a body-coloured alert icon reads as decoration. */
.icon--danger {
  color: var(--danger);
}

/* The line under a page's h1 on the dashboard screens. Without it the subtitle
   rendered at body size and full contrast, competing with the heading it is
   supposed to sit beneath. */
.page-header__subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* Compact segmented control — the rule-type switch in the TDS editor. The base
   control height is sized for a page-level tab bar; the compact track sits in a
   .stack, so the container sets the space around it. */
.tabs__nav.tabs--sm {
  padding: var(--space-1);
  margin-bottom: 0;
}

.tabs--sm .tabs__trigger {
  font-size: var(--fs-sm);
  padding-block: var(--space-1);
  min-height: auto;
}

/* A link inside the alert bar. Every other `app-alert__*` element has a rule;
   this one did not, so the link fell back to the default link colour on a
   coloured surface. Inheriting keeps it legible whatever state the alert is in. */
.app-alert__link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Weight utility. There was none, so two places invented their own name for it
   — `text-strong` and `link--bold` — and neither existed. One rule serves both;
   the link now reads `class="link text-strong"`. */
.text-strong {
  font-weight: var(--fw-semibold);
}

/* ============================================
   Reduced motion
   ============================================
   For readers whose system asks for less motion: nothing slides, scales or
   sweeps. Each rule repeats its component's own selector and wins by ORDER,
   which is why this block is the last thing in the file — never `!important`
   (StyleGuide → Motion). drawers.css and tables.css end with their own block.
   The ONLY such block in this file: a new moving component adds its selector
   here. Colour and opacity fades stay: they move nothing. */
@media (prefers-reduced-motion: reduce) {
  .link--arrow::after,
  .toggle__track,
  .toggle__thumb,
  .field-details__summary::before,
  .mobile-accordion > summary::after {
    transition: none;
  }

  .overview-card-reveal {
    animation: none;
  }

  /* Chevrons flip instead of turning; their hover opacity still fades. */
  .btn-chip__chevron {
    transition: opacity 0.2s ease;
  }

  /* Nav items: the hover colours still fade, the nudge goes. */
  .sidebar .navitem {
    transition:
      background 200ms ease,
      color 200ms ease;
  }

  .sidebar .navitem:hover {
    transform: none;
  }

  /* The header hides on scroll by sliding up; now it just goes. */
  .site-header,
  .utility-bar {
    transition: none;
  }

  /* Global notice: the fade stays, the slide goes. */
  .app-alert,
  .app-alert[data-state='visible'],
  .app-alert[data-notice='visible'] {
    transition: opacity 200ms ease;
  }

  /* Loading bar and the Turnstile wait: a still bar instead of a sweep. */
  .loading-bar[data-loading='true']::before,
  .loading-bar[data-loading='flushing']::before,
  .btn[data-turnstile-pending]:disabled::before {
    animation: none;
  }

  .dialog__panel,
  .tooltip {
    animation: none;
  }

  /* Collapse on desktop (width) and the mobile drawer (transform). */
  .sidebar {
    transition: none;
  }

  body.sidebar-open::before {
    animation: none;
  }

  .card--sticky,
  .card--sticky-header > .card__header {
    transition: none;
  }

  .metric-pill__fill {
    transition: none;
  }
}
