/* Cockpit chassis: sticky changelist headers + column-manager UI.
   Loaded on EVERY admin page via UNFOLD["STYLES"]. Loads BEFORE unfold's own
   styles.css, so every rule here uses an id or a project-owned class — that
   specificity beats single Tailwind utilities regardless of order.

   Sticky mechanism: the changelist's overflow-x wrapper becomes the vertical
   scroller too (viewport-bounded max-height), which is the only way sticky
   headers can work inside an overflow-x-auto container. column_manager.js
   refines --ib-chrome's fallback with a measured height at load/resize.
   Pure CSS: headers stick even if all project JS fails. */

div:has(> table#result_list),
.ib-sticky {
  max-height: calc(100vh - var(--ib-chrome, 220px));
  max-height: calc(100dvh - var(--ib-chrome, 220px));
  overflow-y: auto;
}

#result_list thead th,
.ib-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 30; /* over rows and unfold's z-30 section rows; under pagination (40) and action bar (50) */
  background-color: #fff;
  box-shadow: inset 0 -1px 0 var(--color-base-200, #e5e7eb); /* divider that survives sticking */
}
.dark #result_list thead th {
  background-color: var(--color-base-900, #131720);
  box-shadow: inset 0 -1px 0 var(--color-base-800, #262b36);
}
.ib-sticky thead th { background-color: var(--color-base-50, #f9fafb); }
.dark .ib-sticky thead th { background-color: var(--color-base-900, #131720); }

/* ---- column manager + change notes: STRUCTURAL GLUE ONLY (UI-4 6b) ----
   Cosmetics (buttons, panel surface, inputs, segmented toggle, toast,
   section labels) now come from the component library — the JS emits
   ib-* classes alongside these hooks. Only positioning, layout and
   widget-specific affordances remain here, on ramp tokens. */

.cm-slot { margin-left: auto; position: relative; display: inline-flex; align-items: center; }
.cm-bar  { display: flex; justify-content: flex-end; margin-bottom: .5rem; position: relative; }

.cm-pop.ib-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  min-width: 16rem; max-height: 60vh; overflow-y: auto; padding: .375rem;
}
.cm-pop ul { list-style: none; margin: 0; padding: 0; }
.cm-pop li {
  display: flex; align-items: center; gap: .5rem;
  padding: .25rem .375rem; border-radius: .375rem; font-size: .8125rem;
  color: var(--ib-ink-gray-7);
}
.cm-pop li:hover { background: var(--ib-alpha-gray-2); }
.cm-pop li.cm-dragging { opacity: .4; }
.cm-grip { cursor: grab; color: var(--ib-ink-gray-4); user-select: none; }
.cm-pop label {
  flex: 1 1 auto; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cm-move { border: 0; background: none; cursor: pointer; color: var(--ib-ink-gray-4); padding: 0 .125rem; font-size: .75rem; }
.cm-move:hover { color: var(--ib-ink-gray-7); }
.cm-foot {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  margin-top: .375rem; padding-top: .375rem;
  border-top: 1px solid var(--ib-outline-gray-1);
}
.cm-reset { border: 0; background: none; color: var(--color-primary-600, #1d5cf5); cursor: pointer; font-size: .75rem; font-weight: 500; }
.cm-hint { font-size: .6875rem; color: var(--ib-ink-gray-4); }

/* change notes: fixed placement + fab pill shape (double-class selector
   outranks the later-loading .ib-btn radius) */
.cn-fab.ib-btn {
  position: fixed; right: 18px; bottom: 88px; z-index: 50;
  border-radius: 9999px;
  box-shadow: var(--ib-elevation-md);
}
.cn-panel.ib-panel {
  position: fixed; right: 18px; bottom: 134px; z-index: 50;
  width: 320px; padding: 12px;
}
.cn-label { margin-bottom: 6px; }
.cn-err { margin-top: 6px; }
.cn-row { display: flex; gap: 8px; margin-top: 8px; }
.cn-kind { margin-bottom: 8px; display: flex; }
.cn-kind > button { flex: 1; }

/* T5/H1: saved views section inside the Columns popover */
.cm-views { margin-top: .375rem; padding-top: .375rem; border-top: 1px solid var(--ib-outline-gray-1); }
.cm-views-head { margin-bottom: .25rem; }
.cm-views-list { list-style: none; margin: 0 0 .25rem; padding: 0; }
.cm-view { display: flex; align-items: center; gap: .5rem; padding: .2rem .375rem; border-radius: .375rem; font-size: .8125rem; }
.cm-view:hover { background: var(--ib-alpha-gray-2); }
.cm-view a { flex: 1 1 auto; color: var(--color-primary-600, #1d5cf5); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-view a:hover { text-decoration: underline; }
.cm-view-del { border: 0; background: none; cursor: pointer; color: var(--ib-ink-gray-4); font-size: .75rem; }
.cm-view-del:hover { color: var(--ib-ink-red); }
.cm-view-empty { font-size: .75rem; color: var(--ib-ink-gray-4); padding: .2rem .375rem; }
.cm-view-save { border: 0; background: none; color: var(--color-primary-600, #1d5cf5); cursor: pointer; font-size: .75rem; font-weight: 500; padding: .2rem .375rem; }

/* T6: dashboard block drag handles (visible in edit mode only) */
.ib-dash-handle {
  cursor: grab; user-select: none; font-size: .6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--color-base-400, #9ca3af); margin-bottom: .375rem;
}
.ib-dash-handle:active { cursor: grabbing; }
[x-cloak] { display: none !important; }

/* ---- inline tables read as the SAME table as every changelist ----------- */
/* chassis rule (Philip 2026-08-25): one table look system-wide. unfold's
   tabular inlines get changelist-height rows, matching header treatment,
   row hover, and no leftover stripe where the per-row title was. */
.inline-group table.formset thead th {
  background-color: var(--color-base-50, #f9fafb);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.dark .inline-group table.formset thead th {
  background-color: var(--color-base-900, #131720);
}
.inline-group table.formset td.field-tabular {
  min-height: 0;
  padding-top: .5rem;
  padding-bottom: .5rem;
}
.inline-group table.formset tbody.original:hover tr.form-row {
  background-color: var(--color-base-50, #f9fafb);
}
.dark .inline-group table.formset tbody.original:hover tr.form-row {
  background-color: rgba(255, 255, 255, .02);
}
/* show_title=False leaves the title tr holding only hidden pk/fk inputs —
   collapse it entirely so no empty stripe remains */
.inline-group tbody.original > tr:first-child:not(.form-row) > td[colspan] {
  padding: 0;
  border: 0;
  height: 0;
}

/* U2: .ib-table moved into the component library (assets/cockpit-tw.css,
 * UI-4 stage 3) — retokenised on the Espresso ramp, same class names. */

/* U2b record-page chassis moved into the component library (UI-4 stage
 * 8) — retokenised on the Espresso ramp; .ib-card record-summary variant
 * renamed .ib-stat there to end the double definition. */

/* Helpdesk + shared component styles moved to the token build
   (assets/cockpit-tw.css -> brain/tw.css, @layer components) — UI-2. */
