/* ==========================================================================
   BEAMERY DESIGN SYSTEM – CSS Custom Properties & Utility Classes
   Ground truth for prototyping, aligned to BeameryHQ/lib-design-system
   (packages/theme). WCAG 2.2 AA compliant on light backgrounds.
   Copy this <style> block into any HTML prototype.
   ========================================================================== */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --- Design Tokens ---
   Naming: --color-* are PRIMITIVES (lib-design-system baseColors).
   Semantic aliases (text/borders/backgrounds/controls/forms/outlines)
   follow packages/theme/src/colors.ts. Components consume semantics. */
:root {
  /* Primitives: brand */
  --color-brand-navy:          #150E3F;
  --color-brand-deep-lavender: #7E4BBC;
  --color-brand-orange:        #F15852;

  /* Primitives: neutrals */
  --color-neutral-900: #1F1F23;
  --color-neutral-800: #484851;
  --color-neutral-750: #5B5B67;
  --color-neutral-700: #6C6C7A;
  --color-neutral-600: #A0A0AB;
  --color-neutral-500: #BCBCC3;
  --color-neutral-400: #DBDBE0;
  --color-neutral-300: #E7E7E9;
  --color-neutral-200: #F1F1F3;
  --color-neutral-100: #F6F6F7;
  --color-neutral-0:   #FFFFFF;

  /* Primitives: indigos (brand primary ramp) */
  --color-indigo-900: #2222C3;
  --color-indigo-800: #391EE6;
  --color-indigo-500: #492FF4;
  --color-indigo-200: #D7D7FE;
  --color-indigo-100: #EBEBFE;

  /* Primitives: greens */
  --color-green-900: #064C1D;
  --color-green-800: #095D25;
  --color-green-500: #06742B;
  --color-green-200: #B1F6BD;
  --color-green-100: #D1FFD9;

  /* Primitives: yellows */
  --color-yellow-800: #704D00;
  --color-yellow-750: #885E00;
  --color-yellow-500: #FFBF00;
  --color-yellow-200: #FFE38D;
  --color-yellow-150: #FFEAAB;
  --color-yellow-100: #FFF1C7;
  --color-yellow-50:  #FFF8E3;

  /* Primitives: reds */
  --color-red-900: #860329;
  --color-red-800: #9E002D;
  --color-red-500: #BF0338;
  --color-red-400: #E70545;
  --color-red-200: #FFCCD2;
  --color-red-100: #FFE6E9;
  --color-red-50:  #FFF2F4;

  /* Semantic: text */
  --text-default:          var(--color-neutral-900);
  --text-secondary:        var(--color-neutral-700);
  --text-secondary-ongray: var(--color-neutral-750);
  --text-on-dark:          var(--color-neutral-0);
  --text-primary:          var(--color-indigo-500);
  --text-primary-active:   var(--color-indigo-900);
  --text-error:            var(--color-red-500);
  --text-warning:          var(--color-yellow-800);
  --text-warning-subtle:   var(--color-yellow-750);
  --text-success:          var(--color-green-500);

  /* Semantic: forms */
  --forms-label:                 var(--color-neutral-900);
  --forms-placeholder:           var(--color-neutral-700);
  --forms-placeholder-active:    var(--color-neutral-700);
  --forms-placeholder-ongray:    var(--color-neutral-750);

  /* Semantic: borders */
  --border-default:             var(--color-neutral-400);
  --border-form:                var(--color-neutral-700);   /* resting control border */
  --border-form-active:         var(--color-neutral-900);   /* hover/active border */
  --border-primary:             var(--color-indigo-500);
  --border-primary-active:      var(--color-indigo-900);
  --border-error:               var(--color-red-500);
  --border-error-subtle:        var(--color-red-200);
  --border-warning-subtle:      var(--color-yellow-150);
  --border-warning-subtle-hover:var(--color-yellow-750);

  /* Semantic: backgrounds */
  --bg-default:           var(--color-neutral-100);
  --bg-ongray:            var(--color-neutral-0);
  --bg-secondary:         var(--color-neutral-200);
  --bg-secondary-ongray:  var(--color-neutral-300);
  --bg-accent:            var(--color-indigo-100);
  --bg-accent-hover:      var(--color-indigo-200);
  --bg-success:           var(--color-green-100);
  --bg-warning:           var(--color-yellow-100);
  --bg-warning-subtle:    var(--color-yellow-50);
  --bg-error:             var(--color-red-100);
  --bg-error-subtle:      var(--color-red-50);
  --bg-dark:              var(--color-neutral-900);

  /* Semantic: controls (fills) */
  --control-primary:          var(--color-indigo-500);
  --control-primary-hover:    var(--color-indigo-800);
  --control-primary-active:   var(--color-indigo-900);
  --control-secondary:        var(--color-neutral-200);
  --control-secondary-hover:  var(--color-neutral-400);
  --control-secondary-active: var(--color-neutral-500);
  --control-destructive:        var(--color-red-500);
  --control-destructive-hover:  var(--color-red-800);
  --control-destructive-active: var(--color-red-900);
  --control-activation:         var(--color-green-500);
  --control-activation-hover:   var(--color-green-800);
  --control-activation-active:  var(--color-green-900);

  /* Semantic: outlines */
  --outline-focus: var(--color-indigo-500);

  /* Back-compat aliases used by filter / SC prototypes (--neutral-*, --brand-*) */
  --neutral-900: var(--color-neutral-900);
  --neutral-800: var(--color-neutral-800);
  --neutral-750: var(--color-neutral-750);
  --neutral-700: var(--color-neutral-700);
  --neutral-600: var(--color-neutral-600);
  --neutral-500: var(--color-neutral-500);
  --neutral-400: var(--color-neutral-400);
  --neutral-300: var(--color-neutral-300);
  --neutral-200: var(--color-neutral-200);
  --neutral-100: var(--color-neutral-100);
  --neutral-0:   var(--color-neutral-0);
  --brand-primary:        var(--color-indigo-500);
  --brand-primary-hover:  var(--color-indigo-800);
  --brand-primary-active: var(--color-indigo-900);
  --indigo-100: var(--color-indigo-100);
  --indigo-200: var(--color-indigo-200);
  --error:       var(--color-red-500);
  --error-light: var(--color-red-100);
  --control-keyline:       var(--border-form);
  --control-keyline-hover: var(--border-form-active);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --font-size-xs:  12px;
  --font-size-sm:  14px;
  --font-size-base:16px;
  --font-size-lg:  18px;
  --font-size-xl:  20px;
  --font-size-2xl: 24px;

  /* Spacing (4px grid) */
  --space-0:   0;
  --space-1:   4px;
  --space-2:   8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-6:   24px;
  --space-8:   32px;
  --space-10:  40px;
  --space-18:  72px;

  /* Control height (lib-design-system sizes.x8) */
  --control-height: 32px;
  --chip-height: 28px;

  /* Radii (lib-design-system radii x1 / x1_5 / x2) */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Shadows */
  --shadow-card:   0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
  --shadow-btn-primary:     0 2px 4px rgba(73,47,244,0.31);
  --shadow-btn-activation:  0 2px 4px rgba(6,116,43,0.31);
  --shadow-btn-destructive: 0 2px 4px rgba(191,3,56,0.31);

  /* Focus ring – 2px white inset + 2px primary. The accessibility floor. */

  /* Stacking — tooltips above app chrome (top nav 100), bulk bars, panels */
  --z-tooltip: 1100;
  --focus-ring: 0 0 0 2px var(--color-neutral-0), 0 0 0 4px var(--outline-focus);

  /* Select chevron (neutral-900) */
  --ds-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M13.5306 6.53061L8.5306 11.5306C8.46092 11.6005 8.37813 11.656 8.28696 11.6939C8.1958 11.7317 8.09806 11.7512 7.99935 11.7512C7.90064 11.7512 7.8029 11.7317 7.71173 11.6939C7.62057 11.656 7.53778 11.6005 7.4681 11.5306L2.4681 6.53061C2.3272 6.38972 2.24805 6.19862 2.24805 5.99936C2.24805 5.80011 2.3272 5.60901 2.4681 5.46811C2.60899 5.32722 2.80009 5.24806 2.99935 5.24806C3.19861 5.24806 3.3897 5.32722 3.5306 5.46811L7.99997 9.93749L12.4693 5.46749C12.6102 5.32659 12.8013 5.24744 13.0006 5.24744C13.1999 5.24744 13.391 5.32659 13.5318 5.46749C13.6727 5.60838 13.7519 5.79948 13.7519 5.99874C13.7519 6.198 13.6727 6.38909 13.5318 6.52999L13.5306 6.53061Z' fill='%231F1F23'/%3E%3C/svg%3E");
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--text-default);
  line-height: 1.6;
  background: var(--bg-default);
}

/* --- Typography --- */
h1, .h1 { font-size: var(--font-size-2xl); font-weight: 800; line-height: 36px; color: var(--text-default); }
.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  margin: 0;
  padding-top: 16px;
}
.page-title__logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: var(--text-default);
}
.page-title__suffix {
  flex: 1;
  min-width: 0;
}
h2, .h2 { font-size: var(--font-size-xl);  font-weight: 700; line-height: 32px; color: var(--text-default); }
h3, .h3 { font-size: var(--font-size-base);  font-weight: 700; line-height: 24px; color: var(--text-default); }
h4, .h4 { font-size: var(--font-size-sm);  font-weight: 700; line-height: 24px; color: var(--text-default); }
h5, .h5 { font-size: var(--font-size-xs);  font-weight: 700; line-height: 20px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.25px; }

.text-body       { font-size: var(--font-size-sm); color: var(--text-default); line-height: 20px; }
.text-body-em    { font-size: var(--font-size-sm); color: var(--text-default); font-weight: 600; line-height: 20px; }
.text-small      { font-size: var(--font-size-xs); color: var(--text-default); line-height: 20px; }
.text-secondary  { font-size: var(--font-size-sm); color: var(--text-secondary); line-height: 1.6; }
.text-label      { font-size: var(--font-size-sm); font-weight: 500; color: var(--text-default); }
.text-link       { font-size: var(--font-size-sm); color: var(--text-primary); cursor: pointer; text-decoration: none; }
.text-link:hover { color: var(--control-primary-hover); text-decoration: underline; }
.text-error      { font-size: var(--font-size-sm); color: var(--text-error); }
.text-success    { font-size: var(--font-size-sm); color: var(--text-success); }

/* --- Layout --- */
.stack-v { display: flex; flex-direction: column; }
.stack-h { display: flex; flex-direction: row; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.items-center   { align-items: center; }
.justify-end    { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }

.page-bg       { min-height: 100vh; background: var(--bg-default); }
.container     { max-width: 1280px; margin: 0 auto; padding: var(--space-6); }
.container-sm  { max-width: 448px; margin: 0 auto; }
.container-md  { max-width: 672px; margin: 0 auto; }

.grid      { display: grid; gap: var(--space-4); }
.grid-2    { grid-template-columns: repeat(2, 1fr); }
.grid-3    { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* --- Card --- */
.card {
  background: var(--bg-ongray);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.card-compact { padding: var(--space-4); }

/* --- Buttons ---
   Height: 32px (sizes.x8). `.btn-sm` is 28px — matches chip height for inline
   rows (filter panels, chip toolbars). Secondary family carries a resting 1px
   border (borders.form), rendered as an inset box-shadow so geometry never
   shifts. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-height);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  line-height: 1;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--control-primary);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-btn-primary);
}
.btn-primary:hover  { background: var(--control-primary-hover); }
.btn-primary:active { background: var(--control-primary-active); }

.btn-secondary {
  background: var(--control-secondary);
  color: var(--text-default);
  box-shadow: inset 0 0 0 1px var(--border-form);
}
.btn-secondary:hover  { background: var(--control-secondary-hover);  box-shadow: inset 0 0 0 1px var(--border-form-active); }
.btn-secondary:active { background: var(--control-secondary-active); box-shadow: inset 0 0 0 1px var(--border-form-active); }
.btn-secondary:focus-visible { box-shadow: inset 0 0 0 1px var(--border-form-active), var(--focus-ring); }

.btn-secondary-accent {
  background: var(--bg-accent);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--border-primary);
}
.btn-secondary-accent:hover  { background: var(--control-primary-hover); color: var(--text-on-dark); box-shadow: none; }
.btn-secondary-accent:active { background: var(--control-primary-active); color: var(--text-on-dark); box-shadow: none; }

.btn-subtle {
  background: transparent;
  color: var(--text-default);
}
.btn-subtle:hover  { background: var(--control-secondary-hover); }
.btn-subtle:active { background: var(--control-secondary-active); }

.btn-activation {
  background: var(--control-activation);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-btn-activation);
}
.btn-activation:hover  { background: var(--control-activation-hover); }
.btn-activation:active { background: var(--control-activation-active); }

.btn-destructive {
  background: var(--control-destructive);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-btn-destructive);
}
.btn-destructive:hover  { background: var(--control-destructive-hover); }
.btn-destructive:active { background: var(--control-destructive-active); }

.btn-destructive-secondary {
  background: var(--bg-error);
  color: var(--text-error);
  box-shadow: inset 0 0 0 1px var(--border-error);
}
.btn-destructive-secondary:hover { background: var(--control-destructive-hover); color: var(--text-on-dark); box-shadow: none; }

.btn-full { width: 100%; }

.btn-sm {
  height: var(--chip-height);
  min-height: var(--chip-height);
  padding: 0 var(--space-3);
  font-size: var(--font-size-xs);
}
.btn-sm.btn-icon-only {
  width: var(--chip-height);
  padding: 0;
}

.btn-icon,
svg.btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.btn-icon-only {
  padding: 0 var(--space-2);
}

/* --- Inputs ---
   Grey-fill control (controls.secondary) with a visible resting border
   (borders.form). Hover darkens fill + border; focus goes white with the
   primary border + focus ring. */
.input {
  width: 100%;
  height: var(--control-height);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-form);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--text-default);
  background: var(--control-secondary);
  transition: border-color 0.15s, background-color 0.15s;
  line-height: 1.5;
}
.input::placeholder { color: var(--forms-placeholder); opacity: 1; }
.input-ongray::placeholder { color: var(--forms-placeholder-ongray); opacity: 1; }
.input:hover {
  background: var(--control-secondary-hover);
  border-color: var(--border-form-active);
}
.input:focus {
  outline: none;
  background: var(--bg-ongray);
  border-color: var(--border-primary);
  box-shadow: var(--focus-ring);
}
.input-error,
.input-error:hover { border-color: var(--border-error); }
.input-error:focus {
  border-color: var(--border-error);
  box-shadow: 0 0 0 2px var(--color-neutral-0), 0 0 0 4px var(--border-error);
}
.input:disabled {
  background: var(--control-secondary);
  border-color: var(--border-form);
  cursor: not-allowed;
  opacity: 0.5;
}
/* Read-only display variant — NOT disabled: full-contrast text, subtle border,
   white fill, no hover affordance. Use for showing values the user can read/copy
   but not edit. */
.input[readonly],
.input[readonly]:hover {
  background: var(--bg-ongray);
  border-color: var(--border-default);
  color: var(--text-default);
  cursor: default;
}
.input[readonly]:focus {
  background: var(--bg-ongray);
  border-color: var(--border-default);
  box-shadow: var(--focus-ring);
}

/* Search input variant – leading icon inside the field */
.input-search-wrap { position: relative; width: 100%; }
.input-search-wrap .input-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--forms-placeholder);
  pointer-events: none;
}
.input-search-wrap .input { padding-left: 34px; }

/* --- Form Elements --- */
.form-group { display: flex; flex-direction: column; gap: var(--space-1); }
.form-label { font-size: var(--font-size-sm); font-weight: 500; color: var(--forms-label); }
.form-group:has(.input-error) .form-label,
.form-group:has([aria-invalid="true"]) .form-label {
  color: var(--text-error);
}
.form-required { color: var(--text-error); }
.form-hint  { font-size: var(--font-size-sm); color: var(--text-secondary); }
.form-error { font-size: var(--font-size-sm); color: var(--text-error); }

/* --- Select ---
   Secondary-control family (same chrome as .btn-secondary): inset border, grey fill,
   chevron. Base styles apply to .select and filter-prototype aliases. */
.select,
.qualifier-select,
.modal-select,
.status-select {
  width: auto;
  max-width: 100%;
  height: var(--control-height);
  padding: var(--space-1) var(--space-8) var(--space-1) var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-default);
  background-color: var(--control-secondary);
  background-image: var(--ds-select-chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  box-shadow: inset 0 0 0 1px var(--border-form);
  appearance: none;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s;
  align-self: flex-start;
  flex: 0 0 auto;
}
.select:hover,
.qualifier-select:hover,
.modal-select:hover,
.status-select:hover {
  background-color: var(--control-secondary-hover);
  box-shadow: inset 0 0 0 1px var(--border-form-active);
}
.select:active,
.qualifier-select:active,
.modal-select:active,
.status-select:active {
  background-color: var(--control-secondary-active);
  box-shadow: inset 0 0 0 1px var(--border-form-active);
}
.select:focus-visible,
.qualifier-select:focus-visible,
.modal-select:focus-visible,
.status-select:focus-visible {
  outline: none;
  background-color: var(--control-secondary);
  box-shadow: inset 0 0 0 1px var(--border-form-active), var(--focus-ring);
}
.select:disabled,
.qualifier-select:disabled,
.modal-select:disabled,
.status-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.select-full { width: 100%; }

/* --- List panels ---
   Shared floating list chrome for action menus and searchable pickers (typeahead).
   Items are text-only by default; add .list-panel__icon only for critical actions. */
.list-panel-host,
.search-input-wrap,
.input-search-wrap {
  position: relative;
}
.list-panel-host--inline {
  display: inline-block;
  width: auto;
}
.list-panel-host--select {
  display: block;
  width: 100%;
}
.list-panel-host--select > .btn {
  width: 100%;
  justify-content: space-between;
}
.list-panel-host--select .select-picker__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-weight: 300;
}
.list-panel-host--select-inline .select-picker__value {
  flex: 0 1 auto;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  text-align: left;
  font-weight: 300;
}
.select-picker__value.is-empty-muted {
  color: var(--text-secondary);
}
.list-panel-host--select-inline {
  display: inline-block;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
  align-self: flex-start;
}
.list-panel-host--select-inline > .select-picker-trigger {
  width: auto;
}
.list-panel-host--select-inline > .list-panel {
  right: auto;
  width: max-content;
  min-width: 100%;
}

/* Select picker triggers — tighter insets than default .btn (16px → 12px left, 8px right) */
.btn.select-picker-trigger:not(.select-picker-trigger--chip) {
  padding-left: var(--space-3);
  padding-right: var(--space-2);
}

/* Action menu triggers with trailing caret — match select picker caret inset */
.list-panel-host > .btn.btn-secondary:not(.select-picker-trigger):not(.btn-icon-only):has(> .btn-icon:last-child) {
  padding-right: var(--space-2);
}

/* Chip select picker — 28px pill trigger matching .chip; for inline filter rows */
.list-panel-host--select-chip {
  display: inline-block;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
  align-self: flex-start;
}
.list-panel-host--select-chip > .select-picker-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  height: var(--chip-height);
  min-height: var(--chip-height);
  padding: 0 var(--space-3);
  border-radius: 9999px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 400;
  line-height: 1;
  background: var(--bg-ongray);
  color: var(--text-default);
  border: 1px solid var(--border-form);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: none;
}
.list-panel-host--select-chip > .select-picker-trigger:hover {
  background: var(--bg-secondary);
  border-color: var(--border-form-active);
}
.list-panel-host--select-chip > .select-picker-trigger:active {
  background: var(--bg-secondary-ongray);
  border-color: var(--border-form-active);
}
.list-panel-host--select-chip > .select-picker-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.list-panel-host--select-chip .select-picker__value {
  flex: 0 1 auto;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  text-align: left;
  font-weight: 400;
}
.list-panel-host--select-chip .select-picker-trigger .btn-icon {
  width: 12px;
  height: 12px;
  color: var(--text-secondary);
}
.list-panel-host--select-chip > .list-panel {
  right: auto;
  width: max-content;
  min-width: 100%;
}

/* Labeled select picker — prefix label inside trigger (“Sort by:” + value; empty → “Any …”) */
.list-panel-host--select-labeled {
  display: block;
  width: 100%;
}
.list-panel-host--select-labeled > .btn {
  width: 100%;
  justify-content: space-between;
}
.list-panel-host--select-labeled-inline {
  display: inline-block;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
  align-self: flex-start;
}
.list-panel-host--select-labeled-inline > .select-picker-trigger {
  width: auto;
}
.list-panel-host--select-labeled-inline > .list-panel {
  right: auto;
  width: max-content;
  min-width: 100%;
}
.select-picker__display {
  display: flex;
  align-items: baseline;
  gap: 0.25em;
  min-width: 0;
}
.list-panel-host--select-labeled .select-picker__display {
  flex: 1;
  overflow: hidden;
}
.list-panel-host--select-labeled-inline .select-picker__display {
  flex: 0 1 auto;
  overflow: visible;
}
.select-picker__prefix {
  font-weight: 500;
  flex-shrink: 0;
}
.list-panel-host--select-labeled .select-picker__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-weight: 300;
}
.list-panel-host--select-labeled-inline .select-picker__value {
  flex: 0 1 auto;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  text-align: left;
  font-weight: 300;
}
.list-panel-host--select-labeled.is-empty .select-picker__prefix,
.list-panel-host--select-labeled-inline.is-empty .select-picker__prefix {
  display: none;
}
.list-panel-host--select-labeled.is-empty .select-picker__value,
.list-panel-host--select-labeled-inline.is-empty .select-picker__value {
  font-weight: 500;
}

select.select-picker-native {
  display: none !important;
}

.list-panel,
.typeahead-results {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 100%;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-ongray);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  padding: var(--space-1);
}
.list-panel-host--inline > .list-panel {
  right: auto;
  min-width: 12rem;
}
.typeahead-results {
  max-height: 180px;
}
.list-panel[hidden],
.typeahead-results[hidden] {
  display: none;
}

.list-panel__item[hidden],
.typeahead-option[hidden] {
  display: none !important;
}

.list-panel__item,
.typeahead-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 28px;
  padding: 5px var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-default);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  line-height: 1.4;
}
.list-panel__item:hover,
.list-panel__item.is-active,
.list-panel__item[aria-selected="true"],
.typeahead-option:hover,
.typeahead-option.is-active {
  background: var(--bg-secondary);
}
.list-panel__item[aria-selected="true"] {
  font-weight: 500;
  color: var(--text-primary);
}
.list-panel__item:focus-visible,
.typeahead-option:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.list-panel__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.list-panel__divider {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: var(--space-1) 0;
}

.list-panel__empty,
.typeahead-empty {
  padding: 6px var(--space-2);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* --- Chips ---
   Value chip: resting border borders.form; hover darkens the border to
   formActive with a subtle fill; selected goes accent + indigo-900. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 var(--space-3);
  border-radius: 9999px;
  font-size: var(--font-size-sm);
  font-weight: 400;
  line-height: 1;
  background: var(--bg-ongray);
  color: var(--text-default);
  border: 1px solid var(--border-form);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.chip:hover {
  background: var(--bg-secondary);
  border-color: var(--border-form-active);
}
.chip:active {
  background: var(--bg-secondary-ongray);
  border-color: var(--border-form-active);
}
.chip:focus-visible,
.chip:focus-within {
  outline: none;
  box-shadow: var(--focus-ring);
}
.chip.selected {
  background: var(--bg-accent);
  color: var(--text-primary-active);
  border-color: var(--border-primary-active);
}
.chip.selected:hover,
.chip-check:has(.chip-input:checked):hover { background: var(--bg-accent-hover); }
.chip-check:has(.chip-input:checked) {
  background: var(--bg-accent);
  color: var(--text-primary-active);
  border-color: var(--border-primary-active);
}
.chip .chip-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
}
.chip .chip-close:hover { color: var(--text-default); opacity: 1; }
.chip .chip-close svg { width: 12px; height: 12px; }
/* Removable-chip affordance (filter prototypes): hovering a chip whose only
   action is removal previews the destructive outcome with errorSubtle colours. */
.chip.removable:hover {
  background: var(--bg-ongray);
  border-color: var(--text-error);
  color: var(--text-error);
}
.chip.removable:hover .chip-close { color: var(--text-error); }

/* Chip wrapping a native checkbox or radio (selected = checked state). */
.chip-check { position: relative; }
.chip-check .chip-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.chip-fieldset {
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.chip-fieldset + .chip-fieldset { margin-top: var(--space-4); }
.chip-fieldset legend {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--forms-label);
  margin-bottom: var(--space-2);
  padding: 0;
}
.chip-check-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* --- Connector chips (AND / OR / IS / IS NOT) ---
   Full spec in Filter System/connector-chip-spec.md.
   11px/700. All pairings ≥ 4.5:1. Locked variant: same colours,
   cursor not-allowed, not focusable, no hover response. */
.connector {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background-color .12s, border-color .12s, color .12s;
}
.connector.or, .connector.is {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
}
.connector.or:hover, .connector.is:hover {
  background: var(--bg-secondary-ongray);
  border-color: var(--border-form);
  color: var(--text-default);
}
.connector.and {
  background: var(--bg-warning-subtle);
  border: 1px solid var(--border-warning-subtle);
  color: var(--text-warning-subtle);
}
.connector.and:hover { border-color: var(--border-warning-subtle-hover); }
.connector.not, .connector.is-not {
  background: var(--bg-error-subtle);
  border: 1px solid var(--border-error-subtle);
  color: var(--text-error);
}
.connector.not:hover, .connector.is-not:hover { border-color: var(--border-error); }
.connector:not(.locked):focus-visible {
  outline: 2px solid var(--outline-focus);
  outline-offset: 2px;
}
/* Locked: cursor affordance only – hover/active re-pin the resting colours */
.connector.locked { cursor: not-allowed; }
.connector.or.locked:hover, .connector.or.locked:active,
.connector.is.locked:hover, .connector.is.locked:active {
  background: var(--bg-secondary);
  border-color: var(--border-default);
  color: var(--text-secondary);
}
.connector.and.locked:hover, .connector.and.locked:active {
  background: var(--bg-warning-subtle);
  border-color: var(--border-warning-subtle);
  color: var(--text-warning-subtle);
}
.connector.not.locked:hover, .connector.not.locked:active,
.connector.is-not.locked:hover, .connector.is-not.locked:active {
  background: var(--bg-error-subtle);
  border-color: var(--border-error-subtle);
  color: var(--text-error);
}

/* --- Checkbox (single) ---
   16×16 box, 4px radius – matches lib-design-system Checkbox. */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  line-height: 20px;
  color: var(--text-default);
  cursor: pointer;
  user-select: none;
}
.checkbox-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.checkbox-box {
  position: relative;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 1px solid var(--border-form);
  border-radius: var(--radius-sm);
  background: var(--color-neutral-0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, background-color 0.12s;
}
.checkbox-box svg {
  width: 12px;
  height: 12px;
  color: var(--text-on-dark);
  opacity: 0;
  transition: opacity 0.12s;
}
.checkbox:hover .checkbox-input:not(:checked):not(:disabled) + .checkbox-box {
  border-color: var(--border-primary);
}
.checkbox-input:checked + .checkbox-box {
  border-color: var(--border-primary-active);
  background: var(--control-primary-active);
}
.checkbox-input:checked + .checkbox-box svg { opacity: 1; }
.checkbox-input:focus-visible + .checkbox-box { box-shadow: var(--focus-ring); }
.checkbox-input:disabled + .checkbox-box {
  opacity: 0.5;
  cursor: not-allowed;
}
.checkbox-input:disabled ~ .checkbox-label {
  opacity: 0.5;
  cursor: not-allowed;
}
.checkbox:has(.checkbox-input:disabled) { cursor: not-allowed; }

/* --- Toggle ---
   Off track is neutral-700 (≥3:1 against both the page and the white thumb);
   On is brand primary. State is conveyed by thumb position + track colour
   + icon – three non-colour-alone cues (SC 1.4.1). */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  cursor: pointer;
  user-select: none;
}
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-neutral-700);
  border-radius: 9999px;
  transition: background-color 0.2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--color-neutral-0);
  border-radius: 9999px;
  transition: transform 0.2s;
  z-index: 1;
}
.toggle-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  color: var(--color-neutral-0);
}
.toggle-icon svg { width: 12px; height: 12px; }
.toggle-icon-check { left: 5px; opacity: 0; }
.toggle-icon-close { right: 5px; opacity: 1; }
.toggle-input:checked + .toggle-track { background: var(--control-primary); }
.toggle-input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle-input:checked + .toggle-track .toggle-icon-check { opacity: 1; }
.toggle-input:checked + .toggle-track .toggle-icon-close { opacity: 0; }
.toggle-input:focus-visible + .toggle-track { box-shadow: var(--focus-ring); }
.toggle-input:disabled + .toggle-track { opacity: 0.5; cursor: not-allowed; }

/* Compact / dense toggle size (exploration – not yet in lib-design-system).
   Match default thumb:track ratio (~75% height, equal inset). Hit target ≥24×24
   via padding on the label – never on the track, or the thumb looks undersized. */
.toggle-track--xs {
  width: 36px;
  height: 16px;
}
.toggle-track--xs .toggle-thumb {
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
}
.toggle-track--xs .toggle-icon {
  width: 12px;
  height: 12px;
}
.toggle-track--xs .toggle-icon svg { width: 12px; height: 12px; }
.toggle-track--xs .toggle-icon-check { left: 2px; }
.toggle-track--xs .toggle-icon-close { right: 2px; }
.toggle-input:checked + .toggle-track--xs .toggle-thumb { transform: translateX(20px); }

/* Hit padding on the control, not the track – keeps the painted pill true-to-size */
.toggle--compact-hit {
  min-height: 24px;
  align-items: center;
}
.toggle--compact-hit:has(.toggle-track--xs) {
  padding-block: 4px; /* 16 + 8 = 24 */
}

/* --- Pills (status labels) --- */
.pill,
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: 9999px;
  font-size: var(--font-size-xs);
  font-weight: 500;
}
.pill-accent, .pill-primary, .badge-accent, .badge-primary { background: var(--bg-accent); color: var(--text-primary); }
.pill-success, .badge-success { background: var(--bg-success); color: var(--text-success); }
.pill-error,   .badge-error   { background: var(--bg-error); color: var(--text-error); }
.pill-warning, .badge-warning { background: var(--bg-warning); color: var(--text-warning); }
.pill-neutral, .badge-neutral { background: var(--bg-secondary); color: var(--text-secondary); }

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--color-neutral-300);
  margin: var(--space-4) 0;
}

/* --- Alerts --- */
.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}
.alert-error   { background: var(--bg-error);   color: var(--text-error); }
.alert-success { background: var(--bg-success); color: var(--text-success); }
.alert-warning { background: var(--bg-warning); color: var(--text-warning); }
.alert-icon    { flex-shrink: 0; width: 20px; height: 20px; }
.alert-body    { flex: 1; }
.alert-title   { font-weight: 600; margin-bottom: var(--space-1); }

/* --- Icons (SVG sprite, currentColor) --- */
.ds-icon { width: 16px; height: 16px; flex-shrink: 0; }
.ds-logo { width: 118px; height: 32px; color: var(--text-default); }
.ds-bexa { width: 32px; height: 32px; color: var(--text-default); }

/* --- Table --- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}
.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: 400;
  font-size: var(--font-size-xs);
  color: var(--text-secondary-ongray);
  background: var(--bg-secondary-ongray);
  border-bottom: 1px solid var(--color-neutral-300);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.table th .sort-indicator {
  display: inline-flex;
  align-items: center;
  width: 12px;
  height: 12px;
  margin-left: var(--space-1);
  vertical-align: middle;
  color: var(--text-secondary);
}
.table th[aria-sort="ascending"] .sort-indicator,
.table th[aria-sort="descending"] .sort-indicator {
  color: var(--control-primary);
}
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-neutral-300);
  color: var(--text-default);
}
.table tr:hover td { background: var(--bg-default); }

/* --- Tooltip — CSS-only, brief plain text, reveals on hover + focus ---
   Markup:  <span class="tooltip"> <trigger> <span class="tooltip__bubble"
   data-position="top|right|bottom|left">…</span> </span>
   The trigger must be focusable. When the tip duplicates an accessible name
   (e.g. an icon button's aria-label) mark the bubble aria-hidden="true";
   otherwise link them with aria-describedby on the trigger. */
.tooltip { position: relative; display: inline-flex; }
.tooltip:hover,
.tooltip:focus-within {
  z-index: var(--z-tooltip);
}
.tooltip__bubble {
  position: absolute;
  z-index: var(--z-tooltip);
  pointer-events: none;
  width: max-content;
  max-width: 220px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-dark);
  color: var(--text-on-dark);
  font-size: var(--font-size-xs);
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  box-shadow: var(--shadow-card);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0s linear 0.12s;
}
.tooltip:hover > .tooltip__bubble,
.tooltip:focus-within > .tooltip__bubble {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.12s ease 0.4s, visibility 0s;   /* ~hover-intent delay */
}
/* Instant reveal — no hover-intent delay. Set data-delay="instant" on .tooltip,
   or use side nav chrome (instant by convention). */
.tooltip[data-delay="instant"]:hover > .tooltip__bubble,
.tooltip[data-delay="instant"]:focus-within > .tooltip__bubble,
.side-nav .tooltip:hover > .tooltip__bubble,
.side-nav .tooltip:focus-within > .tooltip__bubble {
  transition: opacity 0.12s ease, visibility 0s;
}
/* Position — default top. 8px gap from the trigger. */
.tooltip__bubble,
.tooltip__bubble[data-position="top"]    { bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); }
.tooltip__bubble[data-position="bottom"] { top: calc(100% + 8px); bottom: auto; left: 50%; transform: translateX(-50%); }
.tooltip__bubble[data-position="left"]   { right: calc(100% + 8px); left: auto; top: 50%; bottom: auto; transform: translateY(-50%); }
.tooltip__bubble[data-position="right"]  { left: calc(100% + 8px); top: 50%; bottom: auto; transform: translateY(-50%); }

/* ==========================================================================
   APP CHROME
   ========================================================================== */

/* ── Top nav ── */
.top-nav {
  background: var(--color-brand-navy);
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  flex-shrink: 0;
  z-index: 100;
}

.top-nav__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text-on-dark);
  flex-shrink: 0;
}
.top-nav__logo-symbol  { width: 24px; height: 24px; }
.top-nav__logo-wordmark { width: 88px; height: 24px; }

.top-nav__search-wrapper {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
}
.top-nav__search {
  display: flex;
  align-items: center;
  background: var(--control-secondary);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 0 var(--space-2) 0 var(--space-2);
  height: var(--control-height);
  gap: var(--space-2);
  width: 100%;
  transition: border-color 0.15s;
}
.top-nav__search:focus-within {
  border-color: var(--border-primary);
  background: var(--bg-ongray);
}
.top-nav__search svg { flex-shrink: 0; color: var(--forms-placeholder); }
.top-nav__search input {
  border: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--text-default);
  outline: none;
  width: 100%;
}
.top-nav__search input::placeholder { color: var(--forms-placeholder); }

.top-nav__actions { display: flex; align-items: center; gap: var(--space-1); margin-left: auto; }

.top-nav__icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-on-dark);
  transition: background 0.15s;
}
.top-nav__icon-btn:hover { background: rgba(255,255,255,0.1); }
.top-nav__icon-btn:focus-visible { outline: 2px solid rgba(255,255,255,0.5); outline-offset: 2px; }

.top-nav__user-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-on-dark);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
.top-nav__user-btn:hover { background: rgba(255,255,255,0.1); }
.top-nav__user-btn:focus-visible { outline: 2px solid rgba(255,255,255,0.5); outline-offset: 2px; }

.top-nav__avatar {
  width: 24px;
  height: 24px;
  background: var(--color-indigo-500);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-on-dark);
  flex-shrink: 0;
}

/* ── Body layout ── */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* ── Side nav ── */
.side-nav {
  width: 56px;
  background: var(--bg-default);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding-top: var(--space-6);
  padding-bottom: var(--space-4);
  gap: 0;
}

.side-nav__section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-2);
  margin-bottom: var(--space-4);
}

.side-nav__section + .side-nav__section {
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-default);
}

.side-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--text-default);
  transition: background 0.15s, color 0.15s;
}
.side-nav__link:hover { background: var(--bg-accent); color: var(--color-indigo-500); }
.side-nav__link.active { background: var(--bg-accent); color: var(--color-indigo-500); }
.side-nav__link:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.side-nav__link svg { width: 16px; height: 16px; color: inherit; }

/* ── Main content ── */
.main-content {
  flex: 1;
  overflow: auto;
  padding: var(--space-8);
  background: var(--bg-default);
}

.svg-sprite { display: none; }

/* --- App shell — opt-in full-height body layout (add class="app-shell" to <body>) --- */
.app-shell { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

/* --- Skip link --- */
.skip-link { position: absolute; left: var(--space-2); top: -48px; z-index: 1000; padding: var(--space-2) var(--space-4); background: var(--control-primary); color: var(--text-on-dark); border-radius: var(--radius-md); font-size: var(--font-size-sm); font-weight: 500; text-decoration: none; transition: top 0.15s; }
.skip-link:focus { top: var(--space-2); outline: none; box-shadow: var(--focus-ring); }

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