/* ============================================================
   FONT
   ============================================================ */

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("/assets/nunito-latin-wght-normal-8d9cc785.woff2") format("woff2-variations");
}

/* ============================================================
   TOKENS
   Whitelabel rule: orgs override only the brand knobs below;
   every other tone derives from them via color-mix, so a single
   per-org --color-primary re-themes the whole app.
   ============================================================ */

:root {
  /* brand knobs (whitelabel overrides these) */
  --color-primary: #0e7490;
  --color-on-primary: #fff;
  --color-accent: #f59e0b; /* reserved for achievement moments */

  /* derived brand family */
  --color-primary-strong: color-mix(in oklab, var(--color-primary) 85%, black);
  --color-primary-soft: color-mix(in oklab, var(--color-primary) 12%, white);
  --color-primary-softer: color-mix(in oklab, var(--color-primary) 6%, white);
  --color-primary-border: color-mix(in oklab, var(--color-primary) 25%, white);
  --color-accent-soft: color-mix(in oklab, var(--color-accent) 15%, white);
  /* oklch keeps the sweep saturated (teal -> gold) */
  --gradient-celebrate: linear-gradient(
    135deg in oklch,
    var(--color-primary),
    var(--color-accent)
  );

  /* warm neutrals */
  --color-bg: #fffbf5;
  --color-surface: #fff;
  --color-text: #233940; /* faint teal tint, same lightness as before */
  /* 66% clears WCAG AA 4.5:1 on both cream (--color-bg) and white surfaces for normal-size text */
  --color-muted: color-mix(in oklab, var(--color-text) 66%, var(--color-bg));
  --color-border: color-mix(in oklab, var(--color-text) 12%, var(--color-bg));

  /* semantic, independent of brand */
  --color-success: #15803d;
  --color-success-soft: color-mix(in oklab, var(--color-success) 12%, white);
  --color-danger: #b91c1c;
  --color-danger-soft: color-mix(in oklab, var(--color-danger) 10%, white);
  --color-warning: #854d0e;
  --color-warning-soft: color-mix(in oklab, var(--color-accent) 18%, white);

  /* shape */
  --radius-card: 1rem;
  --radius-control: 0.75rem;
  --radius-pill: 999px;

  /* soft primary-tinted elevation */
  --shadow-card:
    0 1px 3px color-mix(in oklab, var(--color-primary) 8%, transparent),
    0 4px 16px color-mix(in oklab, var(--color-primary) 7%, transparent);
  --shadow-lift: 0 8px 24px color-mix(in oklab, var(--color-primary) 20%, transparent);

  /* type & spacing */
  --font-sans: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.5rem;
  --text-display: 1.875rem;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;

  /* motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --transition-quick: 150ms ease;
}

/* ============================================================
   BASE
   ============================================================ */

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1rem 1rem;
  line-height: 1.5;
  /* Sticky footer: fill the viewport so .app-footer rests at the bottom on
     short pages and flows after content on long ones. calc keeps content-box
     sizing — the 1rem bottom padding stays outside the height, so no overflow. */
  min-height: calc(100dvh - 1rem);
  display: flex;
  flex-direction: column;
}

/* Grows to absorb free space, pushing the footer down on short pages. */
.app-main { flex: 1 0 auto; }
/* The footer brings its own top margin, so a trailing section margin only
   doubles the gap. */
.app-main > :last-child { margin-bottom: 0; }

h1 {
  font-size: var(--text-display);
  font-weight: 800;
  line-height: 1.2;
}

::selection {
  background: var(--color-primary-soft);
}

a {
  color: var(--color-primary);
}

input[type="checkbox"] {
  accent-color: var(--color-primary);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in oklab, var(--color-primary) 30%, transparent);
  outline-offset: 2px;
}

/* ============================================================
   NAV
   ============================================================ */

.main-nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-lg);
}

.main-nav a { text-decoration: none; }

.main-nav__brand {
  display: inline-flex;
  align-items: center;
  min-width: 0; /* allow the name to truncate instead of overflowing the nav */
  max-width: min(18rem, 42vw);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.01em;
}
.main-nav__brand:hover { color: var(--color-primary-strong); }
/* Long org names collapse to one line with an ellipsis; the full name lives in the link's title. */
.main-nav__brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-nav__logo { display: block; height: 32px; width: auto; max-width: 180px; object-fit: contain; }

.main-nav__links { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-xs); }
.main-nav__links > a,
.main-nav__menu-toggle {
  color: color-mix(in oklab, var(--color-text) 80%, var(--color-bg));
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  transition: color var(--transition-quick), background var(--transition-quick);
}
.main-nav__links > a:hover,
.main-nav__menu-toggle:hover,
.main-nav__menu-toggle[aria-expanded="true"] { color: var(--color-primary); background: var(--color-primary-softer); }
.main-nav__links > a[aria-current="page"] {
  color: var(--color-primary);
  background: var(--color-primary-soft);
  font-weight: 700;
}

/* Admin config actions grouped under a "Manage" disclosure (reuses the
   profile-menu Stimulus controller) so the strip stays within ~5 items. */
.main-nav__menu { position: relative; display: flex; }
.main-nav__menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}
.main-nav__menu-chevron { width: 0.85em; height: 0.85em; transition: transform var(--transition-quick); }
.main-nav__menu-toggle[aria-expanded="true"] .main-nav__menu-chevron { transform: rotate(180deg); }
.main-nav__menu-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 0.5rem);
  min-width: 12rem;
  max-width: calc(100vw - 2rem);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-lift);
  z-index: 100;
  padding: var(--space-sm) 0;
  overflow: hidden; /* clip item hover fills to the rounded corners */
}
.main-nav__menu-panel:not([hidden]) {
  transform-origin: top left;
  animation: popover-in 150ms var(--ease-out);
}
.main-nav__menu-panel a {
  display: flex;
  align-items: center;
  box-sizing: border-box; /* fold padding into min-height, matching profile-popover__item */
  min-height: 44px;
  padding: 0.5rem var(--space-md);
  color: var(--color-text);
  font-weight: 600;
  white-space: nowrap;
}
.main-nav__menu-panel a:hover,
.main-nav__menu-panel a[aria-current="page"] {
  color: var(--color-primary);
  background: var(--color-primary-softer);
}

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.locale-switch { display: flex; gap: 0.35rem; }
.link-button--active { color: var(--color-primary); font-weight: 700; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-muted);
  cursor: pointer;
  font: inherit;
}
.link-button:hover { color: var(--color-primary); }

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

.button,
.actions input[type="submit"] {
  --button-bg: var(--color-primary);
  display: inline-block;
  background: var(--button-bg);
  color: var(--color-on-primary) !important;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  box-shadow: 0 4px 12px color-mix(in oklab, var(--button-bg) 30%, transparent);
  transition:
    background var(--transition-quick),
    box-shadow var(--transition-quick),
    transform var(--transition-quick);
}
.button:hover,
.actions input[type="submit"]:hover {
  background: color-mix(in oklab, var(--button-bg) 85%, black);
  box-shadow: 0 8px 20px color-mix(in oklab, var(--button-bg) 35%, transparent);
  transform: translateY(-1px);
}
.button:active,
.actions input[type="submit"]:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px color-mix(in oklab, var(--button-bg) 30%, transparent);
}
.button:disabled,
.button:disabled:hover,
.actions input[type="submit"]:disabled,
.actions input[type="submit"]:disabled:hover {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  background: var(--button-bg);
  box-shadow: none;
}

.button--approve { --button-bg: var(--color-success); }
.button--reject { --button-bg: var(--color-danger); }
.button--danger { --button-bg: var(--color-danger); }
.button--sm { padding: 0.3rem 0.9rem; font-size: var(--text-sm); }

.invitation-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

.table-wrap {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 1rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }

/* Right-aligned, inline row actions (e.g. Edit + Archive on the rewards table). */
.table-actions { display: flex; gap: var(--space-sm); justify-content: flex-end; align-items: center; }
.table-actions form { margin: 0; }

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

/* Collapsible list of a reward's price tiers. */
.tier-list > summary {
  cursor: pointer;
  color: var(--color-primary);
  font-weight: 600;
  width: fit-content;
}
.tier-list__items { margin: 0.5rem 0 0; padding-left: 1.1rem; color: var(--color-muted); }
.tier-list__items li { margin: 0.15rem 0; }
th {
  color: var(--color-muted);
  font-weight: 800;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody tr { transition: background var(--transition-quick); }
tbody tr:hover { background: var(--color-primary-softer); }
tbody tr:last-child th,
tbody tr:last-child td { border-bottom: none; }

.field { margin-bottom: var(--space-md); max-width: 28rem; }
.field:has(.autocomplete-results) { position: relative; }
.field label { display: block; font-weight: 700; margin-bottom: var(--space-xs); }
.field p { margin: 0 0 var(--space-xs); } /* devise wraps fields in <p> */
.logo-preview { display: block; height: 48px; width: auto; max-width: 200px; object-fit: contain; margin-bottom: var(--space-xs); }

.autocomplete-results {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  max-height: 14rem;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  /* Lift + card radius to match .emoji-popover, the other popover in this same
     form. Without elevation the list reads as one more field rather than a
     temporary overlay sitting on top of the one it covers. */
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lift);
}
/* Scope display to the visible state so the `hidden` attribute still hides the
   frame (a bare `display: block` would override [hidden] and it'd never close). */
.autocomplete-results:not([hidden]) { display: block; }

/* While Turbo loads the next set, the visible rows are stale — ignore clicks on
   them until the fresh set lands. The field spinner is the loading cue; the list
   itself stays crisp (no dim) to keep text legible and avoid a per-keystroke flicker. */
.autocomplete-results[busy] { pointer-events: none; }

.autocomplete-results [role="option"],
.autocomplete-results__note { padding: 0.5rem 0.75rem; }
.autocomplete-results [role="option"] { cursor: pointer; }
.autocomplete-results__note { margin: 0; color: var(--color-muted); }

.autocomplete-results__create { color: var(--color-primary); font-weight: 700; }

.autocomplete-results [role="option"]:hover,
.autocomplete-results [role="option"][aria-selected="true"] {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

@media (pointer: coarse) {
  .autocomplete-results [role="option"] { min-height: 44px; display: flex; align-items: center; }
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="email"],
.field input[type="password"],
.field select,
.field textarea,
.inline-form input[type="email"],
.inline-form select {
  box-sizing: border-box;
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: inherit;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  transition: border-color var(--transition-quick);
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="email"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-form input:focus,
.inline-form select:focus {
  border-color: var(--color-primary);
}

#metric_search_input::placeholder { color: var(--color-muted); }

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

/* flex-start, not center: a label that wraps to two lines otherwise floats the
   box to the vertical middle instead of aligning with its first line. */
.field--checkbox { display: flex; align-items: flex-start; gap: 0.5rem; min-height: 2.75rem; }
/* The label toggles the box, so the row is the real tap target — min-height
   above brings it to 44px. The native 13px box is nudged up to match the text. */
.field--checkbox label { margin-bottom: 0; font-weight: 400; padding: 0.65rem 0; }
.field--checkbox input[type="checkbox"] { flex: none; width: 1.1rem; height: 1.1rem; margin-top: 0.85rem; }

/* The box is the input; the number fills it and the unit sits inside as a suffix. */
.input-with-unit {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  box-sizing: border-box;
  padding: 0.6rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  transition: border-color var(--transition-quick);
}
.input-with-unit:focus-within { border-color: var(--color-primary); }
.input-with-unit:has(input:focus-visible) {
  outline: 3px solid color-mix(in oklab, var(--color-primary) 30%, transparent);
  outline-offset: 2px;
}
.input-with-unit input[type="number"] {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.input-with-unit input[type="number"]:focus-visible { outline: none; }
.unit-hint { font-size: var(--text-sm); color: var(--color-muted); white-space: nowrap; }

/* Hide the native number spinner; keyboard up/down still steps by 1. */
.field input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.chevron { display: block; }
.combobox-control { position: relative; }
.combobox-control input[type="text"] { padding-right: 2.25rem; }
.combobox-chevron {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--color-muted);
}
.combobox-chevron .chevron { width: 14px; height: 14px; }

/* Loading spinner shares the chevron's spot, shown only while Turbo is loading
   the results frame ([busy]); the chevron hides while it spins. */
.combobox-spinner { display: none; }
.field:has(.autocomplete-results[busy]) .combobox-spinner {
  display: block;
  position: absolute;
  top: 50%;
  right: 0.75rem;
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in oklab, var(--color-muted) 35%, transparent);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  transform: translateY(-50%);
  animation: spin 0.6s linear infinite;
}
.field:has(.autocomplete-results[busy]) .combobox-chevron { display: none; }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .combobox-spinner { animation: none; }
}

.emoji-trigger {
  width: 3rem;
  height: 3rem;
  font-size: 1.5rem;
  border: 2px solid var(--color-primary-border);
  border-radius: var(--radius-control);
  background: var(--color-primary-softer);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color var(--transition-quick), background var(--transition-quick);
}
.emoji-trigger:hover { background: var(--color-primary-soft); border-color: var(--color-primary); }
.emoji-trigger:focus-visible { outline: 3px solid color-mix(in oklab, var(--color-primary) 30%, transparent); }

.emoji-popover {
  position: absolute;
  z-index: 100;
  margin-top: var(--space-xs);
  box-shadow: var(--shadow-lift);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.field:has(.emoji-popover) { position: relative; }

.actions { display: flex; align-items: center; gap: 1rem; margin-top: var(--space-lg); }

.form-errors,
#error_explanation {
  background: var(--color-danger-soft);
  border-radius: var(--radius-control);
  padding: 1rem 1.25rem;
  margin-bottom: var(--space-md);
  color: var(--color-danger);
}
.form-errors p,
#error_explanation h2 { margin: 0 0 0.5rem; font-weight: 700; font-size: var(--text-base); }
.form-errors ul,
#error_explanation ul { margin: 0; padding-left: 1.25rem; }
/* Match .field, so the summary never spans wider than the fields it describes. */
.form-errors { max-width: 28rem; }
.form-errors a { color: inherit; }

.flash {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-control);
  margin-bottom: var(--space-md);
  font-weight: 600;
  animation: slide-in 400ms var(--ease-out);
}
.flash--notice { background: var(--color-success-soft); color: var(--color-success); }
.flash--alert { background: var(--color-danger-soft); color: var(--color-danger); }

.empty-state {
  color: var(--color-muted);
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  border: 1.5px dashed var(--color-primary-border);
  border-radius: var(--radius-card);
}

.status {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 700;
}
.status--pending { background: var(--color-warning-soft); color: var(--color-warning); }
.status--approved { background: var(--color-success-soft); color: var(--color-success); }
.status--rejected { background: var(--color-danger-soft); color: var(--color-danger); }

.inline-form { display: flex; gap: 0.5rem; align-items: center; max-width: 36rem; }
.inline-form input[type="email"] { flex: 1; }

/* ============================================================
   SCREENS
   ============================================================ */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* the nav's own bottom margin already separates it from above */
  margin: -0.35rem 0 0.9rem;
}

.review-actions__buttons { display: flex; gap: 0.5rem; }
.review-actions .button { padding: 0.3rem 0.9rem; font-size: var(--text-sm); }
.review-actions .button:disabled { opacity: 0.5; cursor: not-allowed; }

.dashboard-section { margin-bottom: 2rem; }
.dashboard-section h2 { font-size: var(--text-lg); margin-bottom: 0.75rem; }

/* Subscription: one stateful billing panel (choose -> subscribe / active -> cancel),
   not a pricing-card grid — there is a single plan. */
.subscription__panel {
  max-width: 30rem;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
}
.subscription__lead { margin: 0 0 var(--space-md); color: var(--color-muted); }
.subscription__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}
.subscription__plan-name { margin: 0; font-size: var(--text-xl); font-weight: 800; }
.subscription__price {
  margin: var(--space-sm) 0 0;
  font-size: var(--text-display);
  font-weight: 800;
  line-height: 1.1;
}
.subscription__cadence { margin-left: 0.25rem; font-size: var(--text-base); font-weight: 600; color: var(--color-muted); }
.subscription__points { margin: var(--space-xs) 0 0; color: var(--color-muted); }
.subscription__unlocks { margin: var(--space-md) 0 0; color: var(--color-text); }
.subscription__note {
  margin: var(--space-md) 0 0;
  padding: 0.6rem 0.85rem;
  background: var(--color-primary-softer);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-control);
  font-size: var(--text-sm);
  color: var(--color-text);
}
.subscription__actions { margin-top: var(--space-lg); }

/* Styled confirm dialog: one shared instance wired into Turbo's global confirm
   hook by the `confirm` controller, so every turbo_confirm site uses it. */
.confirm-dialog {
  margin: auto;
  /* Optical center: sit slightly above true center — dead-center reads a touch low.
     Shrinking the bottom inset shifts the auto-margined dialog up ~5vh. */
  inset-block: 0 10vh;
  max-width: 24rem;
  width: calc(100vw - 2rem);
  padding: var(--space-lg);
  border: none;
  border-radius: var(--radius-card);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-lift);
}
.confirm-dialog::backdrop { background: color-mix(in oklab, var(--color-text) 45%, transparent); }
.confirm-dialog__title { margin: 0 0 var(--space-sm); font-size: var(--text-lg); font-weight: 800; }
.confirm-dialog__message { margin: 0 0 var(--space-lg); }
.confirm-dialog__actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); justify-content: flex-end; }
.confirm-dialog__actions .button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Narrow screens: stack full-width with the safe action (DOM-last) at the bottom/thumb. */
@media (max-width: 480px) {
  .confirm-dialog__actions { flex-direction: column; }
  .confirm-dialog__actions .button { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .confirm-dialog[open] { animation: popover-in 150ms var(--ease-out); }
  .confirm-dialog[open]::backdrop { animation: backdrop-fade 150ms var(--ease-out); }
}
@keyframes backdrop-fade { from { opacity: 0; } }

.award-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
}

.progress-bar {
  height: 0.625rem;
  background: var(--color-primary-softer);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-bar__fill {
  /* explicit: the goal chip renders the fill as a span, and an inline box
     ignores width/height — the bar would read empty at every percentage */
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  animation: progress-grow 700ms var(--ease-out);
}

.award-card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-quick), box-shadow var(--transition-quick);
}
.award-card__icon {
  font-size: 2rem;
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  margin: 0 auto;
  background: var(--color-accent-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.award-card__name { margin: 0.5rem 0 0.25rem; font-weight: 700; }
.award-card__period { margin: 0; font-size: 0.8rem; color: var(--color-muted); }

/* Recently-earned trophies carry the celebrate frame — the recognition peak,
   now living in the one canonical surface (the removed "Concluídas" cards). */
.award-card--recent {
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
    var(--gradient-celebrate) border-box;
}
/* The icon keeps --color-accent-soft in both states; the celebrate treatment
   lives on the border above. A generated icon is a full-bleed illustration with
   its own rim light and shadow tones, so a saturated gradient behind it competes
   with the artwork — and contradicts the "light background" premise the image
   prompt is written against (BadgeIcons::Generate::LEGIBILITY). */
/* Shine sweep fires when the trophy scrolls into view (the reveal controller
   adds .is-revealed), so it lands when seen — not wasted at load below the fold. */
@media (prefers-reduced-motion: no-preference) {
  .award-card--recent.is-revealed::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgb(255 255 255 / 60%) 50%, transparent 60%);
    transform: translateX(-100%);
    animation: shine 1.2s var(--ease-out) forwards;
    pointer-events: none;
  }
}

.award-card {
  animation: fade-up 500ms var(--ease-out) backwards;
}
.award-card:nth-child(2) { animation-delay: 60ms; }
.award-card:nth-child(3) { animation-delay: 120ms; }
.award-card:nth-child(4) { animation-delay: 180ms; }
.award-card:nth-child(n + 5) { animation-delay: 240ms; }

/* Rewards: mocked gift-card catalog + spendable balance */
.reward-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}
.reward-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-quick), box-shadow var(--transition-quick);
}
.reward-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.reward-card__thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-control);
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  background: color-mix(in oklab, var(--color-muted) 8%, var(--color-surface));
}
.reward-card__thumb svg { width: 2.5rem; height: 2.5rem; opacity: 0.55; }
.reward-card__thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.reward-card__name { margin: 0; font-weight: 700; }

/* Reward thumbnail in the admin table and form preview. */
.reward-thumb {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: cover;
  border-radius: var(--radius-control);
  vertical-align: middle;
}
.reward-thumb--preview { width: 8rem; height: 4.5rem; display: block; margin-bottom: 0.5rem; }
.reward-name-cell { display: flex; align-items: center; gap: 0.5rem; }

/* Nested tier rows in the reward form. */
.reward-tiers { border: 1px solid var(--color-border); border-radius: var(--radius-control); padding: 1rem; margin: 1rem 0; }
.reward-tiers legend { padding: 0 0.5rem; font-weight: 600; }
.reward-tier-row { display: flex; align-items: flex-end; gap: 0.75rem; margin-bottom: 0.75rem; }
.reward-tier-row .field { margin: 0; }
.reward-tier-row__remove { flex: none; }

/* Coupon codes added to the reward form (created/removed before save). */
.reward-coupons { border: 1px solid var(--color-border); border-radius: var(--radius-control); padding: 1rem; margin: 1rem 0; }
.reward-coupons legend { padding: 0 0.5rem; font-weight: 600; }
.reward-coupons__count { font-weight: 600; }
.reward-coupon-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.reward-coupon-row__code { flex: 1; }
.reward-coupon-row__remove { flex: none; }
.reward-coupons__add { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.reward-coupons__list { columns: 4 12rem; margin: 0.5rem 0 0; padding-left: 1.1rem; }
.reward-coupons__list li { margin: 0.15rem 0; }
.reward-card__form { display: flex; flex-direction: column; gap: 0.5rem; margin-top: auto; }
.reward-card__label { font-size: var(--text-sm); color: var(--color-muted); }

.reward-card--balance {
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-strong));
  align-items: center;
  justify-content: center;
  text-align: center;
}
.reward-balance__points { margin: 0; font-size: 3rem; font-weight: 800; line-height: 1; }
.reward-balance__label { margin: 0.25rem 0 0.75rem; font-weight: 600; }
.reward-balance__link { color: #fff; font-weight: 700; text-decoration: underline; }

/* The card owns the surface, so the heading and the full-bleed "show more" band
   sit on it rather than floating over the page background. */
.feed-card {
  padding: 1.1rem 1.25rem 0;
  margin-bottom: 2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  /* the full-bleed "show more" band ends on the card's own rounded corner */
  overflow: hidden;
}
.feed { list-style: none; padding: 0; margin: 0 0 1.25rem; }
/* the trailing band supplies its own edge, so the list stops short of it */
.feed:has(.feed__more) { margin-bottom: 0; }
/* Rows page in through nested frames; display:contents lets each page's <li>s
   flow into the single .feed list instead of nesting a block inside it. */
.feed turbo-frame { display: contents; }
.feed__item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--color-border);
}
.feed__item:last-child { border-bottom: none; }
.feed__head { display: flex; align-items: center; gap: 0.65rem; }
/* Bigger than the roster's .avatar--md: the feed row is the one place a person
   is the subject of the sentence rather than a cell in a table. */
.feed__head .avatar { width: 2.35rem; height: 2.35rem; font-size: 0.8rem; }
.feed__text { min-width: 0; }
.feed__text b { font-weight: 800; }
/* the rare thing, tinted with the accent the app reserves for achievement */
.feed__badge { font-weight: 800; color: var(--color-warning); white-space: nowrap; }
.feed__amount { font-weight: 800; color: var(--color-primary-strong); font-variant-numeric: tabular-nums; }
.feed__kind {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.02rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--color-accent-soft);
  color: var(--color-warning);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: 0.1em;
}
.feed__date {
  margin-left: auto;
  align-self: flex-start;
  text-align: right;
  font-size: 0.8rem;
  color: var(--color-muted);
  white-space: nowrap;
}
.feed__occurred { display: block; font-size: 0.72rem; opacity: 0.85; }
.feed__note {
  margin: 0.5rem 0 0 3rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg);
  border-radius: var(--radius-control);
  font-size: var(--text-sm);
}
/* Closes the card as a full-width band: negative inline margins cancel the
   card's padding so the border-top reaches both edges. */
.feed__more { margin: 0 -1.25rem; border-top: 1px solid var(--color-border); }
.feed__more .load-more {
  display: block;
  box-sizing: border-box; /* width:100% must absorb the padding below */
  width: 100%;
  margin: 0;
  padding: 0.85rem;
  text-align: center;
}
.feed__more .load-more:hover { background: var(--color-primary-softer); }
/* leaderboard pager: prev / status / next on one centered row */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
}
.pagination__status { font-size: var(--text-sm); color: var(--color-muted); }
.feed-empty { margin: 0 0 1.25rem; color: var(--color-muted); text-align: center; padding: var(--space-lg) var(--space-md); }
.feed-empty__link {
  display: inline-block;
  margin-top: var(--space-xs);
  font-weight: 700;
  color: var(--color-primary);
}

/* ---- Member dashboard: where you stand, then what's left to do ---- */
.page-header__lead { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
/* The divider between summary and goals is the goals section's own top border,
   so an empty summary never leaves a stray rule. */
.dashboard-panel {
  padding: 1.1rem 1.25rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  margin-bottom: 2rem;
}
.dashboard-panel .goals { margin: 1.25rem 0 0; padding-top: 1.1rem; border-top: 1px solid var(--color-border); }
.dashboard-panel .goals__head { margin-bottom: 0.65rem; }
.dashboard-panel .goals h2 { font-size: var(--text-lg); font-weight: 800; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.75rem;
  margin-bottom: 0.75rem;
}
.section-head h2 { margin: 0; font-size: var(--text-xl); font-weight: 800; }

.page-header__cycle { margin: 0; color: var(--color-muted); font-size: var(--text-sm); font-weight: 600; }

/* Tiles with a destination render as links, hence the a.stat hover below. */
.summary__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.6rem;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.7rem 0.85rem;
  background: var(--color-primary-softer);
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  text-decoration: none;
  color: var(--color-text);
  transition: transform var(--transition-quick), box-shadow var(--transition-quick), border-color var(--transition-quick);
}
a.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--color-primary-border); }
.stat__label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.stat__value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  /* digits line up across the tiles */
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat__value small { font-size: 0.85rem; font-weight: 700; color: var(--color-muted); letter-spacing: 0; }
.stat__meta { font-size: 0.78rem; color: var(--color-muted); font-weight: 600; }
.stat--accent .stat__value { color: var(--color-primary-strong); }
.stat__pill {
  align-self: flex-start;
  margin-top: 0.1rem;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.05rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--color-accent-soft);
  color: var(--color-warning);
}

.alert-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.6rem 0 0;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-control);
  background: var(--color-warning-soft);
  border: 1px solid color-mix(in oklab, var(--color-accent) 40%, white);
  color: var(--color-warning);
  font-weight: 700;
  font-size: var(--text-sm);
}
.alert-row .icon-monoline { width: 1.1rem; height: 1.1rem; flex: none; }
.alert-row a { margin-left: auto; color: var(--color-warning); font-weight: 800; white-space: nowrap; }

/* Badge icons: an emoji or a generated image (BadgeIcons::Generate) share these
   slots, so every slot clips to its own shape. OpenAI gives us a transparent PNG,
   but Gemini can't — overflow:hidden means an opaque image still reads as a
   deliberate crop instead of a square poking out of a pill. */
.badge-icon-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.badge-row__icon,
.feed__badge-icon,
.goal-chip__icon {
  flex: none;
  align-self: center;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  vertical-align: middle;
}

/* The badge form's icon controls on one line: generated preview, emoji trigger,
   generate button. Wraps on narrow screens rather than overflowing. */
.icon-field__row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  min-height: 3.5rem;
}

/* The Turbo broadcast target, so the generated image lands here without a
   reload. */
.badge-icon-preview {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.badge-icon-preview__slot {
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  font-size: 1.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.badge-icon-preview__error { color: var(--color-danger); font-size: var(--text-sm); }

/* Fills the icon slot while the job runs, so the shape holds and only its
   contents change. Its own keyframe: the combobox spinner's `spin` bakes in a
   translateY for vertical centring that would knock this one off-centre. */
.badge-icon-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid color-mix(in oklab, var(--color-muted) 35%, transparent);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: badge-icon-spin 0.6s linear infinite;
}
@keyframes badge-icon-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  /* Static ring; the disabled button and the sr-only label still report state. */
  .badge-icon-spinner { animation: none; }
}
/* Filter menu + section head */
.goals__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}
.goals__head h2 { margin: 0; }
.goals__title { min-width: 0; }
/* CSS-only period filter: visually-hidden radios + <label> chips. :has() hides
   the group that isn't selected — instant, no controller, no round-trip. */
/* align-items:center so a chip keeps its own slim height instead of stretching
   to the header row */
.goal-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0; padding: 0; border: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem; /* slim pill; wide enough tap target with the padding */
  line-height: 1.2;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition-quick), border-color var(--transition-quick), color var(--transition-quick);
}
.chip:hover { border-color: var(--color-primary-border); }
/* the radio precedes its label, so :checked styles the chip; the radio is
   sr-only, so mirror its focus ring onto the chip for keyboard users */
.goal-filter input:checked + .chip {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-on-primary);
}
.goal-filter input:focus-visible + .chip { outline: 2px solid var(--color-primary-strong); outline-offset: 2px; }
.goals:has(#gf-weekly:checked) .goal-chip:not([data-period="weekly"]),
.goals:has(#gf-monthly:checked) .goal-chip:not([data-period="monthly"]),
.goals:has(#gf-milestone:checked) .goal-chip:not([data-period="milestone"]) { display: none; }
.goals__hint {
  margin: 0.2rem 0 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}
/* Shown when every goal this period is already met, in place of the chip strip. */
.goals__all-done {
  margin: 0;
  padding: var(--space-lg);
  text-align: center;
  font-weight: 700;
  color: var(--color-primary-strong);
  background: var(--color-primary-softer);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-card);
}

/* The strip wraps rather than scrolling on purpose — inside an overflow-x
   scroller the browser computes overflow-y to auto and clips the detail panel. */
.goal-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.goal-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem 0.4rem 0.4rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: var(--color-text);
  transition: transform var(--transition-quick), border-color var(--transition-quick), box-shadow var(--transition-quick);
}
.goal-chip:hover { transform: translateY(-2px); border-color: var(--color-primary-border); box-shadow: var(--shadow-lift); }
.goal-chip__icon {
  background: var(--color-primary-softer);
  border-radius: var(--radius-pill);
  width: 1.9rem;
  height: 1.9rem;
  font-size: 1.05rem;
}
.goal-chip .progress-bar { width: 3.25rem; height: 0.4rem; flex: none; }
.goal-chip__percent {
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--color-primary-strong);
  min-width: 2.3rem;
  text-align: right;
}

/* The panel carries the chip's whole accessible name, so it is never
   display:none — it is transparent and untargetable until revealed. */
.goal-chip__detail {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  transform: translate(-50%, 4px);
  width: max-content;
  max-width: 15rem;
  padding: 0.6rem 0.8rem;
  background: var(--color-text);
  color: var(--color-bg);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-lift);
  font-size: var(--text-sm);
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-quick), transform var(--transition-quick);
  z-index: 5;
}
.goal-chip:hover .goal-chip__detail,
.goal-chip:focus-visible .goal-chip__detail { opacity: 1; transform: translate(-50%, 0); }
.goal-chip__detail b { display: block; font-weight: 800; }
.goal-chip__detail span { display: block; color: color-mix(in oklab, var(--color-bg) 75%, var(--color-text)); }
.goal-chip__detail em { font-style: normal; color: var(--color-accent); font-weight: 700; }

/* "load more" is a grid item on its own full-width row below the cards;
   click-driven (not scroll), so the list grows only on demand, never underfoot */
.load-more {
  grid-column: 1 / -1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: var(--space-sm);
  font-weight: 700;
  color: var(--color-primary);
}
.load-more:hover { color: var(--color-primary-strong); }
/* Insignias — the recognition payoff, given its own elevated surface and the
   page's closing position so a member ends on their own trophies. */
.insignias {
  background: var(--color-primary-softer);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
}
.insignias__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: var(--space-md);
}
.insignias__head h2 { margin: 0; font-size: var(--text-xl); }
/* offset so the teaser's jump-to-showcase clears the top edge comfortably */
#badges { scroll-margin-top: 1rem; }
/* Showcase pages flow into the one .award-grid via display:contents frames. */
.insignias turbo-frame { display: contents; }

/* Smooth in-page jumps (e.g. the badge teaser -> showcase), motion-safe only. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Mobile: keep the primary action in the thumb zone while scrolling. */
.checkin-fab { display: none; }
@media (max-width: 640px) {
  .checkin-fab {
    display: inline-flex;
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    z-index: 20;
    box-shadow: var(--shadow-lift);
  }
  .page-header .button { display: none; } /* the FAB is the CTA on mobile */
  body { padding-bottom: 5rem; } /* clear the floating CTA */
}

.invitation-page {
  max-width: 32rem;
  margin: 3rem auto;
  text-align: center;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-xl) var(--space-lg);
}
.invitation-page .actions { justify-content: center; }

.auth-page { max-width: 26rem; margin: 3rem auto 0; }

.auth-brand { text-align: center; margin-bottom: var(--space-lg); }
.auth-brand__name {
  margin: var(--space-sm) 0 0;
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.01em;
}
.auth-brand__tagline { margin: 0; color: var(--color-muted); }

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  animation: fade-up 500ms var(--ease-out) backwards;
}
.auth-card h2 { margin: 0 0 var(--space-md); font-size: var(--text-xl); font-weight: 800; }
.auth-card .field { max-width: none; }
.auth-card .actions { margin-top: var(--space-md); }
.auth-card .actions input[type="submit"] { width: 100%; }

.auth-card__links {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  font-size: var(--text-sm);
}
.auth-card__links p { margin: 0; }

/* space-sm, not xs: the focus ring is 3px at 2px offset, so a 4px gap put the
   ring through the top of the hint text. */
.field__hint { margin: var(--space-sm) 0 0; font-size: var(--text-sm); color: var(--color-muted); }

.password-field { position: relative; }
.password-field input[type="password"],
.password-field input[type="text"] { padding-right: 3rem; }
.password-field__toggle {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.3rem;
  border-radius: var(--radius-pill);
}
.password-field__toggle:hover { background: var(--color-primary-softer); }

/* ============================================================
   LANDING (public marketing page)
   The body shell is sized for product screens; the landing runs
   full-bleed sections with its own container. Its responsive
   rules live here too — they don't apply to app screens.
   ============================================================ */

body:has(.landing) { max-width: none; padding: 0; }
body:has(.landing) .flash { max-width: min(60rem, calc(100% - 2rem)); margin: var(--space-md) auto; }
html:has(.landing) { scroll-behavior: smooth; }

.landing__container { max-width: 68rem; margin-inline: auto; padding-inline: 1.25rem; }

.landing section[id] { scroll-margin-top: 4.5rem; /* clear the sticky nav */ }

.landing-section { padding-block: clamp(3rem, 7vw, 5rem); }
.landing-section--alt { background: var(--color-surface); }
.landing-section--tint {
  background: var(--color-primary-softer);
  /* muted text needs a touch more ink to clear AA 4.5:1 on the tint
     (the base --color-muted is validated only against cream and white). */
  --color-muted: color-mix(in oklab, var(--color-text) 72%, var(--color-bg));
}

.landing-section__title {
  margin: 0 0 var(--space-md);
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.landing-section__title--center { text-align: center; margin-bottom: var(--space-xl); }

.landing-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}
.landing-nav__inner { display: flex; align-items: center; gap: var(--space-lg); padding-block: 0.7rem; }
.landing-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.landing-nav__links { display: flex; gap: var(--space-xs); }
.landing-nav__links a {
  color: var(--color-muted);
  font-weight: 600;
  text-decoration: none;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-pill);
  transition: color var(--transition-quick), background var(--transition-quick);
}
.landing-nav__links a:hover { color: var(--color-primary); background: var(--color-primary-softer); }
.landing-nav__actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-md); }
.landing-nav__locales { display: flex; gap: 0.35rem; }
.landing-nav__locales a { text-decoration: none; }
.landing-nav__signin { color: var(--color-text); font-weight: 700; text-decoration: none; }
.landing-nav__signin:hover { color: var(--color-primary); }

.landing-hero { overflow: hidden; /* confetti stays inside */ }
.landing-hero__inner {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-xl);
  align-items: center;
  padding-block: clamp(3.5rem, 8vw, 6rem);
}
.landing-hero__title {
  margin: 0;
  font-size: clamp(2.1rem, 4.5vw, 3.1rem);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.landing-hero__subtitle { margin: var(--space-md) 0 0; font-size: var(--text-lg); color: var(--color-muted); max-width: 34rem; }
.landing-hero__ctas { margin-top: var(--space-lg); display: flex; align-items: center; gap: var(--space-lg); flex-wrap: wrap; }
.landing-hero__secondary { font-weight: 700; text-decoration: none; }
.landing-hero__secondary:hover { text-decoration: underline; }

.button--lg { padding: 0.8rem 1.75rem; font-size: var(--text-lg); }
.button--inverse { --button-bg: #fff; color: var(--color-primary) !important; }

.hero-badge {
  position: relative;
  max-width: 19rem;
  margin-inline: auto;
  text-align: center;
  background: var(--color-surface);
  border: 2px solid transparent;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
}
.hero-badge.is-achieved {
  background:
    linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
    var(--gradient-celebrate) border-box;
  box-shadow: var(--shadow-lift);
}
.hero-badge__dial { position: relative; width: 10rem; margin-inline: auto; }
.hero-badge__ring { display: block; width: 100%; transform: rotate(-90deg); }
.hero-badge__track,
.hero-badge__fill { fill: none; stroke-width: 9; }
.hero-badge__track { stroke: var(--color-primary-softer); }
.hero-badge__fill {
  stroke: url("#hero-ring-gradient");
  stroke-linecap: round;
  /* r=52 → circumference ≈ 326.7; the 13% offset is the stretch left to the goal */
  stroke-dasharray: 326.7;
  stroke-dashoffset: 42.5;
  transition: stroke-dashoffset 1100ms var(--ease-out);
}
.hero-badge.is-achieved .hero-badge__fill { stroke-dashoffset: 0; }
.hero-badge__icon { position: absolute; inset: 0; display: grid; place-items: center; font-size: 3rem; }
.hero-badge__name { margin: var(--space-md) 0 0; font-weight: 800; font-size: var(--text-lg); }
.hero-badge__goal { margin: 0; color: var(--color-muted); font-size: var(--text-sm); }
.hero-badge__progress,
.hero-badge__achieved { margin: var(--space-sm) 0 0; font-weight: 800; }
.hero-badge__progress { color: var(--color-muted); }
.hero-badge__achieved { display: none; color: var(--color-warning); }
.hero-badge.is-achieved .hero-badge__progress { display: none; }
.hero-badge.is-achieved .hero-badge__achieved { display: block; animation: pop-in 500ms var(--ease-out); }

.hero-badge__confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti-piece {
  position: absolute;
  top: 38%;
  left: 50%;
  width: 0.45rem;
  height: 0.7rem;
  border-radius: 2px;
  background: var(--color-primary);
  opacity: 0;
  animation: confetti-burst 1600ms var(--ease-out) var(--delay, 0ms) forwards;
}
.confetti-piece:nth-child(3n) { background: var(--color-accent); }
.confetti-piece:nth-child(3n + 2) { background: var(--color-success); }

.landing-strip { background: var(--color-surface); border-block: 1px solid var(--color-border); }
.landing-strip__inner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  padding-block: var(--space-lg);
}
.landing-strip__item { display: flex; align-items: center; justify-content: center; gap: var(--space-md); }
.landing-strip__icon { color: var(--color-primary); }
.landing-strip__icon .icon-monoline { width: 1.75rem; height: 1.75rem; }
.landing-strip__item p { margin: 0; color: var(--color-muted); font-size: var(--text-sm); }

.landing-problem .landing__container { max-width: 46rem; text-align: center; }
.landing-problem__body { margin: 0; font-size: var(--text-lg); color: var(--color-muted); }
/* the closing beat pulled out as a weightier line so the "silence" lands */
.landing-problem__punch {
  margin: var(--space-lg) 0 0;
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-wrap: balance;
}
.landing-problem__title-line { display: block; }

/* Scroll reveal (progressive enhancement — see reveal_controller.js).
   Items are fully visible until JS adds .reveal-ready; the transition lives
   only on .is-revealed, so applying the hidden state never animates a
   fade-out. Untouched under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .reveal-ready .reveal { opacity: 0; transform: translateY(1.25rem); }
  .reveal-ready .reveal.is-revealed {
    opacity: 1;
    transform: none;
    transition: opacity 650ms var(--ease-out), transform 650ms var(--ease-out);
  }
  /* second title line lands as its own beat */
  .reveal-ready .landing-problem__title-line--2.is-revealed { transition-delay: 180ms; }
  /* philosophy manifesto cascades: critique → pull-quote → close */
  .reveal-ready .landing-philosophy__lead.is-revealed { transition-delay: 90ms; }
  .reveal-ready .landing-philosophy__quote.is-revealed { transition-delay: 200ms; }
  .reveal-ready .landing-philosophy__close.is-revealed { transition-delay: 320ms; }
}

.landing-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}
.step-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
}
.step-card__num {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-pill);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 800;
}
.step-card h3 { margin: var(--space-md) 0 var(--space-xs); font-size: var(--text-base); }
.step-card p { margin: 0; color: var(--color-muted); font-size: var(--text-sm); }

.landing-whitelabel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: center;
}
.landing-whitelabel__copy > p { margin: 0 0 var(--space-md); color: var(--color-muted); max-width: 30rem; }
p.landing-whitelabel__hint { color: var(--color-text); font-weight: 700; }

.wl-swatches { display: flex; gap: var(--space-sm); }
.wl-swatch {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-pill);
  background: var(--swatch);
  border: 3px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border);
  cursor: pointer;
  transition: transform var(--transition-quick), box-shadow var(--transition-quick);
}
.wl-swatch:hover { transform: scale(1.08); }
.wl-swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--swatch); transform: scale(1.05); }

.wl-mock {
  /* Re-declare the derived family so it recomputes from the picked color —
     the same single-knob theming the app uses (see TOKENS above). */
  --color-primary-strong: color-mix(in oklab, var(--color-primary) 85%, black);
  --color-primary-soft: color-mix(in oklab, var(--color-primary) 12%, white);
  --color-primary-softer: color-mix(in oklab, var(--color-primary) 6%, white);
  --color-primary-border: color-mix(in oklab, var(--color-primary) 25%, white);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}
.wl-mock__bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.7rem var(--space-md);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 800;
}
.wl-mock__dot {
  width: 1rem;
  height: 1rem;
  border-radius: var(--radius-pill);
  background: color-mix(in oklab, var(--color-on-primary) 80%, transparent);
}
.wl-mock__body { padding: var(--space-lg); display: grid; gap: var(--space-md); justify-items: start; }
.wl-mock__card {
  box-sizing: border-box; /* width:100% must absorb the padding */
  width: 100%;
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-md);
}
.wl-mock__badge { margin: 0 0 var(--space-sm); font-weight: 700; }
.wl-mock__numbers { margin: var(--space-sm) 0 0; font-weight: 800; color: var(--color-primary); }
.wl-mock__button {
  background: var(--color-primary);
  color: var(--color-on-primary);
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: var(--text-sm);
}

.landing-philosophy .landing__container { max-width: 44rem; text-align: center; }
/* manifesto: supporting critique → display pull-quote thesis → supporting close */
.landing-philosophy__lead,
.landing-philosophy__close { margin: 0 auto; max-width: 38rem; font-size: var(--text-lg); color: var(--color-muted); }
.landing-philosophy__quote {
  margin: var(--space-lg) auto;
  max-width: 28rem;
  font-size: clamp(1.6rem, 3.4vw, 2.3rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-wrap: balance;
}

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
.feature-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  transition: transform var(--transition-quick), box-shadow var(--transition-quick);
}
.feature-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.feature-card__icon {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  color: var(--color-primary);
  background: var(--color-primary-soft);
  border-radius: var(--radius-pill);
}
.icon-monoline { display: block; }
.feature-card__icon .icon-monoline { width: 1.4rem; height: 1.4rem; }
.feature-card h3 { margin: var(--space-md) 0 var(--space-xs); font-size: var(--text-base); }
.feature-card p { margin: 0; color: var(--color-muted); font-size: var(--text-sm); }

.landing-faq .landing__container { max-width: 46rem; }
.landing-faq__list { display: grid; gap: var(--space-sm); }
.faq-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  padding: var(--space-md) var(--space-lg);
}
.faq-item summary { font-weight: 700; cursor: pointer; }
.faq-item summary::marker { color: var(--color-primary); }
.faq-item[open] summary { color: var(--color-primary); }
.faq-item p { margin: var(--space-sm) 0 0; color: var(--color-muted); }

.landing-final {
  position: relative;
  overflow: hidden;
  background: var(--gradient-celebrate);
  color: var(--color-on-primary);
  text-align: center;
  padding-block: clamp(3.5rem, 8vw, 5.5rem);
}
/* Plum-ink vignette keeps white copy ≥4.5:1 over the bright amber core of the
   celebrate gradient; the vivid violet/amber edges still read at the corners. */
.landing-final::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 62% 82% at 50% 50%,
    color-mix(in srgb, var(--color-text) 62%, transparent) 0%,
    color-mix(in srgb, var(--color-text) 34%, transparent) 46%,
    transparent 76%
  );
  pointer-events: none;
}
.landing-final .landing__container { position: relative; z-index: 1; }
.landing-final__title { margin: 0; font-size: clamp(1.7rem, 3.5vw, 2.4rem); font-weight: 900; line-height: 1.2; }
.landing-final__body {
  margin: var(--space-md) auto var(--space-lg);
  max-width: 34rem;
  color: color-mix(in srgb, var(--color-on-primary) 88%, transparent);
}

.landing-footer { background: var(--color-surface); border-top: 1px solid var(--color-border); }
.landing-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-block: var(--space-lg);
  flex-wrap: wrap;
}
.landing-footer__brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; color: var(--color-primary); }
.landing-footer__tagline { color: var(--color-muted); font-weight: 400; margin-left: var(--space-sm); }
.landing-footer__links { display: flex; gap: var(--space-md); flex-wrap: wrap; }
.landing-footer__links a { color: var(--color-muted); text-decoration: none; font-weight: 600; font-size: var(--text-sm); }
.landing-footer__links a:hover { color: var(--color-primary); }

/* In-app footer: discreet product attribution so the org's brand leads (whitelabel). */
.app-footer {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  text-align: center;
}
.app-footer__attribution { margin: 0; font-size: var(--text-sm); color: var(--color-muted); }

/* Getting-started panel: a single featured card, centered in the section */
.landing-fork__lead {
  max-width: 42rem;
  margin: calc(-1 * var(--space-sm)) auto var(--space-xl);
  text-align: center;
  color: var(--color-muted);
  font-size: var(--text-lg);
}
.fork-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  max-width: 36rem;
  margin-inline: auto;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-lift);
}
.fork-panel__title { margin: 0; font-size: var(--text-xl); font-weight: 800; letter-spacing: -0.01em; }
.fork-panel__body { margin: 0; color: var(--color-muted); }
.fork-panel__points { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-sm); }
.fork-panel__points li {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: var(--space-sm);
  align-items: start;
  font-weight: 600;
}
.fork-panel__points li::before { content: "✓"; color: var(--color-success); font-weight: 900; }
.fork-panel .button { margin-top: auto; align-self: flex-start; }

.button--ghost {
  background: transparent;
  color: var(--color-primary) !important;
  box-shadow: inset 0 0 0 2px var(--color-primary-border);
}
.button--ghost:hover {
  background: var(--color-primary-soft);
  box-shadow: inset 0 0 0 2px var(--color-primary);
  transform: translateY(-1px);
}
/* Low-emphasis destructive action (e.g. the confirm in a destructive dialog,
   where the safe action is the solid primary). */
.button--ghost-danger {
  background: transparent;
  color: var(--color-danger) !important;
  box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--color-danger) 35%, transparent);
}
.button--ghost-danger:hover {
  background: var(--color-danger-soft);
  box-shadow: inset 0 0 0 2px var(--color-danger);
  transform: translateY(-1px);
}
.landing-final__ctas { display: flex; gap: var(--space-md); justify-content: center; flex-wrap: wrap; }

@media (max-width: 900px) {
  .landing-nav__links { display: none; }
  /* On phones the hero CTA (and one per section) carries acquisition; the nav
     keeps a compact "Entrar" for returning users instead of a cramped button
     that overflows small (≤375px) viewports. */
  .landing-nav__actions .button { display: none; }

  /* Desktop vignette is tuned for centered max-width copy; on phones the copy
     is full-width, so cover the whole column and never fully clear to keep
     white text ≥4.5:1 out to the amber edge. */
  .landing-final::before {
    background: radial-gradient(
      ellipse 135% 78% at 50% 48%,
      color-mix(in srgb, var(--color-text) 68%, transparent) 0%,
      color-mix(in srgb, var(--color-text) 52%, transparent) 60%,
      color-mix(in srgb, var(--color-text) 36%, transparent) 100%
    );
  }

  .landing-hero__inner { grid-template-columns: 1fr; text-align: center; }
  .landing-hero__subtitle { margin-inline: auto; }
  .landing-hero__ctas { justify-content: center; }

  .landing-strip__inner { grid-template-columns: 1fr; gap: var(--space-md); }
  .landing-strip__item { justify-content: flex-start; }

  .landing-steps,
  .landing-whitelabel { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .feature-grid { grid-template-columns: 1fr; }
  .landing-footer__inner { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   BACKOFFICE
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  transition: transform var(--transition-quick), box-shadow var(--transition-quick);
  animation: fade-up 500ms var(--ease-out) backwards;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.stat-card:nth-child(2) { animation-delay: 60ms; }
.stat-card:nth-child(3) { animation-delay: 120ms; }
.stat-card__value { margin: 0; font-size: var(--text-display); font-weight: 800; line-height: 1; color: var(--color-primary); }
.stat-card__label { margin: var(--space-xs) 0 0; color: var(--color-muted); font-weight: 600; }

.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-xs) var(--space-lg);
  margin-bottom: var(--space-lg);
}
.detail-list dt { color: var(--color-muted); font-weight: 700; }
.detail-list dd { margin: 0; }

.swatch { display: inline-flex; align-items: center; gap: var(--space-sm); }
.swatch__chip {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: var(--swatch);
}

.field input[type="color"] {
  width: 3rem;
  height: 2.75rem;
  padding: 0.2rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  cursor: pointer;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

@keyframes progress-grow {
  from {
    width: 0;
  }
}

@keyframes shine {
  to {
    transform: translateX(100%);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

@keyframes confetti-burst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -120px)))
      rotate(var(--spin, 540deg));
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 640px) {
  .main-nav {
    display: grid;
    grid-template-columns: 1fr auto;
    row-gap: var(--space-sm);
  }
  .main-nav__brand { grid-row: 1; grid-column: 1; }
  .nav-right { grid-row: 1; grid-column: 2; margin-left: 0; }
  .main-nav__links {
    grid-row: 2;
    grid-column: 1 / -1;
  }

  h1 { font-size: var(--text-xl); }

  .page-header {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .actions {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .inline-form { flex-wrap: wrap; }
  .inline-form input[type="email"] { min-width: 0; flex-basis: 100%; }

  .invitation-page { margin: 1.5rem auto; padding: var(--space-lg) var(--space-md); }

  .auth-page { margin-top: 1.5rem; }
}

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

/* Initials avatar. There are no uploaded avatars — this is the only likeness a
   member has, so it shows up in the roster, the leaderboard and profile headers.
   The nav's circle is this plus .profile-avatar, which adds only the button bits. */
.avatar {
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar--md { width: 2rem; height: 2rem; font-size: 0.75rem; }
.avatar--lg { width: 4rem; height: 4rem; font-size: var(--text-lg); }

/* Avatar + name, side by side, in a table cell. */
.member-cell {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.profile-header h1 { margin: 0; }
.profile-header .subtitle { margin: 0.25rem 0 0; }
/* Account settings stacks two independent forms (handle, then Devise account) —
   rule them apart so the first one's button doesn't read as the second's. */
.account-section {
  padding-bottom: var(--space-lg);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.profile-header__handle {
  margin: 0.1rem 0 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.profile-stats { display: flex; gap: var(--space-lg); }
.profile-stat { display: flex; flex-direction: column; }
.profile-stat__value { font-size: var(--text-xl); font-weight: 700; }
.profile-stat__label { color: var(--color-muted); font-size: var(--text-sm); }

/* Button-only additions on top of .avatar .avatar--md — the circle itself is
   defined once there, so the nav can't drift from the roster. */
.profile-avatar {
  border: none;
  cursor: pointer;
  transition: background var(--transition-quick);
}
.profile-avatar:hover { background: var(--color-primary-strong); }

.profile-menu { position: relative; }

.profile-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-lift);
  min-width: 19rem;
  max-width: calc(100vw - 2rem);
  z-index: 100;
  padding: var(--space-sm) 0;
  overflow: hidden; /* clip item hover fills to the rounded corners */
}
.profile-popover:not([hidden]) {
  transform-origin: top right;
  animation: popover-in 150ms var(--ease-out);
}
@keyframes popover-in {
  from { opacity: 0; transform: translateY(-4px); }
}

/* who you're signed in as */
.profile-popover__identity {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: var(--space-xs) var(--space-md);
}
.profile-popover__caption { font-size: var(--text-sm); color: var(--color-muted); }
.profile-popover__name { font-weight: 700; }
.profile-popover__email {
  font-size: var(--text-sm);
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* one row vocabulary for every actionable item */
.profile-popover .button_to { display: block; }
.profile-popover__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  box-sizing: border-box; /* width:100% must absorb the padding */
  width: 100%;
  padding: 0.5rem var(--space-md);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-decoration: none;
}
.profile-popover__item:hover,
.profile-popover__item:focus-visible {
  background: var(--color-primary-softer);
  color: var(--color-primary);
}
.profile-popover__item--current {
  font-weight: 700;
  color: var(--color-primary);
  cursor: default;
}
.profile-popover__item--current:hover { background: none; }
.profile-popover__icon { width: 1rem; height: 1rem; flex-shrink: 0; }
.profile-popover__item--danger:hover,
.profile-popover__item--danger:focus-visible {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.profile-popover__divider { border-top: 1px solid var(--color-border); margin: var(--space-xs) 0; }

/* language segmented control */
.profile-popover__locales {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
}
.profile-popover__locales .button_to { flex: 1; }
.profile-popover__locale {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: none;
  color: var(--color-muted);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}
.profile-popover__locale:hover { background: var(--color-primary-softer); color: var(--color-primary); }
.profile-popover__locale--active {
  background: var(--color-primary-soft);
  border-color: var(--color-primary-border);
  color: var(--color-primary);
}

/* ---- AI badge assistant ---- */

/* Generate panel on the badges index */
.ai-assistant {
  background: var(--color-primary-softer);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}
.ai-assistant h2 { font-size: var(--text-lg); margin: 0 0 var(--space-xs); }
.ai-assistant__hint { color: var(--color-muted); margin: 0 0 var(--space-md); }
.ai-assistant .field { max-width: none; margin-bottom: var(--space-md); }
.ai-assistant textarea { width: 100%; }

/* Hero variant: on an org with no badges yet, the panel IS the empty state. */
.ai-assistant--hero { text-align: center; padding: var(--space-xl) var(--space-lg); }
.ai-assistant--hero .field { max-width: 32rem; margin-inline: auto; text-align: left; }
.ai-assistant__manual { margin: var(--space-md) 0 0; color: var(--color-muted); font-size: var(--text-sm); }

/* Set apart as a panel so the fields read as "the metric", not more badge fields. */
.new-metric {
  /* border-box, so the 28rem of .field plus this padding actually resolves to
     the declared width — content-box rendered it 50px wider and pushed every
     field inside it off the form's left edge. min-inline-size overrides the
     UA's min-content default for fieldset. */
  box-sizing: border-box;
  min-inline-size: 0;
  max-width: 31rem;
  background: var(--color-primary-softer);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-card);
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  margin-bottom: var(--space-lg);
}
.new-metric__legend {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  padding-inline: var(--space-xs);
  font-weight: 700;
}
.new-metric__legend .link-button { font-size: var(--text-sm); font-weight: 400; }

/* Populated header: the AI toggle and the manual link sit together as a pair. */
.header-actions { display: flex; align-items: center; gap: var(--space-sm); }

/* Inline "Gerando…" status that replaces the submit button while generating.
   Same padding as .button so the label lands exactly where the button's did. */
.loading-status {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  color: var(--color-primary);
  font-weight: 700;
}

/* Suggestion list: compact cards, expand-to-edit */
.ai-suggestions__hint { margin: 0 0 var(--space-xs); }
.ai-suggestions__note { margin: 0 0 var(--space-md); color: var(--color-muted); font-size: var(--text-sm); }

.ai-suggestion {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
}

/* The select checkbox lives on the summary line, so it centers with the text
   in both collapsed and expanded states (no per-state alignment needed). */
.ai-suggestion__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem var(--space-sm);
  cursor: pointer;
  list-style: none;
  padding: var(--space-xs) 0;
}
.ai-suggestion__summary::-webkit-details-marker { display: none; }
.ai-suggestion__icon { font-size: 1.25rem; }
.ai-suggestion__name { font-size: var(--text-base); }
.ai-suggestion__facts { color: var(--color-muted); font-size: var(--text-sm); }
.ai-suggestion__edit {
  margin-left: auto;
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
}
.ai-suggestion__edit::after { content: " ▾"; }
.ai-suggestion__details[open] .ai-suggestion__edit::after { content: " ▴"; }

.ai-suggestion__body {
  padding-top: var(--space-sm);
  margin-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}
