:root {
  /* Chrome heights are fixed so no bar changes size with its content. */
  --topbar-h: 32px;
  --toolbar-h: 27px;
  --pager-h: 28px;
  --sidebar-w: 258px;

  /* Palette — near black. Surfaces go down, borders come up so they stay
     visible; every colour in this file is one of these tokens. */
  --bg: #070809;
  --surface: #101418;
  --surface-2: #0d1114;
  --surface-3: #161b21;
  --stripe: #0b0e11;
  --nav: #0b0e12;
  --nav-2: #0e1216;
  --nav-3: #0d1115;
  --field: #06080a;
  --border: #1c232b;
  --border-soft: #2b3541;
  --text: #c8d2dc;
  --text-bright: #f2f6fa;
  --muted: #7c8994;
  --bar-top: #161c22;
  --bar-bottom: #11161b;
  --btn-top: #1b2229;
  --btn-bottom: #141a20;
  --btn-hover-top: #263039;
  --btn-hover-bottom: #1b232b;
  --nav-hover-top: #1d2c3a;
  --nav-hover-bottom: #16212c;
  --hover: #182430;
  --link: #6fb3ea;
  --link-hover: #a8d6ff;
  --focus: #2f6fa6;
  --accent-border: #2a5680;
  --accent-top: #23557f;
  --accent-bottom: #1a4266;
  --accent-bg: #1b3247;
  --info-bg: #10202c;
  --danger-border: #6d2f2f;
  --danger-top: #712929;
  --danger-bottom: #4c1d1d;
  --danger-bg: #251515;
  --danger-text: #f0a3a3;
  --ok-border: #24593a;
  --ok-bg: #10261a;
  --ok-text: #6cc98a;
  --warn-border: #63501f;
  --warn-bg: #241d10;
  --warn-text: #e6c36f;
  --select-bg: #12293d;
  --select-edge: #4a90d9;

  /* Depth. Surfaces that float above the page cast a shadow; bars get a
     1px top highlight so they read as raised rather than painted on. */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 22px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 18px 60px rgba(0, 0, 0, 0.55);
  --highlight: rgba(255, 255, 255, 0.05);
  --z-sticky: 1;
  --z-popup: 20;
  --z-menu: 40;
  /* Help answers about a control that may itself be inside an open menu, so
     it sits above every other layer. */
  --z-help: 60;
  --help-panel-w: 340px;
  --transition: 90ms ease;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* Any rule that sets `display` on a class or a tag outbids the browser's
   own `[hidden]` rule, so a "hidden" element stays laid out: an invisible
   menu sat over the table and swallowed clicks on the rows beneath it, and
   the selection counter showed "0 selected" with nothing selected. One
   global opt-out covers every layer, present and future. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
.ghost-button,
.primary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 2px 8px;
  color: var(--text);
  background: linear-gradient(var(--btn-top), var(--btn-bottom));
  box-shadow: inset 0 1px 0 var(--highlight);
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
    box-shadow var(--transition);
}

button:hover,
.ghost-button:hover {
  color: var(--text-bright);
  background: linear-gradient(var(--btn-hover-top), var(--btn-hover-bottom));
}

button:active,
.ghost-button:active,
.primary-button:active,
.danger-button:active {
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* Keyboard focus must be visible everywhere, not only in text fields. */
button:focus-visible,
a:focus-visible,
summary:focus-visible,
.ghost-button:focus-visible,
.primary-button:focus-visible,
.danger-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.primary-button {
  border-color: var(--accent-border);
  color: var(--text-bright);
  background: linear-gradient(var(--accent-top), var(--accent-bottom));
}

.danger-button {
  border-color: var(--danger-border);
  color: var(--text-bright);
  background: linear-gradient(var(--danger-top), var(--danger-bottom));
}

.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  min-height: 100vh;
}

.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--nav);
}

/* Collapsed: a narrow rail of icons — labels and view trees fold away. */
body.sidebar-collapsed {
  --sidebar-w: 40px;
}

body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .view-tree,
body.sidebar-collapsed .tree-icon,
/* Group headers would otherwise be empty clickable strips. */
body.sidebar-collapsed .nav-section > summary {
  display: none;
}

body.sidebar-collapsed .nav-link,
body.sidebar-collapsed .resource-link,
body.sidebar-collapsed .sidebar-footer .ghost-button,
body.sidebar-collapsed .session-chip {
  display: flex;
  justify-content: center;
  padding: 0;
}

/* The rail is 40px wide: no nesting indents, no icon margins. */
body.sidebar-collapsed .resource-node {
  margin-left: 0;
}

body.sidebar-collapsed .resource-node > summary {
  padding-left: 0;
}

body.sidebar-collapsed .item-icon {
  margin: 0;
}

body.sidebar-collapsed .sidebar-footer {
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding: 4px 6px;
  background: var(--nav-2);
}

.sidebar-footer form {
  margin: 0;
}

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  white-space: nowrap;
}

.brand {
  color: var(--text-bright);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand.large {
  display: block;
  margin-bottom: 12px;
  font-size: 22px;
}

.nav-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 10px;
}

.nav-tree details {
  margin: 0;
}

.nav-tree summary {
  list-style: none;
}

.nav-tree summary::-webkit-details-marker {
  display: none;
}

.nav-section > summary,
.resource-node > summary {
  display: flex;
  align-items: center;
  min-height: 24px;
  cursor: pointer;
}

.nav-section > summary {
  border-top: 1px solid var(--border);
  padding: 5px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--nav-2);
}

.resource-node {
  margin-left: 12px;
}

.resource-node > summary {
  padding-left: 6px;
}

.tree-icon,
.item-icon {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin-right: 5px;
  color: var(--muted);
}

.tree-icon {
  transition: transform 120ms ease;
}

details[open] > summary .tree-icon {
  transform: rotate(90deg);
}

.nav-link,
.resource-link,
.view-link {
  display: block;
  min-height: 24px;
  border-width: 1px 0;
  border-style: solid;
  border-color: transparent;
  color: var(--text);
}

.nav-link {
  padding: 5px 10px;
}

.resource-link {
  flex: 1;
  padding: 4px 8px 4px 0;
  font-weight: 700;
}

.view-tree {
  margin-left: 24px;
  padding: 2px 0 5px 12px;
  border-left: 1px solid var(--border-soft);
  background: var(--nav-3);
}

.view-tree-split {
  margin: 4px 8px;
  border-top: 1px solid var(--border-soft);
}

.view-link {
  padding: 4px 8px;
  color: var(--text);
}

.user-view-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.user-view-row > a:last-child {
  padding: 0 8px;
  color: var(--muted);
  font-size: 11px;
}

.nav-link:hover,
.resource-link:hover,
.view-link:hover,
.nav-link.active,
.resource-link.active,
.view-link.active {
  border-color: var(--border);
  color: var(--text-bright);
  background: linear-gradient(var(--nav-hover-top), var(--nav-hover-bottom));
}

.workspace {
  min-width: 0;
  overflow: auto;
  background: var(--bg);
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(240px, 720px) minmax(0, 1fr);
  align-items: center;
  gap: 0;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  padding: 0 7px;
  background: linear-gradient(var(--bar-top), var(--bar-bottom));
}

/* Wordmark first, hard against the left edge; the toggle follows it. */
.topbar-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: var(--sidebar-w);
  padding-right: 8px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.sidebar-toggle {
  display: inline-grid;
  place-items: center;
  width: 24px;
  padding: 0;
}

/* Icons inside buttons must not carry the nav icon's trailing margin —
   flex centres the margin box, which shifted the burger off centre. */
.sidebar-toggle .item-icon,
button .item-icon {
  margin: 0;
  color: inherit;
}

.global-search {
  padding: 0 7px;
}

.global-search {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
}

.live-search-results {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  z-index: var(--z-popup);
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
}

.live-search-state,
.live-search-group-title,
.live-search-results a {
  display: block;
  padding: 6px 8px;
}

.live-search-group-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--surface-3);
}

.live-search-results a:hover {
  background: var(--hover);
}

.live-search-state.danger {
  color: var(--danger-text);
}

.content {
  display: grid;
  gap: 7px;
  padding: 7px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 7px;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.section-title,
.resource-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--toolbar-h);
  border-bottom: 1px solid var(--border);
  padding: 3px 7px;
  color: var(--text-bright);
  background: linear-gradient(var(--bar-top), var(--bar-bottom));
  box-shadow: inset 0 1px 0 var(--highlight);
  font-weight: 700;
}

.resource-toolbar {
  flex-wrap: nowrap;
  overflow: hidden;
}

.resource-toolbar form {
  display: inline-flex;
  margin: 0;
}

.toolbar-separator {
  width: 1px;
  height: 17px;
  margin: 0 2px;
  background: var(--border);
}

.list-layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  /* topbar + toolbar + content padding */
  min-height: calc(100vh - var(--topbar-h) - var(--toolbar-h) - 22px);
}

.filter-panel {
  border-right: 1px solid var(--border);
  padding: 7px;
  background: var(--surface-2);
}

.filter-panel form,
.form-panel form,
.login-card form {
  display: grid;
  gap: 7px;
}

label {
  display: grid;
  gap: 3px;
  color: var(--text);
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 4px 6px;
  color: var(--text-bright);
  background: var(--field);
}

input:focus,
textarea:focus,
select:focus {
  outline: 1px solid var(--focus);
  border-color: var(--focus);
}

textarea {
  resize: vertical;
}

details label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  font-weight: 400;
}

details input[type='checkbox'] {
  width: auto;
}

.save-view-form {
  margin-top: 12px;
  border-top: 1px solid var(--border-soft);
  padding-top: 8px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  height: 26px;
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 3px 7px;
  text-align: left;
  vertical-align: middle;
}

/* A cell holds one line, whatever is in it. Without this a single long
   value — a role's permission list, a description — wraps, the row grows to
   three lines, and the table pushes its last columns off the right edge:
   `holders` and `createdAt` were invisible on a five-row list. The full
   value stays reachable: initCellTitles puts it in a tooltip on exactly the
   cells that were clipped. */
td {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  color: var(--text);
  background: var(--bar-bottom);
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:nth-child(even) td {
  background: var(--stripe);
}

tbody tr:hover td,
tbody tr:hover th {
  background: var(--hover);
}

tr[data-href] {
  cursor: pointer;
}

.select-cell {
  width: 28px;
  text-align: center;
}

.select-cell input {
  width: auto;
}

.property-table th {
  width: 215px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--pager-h);
  border-bottom: 1px solid var(--border);
  padding: 0 7px;
  background: var(--surface-2);
}

.pager-summary {
  color: var(--muted);
}

.pager-controls {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.pager-jump {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}

.pager-jump input {
  width: 60px;
}

.pager span,
.form-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.form-panel {
  max-width: 760px;
}

.form-panel form {
  padding: 9px;
}

.secondary-actions {
  border-top: 1px solid var(--border-soft);
  padding: 9px;
}

.login-page {
  display: grid;
  min-width: 0;
  place-items: center;
  background: radial-gradient(circle at 50% 10%, var(--bar-top), var(--bg) 60%);
}

.login-card {
  width: min(360px, calc(100vw - 24px));
  border: 1px solid var(--border);
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-3);
}

.login-card h1 {
  margin: 0 0 12px;
  font-size: 18px;
}

.callout {
  margin: 7px;
  border: 1px solid var(--border-soft);
  padding: 7px;
  background: var(--info-bg);
}

.callout.danger {
  border-color: var(--danger-border);
  color: var(--danger-text);
  background: var(--danger-bg);
}

.empty-cell {
  padding: 14px;
  color: var(--muted);
  background: var(--surface-2);
}

.muted {
  color: var(--muted);
}

/* "the device reported this exact state N times" — the server keeps one row
   per state, so the count is the only trace a retry loop leaves. */
.repeat-count {
  display: inline-block;
  min-width: 22px;
  padding: 0 4px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.field-error {
  color: var(--danger-text);
  font-size: 11px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  border: 1px solid var(--border-soft);
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge.ok {
  border-color: var(--ok-border);
  color: var(--ok-text);
  background: var(--ok-bg);
}

.status-badge.warn {
  border-color: var(--warn-border);
  color: var(--warn-text);
  background: var(--warn-bg);
}

.status-badge.error {
  border-color: var(--danger-border);
  color: var(--danger-text);
  background: var(--danger-bg);
}

.search-section {
  border-top: 1px solid var(--border-soft);
  padding: 8px;
}

.search-section h2 {
  margin: 0 0 6px;
  font-size: 13px;
}

.search-section ul {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 920px) {
  /* Scoped to :not(.sidebar-collapsed) so the rail still collapses here. */
  body:not(.sidebar-collapsed) .app-shell {
    --sidebar-w: 220px;
  }

  .dashboard-grid,
  .list-layout {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 680px) {
  .app-body {
    display: block;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-tree {
    max-height: 45vh;
    overflow: auto;
  }

  .content {
    padding: 4px;
  }

  .pager {
    flex-wrap: wrap;
    height: auto;
  }

  th,
  td {
    white-space: nowrap;
  }
}

/* --- iteration: dashboards, progress bars, panels --- */
.stat-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-card { display: flex; flex-direction: column; padding: 8px 12px; border: 1px solid var(--border); background: var(--surface-2); text-decoration: none; min-width: 96px; }
.stat-card:hover { border-color: var(--border-soft); }
.stat-value { font-size: 20px; font-weight: 700; color: var(--text-bright); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat-label.error { color: var(--danger-text); }
.stat-label.in_sync { color: var(--ok-text); }
.stat-label.pending { color: var(--warn-text); }

.progress-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.progress-label { width: 90px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.progress-track { flex: 1; height: 10px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; background: var(--muted); }
.progress-fill.ok { background: var(--ok-text); }
.progress-fill.info { background: var(--link); }
.progress-fill.danger { background: var(--danger-text); }
.progress-fill.warn { background: var(--warn-text); }
.progress-count { width: 48px; text-align: right; color: var(--text-bright); }

/* Same three colours as .status-badge, from the same table (help::status):
   a word cannot be green in a list and grey on a card. */
.status-pill { display: inline-block; padding: 1px 7px; border: 1px solid var(--border); font-size: 11px; background: var(--surface-3); color: var(--text); }
.status-pill.ok { border-color: var(--ok-border); background: var(--ok-bg); color: var(--ok-text); }
.status-pill.warn { border-color: var(--warn-border); background: var(--warn-bg); color: var(--warn-text); }
.status-pill.error { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }
/* Something changed and has not been applied yet — a state, not a status. */
.status-pill.attention { background: var(--warn-bg); color: var(--warn-text); }

.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 4px 0; }
.panel-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.module-node { border: 1px solid var(--border); padding: 7px; margin: 7px 0; background: var(--surface-2); }
.module-node summary { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.artifacts-panel { margin: 10px 0 4px; }
.token-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: 3px 7px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; }

/* Tag chips (target card) */
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tag-chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border: 1px solid var(--border-soft); background: var(--surface-3); font-size: 12px; }
.tag-chip form { display: inline; margin: 0; }
.chip-remove { border: none; background: none; cursor: pointer; color: inherit; font-size: 13px; padding: 0 2px; opacity: .6; }
.chip-remove:hover { opacity: 1; }

/* One layout for every "label + trailing action" row: the action sits in a
   fixed column, so it never drifts with the label's length. */
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) 22px; align-items: center; }
.list-row-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-actions { display: inline-flex; align-items: center; justify-content: center; }
.list-row-actions form { margin: 0; }
.recent-search-clear { display: flex; justify-content: flex-end; margin: 0; padding: 4px 6px; border-top: 1px solid var(--border); }
.view-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Module rows: the Detach button keeps its own column too. */
.module-node summary .inline-form { margin-left: auto; }
.tag-chip { max-width: 320px; }
.tag-chip .list-row-label { max-width: 260px; }

/* Selection chips (incident views) */
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); padding: 4px 7px; background: var(--surface-2); }
.chip { display: inline-flex; align-items: center; min-height: 22px; border: 1px solid var(--border); padding: 0 8px; color: var(--text); background: var(--surface-3); text-decoration: none; }
.chip:hover { background: var(--hover); }
.chip.active { color: var(--text-bright); border-color: var(--accent-border); background: var(--accent-bg); }
.console-noise { display: inline-block; padding: 4px 7px; }

/* Filters are off by default: the list is what people came for. */
.list-layout { grid-template-columns: minmax(0, 1fr); }
.filter-panel { display: none; }
body.filters-open .list-layout { grid-template-columns: 248px minmax(0, 1fr); }
body.filters-open .filter-panel { display: block; }

/* Row selection, Redmine style: the whole cell is the checkbox's label, a
   selected row is unmistakable, and the operations live in a context menu. */
.select-cell input { margin: 0; }
.select-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  margin: -3px -7px;
  padding: 3px 7px;
  cursor: pointer;
}

tbody tr.selected td,
tbody tr.selected th {
  background: var(--select-bg);
  color: var(--text-bright);
}

tbody tr.selected td:first-child {
  box-shadow: inset 3px 0 0 var(--select-edge);
}

.bulk-trigger { color: var(--text-bright); }

.menu {
  position: fixed;
  z-index: var(--z-menu);
  display: flex;
  flex-direction: column;
  min-width: 230px;
  border: 1px solid var(--border-soft);
  padding: 3px;
  background: var(--surface-3);
  box-shadow: var(--shadow-2);
}

.menu-title {
  padding: 4px 7px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.menu-item {
  justify-content: flex-start;
  border-color: transparent;
  background: none;
  box-shadow: none;
}

.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger-text); }

.menu-group {
  display: grid;
  gap: 3px;
  padding: 4px 3px;
  border-top: 1px solid var(--border);
  margin-top: 3px;
}

.menu-group-actions { display: flex; gap: 3px; }

/* Searchable picker: replaces every dropdown a server list used to fill. */
.picker { position: relative; display: inline-block; min-width: 220px; }
.picker-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: var(--z-popup);
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
}

.picker-option {
  justify-content: flex-start;
  border: none;
  background: none;
  box-shadow: none;
  text-align: left;
}

.picker-option:hover,
.picker-option.active {
  background: var(--hover);
  color: var(--text-bright);
}

.picker-state { padding: 5px 8px; color: var(--muted); }

/* Raw / human values on object pages */
.raw-switch { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 400; }
.property-table .raw { display: none; }
body.raw-values .property-table .raw { display: inline; }
body.raw-values .property-table .cooked { display: none; }

/* ---------------------------------------------------------------------------
   Help: What's This? mode, the answer panel, and the manual's own typography.
   --------------------------------------------------------------------------- */

.help-toggle[aria-pressed="true"] {
  border-color: var(--accent-border);
  background: linear-gradient(var(--accent-top), var(--accent-bottom));
  color: var(--text-bright);
}

/* The `*` is needed: rows, buttons and summaries all set their own cursor and
   would win on specificity. */
body.help-mode,
body.help-mode * { cursor: help; }

/* Outline, never border or padding — nothing may move by a pixel while the
   operator is pointing at it. */
body.help-mode [data-help]:hover {
  outline: 1px solid var(--select-edge);
  outline-offset: -1px;
}

.help-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  z-index: var(--z-help);
  width: var(--help-panel-w);
  max-width: 100%;
  overflow: auto;
  border-left: 1px solid var(--border);
  padding: 7px;
  background: var(--surface-2);
  box-shadow: var(--shadow-3);
}

.help-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.help-panel-topic { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }
.help-panel-title { margin: 7px 0; color: var(--text-bright); font-weight: 700; }
.help-panel-body { margin-bottom: 14px; }

/* The manual. `.doc` is the shared type; `.doc-article` is the page — the
   340px answer panel uses the first without the second. */
.doc { line-height: 1.6; }
.doc-article { padding: 16px 20px 24px; max-width: 820px; }
.doc p { margin: 0 0 10px; }
.doc ul, .doc ol { margin: 0 0 12px; padding-left: 24px; }
.doc li { margin-bottom: 5px; }
.doc code { color: var(--text-bright); background: var(--field); padding: 0 3px; }
.doc a { text-decoration: none; }
.doc a:hover { text-decoration: underline; }
.doc .callout { margin: 12px 0; }

/* A section is a heading with a rule above it, never a card of its own. */
.doc h2 {
  margin: 26px 0 10px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  color: var(--text-bright);
  font-size: 14px;
  font-weight: 700;
}
.doc-article > h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }

/* A badge is a badge, not a link that grew an underline. */
.doc a.status-badge:hover { text-decoration: none; border-color: var(--select-edge); }
.doc h2 a.status-badge { font-size: 12px; }

.doc-disclaimer { color: var(--muted); font-size: 11px; }
.doc-disclaimer summary { cursor: pointer; }
.doc-disclaimer p { margin: 6px 0 0; }
/* At the head of an article it is a lid; in the answer panel it is a footer. */
.doc-article > .doc-disclaimer {
  margin: 0 0 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.help-panel .doc-disclaimer {
  margin: 16px 0 0;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.doc-toc {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  margin: 4px 0 6px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 9px 0;
}
.doc-toc-label { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }

.doc-defs { margin: 0 0 14px; }
.doc-defs dt { margin-top: 12px; color: var(--text-bright); font-weight: 700; }
.doc-defs dt:first-child { margin-top: 0; }
.doc-defs dd { margin: 3px 0 0; padding-left: 16px; border-left: 1px solid var(--border); }
.doc-code {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  padding: 9px 11px;
  overflow: auto;
  background: var(--field);
}
/* Deliberately not the danger callout: a note is not a broken page. */
.callout.note { border-color: var(--accent-border); background: var(--info-bg); }
.doc-anchor { color: inherit; text-decoration: none; }
.doc-search { display: inline-flex; align-items: center; gap: 4px; }
.doc-search input { width: 220px; }

/* The one-line answer under a form control: what to type, before you ask. */
.field-hint { color: var(--muted); font-weight: 400; }

/* A search hit shows the section's opening line, not the whole section. */
.doc-hits dd {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
