/* =============================================================================
   3. FORM CONTROLS - Labels, inputs, selects, checkboxes

   V0 Source Reference: app/globals.css lines 476-495 (.sbos-label)
                        app/globals.css lines 659-699 (.sbos-field, .sbos-field-input)
                        app/globals.css lines 972-998 (field attention exceptions)
   V0 Component: components/ui/input.tsx, components/ui/select.tsx

   NAMING MAPPING (V0 → SBOS):
   ─────────────────────────────────────────────────────────────────────────────
   .sbos-label                       → .ui-2026-label
   .sbos-label-aligned               → .ui-2026-label--inline
   .sbos-field                       → .ui-2026-field
   .sbos-field-row                   → .ui-2026-field--row
   .sbos-field-input                 → .ui-2026-input, .ui-2026-select, .ui-2026-textarea
   .sbos-field-input-readonly        → .ui-2026-input[readonly]
   .sbos-field-error                 → .ui-2026-error
   [data-attention="error"]          → .ui-2026-input--error (via .is-error)
   [data-attention="warning"]        → .ui-2026-input--warning
   [data-valid="true"]               → (native :valid pseudo-class)
   [data-valid="false"]              → (native :invalid pseudo-class)

   EXCEPTION PATTERN MAPPING:
   V0 uses data attributes           → SBOS uses BEM modifiers or state classes
   [data-attention="error"]          → .is-error on field container
   [data-state="disabled"]           → [disabled] attribute

   Design notes:
   - Labels are uppercase with letter-spacing
   - Inputs use --border, --background, --foreground tokens
   - Focus state uses --ring token for outline
   ============================================================================= */

.ui-2026 .ui-2026-field {
  display: grid;
  /* @ai: minmax(0, 1fr) clamps the single implicit column to the field's width. Without it the
     'auto' track grows to a child's max-content (e.g. a long select label) and overflows into the
     neighbouring grid cell. Lower specificity, so fields that set their own columns still win. */
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.ui-2026 .ui-2026-label {
  font-size: var(--text-sm);
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: hsl(var(--muted-foreground));
}

.ui-2026 .ui-2026-label--inline {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
}

.ui-2026 .ui-2026-hint {
  font-size: var(--text-xs);
  color: hsl(var(--muted-foreground));
}

.ui-2026 .ui-2026-input,
.ui-2026 .ui-2026-select,
.ui-2026 .ui-2026-textarea {
  box-sizing: border-box;
  width: 100%;
  height: var(--input-h, 38px);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 8px 12px;
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.25;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ui-2026 .ui-2026-select {
  padding-right: 24px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 14px;
  /* @ai: border-radius is set by the combined .ui-2026-input/.ui-2026-select/.ui-2026-textarea rule above via var(--radius). Do NOT override here. */
  border-color: hsl(var(--border));
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
}

/* @ai: border-radius is set by the combined rule above via var(--radius). Do NOT add a hardcoded radius here.
   Shadow treatment matches the select component styling. */
.ui-2026 .ui-2026-input,
.ui-2026 .ui-2026-textarea {
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
}

.ui-2026 .ui-2026-textarea,
.ui-2026 textarea.ui-2026-input {
  height: auto;
  min-height: var(--input-h, 38px);
  resize: vertical;
}

/* Multi-select listbox styling */
.ui-2026 .ui-2026-select[multiple],
.ui-2026 select.ui-2026-select[multiple] {
  padding: 0;
  padding-right: 0;
  height: auto;
  min-height: 100px;
  max-height: 160px;
  overflow-y: auto;
  background-image: none; /* Remove dropdown arrow */
}

.ui-2026 .ui-2026-select[multiple] option,
.ui-2026 select.ui-2026-select[multiple] option {
  padding: 6px 10px;
  border-bottom: 1px solid hsl(var(--border) / 0.5);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.ui-2026 .ui-2026-select[multiple] option:last-child,
.ui-2026 select.ui-2026-select[multiple] option:last-child {
  border-bottom: none;
}

.ui-2026 .ui-2026-select[multiple] option:hover,
.ui-2026 select.ui-2026-select[multiple] option:hover {
  background-color: hsl(var(--muted) / 0.5);
}

.ui-2026 .ui-2026-select[multiple] option:checked,
.ui-2026 select.ui-2026-select[multiple] option:checked {
  background: linear-gradient(0deg, hsl(var(--primary) / 0.15), hsl(var(--primary) / 0.15));
  color: hsl(var(--primary));
  font-weight: 500;
}

/* Scrollbar styling for multi-select */
.ui-2026 .ui-2026-select[multiple]::-webkit-scrollbar {
  width: 6px;
}

.ui-2026 .ui-2026-select[multiple]::-webkit-scrollbar-track {
  background: hsl(var(--muted) / 0.3);
  border-radius: 3px;
}

.ui-2026 .ui-2026-select[multiple]::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.3);
  border-radius: 3px;
}

.ui-2026 .ui-2026-select[multiple]::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.5);
}

/* -----------------------------------------------------------------------------
   Custom Select Dropdown (UI-2026 Reference — /ui2026-reference/inputs)
   Single + multi-select (checkbox options inside .ui-2026-select-options)
   ----------------------------------------------------------------------------- */
.ui-2026 .ui-2026-select-dropdown {
  position: relative;
}

.ui-2026 .ui-2026-select-control {
  box-sizing: border-box;
  width: 100%;
  height: var(--input-h, 38px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  padding: 8px 12px;
  padding-right: 10px;
  border: 1px solid hsl(var(--border) / 0.8);
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.ui-2026 .ui-2026-select-control:hover {
  border-color: hsl(var(--border) / 0.9);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}

.ui-2026 .ui-2026-select-control:focus,
.ui-2026 .ui-2026-select-dropdown.is-open .ui-2026-select-control {
  outline: none;
  border-color: hsl(var(--ring) / 0.9);
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15), 0 1px 3px rgb(0 0 0 / 0.06);
}

.ui-2026 .ui-2026-select-control .selected-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  /* @ai: min-width:0 lets a long single-line label (e.g. "30 days after the end of the
     invoiced month") actually ellipsis instead of forcing the control's min-content wider
     than its grid cell and overflowing into the neighbouring field. */
  min-width: 0;
}

.ui-2026 .ui-2026-select-control__icon {
  width: 16px;
  height: 16px;
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.ui-2026 .ui-2026-select-dropdown.is-open .ui-2026-select-control__icon {
  transform: rotate(180deg);
}

.ui-2026 .ui-2026-select-options {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border) / 0.8);
  border-radius: var(--radius-xl, 12px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  padding: 6px;
  max-height: 240px;
  overflow-y: auto;
  display: none;
  z-index: 40;
}

.ui-2026 .ui-2026-select-options.show,
.ui-2026 .ui-2026-select-dropdown.is-open .ui-2026-select-options {
  display: block;
}

.ui-2026 .ui-2026-select-option {
  padding: 8px 12px;
  border-radius: calc(var(--radius-xl, 12px) - 4px);
  margin: 1px 0;
  cursor: pointer;
  color: hsl(var(--foreground));
  font-size: var(--text-sm);
  transition: background-color 0.15s ease, transform 0.1s ease, border-radius 0.15s ease;
  position: relative;
  background: transparent;
}

.ui-2026 .ui-2026-select-option:hover {
  background: hsl(var(--muted) / 0.9) !important;
  border-radius: calc(var(--radius-xl, 12px) - 4px) !important;
  transform: translateX(2px);
  box-shadow: inset 0 0 0 1px hsl(var(--border) / 0.3);
}

.ui-2026 .ui-2026-select-option.is-highlighted {
  background: hsl(var(--muted) / 0.7);
  outline: 2px solid hsl(var(--ring) / 0.4);
  outline-offset: -2px;
}

.ui-2026 .ui-2026-select-option.is-selected {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  font-weight: 500;
}

.ui-2026 .ui-2026-select-option .ui-2026-checkbox-label {
  width: 100%;
  gap: 8px;
}

/* -----------------------------------------------------------------------------
   Progressive-enhancement shell — native <select> rendered as the custom
   select-dropdown by webroot/js/ui-2026/select-dropdown-enhance.js. The native
   <select> stays in the DOM (hidden) as the source of truth. Global so every
   UI-2026-scoped page that loads the enhancer gets a consistent look.
   ----------------------------------------------------------------------------- */
/* Hide the native <select> once its custom shell is built (value still readable). */
.ui-2026 select.is-enhanced {
  display: none;
}

/* Disabled state mirrors the native <select>'s `disabled` attribute. */
.ui-2026 .ui-2026-select-dropdown.is-disabled .ui-2026-select-control {
  background: hsl(var(--muted) / 0.4);
  color: hsl(var(--muted-foreground));
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.7;
}
.ui-2026 .ui-2026-select-dropdown.is-disabled .ui-2026-select-control:hover {
  border-color: hsl(var(--border) / 0.8);
  box-shadow: none;
}

/* Small control variant (mirrors .ui-2026-select--sm sizing).
   Padding/radius must match .ui-2026-input--sm exactly. */
.ui-2026 .ui-2026-select-control--sm {
  height: var(--input-h-sm, 30px);
  padding: 6px 10px;
  padding-right: 8px;
  font-size: var(--text-xs);
}

/* Enhanced wrapper behaves like a native select inside a flex date-range row. */
.ui-2026 .ui-2026-date-range .ui-2026-select-dropdown {
  flex: 1;
  min-width: 0;
}

/* Float the open options panel above sibling fields, especially inside modals/dialogs. */
.ui-2026 .ui-2026-modal .ui-2026-select-dropdown.is-open,
.ui-2026 .ui-2026-dialog .ui-2026-select-dropdown.is-open {
  position: relative;
  z-index: 2200;
}
.ui-2026 .ui-2026-modal .ui-2026-select-options,
.ui-2026 .ui-2026-dialog .ui-2026-select-options {
  z-index: 2200;
}

.ui-2026 .ui-2026-input--readonly {
  background: hsl(var(--muted) / 0.3);
  color: hsl(var(--foreground));
}

/* GW 2026-06-20: disabled inputs need clear visual distinction. */
.ui-2026 .ui-2026-input:disabled,
.ui-2026 .ui-2026-select:disabled,
.ui-2026 .ui-2026-textarea:disabled {
  background: hsl(var(--muted) / 0.4);
  color: hsl(var(--muted-foreground));
  cursor: not-allowed;
  opacity: 0.7;
  box-shadow: none;
}

.ui-2026 .ui-2026-select--sm {
  min-width: 180px;
  height: var(--input-h-sm, 30px);
  padding: 6px 10px;
  font-size: var(--text-xs);
}

.ui-2026 .ui-2026-input--sm {
  max-width: 120px;
  height: var(--input-h-sm, 30px);
  padding: 6px 10px;
  font-size: var(--text-xs);
}

/* Color input specific styling */
.ui-2026 .ui-2026-input--color,
.ui-2026 .ui-2026-input[type="color"] {
  width: 80px;
  height: 40px;
  padding: 4px;
  cursor: pointer;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}

.ui-2026 .ui-2026-input--color::-webkit-color-swatch-wrapper,
.ui-2026 .ui-2026-input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.ui-2026 .ui-2026-input--color::-webkit-color-swatch,
.ui-2026 .ui-2026-input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: calc(var(--radius) - 2px);
}

.ui-2026 .ui-2026-input--color::-moz-color-swatch,
.ui-2026 .ui-2026-input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: calc(var(--radius) - 2px);
}

.ui-2026 .ui-2026-input--with-icon {
  padding-right: 36px;
}

/* Input wrapper for icon positioning */
.ui-2026 .ui-2026-input-wrapper {
  position: relative;
}

.ui-2026 .ui-2026-input-wrapper__icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
}

.ui-2026 .ui-2026-input-wrapper__icon svg,
.ui-2026 .ui-2026-input-wrapper__icon i {
  width: 16px;
  height: 16px;
  color: hsl(var(--muted-foreground));
}

/* GW 2026-06-20: date inputs clip the date text when squeezed in flex grids. */
.ui-2026 .ui-2026-input[type="date"],
.ui-2026 .ui-2026-input[type="datetime-local"] {
  min-width: 140px;
}

.ui-2026 .ui-2026-input:focus,
.ui-2026 .ui-2026-select:focus,
.ui-2026 .ui-2026-textarea:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.ui-2026 .ui-2026-checkbox,
.ui-2026 .ui-2026-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Opt-in: keep the box aligned with the FIRST line of a wrapping label so
   multi-line checkboxes line up with single-line siblings in the same row
   (e.g. "Access Equipment (Scaffold) Required" — SBOS-ONLINE-554). */
.ui-2026 .ui-2026-checkbox--align-top,
.ui-2026 .ui-2026-radio--align-top {
  align-items: flex-start;
}

.ui-2026 .ui-2026-checkbox--align-top .ui-2026-checkbox__input,
.ui-2026 .ui-2026-radio--align-top .ui-2026-radio__input {
  margin-top: 2px; /* optically centre the 16px box on the first text line */
}

.ui-2026 .ui-2026-checkbox__input,
.ui-2026 .ui-2026-radio__input {
  width: 16px;
  height: 16px;
}

/* Custom-styled checkbox + radio — replaces native OS appearance */
.ui-2026 input.ui-2026-checkbox,
.ui-2026 input.ui-2026-radio {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  border: 1.5px solid hsl(var(--border));
  background: hsl(var(--background));
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.ui-2026 input.ui-2026-checkbox { border-radius: 4px; }
.ui-2026 input.ui-2026-radio    { border-radius: 50%; }

/* Hover */
.ui-2026 input.ui-2026-checkbox:not(:disabled):hover,
.ui-2026 input.ui-2026-radio:not(:disabled):hover {
  border-color: hsl(var(--ring));
}

/* Checked — fills with module/primary accent, shows white checkmark */
.ui-2026 input.ui-2026-checkbox:checked {
  background-color: var(--module-accent, hsl(var(--primary)));
  border-color: var(--module-accent, hsl(var(--primary)));
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 6L5 9L10 3' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 11px;
}

.ui-2026 input.ui-2026-radio:checked {
  background-color: var(--module-accent, hsl(var(--primary)));
  border-color: var(--module-accent, hsl(var(--primary)));
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 8 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='4' cy='4' r='2' fill='white'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

/* Indeterminate — dash mark (set via JS: el.indeterminate = true) */
.ui-2026 input.ui-2026-checkbox:indeterminate {
  background-color: var(--module-accent, hsl(var(--primary)));
  border-color: var(--module-accent, hsl(var(--primary)));
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 2' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cline x1='2' y1='1' x2='10' y2='1' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

/* Focus ring */
.ui-2026 input.ui-2026-checkbox:focus-visible,
.ui-2026 input.ui-2026-radio:focus-visible {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.2);
}

/* Disabled */
.ui-2026 input.ui-2026-checkbox:disabled,
.ui-2026 input.ui-2026-radio:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ui-2026 .ui-2026-checkbox__label,
.ui-2026 .ui-2026-radio__label {
  font-size: var(--text-sm);
  color: hsl(var(--foreground));
}

/* Input Group with Icon - V0 pattern for search inputs */
.ui-2026 .ui-2026-input-group {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.ui-2026 .ui-2026-input-group__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

.ui-2026 .ui-2026-input-group .ui-2026-input,
.ui-2026 .ui-2026-input--with-icon {
  padding-left: 36px;
}

/* Input group with addon button (e.g., search + advanced search icon) */
.ui-2026 .ui-2026-input-group--with-addon {
  display: flex;
  align-items: stretch;
}

.ui-2026 .ui-2026-input-group--with-addon .ui-2026-input {
  flex: 1;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

.ui-2026 .ui-2026-input-group__addon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ui-2026 .ui-2026-input-group__addon:hover {
  background: hsl(var(--muted-foreground) / 0.15);
  color: hsl(var(--foreground));
}

.ui-2026 .ui-2026-input-group__addon svg {
  width: 16px;
  height: 16px;
}

/* Autocomplete list styling */
.ui-2026 .ui-2026-autocomplete {
  position: relative;
}

.ui-2026 .ui-2026-autocomplete__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 4px;
  z-index: 100;
  box-shadow: 0 4px 12px rgb(15 23 42 / 0.08);
}

/* =============================================================================
   FORM CARDS & SECTIONS - Modern form layout components
   ============================================================================= */

.ui-2026-form-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}

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

.ui-2026-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ui-2026-form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: hsl(var(--foreground));
}

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

.ui-2026-form-select {
  padding: 10px 14px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  min-width: 180px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ui-2026-form-select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.ui-2026-form-actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
  border-top: 1px solid hsl(var(--border));
  justify-content: flex-end;
}

/* =============================================================================
   FORMULA EDITOR - Contenteditable input for formulas
   ============================================================================= */

.ui-2026-formula-editor {
  width: 100%;
  min-height: 160px;
  max-height: 240px;
  padding: var(--space-3);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, monospace;
  font-size: var(--text-sm);
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  overflow-y: auto;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

.ui-2026-formula-editor:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.ui-2026-formula-editor .syntax {
  color: hsl(0 72% 51%);
}

.ui-2026-formula-editor .syntax2 {
  color: hsl(217 91% 60%);
}

.ui-2026-formula-operators {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.ui-2026-formula-btn {
  padding: 6px 12px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.ui-2026-formula-btn:hover {
  background: hsl(var(--muted) / 0.8);
  transform: translateY(-1px);
}

.ui-2026-formula-btn:active {
  transform: translateY(0);
}

.ui-2026-formula-btn--text {
  padding: 6px 10px;
  font-size: var(--text-xs);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* =============================================================================
   CHECKBOX GROUPS - Multi-select checkbox grids for Magic Order Entry

   Used for fields like "fixing" in Aluminium Venetian where multiple options
   can be selected (Timber, Aluminium, Steel, etc.)

   HTML Structure:
   <div class="ui-2026-checkbox-group" data-magic-checkbox-group="fixing">
     <label class="ui-2026-checkbox-item">
       <input type="checkbox" class="ui-2026-checkbox">
       <span class="ui-2026-checkbox-label">Timber</span>
     </label>
   </div>
   ============================================================================= */

.ui-2026 .ui-2026-checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px 12px;
}

.ui-2026 .ui-2026-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
}

.ui-2026 .ui-2026-checkbox-item:hover {
  opacity: 0.9;
}

/* Custom checkbox rules are at the top of the checkbox section above */

/* When .ui-2026-checkbox is used as a label wrapper (BEM pattern) */
.ui-2026 label.ui-2026-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.ui-2026 .ui-2026-checkbox-label {
  font-size: var(--text-sm);
  color: hsl(var(--foreground));
  user-select: none;
}

/* When used as a label element (not just a span) */
.ui-2026 label.ui-2026-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
}

.ui-2026 label.ui-2026-checkbox-label:hover {
  opacity: 0.9;
}

/* Compact variant for smaller spaces */
.ui-2026 .ui-2026-checkbox-group--compact {
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px 8px;
}

.ui-2026 .ui-2026-checkbox-group--compact .ui-2026-checkbox-item {
  padding: 2px 0;
}

/* ==========================================================================
   Multiselect Dropdown (Select2-powered)
   @ai-note Added v2.7.49 for AV installation fixing field
   ========================================================================== */

.ui-2026 .ui-2026-multiselect {
  width: 100%;
  min-height: 38px;
}

/* Select2 overrides for UI-2026 */
.ui-2026 .select2-container--default .select2-selection--multiple {
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background-color: hsl(var(--background));
  min-height: 38px;
  padding: 2px 4px;
}

.ui-2026 .select2-container--default .select2-selection--multiple:focus,
.ui-2026 .select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: hsl(var(--ring));
  outline: none;
  box-shadow: 0 0 0 2px hsla(var(--ring), 0.2);
}

.ui-2026 .select2-container--default .select2-selection--multiple .select2-selection__choice {
  background-color: hsl(var(--accent));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 2px 8px;
  margin: 2px;
  font-size: var(--text-sm);
  color: hsl(var(--foreground));
}

.ui-2026 .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: hsl(var(--muted-foreground));
  margin-right: 4px;
}

.ui-2026 .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
  color: hsl(var(--destructive));
}

.ui-2026 .select2-dropdown {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background-color: hsl(var(--popover));
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.ui-2026 .select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.ui-2026 .select2-container--default .select2-results__option[aria-selected="true"] {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* =============================================================================
   LOCK TOGGLE - Compact slider toggle for override fields

   Used in Magic Order Entry for fields like manual_width_override.
   Shows red when locked (automatic) and green when unlocked (manual override).
   Icon-only design with sliding knob.

   HTML Structure:
   <label class="ui-2026-lock-toggle">
     <input type="checkbox" class="ui-2026-lock-toggle__input" data-magic-field="field_name">
     <span class="ui-2026-lock-toggle__track">
       <span class="ui-2026-lock-toggle__knob">
         <i data-lucide="lock" class="ui-2026-lock-toggle__icon-lock"></i>
         <i data-lucide="lock-open" class="ui-2026-lock-toggle__icon-unlock"></i>
       </span>
     </span>
   </label>
   ============================================================================= */

.ui-2026 .ui-2026-lock-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.ui-2026 .ui-2026-lock-toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ui-2026 .ui-2026-lock-toggle__track {
  position: relative;
  width: 52px;
  height: 28px;
  border-radius: 14px;
  background: #dc2626;
  transition: background-color 0.25s ease;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ui-2026 .ui-2026-lock-toggle__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ui-2026 .ui-2026-lock-toggle__knob svg {
  width: 14px;
  height: 14px;
  transition: opacity 0.2s ease;
}

.ui-2026 .ui-2026-lock-toggle__icon-lock {
  color: #dc2626;
  opacity: 1;
}

.ui-2026 .ui-2026-lock-toggle__icon-unlock {
  position: absolute;
  color: #16a34a;
  opacity: 0;
}

/* Unlocked state (checkbox checked) */
.ui-2026 .ui-2026-lock-toggle__input:checked ~ .ui-2026-lock-toggle__track {
  background: #16a34a;
}

.ui-2026 .ui-2026-lock-toggle__input:checked ~ .ui-2026-lock-toggle__track .ui-2026-lock-toggle__knob {
  transform: translateX(24px);
}

.ui-2026 .ui-2026-lock-toggle__input:checked ~ .ui-2026-lock-toggle__track .ui-2026-lock-toggle__icon-lock {
  opacity: 0;
}

.ui-2026 .ui-2026-lock-toggle__input:checked ~ .ui-2026-lock-toggle__track .ui-2026-lock-toggle__icon-unlock {
  opacity: 1;
}

/* Focus state */
.ui-2026 .ui-2026-lock-toggle__input:focus ~ .ui-2026-lock-toggle__track {
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 3px hsl(var(--ring) / 0.3);
}

/* Disabled state */
.ui-2026 .ui-2026-lock-toggle__input:disabled ~ .ui-2026-lock-toggle__track {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Center lock toggle horizontally within field group containers */
.ui-2026 .magic-field-group .ui-2026-lock-toggle {
  display: flex;
  margin: 0 auto;
}

/* ---------------------------------------------------------------------------
 * Order Priority radio group (SBOS-ONLINE-553)
 * The selected radio is tinted its own swatch colour (accent-color: <hex>),
 * so the "chosen" state is not visually distinct from the colour label
 * (yellow is near-invisible). Give the checked option a clear,
 * colour-independent selected treatment: tinted pill + primary ring on the
 * swatch + bold label. Used by templates/OrderFinalizeds/edit.php.
 * ------------------------------------------------------------------------- */
.ui-2026 .ui-2026-priority-option {
  padding: var(--space-3xs, 2px) var(--space-xs, 8px);
  border: 1px solid transparent;
  border-radius: 999px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ui-2026 .ui-2026-priority-option:hover {
  background: hsl(var(--primary) / 0.06);
}

.ui-2026 .ui-2026-priority-option:has(input:checked) {
  background: hsl(var(--primary) / 0.12);
  border-color: hsl(var(--primary));
  font-weight: 600;
}

.ui-2026 .ui-2026-priority-option:has(input:checked) .ui-2026-priority-swatch {
  box-shadow: 0 0 0 2px hsl(var(--background, 0 0% 100%)), 0 0 0 4px hsl(var(--primary));
}

.ui-2026 .ui-2026-priority-option .u-text-xs {
  font-weight: inherit;
}

/* Cache bust Mon, May 18, 2026 v5 (SBOS-ONLINE-553 priority radios) */
