/* revision: 2026.06.16.23.12.24 */
/*
 * BlockForge — framework_core.css (block rules)
 *
 * All .bf-* block styling. Consumes the design tokens defined in
 * framework_theme.css. HARD DEPENDENCY: framework_theme.css MUST be loaded
 * BEFORE this file so the var() references resolve. Host load order is
 * framework_theme.css -> framework_core.css -> /Application/styles.css.
 *
 * Colour, spacing, radius, shadow, and the dark nav-sidebar palette are design
 * tokens (var(--bf-*)), not literals. A few genuinely bespoke layout one-offs
 * (e.g. odd paddings) and two semantic literals — the slate badge fill
 * (.bf-tree-badge--slate) and the accent hover tint (.bf-list-editor__add:hover) —
 * remain literal by design.
 */

/*
 * revision: 2026.06.09.21.05.00
 */

/* ============================================================
   BlockForge — Base Styles
   ============================================================ */

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#app {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--bf-color-text);
  background: var(--bf-color-surface-alt);
  overflow: hidden;
}

/* ============================================================
   Layout Primitives (used by container-block)
   ============================================================ */

.bf-row {
  display: flex;
  flex-direction: row;
  gap: var(--bf-space-4);
}

.bf-column {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-4);
}

.bf-grid {
  display: grid;
  gap: var(--bf-space-4);
}

.bf-container-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

/* ============================================================
   Block Shell
   ============================================================ */

[data-block-id] {
  position: relative;
}

/* ============================================================
   List Block — Four mutually exclusive states
   ============================================================ */

.bf-list {
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  overflow: auto;
  flex: 1;
}

/* State message (rendered by JS) */
.bf-list .bf-state-msg {
  padding: 24px;
  text-align: center;
}
.bf-list.loading .bf-state-msg { color: var(--bf-color-text-subtle); }
.bf-list.error   .bf-state-msg { color: var(--bf-color-danger); }
.bf-list.empty   .bf-state-msg { color: var(--bf-color-text-subtle); }

/* ============================================================
   List Table
   ============================================================ */

.bf-list table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.bf-list th {
  background: var(--bf-color-surface-alt);
  border-bottom: 2px solid var(--bf-color-border);
  padding: var(--bf-space-4) var(--bf-space-5);
  text-align: left;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
}

.bf-list-header-content {
  display: flex;
  align-items: center;
  min-width: 0;
}

.bf-list-header-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bf-column-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  width: 7px;
  cursor: col-resize;
  z-index: 2;
  touch-action: none;
}

.bf-column-resizer::after {
  content: '';
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 3px;
  border-left: 1px solid transparent;
}

.bf-column-resizer:hover::after,
.bf-column-resizing .bf-column-resizer::after {
  border-left-color: var(--bf-color-primary);
}

.bf-column-resizing {
  cursor: col-resize;
  user-select: none;
}

.bf-list td {
  border-bottom: 1px solid var(--bf-color-border-light);
  padding: var(--bf-space-4) var(--bf-space-5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bf-list tr:hover td {
  background: var(--bf-color-surface-alt);
  cursor: pointer;
}

/* Per-column text alignment (col.align, or auto-right for numeric/currency
   formats). Applied to header, body, footer cells; click-to-edit inputs inherit
   the cell alignment so values stay aligned while editing. */
.bf-list th.bf-col-align-right,
.bf-list td.bf-col-align-right { text-align: right; }
.bf-list th.bf-col-align-center,
.bf-list td.bf-col-align-center { text-align: center; }
.bf-list td.bf-col-align-right input:not([type="checkbox"]),
.bf-list td.bf-col-align-center input:not([type="checkbox"]) { text-align: inherit; }

.bf-list tr.selected td {
  background: var(--bf-color-primary-soft);
}

.bf-list th.bf-list-sort-handle-col,
.bf-list td.bf-list-sort-handle-col {
  width: 32px;
  text-align: center;
  padding: 8px 4px;
}

.bf-list-row-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--bf-color-text-muted);
  background: var(--bf-color-surface);
  border: 1px solid transparent;
  border-radius: var(--bf-radius-sm);
  cursor: pointer;
  user-select: none;
}

.bf-list-row-drag-handle:hover {
  color: var(--bf-color-text);
  background: var(--bf-color-surface-muted);
  border-color: var(--bf-color-border);
}

.bf-list-row-drag-handle:active {
  cursor: pointer;
}

.bf-list tr.bf-list-row-dragging td {
  opacity: 0.45;
}

.bf-list tr.bf-list-row-over-top td {
  box-shadow: inset 0 2px 0 var(--bf-color-primary);
}

.bf-list tr.bf-list-row-over-bottom td {
  box-shadow: inset 0 -2px 0 var(--bf-color-primary);
}

.bf-list-options {
  display: flex;
  align-items: center;
  gap: var(--bf-space-2);
  flex-wrap: wrap;
  min-height: 22px;
}

.bf-list-option-chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  background: var(--bf-color-surface-muted);
  color: var(--bf-color-text);
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Active-row highlight — row whose field matches activeKey state value */
.bf-list tr.bf-row--active td {
  background: var(--bf-color-success-soft);
}
.bf-list tr.bf-row--active:hover td {
  background: var(--bf-color-success-soft);
}

/* Row indicators */
.bf-list tr.dirty td:first-child::before {
  content: '●';
  color: var(--bf-color-warning);
  margin-right: 6px;
  font-size: 10px;
}

.bf-list tr.failed td:first-child::before {
  content: '✕';
  color: var(--bf-color-danger);
  margin-right: 6px;
  font-size: 10px;
}

.bf-list tr.dirty.failed td:first-child::before {
  content: '✕●';
  color: var(--bf-color-danger);
  margin-right: 6px;
  font-size: 10px;
}

/* ============================================================
   List Cards
   ============================================================ */

.bf-list-cards {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-4);
  padding: var(--bf-space-4);
}

.bf-list-card {
  position: relative;
  border: 1px solid var(--bf-color-border-light);
  border-radius: var(--bf-radius-md);
  background: var(--bf-color-surface);
  padding: 10px;
}

.bf-list-card:hover {
  background: var(--bf-color-surface-muted);
  cursor: pointer;
}

.bf-list-card.selected {
  border-color: var(--bf-color-primary-border);
  background: var(--bf-color-primary-soft);
}

.bf-list-card.bf-row--active {
  border-color: var(--bf-color-success-border);
  background: var(--bf-color-success-soft);
}

.bf-list-card.dirty::before,
.bf-list-card.failed::before {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  font-weight: 700;
}

.bf-list-card.dirty::before {
  content: '●';
  color: var(--bf-color-warning);
}

.bf-list-card.failed::before {
  content: '✕';
  color: var(--bf-color-danger);
}

.bf-list-card.dirty.failed::before {
  content: '✕●';
  color: var(--bf-color-danger);
}

.bf-list-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--bf-space-3);
  margin-top: 8px;
}

/* Row checkbox column */
.bf-list td.bf-row-check,
.bf-list th.bf-row-check {
  width: 32px;
  text-align: center;
  padding: 8px 4px;
}

/* ============================================================
   Detail Block
   ============================================================ */

.bf-detail {
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  padding: var(--bf-space-6);
  min-width: 280px;
}

.bf-detail-header {
  font-weight: 600;
  font-size: 13px;
  color: var(--bf-color-text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bf-color-border-light);
}

.bf-modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-4);
}

.bf-modal-footer {
  align-items: stretch;
  border-top: 1px solid var(--bf-color-border-light);
  background: var(--bf-color-surface);
  padding: 14px 24px;
  width: 100%;
}

.bf-field {
  margin-bottom: 12px;
}

.bf-form-body {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-5);
}

.bf-form-body > .bf-field,
.bf-form-section > .bf-field,
.bf-form-section-body > .bf-field {
  margin-bottom: 0;
}

.bf-form-layout-grid > .bf-form-body,
.bf-form-layout-grid .bf-form-section--layout-grid {
  display: grid;
  grid-template-columns: repeat(var(--bf-form-columns, 2), minmax(0, 1fr));
  gap: var(--bf-space-5);
  align-items: start;
}

.bf-form-layout-auto-grid > .bf-form-body,
.bf-form-layout-auto-grid .bf-form-section--layout-auto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--bf-form-min-field-width, 220px), 100%), 1fr));
  gap: var(--bf-space-5);
  align-items: start;
}

.bf-form-layout-grid .bf-form-section,
.bf-form-layout-auto-grid .bf-form-section,
.bf-form-layout-grid .bf-form-section-header,
.bf-form-layout-auto-grid .bf-form-section-header,
.bf-form-layout-grid .bf-form-section-body,
.bf-form-layout-auto-grid .bf-form-section-body,
.bf-form-layout-grid .bf-field--full,
.bf-form-layout-auto-grid .bf-field--full,
.bf-form-section-body--layout-grid .bf-field--full,
.bf-form-section-body--layout-auto-grid .bf-field--full {
  grid-column: 1 / -1;
}

.bf-form-section {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin-bottom: 10px;
}

.bf-form-section-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--bf-space-5);
  width: 100%;
  min-width: 0;
}

.bf-form-section-body--layout-grid {
  display: grid;
  grid-template-columns: repeat(var(--bf-form-columns, 2), minmax(0, 1fr));
  gap: var(--bf-space-5);
  align-items: start;
}

.bf-form-section-body--layout-auto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--bf-form-min-field-width, 220px), 100%), 1fr));
  gap: var(--bf-space-5);
  align-items: start;
}

.bf-form-section-header {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bf-space-4);
  width: 100%;
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bf-color-text-muted);
  padding: 4px 0 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--bf-color-border-light);
}

.bf-form-section--collapsible > .bf-form-section-header {
  justify-content: flex-start;
  align-items: start;
}

.bf-form-section-toggle {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--bf-color-text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}

.bf-form-section-title {
  flex: 0 0 auto;
  padding-top: 1px;
}

.bf-form-section-summary {
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: break-word;
  word-break: normal;
  white-space: normal;
  color: var(--bf-color-text-muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.bf-form-section--collapsed > .bf-form-section-body {
  display: none;
}

/* sectionStyle: 'background' — colored header row */
.bf-form-section--background .bf-form-section-header {
  background: var(--bf-color-primary-soft);
  color: var(--bf-color-text);
  padding: 5px 8px;
  border-radius: var(--bf-radius-md);
  border-bottom: none;
  margin-bottom: 6px;
}

/* sectionStyle: 'border' — full border around section */
.bf-form-section--border {
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-lg);
  padding: 0 8px 8px;
}
.bf-form-section--border .bf-form-section-header {
  background: var(--bf-color-surface-muted);
  color: var(--bf-color-text);
  padding: var(--bf-space-3) var(--bf-space-4);
  border-radius: var(--bf-radius-lg) var(--bf-radius-lg) 0 0;
  border-bottom: 1px solid var(--bf-color-border);
  margin: 0 -8px 8px;
}

/* sectionStyle: 'indent' — indented fields, no header background */
.bf-form-section--indent .bf-field,
.bf-form-section--indent .bf-form-section {
  width: 100%;
  padding-left: 12px;
  border-left: 2px solid var(--bf-color-border-light);
}

/* ── List editor (string-list / object-list) ─────────────────────────────── */

.bf-list-editor {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-2);
  margin-top: 4px;
}

.bf-list-editor--compact {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

.bf-list-editor--compact .bf-list-editor__row {
  flex: 0 1 180px;
}

.bf-list-editor--compact .bf-list-editor__add {
  align-self: center;
  margin-top: 0;
}

.bf-list-editor__row {
  display: flex;
  align-items: center;
  gap: var(--bf-space-2);
}

.bf-list-editor__header {
  align-items: end;
  margin-bottom: 1px;
}

.bf-list-editor__heading {
  flex: 1;
  min-width: 0;
  padding: 0 6px 2px;
  color: var(--bf-color-text-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bf-list-editor__action-spacer {
  flex-shrink: 0;
  width: 28px;
}

.bf-list-editor__cell {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  font-size: 12px;
  font-family: var(--bf-font-mono, ui-monospace, monospace);
  background: var(--bf-color-surface);
  color: var(--bf-color-text);
}

.bf-list-editor__cell--select-field {
  padding: 0;
  border: 0;
  background: transparent;
}

.bf-list-editor__cell--select-field .bf-select-field-wrapper,
.bf-list-editor__cell--select-field .bf-select-field-trigger {
  width: 100%;
}

.bf-list-editor__cell:focus {
  outline: none;
  border-color: var(--bf-color-accent);
  box-shadow: 0 0 0 2px rgba(99,102,241,.1);
}

.bf-list-editor__cell[readonly] {
  background: var(--bf-color-surface-muted);
  color: var(--bf-color-text-muted);
}

.bf-list-editor__remove {
  flex-shrink: 0;
  padding: 2px 7px;
  background: none;
  border: 1px solid var(--bf-color-border-light);
  border-radius: var(--bf-radius-sm);
  color: var(--bf-color-text-subtle);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
}

.bf-list-editor__remove:hover {
  background: var(--bf-color-danger-soft);
  border-color: var(--bf-color-danger-border);
  color: var(--bf-color-danger);
}

.bf-list-editor__add {
  align-self: flex-start;
  padding: 3px 8px;
  background: none;
  border: 1px dashed var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  color: var(--bf-color-text-muted);
  cursor: pointer;
  font-size: 11px;
  margin-top: 2px;
}

.bf-list-editor__add:hover {
  border-color: var(--bf-color-accent);
  color: var(--bf-color-accent);
  background: #f5f3ff;
}

.bf-array-controls {
  display: inline-flex;
  align-items: center;
  gap: var(--bf-space-4);
  margin-top: 4px;
}

.bf-array-controls__summary {
  color: var(--bf-color-text-muted);
  font-size: 12px;
}

.bf-array-controls__delete {
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  background: var(--bf-color-surface);
  color: var(--bf-color-text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
  padding: 3px 8px;
  text-transform: none;
}

.bf-field label {
  display: block;
  font-size: 12px;
  color: var(--bf-color-text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.bf-field {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}

.bf-field input,
.bf-field textarea {
  width: 100%;
  max-width: 100%;
  padding: var(--bf-space-3) var(--bf-space-4);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  font-size: 14px;
  font-family: inherit;
}

/* Shared validation feedback (field-block + form-block). */
.bf-field-error {
  display: block;
  font-size: 12px;
  color: var(--bf-color-danger);
  margin-top: 3px;
}

.bf-field--invalid input,
.bf-field--invalid textarea {
  border-color: var(--bf-color-danger);
}

.bf-field--width-small input:not([type="checkbox"]),
.bf-field--width-small select,
.bf-field--width-small .bf-searchable-select {
  max-width: 140px;
}

.bf-field--width-medium input:not([type="checkbox"]),
.bf-field--width-medium select,
.bf-field--width-medium .bf-searchable-select {
  max-width: 320px;
}

.bf-field--width-large input:not([type="checkbox"]),
.bf-field--width-large select,
.bf-field--width-large .bf-searchable-select {
  max-width: 520px;
}

.bf-field--width-custom input:not([type="checkbox"]),
.bf-field--width-custom select,
.bf-field--width-custom .bf-searchable-select {
  max-width: var(--bf-field-width);
}

.bf-field--full input:not([type="checkbox"]),
.bf-field--full textarea,
.bf-field--full select,
.bf-field--full .bf-searchable-select {
  max-width: 100%;
}

.bf-form-layout-grid .bf-field--spanned:not(.bf-field--compact):not(.bf-field--width-custom) input:not([type="checkbox"]),
.bf-form-layout-grid .bf-field--spanned:not(.bf-field--compact):not(.bf-field--width-custom) select,
.bf-form-layout-grid .bf-field--spanned:not(.bf-field--compact):not(.bf-field--width-custom) .bf-searchable-select,
.bf-form-layout-auto-grid .bf-field--spanned:not(.bf-field--compact):not(.bf-field--width-custom) input:not([type="checkbox"]),
.bf-form-layout-auto-grid .bf-field--spanned:not(.bf-field--compact):not(.bf-field--width-custom) select,
.bf-form-layout-auto-grid .bf-field--spanned:not(.bf-field--compact):not(.bf-field--width-custom) .bf-searchable-select {
  max-width: 100%;
}

.bf-field--checkbox {
  display: grid;
  grid-template-columns: max-content max-content;
  align-items: center;
  column-gap: var(--bf-space-4);
}

.bf-form-layout-grid .bf-field--checkbox,
.bf-form-layout-auto-grid .bf-field--checkbox {
  align-content: start;
}

.bf-form-layout-grid .bf-field--checkbox-align-control,
.bf-form-layout-auto-grid .bf-field--checkbox-align-control {
  padding-top: 30px;
}

.bf-field--checkbox label {
  margin-bottom: 0;
  line-height: 1.2;
}

.bf-field--checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  max-width: none;
  padding: 0;
  margin: 0;
  justify-self: start;
}

.bf-field textarea {
  min-width: 100%;
  resize: vertical;
  overflow-y: hidden;
  line-height: 1.45;
  tab-size: 2;
}

.bf-field input:focus,
.bf-field textarea:focus {
  outline: none;
  border-color: var(--bf-color-primary);
  box-shadow: var(--bf-focus-ring);
}

.bf-field input[readonly],
.bf-field textarea[readonly] {
  background: var(--bf-color-surface-alt);
  color: var(--bf-color-text-muted);
  border-color: var(--bf-color-border);
  cursor: default;
}

/* field-blocks in a row container share width equally */
.bf-row > .bf-field {
  flex: 1;
  min-width: 0;
}

.bf-field .bf-field-display {
  width: 100%;
  padding: var(--bf-space-3) var(--bf-space-4);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  font-size: 14px;
  background: var(--bf-color-surface-alt);
  color: var(--bf-color-text-muted);
}

/* Nested bf-detail inside a modal panel or bf-detail wrapper */
.bf-modal-panel .bf-detail,
.bf-detail .bf-detail {
  border: none;
  background: transparent;
  padding: 0;
  min-width: 0;
  border-radius: 0;
}

.bf-field select {
  width: 100%;
  padding: 6px 28px 6px 8px;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  font-size: 14px;
  font-family: inherit;
  background-color: var(--bf-color-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  appearance: none;
  cursor: pointer;
}

.bf-field select:focus {
  outline: none;
  border-color: var(--bf-color-primary);
  box-shadow: var(--bf-focus-ring);
}

.bf-detail-actions {
  display: flex;
  gap: var(--bf-space-4);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--bf-color-border-light);
}

/* ============================================================
   Action Controls Block
   ============================================================ */

.bf-controls {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-3);
  padding: var(--bf-space-4);
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
}

.bf-controls-heading {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: var(--bf-space-4);
}

.bf-controls-title {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.3;
}

.bf-controls-subtitle {
  color: var(--bf-color-text-muted);
  font-size: 13px;
  line-height: 1.3;
}

.bf-controls-filters-row {
  flex-wrap: wrap;
  gap: var(--bf-space-3);
}

.bf-search-input {
  padding: 6px 10px;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  font-size: 14px;
  min-width: 200px;
}

.bf-search-input:focus {
  outline: none;
  border-color: var(--bf-color-primary);
}

/* ============================================================
   Buttons
   ============================================================ */

.bf-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--bf-space-2);
  padding: 6px 12px;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  background: var(--bf-color-surface);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.bf-btn:hover {
  background: var(--bf-color-surface-alt);
}

.bf-btn-primary {
  background: var(--bf-color-primary);
  color: var(--bf-color-surface);
  border-color: var(--bf-color-primary-hover);
}

.bf-btn-primary:hover {
  background: var(--bf-color-primary-hover);
}

.bf-btn-secondary {
  background: var(--bf-color-border-light);
  color: var(--bf-color-text);
  border-color: var(--bf-color-border);
}

.bf-btn-secondary:hover {
  background: var(--bf-color-border);
}

.bf-btn-danger {
  background: var(--bf-color-surface);
  color: var(--bf-color-danger);
  border-color: var(--bf-color-danger);
}

.bf-btn-danger:hover {
  background: var(--bf-color-danger-soft);
}

.bf-btn-link {
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--bf-color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bf-btn-link:hover {
  background: transparent;
  color: var(--bf-color-primary);
}

.bf-btn[hidden] {
  display: none;
}

.bf-form-actions,
.um-modal-actions {
  align-self: stretch;
  gap: clamp(12px, 2vw, 32px);
  justify-content: space-between;
  margin-top: 34px;
  max-width: none;
  width: 100%;
}

.bf-modal-body > .bf-form-actions:last-child,
.bf-modal-body > .um-modal-actions:last-child {
  align-self: stretch;
  margin-left: -18px;
  margin-right: -18px;
  margin-bottom: -18px;
  max-width: none;
  width: calc(100% + 36px);
}

.bf-modal-footer > .bf-form-actions,
.bf-modal-footer > .um-modal-actions {
  margin-top: 0;
}

.bf-form-actions > [data-block-id],
.um-modal-actions > [data-block-id] {
  display: flex;
  flex: 0 1 min(100%, 420px);
  min-width: 0;
}

.bf-form-actions > [data-block-id] > .bf-btn,
.um-modal-actions > [data-block-id] > .bf-btn,
.bf-form-actions > .bf-btn,
.um-modal-actions > .bf-btn {
  flex: 0 1 min(100%, 420px);
  justify-content: center;
  min-width: 0;
  min-height: 32px;
  width: 100%;
}

.bf-form-actions .bf-btn-danger,
.um-modal-actions .bf-btn-danger {
  background: var(--bf-color-danger-hover);
  color: var(--bf-color-surface);
  border-color: var(--bf-color-danger-hover);
}

.bf-form-actions .bf-btn-danger:hover,
.um-modal-actions .bf-btn-danger:hover {
  background: var(--bf-color-danger-hover);
  border-color: var(--bf-color-danger-hover);
}

/* ============================================================
   Config Menu Block
   ============================================================ */

.bf-config-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.bf-config-panel {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  box-shadow: var(--bf-shadow-md);
  padding: var(--bf-space-5);
  min-width: 240px;
  z-index: 100;
}

.bf-config-panel[hidden] {
  display: none;
}

.bf-config-section {
  margin-bottom: 12px;
}

.bf-config-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--bf-color-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.bf-config-option {
  display: flex;
  align-items: center;
  gap: var(--bf-space-4);
  padding: 4px 0;
  font-size: 13px;
}

.bf-config-column-width {
  flex: 0 0 auto;
  color: var(--bf-color-text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Resizable Containers
   ============================================================ */

.bf-resizable {
  position: relative;
}

.bf-resizable-y {
  padding-bottom: 8px;
}

.bf-resizable-x {
  padding-right: 8px;
}

.bf-resize-handle-y {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 8px;
  pointer-events: none;
}

.bf-resize-handle-y .bf-resize-handle-grip {
  pointer-events: auto;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 48px;
  transform: translateX(-50%);
  cursor: row-resize;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bf-resize-handle-y .bf-resize-handle-grip::after {
  content: '';
  width: 32px;
  border-top: 2px solid var(--bf-color-border);
}

.bf-resize-handle-y .bf-resize-handle-grip:hover::after,
.bf-container-resizing .bf-resize-handle-y .bf-resize-handle-grip::after {
  border-top-color: var(--bf-color-primary);
}

.bf-resize-handle-x {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 8px;
  pointer-events: none;
}

.bf-resize-handle-x .bf-resize-handle-grip {
  pointer-events: auto;
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 48px;
  transform: translateY(-50%);
  cursor: col-resize;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bf-resize-handle-x .bf-resize-handle-grip::after {
  content: '';
  height: 32px;
  border-left: 2px solid var(--bf-color-border);
}

.bf-resize-handle-x .bf-resize-handle-grip:hover::after,
.bf-container-resizing .bf-resize-handle-x .bf-resize-handle-grip::after {
  border-left-color: var(--bf-color-primary);
}

.bf-container-resizing {
  user-select: none;
}

.bf-container-resizing-y {
  cursor: row-resize;
}

.bf-container-resizing-x {
  cursor: col-resize;
}

/* ============================================================
   Sidebar Shell Helpers
   ============================================================ */

/* The sidebar shell is themed entirely from the --bf-nav-* palette tokens (light by
   default, dark under .bf-sidebar--dark). Independent of the tree's navigationMode —
   appearance is the sidebar's concern, route-driven highlighting is the tree's. */
.bf-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 14px;
  box-sizing: border-box;
  color: var(--bf-nav-text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.006) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.006) 1px, transparent 1px),
    var(--bf-nav-bg);
  background-size: 28px 28px;
  border-right: 1px solid var(--bf-nav-border);
  overflow: hidden;
  /* Crisp light-on-dark label text: default subpixel AA fattens/blurs it on the dark slate. */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.bf-sidebar .bf-select-field-label {
  color: var(--bf-nav-text-muted);
}

.bf-sidebar .bf-select-field-trigger {
  border-color: var(--bf-nav-control-border);
  background-color: var(--bf-nav-control-bg);
  color: var(--bf-nav-text-active);
  box-shadow: none;
}

.bf-sidebar .bf-select-field-trigger:hover {
  border-color: var(--bf-nav-control-border-hover);
  background-color: var(--bf-nav-control-bg-hover);
}

.bf-sidebar .bf-select-field-trigger:focus {
  border-color: var(--bf-color-primary);
  box-shadow: var(--bf-focus-ring);
}

.bf-sidebar .bf-select-field-trigger--empty {
  color: var(--bf-nav-text-muted);
}

.bf-sidebar .bf-select-field-clear {
  color: var(--bf-nav-text-muted);
}

.bf-sidebar .bf-select-field-clear:hover {
  color: var(--bf-nav-text-active);
}

.bf-sidebar > .bf-vertical-menu,
.bf-sidebar > .bf-tree {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  width: 100%;
  align-self: stretch;
  position: static;
  background: transparent;
  border-right: 0;
  padding-top: 0;
  overflow-y: auto;
}

/* Footer (e.g. version stamp): a thin accent rule, then the text tight to the sidebar's
   bottom-right. Negative margins bleed the rule full-width and pull it down past the
   sidebar's own padding so the stamp sits close to the corner. */
.bf-sidebar > .bf-sidebar-footer {
  flex: 0 0 auto;
  /* width:auto overrides the .bf-field width:100% so the negative margins actually widen
     the footer (bleed to the sidebar edges) instead of shifting it left. */
  width: auto;
  margin: auto -14px -16px;
  padding: 5px 6px 4px 0;
  border-top: 1px solid var(--bf-nav-accent);
  box-sizing: border-box;
}

.bf-sidebar > .bf-sidebar-footer .bf-field-display {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 11px;
  color: var(--bf-nav-text-muted);
  text-align: right;
  user-select: none;
  min-height: 1.2em;
}

.bf-chart-fill {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.bf-chart-fill canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Drag insertion indicators for column reorder rows */
.bf-config-draggable {
  border-radius: var(--bf-radius-sm);
  position: relative;
}

.bf-config-draggable.bf-config-over-before::before,
.bf-config-draggable.bf-config-over-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bf-color-primary);
  border-radius: var(--bf-radius-pill);
  pointer-events: none;
}

.bf-config-draggable.bf-config-over-before::before {
  top: -2px;
}

.bf-config-draggable.bf-config-over-after::after {
  bottom: -2px;
}

/* ============================================================
   Message Block
   ============================================================ */

.bf-messages {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-3);
}

.bf-message {
  display: flex;
  align-items: flex-start;
  gap: var(--bf-space-4);
  padding: var(--bf-space-4) var(--bf-space-5);
  border-radius: var(--bf-radius-md);
  font-size: 13px;
}

.bf-message.error {
  background: var(--bf-color-danger-soft);
  border: 1px solid var(--bf-color-danger-border);
  color: var(--bf-color-danger);
}

.bf-message.info {
  background: var(--bf-color-primary-soft);
  border: 1px solid var(--bf-color-primary-border);
  color: var(--bf-color-primary-hover);
}

.bf-message.success {
  background: var(--bf-color-success-soft);
  border: 1px solid var(--bf-color-success-border);
  color: var(--bf-color-success);
}

.bf-message-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
}

.bf-message-dismiss:hover {
  opacity: 1;
}

/* ============================================================
   Toolbar / App Shell
   ============================================================ */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
  gap: var(--bf-space-5);
}

.bf-toolbar {
  display: flex;
  align-items: center;
  gap: var(--bf-space-5);
  flex-wrap: wrap;
}

.um-toolbar {
  align-items: stretch;
}

.um-toolbar > [data-block-id] {
  display: flex;
}

.um-toolbar > [data-block-id] > .bf-btn {
  align-items: center;
  height: 100%;
}

[data-block-id="um-ui.container-invites-toolbar"].um-toolbar {
  flex-wrap: nowrap;
}

[data-block-id="um-ui.controls-invites"].bf-controls {
  flex-direction: row;
  align-items: center;
  gap: var(--bf-space-5);
}

[data-block-id="um-ui.controls-invites"] .bf-controls-title {
  margin: 0;
  white-space: nowrap;
}

.um-roles-add-form {
  align-items: flex-start;
  gap: 10px;
}

.um-roles-add-form > [data-block-id] {
  display: block;
  min-width: 0;
}

.um-roles-add-form > .bf-field {
  flex: 1 1 360px;
  margin-bottom: 0;
}

.um-toolbar.um-roles-add-form > [data-block-id]:has(> .bf-btn) {
  display: block;
  flex: 0 0 auto;
  padding-top: 22px;
}

.um-roles-add-form .bf-field label {
  display: block;
  margin-bottom: 4px;
  white-space: nowrap;
}

.um-toolbar.um-roles-add-form > [data-block-id] > .bf-btn {
  height: auto;
}

.um-password-section {
  margin-top: 18px;
}

.um-role-active-row,
.um-password-fields {
  align-items: flex-start;
  gap: var(--bf-space-5);
  width: 100%;
}

.um-role-active-row > [data-block-id],
.um-password-fields > [data-block-id] {
  flex: 1 1 0;
  min-width: 0;
}

.um-role-active-row > [data-block-id]:has(input[type="checkbox"]) {
  flex: 0 0 auto;
  padding-top: 22px;
}

.um-password-section .um-modal-actions {
  margin-top: 0;
}

.um-password-section .um-modal-actions > [data-block-id],
.um-password-section .um-modal-actions > [data-block-id] > .bf-btn {
  flex-basis: 100%;
  max-width: none;
}

.bf-main {
  display: flex;
  gap: var(--bf-space-5);
  flex: 1;
  min-height: 0;
}

/* ============================================================
   Header Block
   ============================================================ */

.bf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bf-space-6);
  min-height: 48px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--bf-color-border);
  background: var(--bf-color-primary-soft);
  flex-shrink: 0;
  margin: 0 -20px;
}

.bf-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--bf-color-text);
}

.bf-header-user {
  position: relative;
  display: flex;
  align-items: center;
}

.bf-header-user-button {
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  background: var(--bf-color-surface);
  color: var(--bf-color-text);
  font: inherit;
  font-size: 13px;
  padding: 6px 28px 6px 10px;
  cursor: pointer;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
}

.bf-header-user-button::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--bf-color-text-muted);
  transform: translateY(-40%);
}

.bf-header-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  box-shadow: var(--bf-shadow-lg);
  z-index: 300;
  overflow: hidden;
}

.bf-header-menu[hidden] {
  display: none;
}

.bf-header-menu-item {
  display: block;
  width: 100%;
  border: 0;
  background: var(--bf-color-surface);
  color: var(--bf-color-text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 9px 12px;
  cursor: pointer;
}

.bf-header-menu-item:hover,
.bf-header-menu-item:focus {
  background: var(--bf-color-surface-muted);
  outline: none;
}

/* ============================================================
   Tabbed UI Block
   ============================================================ */

.bf-tabbed-ui {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-5);
  min-width: 0;
}

.bf-tabbed-ui-tabs {
  display: flex;
  align-items: center;
  gap: var(--bf-space-2);
  border-bottom: 1px solid var(--bf-color-border);
  flex-wrap: wrap;
}

.bf-tabbed-ui-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--bf-space-4);
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--bf-radius-md) var(--bf-radius-md) 0 0;
  background: transparent;
  color: var(--bf-color-text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: var(--bf-space-4) var(--bf-space-5);
  min-height: 34px;
  cursor: pointer;
}

.bf-tabbed-ui-tab-label {
  min-width: 0;
}

.bf-tabbed-ui-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: var(--bf-radius-sm);
  color: var(--bf-color-text-muted);
  font-size: 12px;
  line-height: 1;
}

.bf-tabbed-ui-tab-close:hover {
  background: var(--bf-color-border-light);
  color: var(--bf-color-text);
}

.bf-tabbed-ui-tab:hover {
  background: var(--bf-color-surface-muted);
  color: var(--bf-color-text);
}

.bf-tabbed-ui-tab--active {
  background: var(--bf-color-surface);
  border-color: var(--bf-color-border);
  color: var(--bf-color-text);
  margin-bottom: -1px;
}

.bf-tabbed-ui-panels,
.bf-tabbed-ui-panel {
  min-width: 0;
}

.bf-tabbed-ui-panel[hidden] {
  display: none;
}

/* ============================================================
   Per-field Search Filters
   ============================================================ */

.bf-controls-row {
  display: flex;
  align-items: center;
  gap: var(--bf-space-4);
  flex-wrap: wrap;
}

.bf-search-group {
  display: flex;
  align-items: center;
  gap: var(--bf-space-3);
}

.bf-search-label {
  font-size: 12px;
  color: var(--bf-color-text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.bf-field-filter-group {
  display: flex;
  align-items: center;
  gap: var(--bf-space-2);
  background: var(--bf-color-surface-alt);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  padding: 3px 6px;
}

.bf-field-filter-label {
  font-size: 11px;
  color: var(--bf-color-text-subtle);
  white-space: nowrap;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.bf-filter-op {
  padding: 4px 4px;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  font-size: 12px;
  background: var(--bf-color-surface);
  cursor: pointer;
  max-width: 100px;
}

.bf-filter-value {
  padding: 5px 7px;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  font-size: 13px;
  width: 110px;
  font-family: inherit;
}

.bf-filter-value:focus {
  outline: none;
  border-color: var(--bf-color-primary);
  box-shadow: var(--bf-focus-ring);
}

.bf-filter-clear {
  padding: 3px 5px;
  font-size: 11px;
  line-height: 1;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  background: var(--bf-color-surface);
  cursor: pointer;
  color: var(--bf-color-text-subtle);
}
.bf-filter-clear:hover { color: var(--bf-color-danger); border-color: var(--bf-color-danger); }

/* "+ Filter" dropdown */
.bf-filter-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  box-shadow: var(--bf-shadow-md);
  z-index: 200;
  min-width: 140px;
  overflow: hidden;
}

.bf-filter-dropdown[hidden] { display: none; }

.bf-filter-dropdown-item {
  padding: var(--bf-space-4) var(--bf-space-5);
  font-size: 13px;
  cursor: pointer;
}
.bf-filter-dropdown-item:hover { background: var(--bf-color-surface-alt); }

.bf-filter-dropdown-empty {
  padding: var(--bf-space-4) var(--bf-space-5);
  font-size: 12px;
  color: var(--bf-color-text-subtle);
}

/* select-field-block — custom dropdown */
.bf-select-field {
  margin-bottom: 12px;
}
.bf-select-field-label {
  display: block;
  font-size: 12px;
  color: var(--bf-color-text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.bf-select-field-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--bf-space-2);
}
.bf-select-field-trigger {
  flex: 1;
  padding: 6px 28px 6px 8px;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  font-size: 14px;
  font-family: inherit;
  background-color: var(--bf-color-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  user-select: none;
  color: var(--bf-color-text);
  min-height: 32px;
  box-sizing: border-box;
}
.bf-select-field-trigger--empty { color: var(--bf-color-text-subtle); }
.bf-select-field-trigger:focus {
  outline: none;
  border-color: var(--bf-color-primary);
  box-shadow: var(--bf-focus-ring);
}
.bf-select-field-clear {
  background: none;
  border: none;
  color: var(--bf-color-text-subtle);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
.bf-select-field-clear:hover { color: var(--bf-color-text); }
.bf-select-field-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  box-shadow: var(--bf-shadow-md);
  z-index: 200;
  max-height: 240px;
  flex-direction: column;
}
.bf-select-field-dropdown:not([hidden]) { display: flex; }
.bf-select-field-search {
  border: none;
  border-bottom: 1px solid var(--bf-color-border-light);
  padding: var(--bf-space-3) var(--bf-space-4);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  flex-shrink: 0;
}
.bf-select-field-list {
  overflow-y: auto;
  flex: 1;
}
.bf-select-field-option {
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--bf-color-text);
  display: flex;
  align-items: center;
  gap: var(--bf-space-3);
}
.bf-select-field-option:hover { background: var(--bf-color-surface-alt); }
.bf-select-field-option--selected {
  background: var(--bf-color-primary-soft);
  font-weight: 500;
}
.bf-select-field-option-checkbox {
  flex-shrink: 0;
  pointer-events: none;
}
.bf-select-field-empty {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--bf-color-text-subtle);
}

/* Seamless extension of a .bf-detail card — no top border/radius, matching padding */
.bf-detail:has(+ .bf-form-extension) {
  border-bottom: none;
  border-radius: var(--bf-radius-md) var(--bf-radius-md) 0 0;
}
.bf-form-extension {
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-top: none;
  border-radius: 0 0 var(--bf-radius-md) var(--bf-radius-md);
  padding: 0 16px 12px;
  min-width: 280px;
}

/* ============================================================
   Vertical Menu Block
   ============================================================ */

.bf-vertical-menu {
  flex-shrink: 0;
  width: 200px;
  height: 100vh;
  background: var(--bf-color-surface);
  border-right: 1px solid var(--bf-color-border);
  padding: 8px 0;
  align-self: flex-start;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

.bf-menu-item {
  display: flex;
  align-items: center;
  gap: var(--bf-space-4);
  padding: var(--bf-space-4) var(--bf-space-6);
  font-size: 14px;
  color: var(--bf-color-text);
  user-select: none;
}

.bf-menu-item:hover {
  background: var(--bf-color-surface-alt);
}

.bf-menu-toggle {
  font-size: 10px;
  color: var(--bf-color-text-subtle);
  width: 12px;
  flex-shrink: 0;
}

.bf-menu-label {
  display: flex;
  align-items: center;
  gap: var(--bf-space-3);
  flex: 1;
  min-width: 0;
}

.bf-menu-item--active {
  background: var(--bf-color-primary-soft);
  color: var(--bf-color-primary-hover);
  font-weight: 500;
}

.bf-menu-children {
  padding-left: 20px;
}

.bf-menu-item-actions {
  display: flex;
  align-items: center;
  gap: var(--bf-space-1);
  opacity: 0;
  transition: opacity 0.1s;
}

.bf-menu-item:hover .bf-menu-item-actions {
  opacity: 1;
}

.bf-menu-item-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  border-radius: var(--bf-radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--bf-color-text-subtle);
  padding: 0;
  line-height: 1;
}

.bf-menu-item-action:hover {
  background: var(--bf-color-border);
  color: var(--bf-color-text);
}

/* ============================================================
   Tree Block
   ============================================================ */

.bf-tree {
  padding: 4px 0;
  overflow-y: auto;
}

.bf-tree-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--bf-space-4);
  padding: 5px 12px;
  font-size: 13px;
  color: var(--bf-color-text);
  user-select: none;
}

.bf-tree-item:hover {
  background: var(--bf-color-surface-alt);
}

.bf-tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--bf-color-text-subtle);
  width: 12px;
  flex-shrink: 0;
}

.bf-tree-label {
  display: flex;
  align-items: center;
  gap: var(--bf-space-3);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bf-tree-icon {
  flex: 0 0 auto;
}

.bf-tree-value {
  font-size: 12px;
  color: var(--bf-color-text-subtle);
  margin-left: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.bf-tree-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--bf-radius-pill);
  box-sizing: border-box;
  background: var(--bf-color-border-light);
  color: var(--bf-color-text);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  margin-left: auto;
  flex: 0 0 auto;
}

.bf-tree-badge--blue {
  background: var(--bf-color-primary);
  color: var(--bf-color-surface);
}

.bf-tree-badge--orange {
  background: var(--bf-color-warning);
  color: var(--bf-color-surface);
}

.bf-tree-badge--red {
  background: var(--bf-color-danger);
  color: var(--bf-color-surface);
}

.bf-tree-badge--green {
  background: var(--bf-color-success);
  color: var(--bf-color-surface);
}

.bf-tree-badge--slate {
  background: #64748b;
  color: var(--bf-color-surface);
}

.bf-tree-children {
  padding-left: 20px;
}

.bf-tree-item--active {
  background: var(--bf-color-primary-soft);
  color: var(--bf-color-primary-hover);
  font-weight: 500;
}

.bf-tree-item--selected {
  background: var(--bf-color-primary-soft);
  color: var(--bf-color-primary-hover);
}

.bf-tree-item-actions {
  display: flex;
  align-items: center;
  gap: var(--bf-space-1);
  opacity: 0;
  transition: opacity 0.1s;
  margin-left: auto;
}

.bf-tree-item:hover .bf-tree-item-actions {
  opacity: 1;
}

.bf-tree-dragging {
  opacity: 0.45;
}

.bf-tree-over-before {
  border-top: 2px solid var(--bf-color-primary);
}

.bf-tree-over-after {
  border-bottom: 2px solid var(--bf-color-primary);
}

.bf-tree-over-inside {
  background: var(--bf-color-primary-soft);
  outline: 1px solid var(--bf-color-primary);
}

.bf-tree-item-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  border-radius: var(--bf-radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--bf-color-text-subtle);
  padding: 0;
  line-height: 1;
}

.bf-tree-item-action:hover {
  background: var(--bf-color-border);
  color: var(--bf-color-text);
}

/* Sidebar "menu" chrome: applies to ANY tree placed directly in a .bf-sidebar, not
   just navigationMode trees. Colour comes from the --bf-nav-* tokens (themed by
   .bf-sidebar--dark); navigationMode only governs route-driven active highlighting. */
.bf-sidebar > .bf-tree {
  padding: 6px 0;
  color: var(--bf-nav-text);
  scrollbar-color: var(--bf-nav-border) transparent;
}

.bf-sidebar > .bf-tree .bf-tree-item {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: var(--bf-radius-lg);
  color: var(--bf-nav-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

.bf-sidebar > .bf-tree .bf-tree-item:hover {
  background: var(--bf-nav-item-hover);
  color: var(--bf-nav-text-active);
}

.bf-sidebar > .bf-tree .bf-tree-toggle {
  color: var(--bf-nav-text-subtle);
  width: 14px;
}

.bf-sidebar > .bf-tree .bf-tree-label {
  gap: var(--bf-space-5);
}

.bf-sidebar > .bf-tree .bf-tree-icon {
  width: 22px;
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--bf-nav-icon);
  font-size: 16px;
}

/* Icon-less rows collapse the gutter by default (all-text menus sit flush left),
   and only reserve the hidden gutter when the tree actually contains icons. */
.bf-sidebar > .bf-tree .bf-tree-icon--empty {
  display: none;
}

.bf-sidebar > .bf-tree.bf-tree--has-icons .bf-tree-icon--empty {
  display: inline-flex;
  visibility: hidden;
}

.bf-sidebar > .bf-tree .bf-tree-value {
  color: var(--bf-nav-text-muted);
}

.bf-sidebar > .bf-tree .bf-tree-children {
  padding-left: 18px;
}

.bf-sidebar > .bf-tree .bf-tree-item--active,
.bf-sidebar > .bf-tree .bf-tree-item--selected {
  background: var(--bf-nav-item-active);
  color: var(--bf-nav-text-active);
  font-weight: 700;
}

.bf-sidebar > .bf-tree .bf-tree-item--active::before,
.bf-sidebar > .bf-tree .bf-tree-item--selected::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: var(--bf-radius-pill);
  background: var(--bf-nav-accent);
}

.bf-sidebar > .bf-tree .bf-tree-item--active .bf-tree-icon,
.bf-sidebar > .bf-tree .bf-tree-item--selected .bf-tree-icon {
  color: var(--bf-nav-text-active);
}

.bf-sidebar > .bf-tree .bf-tree-item--role-section,
.bf-sidebar > .bf-tree .bf-tree-item--node-section {
  min-height: 24px;
  padding: 20px 12px 7px;
  color: var(--bf-nav-text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  cursor: default;
}

.bf-sidebar > .bf-tree .bf-tree-item--role-section:hover,
.bf-sidebar > .bf-tree .bf-tree-item--node-section:hover {
  background: transparent;
  color: var(--bf-nav-text-muted);
}

.bf-sidebar > .bf-tree .bf-tree-item--role-section .bf-tree-toggle,
.bf-sidebar > .bf-tree .bf-tree-item--node-section .bf-tree-toggle {
  display: none;
}

.bf-sidebar > .bf-tree .bf-tree-item-action {
  color: var(--bf-nav-text-muted);
}

.bf-sidebar > .bf-tree .bf-tree-item-action:hover {
  background: var(--bf-nav-control-bg);
  color: var(--bf-nav-text-active);
}

.bf-sidebar > .bf-tree .bf-tree-over-before {
  border-top-color: var(--bf-nav-accent);
}

.bf-sidebar > .bf-tree .bf-tree-over-after {
  border-bottom-color: var(--bf-nav-accent);
}

.bf-sidebar > .bf-tree .bf-tree-over-inside {
  background: color-mix(in srgb, var(--bf-nav-accent) 16%, transparent);
  outline-color: var(--bf-nav-accent);
}

/* ============================================================
   Graph Block
   ============================================================ */

.bf-graph {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 400px;
  background: var(--bf-color-surface-alt);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  cursor: grab;
}

.bf-graph:active {
  cursor: grabbing;
}

.bf-graph svg {
  display: block;
  width: 100%;
  height: 100%;
}

.bf-graph-edge {
  fill: none;
  stroke: var(--bf-color-border);
  stroke-width: 1.5;
}

.bf-graph-edge-label {
  font-size: 10px;
  fill: var(--bf-color-text-subtle);
  text-anchor: middle;
  pointer-events: none;
}

.bf-graph-node rect {
  opacity: 0.88;
  transition: opacity 0.1s;
}

.bf-graph-node:hover rect {
  opacity: 1;
}

.bf-graph-node--selected rect {
  opacity: 1;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.4));
}

.bf-graph-node-type {
  font-size: 9px;
  fill: rgba(255,255,255,0.75);
  text-anchor: middle;
  pointer-events: none;
}

.bf-graph-node-label {
  font-size: 12px;
  fill: var(--bf-color-surface);
  text-anchor: middle;
  font-weight: 500;
  pointer-events: none;
}

.bf-list .bf-list-footer-cell {
  font-weight: 600;
  border-top: 2px solid var(--bf-color-border);
  padding: var(--bf-space-3) var(--bf-space-4);
  background: var(--bf-color-surface-alt);
  color: var(--bf-color-text);
  white-space: normal;
  overflow: visible;
}

/* Pagination */
.bf-pagination {
  display: flex;
  align-items: center;
  gap: var(--bf-space-4);
  padding: var(--bf-space-4) var(--bf-space-5);
  border-top: 1px solid var(--bf-color-border-light);
  font-size: 13px;
  color: var(--bf-color-text-muted);
}

/* ============================================================
   Login Page
   ============================================================ */

/* ============================================================
   Sortable List Block
   ============================================================ */

.bf-sortable-list {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-2);
}

.bf-sortable-item {
  display: flex;
  align-items: center;
  gap: var(--bf-space-4);
  padding: var(--bf-space-3) var(--bf-space-4);
  border: 1px solid var(--bf-color-border-light);
  border-radius: var(--bf-radius-md);
  background: var(--bf-color-surface-alt);
  user-select: none;
}

.bf-sortable-item[draggable="true"] {
  cursor: default;
}

.bf-sortable-item.bf-sortable-dragging {
  opacity: 0.4;
}

.bf-sortable-item.bf-sortable-over-top {
  border-top: 2px solid var(--bf-color-primary);
}

.bf-sortable-item.bf-sortable-over-bottom {
  border-bottom: 2px solid var(--bf-color-primary);
}

.bf-sortable-item.bf-sortable-over-inside {
  border-color: var(--bf-color-primary);
  background: var(--bf-color-primary-soft);
}

.bf-sortable-handle {
  color: var(--bf-color-border);
  font-size: 14px;
  cursor: grab;
  flex-shrink: 0;
  line-height: 1;
}

.bf-sortable-handle:active {
  cursor: grabbing;
}

.bf-sortable-label {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bf-sortable-badge {
  font-size: 11px;
  color: var(--bf-color-text-subtle);
  background: var(--bf-color-surface-alt);
  padding: 2px 6px;
  border-radius: var(--bf-radius-xl);
  flex-shrink: 0;
}

.bf-sortable-item-actions {
  display: flex;
  align-items: center;
  gap: var(--bf-space-1);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.1s;
}

.bf-sortable-item:hover .bf-sortable-item-actions {
  opacity: 1;
}

.bf-sortable-action-danger {
  color: var(--bf-color-danger) !important;
}

.bf-sortable-action-danger:hover {
  background: var(--bf-color-danger-soft) !important;
}

/* ============================================================
   List Block — Editable Cells
   ============================================================ */

.bf-list-cell-editable {
  display: block;
  width: 100%;
  cursor: text;
  min-height: 20px;
}

.bf-list-cell-display {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bf-list-cell-editable .bf-list-cell-input {
  width: 100%;
  box-sizing: border-box;
  outline: none;
  border: 1px solid transparent;
  border-radius: var(--bf-radius-md);
  background: transparent;
  transition: border-color 0.1s, background 0.1s;
}

.bf-list-cell-editable .bf-list-cell-input:focus {
  outline: none;
  border-color: var(--bf-color-border);
  background: var(--bf-color-primary-soft);
}

/* ============================================================
   List Block — Row Detail Button
   ============================================================ */

.bf-list-detail-col {
  width: 28px;
  padding: 2px 0 !important;
  text-align: center;
}

.bf-list-detail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: var(--bf-radius-md);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  opacity: 1;
  transition: background 0.1s;
}

.bf-list-detail-btn:hover {
  background: var(--bf-color-success-soft);
}

/* ============================================================
   Login Page
   ============================================================ */

.bf-login-card {
  max-width: 360px;
  width: 100%;
  padding: 32px;
  background: var(--bf-color-surface);
  border-radius: var(--bf-radius-xl);
  box-shadow: var(--bf-shadow-md);
  display: flex;
  flex-direction: column;
}

.bf-login-title {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 600;
  color: var(--bf-color-text);
  text-align: center;
}

.bf-login-card .bf-btn {
  width: 100%;
  justify-content: center;
}

.ls-login-title {
  margin: 0 0 18px;
  color: var(--bf-color-text);
  font-size: 22px;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
}

.ls-login-card {
  width: 20vw;
  min-width: min(420px, calc(100vw - 32px));
  min-height: min(420px, calc(100vh - 32px));
  margin: auto;
  align-self: center;
  justify-content: center;
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border-light);
  border-radius: var(--bf-radius-xl);
  box-shadow: var(--bf-shadow-lg);
  padding: 40px;
}

.ls-login-primary {
  width: 100%;
  justify-content: center;
}

.ls-login-secondary-actions {
  gap: 10px;
  margin-top: 18px;
  align-items: center;
}

.ls-login-secondary {
  width: auto;
  justify-content: center;
}

.ls-user-settings-actions {
  width: 100%;
  justify-content: stretch;
}

.ls-user-settings-actions > [data-block-id] {
  width: 100%;
}

.ls-user-settings-primary {
  width: 100%;
  justify-content: center;
}

/* ============================================================
   upload-block
   ============================================================ */

.bf-upload-block {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-4);
  padding: 12px 0;
}

.bf-upload-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bf-upload-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--bf-color-text);
  flex: 1;
}

.bf-upload-choose-btn {
  font-size: 12px;
  padding: 4px 12px;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-md);
  background: var(--bf-color-surface);
  color: var(--bf-color-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.bf-upload-choose-btn:hover {
  background: var(--bf-color-surface-muted);
  border-color: var(--bf-color-text-subtle);
}

.bf-upload-dropzone {
  border: 2px dashed var(--bf-color-border);
  border-radius: var(--bf-radius-lg);
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--bf-color-text-subtle);
  background: var(--bf-color-surface-alt);
  transition: border-color 0.15s, background 0.15s;
  cursor: default;
}
.bf-upload-dropzone.bf-upload-drag-over {
  border-color: var(--bf-color-primary);
  background: var(--bf-color-primary-soft);
  color: var(--bf-color-primary);
}
.bf-upload-dropzone.bf-upload-loading {
  opacity: 0.6;
  pointer-events: none;
}

.bf-upload-file-list {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-3);
}

.bf-upload-empty {
  font-size: 12px;
  color: var(--bf-color-text-subtle);
  padding: 4px 0;
}

.bf-upload-file-item {
  display: flex;
  align-items: center;
  gap: var(--bf-space-4);
  padding: var(--bf-space-3) var(--bf-space-4);
  border: 1px solid var(--bf-color-border-light);
  border-radius: var(--bf-radius-lg);
  background: var(--bf-color-surface);
  font-size: 12px;
}

.bf-upload-file-preview {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--bf-color-text-muted);
}

.bf-upload-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--bf-radius-sm);
  display: block;
}

.bf-upload-file-icon {
  display: flex;
  align-items: center;
  color: var(--bf-color-text-subtle);
}

.bf-upload-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--bf-color-text);
}

.bf-upload-file-size {
  flex-shrink: 0;
  color: var(--bf-color-text-subtle);
  white-space: nowrap;
}

.bf-upload-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--bf-color-text-subtle);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: var(--bf-radius-sm);
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.bf-upload-remove:hover {
  color: var(--bf-color-danger);
  background: var(--bf-color-danger-soft);
}

.bf-upload-status {
  font-size: 12px;
  color: var(--bf-color-text-muted);
  min-height: 16px;
}
.bf-upload-status-error {
  color: var(--bf-color-danger);
}

/* ============================================================
   file-list-block
   ============================================================ */

.bf-file-list-block {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-4);
}

.bf-fl-header {
  font-weight: 600;
  font-size: 13px;
  color: var(--bf-color-text);
}

.bf-fl-empty {
  font-size: 12px;
  color: var(--bf-color-text-subtle);
}

.bf-fl-list {
  display: flex;
  flex-direction: column;
  gap: var(--bf-space-2);
}

/* thumbnail grid */
.bf-fl-thumbnails {
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--bf-space-4);
}

.bf-fl-thumb-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--bf-space-2);
  text-decoration: none;
  color: var(--bf-color-text);
  width: 80px;
}

.bf-fl-thumb-preview {
  width: 72px;
  height: 72px;
  border: 1px solid var(--bf-color-border-light);
  border-radius: var(--bf-radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bf-color-surface-muted);
  flex-shrink: 0;
}

.bf-fl-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bf-fl-file-icon {
  color: var(--bf-color-text-subtle);
}

.bf-fl-thumb-name {
  font-size: 11px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 72px;
  color: var(--bf-color-text-muted);
}

/* link list */
.bf-fl-links {
  flex-direction: column;
}

.bf-fl-list-item {
  display: flex;
  align-items: center;
  gap: var(--bf-space-3);
  font-size: 12px;
  color: var(--bf-color-primary);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 1px solid var(--bf-color-surface-muted);
}
.bf-fl-list-item:hover {
  text-decoration: underline;
}
.bf-fl-list-item:last-child {
  border-bottom: none;
}

.bf-fl-list-icon {
  flex-shrink: 0;
  color: var(--bf-color-text-subtle);
  display: flex;
  align-items: center;
}

.bf-fl-list-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bf-fl-list-size {
  flex-shrink: 0;
  color: var(--bf-color-text-subtle);
}

/* auto: thumbnails section followed by links section */
.bf-fl-auto {
  gap: var(--bf-space-5);
}

/* thumbnail renderer used in list-block columns */
.bf-list-thumbnail {
  max-width: 48px;
  max-height: 48px;
  object-fit: cover;
  border-radius: var(--bf-radius-sm);
  vertical-align: middle;
  display: inline-block;
}
