/* Events page. Industrial look: dense monospace data, flat controls, hairline rules.
   Colours come from the theme tokens defined on :root in app.css. */

:root {
  --ev-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --ev-rule: var(--border-subtle, #1f1f1f);
  --ev-rule-strong: #2c2c2c;
  --ev-accent: #f59e0b;
  --ev-head: #101010;
}

/* ---------- Header and toolbar ---------- */

.events-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.events-title {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.events-header h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.events-count {
  margin-left: auto;
  font-family: var(--ev-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-main, #e5e5e5);
  white-space: nowrap;
}

.events-count .count-label {
  color: var(--text-muted, #7a7a7a);
}

/* Timeline: one bar per part of the time range, above the table */
.timeline-toggle.is-on {
  color: var(--text-main);
  border-color: var(--border-focus);
  background: var(--bg-surface-hover);
}

.timeline-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.7rem 0.9rem 0.6rem;
  margin-bottom: 0.9rem;
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  font-family: var(--ev-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.timeline-title {
  color: var(--text-main);
}

.timeline-chart {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  grid-template-rows: 7.5rem auto;
  column-gap: 0.5rem;
  transition: opacity 0.15s ease;
}

.timeline-chart.is-loading {
  opacity: 0.6;
}

.timeline-yaxis {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  font-family: var(--ev-mono);
  font-size: 0.66rem;
  line-height: 1;
  color: var(--text-subtle);
  padding: 0.1rem 0;
}

.timeline-plot {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  min-width: 0;
}

.timeline-gridline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--border-subtle);
  pointer-events: none;
}

.timeline-gridline.is-base {
  border-top: 1px solid var(--border-focus);
}

.timeline-bars {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 2px;
}

.timeline-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  border-radius: 3px 3px 0 0;
}

.timeline-col.is-hover {
  background: var(--bg-surface-hover);
}

.timeline-bar {
  width: 100%;
  background: var(--chart-green);
  border-radius: 3px 3px 0 0;
  transition: height 0.25s ease;
}

.timeline-xlabels {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
  font-family: var(--ev-mono);
  font-size: 0.66rem;
  color: var(--text-subtle);
}

.timeline-tip {
  position: absolute;
  top: 0;
  z-index: 2;
  padding: 0.35rem 0.55rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-focus);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  font-family: var(--ev-mono);
  font-size: 0.7rem;
  color: var(--text-main);
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(8px);
}

.timeline-tip.is-flip {
  transform: translateX(calc(-100% - 8px));
}

.timeline-tip-range {
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.timeline-error {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--chart-red);
}

@media (max-width: 640px) {
  .timeline-chart {
    grid-template-columns: 2.75rem minmax(0, 1fr);
  }
}

.events-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.toolbar-end {
  margin-left: auto;
}

.toolbar-group label {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #7a7a7a);
}

.toolbar-group select {
  margin: 0;
  width: auto;
  min-width: 9rem;
  font-size: 0.8rem;
}

/* Flat tool buttons used in the toolbar and pager */
.tool-btn {
  margin: 0;
  padding: 0.3rem 0.7rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--ev-rule-strong);
  border-radius: 2px;
  color: var(--text-main, #e5e5e5);
}

.tool-btn:hover:not([disabled]) {
  border-color: var(--text-main, #e5e5e5);
  background: transparent;
}

.tool-btn[disabled] {
  opacity: 0.35;
}

.tool-btn span {
  font-family: var(--ev-mono);
  color: var(--ev-accent);
  text-transform: none;
  letter-spacing: 0;
}

.events-error {
  color: var(--chart-red, #ef4444);
  border: 1px solid var(--chart-red-dim, rgba(239, 68, 68, 0.18));
  padding: 0.5rem 0.75rem;
  border-radius: 2px;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
}

.muted {
  color: var(--text-muted, #7a7a7a);
  font-size: 0.8rem;
}

/* ---------- Filter badges ---------- */

.filter-bar {
  align-items: center;
  justify-content: flex-start;
  min-height: 2rem;
}

.filter-bar .toolbar-group {
  flex: 0 0 auto;
}

.filter-clear {
  order: 3;
  margin-left: auto;
}

.filter-chips {
  order: 2;
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.3rem 0.2rem 0.55rem;
  border: 1px solid var(--ev-rule-strong);
  border-left: 2px solid var(--ev-accent);
  border-radius: 2px;
  background: var(--bg-surface-elevated, #141414);
  font-family: var(--ev-mono);
  font-size: 0.75rem;
  max-width: 100%;
}

.filter-chip.raw {
  border-left-color: var(--text-muted, #7a7a7a);
}

.filter-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-chip button {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted, #7a7a7a);
  line-height: 1;
}

.filter-remove {
  font-size: 0.95rem;
  padding: 0 0.2rem !important;
}

.filter-eye {
  display: inline-flex;
  opacity: 0;
  transition: opacity 0.15s;
}

.filter-chip:hover .filter-eye,
.filter-chip.disabled .filter-eye {
  opacity: 1;
}

.filter-eye:hover {
  color: var(--text-main, #e5e5e5) !important;
}

.filter-chip.disabled {
  opacity: 0.45;
  text-decoration: line-through;
}

.filter-chip.filter-editing {
  gap: 0.25rem;
  text-decoration: none;
  padding: 0.25rem;
  flex-wrap: wrap;
}

.filter-edit-fields {
  display: inline-flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.filter-chip.filter-editing input,
.filter-chip.filter-editing select,
.filter-chip.filter-editing textarea {
  margin: 0;
  width: auto;
  min-width: 6rem;
  height: 1.8rem;
  padding: 0.1rem 0.4rem;
  font-family: var(--ev-mono);
  font-size: 0.75rem;
}

.filter-chip.filter-editing textarea {
  min-width: 18rem;
  height: auto;
}

.filter-chip.filter-editing button {
  margin: 0;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
}

.filter-slot {
  display: contents;
}

/* ---------- Table ---------- */

/* The frame draws the border. The header is a sticky box in the page flow; the body scrolls
   sideways only, and the header is moved to match it. */
.table-frame {
  position: relative;
  border: 1px solid var(--ev-rule);
  border-radius: 2px;
  background: var(--bg-surface, #0b0b0b);
}

.events-head {
  position: sticky;
  top: 0;
  z-index: 3;
  overflow: hidden;
  background: var(--ev-head);
  border-radius: 2px 2px 0 0;
}

.events-table-wrap {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
}

.events-table {
  width: 100%;
  margin: 0;
  font-family: var(--ev-mono);
  font-size: 0.74rem;
  white-space: nowrap;
  border-collapse: collapse;
}

.events-table th,
.events-table td {
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid var(--ev-rule);
  text-align: left;
  vertical-align: middle;
}

.events-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--ev-head);
  color: var(--text-muted, #7a7a7a);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--ev-rule-strong);
}

.events-table thead th:hover {
  color: var(--text-main, #e5e5e5);
}

.sort-mark {
  color: var(--ev-accent);
  margin-left: 0.25rem;
}

.events-table tbody tr {
  transition: background 0.1s;
}

.events-table tbody tr:hover {
  background: var(--bg-surface-hover, #1a1a1a);
}

.events-table tbody tr:hover td:first-child {
  box-shadow: inset 2px 0 0 var(--ev-accent);
}

.events-table .cell {
  position: relative;
  max-width: 24rem;
  overflow: hidden;
}

.events-table .cell-text {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* Country flag before a country code. Sized to the cell text and outlined so pale flags stay visible */
.events-table .cell-flag {
  margin-right: 0.4em;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(127, 127, 127, 0.35);
}


/* Events that involve a critical asset: a red tint and a bar on the left edge */
.events-table tbody tr.row-critical td {
  background: rgba(220, 38, 38, 0.1);
}
.events-table tbody tr.row-critical td:first-child {
  box-shadow: inset 3px 0 0 #dc2626;
}

/* Severity text: uppercase, coloured by level. Low is muted, medium is normal, high yellow, critical red */
.events-table .cell-text.is-severity {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.events-table .cell-text.sev-low { color: var(--text-muted, #a3a3a3); }
.events-table .cell-text.sev-medium { color: var(--text-main, #e5e5e5); }
.events-table .cell-text.sev-high { color: #eab308; }
.events-table .cell-text.sev-critical { color: #ef4444; }

/* Alert severity: high is yellow, medium is the normal row, low is muted */
.events-table tbody tr.row-high td {
  background: rgba(234, 179, 8, 0.16);
}
.events-table tbody tr.row-low td {
  opacity: 0.55;
}

/* Header drag: a line on the side the column will land on. An inset shadow stays inside
   the header, so the neighbouring header and the clipped header row do not hide it. */
.events-table thead th.dragging {
  opacity: 0.35;
}
.events-table thead th.drop-before {
  box-shadow: inset 3px 0 0 var(--ev-accent);
}
.events-table thead th.drop-after {
  box-shadow: inset -3px 0 0 var(--ev-accent);
}

/* Numbers read best right-aligned with tabular digits; times are muted */
.events-table .col-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.events-table .col-time {
  color: var(--text-muted, #a3a3a3);
}

.cell-actions {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.15rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(24, 24, 24, 0.5);
  backdrop-filter: blur(14px) saturate(170%);
  -webkit-backdrop-filter: blur(14px) saturate(170%);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-50%) scale(0.94);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

/* Appear after a short hover delay, so passing over a cell does not flicker the bar */
.cell:hover .cell-actions {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
  transition-delay: 0.12s;
}

.cell-actions button {
  margin: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  line-height: 1;
  font-size: 0.85rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-main, #e5e5e5);
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.cell-actions button:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--ev-accent);
  transform: scale(1.12);
  transition-delay: 0.1s;
}

.row-action {
  text-align: right;
  width: 1%;
}

.details-btn {
  margin: 0;
  padding: 0.2rem 0.55rem;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--ev-rule-strong);
  border-radius: 2px;
  color: var(--text-main, #e5e5e5);
}

.details-btn:hover {
  border-color: var(--ev-accent);
  color: var(--ev-accent);
}

/* The empty message fills about five rows of the table, with the text centred both ways */
.events-table td.empty-row {
  text-align: center;
  vertical-align: middle;
  color: var(--text-muted, #7a7a7a);
  height: 10.5rem;
  padding: 0 1rem;
}

/* ---------- Pager ---------- */

.events-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  font-family: var(--ev-mono);
  font-size: 0.72rem;
  color: var(--text-muted, #7a7a7a);
}

.pager-buttons {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.pager-page {
  padding: 0 0.4rem;
  color: var(--text-main, #e5e5e5);
}

.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.66rem;
}

.pager-size select {
  margin: 0;
  width: auto;
  min-width: 5rem;
  padding: 0.2rem 0.4rem;
  font-family: var(--ev-mono);
  font-size: 0.72rem;
}

/* ---------- Flyouts ---------- */

.flyout-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

.flyout {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(600px, 100%);
  max-width: 100%;
  background: var(--bg-surface, #0b0b0b);
  border-left: 1px solid var(--ev-rule-strong);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.flyout-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ev-rule);
}

.flyout-header h3 {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.flyout-header button {
  margin: 0;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
}

.flyout-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid var(--ev-rule);
}

.flyout-tabs button {
  margin: 0 0 -1px;
  padding: 0.35rem 0.8rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 2px 2px 0 0;
}

.flyout-body {
  flex: 1;
  overflow: auto;
  padding: 0.9rem 1rem 1rem;
}

/* Filters flyout: labelled sections divided by hairline rules */

.fl-section {
  padding-bottom: 1.1rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--ev-rule);
}

.fl-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

.fl-title {
  margin: 0 0 0.6rem;
  font-family: var(--ev-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted, #7a7a7a);
}

.fl-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.fl-title-row .fl-title {
  margin-bottom: 0.6rem;
}

.fl-count {
  margin-left: 0.35rem;
  color: var(--ev-accent);
}

.fl-clear {
  margin: 0 0 0.6rem;
}

.fl-empty {
  margin: 0;
  font-size: 0.78rem;
}

.fl-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8rem minmax(0, 1.3fr) auto;
  gap: 0.5rem;
  align-items: end; /* the button lines up with the inputs, below their labels */
}

.fl-field {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  min-width: 0;
}

.fl-field > span {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #7a7a7a);
}

/* The type of the chosen field, on its own line below the field, operator and value row */
.fl-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.66rem;
  color: var(--text-muted, #7a7a7a);
}

.fl-field input,
.fl-field select,
.fl-save input {
  margin: 0;
  min-width: 0;
  height: 2.1rem;
  font-family: var(--ev-mono);
  font-size: 0.78rem;
}

.fl-submit {
  margin: 0;
  height: 2.1rem;
  font-size: 0.7rem !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.5rem 1rem !important;
}

.fl-raw {
  margin: 0 0 0.6rem;
  font-family: var(--ev-mono);
  font-size: 0.78rem;
  line-height: 1.5;
}

.flyout-raw textarea,
.sql-editor {
  margin: 0;
  font-family: var(--ev-mono);
  font-size: 0.78rem;
  line-height: 1.5;
}

.flyout-actions button {
  margin: 0;
  font-size: 0.72rem;
}

/* Decoded and Base64 views for a payload in the analysis tab */
.body-views {
  display: flex;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.view-switch {
  position: sticky;
  top: -0.9rem;
  z-index: 2;
  display: flex;
  gap: 0.35rem;
  margin: -0.9rem -1rem 0.7rem;
  padding: 0.9rem 1rem 0.5rem;
  background: var(--bg-surface, #0b0b0b);
}

.body-views .pill-btn,
.view-switch .pill-btn {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.25rem 0.6rem !important;
  border-radius: 2px !important;
  font-size: 0.64rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Body tab label: BODY and the number of bodies, the number in the accent colour */
.body-tab-count {
  color: var(--ev-accent, #f59e0b);
  font-weight: 700;
}

/* The buttons are links: they keep the button look and never show a link underline */
.body-views .pill-btn,
.body-views .pill-btn:hover,
.body-views .pill-btn:focus-visible {
  text-decoration: none;
}

.body-views .pill-btn.active,
.view-switch .pill-btn.active {
  border-color: var(--text-main, #e5e5e5);
}

/* Details flyout: Key and Value columns. The filter buttons sit at the right of the key. */
.detail-table {
  width: 100%;
  table-layout: fixed;
  margin: 0;
  border-collapse: collapse;
  font-family: var(--ev-mono);
  font-size: 0.76rem;
}

.detail-table tr,
.detail-table th,
.detail-table td {
  background: transparent;
}

.detail-table th,
.detail-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--ev-rule);
  text-align: left;
  vertical-align: middle;
  word-break: break-all;
  transition: background-color 0.08s linear;
}

/* Row hover covers every cell, the key column included */
.detail-table tbody tr:hover td {
  background: var(--bg-surface-hover, #1f1f1f);
}

.detail-table thead th {
  padding-top: 0;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #7a7a7a);
}

.detail-table .dt-key {
  color: var(--text-muted, #7a7a7a);
  word-break: normal;
  overflow-wrap: anywhere;
}

.detail-table .dt-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Same translucent pill as the table's cell actions, always visible */
.detail-table .filter-btns {
  display: inline-flex;
  flex-shrink: 0;
  gap: 0.1rem;
  padding: 0.12rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(24, 24, 24, 0.5);
}

.detail-table .filter-btns .cell-btn {
  display: grid !important;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0 !important;
  margin: 0 !important;
  transform: none !important;
  line-height: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-main, #e5e5e5);
}

.detail-table .filter-btns .cell-btn svg {
  display: block;
}

.detail-table .filter-btns .cell-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--ev-accent);
}

.flyout-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.filter-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  margin-top: 1rem;
}

.filter-list .filter-chip {
  max-width: 100%;
}

/* Columns flyout */
.column-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.35rem;
}

.column-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--ev-rule);
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--ev-mono);
  font-size: 0.74rem;
}

.column-option input {
  margin: 0;
  width: auto;
}

.column-option.on {
  border-color: var(--ev-rule-strong);
  border-left: 2px solid var(--ev-accent);
}

.column-option .column-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.column-option .column-type {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #7a7a7a);
}

/* SQL tab */
.sql-editor {
  width: 100%;
  box-sizing: border-box;
}

/* Details flyout */
.flyout-body dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 0.9rem;
  margin: 0;
  font-family: var(--ev-mono);
  font-size: 0.76rem;
}

.flyout-body dt {
  color: var(--text-muted, #7a7a7a);
}

.flyout-body dd {
  margin: 0;
  word-break: break-all;
}

.flyout-body pre {
  margin: 0;
  font-family: var(--ev-mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-all;
}

@media (max-width: 640px) {
  .toolbar-group select {
    width: 100%;
  }
}

/* ---------- Header and toolbar buttons ---------- */

.th-tool {
  margin: 0;
  padding: 0.25rem 0.55rem;
  font-family: var(--ev-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--ev-rule-strong);
  border-radius: 2px;
  color: var(--text-muted, #7a7a7a);
  white-space: nowrap;
}

.th-tool span {
  color: var(--ev-accent);
}

.th-tool:hover {
  color: var(--text-main, #e5e5e5);
  border-color: var(--text-main, #e5e5e5);
}

.tool-range {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  text-transform: none;
  letter-spacing: 0;
}

.range-caption {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted, #7a7a7a);
}

.range-value {
  font-family: var(--ev-mono);
  font-size: 0.74rem;
  color: var(--ev-accent);
}

/* ---------- Time range flyout: the Filters flyout's sections, fields and buttons ---------- */

.range-now {
  color: var(--text-main, #e5e5e5);
  font-family: var(--ev-mono);
}

/* Presets: outlined mono buttons; the selected range is solid, like the primary action */
.range-presets {
  display: grid;
  /* Filled down each column in duration order, so the list reads top to bottom */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(6, auto);
  grid-auto-flow: column;
  gap: 0.4rem;
}

.range-presets button {
  margin: 0;
  padding: 0.4rem 0.6rem !important;
  border: 1px solid var(--ev-rule-strong) !important;
  border-radius: 2px !important;
  background: transparent !important;
  color: var(--text-main, #e5e5e5) !important;
  font-family: var(--ev-mono);
  font-size: 0.68rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: none;
}

.range-presets button:hover {
  border-color: var(--text-main, #e5e5e5) !important;
}

.range-presets button:not(.secondary) {
  background: var(--text-main, #e5e5e5) !important;
  border-color: var(--text-main, #e5e5e5) !important;
  color: var(--bg-base, #000) !important;
}

/* An amount and its unit, or a date and time, side by side */
/* The custom amount and unit under a block of presets */
.range-custom {
  margin-top: 0.75rem;
}

.range-add {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

/* The To section's Now switch sits on the title row, so it takes its own width */
.fl-switch.range-now-switch {
  width: auto !important;
  gap: 0.5rem;
  margin-left: auto;
  padding: 0.35rem 0 0.45rem; /* flush with the right edge of the section */
}

.range-now-switch > span {
  font-family: var(--ev-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted, #7a7a7a);
}

/* Space between the To heading row and the rule below it */
.range-to-head {
  padding-bottom: 0.35rem;
}

/* Space between the rule under the To section and the Apply button; the button spans the flyout */
.range-apply {
  padding-top: 0.35rem;
}

.range-apply button {
  width: 100%;
}

/* Fixed at the bottom of the flyout: what is shown, and the timezone note */
.range-footer {
  flex: none;
  padding: 0.7rem 1rem 0.9rem;
  border-top: 1px solid var(--ev-rule);
}

.range-footer p {
  margin: 0;
  text-align: center;
}



/* History: one row per applied range, newest first */
.range-history {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.range-history-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.6rem !important;
  border: 1px solid var(--ev-rule-strong) !important;
  border-radius: 2px !important;
  background: transparent !important;
  color: var(--text-main, #e5e5e5) !important;
  font-family: var(--ev-mono);
  font-size: 0.74rem !important;
  text-align: left;
  box-shadow: none;
}

.range-history-item:hover {
  border-color: var(--text-main, #e5e5e5) !important;
}

.range-history-item.is-current {
  border-left: 2px solid var(--ev-accent) !important;
}

.range-history-at {
  flex: none;
  font-size: 0.66rem;
  color: var(--text-muted, #7a7a7a);
  white-space: nowrap;
}

/* Pico's select padding pushes the mono text to the bottom edge of the fixed height */
.range-add select {
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  line-height: 1.4;
}

/* ---------- Flyout motion ---------- */

@keyframes flyout-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes flyout-out {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes backdrop-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.flyout {
  animation: flyout-in 260ms cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.flyout.is-leaving {
  animation: flyout-out 200ms cubic-bezier(0.4, 0, 1, 1) both;
}

.flyout-backdrop {
  animation: backdrop-in 200ms ease-out both;
}

.flyout-backdrop.is-leaving {
  animation: backdrop-out 200ms ease-in both;
}

@media (prefers-reduced-motion: reduce) {
  .flyout,
  .flyout.is-leaving,
  .flyout-backdrop,
  .flyout-backdrop.is-leaving,
  .cell-actions,
  .cell:hover .cell-actions {
    animation-duration: 1ms;
    transition-duration: 1ms;
    transition-delay: 0ms;
  }
}

/* Plain underlined text link, used for Columns in the table header */
.link-btn {
  margin: 0 !important;
  padding: 0 !important;
  background: none;
  border: 0;
  border-radius: 0 !important;
  /* Same type as the other column headers. The global button rule is !important, so these are too. */
  font-family: var(--ev-mono) !important;
  font-size: 0.66rem !important;
  font-weight: 600 !important;
  line-height: inherit !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
  color: var(--text-muted, #7a7a7a);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--text-main, #e5e5e5);
}

/* Top nav brand and the console card on the dashboard */
.nav-brand {
  align-self: center;
  margin-right: 1.25rem;
  font-family: var(--ev-mono);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ev-accent);
}

.console-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.console-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

/* Header actions: Filters and the time range, with small icons */
.events-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tool-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.tool-icon svg {
  flex: none;
}

/* Details flyout: a handle on the left edge drags the width */
.flyout-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  width: 8px;
  cursor: ew-resize;
  touch-action: none;
  z-index: 1;
}

.flyout-resizer:hover,
.flyout-resizer:focus-visible,
.flyout-resizer:active {
  background: var(--ev-rule-strong);
  outline: none;
}

@media (max-width: 640px) {
  .flyout-resizer {
    display: none;
  }
}

/* Flyouts that slide in from the left edge */
.flyout.from-left {
  left: 0;
  right: auto;
  border-left: 0;
  border-right: 1px solid var(--ev-rule-strong);
  animation: flyout-in-left 260ms cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.flyout.from-left.is-leaving {
  animation: flyout-out-left 200ms cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes flyout-in-left {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

@keyframes flyout-out-left {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

/* Columns flyout: one list, filter on top */
.column-filter {
  margin: 0 0 0.75rem;
  font-family: var(--ev-mono);
  font-size: 0.8rem;
}

.column-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.column-row {
  display: grid;
  grid-template-columns: 1.1rem 1fr max-content;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem 0.4rem 0.35rem;
  border: 1px solid var(--ev-rule);
  border-radius: 2px;
  font-family: var(--ev-mono);
  font-size: 0.76rem;
  color: var(--text-muted, #7a7a7a);
}

.column-row.on {
  color: var(--text-main, #e5e5e5);
  border-color: var(--ev-rule-strong);
  border-left: 2px solid var(--ev-accent);
}

.drag-handle {
  cursor: grab;
  text-align: center;
  color: var(--text-muted, #7a7a7a);
  user-select: none;
  line-height: 1;
}

.drag-handle:hover {
  color: var(--text-main, #e5e5e5);
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle.hidden {
  visibility: hidden;
}

.column-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  cursor: pointer;
  min-width: 0;
}

.column-check input {
  margin: 0;
  width: auto;
}

.column-check .column-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.column-row .column-type {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Last column: right-aligned header link and Details buttons. This selector outranks the generic cell alignment. */
.events-table .row-action {
  text-align: right;
}

/* Header buttons are icon-only squares */
.events-actions .tool-btn {
  height: 2rem;
  padding: 0 0.6rem;
  line-height: 0;
  align-items: center;
}

/* Column drag: the row being moved fades, and an accent line shows where it will land */
.column-row {
  position: relative;
  transition: opacity 0.15s ease;
}

.column-row.dragging {
  opacity: 0.35;
}

.column-row.drop-before::before,
.column-row.drop-after::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--ev-accent);
  box-shadow: 0 0 10px var(--ev-accent);
  pointer-events: none;
}

.column-row.drop-before::before {
  top: -4px;
}

.column-row.drop-after::after {
  bottom: -4px;
}

/* ---------- Column widths ---------- */

.events-table {
  table-layout: fixed;
  width: 100%;
}

.events-table thead th {
  position: sticky;
  overflow: hidden;
}

.events-table .th-label {
  display: inline-block;
  max-width: calc(100% - 0.6rem);
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* Grab zone along the right edge of each header */
.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 2;
}

.col-resizer::after {
  content: '';
  position: absolute;
  top: 25%;
  bottom: 25%;
  right: 3px;
  width: 1px;
  background: var(--ev-rule-strong);
  transition: background-color 0.15s ease;
}

.events-table thead th:hover .col-resizer::after {
  background: var(--text-muted, #7a7a7a);
}

.col-resizer:hover::after {
  background: var(--ev-accent) !important;
}

body.is-resizing,
body.is-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

/* ---------- Filter chips: actions appear on hover ---------- */

.filter-chip .chip-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width 0.2s ease, opacity 0.15s ease 0.04s;
}

.filter-chip:hover .chip-actions,
.filter-chip:focus-within .chip-actions {
  max-width: 6rem;
  opacity: 1;
  transition-delay: 0.1s;
}

.filter-chip .chip-btn {
  display: inline-grid;
  place-items: center;
  width: 1.3rem;
  height: 1.3rem;
  padding: 0;
  margin: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted, #7a7a7a);
  line-height: 0;
}

.filter-chip .chip-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main, #e5e5e5);
}

.filter-chip .chip-remove:hover {
  color: #fca5a5;
}

/* ---------- +/- buttons on cells ---------- */

.cell-actions {
  gap: 0.2rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(16, 16, 16, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.cell-actions .cell-btn {
  display: inline-grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-main, #e5e5e5);
  line-height: 0;
  font-size: 0;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.cell-actions .cell-btn:hover {
  transform: scale(1.1);
  transition-delay: 0.1s;
}

.cell-actions .cell-add:hover {
  background: rgba(34, 197, 94, 0.22);
  color: #86efac;
}

.cell-actions .cell-exclude:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* ---------- Chip actions: float inside the chip, labels never move ---------- */

.filter-chip {
  position: relative;
}

.filter-chip .chip-actions {
  position: absolute;
  top: 50%;
  right: 0.2rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  max-width: none;
  padding: 0.1rem;
  border-radius: 999px;
  background: var(--bg-surface-elevated, #141414);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s;
}

.filter-chip:hover .chip-actions,
.filter-chip:focus-within .chip-actions {
  opacity: 1;
  visibility: visible;
  transition-delay: 0.08s;
}

/* The label fades out under the icons instead of sliding */
.filter-chip:hover .filter-text {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 4.5rem), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 4.5rem), transparent);
}

/* Global button rules use !important; these win over them */
.filter-chip .chip-btn {
  display: inline-grid !important;
  place-items: center;
  width: 1.25rem !important;
  height: 1.25rem !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 999px !important;
  border: 0;
  background: transparent;
  color: var(--text-muted, #7a7a7a);
  line-height: 0;
}

.cell-actions .cell-btn {
  width: 1.5rem !important;
  height: 1.5rem !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 999px !important;
  font-size: 0 !important;
}

.cell-actions {
  padding: 0.15rem !important;
  gap: 0.15rem;
}

/* ---------- Hover icons: translucent, the icon under the pointer is more solid ----------
   The fade is on each button, not the group, so the group does not dim them further. */

.filter-chip .chip-actions {
  opacity: 1;
}

.filter-chip .chip-btn,
.cell-actions .cell-btn {
  opacity: 0;
  transition: opacity 0.15s ease, background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.filter-chip:hover .chip-btn,
.cell:hover .cell-actions .cell-btn {
  opacity: 0.5;
}

.filter-chip:hover .chip-btn:hover,
.cell:hover .cell-actions .cell-btn:hover {
  opacity: 0.9;
}

.cell-actions {
  opacity: 1;
}

/* ---------- Let the text underneath show through the hover bars ---------- */

.cell-actions {
  background: rgba(20, 20, 20, 0.16);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

.filter-chip .chip-actions {
  background: rgba(20, 20, 20, 0.16);
  box-shadow: none;
}

/* No fade over the label: the text stays readable under the icons */
.filter-chip:hover .filter-text {
  -webkit-mask-image: none;
  mask-image: none;
}

/* ---------- Final hover rules: buttons are always opaque; only the container's background changes ----------
   Hovering any button (the container is the hover target) makes its background fully opaque. */

.cell-actions .cell-btn,
.filter-chip .chip-btn {
  opacity: 1 !important;
}

.cell-actions,
.filter-chip .chip-actions {
  background: rgba(24, 24, 24, 0.65) !important;
}

.cell-actions:hover,
.filter-chip .chip-actions:hover {
  background: rgba(24, 24, 24, 1) !important;
}

/* ---------- Details: plain cell-sized text, underlined on hover ---------- */

.details-btn {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  font-family: inherit !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  letter-spacing: inherit !important;
  line-height: inherit !important;
  text-transform: none !important;
  color: var(--text-main, #e5e5e5) !important;
  text-decoration: none;
  transition: none !important;
}

/* Same hover for the Event link and the Details button: a 1px lift and an underline. The global
   button rules give the lift to buttons only, so it is set here for both. */
.details-btn {
  display: inline-block;
  cursor: pointer;
}

.details-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  transform: translateY(-1px);
}

.details-btn:active {
  transform: translateY(1px);
}

/* The Event link sits before Details in the last column, with a gap between them */
.events-table .row-action .event-btn {
  margin-right: 0.9rem !important;
}

/* ---------- Columns: underlined on hover only ---------- */

.link-btn {
  text-decoration: none;
}

.link-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Clear: plain text like Details, underlined on hover ---------- */

.filter-clear {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  font-family: var(--ev-mono) !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em !important;
  line-height: inherit !important;
  text-transform: uppercase !important;
  color: var(--text-muted, #7a7a7a) !important;
  text-decoration: none;
  transition: none !important;
}

.filter-clear:hover {
  color: var(--text-main, #e5e5e5) !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Analysis tab in the event details flyout */
.analysis-summary {
  margin: 0.25rem 0 0.5rem;
  font-family: var(--ev-mono);
  font-size: 0.85rem;
  color: var(--text-main, #e5e5e5);
  word-break: break-word;
}

.analysis-section {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ev-rule);
}

.analysis-section h4 {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #888);
}

.analysis-section dd {
  font-family: var(--ev-mono);
  font-size: 0.8rem;
  word-break: break-all;
}

.analysis-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.25rem 0;
  font-size: 0.75rem;
  color: var(--text-muted, #888);
}

.analysis-warn {
  color: var(--chart-red, #ef4444);
}

.analysis-body pre {
  max-height: 50vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--ev-mono);
  font-size: 0.75rem;
}

/* Body tab: one row per stored body. The whole row is the button that opens its preview. */
.body-row {
  margin-bottom: 0.4rem;
}

.body-row-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--ev-rule-strong);
  border-radius: 3px;
  background: var(--bg-surface, #141414);
  color: var(--text-main, #e5e5e5);
  font-family: var(--ev-mono);
  font-size: 0.8rem;
  font-weight: 400;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.body-row-head:hover:not(:disabled),
.body-row-head:focus-visible:not(:disabled) {
  border-color: var(--border-focus, #6b6b6b);
}

.body-row-head[aria-expanded="true"] {
  border-color: var(--text-main, #e5e5e5);
}

.body-row-head:disabled {
  cursor: default;
  opacity: 0.7;
}

.body-row-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.body-row-meta {
  flex: 0 1 auto;
  white-space: nowrap;
  color: var(--text-muted, #888);
  font-size: 0.72rem;
}

.body-chevron {
  flex: 0 0 auto;
  color: var(--text-muted, #888);
  transition: transform 0.15s ease;
}

.body-chevron.is-open {
  transform: rotate(180deg);
}

.body-row-box {
  padding-bottom: 0.6rem;
}

/* Body preview: black with white text, like the console's code views. Pages are shown in a
   sandboxed frame, so captured content cannot run scripts. */
.body-preview {
  display: block;
  width: 100%;
  height: 360px;
  margin: 0;
  border: 1px solid var(--ev-rule);
  border-radius: 3px;
  background: #000;
  color: #fff;
  color-scheme: dark;
}

.body-preview-image {
  height: auto;
  max-height: 360px;
  object-fit: contain;
}

.body-preview-text {
  box-sizing: border-box;
  overflow: auto;
  max-height: 360px;
  padding: 0.6rem 0.75rem;
  font-family: var(--ev-mono);
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.body-note {
  margin: 0.4rem 0;
  font-size: 0.75rem;
}


/* ---------- Refresh split button and auto refresh popover ---------- */
.refresh-split {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  height: 2rem;
  border: 1px solid var(--ev-rule-strong);
  border-radius: 4px;
  background: var(--bg-surface, #141414);
}

.refresh-split button {
  position: relative;
  z-index: 1;
  margin: 0;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-muted, #888) !important;
  line-height: 0;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.refresh-split button:hover:not(:disabled) {
  color: var(--text-main, #e5e5e5) !important;
}

.refresh-split button:disabled {
  cursor: progress;
}

.refresh-main {
  padding: 0 0.6rem !important;
  border-radius: 3px 0 0 3px !important;
}

.refresh-caret {
  padding: 0 0.45rem !important;
  border-left: 1px solid var(--ev-rule-strong) !important;
  border-radius: 0 3px 3px 0 !important;
}

.refresh-split.is-auto .refresh-main {
  color: var(--ev-accent, #f59e0b) !important;
}

.refresh-icon.is-spinning {
  animation: events-spin 0.8s linear infinite;
}

@keyframes events-spin {
  to {
    transform: rotate(360deg);
  }
}

.refresh-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 40;
  width: 13.5rem;
  padding: 0.5rem 0;
  border: 1px solid var(--ev-rule-strong);
  border-radius: 6px;
  background: var(--bg-surface-elevated, #1a1a1a);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  text-transform: none;
  letter-spacing: normal;
}

.refresh-toggle,
.fl-switch {
  display: flex;
  width: 100% !important; /* Pico sets fit-content on labels that hold a checkbox or radio */
  box-sizing: border-box;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
  padding: 0.35rem 0.85rem 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main, #e5e5e5);
  cursor: pointer;
}

/* Switch: a pill with a knob, lit in the accent colour when on */
.refresh-toggle input[type="checkbox"],
.fl-switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 2rem;
  height: 1.1rem;
  margin: 0;
  border: none;
  border-radius: 999px;
  background: var(--ev-rule-strong) !important;
  background-image: none !important;
  cursor: pointer;
  transition: background-color 0.18s ease;
}

.refresh-toggle input[type="checkbox"]::before,
.fl-switch input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  margin: 0 !important;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--text-main, #e5e5e5);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.refresh-toggle input[type="checkbox"]:checked,
.fl-switch input[type="checkbox"]:checked {
  background: var(--ev-accent, #f59e0b) !important;
  background-image: none !important;
}

.refresh-toggle input[type="checkbox"]:checked::before,
.fl-switch input[type="checkbox"]:checked::before {
  transform: translateX(0.9rem);
  margin-inline-start: 0 !important;
  background: #141414;
}

.refresh-divider {
  height: 1px;
  margin: 0 0 0.35rem;
  background: var(--ev-rule);
}

.refresh-options {
  display: grid;
  gap: 0.05rem;
  padding: 0 0.35rem;
  transition: opacity 0.18s ease;
}

.refresh-options.is-off {
  opacity: 0.42;
}

.refresh-option {
  display: flex;
  width: 100% !important;
  box-sizing: border-box;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0;
  padding: 0.38rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text-main, #e5e5e5);
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.refresh-option:hover {
  background: var(--bg-surface-hover, #222);
}

/* Radio: a ring with a dot, the dot in the accent colour when chosen */
.refresh-option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-content: center;
  flex: none;
  width: 0.9rem;
  height: 0.9rem;
  margin: 0;
  border: 1px solid var(--ev-rule-strong);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.refresh-option input[type="radio"]::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--ev-accent, #f59e0b);
  transform: scale(0);
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.refresh-option input[type="radio"]:checked {
  border-color: var(--ev-accent, #f59e0b);
}

.refresh-option input[type="radio"]:checked::before {
  transform: scale(1);
}

.refresh-option input[type="radio"]:disabled {
  cursor: not-allowed;
}

/* Countdown to the next automatic refresh: a fill behind the split button */
.refresh-progress {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 3px 0 0 3px;
  background: rgba(245, 158, 11, 0.16);
  pointer-events: none;
  transition: width 0.2s linear;
}

/* Table loading: a gradient over the first rows with a spinner in its middle */
.table-frame {
  position: relative;
}

.table-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 12rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(to bottom, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0));
  z-index: 2;
}

/* First load: skeleton rows in the table's own rhythm, with a soft shimmer */
.skeleton-row td {
  height: 2.6rem;
  border-bottom: 1px solid var(--ev-rule);
  padding: 0 0.65rem;
  vertical-align: middle;
}

.skeleton-cells {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: var(--w, 60%);
  max-width: 100%;
}

.skeleton-bar {
  display: block;
  height: 0.62rem;
  width: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ev-rule) 0%, var(--ev-rule-strong) 50%, var(--ev-rule) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.skeleton-bar-short {
  width: 45%;
}

@keyframes skeleton-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

/* ---------- Phone layout of the Events and Alerts page (desktop is unchanged) ---------- */

@media (max-width: 640px) {
  /* Header: the time range takes the row, the timeline button stays at the end.
     The count moves to the pager, which already shows it. */
  .events-page .events-header {
    gap: 0.4rem;
  }

  .events-page .events-header .events-actions {
    flex: 1 1 auto;
    min-width: 0;
  }

  .events-page .events-count {
    display: none;
  }

  .events-page .events-actions .tool-range {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  .events-page .events-actions .range-value {
    flex: 1 1 0;
    min-width: 0;
    line-height: 1.2;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Filter bar: the clear button stays put; the badges scroll sideways under its edge */
  .events-page .filter-bar {
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  .events-page .filter-bar .filter-chips {
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding-bottom: 2px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent);
  }

  .events-page .filter-bar .filter-chips::-webkit-scrollbar {
    display: none;
  }

  .events-page .filter-bar .filter-chip {
    max-width: none;
  }

  .events-page .filter-bar .filter-clear {
    flex: none;
    margin-left: 0;
    order: 3;
  }

  /* Pager, in two lines: the range and rows per page, then the icon buttons */
  .events-page .events-pager {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem 0.6rem;
  }

  .events-page .pager-range {
    grid-column: 1;
    grid-row: 1;
  }

  .events-page .pager-size {
    grid-column: 2;
    grid-row: 1;
  }

  .events-page .pager-buttons {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0.4rem;
  }

  /* Phones show only the arrow: the words are hidden by a zero font size, and the arrow
     is drawn from data-glyph, so the markup stays the same as on desktop */
  .events-page .pager-buttons .tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    /* app.css sets every button's font size with !important, so this one must match it */
    font-size: 0 !important;
    line-height: 1;
  }

  .events-page .pager-buttons .tool-btn::before {
    content: attr(data-glyph);
    font-size: 1rem;
    line-height: 1;
  }

  .events-page .pager-page {
    min-width: 7rem;
    text-align: center;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-bar {
    animation: none;
  }
}

.table-loading .spinner {
  width: 1.6rem;
  height: 1.6rem;
  border: 2px solid rgba(245, 158, 11, 0.25);
  border-top-color: var(--ev-accent, #f59e0b);
  border-radius: 50%;
  animation: events-spin 0.8s linear infinite;
}

/* ---------- Filters flyout: active filters as full-width rows, icons always visible ----------
   Scoped to the list so the table's filter bar keeps its compact chips. */

.filter-list {
  align-items: stretch;
  gap: 0.35rem;
  margin-top: 0;
}

.filter-list .filter-chip {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  justify-content: space-between;
  padding: 0.4rem 0.35rem 0.4rem 0.7rem;
  background: var(--bg-surface, #0b0b0b);
  font-size: 0.78rem;
}

.filter-list .filter-chip.filter-editing {
  flex-wrap: wrap;
  padding: 0.35rem 0.4rem;
}

.filter-list .filter-chip .filter-text {
  flex: 1;
  min-width: 0;
}

.filter-list .filter-chip .chip-actions {
  position: static;
  transform: none;
  display: inline-flex;
  flex-shrink: 0;
  padding: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  opacity: 1;
  visibility: visible;
  gap: 0.15rem;
}

.filter-list .filter-chip .chip-btn {
  width: 1.6rem !important;
  height: 1.6rem !important;
  opacity: 1 !important;
  color: var(--text-muted, #7a7a7a);
}

.filter-list .filter-chip .chip-btn:hover {
  color: var(--ev-accent);
  background: rgba(255, 255, 255, 0.08) !important;
}

.filter-list .filter-chip .chip-remove:hover {
  color: var(--chart-red, #ef4444);
}

.filter-list .filter-chip.disabled .filter-text {
  text-decoration: line-through;
}

/* ---------- Flyout controls: the toolbar's mono, hairline style instead of the Pico colours ----------
   Tabs: the selected tab (no .outline class) is underlined in the accent colour. */

.flyout-tabs button {
  margin: 0 0 -1px;
  padding: 0.45rem 0.1rem !important;
  border: 0 !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--text-muted, #7a7a7a) !important;
  font-family: var(--ev-mono);
  font-size: 0.7rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: none;
}

.flyout-tabs button:not(.outline) {
  border-bottom-color: var(--ev-accent) !important;
  color: var(--text-main, #e5e5e5) !important;
}

.flyout-tabs button:hover {
  color: var(--text-main, #e5e5e5) !important;
}

/* Header and action buttons: outlined; the primary action is solid */
.flyout-header button,
.flyout-actions button,
.fl-submit {
  margin: 0;
  padding: 0.35rem 0.8rem !important;
  border: 1px solid var(--ev-rule-strong) !important;
  border-radius: 2px !important;
  background: transparent !important;
  color: var(--text-main, #e5e5e5) !important;
  font-family: var(--ev-mono);
  font-size: 0.68rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: none;
}

.flyout-header button:hover,
.flyout-actions button:hover,
.fl-submit:hover {
  border-color: var(--text-main, #e5e5e5) !important;
  background: transparent !important;
}

.flyout-actions button:not(.secondary),
.fl-submit {
  background: var(--text-main, #e5e5e5) !important;
  border-color: var(--text-main, #e5e5e5) !important;
  color: var(--bg-base, #000) !important;
}

.flyout-actions button:not(.secondary):hover,
.fl-submit:hover {
  opacity: 0.85;
  background: var(--text-main, #e5e5e5) !important;
}

/* Clear all: plain text, underlined on hover */
.fl-clear {
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--text-muted, #7a7a7a) !important;
  font-size: 0.66rem !important;
}

.fl-clear:hover {
  color: var(--text-main, #e5e5e5) !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Filters flyout inputs share the toolbar's mono look */
.flyout-body input,
.flyout-body select,
.flyout-body textarea {
  border-radius: 2px !important;
  border-color: var(--ev-rule-strong) !important;
}

/* PCAP and JSON sit at the end of the tab row, styled like the other tabs */
.json-tab-actions {
  display: flex;
  justify-content: flex-end;
  margin: 0.25rem 0 0.5rem;
}

.flyout-tab-actions {
  display: flex;
  align-items: flex-end;
  align-self: flex-end;
  margin-left: auto;
  /* The same gap as between the other tabs (see .flyout-tabs above) */
  gap: 1.25rem;
}

/* Any flyout open: the page behind it does not scroll */
body.flyout-open {
  overflow: hidden;
}

/* Faster hover feedback: no delay before the table's row buttons and cell actions respond */
.events-table .cell-actions,
.events-table .cell-actions .cell-btn,
.cell:hover .cell-actions,
.cell:hover .cell-actions .cell-btn,
.detail-table .filter-btns .cell-btn,
.detail-table .filter-btns .cell-btn:hover:not(:disabled),
.filter-list .filter-chip .chip-btn,
.filter-list .filter-chip .chip-btn:hover:not(:disabled) {
  transition-delay: 0s !important;
  transition-duration: 0.1s !important;
}

.events-table td {
  transition: background-color 0.08s linear;
}

/* ---------- Payload tree: collapsible JSON ---------- */

.json-tree {
  font-family: var(--ev-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: normal;
  word-break: break-all;
}

.json-line {
  display: flex;
  align-items: baseline;
}

.json-ln {
  flex: 0 0 2.6rem;
  padding-right: 0.7rem;
  margin-right: 0.6rem;
  border-right: 1px solid var(--ev-rule);
  text-align: right;
  color: var(--text-subtle, #555555);
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.json-code {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.json-toggle {
  display: inline-block;
  width: 1.1rem;
  margin: 0;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--text-muted, #7a7a7a) !important;
  font-family: var(--ev-mono);
  font-size: 0.8rem !important;
  line-height: inherit;
  text-align: left;
  box-shadow: none;
  transform: none !important;
}

.json-toggle:hover {
  color: var(--ev-accent) !important;
}

.json-key {
  color: var(--text-main, #e5e5e5);
}

.json-str {
  color: var(--chart-green, #22c55e);
}

.json-num,
.json-bool {
  color: var(--chart-yellow, #eab308);
}

.json-null,
.json-summary,
.json-idx {
  color: var(--text-muted, #7a7a7a);
}

.json-punct {
  color: var(--text-muted, #7a7a7a);
}

/* ---------- Tree table: nested keys indented, blocks expand and collapse ---------- */

.tree-label {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.tree-toggle-slot {
  display: inline-block;
  width: 1.1rem;
  flex-shrink: 0;
}

.tree-toggle {
  display: inline-block;
  width: 1.1rem;
  margin: 0;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--text-muted, #7a7a7a) !important;
  font-family: var(--ev-mono);
  font-size: 0.8rem !important;
  line-height: inherit;
  text-align: left;
  box-shadow: none;
  transform: none !important;
}

.tree-toggle:hover {
  color: var(--ev-accent) !important;
}

.tree-block .dt-key {
  color: var(--text-main, #e5e5e5);
}

.tree-index {
  color: var(--text-muted, #7a7a7a);
}

.tree-count {
  color: var(--text-muted, #7a7a7a);
}

/* Filter: a footer row under the scrolling body, so it always sits at the bottom of the flyout */
.tree-filter-bar {
  flex: 0 0 auto;
  padding: 0.35rem 1.25rem;
  border-top: 1px solid var(--ev-rule);
  background: var(--bg-surface, #0b0b0b);
}

.tree-search {
  display: block;
  width: 100% !important;
  height: 2.35rem !important;
  margin: 0 !important;
  padding: 0.3rem 0.55rem !important;
  border-radius: 2px !important;
  border: 1px solid var(--ev-rule-strong) !important;
  background: var(--bg-base) !important;
  font-family: var(--ev-mono);
  font-size: 0.74rem !important;
}

/* The parent path of a key slides open before its name when the row is hovered */
.tree-name {
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
}

.tree-parent {
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted, #7a7a7a);
  opacity: 0;
  transition: max-width 0.25s ease, opacity 0.2s ease;
}

.tree-table tbody tr:hover .tree-parent {
  max-width: 100%;
  opacity: 1;
}

/* Saved filter sets in the Filters flyout */
.fl-save {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.fl-summary {
  margin: 0 0 0.6rem;
  font-family: var(--ev-mono);
  font-size: 0.74rem;
  color: var(--text-muted, #7a7a7a);
  overflow-wrap: anywhere;
}

.flyout-tabs .tab-end {
  margin-left: auto;
}

.filter-list .saved-chip.is-active {
  box-shadow: inset 2px 0 0 var(--ev-accent);
}

.filter-list .filter-chip .saved-apply {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  margin: 0;
  padding: 0 !important;
  width: auto;
  background: none;
  border: 0;
  box-shadow: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.saved-apply .filter-text {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-meta {
  font-size: 0.7rem;
}

/* Inner tabs of the Builder: Add condition or Raw SQL */
.fl-subtabs {
  display: flex;
  gap: 1rem;
  margin: 0 0 0.9rem;
  border-bottom: 1px solid var(--ev-rule);
}

.fl-subtabs button {
  margin: 0 0 -1px;
  padding: 0.3rem 0 0.4rem !important;
  border: 0 !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-muted, #7a7a7a) !important;
  font-family: var(--ev-mono);
  font-size: 0.66rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.fl-subtabs button:not(.outline) {
  border-bottom-color: var(--ev-accent) !important;
  color: var(--text-main, #e5e5e5) !important;
}

.fl-subtabs button:hover {
  color: var(--text-main, #e5e5e5) !important;
}

/* Groups: a header row with an AND / OR choice, and the conditions indented beneath it */
.filter-list .filter-chip.filter-group {
  border-style: dashed;
  background: transparent;
}

.fl-group .flyout-actions select {
  width: auto;
  margin: 0;
  height: 1.9rem;
  padding: 0.2rem 1.8rem 0.2rem 0.5rem !important;
  font-family: var(--ev-mono);
  font-size: 0.7rem !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.group-label {
  flex: none;
  padding: 0 0.2rem;
  font-family: var(--ev-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-main, #e5e5e5);
}

.fl-group .flyout-actions {
  align-items: center;
}

/* A list slot takes a box so that a group's conditions can be indented */
.filter-list .filter-slot {
  display: block;
}

.fl-group .fl-empty {
  margin: 0.6rem 0 0;
}

/* Dragging: the handle grabs a row; the line shows where it lands */
.drag-handle {
  flex: none;
  padding: 0 0.3rem 0 0;
  font-family: var(--ev-mono);
  color: var(--text-muted, #7a7a7a);
  cursor: grab;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.filter-list .filter-slot {
  position: relative;
}

/* The drop line sits in the gap above or below the row, drawn over the chips */
.filter-list .filter-slot.is-drop-before::before,
.filter-list .filter-slot.is-drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 2;
  background: var(--ev-accent);
  pointer-events: none;
}

.filter-list .filter-slot.is-drop-before::before {
  top: -2px;
}

.filter-list .filter-slot.is-drop-after::after {
  bottom: -2px;
}

/* Dropping inside a block outlines the block */
.filter-list .filter-slot.is-drop-into > .filter-chip {
  box-shadow: inset 0 0 0 2px var(--ev-accent);
}

/* A block that breaks its operand count is outlined in red and says why */
.filter-list .filter-chip.is-invalid {
  border-color: var(--chart-red, #ef4444);
}

.block-hint {
  flex: 1;
  min-width: 0;
  font-family: var(--ev-mono);
  font-size: 0.66rem;
  color: var(--text-muted, #7a7a7a);
}

.filter-chip.is-invalid .block-hint {
  color: var(--chart-red, #ef4444);
}

.fl-groups {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.fl-groups .fl-title {
  flex: 1;
  display: flex;
  align-items: center;
  height: 2.1rem;
  margin: 0;
  line-height: 1;
}

.fl-groups button {
  margin: 0;
  height: 2.1rem;
  padding: 0 0.8rem !important;
  font-size: 0.7rem !important;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fl-groups button.secondary {
  border: 1px solid var(--ev-rule-strong) !important;
  background: transparent !important;
  color: var(--text-main, #e5e5e5) !important;
}

/* ---------- Badges in cells: TCP flags (@tcp_flag) and list columns such as tags ---------- */

.cell-badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
}

.cell-badge {
  --flag-color: var(--text-muted, #7a7a7a);
  max-width: 100%;
  padding: 0.12rem 0.35rem;
  border-radius: 2px;
  background: color-mix(in srgb, var(--flag-color) 14%, transparent);
  color: var(--flag-color);
  font-family: var(--ev-mono);
  font-size: 0.7rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* A list item: hovering it covers the text with a + (or a - while Alt is held) */
/* The global button rules set size and weight with !important, so the sizes here are restated to match the flag badges */
.cell-badge-item {
  position: relative;
  display: inline-block;
  margin: 0;
  padding: 0.12rem 0.35rem !important;
  border: 0;
  border-radius: 2px !important;
  font-size: 0.7rem !important;
  font-weight: 400 !important;
  line-height: 1.2;
  text-align: inherit;
  cursor: pointer;
}

.cell-badge-item:hover,
.cell-badge-item:focus-visible,
.cell-badge-item:active {
  background: color-mix(in srgb, var(--flag-color) 26%, transparent);
  outline: none;
  transform: none !important;
}

.badge-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-sign {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 600;
  visibility: hidden;
}

.cell-badge-item:hover .badge-text,
.cell-badge-item:focus-visible .badge-text {
  visibility: hidden;
}

.cell-badge-item:hover .badge-sign,
.cell-badge-item:focus-visible .badge-sign {
  visibility: visible;
}

.cell-badge-item.is-exclude:hover,
.cell-badge-item.is-exclude:focus-visible {
  --flag-color: #ef4444;
}

.cell-badge.flag-syn { --flag-color: var(--chart-green); }
.cell-badge.flag-ack { --flag-color: var(--viz-1); }
.cell-badge.flag-fin { --flag-color: var(--chart-yellow); }
.cell-badge.flag-rst { --flag-color: var(--chart-red); }
.cell-badge.flag-psh { --flag-color: var(--viz-7); }
.cell-badge.flag-urg { --flag-color: var(--viz-2); }
.cell-badge.flag-ece { --flag-color: var(--viz-5); }
.cell-badge.flag-cwr { --flag-color: var(--viz-8); }

.flow-timeline {
  overflow-x: auto;
}
.flow-timings td,
.flow-timings th,
.flow-wire-table td,
.flow-wire-table th {
  white-space: nowrap;
}
/* Offset and seq/ack look the same in both timing views */
.flow-timings th:first-child,
.flow-timings td:first-child,
.flow-wire-table th:first-child,
.flow-wire-table td:first-child {
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}
.flow-offset {
  color: var(--text-muted, #888888);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}
.flow-num {
  font-variant-numeric: tabular-nums;
}
/* Seq and ack are right-aligned, in both views. The table's own cell rule would win on specificity. */
.detail-table .flow-num {
  text-align: right;
}
.flow-arrow-text {
  margin: 0 0.25rem;
  color: var(--text-subtle, #555555);
}
.flow-kind {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.flow-kind.syn { color: var(--chart-green); }
.flow-kind.ack { color: var(--viz-1); }
.flow-kind.fin { color: var(--chart-yellow); }
.flow-kind.rst { color: var(--chart-red); }
.flow-kind.other { color: var(--text-muted, #888888); }

/* Tabs in the flyout are spaced apart, so neighbouring labels do not run together */
.flyout-tabs {
  gap: 1.25rem;
}

/* Flow tab: sections share one header style, with space between them */
.flow-section {
  padding: 0.8rem 0.8rem 0.9rem;
  border: 1px solid var(--border-subtle, #222222);
  border-radius: 6px;
  background: var(--bg-surface-elevated, #141414);
}
.flow-section + .flow-section {
  margin-top: 1rem;
}
.flow-section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.6rem;
}
.flow-section-head .body-views {
  grid-column: 2;
  justify-self: end;
  margin: 0;
  width: max-content;
}
.flow-title {
  grid-column: 1;
  margin: 0;
  font-family: var(--ev-mono);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #888888);
}
.flow-badge.is-fail {
  border-color: var(--chart-red);
  color: var(--chart-red);
}
.flow-badge {
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--ev-accent);
  border-radius: 999px;
  color: var(--ev-accent);
  font-family: var(--ev-mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}
/* Flow tab: stub shown in place of the timings and checks when the flow has no handshake */
.flow-stub {
  margin: 1.25rem 0 0;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--ev-rule-strong);
  border-radius: 4px;
  color: var(--text-muted, #888888);
  font-family: var(--pico-font-family, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  text-align: center;
}

/* Flow tab: the wire view and the sequence checks */
.flow-wire-table {
  --lane-half: 28px;
}
.flow-wire-table th,
.flow-wire-table td {
  white-space: nowrap;
  padding: 0.4rem 0.5rem;
}
.flow-wire-table .flow-wire-cell {
  padding: 0.2rem 0 !important;
}
.flow-lane-head small {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-muted, #888888);
  font-family: var(--ev-mono);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}
.flow-wire-head {
  text-align: center;
}
.flow-wire-table .lane-initiator,
.flow-wire-table .lane-responder,
.flow-wire-table .flow-lane-head,
.flow-wire-table .flow-wire-head {
  padding-left: 0;
  padding-right: 0;
  text-align: center;
}
.flow-wire-table .flow-lane-head {
  font-size: 0.62rem;
  letter-spacing: 0.04em;
}
.flow-node {
  display: block;
  margin: 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px var(--bg-surface, #0a0a0a), 0 0 0 4px currentColor;
}
.flow-wire-cell {
  padding: 0.2rem 0 !important;
}
.flow-wire {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 1.9rem;
  /* Run from the centre of one lane's column to the centre of the other's */
  margin: 0 calc(-1 * var(--lane-half));
  color: inherit;
}
.flow-wire::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px dashed currentColor;
  opacity: 0.55;
}
/* The receiving end of a packet: a chevron centred in the receiver's column */
.flow-head {
  display: block;
  width: 7px;
  height: 7px;
  margin: 0 auto;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
}
.flow-head.head-right {
  transform: rotate(45deg);
}
.flow-head.head-left {
  transform: rotate(-135deg);
}
.flow-wire-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  line-height: 1;
  white-space: nowrap;
}
/* The packet badge sits on the dotted line, so it masks the line behind it */
.flow-wire .flow-kind {
  background: var(--bg-surface-elevated, #141414);
}
.flow-row.syn .flow-wire,
.flow-row.syn .flow-node { color: var(--chart-green); }
.flow-row.ack .flow-wire,
.flow-row.ack .flow-node { color: var(--viz-1); }
.flow-row.fin .flow-wire,
.flow-row.fin .flow-node { color: var(--chart-yellow); }
.flow-row.rst .flow-wire,
.flow-row.rst .flow-node { color: var(--chart-red); }

.flow-checks {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--ev-mono);
  font-size: 0.76rem;
}
.flow-checks li {
  display: grid;
  grid-template-columns: 1.2rem max-content 1fr;
  gap: 0.25rem 0.6rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--ev-rule);
}
.flow-checks .check-mark {
  color: var(--chart-green);
  text-align: center;
}
.flow-checks .check-fail .check-mark,
.flow-checks .check-fail .check-label {
  color: var(--chart-red);
}
.flow-checks .check-skip .check-mark {
  color: var(--text-subtle, #555555);
}
.flow-checks .check-detail {
  grid-column: 2 / -1;
  font-size: 0.7rem;
}


