/* ---------- tokens ---------- */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --border: #e2e6ea;
  --border-strong: #ccd2d9;
  --text: #1b2024;
  --text-muted: #6a737d;
  --text-dim: #a4acb5;
  --accent: #2f7d4f;
  --accent-soft: #e8f4ec;
  --warn: #9a5b00;
  --warn-soft: #fdf3e2;
  --danger: #a52a2a;
  --selected: #e8f0fe;
  --row-height: 30px;
  /* Rewritten in place by the diff's hover handler via CSSOM - see EventDiffSection.js. */
  --diff-crosshair: #eef2f6;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --radius: 5px;
}

/* Provider-type palette. One hue per omnibug-engine provider type, so a scan down the list reads
   all Marketing hits as one visual class without reading a word. Chosen for legibility as tinted
   chips on a light surface; iterate freely, nothing depends on the specific hues. */
.provider-chip--analytics { --chip-fg: #1d4ed8; --chip-bg: #dfe9fe; }
.provider-chip--marketing { --chip-fg: #92500e; --chip-bg: #fdefd3; }
.provider-chip--tagmanager { --chip-fg: #6d28d9; --chip-bg: #ece5fe; }
.provider-chip--visitorid { --chip-fg: #0f766e; --chip-bg: #d3f5f0; }
.provider-chip--testing { --chip-fg: #a21caf; --chip-bg: #fbe3fb; }
.provider-chip--customer { --chip-fg: #15803d; --chip-bg: #dcf5e3; }
.provider-chip--replay { --chip-fg: #4338ca; --chip-bg: #e2e5fd; }
.provider-chip--unknown { --chip-fg: #5b6470; --chip-bg: #e8ebee; }
.dist--analytics { --chip-bg: #dfe9fe; }
.dist--marketing { --chip-bg: #fdefd3; }
.dist--tagmanager { --chip-bg: #ece5fe; }
.dist--visitorid { --chip-bg: #d3f5f0; }
.dist--testing { --chip-bg: #fbe3fb; }
.dist--customer { --chip-bg: #dcf5e3; }
.dist--replay { --chip-bg: #e2e5fd; }
.dist--unknown { --chip-bg: #e8ebee; }

* { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body.is-resizing { cursor: col-resize; user-select: none; }

.app { display: flex; height: 100%; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 208px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 120ms ease;
}
.sidebar.is-collapsed { width: 48px; }
.sidebar__brand {
  display: flex; align-items: center; justify-content: space-between;
  height: 44px; padding: 0 8px 0 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar__title { font-weight: 600; font-size: 13px; letter-spacing: 0.2px; }
.sidebar__collapse {
  border: 0; background: none; cursor: pointer; color: var(--text-muted);
  padding: 4px 6px; border-radius: var(--radius); font-size: 12px;
}
.sidebar__collapse:hover { background: var(--bg); color: var(--text); }
.sidebar__list { list-style: none; margin: 6px 0 0; padding: 0 6px; }
.sidebar__item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: 0; background: none; cursor: pointer; text-align: left;
  padding: 7px 8px; border-radius: var(--radius); color: var(--text-muted); font-size: 13px;
}
.sidebar__item:hover { background: var(--bg); color: var(--text); }
.sidebar__item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar__icon { width: 16px; text-align: center; flex-shrink: 0; }
.sidebar__label { flex: 1; white-space: nowrap; overflow: hidden; }
.sidebar__badge {
  font-variant-numeric: tabular-nums; font-size: 11px;
  background: var(--bg); color: var(--text-muted); padding: 1px 6px; border-radius: 9px;
}
.sidebar__item.is-active .sidebar__badge { background: #fff; color: var(--accent); }

/* User chip, pinned to the bottom. margin-top:auto rather than flex:1 on the list above it, so the
   nav keeps its natural height and nothing needs to know this footer exists. */
.sidebar__user {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.sidebar.is-collapsed .sidebar__user { flex-direction: column; gap: 6px; padding: 8px 4px; }
.sidebar__user-info { display: flex; align-items: baseline; gap: 6px; min-width: 0; flex: 1; }
.sidebar__user-name {
  font-size: 12px; color: var(--text); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__user-tag {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.4px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent); padding: 1px 5px; border-radius: 3px;
}
/* Initials, for the 48px rail. Same footprint as a nav icon so the rail stays a single column. */
.sidebar__avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  font-size: 10px; font-weight: 600; letter-spacing: 0.3px;
}
.sidebar__logout-form { margin: 0; display: flex; }
.sidebar__logout {
  border: 0; background: none; cursor: pointer; color: var(--text-muted);
  font: inherit; font-size: 11.5px; padding: 3px 6px; border-radius: var(--radius);
}
.sidebar__logout:hover { background: var(--bg); color: var(--text); }

/* ---------- buttons & primitives ---------- */
.btn {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 5px 11px; border-radius: var(--radius); cursor: pointer; font-size: 12px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn--ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn--danger { color: var(--danger); border-color: transparent; }
.btn--danger:hover:not(:disabled) { background: #fdeaea; border-color: #f3caca; }
.link-btn {
  border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent);
  font-size: 11.5px; text-decoration: underline; text-underline-offset: 2px; font-family: inherit;
}
.copy-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  font-size: 10.5px; padding: 1px 6px; border-radius: 3px; cursor: pointer; font-family: inherit;
}
.copy-btn:hover { color: var(--text); background: var(--bg); }
.copy-btn--done { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.hint { color: var(--text-muted); font-size: 11.5px; margin: 5px 0 0; }
.error-text { color: var(--danger); }
.warn-text { color: var(--warn); }
.wrap-anywhere { overflow-wrap: anywhere; }
code { font-family: var(--mono); font-size: 11.5px; }

.provider-chip {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: middle;
  color: var(--chip-fg); background: var(--chip-bg);
  padding: 1px 7px; border-radius: 10px; font-size: 11.5px; font-weight: 600;
}
.provider-chip--unrecognized { font-weight: 500; font-style: italic; }

.badge { padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; cursor: help; }
.badge--warn { color: var(--warn); background: var(--warn-soft); }
.badge--info { color: #1d4ed8; background: #dfe9fe; }
.badge--custom { color: #6d28d9; background: #ece5fe; }

.chip-tag {
  display: inline-block;
  margin-left: 5px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.12);
  font-weight: 700;
  vertical-align: middle;
}

.spinner { display: flex; align-items: center; gap: 8px; color: var(--text-muted); padding: 14px; }
.spinner__dot {
  width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- popovers & menus ---------- */
.popover { position: relative; display: inline-block; }
.popover__backdrop { position: fixed; inset: 0; z-index: 40; }
.popover__panel {
  position: absolute; top: calc(100% + 4px); z-index: 41;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 6px; box-shadow: 0 8px 24px rgba(20, 26, 33, 0.14);
  min-width: 210px; max-height: 60vh; overflow: auto;
}
.popover__panel--left { left: 0; }
.popover__panel--right { right: 0; }
.menu { padding: 4px; display: flex; flex-direction: column; }
.menu--values { min-width: 260px; }
.menu__item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 0; background: none; cursor: pointer; text-align: left; font: inherit;
  padding: 6px 8px; border-radius: var(--radius); color: var(--text);
}
.menu__item:hover { background: var(--bg); }
.menu__count { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 11px; }
.menu__back { border: 0; background: none; cursor: pointer; color: var(--text-muted); font: inherit; padding: 6px 8px; text-align: left; }
.menu__back:hover { color: var(--text); }
.menu__empty { color: var(--text-muted); padding: 8px; margin: 0; font-size: 12px; }
.menu__check { display: flex; align-items: center; gap: 7px; padding: 5px 8px; cursor: pointer; border-radius: var(--radius); }
.menu__check:hover { background: var(--bg); }
.menu--daterange { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.menu__field { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--text-muted); }
.menu__field input {
  font: inherit; font-size: 12.5px; color: var(--text);
  padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius);
}

/* ---------- filter bar ---------- */
.explorer { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.filterbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 8px 12px; display: flex; flex-direction: column; gap: 7px; flex-shrink: 0;
}
.filterbar__row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filterbar__row--chips { gap: 6px; }
.filterbar__row--results { border-top: 1px solid var(--border); padding-top: 7px; }
.filterbar__spacer { flex: 1; }
.search {
  flex: 1; min-width: 240px; padding: 6px 10px; font: inherit;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-alt);
}
.search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: var(--surface); }
.switch { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.switch input { cursor: pointer; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-soft); color: #1d5c39; border: 1px solid #c6e2d1;
  padding: 2px 4px 2px 9px; border-radius: 11px; font-size: 11.5px; max-width: 320px;
}
.chip__x { border: 0; background: none; cursor: pointer; color: #4b7c60; font-size: 14px; line-height: 1; padding: 0 4px; }
.chip__x:hover { color: var(--danger); }
.new-pill {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  padding: 4px 11px; border-radius: 12px; cursor: pointer; font-size: 12px; font-weight: 600; font-family: inherit;
}
.result-count { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.distribution { display: flex; gap: 5px; flex-wrap: wrap; }
.dist {
  position: relative; overflow: hidden; border: 1px solid var(--border);
  background: var(--surface-alt); border-radius: var(--radius); cursor: pointer;
  padding: 3px 8px; font: inherit; font-size: 11.5px; display: flex; align-items: center; gap: 7px;
}
.dist:disabled { cursor: default; }
.dist:hover:not(:disabled) { border-color: var(--border-strong); }
.dist.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.dist__bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--chip-bg); z-index: 0; }
.dist__label, .dist__count { position: relative; z-index: 1; }
.dist__count { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- split ---------- */
.split { flex: 1; display: flex; min-height: 0; }
.split__list { flex-shrink: 0; min-width: 0; display: flex; }
.split__handle { width: 5px; cursor: col-resize; background: var(--border); flex-shrink: 0; }
.split__handle:hover { background: var(--accent); }
.split__detail { flex: 1; min-width: 0; background: var(--surface); border-left: 1px solid var(--border); overflow: auto; }

/* ---------- event list ---------- */
.list { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.list__head {
  display: grid; align-items: stretch; flex-shrink: 0;
  border-bottom: 1px solid var(--border-strong); background: var(--surface-alt);
}
.list__th {
  border: 0; background: none; font: inherit; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted);
  text-align: left; padding: 6px 8px; cursor: default; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.list__th.is-sortable { cursor: pointer; }
/* Non-sortable headers use aria-disabled, not disabled, so they still surface their title tooltip -
   the cursor is what tells you they are not clickable. */
.list__th:not(.is-sortable) { cursor: default; }
.list__th.is-sortable:hover { color: var(--text); background: var(--bg); }
.list__th.is-sorted { color: var(--accent); }
.sort-arrow { margin-left: 3px; }
.list__viewport { flex: 1; overflow: auto; }
.list__row {
  display: grid; align-items: center; cursor: pointer;
  border-bottom: 1px solid #f0f2f4;
}
.list__row:hover { background: var(--surface-alt); }
.list__row.is-selected { background: var(--selected); box-shadow: inset 2px 0 0 var(--accent); }
.list__empty { padding: 24px; }
.cell {
  padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;
}
.cell--num { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.cell--mono { font-family: var(--mono); font-size: 11.5px; }
.cell--endpoint { font-size: 12px; }
.endpoint__host { color: var(--text); }
.endpoint__path { color: var(--text-muted); }

/* ---------- detail pane ---------- */
.detail { display: flex; flex-direction: column; min-height: 100%; }
.detail--empty { align-items: center; justify-content: center; padding: 32px; text-align: center; }
.detail__head {
  position: sticky; top: 0; z-index: 5; background: var(--surface);
  border-bottom: 1px solid var(--border); padding: 10px 14px 0;
}
.detail__title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail__spacer { flex: 1; }
.request-type { font-size: 14px; font-weight: 600; }
.detail__facts {
  display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 9px 0 0;
}
.detail__facts > div { display: flex; flex-direction: column; gap: 1px; }
.detail__facts dt {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-dim);
}
.detail__facts dd { margin: 0; font-size: 12px; display: flex; align-items: center; gap: 5px; }
.tabs { display: flex; gap: 2px; margin-top: 10px; }
.tab {
  border: 0; border-bottom: 2px solid transparent; background: none; font: inherit;
  padding: 6px 12px; cursor: pointer; color: var(--text-muted); font-size: 12.5px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-body { padding: 12px 14px 24px; }

/* ---------- collapsible sections ---------- */
.collapsible { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; background: var(--surface); }
.collapsible--subdued { background: var(--surface-alt); border-style: dashed; }
.collapsible__head { display: flex; align-items: center; gap: 8px; padding-right: 8px; }
.collapsible__toggle {
  flex: 1; display: flex; align-items: center; gap: 7px;
  border: 0; background: none; font: inherit; cursor: pointer; text-align: left; padding: 7px 10px;
}
.collapsible__caret { color: var(--text-dim); transition: transform 100ms ease; display: inline-block; }
.collapsible__caret.is-open { transform: rotate(90deg); }
.collapsible__title { font-weight: 600; font-size: 12.5px; }
.collapsible--subdued .collapsible__title { font-weight: 500; color: var(--text-muted); }
.collapsible__count {
  font-size: 11px; color: var(--text-muted); background: var(--bg);
  padding: 0 6px; border-radius: 9px; font-variant-numeric: tabular-nums;
}
.collapsible__body { padding: 0 10px 9px; }

/* ---------- param tables ---------- */
.param-filter { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.param-filter input {
  flex: 1; padding: 5px 9px; font: inherit; font-size: 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.param-filter__count { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; }
.param-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.param-table td { padding: 5px 6px; vertical-align: top; border-top: 1px solid #f0f2f4; }
.param-table tr:first-child td { border-top: 0; }
.param-field { width: 38%; }
.param-field__label { display: block; font-weight: 600; font-size: 12px; }
.param-field__key { display: block; color: var(--text-dim); font-size: 11px; }
.param-field__key--only { color: var(--text-muted); font-size: 12px; }
.param-value { min-width: 0; }
.param-value__text {
  font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere;
  max-height: 3.9em; overflow: hidden;
}
.param-value__text.is-expanded { max-height: none; }
.param-value--empty { color: var(--text-dim); font-style: italic; font-family: inherit; }
.param-value__tools { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.param-value__json {
  margin: 6px 0 0; padding: 8px; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius); font-family: var(--mono); font-size: 11px;
  max-height: 340px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
.nested-params { margin-top: 6px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.nested-params__base {
  padding: 4px 8px; background: var(--surface-alt); border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 11px; color: var(--text-muted); overflow-wrap: anywhere;
}
.nested-params__table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.nested-params__table td { padding: 3px 8px; border-top: 1px solid #f2f4f6; vertical-align: top; }
.nested-params__key { width: 34%; }
.nested-params__val { font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; }

/* ---------- raw tab ---------- */
.raw-block {
  font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; white-space: pre-wrap;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px;
}
.raw-block--scroll { max-height: 420px; overflow: auto; }
.raw-sub { margin-top: 7px; }

/* ---------- metadata tab ---------- */
.meta-row { display: flex; gap: 12px; padding: 5px 0; border-top: 1px solid #f0f2f4; align-items: baseline; }
.meta-row:first-child { border-top: 0; }
.meta-row__label { width: 34%; flex-shrink: 0; color: var(--text-muted); font-size: 12px; }
.meta-row__hint { display: block; color: var(--text-dim); font-size: 10.5px; }
.meta-row__value { flex: 1; min-width: 0; font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.meta-row__value > table { flex: 1 0 100%; }
.sibling-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; flex: 1 0 100%; }
.sibling-chip {
  border: 1px solid var(--border-strong); background: var(--surface); font: inherit; font-size: 11px;
  padding: 2px 7px; border-radius: 10px; cursor: pointer; max-width: 210px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sibling-chip:hover { background: var(--bg); }
.sibling-chip.is-current { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- empty states ---------- */
.empty { padding: 28px 20px; max-width: 520px; }
.empty h3 { margin: 0 0 7px; font-size: 14px; }
.empty p { margin: 0 0 10px; color: var(--text-muted); }
.empty__actions { display: flex; gap: 8px; margin-bottom: 8px; }

/* ---------- sections (sessions / import / rules) ---------- */
.section-pad { padding: 16px 20px 40px; overflow: auto; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2, .section-head h3 { margin: 0; font-size: 15px; }
.section-pad > h2 { margin: 0 0 12px; font-size: 15px; }
.section-subhead { margin: 26px 0 10px; font-size: 13px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 14px; margin-bottom: 12px;
}
.card--form { display: flex; flex-direction: column; gap: 9px; max-width: 460px; }
.card label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--text-muted); }
.card input, .card textarea, .card select, .import-assign input, .import-assign select {
  font: inherit; font-size: 12.5px; color: var(--text);
  padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.card__title { margin: 0 0 3px; font-size: 13.5px; }
.card__sub { margin: 0 0 6px; color: var(--text-muted); font-size: 12px; }
.card__desc { margin: 0 0 9px; font-size: 12px; }
.card__stats { display: flex; gap: 18px; margin: 0 0 11px; }
.card__stats dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-dim); }
.card__stats dd { margin: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.card__actions { display: flex; gap: 7px; flex-wrap: wrap; }
.session-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }

.source-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.source {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 6px;
  padding: 9px 12px; cursor: pointer; font: inherit; text-align: left;
  display: flex; flex-direction: column; gap: 2px; min-width: 180px;
}
.source:hover:not(:disabled) { border-color: var(--accent); }
.source.is-active { border-color: var(--accent); background: var(--accent-soft); }
.source.is-stub { opacity: 0.55; cursor: not-allowed; }
.source__label { font-weight: 600; font-size: 12.5px; }
.source__hint { color: var(--text-muted); font-size: 11px; }
.file-label { cursor: pointer; }
.import-assign { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.import-assign label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--text-muted); }

.preview { max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.preview__table, .history { width: 100%; border-collapse: collapse; font-size: 12px; }
.preview__table th, .history th {
  position: sticky; top: 0; background: var(--surface-alt); text-align: left;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted);
  padding: 6px 8px; border-bottom: 1px solid var(--border-strong);
}
.preview__table td, .history td { padding: 4px 8px; border-top: 1px solid #f0f2f4; }
.preview__table tr.is-selected { background: var(--selected); }
.preview__endpoint, .history__detail {
  max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 11px;
}
.history { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }

/* ---------- event diff ---------- */
/* A grid rather than a table: bands wrap their sections in collapsibles, which a single <table>
   cannot contain, and fixed track widths keep every section's rows aligned with the one header
   row above them without a shared <colgroup>. */
.diff { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.diff__controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 12px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.diff__param-filter {
  flex: 0 1 260px; padding: 4px 8px; font: inherit; font-size: 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.diff__banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 6px 12px; font-size: 11.5px; border-bottom: 1px solid var(--border); background: var(--surface-alt);
  flex-shrink: 0;
}

.diff__scroll { overflow: auto; flex: 1; min-height: 0; padding-bottom: 40px; }
.diff__grid {
  /* --diff-n is set inline from the column count. */
  --diff-param-w: 260px;
  --diff-col-w: 150px;
  width: max-content; min-width: 100%; font-size: 11.5px;
}

.diff__row {
  display: grid;
  grid-template-columns: var(--diff-param-w) repeat(var(--diff-n), var(--diff-col-w));
  width: max-content;
  border-top: 1px solid #f0f2f4;
}
.diff__row:hover { background: var(--surface-alt); }

/* Sticky in both axes. The header must outrank the parameter column at the crossing point, or the
   top-left corner scrolls out from under itself. */
.diff__head {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface); border-bottom: 1px solid var(--border-strong); border-top: 0;
}
.diff__head:hover { background: var(--surface); }
.diff__param {
  position: sticky; left: 0; z-index: 2;
  display: flex; align-items: flex-start; gap: 4px;
  background: inherit; border-right: 1px solid var(--border);
  padding: 3px 6px; min-width: 0;
}
.diff__row:not(.diff__head) .diff__param { background: var(--surface); }
.diff__row:not(.diff__head):hover .diff__param { background: var(--surface-alt); }
.diff__head .diff__param {
  z-index: 4; align-items: flex-end;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted);
}

.diff__param-main {
  flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 0;
  font: inherit; cursor: pointer; color: inherit;
}
.diff__param-label { display: block; font-weight: 600; }
.diff__param-key { display: block; color: var(--text-dim); font-family: var(--mono); font-size: 10.5px; }
.diff__param-key--only { color: var(--text-muted); font-size: 11px; }
.diff__param-expand, .diff__param-hide {
  border: 0; background: none; cursor: pointer; color: var(--text-dim);
  padding: 0 2px; font: inherit; line-height: 1; opacity: 0;
}
.diff__row:hover .diff__param-expand, .diff__row:hover .diff__param-hide { opacity: 1; }
.diff__param-expand:hover, .diff__param-hide:hover { color: var(--text); }
/* An expanded row keeps its control visible - otherwise the only way back is to guess where it was. */
.diff__param-expand:not(:only-of-type), .diff__row--wrap .diff__param-expand { opacity: 1; }

.diff__cell {
  padding: 3px 6px; border-left: 1px solid #f0f2f4; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 11px;
}
/* Clicking the parameter cell wraps the whole row, which is the only way to read a 400-character
   `dl` without a popover per cell. */
.diff__row--wrap .diff__cell { white-space: pre-wrap; word-break: break-all; }
.diff__row--child .diff__param { padding-left: 20px; }
.diff__row--child .diff__param-key { color: var(--text-muted); }

/* Four states, deliberately distinguishable at a glance rather than by reading:
   value / present-but-empty / absent (tinted, so gaps read as shapes) / out-of-band (grey). */
.diff__cell--empty { color: var(--text-dim); font-style: italic; font-family: inherit; }
.diff__cell--absent { background: #fdf6ec; }
.diff__cell--oob { background: repeating-linear-gradient(45deg, #f4f5f7 0 4px, #eff1f3 4px 8px); }
.diff__cell--changed { box-shadow: inset 3px 0 0 var(--accent); background: var(--accent-soft); }
.diff__cell--absent.diff__cell--changed { background: #fbe9d8; }

.diff__col { padding: 4px 6px; border-left: 1px solid var(--border); min-width: 0; }
.diff__col-top { display: flex; align-items: center; gap: 3px; }
.diff__col-index { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-muted); font-size: 10.5px; }
.diff__col-link, .diff__col-hide {
  border: 0; background: none; cursor: pointer; color: var(--text-dim); padding: 0 1px; font: inherit; line-height: 1;
}
.diff__col-link { margin-left: auto; }
.diff__col-link:hover, .diff__col-hide:hover { color: var(--text); }
.diff__col-type { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff__col-time { color: var(--text-muted); font-family: var(--mono); font-size: 10.5px; }
.diff__col-delta { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 10.5px; }
.diff__col-label {
  margin-top: 2px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Band titles and section headers stay pinned to the left edge: at fifty columns they would
   otherwise scroll away and leave unlabelled rows behind. */
.diff__band { margin-top: 10px; }
.diff__band-title {
  position: sticky; left: 0; width: max-content;
  display: flex; align-items: baseline; gap: 8px;
  padding: 4px 10px; font-weight: 600; font-size: 12px;
}
.diff__band-count { color: var(--text-dim); font-weight: 400; font-size: 11px; }
.diff__band-empty { position: sticky; left: 0; width: max-content; padding: 0 10px 8px; font-size: 11.5px; }
.diff__section .collapsible { margin: 0 0 4px; border-radius: 0; border-left: 0; border-right: 0; }
.diff__section .collapsible__head { position: sticky; left: 0; width: max-content; }
.diff__section .collapsible__body { padding: 0; }

.menu__search {
  margin: 2px 4px 6px; padding: 4px 7px; font: inherit; font-size: 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.menu__item.is-selected { background: var(--accent-soft); color: var(--accent); }

/* ---------- login page ---------- */
/* A separate document from the app, so none of the .app / .sidebar layout applies here. */
.login {
  max-width: 340px;
  margin: 12vh auto 0;
  padding: 0 20px 40px;
}
.login__title { margin: 0; font-size: 19px; letter-spacing: 0.2px; }
.login__sub { margin: 4px 0 22px; color: var(--text-muted); font-size: 13px; }
.login__error {
  margin: 0 0 16px; padding: 8px 11px; font-size: 12.5px;
  color: var(--danger); background: #fdeaea; border: 1px solid #f3caca;
  border-radius: var(--radius);
}
.login__form { display: flex; flex-direction: column; gap: 13px; }
.login__form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11.5px; color: var(--text-muted);
}
.login__form input {
  font: inherit; font-size: 13px; padding: 7px 9px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.login__form input:focus { outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent); }
.login__submit {
  margin-top: 4px; padding: 8px 11px; font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: #fff;
}
.login__submit:hover { filter: brightness(1.08); }
.login__note { margin: 24px 0 0; color: var(--text-dim); font-size: 11.5px; line-height: 1.5; }

/* ---------- admin section ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.admin-table th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-dim); font-weight: 600; padding: 0 10px 6px 0;
  border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
/* Dimmed rather than hidden: a disabled user still owns sessions, and their row is where you go to
   re-enable them. */
.admin-table tr.is-disabled td { opacity: 0.6; }
.admin-table__actions-head, .admin-table__actions { text-align: right; white-space: nowrap; }
.admin-table__actions { display: table-cell; }
.admin-table__reset td { background: var(--surface-alt); }
.admin-reset { display: flex; align-items: flex-end; gap: 9px; flex-wrap: wrap; padding: 4px 0; }
.admin-reset label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--text-muted); }
.admin-reset input {
  font: inherit; font-size: 12.5px; padding: 5px 8px; min-width: 240px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.admin-reset .hint { flex-basis: 100%; margin: 0; }
