/*
 * Layout and components. Every colour, size and radius comes from css/tokens.css; this file
 * never declares a literal colour that only works in one theme.
 *
 * Order: base -> layout (shell, header, pages, grids) -> components (buttons, fields, badges,
 * tiles, charts, table, popover, states, toast, modal) -> pages (login, home, styleguide)
 * -> responsive and motion preferences.
 */

/* ---- base --------------------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

ul {
  padding: 0;
  list-style: none;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 0.05em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--ink-2);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -48px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-3);
}

.noscript {
  padding: var(--space-8);
  text-align: center;
}

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

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

.icon {
  flex: none;
  display: inline-block;
  vertical-align: middle;
}

/* ---- boot --------------------------------------------------------------------------------- */

.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-3);
  color: var(--ink-3);
}

.boot__mark {
  width: 40px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  animation: boot-pulse 1.2s var(--ease) infinite alternate;
}

@keyframes boot-pulse {
  from {
    opacity: 0.35;
    transform: scaleX(0.6);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

/* ---- shell -------------------------------------------------------------------------------- */

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 3px;
  background: var(--brand-gradient);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

.app-header__inner,
.synthetic-banner__inner,
.app-footer__inner,
.main > .page {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.app-header__inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--ink);
  text-decoration: none;
  flex: none;
}

/* The Norvelis mark (web/img/norvelis-mark-*.png, transparent background) beside the wordmark. */
.brand__logo {
  display: block;
  flex: none;
  object-fit: contain;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand__name {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
  letter-spacing: -0.01em;
}

.brand__product {
  font-size: var(--text-xs);
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.module-nav {
  flex: 1;
  min-width: 0;
  align-self: stretch;
  overflow-x: auto;
  scrollbar-width: none;
}

.module-nav::-webkit-scrollbar {
  display: none;
}

.module-nav__list {
  height: 100%;
  display: flex;
  align-items: stretch;
  gap: var(--space-1);
}

.module-nav__list > li {
  display: flex;
}

.module-nav__link {
  position: relative;
  display: flex;
  align-items: center;
  padding-inline: var(--space-3);
  color: var(--ink-2);
  font-weight: var(--weight-medium);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--duration-fast) var(--ease);
}

.module-nav__link:hover {
  color: var(--ink);
}

.module-nav__link[aria-current="page"] {
  color: var(--ink);
}

.module-nav__link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}

.module-nav__link:focus-visible {
  outline-offset: -4px;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

.synthetic-banner {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--ink-3);
  font-size: var(--text-xs);
}

.synthetic-banner__inner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 28px;
}

.synthetic-banner__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sev-warning-mark);
  flex: none;
}

.main {
  flex: 1;
  outline: none;
  padding-block: var(--space-6) var(--space-12);
}

.app-footer {
  border-top: 1px solid var(--border);
  color: var(--ink-3);
  font-size: var(--text-xs);
}

.app-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-block: var(--space-4);
}

.version {
  font-variant-numeric: tabular-nums;
}

/* user menu */

.user-menu {
  position: relative;
}

.user-menu__button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-2) 0 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  cursor: pointer;
}

.user-menu__button:hover {
  background: var(--surface-hover);
}

.user-menu__button:focus-visible {
  border-radius: var(--radius-pill);
}

.avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
}

.user-menu__name {
  font-weight: var(--weight-medium);
  color: var(--ink);
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  min-width: 240px;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.user-menu__who {
  padding: var(--space-2) var(--space-3) var(--space-3);
  margin-bottom: var(--space-1);
  border-bottom: 1px solid var(--border);
}

.user-menu__display {
  font-weight: var(--weight-semibold);
}

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

.user-menu__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.user-menu__item:hover,
.user-menu__item:focus-visible {
  background: var(--surface-hover);
}

.user-menu__item .icon {
  color: var(--ink-3);
}

/* ---- page layout -------------------------------------------------------------------------- */

.page {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}

.eyebrow {
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.page-title--xl {
  font-size: var(--text-3xl);
  letter-spacing: -0.02em;
}

.page-lead {
  margin-top: var(--space-1);
  max-width: 68ch;
  color: var(--ink-2);
  font-size: var(--text-md);
}

/*
 * Inline page header (cockpit): eyebrow on top, then the title and the lead on ONE line on wide
 * screens, so the first screen at 1280x720 keeps its height for the KPI tiles. Narrow screens
 * stack as usual.
 */
@media (min-width: 1200px) {
  .page-header--inline {
    align-items: center;
  }

  .page-header--inline > div:first-child {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: var(--space-4);
    align-items: baseline;
  }

  .page-header--inline .eyebrow {
    grid-column: 1 / -1;
  }

  .page-header--inline .page-lead {
    margin-top: 0;
  }
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.section {
  display: block;
}

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

.grid--tiles {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-5);
}

.card--placeholder {
  border-style: dashed;
  background: var(--surface-2);
}

/* ---- buttons ------------------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: var(--weight-semibold);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease);
}

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

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

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-2);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--ink);
}

.btn--danger {
  background: var(--sev-error-bg);
  border-color: var(--sev-error-border);
  color: var(--sev-error-fg);
}

.btn--danger:hover:not(:disabled) {
  border-color: var(--sev-error-mark);
}

.btn--sm {
  min-height: 30px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

.btn--block {
  width: 100%;
}

.btn[aria-busy="true"] {
  cursor: progress;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.icon-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn--sm {
  width: 28px;
  height: 28px;
}

.icon-wrap {
  display: inline-grid;
}

/* ---- form fields -------------------------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form__intro {
  color: var(--ink-2);
}

.form__error,
.field__error {
  color: var(--sev-error-fg);
  font-size: var(--text-sm);
}

.form__error {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--sev-error-bg);
  border: 1px solid var(--sev-error-border);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.field__label {
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

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

.input,
.select select {
  width: 100%;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.input::placeholder {
  color: var(--ink-3);
}

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

.input:focus-visible,
.select select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}

.input[aria-invalid="true"] {
  border-color: var(--sev-error-mark);
}

.select {
  position: relative;
  min-width: 0;
}

.select select {
  appearance: none;
  padding-right: var(--space-8);
  cursor: pointer;
  text-overflow: ellipsis;
}

.select__chevron {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  color: var(--ink);
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

/* segmented control (currency) */

.segmented {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.segmented__options {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.segmented__option {
  position: relative;
}

.segmented__option input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.segmented__option span {
  display: block;
  min-width: 44px;
  padding: 5px var(--space-3);
  border-radius: 6px;
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-align: center;
}

.segmented__option input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.segmented__option input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* ---- filter bar --------------------------------------------------------------------------- */

/*
 * Compact by design: small labels above 34px controls, everything on one row from 1200px wide
 * (about 70px tall instead of 135px), so the cockpit's tiles stay on the first screen.
 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--space-3) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.filter-bar__fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2) var(--space-3);
  min-width: 0;
}

.filter-bar .field {
  gap: 2px;
}

.filter-bar .field__label {
  color: var(--ink-3);
  font-size: var(--text-xs);
}

.filter-bar .select select {
  min-height: 34px;
}

.filter-bar__fields .field--inline {
  width: 184px;
}

/* A URL filter outside the user's scope (filterBar.js showValue): amber frame, as the tiles say. */
.filter-bar .field--outside .select select {
  border-color: var(--sev-warning-mark);
  background: var(--sev-warning-bg);
  color: var(--sev-warning-fg);
}

.filter-bar__fields .segmented {
  width: auto;
  flex: none;
}

.filter-bar__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  color: var(--ink-3);
  font-size: var(--text-sm);
  white-space: nowrap;
}

@media (min-width: 1200px) {
  .filter-bar,
  .filter-bar__fields {
    flex-wrap: nowrap;
  }

  .filter-bar__fields {
    flex: 1 1 auto;
  }

  .filter-bar__meta {
    flex: none;
  }

  .filter-bar__fields .field--inline {
    width: auto;
    flex: 1 1 150px;
    max-width: 220px;
  }

  .filter-bar__fields .segmented.field--inline {
    flex: none;
    max-width: none;
  }
}

/*
 * Sticky filter bar (filterBar(el, { sticky: true })): wide and tall-enough screens only - on a
 * phone a sticky bar would eat a third of the viewport. The host is the sticky element (a sticky
 * child cannot outlive its own wrapper); a band of page background masks the content scrolling
 * underneath, and the bar's bottom edge is published as --sticky-top by js/ui/filterBar.js.
 */
@media (min-width: 1200px) and (min-height: 600px) {
  .filter-bar-host--sticky {
    position: sticky;
    top: var(--header-h);
    z-index: 20;
    margin-block: calc(-1 * var(--space-2));
    padding-block: var(--space-2);
    background: var(--bg);
  }
}

.as-of strong {
  color: var(--ink-2);
  font-weight: var(--weight-semibold);
}

/* ---- badges ------------------------------------------------------------------------------- */

.trust,
.sev,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}

.trust strong {
  font-weight: var(--weight-bold);
}

.trust--green {
  background: var(--trust-green-bg);
  color: var(--trust-green-fg);
}

.trust--amber {
  background: var(--trust-amber-bg);
  color: var(--trust-amber-fg);
}

.trust--red {
  background: var(--trust-red-bg);
  color: var(--trust-red-fg);
}

.trust--none {
  background: var(--surface-sunken);
  color: var(--ink-3);
}

.sev--error {
  background: var(--sev-error-bg);
  color: var(--sev-error-fg);
  border-color: var(--sev-error-border);
}

.sev--warning {
  background: var(--sev-warning-bg);
  color: var(--sev-warning-fg);
  border-color: var(--sev-warning-border);
}

.sev--info {
  background: var(--sev-info-bg);
  color: var(--sev-info-fg);
  border-color: var(--sev-info-border);
}

.sev--ok {
  background: var(--sev-ok-bg);
  color: var(--sev-ok-fg);
  border-color: var(--sev-ok-border);
}

.pill--neutral {
  background: var(--surface-sunken);
  color: var(--ink-2);
}

.pill--ok {
  background: var(--sev-ok-bg);
  color: var(--sev-ok-fg);
}

.pill--warning {
  background: var(--sev-warning-bg);
  color: var(--sev-warning-fg);
}

.pill--muted {
  background: transparent;
  color: var(--ink-3);
  border-color: var(--border-strong);
  border-style: dashed;
}

/* Refusals and failures (access denied, tool rejected): always with an icon, see statusPill(). */
.pill--error {
  background: var(--sev-error-bg);
  color: var(--sev-error-fg);
  border-color: var(--sev-error-border);
}

.pill--info {
  background: var(--sev-info-bg);
  color: var(--sev-info-fg);
}

.pill--accent {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

/* k-anonymity marker "n<5" (suppressedMarker() in js/ui/badges.js): muted, dashed, explained. */
.n5 {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
  cursor: help;
}

/* ---- tabs (js/ui/tabs.js) ------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-3);
  border: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-weight: var(--weight-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease);
}

.tab:hover {
  color: var(--ink);
  background: var(--surface-hover);
}

.tab .icon {
  color: var(--ink-3);
}

.tab[aria-selected="true"] {
  color: var(--ink);
}

.tab[aria-selected="true"] .icon {
  color: var(--accent);
}

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}

.tab:focus-visible {
  outline-offset: -3px;
}

/* ---- copy button (js/ui/copyButton.js) ------------------------------------------------------ */

.copy-btn {
  flex: none;
}

.copy-btn__done {
  display: none;
}

.copy-btn.is-done {
  color: var(--delta-good);
}

.copy-btn.is-done .copy-btn__done {
  display: inline-block;
}

/* Off-screen textarea of the clipboard fallback: focusable and selectable, never visible. */
.offscreen {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 26px;
  padding: 0 4px 0 var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.chip__remove {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.chip__remove:hover {
  background: var(--surface);
}

/* ---- KPI tiles ---------------------------------------------------------------------------- */

.kpi-tile-link {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-lg);
}

.kpi-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 148px;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.kpi-tile-link:hover .kpi-tile {
  border-color: var(--border-strong);
}

.kpi-tile__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.kpi-tile__label {
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.35;
}

.kpi-tile__value {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
}

.kpi-tile__value--muted {
  color: var(--ink-3);
  font-size: var(--text-xl);
}

.kpi-tile__foot {
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
}

.kpi-tile__delta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 4px;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.kpi-tile__delta-value {
  font-weight: var(--weight-semibold);
}

.kpi-tile__delta-ref {
  color: var(--ink-3);
  font-weight: var(--weight-regular);
  width: 100%;
  font-size: var(--text-xs);
}

.kpi-tile__delta--good {
  color: var(--delta-good);
}

.kpi-tile__delta--bad {
  color: var(--delta-bad);
}

.kpi-tile__delta--neutral {
  color: var(--ink-2);
}

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

.kpi-tile__caution {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--sev-error-fg);
  font-size: var(--text-xs);
}

.kpi-tile--suppressed {
  background: var(--surface-2);
  border-style: dashed;
  box-shadow: none;
}

/* sparkline */

.sparkline {
  display: block;
  flex: none;
  overflow: visible;
}

.sparkline__line {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.8;
}

.sparkline__area {
  fill: var(--viz-1);
  opacity: 0.08;
}

.sparkline__dot {
  fill: var(--viz-1);
  stroke: var(--surface);
  stroke-width: 2;
}

.sparkline--empty {
  display: inline-block;
  width: 96px;
  height: 28px;
}

/* ---- chart cards -------------------------------------------------------------------------- */

.chart-grid {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-4);
}

.chart-grid__cell {
  min-width: 0;
  grid-column: span 12;
}

.chart-grid__cell--6 {
  grid-column: span 6;
}

.chart-grid__cell--4 {
  grid-column: span 4;
}

.chart-grid__cell--8 {
  grid-column: span 8;
}

.chart-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--space-4) var(--space-5) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.chart-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.chart-card__titles {
  min-width: 0;
}

.chart-card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.005em;
  text-wrap: balance;
}

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

.chart-card__actions {
  display: flex;
  gap: var(--space-1);
  flex: none;
}

.chart-card__body {
  flex: 1;
  min-height: 0;
}

.chart-card__canvas {
  width: 100%;
}

.chart-card__table {
  max-height: 360px;
  overflow: auto;
}

.chart-card__footnote {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  color: var(--ink-3);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.chart-card__def-label {
  color: var(--ink-2);
  font-weight: var(--weight-semibold);
}

/* ECharts tooltip content (rendered inside the tooltip box, which ECharts themes). */

.tt-title {
  font-weight: var(--weight-semibold);
  margin-bottom: 4px;
}

.tt-row {
  display: flex;
  align-items: center;
  gap: 2px;
  line-height: 1.7;
}

.tt-key {
  display: inline-block;
  margin-right: 8px;
  flex: none;
}

.tt-key--line {
  width: 12px;
  height: 2px;
  border-radius: 1px;
}

.tt-key--box {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.tt-val {
  font-weight: var(--weight-semibold);
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}

.tt-name {
  opacity: 0.75;
}

.tt-total {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  opacity: 0.8;
}

/* ---- tables ------------------------------------------------------------------------------- */

.table-scroll {
  overflow-x: auto;
}

.simple-table,
.data-table__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}

.simple-table th,
.simple-table td,
.data-table__table th,
.data-table__table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.simple-table th,
.data-table__table th {
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: var(--surface);
}

.simple-table .num,
.data-table__table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.data-table__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.data-table__count {
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.data-table__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}

.data-table__tools {
  display: flex;
  gap: var(--space-2);
  margin-left: auto;
}

.data-table__scroll {
  overflow: auto;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.data-table__table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--border);
}

.data-table__table tbody tr:hover td {
  background: var(--surface-2);
}

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

.data-table__table td {
  color: var(--ink);
}

.th {
  display: flex;
  align-items: center;
  gap: 2px;
}

.num .th {
  justify-content: flex-end;
}

.th__sort,
.th__filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.th__sort {
  padding: 2px 4px;
  margin-left: -4px;
}

.th__sort .icon {
  color: var(--ink-3);
  opacity: 0.6;
}

.th__sort .icon.is-active,
.th__sort:hover .icon {
  color: var(--accent);
  opacity: 1;
}

.th__filter {
  width: 22px;
  height: 22px;
  justify-content: center;
  color: var(--ink-3);
}

.th__filter:hover,
.th__filter.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.popover {
  position: absolute;
  z-index: 20;
  width: 272px;
  max-width: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.popover__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow: auto;
  padding: 2px;
}

.popover__list .check {
  padding: 4px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.popover__list .check:hover {
  background: var(--surface-hover);
}

.popover__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-1);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

/* ---- states ------------------------------------------------------------------------------- */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--ink-2);
}

.state--loading {
  flex-direction: row;
  color: var(--ink-3);
}

.state__icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--ink-3);
  margin-bottom: var(--space-1);
}

.state--error .state__icon {
  background: var(--sev-error-bg);
  color: var(--sev-error-fg);
}

.state__title {
  color: var(--ink);
  font-weight: var(--weight-semibold);
  font-size: var(--text-md);
}

.state__body {
  max-width: 52ch;
  color: var(--ink-2);
}

.state .btn {
  margin-top: var(--space-2);
}

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

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

.skeleton {
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--surface-hover) 50%, var(--surface-sunken) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton--tile {
  height: 148px;
  border-radius: var(--radius-lg);
}

.skeleton--chart {
  height: 220px;
}

.skeleton--row {
  height: 32px;
}

.skeleton--line {
  height: 12px;
}

.skeleton--w0 {
  width: 90%;
}

.skeleton--w1 {
  width: 76%;
}

.skeleton--w2 {
  width: 64%;
}

.skeleton--w3 {
  width: 48%;
}

.skeleton-table,
.skeleton-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

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

.is-refreshing {
  opacity: 0.55;
  transition: opacity var(--duration-base) var(--ease);
  pointer-events: none;
}

/* ---- toast -------------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(380px, calc(100vw - 2 * var(--space-4)));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--duration-base) var(--ease);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 160ms var(--ease),
    transform 160ms var(--ease);
}

.toast__icon {
  margin-top: 1px;
}

.toast--ok .toast__icon {
  color: var(--sev-ok-fg);
}

.toast--info .toast__icon {
  color: var(--sev-info-fg);
}

.toast--warning .toast__icon {
  color: var(--sev-warning-fg);
}

.toast--error .toast__icon {
  color: var(--sev-error-fg);
}

.toast__text {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-weight: var(--weight-semibold);
}

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

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

/* ---- modal -------------------------------------------------------------------------------- */

.modal {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

.modal--lg {
  width: min(760px, calc(100vw - 32px));
}

.modal::backdrop {
  background: var(--overlay);
}

.modal__inner {
  display: flex;
  flex-direction: column;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-2) var(--space-5);
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.modal__body {
  padding: var(--space-2) var(--space-5) var(--space-4);
  color: var(--ink-2);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5) var(--space-4);
}

.modal__footer:empty {
  display: none;
}

/* ---- login -------------------------------------------------------------------------------- */

.login {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  background: var(--bg);
}

.login > .topbar {
  position: absolute;
  inset: 0 0 auto 0;
}

.login__intro {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: var(--space-8);
  padding: var(--space-10) clamp(1.5rem, 5vw, 4.5rem);
  background:
    radial-gradient(120% 80% at 0% 100%, color-mix(in srgb, var(--accent) 10%, transparent) 0%, transparent 60%),
    var(--surface-2);
  border-right: 1px solid var(--border);
}

.login__brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.login__brand .brand__name {
  font-size: var(--text-lg);
}

.login__pitch {
  position: relative;
  z-index: 1;
  max-width: 34rem;
}

/*
 * Sign-in illustration (web/img/login-hero*.webp, an imaginary coastal city): anchored to the
 * bottom of the intro panel, its empty sky cropped first, faded into the panel at the top so
 * the pitch above never sits on a hard edge. Decorative (alt="", aria-hidden).
 */
.login__hero {
  position: absolute;
  inset: auto 0 0 0;
  height: min(48%, 520px);
  pointer-events: none;
}

.login__hero img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 100%;
  filter: var(--hero-filter);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 30%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 30%);
}

.login__headline {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: var(--weight-semibold);
  line-height: 1.15;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.login__points {
  margin-top: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  color: var(--ink-2);
  font-size: var(--text-md);
}

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

.login__points .icon {
  margin-top: 2px;
  color: var(--accent);
}

.login__points strong {
  color: var(--ink);
  font-weight: var(--weight-semibold);
}

.login__legal {
  position: relative;
  z-index: 1;
  margin-top: auto;
  align-self: flex-start;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--ink-2);
  font-size: var(--text-xs);
}

.login__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-10) var(--gutter);
}

.login__card {
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.login__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}

.login__lead {
  color: var(--ink-2);
  margin-top: calc(-1 * var(--space-2));
}

.login__mock {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--sev-info-bg);
  color: var(--sev-info-fg);
  font-size: var(--text-xs);
}

.login__mock .icon {
  margin-top: 1px;
}

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

/* ---- home --------------------------------------------------------------------------------- */

.module-grid {
  margin-top: var(--space-4);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.module-card {
  height: 100%;
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
}

.module-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.module-card:focus-visible {
  border-radius: var(--radius-lg);
}

.module-card__icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
}

.module-card__text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
  min-width: 0;
}

.module-card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.module-card__body {
  color: var(--ink-2);
}

.module-card__go {
  color: var(--ink-3);
  align-self: center;
  transition: transform var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}

.module-card:hover .module-card__go {
  color: var(--accent);
  transform: translateX(2px);
}

.module-grid__empty {
  color: var(--ink-3);
}

.principles__grid {
  margin-top: var(--space-4);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.principle {
  display: flex;
  gap: var(--space-3);
}

.principle__icon {
  color: var(--accent);
  flex: none;
  margin-top: 1px;
}

.principle__title {
  font-weight: var(--weight-semibold);
}

.principle__body {
  color: var(--ink-2);
  font-size: var(--text-sm);
  margin-top: 2px;
}

/* ---- styleguide --------------------------------------------------------------------------- */

.sg-toc {
  position: sticky;
  top: calc(var(--header-h) + 4px);
  z-index: 10;
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  scrollbar-width: thin;
}

.sg-toc a {
  padding: 4px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  white-space: nowrap;
}

.sg-toc a:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.sg-sections {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.sg-section {
  scroll-margin-top: calc(var(--header-h) + 72px);
}

.sg-section__header {
  margin-bottom: var(--space-4);
}

.sg-section__lead {
  margin-top: var(--space-1);
  color: var(--ink-2);
  max-width: 80ch;
}

.sg-subtitle {
  margin-bottom: var(--space-3);
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.sg-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

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

.sg-row--fields {
  align-items: flex-end;
}

.sg-row--fields .field {
  width: 220px;
}

.swatch-group + .swatch-group {
  margin-top: var(--space-6);
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--space-3);
}

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

.swatch__chip {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 12%, transparent);
}

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

.swatch__label {
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
}

.swatch__token {
  padding: 0;
  background: none;
  color: var(--ink-3);
  font-size: var(--text-xs);
}

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

.type-specimen {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.sg-sparks {
  margin-top: var(--space-4);
}

.sg-spark {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
}

.sg-spark figcaption {
  color: var(--ink-3);
  font-size: var(--text-xs);
}

.states-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.states-grid__item {
  display: flex;
  flex-direction: column;
}

.states-grid__item .state {
  flex: 1;
  padding-block: var(--space-4);
}

/* ---- responsive --------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .chart-grid__cell--6,
  .chart-grid__cell--4,
  .chart-grid__cell--8 {
    grid-column: span 12;
  }
}

@media (max-width: 960px) {
  .user-menu__name {
    display: none;
  }

  .login {
    grid-template-columns: 1fr;
  }

  .login__intro {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding-block: var(--space-8);
    gap: var(--space-6);
  }

  .login__points {
    margin-top: var(--space-5);
  }

  .login__hero {
    position: relative;
    inset: auto;
    height: 160px;
    margin-inline: calc(-1 * clamp(1.5rem, 5vw, 4.5rem));
  }

  .login__legal {
    margin-top: 0;
  }

  .principles__grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

@media (max-width: 720px) {
  .app-header__inner {
    height: auto;
    flex-wrap: wrap;
    row-gap: 0;
    padding-top: var(--space-2);
  }

  .brand {
    order: 1;
    min-height: 40px;
  }

  .header-tools {
    order: 2;
    margin-left: auto;
  }

  .module-nav {
    order: 3;
    flex-basis: 100%;
    height: 44px;
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
  }

  .module-nav__list > li:first-child .module-nav__link {
    padding-left: 0;
  }

  .module-nav__list > li:first-child .module-nav__link[aria-current="page"]::after {
    left: 0;
  }

  .main {
    padding-block: var(--space-6) var(--space-10);
  }

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

  .page-title--xl {
    font-size: var(--text-2xl);
  }

  .filter-bar__fields .field--inline {
    width: calc(50% - var(--space-2));
  }

  .filter-bar__fields .segmented {
    width: 100%;
  }

  .segmented__options {
    display: flex;
  }

  .segmented__option {
    flex: 1;
  }

  .login__card {
    padding: var(--space-6) var(--space-5);
  }

  /* Phones: the form comes first; the illustration would push it below the fold. */
  .login__hero {
    display: none;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .sg-row--fields .field {
    width: 100%;
  }

  .data-table__tools {
    margin-left: 0;
  }
}

@media (max-width: 420px) {
  .filter-bar__fields .field--inline {
    width: 100%;
  }

  .grid--tiles {
    grid-template-columns: 1fr;
  }
}

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

@media (forced-colors: active) {
  .trust,
  .sev,
  .pill,
  .chip {
    border: 1px solid CanvasText;
  }
}
