/* Components (docs/DESIGN.md section 4). One block per component, in spec order.
   Markup for every component comes from the macros in web/templates/_ui.html. */

/* ===================================================================== icons (8.1) */
.icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon--xs { width: 12px; height: 12px; }
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 20px; height: 20px; }
.icon--xl { width: 24px; height: 24px; }
.icon--2xl { width: 32px; height: 32px; stroke-width: 1.75; }
.icon--spin { animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================================================== buttons (4.1) */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-3);
  height: 36px; padding: 0 var(--space-5);
  font: 500 var(--text-base)/20px var(--font-sans);
  border-radius: var(--radius-md); border: 1px solid transparent;
  white-space: nowrap; text-decoration: none; cursor: pointer; user-select: none;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  /* default variant: secondary */
  background: var(--surface); color: var(--text-1); border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--surface-hover); color: var(--text-1); text-decoration: none; }
.btn:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--radius-md); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--text-on-accent); border-color: transparent; }
.btn--primary:hover { background: var(--accent-hover); color: var(--text-on-accent); }
.btn--ghost { background: transparent; color: var(--text-2); border-color: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text-1); }
.btn--danger { background: var(--danger-button); color: #fff; border-color: transparent; }
.btn--danger:hover { background: var(--danger-button-hover); color: #fff; }
.btn--danger:focus-visible { box-shadow: var(--focus-ring-danger); }
.btn--danger-text { color: var(--danger-fg); }
.btn--danger-text:hover { color: var(--danger-fg); background: var(--danger-bg); border-color: var(--danger-border); }
.btn--link { height: auto; padding: 0; border: 0; background: none; box-shadow: none; color: var(--link); font-weight: 500; }
.btn--link:hover { background: none; color: var(--link-hover); text-decoration: underline; }
.btn--sm { height: 28px; padding: 0 var(--space-4); font-size: var(--text-sm); gap: var(--space-2); }
.btn--lg { height: 44px; padding: 0 var(--space-6); font-size: var(--text-md); }
.btn--block { width: 100%; }
.btn--icon { width: 36px; padding: 0; }
.btn--icon.btn--sm { width: 28px; }
.btn--icon.btn--lg { width: 44px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; transform: none; }
.btn__spinner { display: none; }
.btn.htmx-request { pointer-events: none; }
.btn.htmx-request > .btn__icon { display: none; }
.btn.htmx-request > .btn__spinner { display: inline-block; animation: spin 800ms linear infinite; }
.btn.htmx-request:not(:has(.btn__icon)) { opacity: .7; }
.btn-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.btn-group--end { justify-content: flex-end; }
@media (max-width: 767px) {
  .btn { height: 44px; }
  .btn--sm { height: 36px; }
  .btn--icon { width: 44px; }
  .btn--icon.btn--sm { width: 36px; }
  .btn--link { height: auto; }
}

/* links inside tables / nav: text-1, underline on hover only (4.2) */
.link-quiet { color: var(--text-1); font-weight: 500; text-decoration: none; }
.link-quiet:hover { color: var(--text-1); text-decoration: underline; text-decoration-color: var(--border-control); }
.link-ext { display: inline-flex; align-items: center; gap: var(--space-1); }

/* ===================================================================== status badges (4.7)
   Markup: <span class="status status-<value>">Label</span> (ui.badge). The tone comes
   from the status value below (mirrors STATUS_TONES in web/templating.py) or from an
   explicit .tone-<tone> class, which wins. */
.status {
  --tone-bg: var(--neutral-bg); --tone-fg: var(--neutral-fg);
  --tone-border: var(--neutral-border); --tone-solid: var(--neutral-solid);
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 var(--space-3); max-width: 100%;
  border-radius: var(--radius-full); border: 1px solid var(--tone-border);
  background: var(--tone-bg); color: var(--tone-fg);
  font: 500 var(--text-xs)/var(--lh-xs) var(--font-sans);
  white-space: nowrap; vertical-align: middle; text-decoration: none;
}
.status::before {
  content: ""; width: 6px; height: 6px; flex: none;
  border-radius: var(--radius-full); background: var(--tone-solid);
}
/* tone: success */
.status-active, .status-ok, .status-done, .status-match, .status-passed, .status-confirmed,
.status-success, .status-online, .status-connected, .status-sent, .status-mapped, .tone-success {
  --tone-bg: var(--success-bg); --tone-fg: var(--success-fg);
  --tone-border: var(--success-border); --tone-solid: var(--success-solid);
}
/* tone: info */
.status-onboarding, .status-queued, .status-pending, .status-draft, .status-running,
.status-pending_approval, .status-waiting, .status-todo, .status-owner, .status-manager,
.status-rep, .tone-info {
  --tone-bg: var(--info-bg); --tone-fg: var(--info-fg);
  --tone-border: var(--info-border); --tone-solid: var(--info-solid);
}
/* tone: warning */
.status-warning, .status-stale, .status-late, .status-partial, .status-open, .status-expiring,
.status-needs_review, .status-required, .status-stopped_at_hard_stop, .tone-warning {
  --tone-bg: var(--warning-bg); --tone-fg: var(--warning-fg);
  --tone-border: var(--warning-border); --tone-solid: var(--warning-solid);
}
/* tone: danger */
.status-error, .status-failed, .status-mismatch, .status-silent, .status-revoked, .tone-danger {
  --tone-bg: var(--danger-bg); --tone-fg: var(--danger-fg);
  --tone-border: var(--danger-border); --tone-solid: var(--danger-solid);
}
/* tone: neutral (default) */
.status-paused, .status-expired, .status-skipped, .status-off, .status-never, .status-disabled,
.status-offline, .status-dry_run, .status-offboarded, .status-blocked, .status-closed,
.status-unused, .status-member, .tone-neutral {
  --tone-bg: var(--neutral-bg); --tone-fg: var(--neutral-fg);
  --tone-border: var(--neutral-border); --tone-solid: var(--neutral-solid);
}
.status-required::before, .status.no-dot::before { display: none; }
.status-offboarded::before {
  content: "\00d7"; width: auto; height: auto; background: none;
  font-size: 13px; line-height: 1; color: var(--tone-solid);
}
.status-running::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
a.status:hover, a > .status:hover { text-decoration: underline; }
a:has(> .status) { text-decoration: none; }

/* tags: non-status labels (sync kind, schedule) */
.tag {
  display: inline-flex; align-items: center; gap: var(--space-2); height: 22px; padding: 0 var(--space-3);
  border-radius: var(--radius-md); border: 1px solid var(--neutral-border); background: var(--neutral-bg);
  color: var(--neutral-fg); font: 500 var(--text-xs)/var(--lh-xs) var(--font-sans); white-space: nowrap;
}
.count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px;
  padding: 0 6px; border-radius: var(--radius-full); background: var(--neutral-bg); color: var(--neutral-fg);
  font: 500 var(--text-xs)/1 var(--font-sans); font-variant-numeric: tabular-nums;
}
.count--warning { background: var(--warning-bg); color: var(--warning-fg); }
.count--accent { background: var(--accent-subtle); color: var(--accent-subtle-fg); }

/* ===================================================================== alerts (4.8) */
.alert {
  --tone-bg: var(--info-bg); --tone-border: var(--info-border); --tone-solid: var(--info-solid); --tone-fg: var(--info-fg);
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: var(--space-4); align-items: start;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--tone-border); border-left: 3px solid var(--tone-solid);
  background: var(--tone-bg); border-radius: var(--radius-lg); color: var(--text-1);
  font-size: var(--text-sm); line-height: var(--lh-sm);
}
.alert--success { --tone-bg: var(--success-bg); --tone-border: var(--success-border); --tone-solid: var(--success-solid); --tone-fg: var(--success-fg); }
.alert--warning { --tone-bg: var(--warning-bg); --tone-border: var(--warning-border); --tone-solid: var(--warning-solid); --tone-fg: var(--warning-fg); }
.alert--danger { --tone-bg: var(--danger-bg); --tone-border: var(--danger-border); --tone-solid: var(--danger-solid); --tone-fg: var(--danger-fg); }
.alert--neutral { --tone-bg: var(--surface-sunken); --tone-border: var(--border); --tone-solid: var(--text-3); --tone-fg: var(--text-2); }
.alert__icon { color: var(--tone-solid); width: 20px; height: 20px; margin-top: 0; }
.alert__title { font-size: var(--text-base); line-height: var(--lh-base); font-weight: 600; margin: 0 0 var(--space-1); color: var(--text-1); }
.alert__body > :last-child { margin-bottom: 0; }
.alert__body p { margin: 0 0 var(--space-2); }
.alert__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.alert--banner { margin-bottom: var(--space-6); }
.alert + .alert { margin-top: var(--space-4); }
@media (max-width: 639px) {
  .alert { grid-template-columns: 20px minmax(0, 1fr); }
  .alert__actions { grid-column: 2; }
}

/* ===================================================================== page header (4.3) */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-5);
  margin-bottom: var(--space-7);
}
.page-header__main { min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.page-header__title { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.page-header__title h1 { overflow-wrap: anywhere; }
.page-header__desc { color: var(--text-2); max-width: 80ch; margin: 0; }
.page-header__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); color: var(--text-2); font-size: var(--text-sm); }
.page-header__meta .sep { color: var(--text-3); }
.page-header__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); flex: none; }
.page-header + .tabs { margin-top: calc(-1 * var(--space-3)); }
@media (max-width: 767px) {
  .page-header { flex-direction: column; align-items: stretch; }
}

/* section heading inside a page */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin: var(--space-8) 0 var(--space-4); }
.section-head h2 { font-size: var(--text-lg); line-height: var(--lh-lg); }

/* ===================================================================== cards (4.4) */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  min-width: 0;
}
.card--raised { box-shadow: var(--shadow-sm); }
.card__header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border);
}
.card__titles { min-width: 0; }
.card__title { font-size: var(--text-base); line-height: var(--lh-base); font-weight: 600; margin: 0; letter-spacing: 0; }
.card__desc { color: var(--text-2); font-size: var(--text-sm); line-height: var(--lh-sm); margin: var(--space-1) 0 0; }
.card__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; flex: none; }
.card__body { padding: var(--space-6); }
.card__body--flush { padding: 0; }
.card__body--flush > .table-wrap { border: 0; border-radius: 0; }
.card__body--flush:last-child > .table-wrap:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card__footer {
  display: flex; justify-content: flex-end; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-6); background: var(--surface-sunken);
  border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.card__footer--between { justify-content: space-between; }
.card-stack { display: flex; flex-direction: column; gap: var(--space-6); }
.card-grid { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1280px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ===================================================================== description list (4.5) */
.dl {
  display: grid; grid-template-columns: minmax(140px, 200px) minmax(0, 1fr);
  column-gap: var(--space-6); row-gap: var(--space-4); margin: 0;
}
.dl dt { font-size: var(--text-sm); line-height: var(--lh-base); font-weight: 500; color: var(--text-2); }
.dl dd { margin: 0; color: var(--text-1); min-width: 0; overflow-wrap: anywhere; }
.dl .dl__help { display: block; margin-top: var(--space-1); font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-2); }
.dl .empty { color: var(--text-3); }
.dl--compact { grid-template-columns: minmax(110px, 160px) minmax(0, 1fr); row-gap: var(--space-3); }
@media (max-width: 639px) {
  .dl { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-1); }
  .dl dd { margin-bottom: var(--space-3); }
}

/* ===================================================================== tables (4.6) */
.table-wrap {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: auto; background: var(--surface); max-width: 100%;
}
.table-wrap--scroll { max-height: 70vh; }
.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: var(--text-base); line-height: var(--lh-base); font-variant-numeric: tabular-nums;
}
.table caption { caption-side: top; text-align: left; padding: var(--space-4) var(--space-4) var(--space-3); color: var(--text-2); font-size: var(--text-sm); }
.table th {
  height: 36px; padding: 0 var(--space-4); background: var(--surface-sunken);
  font-size: var(--text-sm); font-weight: 500; color: var(--text-2); text-align: left;
  white-space: nowrap; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.table-wrap--scroll .table thead th { position: sticky; top: 0; z-index: var(--z-sticky); }
.table td {
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border);
  vertical-align: middle; color: var(--text-1);
  max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.table tbody tr:last-child > td, .table tbody tr:last-child > th { border-bottom: 0; }
.table tbody tr:hover > td, .table tbody tr:hover > th { background: var(--surface-hover); }
.table tbody tr.is-selected > td { background: var(--surface-selected); }
.table tbody th[scope="row"] { font-weight: 500; text-align: left; background: inherit; height: auto; padding: var(--space-3) var(--space-4); color: var(--text-1); font-size: var(--text-base); white-space: nowrap; }
.table .num, .table th.num { text-align: right; }
.table .cell-wrap { white-space: normal; max-width: 60ch; overflow-wrap: anywhere; }
.table .cell-status { min-width: 120px; }
.table .cell-actions { width: 1%; text-align: right; white-space: nowrap; }
.table .cell-primary { font-weight: 500; }
.table .cell-muted { color: var(--text-2); }
.table td.cell-allow { overflow: visible; }
.table .mono { color: var(--text-1); }
.table--compact td { padding: var(--space-2) var(--space-4); font-size: var(--text-sm); line-height: var(--lh-sm); }
.table--compact th { height: 32px; }
.table--compact tbody th[scope="row"] { padding: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.table--freeze tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
.table--freeze thead tr > :first-child { background: var(--surface-sunken); z-index: calc(var(--z-sticky) + 1); }
.table--freeze tbody tr:hover > :first-child { background: var(--surface-hover); }
.table tbody tr.row-link { cursor: pointer; }
.table tr.row-group > th, .table tr.row-group > td {
  background: var(--surface); color: var(--text-3); font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: .04em; font-weight: 500; height: 32px; padding-top: var(--space-4);
}
.table-footer {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border);
  font-size: var(--text-sm); color: var(--text-2); background: var(--surface);
}
.table-wrap.is-loading tbody, .table-wrap[aria-busy="true"] tbody { opacity: .5; transition: opacity var(--dur-fast); }
.table-wrap.is-loading::before, .table-wrap[aria-busy="true"]::before {
  content: ""; position: absolute; top: 0; left: 0; height: 2px; width: 30%; z-index: 3;
  background: var(--accent); animation: indeterminate 1.1s var(--ease) infinite;
}
.table td.cell-empty { padding: 0; white-space: normal; max-width: none; }
.table tbody tr:hover > td.cell-empty { background: transparent; }
.skeleton { display: block; height: 12px; border-radius: var(--radius-sm); background: var(--surface-hover); animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 50% { opacity: .55; } }

/* stacked rows on phones for tables with few columns */
@media (max-width: 767px) {
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td { border: 0; padding: var(--space-1) 0; max-width: none; white-space: normal; text-align: left; display: flex; gap: var(--space-4); justify-content: space-between; align-items: center; }
  .table--stack td.num { text-align: right; }
  .table--stack td[data-label]::before { content: attr(data-label); color: var(--text-2); font-size: var(--text-sm); font-weight: 500; flex: none; }
  .table--stack td.cell-primary { display: block; padding-bottom: var(--space-3); }
  .table--stack td.cell-primary::before { content: none; }
}

/* ===================================================================== forms (4.9) */
.field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field__label { display: inline-flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: 500; color: var(--text-1); }
.field__help { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-2); max-width: 70ch; margin: 0; }
.field__error { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--danger-fg); margin: 0; }
.field__error .icon { margin-top: 3px; }
.field-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6) var(--space-7); }
@media (min-width: 1024px) { .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset > legend { padding: 0; margin-bottom: var(--space-3); font-size: var(--text-sm); font-weight: 500; color: var(--text-1); }

.input, .select, .textarea,
input[type=text], input[type=email], input[type=number], input[type=password], input[type=url],
input[type=search], input[type=date], input[type=month], input[type=time], input[type=datetime-local],
input[type=tel], select, textarea {
  width: 100%; min-width: 0; height: 36px; padding: 0 var(--space-4);
  font: 400 var(--text-base)/var(--lh-base) var(--font-sans); color: var(--text-1);
  background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs); transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
textarea, .textarea { height: auto; min-height: 80px; padding: var(--space-3) var(--space-4); resize: vertical; }
select, .select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("/static/icons/chevron-down.svg"); background-repeat: no-repeat;
  background-position: right 10px center; background-size: 16px 16px;
}
select[multiple] { height: auto; padding: var(--space-2); background-image: none; }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--border-control-hover); }
input:focus-visible, select:focus-visible, textarea:focus-visible,
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); border-radius: var(--radius-md); }
[aria-invalid="true"], .is-invalid { border-color: var(--danger-solid) !important; }
[aria-invalid="true"]:focus, .is-invalid:focus { box-shadow: var(--focus-ring-danger); }
input:disabled, select:disabled, textarea:disabled, input[readonly], textarea[readonly] {
  background-color: var(--surface-sunken); color: var(--text-2); box-shadow: none;
}
input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; }
input.input--num, .input--num { width: 12ch; min-width: 8ch; text-align: right; font-variant-numeric: tabular-nums; }
.input--code { width: 16ch; font-family: var(--font-mono); font-size: var(--text-sm); }
.input--mono { font-family: var(--font-mono); font-size: var(--text-sm); }
.input--auto { width: auto; }
input[type=file] { font-size: var(--text-sm); color: var(--text-2); max-width: 100%; }
input[type=file]::file-selector-button {
  font: 500 var(--text-sm)/1 var(--font-sans); height: 28px; padding: 0 var(--space-4); margin-right: var(--space-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--text-1); cursor: pointer;
}
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible { box-shadow: var(--focus-ring); }
.check { display: flex; align-items: flex-start; gap: var(--space-3); min-height: 24px; font-size: var(--text-base); color: var(--text-1); font-weight: 400; cursor: pointer; }
.check input { margin-top: 2px; }
.check__text { display: flex; flex-direction: column; gap: var(--space-1); }
.check__help { font-size: var(--text-sm); color: var(--text-2); }
.check-list { display: flex; flex-direction: column; gap: var(--space-3); }
/* radio cards */
.choice-cards { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.choice-card { display: flex; gap: var(--space-4); align-items: flex-start; padding: var(--space-5); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); cursor: pointer; }
.choice-card:hover { border-color: var(--border-control-hover); }
.choice-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--surface-selected); }
.choice-card:has(input:disabled) { opacity: .6; cursor: not-allowed; }
/* switch */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; font-weight: 400; }
input[type=checkbox][role=switch] {
  appearance: none; -webkit-appearance: none; position: relative; width: 32px; height: 18px; margin: 0;
  border-radius: var(--radius-full); background: var(--border-strong); border: 0; box-shadow: none;
  transition: background-color var(--dur-fast) var(--ease); cursor: pointer;
}
input[type=checkbox][role=switch]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform var(--dur-fast) var(--ease);
}
input[type=checkbox][role=switch]:checked { background: var(--accent); }
input[type=checkbox][role=switch]:checked::after { transform: translateX(14px); }
/* search input with leading icon */
.search { position: relative; display: inline-flex; align-items: center; width: 240px; max-width: 100%; }
.search > .icon { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.search input { padding-left: 32px; }
.search--full { width: 100%; }
/* sticky form action bar */
.form-actions {
  position: sticky; bottom: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  margin: var(--space-7) calc(-1 * var(--space-9)) calc(-1 * var(--space-11)); padding: var(--space-4) var(--space-9);
  background: var(--surface); border-top: 1px solid var(--border);
}
.form-actions__hint { color: var(--text-2); font-size: var(--text-sm); }
.form-actions--static { position: static; margin: var(--space-6) 0 0; padding: 0; border: 0; background: none; justify-content: flex-end; }
@media (max-width: 767px) {
  .input, .select, input[type=text], input[type=email], input[type=number], input[type=password], input[type=url],
  input[type=search], input[type=date], input[type=month], input[type=time], input[type=tel], select {
    height: 44px; font-size: var(--text-md);
  }
  textarea { font-size: var(--text-md); }
  .form-actions { margin-left: calc(-1 * var(--space-5)); margin-right: calc(-1 * var(--space-5)); padding: var(--space-4) var(--space-5); }
}

/* ===================================================================== tabs & segmented (4.10) */
.tabs {
  display: flex; gap: var(--space-6); border-bottom: 1px solid var(--border);
  overflow-x: auto; margin-bottom: var(--space-7); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: var(--space-3); height: 40px; flex: none;
  font-weight: 500; color: var(--text-2); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text-1); }
.tabs a[aria-current="page"] { color: var(--text-1); border-bottom-color: var(--accent); }
.tabs a:focus-visible { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }

.segmented {
  display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-md); max-width: 100%; overflow-x: auto;
}
.segmented a, .segmented label {
  display: inline-flex; align-items: center; gap: var(--space-2); height: 28px; padding: 0 var(--space-4);
  font-size: var(--text-sm); font-weight: 500; color: var(--text-2); text-decoration: none;
  border-radius: calc(var(--radius-md) - 2px); white-space: nowrap; cursor: pointer;
}
.segmented a:hover, .segmented label:hover { color: var(--text-1); }
.segmented a[aria-current="true"], .segmented a[aria-current="page"], .segmented label:has(input:checked) {
  background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-xs), 0 0 0 1px var(--border);
}
.segmented .count { background: transparent; color: var(--text-3); padding: 0 2px; min-width: 0; }
.segmented a[aria-current] .count { color: var(--text-2); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }

/* ===================================================================== disclosure (4.11) */
.disclosure { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.disclosure + .disclosure { margin-top: var(--space-4); }
.disclosure-group { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.disclosure-group > .disclosure { border: 0; border-radius: 0; margin: 0; }
.disclosure-group > .disclosure + .disclosure { border-top: 1px solid var(--border); }
.disclosure > summary {
  display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-5);
  font-weight: 500; cursor: pointer; list-style: none; border-radius: var(--radius-lg);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary > .disclosure__chevron { color: var(--text-3); transition: transform var(--dur-fast) var(--ease); }
.disclosure[open] > summary > .disclosure__chevron { transform: rotate(90deg); }
.disclosure > summary:hover { background: var(--surface-hover); }
.disclosure__meta { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); color: var(--text-2); font-size: var(--text-sm); font-weight: 400; }
.disclosure__body { padding: var(--space-5); border-top: 1px solid var(--border); }
.disclosure--plain { border: 0; background: none; }
.disclosure--plain > summary { padding: 0; min-height: 32px; color: var(--text-2); }
.disclosure--plain > summary:hover { background: none; color: var(--text-1); }
.disclosure--plain > .disclosure__body { border: 0; padding: var(--space-3) 0 0; }

/* ===================================================================== stat tiles (4.12) */
.stats { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: var(--space-7); }
.stat {
  position: relative; display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-5) var(--space-6); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 0;
  color: inherit; text-decoration: none;
}
a.stat:hover { border-color: var(--border-strong); background: var(--surface); color: inherit; }
a.stat:hover .stat__label { color: var(--text-1); }
.stat__label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 500; color: var(--text-2); }
.stat__label .icon { color: var(--text-3); }
.stat__value {
  font-size: var(--text-3xl); line-height: var(--lh-3xl); font-weight: 600; color: var(--text-1);
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.stat__value--sm { font-size: var(--text-xl); line-height: var(--lh-3xl); letter-spacing: var(--tracking-tight); }
.stat__sub { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: var(--text-sm); color: var(--text-2); min-height: 22px; }
.stat__delta { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: 500; }
.stat__delta--up { color: var(--success-fg); }
.stat__delta--down { color: var(--danger-fg); }
.stat__go { position: absolute; top: var(--space-5); right: var(--space-5); color: var(--text-3); opacity: 0; transition: opacity var(--dur-fast); }
a.stat:hover .stat__go, a.stat:focus-visible .stat__go { opacity: 1; }

/* ===================================================================== stepper & progress (4.13) */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.stepper__item { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: var(--space-4); padding-bottom: var(--space-6); }
.stepper__item:last-child { padding-bottom: 0; }
.stepper__item::before {
  content: ""; position: absolute; left: 11px; top: 28px; bottom: 4px; width: 2px; background: var(--border);
}
.stepper__item:last-child::before { display: none; }
.stepper__item--done::before { background: var(--success-solid); }
.stepper__dot {
  width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: 600; color: var(--text-3); background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--border-strong); font-variant-numeric: tabular-nums;
}
.stepper__item--done .stepper__dot { background: var(--success-solid); color: #fff; box-shadow: none; }
.stepper__item--current .stepper__dot { color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.stepper__item--blocked .stepper__dot { color: var(--warning-fg); box-shadow: inset 0 0 0 2px var(--warning-solid); }
.stepper__text { display: flex; flex-direction: column; gap: var(--space-1); padding-top: 2px; min-width: 0; }
.stepper__label { font-weight: 500; color: var(--text-2); text-decoration: none; }
a.stepper__label:hover { color: var(--text-1); text-decoration: underline; }
.stepper__item--current .stepper__label { color: var(--text-1); }
.stepper__sub { font-size: var(--text-sm); color: var(--text-3); }
.stepper-compact { display: none; font-size: var(--text-sm); color: var(--text-2); }
progress {
  appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 6px; border: 0;
  border-radius: var(--radius-full); background: var(--surface-hover); overflow: hidden; color: var(--accent);
}
progress::-webkit-progress-bar { background: var(--surface-hover); border-radius: var(--radius-full); }
progress::-webkit-progress-value { background: var(--accent); border-radius: var(--radius-full); }
progress::-moz-progress-bar { background: var(--accent); border-radius: var(--radius-full); }
progress:not([value]) { position: relative; }
progress:not([value])::-webkit-progress-bar { background: var(--surface-hover); }
progress:not([value])::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 30%; background: var(--accent);
  border-radius: var(--radius-full); animation: indeterminate 1.1s var(--ease) infinite;
}
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

/* ===================================================================== code, secrets, copy (4.14) */
.code-block { position: relative; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-sunken); min-width: 0; }
.code-block__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  height: 36px; padding: 0 var(--space-2) 0 var(--space-5); border-bottom: 1px solid var(--border);
  font: 500 var(--text-xs)/1 var(--font-mono); color: var(--text-2);
}
.code-block pre {
  margin: 0; padding: var(--space-5); overflow-x: auto; font-size: var(--text-sm); line-height: var(--lh-sm);
  color: var(--text-1); white-space: pre;
}
.code-block--wrap pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.code-block__copy { position: absolute; top: var(--space-3); right: var(--space-3); }
.code-block__head .code-block__copy { position: static; }
.code-block > .code-block__copy[data-tip] { position: absolute; }
.code-block:not(:has(.code-block__head)) pre { padding-right: 48px; }
.secret { display: flex; flex-direction: column; gap: var(--space-4); }
.secret__row { display: flex; gap: var(--space-3); align-items: stretch; }
.secret__value {
  flex: 1; font-family: var(--font-mono); font-size: var(--text-md) !important; height: 44px !important;
  user-select: all; background: var(--surface) !important; color: var(--text-1) !important;
}
@media (max-width: 639px) { .secret__row { flex-direction: column; } }

/* ===================================================================== toasts & loading (4.16) */
.toasts {
  position: fixed; right: var(--space-6); bottom: var(--space-6); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--space-3); width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  --tone-solid: var(--info-solid);
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: var(--space-4); align-items: start;
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-5); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  font-size: var(--text-sm); color: var(--text-1); pointer-events: auto; animation: toast-in var(--dur-base) var(--ease);
}
.toast > .icon { color: var(--tone-solid); width: 20px; height: 20px; }
.toast--success { --tone-solid: var(--success-solid); }
.toast--warning { --tone-solid: var(--warning-solid); }
.toast--danger { --tone-solid: var(--danger-solid); }
.toast__close { margin: -4px -4px -4px 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 767px) { .toasts { top: var(--space-4); bottom: auto; left: var(--space-4); right: var(--space-4); width: auto; } }

.htmx-indicator { opacity: 0; transition: opacity var(--dur-fast); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.loading-bar { position: relative; height: 2px; overflow: hidden; background: transparent; }
.loading-bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 30%; background: var(--accent); animation: indeterminate 1.1s var(--ease) infinite; }
[aria-busy="true"] { cursor: progress; }
.spinner-inline { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--text-2); font-size: var(--text-sm); }

/* ===================================================================== empty states (4.17) */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  max-width: 440px; margin: 0 auto; padding: var(--space-10) var(--space-6);
}
.empty__icon {
  display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px;
  border-radius: 50%; background: var(--surface-sunken); color: var(--text-3); margin-bottom: var(--space-5);
  box-shadow: inset 0 0 0 1px var(--border);
}
.empty__title { font-size: var(--text-lg); line-height: var(--lh-lg); font-weight: 600; margin: 0 0 var(--space-2); }
.empty__body { color: var(--text-2); margin: 0 0 var(--space-6); }
.empty__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: center; }
.empty--compact { padding: var(--space-7); max-width: 520px; }
.empty--compact .empty__title { font-size: var(--text-base); line-height: var(--lh-base); margin-bottom: var(--space-1); }
.empty--compact .empty__body { font-size: var(--text-sm); margin-bottom: var(--space-4); }
.empty--compact .empty__icon { width: 40px; height: 40px; margin-bottom: var(--space-3); }

/* ===================================================================== toolbar & pagination (4.18) */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center; margin-bottom: var(--space-4); }
.toolbar > * { min-width: 0; max-width: 100%; }
.toolbar__end { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
.toolbar__count { font-size: var(--text-sm); color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-sm); color: var(--text-2); }
.pagination__nav { display: flex; gap: var(--space-3); }

/* ===================================================================== dialog (4.19) */
dialog.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); background: var(--surface); color: var(--text-1);
}
dialog.dialog::backdrop { background: rgb(3 7 18 / .5); }
.dialog__body { padding: var(--space-7); display: flex; flex-direction: column; gap: var(--space-4); }
.dialog__footer { display: flex; justify-content: flex-end; gap: var(--space-3); padding: var(--space-4) var(--space-7); background: var(--surface-sunken); border-top: 1px solid var(--border); }

/* ===================================================================== tooltips (4.20) */
[data-tip] { position: relative; }
/* The bubble only exists while shown (display: none otherwise), so a hidden tooltip never
   widens the page's scroll area on phones. It wraps at max 280px / the viewport. */
[data-tip]::after {
  content: attr(data-tip); display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--tooltip-bg); color: var(--tooltip-fg); font: 500 var(--text-xs)/var(--lh-xs) var(--font-sans);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  width: max-content; max-width: min(280px, calc(100vw - 32px)); white-space: normal; overflow-wrap: anywhere; text-align: left;
  pointer-events: none; z-index: var(--z-tooltip);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { display: block; animation: tip-in var(--dur-fast) var(--ease) 300ms both; }
@keyframes tip-in { from { opacity: 0; } to { opacity: 1; } }
[data-tip-pos="bottom"]::after { bottom: auto; top: calc(100% + 6px); }
[data-tip-pos="left"]::after { left: auto; right: 0; transform: none; }
@media (hover: none) { [data-tip]:hover:not(:focus-visible)::after { display: none; } }

/* ===================================================================== avatar, menus, breadcrumbs */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%; background: var(--avatar-bg); color: var(--avatar-fg);
  font: 600 var(--text-xs)/1 var(--font-sans); letter-spacing: .02em;
}
.tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none; overflow: hidden;
  width: 28px; height: 28px; border-radius: var(--radius-md); background: var(--surface-hover);
  color: var(--text-2); font: 600 11px/1 var(--font-sans); box-shadow: inset 0 0 0 1px var(--border);
  letter-spacing: .02em;
}
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile--sm { width: 24px; height: 24px; font-size: 10px; border-radius: var(--radius-sm); }
.tile--lg { width: 48px; height: 48px; font-size: 16px; border-radius: var(--radius-lg); }
.tile--accent { background: var(--accent); color: var(--text-on-accent); box-shadow: none; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; border-radius: var(--radius-md); }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-popover); min-width: 240px;
  padding: var(--space-2); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}
.menu__panel--up { top: auto; bottom: calc(100% + 6px); left: 0; right: auto; }
.menu__head { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); margin: calc(-1 * var(--space-2)) calc(-1 * var(--space-2)) var(--space-2); }
.menu__head strong { display: block; font-weight: 500; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; }
.menu__head span { font-size: var(--text-sm); color: var(--text-2); }
.menu__item {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; height: 32px; padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-md); background: none; color: var(--text-1); font: 400 var(--text-base)/1 var(--font-sans);
  text-decoration: none; cursor: pointer; text-align: left;
}
.menu__item .icon { color: var(--text-3); }
.menu__item:hover { background: var(--surface-hover); color: var(--text-1); }
.menu__item--danger { color: var(--danger-fg); }
.menu__item--static { cursor: default; color: var(--text-2); }
.menu__item--static:hover { background: none; color: var(--text-2); }
.menu__item--danger .icon { color: var(--danger-fg); }
.menu form { margin: 0; }
.menu__sep { height: 1px; background: var(--border); margin: var(--space-2) calc(-1 * var(--space-2)); }

.breadcrumbs { min-width: 0; }
.breadcrumbs ol { display: flex; align-items: center; gap: var(--space-2); list-style: none; margin: 0; padding: 0; min-width: 0; }
.breadcrumbs li { display: flex; align-items: center; gap: var(--space-2); min-width: 0; color: var(--text-2); font-size: var(--text-base); }
.breadcrumbs li + li::before { content: none; }
.breadcrumbs .crumb-sep { color: var(--text-3); }
.breadcrumbs a { color: var(--text-2); text-decoration: none; white-space: nowrap; }
.breadcrumbs a:hover { color: var(--text-1); text-decoration: underline; }
.breadcrumbs [aria-current="page"] { color: var(--text-1); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs__back { display: none; }
@media (max-width: 767px) {
  .breadcrumbs ol { display: none; }
  .breadcrumbs__back { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-2); text-decoration: none; font-weight: 500; }
}

/* ===================================================================== product mark */
.mark {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: var(--radius-md); background: var(--brand-600); color: #fff;
  font: 700 13px/1 var(--font-sans); letter-spacing: -0.02em;
  box-shadow: inset 0 -1px 0 rgb(0 0 0 / .15);
}
.mark--lg { width: 32px; height: 32px; font-size: 17px; border-radius: var(--radius-lg); }

/* ===================================================================== auth pages (8.4 step 7)
   Sign-in, two-step sign-in, errors, dealer choice: a centred 400px card on --bg. */
.auth { min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.auth__top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; padding: var(--space-5) var(--space-6); }
.auth__brand { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--text-1); font-weight: 600; text-decoration: none; letter-spacing: var(--tracking-tight); min-width: 0; }
.auth__brand:hover { color: var(--text-1); }
.auth__brand .brand-logo { width: 28px; height: 28px; border-radius: var(--radius-md); flex: none; }
.auth__end { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.auth__account { display: flex; align-items: center; gap: var(--space-4); font-size: var(--text-sm); color: var(--text-2); flex-wrap: wrap; }
.auth__link { color: var(--text-2); text-decoration: none; font-weight: 500; }
.auth__link:hover { color: var(--text-1); text-decoration: underline; }
.auth__email { display: none; }
@media (min-width: 768px) { .auth__email { display: inline; } }
.auth__main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: var(--space-8) var(--space-5) var(--space-10); }
@media (min-width: 768px) { .auth__main { padding-top: 10vh; } }
.auth__foot { padding: var(--space-6); text-align: center; font-size: var(--text-xs); color: var(--text-3); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); padding: var(--space-8); }
.auth-card--wide { max-width: 560px; }
.auth-card__mark { margin-bottom: var(--space-6); }
.auth-card__eyebrow { font-size: var(--text-sm); font-weight: 500; color: var(--text-2); margin: 0 0 var(--space-2); }
.auth-card h1 { font-size: var(--text-xl); line-height: var(--lh-xl); margin-bottom: var(--space-2); }
.auth-card__lead { color: var(--text-2); margin: 0 0 var(--space-6); }
.auth-card .alert { margin-bottom: var(--space-5); }
.auth-card form { display: flex; flex-direction: column; gap: var(--space-5); }
.auth-card__foot { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--border); font-size: var(--text-sm); color: var(--text-2); }
.auth-card__foot form { display: inline; }
.auth-card__foot .link-button { font-size: var(--text-sm); }
.auth-steps { margin: 0 0 var(--space-6); padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: var(--space-5); }
.auth-steps > li { counter-increment: step; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--space-4); }
.auth-steps > li::before { content: counter(step); width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-subtle); color: var(--accent-subtle-fg); font-size: var(--text-xs); font-weight: 600; }
.mfa-qr { display: block; width: fit-content; margin-top: var(--space-3); padding: var(--space-3); background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.mfa-qr svg { display: block; width: 208px; max-width: 100%; height: auto; }
.mfa-key { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-3); }
.mfa-secret { font-family: var(--mono); font-size: var(--text-md); letter-spacing: .04em; white-space: normal; word-spacing: .25em; }
.mfa-uri { word-break: break-all; }
.mfa-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-4); list-style: none; padding: var(--space-5); margin: 0 0 var(--space-6); background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--radius-lg); font-family: var(--font-mono); font-size: var(--text-md); }
.mfa-codes code { background: none; border: 0; padding: 0; font-size: inherit; }
.card:not(:has(> .card__body)):not(:has(> form > .card__body)) { padding: var(--space-6); }

/* ===================================================================== element defaults & small helpers
   Hand-written labels (outside ui.field), the sign-out link button and inline forms. */
label { font-size: var(--text-sm); font-weight: 500; color: var(--text-1); }
label.check { font-size: var(--text-base); font-weight: 400; }
details > summary { cursor: pointer; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); text-underline-offset: 2px; }
.link-button:hover { color: var(--link-hover); }
.inline-form { display: inline; margin: 0; }

/* Light/dark switch (ui.theme_toggle; web/preferences.py). The form is inline. */
.theme-toggle { display: inline-flex; margin: 0; }
.menu .theme-toggle { display: block; }
