/* BRX Digital Design System — Components (skeleton)
 * PORTABLE. Component classes land here as templates migrate through Phase 1.
 * Populated in order: buttons → forms → alerts → tables → avatars → cards → modals → badges.
 *
 * Naming convention:
 *   .brx-{component}              block
 *   .brx-{component}__{part}      element
 *   .brx-{component}--{variant}   modifier
 *
 * Nothing here may reference brx-one.css selectors or shell layout variables
 * beyond those declared in tokens.css (--sidebar-w, --topbar-h).
 */

/* ===========================================================================
   TYPOGRAPHY UTILITIES
   Mirrors brand guide §4 type scale. Explicit classes rather than element
   overrides so we don't fight Tailwind preflight or template defaults.
   =========================================================================== */

.brx-display {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 64px;
  line-height: 64px;
  letter-spacing: -0.035em;
  color: var(--ink-900);
}

.brx-h1 {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 38px;
  line-height: 42px;
  letter-spacing: -0.025em;
  color: var(--ink-900);
}

.brx-h2 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 22px;
  line-height: 28px;
  letter-spacing: -0.015em;
  color: var(--ink-900);
}

.brx-lead {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 19px;
  line-height: 29px;
  color: var(--ink-700);
}

.brx-body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15px;
  line-height: 24px;
  color: var(--ink-700);
}

.brx-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12.5px;
  line-height: 16px;
  color: var(--ink-800);
}

.brx-numeric {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ===========================================================================
   BUTTONS  (brand guide §8)
   One primary action per screen. Green accent reserved for identity moments.
   =========================================================================== */

.brx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-180) var(--ease-out),
              color var(--dur-180) var(--ease-out),
              border-color var(--dur-180) var(--ease-out),
              box-shadow var(--dur-180) var(--ease-out),
              transform var(--dur-120) var(--ease-out);
  white-space: nowrap;
  user-select: none;
}
.brx-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.brx-btn:disabled,
.brx-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.brx-btn__icon { display: inline-flex; align-items: center; }
.brx-btn__icon svg { width: 16px; height: 16px; }

/* Sizes */
.brx-btn--sm { padding: 6px 12px;  font-size: 12.5px; border-radius: var(--r-sm); }
.brx-btn--md { padding: 10px 20px; font-size: 14px; }
.brx-btn--lg { padding: 12px 24px; font-size: 15px; }

/* Variants */
.brx-btn--primary {
  background: var(--brx-navy);
  color: var(--paper);
}
.brx-btn--primary:hover:not(:disabled) {
  background: var(--brx-navy-2);
}
.brx-btn--primary:active:not(:disabled) { transform: translateY(1px); }

.brx-btn--accent {
  background: var(--brx-green);
  color: var(--brx-navy);
  box-shadow: 0 2px 10px -2px rgba(149, 214, 0, 0.45);
}
.brx-btn--accent:hover:not(:disabled) {
  filter: brightness(1.05);
  box-shadow: 0 4px 14px -2px rgba(149, 214, 0, 0.55);
}

.brx-btn--secondary {
  background: var(--paper);
  color: var(--brx-navy);
  border-color: var(--ink-300);
}
.brx-btn--secondary:hover:not(:disabled) {
  background: var(--paper-2);
  border-color: var(--ink-600);
}

.brx-btn--ghost {
  background: transparent;
  color: var(--ink-700);
}
.brx-btn--ghost:hover:not(:disabled) {
  background: var(--paper-2);
  color: var(--ink-900);
}

.brx-btn--danger {
  background: var(--rose);
  color: var(--paper);
}
.brx-btn--danger:hover:not(:disabled) {
  filter: brightness(0.95);
}

/* ===========================================================================
   FORM CONTROLS (brand guide §9)
   Label above input. Helper below. Errors paired with an icon.
   =========================================================================== */

.brx-field {
  display: block;
  font-family: var(--font-body);
}
.brx-field + .brx-field { margin-top: 1rem; }

.brx-field__label {
  display: block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--ink-800);
  margin-bottom: 6px;
}
.brx-field__required {
  color: var(--ink-500);
  margin-left: 2px;
  font-weight: 400;
}

.brx-field__input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--ink-300);
  border-radius: var(--r-md);
  background: var(--paper);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-900);
  transition: border-color var(--dur-180) var(--ease-out),
              box-shadow var(--dur-180) var(--ease-out);
}
.brx-field__input::placeholder { color: var(--ink-400); }
.brx-field__input:hover:not(:disabled) { border-color: var(--ink-400); }
.brx-field__input:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 4px var(--sky-soft);
}
.brx-field__input:disabled {
  background: var(--paper-3);
  color: var(--ink-500);
  cursor: not-allowed;
}

.brx-field__input--sm { padding: 6px 10px;  font-size: 13px; border-radius: var(--r-sm); }
.brx-field__input--md { padding: 10px 14px; font-size: 14px; }
.brx-field__input--lg { padding: 12px 16px; font-size: 15px; }

.brx-field__select-wrap {
  position: relative;
}
.brx-field__select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232E3A4D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.brx-field__hint {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-500);
  margin: 6px 0 0 0;
}
.brx-field__error {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--rose);
  margin: 6px 0 0 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.brx-field--error .brx-field__input {
  border-color: var(--rose);
}
.brx-field--error .brx-field__input:focus {
  box-shadow: 0 0 0 4px var(--rose-soft);
}

/* Stacked form body inside modals / standalone forms */
.brx-form-stack > * + * { margin-top: 1rem; }

/* Multi-column form grids */
.brx-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 720px) {
  .brx-form-grid--2 { grid-template-columns: repeat(2, 1fr); }
  .brx-form-grid--3 { grid-template-columns: repeat(3, 1fr); }
}

/* Field + adjacent-action row (e.g. password input + "Reset password" button).
   For multi-field rows where the action applies to several inputs, use a
   `brx-form-grid` with `grid-template-columns: 1fr 1fr auto; align-items: end;`
   instead so input widths stay equal. */
.brx-field--with-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: end;
}
.brx-field--with-action > .brx-field { margin: 0; }
.brx-field--disabled .brx-field__label { color: var(--ink-500); }

/* Checkbox (minimum viable) */
.brx-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--brx-green-ink);
  cursor: pointer;
  vertical-align: middle;
}
.brx-checkbox:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 2px;
}

/* ===========================================================================
   FORMS  — populated in Step 5/6
   =========================================================================== */
/* .brx-field, .brx-field__label, .brx-field__input, .brx-field__help,
   .brx-field__error, .brx-field--error, .brx-select, .brx-textarea,
   .brx-checkbox, .brx-radio, .brx-switch */

/* ===========================================================================
   ALERTS  (brand guide §10)
   Four severities. Color + icon + label — never color alone.
   =========================================================================== */

.brx-alert {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}
.brx-alert__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  flex-shrink: 0;
}
.brx-alert__body {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
}
.brx-alert__title {
  font-weight: 700;
  margin-right: 2px;
}
.brx-alert__desc {
  font-weight: 400;
}
.brx-alert__dismiss {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brx-alert__dismiss:hover { opacity: 1; }

.brx-alert--info {
  background: var(--sky-soft);
  border-color: #C9D9F4;
  color: #1C4A9F;
}
.brx-alert--success {
  background: var(--brx-green-soft);
  border-color: #D0E6A0;
  color: var(--brx-green-ink);
}
.brx-alert--warning {
  background: var(--sun-soft);
  border-color: #F0D9A6;
  color: #8A5000;
}
.brx-alert--danger {
  background: var(--rose-soft);
  border-color: #F2C6C3;
  color: #A62A27;
}

/* ===========================================================================
   TABLES  (brand guide §11)
   Designed like a printed ledger. Generous rows. Tabular numerals.
   Uppercase navy headers — our signature table treatment.
   =========================================================================== */

.brx-table-wrap {
  background: var(--paper);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}

/* Horizontal scroll container for wide tables (permission matrix, etc.) */
.brx-table-wrap--scroll {
  overflow-x: auto;
}

.brx-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--ink-800);
  background: var(--paper);
}

.brx-table__th {
  background: var(--paper);
  text-align: left;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 10.5px;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brx-navy);
  padding: 14px 16px;
  border-bottom: 1px solid var(--ink-200);
  white-space: nowrap;
}
.brx-table__th--center { text-align: center; }
.brx-table__th--right  { text-align: right;  }

.brx-table td {
  padding: 14px 16px;
  border-top: 1px solid var(--ink-150);
  color: var(--ink-800);
  vertical-align: middle;
}
.brx-table tbody tr:first-child td {
  border-top: none;
}

/* Numeric cells: mono, right-aligned, tabular-nums */
.brx-table__cell--num {
  font-family: var(--font-mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-900);
}
.brx-table__cell--center { text-align: center; }
.brx-table__cell--right  { text-align: right;  }

/* Sticky column (permission matrix role column, etc.) */
.brx-table__cell--sticky,
.brx-table__th.brx-table__cell--sticky {
  position: sticky;
  left: 0;
  background: var(--paper);
  z-index: 2;
}

.brx-table__cell--empty {
  text-align: center;
  color: var(--ink-400);
  padding: 48px 16px;
  font-style: italic;
}

/* Row interactivity */
.brx-table--hoverable tbody tr:hover td {
  background: var(--paper-2);
}
.brx-table--hoverable tbody tr:hover .brx-table__cell--sticky {
  background: var(--paper-2);
}

.brx-table--striped tbody tr:nth-child(even) td {
  background: var(--paper-2);
}
.brx-table--striped tbody tr:nth-child(even) .brx-table__cell--sticky {
  background: var(--paper-2);
}

/* Auto-granted "all access" row style (permission matrix) */
.brx-table__row--muted td {
  background: var(--paper-3) !important;
  color: var(--ink-500);
  font-style: italic;
}

/* ===========================================================================
   PAGE HEADER + BREADCRUMB
   =========================================================================== */

.brx-page {
  padding: 2rem 2rem 3rem;
  max-width: 1280px;
  margin: 0 auto;
}

.brx-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.brx-page-header__text { min-width: 0; }
.brx-page-header__title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.625rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink-900);
  margin: 0;
}
.brx-page-header__sub {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--ink-500);
  margin: 0.375rem 0 0 0;
}
.brx-page-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Breadcrumb fragments — rendered inside base.html's topbar via {{ breadcrumb_content }}. */
.brx-breadcrumb__sep {
  display: inline-flex;
  align-items: center;
  color: var(--ink-400);
  margin: 0 0.5rem;
}
.brx-breadcrumb__label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--ink-800);
}
.brx-breadcrumb__link {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--ink-600);
  text-decoration: none;
}
.brx-breadcrumb__link:hover {
  color: var(--brx-navy);
  text-decoration: underline;
}

/* Page-level helpers */
.brx-page__status {
  display: none;
  margin-bottom: 1rem;
}
.brx-page__footnote {
  margin-top: 1.25rem;
}
.brx-table__note {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--ink-400);
  font-style: italic;
  margin-left: 0.375rem;
}
.brx-table__cell--granted {
  color: var(--brx-green-ink);
}
.brx-table__th--unavailable,
.brx-table__cell--unavailable {
  background-color: var(--ink-100);
  color: var(--ink-400);
}
.brx-table__cell--unavailable .brx-checkbox { cursor: not-allowed; opacity: 0.4; }

/* ===========================================================================
   AVATAR CHIPS
   The one place hue runs free (§3, §12). Deterministic color by hash of a
   stable identifier (email). Initials are first-letter-first + first-letter-last.
   Keep dark text on the light pastel fill — each chip passes AA at 28px.
   =========================================================================== */

.brx-avatar-chip {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 11px;
  color: var(--ink-900);
  flex-shrink: 0;
  user-select: none;
  letter-spacing: 0.02em;
}

/* Size modifiers */
.brx-avatar-chip--sm { width: 22px; height: 22px; font-size: 10px; }
.brx-avatar-chip--md { width: 28px; height: 28px; font-size: 11px; }
.brx-avatar-chip--lg { width: 36px; height: 36px; font-size: 13px; }
.brx-avatar-chip--xl { width: 48px; height: 48px; font-size: 16px; }

/* Color slots — seed hash → one of these six. Do not reassign; same person = same color forever. */
.brx-avatar-chip--c1 { background: var(--ac-mint);  }
.brx-avatar-chip--c2 { background: var(--ac-sky);   }
.brx-avatar-chip--c3 { background: var(--ac-lilac); }
.brx-avatar-chip--c4 { background: var(--ac-coral); }
.brx-avatar-chip--c5 { background: var(--ac-amber); }
.brx-avatar-chip--c6 { background: var(--ac-sage);  }

/* ===========================================================================
   CARDS  — populated in Step 4 (dashboard)
   =========================================================================== */
/* .brx-card, .brx-card__header, .brx-card__body, .brx-card__footer,
   .brx-card--elevated */

/* ===========================================================================
   CARDS — paper surface sections on canvas (brand guide §6)
   =========================================================================== */

.brx-card {
  background: var(--paper);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 1.5rem;
}
.brx-card + .brx-card { margin-top: 1.25rem; }

.brx-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--ink-150);
}
.brx-card__header--nude {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 1rem;
}
.brx-card__title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.0625rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink-900);
  margin: 0;
}
.brx-card__sub {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--ink-500);
  margin: 0.25rem 0 0 0;
}

/* Danger-zone variant — destructive actions (reset password, deactivate) */
.brx-card--danger {
  border-color: #F2C6C3;
  background: var(--paper);
  box-shadow: var(--shadow-1);
}
.brx-card--danger .brx-card__title {
  color: #A62A27;
}
.brx-card--danger .brx-card__header {
  border-bottom-color: #F7DCD9;
}

/* Stat card — metric tile variant. Big tabular-number value, uppercase caption
   label. Optional `.brx-card--stat__accent` modifier classes add a small
   semantic color tag (used sparingly — earned moments only per brand §3).
   Used across the Deal Centre dashboard, file_application metrics bar, and
   any future analytic tile. */
.brx-card--stat {
  padding: 1.125rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.brx-card--stat__value {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1;
  color: var(--ink-900);
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.brx-card--stat__label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.375rem;
}
.brx-card--stat__delta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  margin-top: 0.25rem;
}
.brx-card--stat__delta--up   { color: var(--moss); }
.brx-card--stat__delta--down { color: var(--rose); }

/* Earned-accent modifiers — keep rare per brand (color = meaning, not decoration) */
.brx-card--stat--good .brx-card--stat__value { color: var(--brx-green-ink); }
.brx-card--stat--bad  .brx-card--stat__value { color: var(--rose); }
.brx-card--stat--warn .brx-card--stat__value { color: var(--sun); }

/* ===========================================================================
   EMPTY STATE — icon · title · subtitle · optional action. Used for empty
   tables, zero-state dashboards, filtered lists with no matches.
   =========================================================================== */

.brx-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--ink-500);
}
.brx-empty-state__icon {
  width: 40px;
  height: 40px;
  color: var(--ink-300);
  margin-bottom: 0.5rem;
}
.brx-empty-state__title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--ink-800);
  margin: 0;
}
.brx-empty-state__body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-500);
  margin: 0;
  max-width: 32rem;
}
.brx-empty-state__action {
  margin-top: 1rem;
}

/* ===========================================================================
   AUTOCOMPLETE — dropdown attached below a field input, keyboard-navigable.
   Markup pattern:
     <div class="brx-autocomplete">
       <input class="brx-field__input brx-field__input--md" />
       <div class="brx-autocomplete__panel" role="listbox">
         <div class="brx-autocomplete__count">42 results</div>
         <div class="brx-autocomplete__item" role="option">Label <span class="brx-autocomplete__sub">sub</span></div>
       </div>
     </div>
   =========================================================================== */

.brx-autocomplete {
  position: relative;
  display: inline-block;
  min-width: 280px;
}
.brx-autocomplete__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  z-index: 50;
  display: none;
}
.brx-autocomplete__panel.is-open { display: block; }

.brx-autocomplete__count {
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-500);
  background: var(--paper-2);
  border-bottom: 1px solid var(--ink-150);
}
.brx-autocomplete__item {
  padding: 10px 14px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink-800);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.brx-autocomplete__item:hover,
.brx-autocomplete__item.is-highlighted {
  background: var(--brx-green-soft);
  color: var(--brx-navy);
}
.brx-autocomplete__sub {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-400);
  flex-shrink: 0;
}
.brx-autocomplete__item:hover .brx-autocomplete__sub,
.brx-autocomplete__item.is-highlighted .brx-autocomplete__sub {
  color: var(--ink-600);
}
.brx-autocomplete__empty {
  padding: 18px 14px;
  text-align: center;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-400);
}
.brx-autocomplete__clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--ink-400);
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brx-autocomplete__clear:hover {
  color: var(--ink-800);
  background: var(--paper-2);
}
.brx-autocomplete__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
  pointer-events: none;
  display: inline-flex;
}
/* Input modifier when used inside autocomplete — leaves room for icon + clear */
.brx-autocomplete .brx-field__input { padding-left: 36px; padding-right: 36px; }

/* ===========================================================================
   SEGMENTED BUTTON GROUP — mutually-exclusive toggle pair (BRX/FINMO view,
   List/Board, timeframe pickers). Active item gets a paper fill + shadow-1.
   =========================================================================== */

.brx-btn-group {
  display: inline-flex;
  background: var(--paper-2);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.brx-btn-group__item {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.2;
  color: var(--ink-600);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--dur-120) var(--ease-out),
              color var(--dur-120) var(--ease-out),
              box-shadow var(--dur-120) var(--ease-out);
  white-space: nowrap;
}
.brx-btn-group__item:hover:not(.is-active) {
  color: var(--ink-900);
}
.brx-btn-group__item.is-active {
  background: var(--paper);
  color: var(--ink-900);
  box-shadow: var(--shadow-1);
  font-weight: 600;
}
.brx-btn-group__item:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Smaller variant for dense toolbars */
.brx-btn-group--sm .brx-btn-group__item { padding: 4px 10px; font-size: 12px; }

/* ===========================================================================
   TABS — horizontal tab navigation inside a card or a modal. Active tab has
   a green-accent underline. Icons allowed alongside label.
   =========================================================================== */

.brx-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--ink-150);
  padding: 0 0.5rem;
  overflow-x: auto;
}
.brx-tabs__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-120) var(--ease-out),
              border-color var(--dur-120) var(--ease-out);
}
.brx-tabs__item:hover:not(.is-active) {
  color: var(--ink-800);
  border-bottom-color: var(--ink-200);
}
.brx-tabs__item.is-active {
  color: var(--brx-navy);
  border-bottom-color: var(--brx-green);
  font-weight: 600;
}
.brx-tabs__item:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.brx-tabs__item svg { width: 14px; height: 14px; }

/* ===========================================================================
   KANBAN — pipeline/stage board with drag-drop cards. Structural layout only;
   status semantics are carried by --active / --good / --bad modifiers on the
   column. Per brand guide: muted neutral base, earned accent on terminal
   states. No 11-color rainbow.
   =========================================================================== */

.brx-kanban-container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  overflow-x: auto;
}
.brx-kanban-board {
  display: flex;
  gap: 0.75rem;
  min-width: fit-content;
  padding-bottom: 1rem;
}

.brx-kanban-column {
  flex: 0 0 264px;
  min-width: 264px;
  max-width: 280px;
  background: var(--paper-2);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 256px);
  transition: background var(--dur-180) var(--ease-out),
              border-color var(--dur-180) var(--ease-out);
}

.brx-kanban-column__header {
  padding: 0.75rem 1rem;
  background: var(--paper);
  border-bottom: 1px solid var(--ink-150);
  border-left: 3px solid var(--ink-300);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.brx-kanban-column__title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.8125rem;
  line-height: 1.25;
  color: var(--ink-900);
  letter-spacing: -0.005em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brx-kanban-column__count {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  color: var(--ink-600);
  background: var(--paper-3);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.brx-kanban-column__cards {
  flex: 1;
  overflow-y: auto;
  padding: 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.brx-kanban-column__cards::-webkit-scrollbar { width: 6px; }
.brx-kanban-column__cards::-webkit-scrollbar-track { background: transparent; }
.brx-kanban-column__cards::-webkit-scrollbar-thumb {
  background: var(--ink-200);
  border-radius: 3px;
}
.brx-kanban-column__cards::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

.brx-kanban-column__empty {
  text-align: center;
  padding: 1.75rem 0.75rem;
  color: var(--ink-400);
  font-family: var(--font-body);
  font-size: 13px;
  font-style: italic;
}

/* Status modifiers — earned accent per brand §3 */
.brx-kanban-column--good .brx-kanban-column__header {
  background: var(--brx-green-soft);
  border-left-color: var(--brx-green);
}
.brx-kanban-column--good .brx-kanban-column__title { color: var(--brx-green-ink); }
.brx-kanban-column--good .brx-kanban-column__count {
  background: var(--paper);
  color: var(--brx-green-ink);
}

.brx-kanban-column--bad .brx-kanban-column__header {
  background: var(--rose-soft);
  border-left-color: var(--rose);
}
.brx-kanban-column--bad .brx-kanban-column__title { color: #A62A27; }
.brx-kanban-column--bad .brx-kanban-column__count {
  background: var(--paper);
  color: #A62A27;
}

/* Drop-target — when a deal-card is dragging over this column */
.brx-kanban-column.is-drag-target {
  background: var(--brx-green-soft);
  border-color: var(--brx-green);
  border-style: dashed;
}
.brx-kanban-column.is-drag-target .brx-kanban-column__header { background: var(--brx-green-soft); }

/* Deal card — paper, shadow-1 resting, shadow-2 + subtle rotate on drag */
.brx-deal-card {
  background: var(--paper);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  user-select: none;
  transition: transform var(--dur-120) var(--ease-out),
              box-shadow var(--dur-120) var(--ease-out),
              border-color var(--dur-120) var(--ease-out);
  font-family: var(--font-body);
}
.brx-deal-card:hover {
  border-color: var(--brx-green);
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}
.brx-deal-card.is-dragging {
  opacity: 0.7;
  transform: rotate(1deg);
  box-shadow: var(--shadow-3);
  border-color: var(--brx-green);
}

.brx-deal-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}
.brx-deal-card__ident {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.brx-deal-card__file {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brx-deal-card__chev {
  color: var(--ink-300);
  font-size: 1rem;
  flex-shrink: 0;
  transition: color var(--dur-120) var(--ease-out),
              transform var(--dur-120) var(--ease-out);
}
.brx-deal-card:hover .brx-deal-card__chev {
  color: var(--brx-green-ink);
  transform: translateX(2px);
}

.brx-deal-card__name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-900);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.brx-deal-card__address {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-500);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 0.375rem;
}

.brx-deal-card__secondary {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-400);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-top: 4px;
}

.brx-deal-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.375rem;
  border-top: 1px solid var(--ink-150);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}
.brx-deal-card__footer-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toast alert — fixed bottom-right, animated slide-in. Rendered into any
   container by replacing innerHTML with a brx-alert block. */
.brx-toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1100;
  max-width: 22rem;
  animation: brx-toast-in var(--dur-240) var(--ease-out);
}
@keyframes brx-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) { .brx-toast { animation: none; } }

/* ===========================================================================
   SPINNER — 24px by default, inherits currentColor so semantic variants work
   =========================================================================== */

.brx-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--ink-200);
  border-top-color: var(--brx-green-ink);
  border-radius: 50%;
  animation: brx-spin 0.8s linear infinite;
}
.brx-spinner--sm { width: 16px; height: 16px; border-width: 2px; }
.brx-spinner--lg { width: 36px; height: 36px; border-width: 4px; }

@keyframes brx-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .brx-spinner { animation: none; border-top-color: var(--ink-400); }
}

/* ===========================================================================
   MODALS
   Paper card on a scrim backdrop. Shadow-3 (modal ceiling). Animated via
   .is-open class added by window.brxModal.
   =========================================================================== */

.brx-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(14, 23, 38, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  transition: opacity var(--dur-240) var(--ease-out);
}
.brx-modal-backdrop[hidden] { display: none; }
.brx-modal-backdrop.is-open {
  display: flex;
  opacity: 1;
}

.brx-modal {
  background: var(--paper);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  width: 100%;
  max-width: 28rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  transform: translateY(8px);
  transition: transform var(--dur-240) var(--ease-out);
}
.brx-modal-backdrop.is-open .brx-modal { transform: translateY(0); }

.brx-modal--sm { max-width: 22rem; }
.brx-modal--md { max-width: 28rem; }
.brx-modal--lg { max-width: 40rem; }
.brx-modal--xl { max-width: 56rem; }

.brx-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--ink-150);
}
.brx-modal__title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink-900);
  margin: 0;
}
.brx-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--ink-500);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: color var(--dur-120) var(--ease-out),
              background var(--dur-120) var(--ease-out);
}
.brx-modal__close:hover {
  color: var(--ink-900);
  background: var(--paper-2);
}
.brx-modal__body {
  padding: 1.5rem;
}
.brx-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ink-150);
}

/* ===========================================================================
   BADGES
   Pill-shaped, uppercase, small. Used for role + status indicators on people
   rows. Always paired with the role name text — color is secondary.
   =========================================================================== */

.brx-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.03em;
  background: var(--paper-3);
  color: var(--ink-700);
  border: 1px solid var(--ink-200);
  white-space: nowrap;
}

/* Semantic variants — for status (active/inactive, pending, failed). */
.brx-badge--success { background: var(--brx-green-soft); color: var(--brx-green-ink); border-color: #D0E6A0; }
.brx-badge--info    { background: var(--sky-soft);       color: #1C4A9F;              border-color: #C9D9F4; }
.brx-badge--warning { background: var(--sun-soft);       color: #8A5000;              border-color: #F0D9A6; }
.brx-badge--danger  { background: var(--rose-soft);      color: #A62A27;              border-color: #F2C6C3; }
.brx-badge--neutral { background: var(--paper-3);        color: var(--ink-600);       border-color: var(--ink-200); }

/* Hue variants — for role classification. Calmer tints than semantics. */
.brx-badge--rose  { background: var(--rose-soft);      color: #A62A27;           border-color: #F2C6C3; }
.brx-badge--sky   { background: var(--sky-soft);       color: #1C4A9F;           border-color: #C9D9F4; }
.brx-badge--green { background: var(--brx-green-soft); color: var(--brx-green-ink); border-color: #D0E6A0; }
.brx-badge--sun   { background: var(--sun-soft);       color: #8A5000;           border-color: #F0D9A6; }
.brx-badge--plum  { background: #EFEAFB;               color: #4E35A0;           border-color: #DED4F4; }

/* Status dot (optional prefix inside a badge) */
.brx-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

/* ===========================================================================
   FILTER BAR — tool bar above a table, hosting search + select filters
   =========================================================================== */

.brx-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.brx-filter-bar .brx-field {
  margin: 0;
}
.brx-filter-bar .brx-field__label {
  display: none;
}
.brx-filter-bar__search {
  flex: 1 1 280px;
  max-width: 400px;
  position: relative;
}
.brx-filter-bar__search .brx-field__input {
  padding-left: 38px;
}
.brx-filter-bar__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
  pointer-events: none;
  display: inline-flex;
}

/* ===========================================================================
   PAGINATION — simple prev/next + indicator; brand-styled buttons
   =========================================================================== */

.brx-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}
.brx-pagination__info {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--ink-500);
}
.brx-pagination__controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brx-pagination__indicator {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-600);
  padding: 0 0.5rem;
  font-variant-numeric: tabular-nums;
}

/* ===========================================================================
   LIST ITEM — simple horizontally-aligned row for permissions, search results
   Use inside a .brx-card or .brx-modal__body. Each row is a grid with a
   label column, optional status chip, and a right-aligned actions slot.
   =========================================================================== */

.brx-list { display: flex; flex-direction: column; }

.brx-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 10px 12px;
  border-radius: var(--r-md);
  transition: background var(--dur-120) var(--ease-out);
}
.brx-list__item:hover { background: var(--paper-2); }

.brx-list__item + .brx-list__item {
  border-top: 1px solid var(--ink-150);
  border-radius: 0;
}
.brx-list__item:first-child { border-top: none; }

.brx-list__main {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  flex: 1;
}
.brx-list__label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  color: var(--ink-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brx-list__sub {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-500);
}
.brx-list__actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

/* Interactive list items (SF search results) — full click target */
.brx-list__item--clickable { cursor: pointer; }
.brx-list__item--clickable:hover { background: var(--sky-soft); }
.brx-list__item--clickable:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Granted/denied icon accents on permission rows */
.brx-list__access {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}
.brx-list__access--granted { background: var(--brx-green-soft); color: var(--brx-green-ink); }
.brx-list__access--denied  { background: var(--rose-soft);      color: var(--rose); }
.brx-list__access--none    { background: var(--paper-3);        color: var(--ink-400); }

/* ===========================================================================
   AVATAR ROW — chip + name side-by-side, for table cells / list items
   =========================================================================== */

.brx-avatar-row {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}
.brx-avatar-row__name {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
