/* DediBlaze components: the one canonical class for every shared component.
 * Loaded last (styles.css → tokens.css → shell.css → servers.css → components.css).
 * Uses tokens only: no colour literals in this file (test/design-system.test.js).
 * Spec and do/don't: docs/design-system.md. Live reference: /design-system.
 * Selectors after a canonical class (e.g. ".home-tile") are deprecated aliases
 * kept so existing pages keep working; new code uses the canonical class. */

/* ================================================================ base */
html { -webkit-text-size-adjust: 100%; }
@media (max-width: 999px) { html { scroll-padding-top: 4.5rem; scroll-padding-bottom: calc(var(--nav-phone-h) + 4.5rem + env(safe-area-inset-bottom)); } }
body { font-family: var(--font-sans); color: var(--text); background: var(--bg); line-height: var(--leading); }
button, input, select, textarea { font-family: inherit; }
h1, h2, h3, h4 { font-weight: var(--weight-semibold); line-height: var(--leading-tight); letter-spacing: 0; }
strong, b { font-weight: var(--weight-semibold); }
code, kbd, samp, .mono { font-family: var(--font-mono); }
code { color: inherit; font-size: .92em; }
.mono { font-size: .92em; font-variant-numeric: tabular-nums; }
::selection { background: var(--info-soft); color: var(--text); }
:where(button, a, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.skip-link { z-index: var(--z-skip); background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-sm); font-weight: var(--weight-semibold); }

/* Brand mark: three rack units on an ember plate. */
.brand-mark { background: var(--accent); box-shadow: none; }
.brand-mark i { border-color: var(--accent-ink); }

/* ======================================================== page headers */
/* Page header: one h2 title, optional one-line description, actions on the right. */
.section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-4); margin: 0 0 var(--space-5); padding: 0; min-height: 0; background: none; border: 0; }
.section-heading h2, main .section-heading h2 { margin: 0; font-size: var(--text-2xl); font-weight: var(--weight-semibold); line-height: var(--leading-tight); letter-spacing: -.01em; }
.section-heading p:not(.eyebrow) { margin: var(--space-1) 0 0; color: var(--muted); font-size: var(--text-base); max-width: 70ch; }
.heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
/* Section header inside a page or panel: h3 on the left, .section-actions on the right. */
.section-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); }
.section-title h3, .section-title h4 { margin: 0; font-size: var(--text-md); }
.section-title p { margin: var(--space-1) 0 0; color: var(--muted); font-size: var(--text-sm); }
.section-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
/* Breadcrumb replaces "← Back" buttons on detail pages. */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin: 0 0 var(--space-3); overflow-wrap: anywhere; padding: 0; list-style: none; color: var(--muted); font-size: var(--text-sm); }
.breadcrumb li + li::before { content: "/"; margin-right: var(--space-1); color: var(--faint); }
.breadcrumb a, .breadcrumb button, .breadcrumb .row-link { color: var(--link); font-weight: var(--weight-medium); text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.breadcrumb a:hover, .breadcrumb button:hover { text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--text); }

/* ============================================================== panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; }
.panel-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table-scroll { overflow-x: auto; }
.panel-table .table-scroll { border-radius: inherit; }

/* ============================================================= buttons
 * .primary: the one main action in a view · .secondary-button: everything else ·
 * .ghost-button: low-emphasis actions in toolbars and rows · .danger: confirms a
 * destructive action (inside its confirmation) · .danger-outline: starts one ·
 * .link-button: an action that reads as a link · .icon-button: icon-only, needs aria-label.
 * Sizes: default 38 px, .btn-sm 30 px (table rows), .btn-lg 44 px (public pages, phone). */
.primary, .secondary-button, .ghost-button, button.danger, a.danger, .danger-outline, .icon-button, .dialog-close {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); padding: 0 var(--space-4); border: 1px solid transparent; border-radius: var(--radius-sm);
  font: var(--weight-medium) var(--text-base)/1.2 var(--font-sans); letter-spacing: 0; text-shadow: none; text-decoration: none; white-space: nowrap;
  box-shadow: none; filter: none; cursor: pointer; transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.primary, button.primary { background: var(--accent); background-image: none; border-color: var(--accent); color: var(--accent-ink); font-weight: var(--weight-semibold); }
.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); filter: none; }
.secondary-button { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.secondary-button:hover:not(:disabled) { background: var(--surface-3); border-color: var(--control-border); }
.ghost-button { background: transparent; border-color: transparent; color: var(--muted); }
.ghost-button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
button.danger, a.danger { background: var(--danger-fill); background-image: none; border-color: var(--danger-fill); color: var(--danger-ink); font-weight: var(--weight-semibold); }
button.danger:hover:not(:disabled), a.danger:hover { background: var(--danger-fill-strong); border-color: var(--danger-fill-strong); }
.danger-outline { background: transparent; border-color: var(--danger); color: var(--danger-text); }
.danger-outline:hover:not(:disabled) { background: var(--danger-soft); }
.icon-button, .dialog-close { flex: none; width: var(--control-h); padding: 0; background: var(--surface-2); border-color: var(--line-strong); color: var(--muted); }
.icon-button:hover:not(:disabled), .dialog-close:hover { color: var(--text); border-color: var(--control-border); }
.link-button { display: inline-block; min-height: 24px; padding: 2px 0; border: 0; background: none; color: var(--link); font: inherit; font-weight: var(--weight-medium); text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; cursor: pointer; }
.link-button:hover:not(:disabled) { text-decoration-color: currentColor; }
.btn-sm { min-height: var(--control-h-sm); padding: 0 var(--space-3); font-size: var(--text-sm); }
.icon-button.btn-sm { width: var(--control-h-sm); padding: 0; }
.btn-lg { min-height: var(--control-h-lg); padding: 0 var(--space-5); font-size: var(--text-md); }
:is(.primary, .secondary-button, .ghost-button, button.danger, a.danger, .danger-outline, .icon-button, .link-button):disabled { opacity: .5; cursor: not-allowed; }
:is(.primary, .secondary-button, .ghost-button, button.danger, a.danger, .danger-outline, .icon-button) .ico { width: 16px; height: 16px; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
@media (max-width: 700px) {
  .primary, .secondary-button, .ghost-button, button.danger, a.danger, .danger-outline { min-height: var(--control-h-lg); }
  .icon-button { width: var(--control-h-lg); min-height: var(--control-h-lg); }
  .btn-sm { min-height: 36px; }
}

/* =============================================================== links */
.text-link { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.text-link:hover { text-decoration-thickness: 2px; }
.text-link[target="_blank"]::after { content: " ↗"; }

/* ============================================================== forms */
.form-stack { display: grid; gap: var(--space-4); align-content: start; max-width: 40rem; }
.form-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); align-items: start; }
.form-cols > .span-all { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-cols { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; align-content: start; gap: var(--space-1); min-width: 0; color: var(--text); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.field > .optional, .field .optional { color: var(--faint); font-weight: var(--weight-regular); }
:is(.field, .form-stack, .form-cols, .dialog, .filter-bar) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
.control {
  display: block; width: 100%; min-width: 0; min-height: var(--control-h); margin: 0; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--control-border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
  font: var(--weight-regular) var(--text-base)/1.35 var(--font-sans);
}
:is(.field, .form-stack, .form-cols, .dialog) textarea, textarea.control { min-height: 6rem; resize: vertical; }
:is(.field, .form-stack, .form-cols, .dialog, .filter-bar) :is(input, select, textarea)::placeholder, .control::placeholder { color: var(--faint); }
:is(.field, .form-stack, .form-cols, .dialog, .filter-bar) :is(input, select, textarea):disabled, .control:disabled { opacity: .6; cursor: not-allowed; }
:is(.field, .form-stack, .form-cols, .dialog, .filter-bar) :is(input, select, textarea)[readonly], .control[readonly] { background: var(--surface-2); border-style: dashed; }
:is(input, select, textarea)[aria-invalid="true"] { border-color: var(--danger); }
.field-hint { margin: 0; color: var(--muted); font-size: var(--text-sm); font-weight: var(--weight-regular); }
.field-error { margin: 0; color: var(--danger-text); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.field-error:empty { display: none; }
.dialog-error { margin: 0; color: var(--danger-text); font-size: var(--text-sm); }
.dialog-error:empty { display: none; }
/* Checkbox and radio: the input sits before its text inside one label. */
.check, .radio-option { display: flex; align-items: flex-start; gap: var(--space-2); min-height: 24px; color: var(--text); font-size: var(--text-base); font-weight: var(--weight-regular); cursor: pointer; }
.check input, .radio-option input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; padding: 0; accent-color: var(--accent); }
.check small, .radio-option small { display: block; color: var(--muted); font-size: var(--text-sm); }
.check-group, .radio-group { display: grid; gap: var(--space-2); margin: 0; padding: 0; border: 0; min-width: 0; }
.check-group > legend, .radio-group > legend { margin-bottom: var(--space-2); padding: 0; color: var(--text); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.radio-group.inline { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.radio-option > span { display: grid; gap: 2px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
/* Form-level messages: one summary per form, next to its submit button. */
.form-error, .form-success { margin: 0; padding: var(--space-2) var(--space-3); border: 1px solid; border-radius: var(--radius-sm); font-size: var(--text-sm); }
.form-error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger-text); }
.form-success { border-color: var(--ok); background: var(--ok-soft); color: var(--ok-text); }
.form-error[hidden], .form-success[hidden], .form-error:empty, .form-success:empty { display: none; }
.form-feedback { margin: 0; color: var(--ok-text); font-size: var(--text-sm); }
.form-feedback.error { color: var(--danger-text); }
.form-feedback:empty { display: none; }

/* ============================================================== tables */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-base); font-variant-numeric: tabular-nums; }
.data-table caption { padding: var(--space-3) var(--space-4); color: var(--muted); font-size: var(--text-sm); text-align: left; }
.data-table th { padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--line); color: var(--muted); font-size: var(--text-sm); font-weight: var(--weight-semibold); letter-spacing: 0; text-transform: none; text-align: left; white-space: nowrap; vertical-align: bottom; }
.data-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--hover-row); }
.data-table tbody tr[aria-selected="true"] td { background: var(--surface-2); }
.data-table :is(th, td).num { text-align: right; }
.data-table td small, .data-table .cell-meta { display: block; color: var(--faint); font-size: var(--text-xs); }
.data-table td.actions { width: 1%; white-space: nowrap; }
.data-table .select-col { width: 1%; padding-right: 0; }
.data-table .select-col input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.data-table.dense td { padding: var(--space-2) var(--space-3); }
.data-table.dense th { padding: var(--space-2) var(--space-3); }
.data-table th[aria-sort] { padding: 0; }
.sort-button { display: inline-flex; align-items: center; gap: var(--space-1); width: 100%; min-height: 0; padding: var(--space-2) var(--space-4); border: 0; background: none; color: inherit; font: inherit; text-align: inherit; cursor: pointer; }
.sort-button:hover, th[aria-sort="ascending"] .sort-button, th[aria-sort="descending"] .sort-button { color: var(--text); }
.row-link { padding: 0; border: 0; background: none; color: var(--text); font: var(--weight-semibold) var(--text-base)/1.3 var(--font-sans); text-align: left; cursor: pointer; }
.row-link:hover { color: var(--link); text-decoration: underline; }
.row-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
@media (min-width: 701px) { .row-actions .icon-button { width: var(--control-h-sm); min-height: var(--control-h-sm); } }
/* Unclassed row buttons (older lists) get the small secondary look. */
.row-actions button:where(:not(.primary, .secondary-button, .ghost-button, .danger, .danger-outline, .link-button, .icon-button)) { min-height: var(--control-h-sm); padding: 0 var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: var(--weight-medium) var(--text-sm)/1.2 var(--font-sans); cursor: pointer; }
.row-actions button:where(:not(.primary, .secondary-button, .ghost-button, .danger, .danger-outline, .link-button, .icon-button)):hover { border-color: var(--control-border); background: var(--surface-3); }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); padding: var(--space-2) 0; font-size: var(--text-sm); }
.bulk-bar > span { margin-right: auto; }
.bulk-bar[hidden] { display: none; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); margin: var(--space-3) 0 0; color: var(--muted); font-size: var(--text-sm); }
.pager-buttons { display: flex; align-items: center; gap: var(--space-2); }
/* Phone: a .stack table becomes a two-line row (dataTable() in dom.js sets
 * data-label on every cell). Line 1: the first cell (the record name) and the
 * second cell (usually its status) on the right. Line 2: the other cells as
 * small "label value" pairs that wrap, then the row actions. td.phone-hide is
 * dropped; cells with data-label="" show their value without a label. */
@media (max-width: 700px) {
  .data-table.stack thead { display: none; }
  .data-table.stack, .data-table.stack tbody { display: block; width: auto; }
  .data-table.stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
  .data-table.stack tbody tr:last-child { border-bottom: 0; }
  .data-table.stack :where(td) { display: block; flex: 0 1 auto; min-width: 0; padding: 0; border: 0; text-align: left; overflow-wrap: anywhere; color: var(--muted); font-size: var(--text-sm); }
  .data-table.stack :where(td)::before { content: attr(data-label) " "; color: var(--faint); }
  .data-table.stack :where(td:first-child), .data-table.stack :where(td:nth-child(2)), .data-table.stack :where(td.actions), .data-table.stack :where(td[data-label=""]), .data-table.stack :where(td:not([data-label])) { font-size: inherit; }
  .data-table.stack :where(td:first-child)::before, .data-table.stack :where(td:nth-child(2))::before, .data-table.stack :where(td.actions)::before, .data-table.stack :where(td.select-col)::before, .data-table.stack :where(td[data-label=""])::before, .data-table.stack :where(td:not([data-label]))::before { content: none; }
  .data-table.stack :where(td:first-child) { flex: 1 1 55%; color: var(--text); font-size: var(--text-md); }
  .data-table.stack :where(td:nth-child(2)) { flex: 0 0 auto; margin-left: auto; color: var(--text); }
  .data-table.stack :where(td:first-child.select-col, td:first-child:has(> input[type="checkbox"]:only-child)) { flex: 0 0 auto; }
  .data-table.stack :where(td.select-col + td, td:first-child:has(> input[type="checkbox"]:only-child) + td) { flex: 1 1 50%; color: var(--text); font-size: var(--text-md); }
  .data-table.stack :where(td.select-col + td)::before { content: none; }
  .data-table.stack :where(td.select-col + td) { margin-left: 0; }
  .data-table.stack :where(td.select-col + td + td) { flex: 0 0 auto; margin-left: auto; color: var(--text); }
  .data-table.stack :where(td.select-col + td + td)::before { content: none; }
  .data-table.stack :where(td > small), .data-table.stack :where(td > .cell-meta) { display: inline; margin-left: var(--space-1); }
  .data-table.stack :where(td:first-child > small), .data-table.stack :where(td.select-col + td > small) { display: block; margin: 0; }
  .data-table.stack :where(td.num) { text-align: left; }
  .data-table.stack :where(td.actions) { flex: 1 1 100%; width: auto; padding-top: var(--space-1); white-space: normal; }
  .data-table.stack :where(td.phone-hide) { display: none; }
  .data-table.stack tbody tr:hover td { background: none; }
  .table-scroll.panel-table:has(.data-table.stack), .panel-table .table-scroll:has(.data-table.stack) { overflow-x: visible; }
  .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .bulk-bar { position: sticky; bottom: calc(var(--nav-phone-h) + env(safe-area-inset-bottom)); z-index: var(--z-sticky); margin: 0 calc(-1 * var(--space-2)); padding: var(--space-2); border-top: 1px solid var(--line); background: var(--surface); }
  .bulk-bar > span { flex: 1 1 100%; }
  .bulk-bar button { flex: 1 1 auto; }
}

/* =================================================== status: LED and pill
 * .dot-status is a front-panel LED followed by its label. ok = green (healthy,
 * on, up), warn = amber (attention, degraded), bad = red (fault, down), info =
 * blue (identify lamp, informational), off = unlit ring (powered off, inactive),
 * pending = amber, slow pulse (an action is in flight). */
.dot-status { display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; font-size: inherit; }
.dot-status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--off); box-shadow: none; }
.dot-status.ok::before { background: var(--ok); box-shadow: 0 0 0 3px var(--glow-ok); }
.dot-status.warn::before, .dot-status.pending::before { background: var(--warn); box-shadow: 0 0 0 3px var(--glow-warn); }
.dot-status.bad::before { background: var(--danger); box-shadow: 0 0 0 3px var(--glow-danger); }
.dot-status.info::before { background: var(--info); box-shadow: 0 0 0 3px var(--glow-info); }
.dot-status.off::before { width: 6px; height: 6px; background: transparent; border: 1.5px solid var(--off); }
.dot-status.pending::before { animation: led-pulse 1.6s ease-in-out infinite; }
@keyframes led-pulse { 50% { opacity: .35; } }
/* .status (pill() in dom.js) is the same dot-plus-label as the LED, for a
 * record's state. One status style everywhere: no filled pills. Tones:
 * accent = the viewer must act (ember dot, ember label) · neutral = waiting on
 * someone else or a plain fact (unlit dot) · ok = done · warn = at risk ·
 * bad = failed or overdue · info = informational. "online" and "offline" are
 * deprecated aliases of ok and bad. */
.status { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; color: var(--text); font-size: inherit; font-weight: var(--weight-medium); line-height: inherit; white-space: nowrap; box-shadow: none; }
.status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: transparent; border: 1.5px solid var(--off); }
.status, .status.neutral, .status.ok, .status.online, .status.warn, .status.bad, .status.offline, .status.info, .status.accent { background: none; border-color: transparent; }
.status.ok::before, .status.online::before { border: 0; background: var(--ok); box-shadow: 0 0 0 3px var(--glow-ok); }
.status.warn::before { border: 0; background: var(--warn); box-shadow: 0 0 0 3px var(--glow-warn); }
.status.bad::before, .status.offline::before { border: 0; background: var(--danger); box-shadow: 0 0 0 3px var(--glow-danger); }
.status.info::before { border: 0; background: var(--info); box-shadow: 0 0 0 3px var(--glow-info); }
.status.accent { color: var(--accent-text); font-weight: var(--weight-semibold); }
.status.accent::before { border: 0; background: var(--accent); }
.status.bad, .status.offline { color: var(--danger-text); }
/* .tag: a user-defined label (server labels). Rectangular like a printed rack label. */
.tag, .label-chips span { display: inline-flex; align-items: center; max-width: 16rem; padding: 0 var(--space-2); min-height: 20px; border: 1px solid var(--line-strong); border-radius: var(--radius-xs); background: transparent; color: var(--muted); font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags, .label-chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }

/* =========================================================== chips/filters */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin: 0 0 var(--space-3); }
.filter-bar input[type="search"] { flex: 1 1 18rem; max-width: 26rem; width: auto; }
.filter-bar select { width: auto; }
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.chip { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 32px; padding: 0 var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface); color: var(--muted); font: var(--weight-medium) var(--text-sm)/1 var(--font-sans); cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--control-border); }
.chip[aria-pressed="true"], .chip[aria-selected="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.chip .count { color: var(--faint); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .count { color: var(--accent-text); }
@media (max-width: 700px) { .chip { min-height: 40px; } }

/* ================================================================ tabs
 * One row of tabs per page. role="tablist" > button[role="tab"][aria-selected]
 * with aria-controls; panels role="tabpanel". Wire keys with wireTabs() in dom.js. */
.tabs, .manager-tabs, .sub-tabs, .server-subtabs { display: flex; gap: var(--space-1); margin: 0 0 var(--space-5); padding: 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs > [role="tab"], .manager-tabs > [role="tab"], .sub-tabs > [role="tab"] , .server-subtabs > [role="tab"] {
  flex: none; display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; margin: 0 0 -1px; padding: 0 var(--space-3);
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted);
  font: var(--weight-medium) var(--text-base)/1.2 var(--font-sans); white-space: nowrap; cursor: pointer;
}
.tabs > [role="tab"]:hover, .manager-tabs > [role="tab"]:hover, .sub-tabs > [role="tab"]:hover , .server-subtabs > [role="tab"]:hover { color: var(--text); background: none; border-color: transparent; }
.tabs > [role="tab"][aria-selected="true"], .manager-tabs > [role="tab"][aria-selected="true"], .sub-tabs > [role="tab"][aria-selected="true"] , .server-subtabs > [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); background: none; }
.tabs > [role="tab"]:focus-visible, .manager-tabs > [role="tab"]:focus-visible, .sub-tabs > [role="tab"]:focus-visible , .server-subtabs > [role="tab"]:focus-visible { outline-offset: -2px; }
.tabs > [role="tab"][hidden], .manager-tabs > [role="tab"][hidden], .sub-tabs > [role="tab"][hidden] , .server-subtabs > [role="tab"][hidden] { display: none; }
.tabs .count { color: var(--faint); font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .tabs > [role="tab"], .manager-tabs > [role="tab"], .sub-tabs > [role="tab"] , .server-subtabs > [role="tab"] { min-height: 44px; } }
/* A tab row that scrolls sideways fades at the edge that has more tabs, so the
 * hidden ones are discoverable on phones (scroll-driven; no effect when it fits). */
@supports (animation-timeline: scroll()) {
  .tabs, .manager-tabs, .sub-tabs, .server-subtabs { animation: tabs-edge linear both; animation-timeline: scroll(self inline); }
  @keyframes tabs-edge {
    0% { mask-image: linear-gradient(to right, black 85%, transparent); }
    1%, 99% { mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent); }
    100% { mask-image: linear-gradient(to right, transparent, black 15%); }
  }
}

/* ======================================================= definition lists
 * Read-only data: label column then value column; one column on phones. */
.facts, .kv { display: grid; grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr); gap: var(--space-2) var(--space-5); margin: 0; font-size: var(--text-base); }
.facts dt, .kv dt { color: var(--muted); }
.facts dd, .kv dd { margin: 0; overflow-wrap: anywhere; }
.facts dd .mono, .facts dd code { font-size: .95em; }
@media (max-width: 560px) { .facts, .kv { grid-template-columns: minmax(0, 1fr); gap: 0; } .facts dd, .kv dd { margin-bottom: var(--space-3); } }
/* .facts-stack: long labels stack earlier, from 650 px. */
@media (max-width: 650px) { .facts.facts-stack { grid-template-columns: minmax(0, 1fr); gap: 0; } .facts.facts-stack dd { margin-bottom: var(--space-3); } }
/* Settings section: read-only by default, one Edit button that opens a dialog. */
.settings-section { display: grid; gap: var(--space-3); padding: var(--space-4) var(--space-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.settings-section > header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.settings-section > header h3 { margin: 0; font-size: var(--text-md); }
.settings-section > header p { margin: var(--space-1) 0 0; color: var(--muted); font-size: var(--text-sm); }
.settings-stack { display: grid; gap: var(--space-4); max-width: var(--reading-max); }

/* ========================================================== tiles / KPIs */
.tiles, .home-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: var(--space-3); }
.tile, .home-tile { display: grid; gap: var(--space-1); align-content: start; min-width: 0; overflow-wrap: anywhere; padding: var(--space-3) var(--space-4); text-align: left; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }
button.tile, button.home-tile { cursor: pointer; }
.tile[aria-pressed="true"], .home-tile[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); }
button.tile:hover, button.home-tile:hover { border-color: var(--line-strong); background: var(--surface-2); }
.tile-label, .home-tile-label { color: var(--muted); font-size: var(--text-sm); font-weight: var(--weight-medium); letter-spacing: 0; text-transform: none; }
.tile-value, .tile > strong, .home-tile > strong { font-size: var(--text-xl); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; line-height: var(--leading-tight); }
.tile-note, .home-tile-note { color: var(--muted); font-size: var(--text-sm); }
.tile.alert, .home-tile.alert { border-color: var(--danger); }
.tile.alert .tile-note, .home-tile.alert .home-tile-note { color: var(--danger-text); }
.tile.attention, .home-tile.attention { border-color: var(--accent-line); }
/* Meter: native <progress class="meter" value max>. */
progress.meter { appearance: none; display: block; width: 100%; height: 6px; border: 0; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
progress.meter::-webkit-progress-bar { background: var(--surface-3); }
progress.meter::-webkit-progress-value { background: var(--ok); }
progress.meter::-moz-progress-bar { background: var(--ok); }
progress.meter.warn::-webkit-progress-value { background: var(--warn); }
progress.meter.warn::-moz-progress-bar { background: var(--warn); }
progress.meter.bad::-webkit-progress-value { background: var(--danger); }
progress.meter.bad::-moz-progress-bar { background: var(--danger); }

/* ============================================================= notices */
.notice { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2) var(--space-3); margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); border: 1px solid var(--line-strong); border-left-width: 3px; border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: var(--text-base); }
.notice > p, .notice > div { flex: 1 1 18rem; margin: 0; }
.notice.info { border-color: var(--info); background: var(--info-soft); }
.notice.ok { border-color: var(--ok); background: var(--ok-soft); }
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.notice.bad { border-color: var(--danger); background: var(--danger-soft); }
.notice.accent { border-color: var(--accent); background: var(--accent-soft); }

/* ============================================================ dialogs
 * Native <dialog class="dialog"> opened with showModal(); aria-labelledby its h2.
 * Desktop: centred. Phone: a bottom sheet; .form-sheet makes it full screen. */
.dialog, .confirm-dialog, .sp-dialog, .edit-dialog {
  width: min(32rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); margin: auto; padding: 0; overflow: auto;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-3);
}
.dialog.wide { width: min(48rem, calc(100vw - 2rem)); }
.dialog::backdrop, .confirm-dialog::backdrop, .sp-dialog::backdrop, .edit-dialog::backdrop { background: var(--overlay); backdrop-filter: none; }
.dialog > form, .dialog > .dialog-body, .confirm-dialog > form, .sp-dialog > form, .edit-dialog > form { display: grid; gap: var(--space-3); padding: var(--space-5); }
.dialog h2, .confirm-dialog h2, .sp-dialog h2, .edit-dialog-form h3 { margin: 0; font-size: var(--text-lg); line-height: var(--leading-tight); }
.dialog p, .confirm-dialog p { margin: 0; color: var(--muted); line-height: var(--leading); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.dialog-head p { margin: var(--space-1) 0 0; overflow-wrap: anywhere; }
.dialog-close { width: 36px; min-height: 36px; }
/* Side-sheet variant of an edit dialog (modal() dialog with .drawer). */
.edit-dialog.drawer { inset: 0 0 0 auto; margin: 0 0 0 auto; width: min(30rem, 100vw); height: 100dvh; max-height: 100dvh; border-radius: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }
.dialog-actions > button { min-width: 6rem; }
@media (max-width: 560px) {
  .dialog, .confirm-dialog, .sp-dialog, .edit-dialog { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-width: 1px 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .dialog.form-sheet, .edit-dialog, .edit-dialog.drawer { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border-width: 0; }
  :is(.dialog.form-sheet, .edit-dialog) .dialog-actions { position: sticky; bottom: 0; padding-top: var(--space-2); background: var(--surface); }
  .dialog > form, .dialog > .dialog-body, .confirm-dialog > form, .sp-dialog > form, .edit-dialog > form { padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); }
  .dialog-actions { flex-direction: column-reverse; align-items: stretch; }
  .dialog-actions > button { width: 100%; min-height: var(--control-h-lg); }
}
/* Typed confirmation: confirmAction({ typed }) in confirm.js renders this. */
.typed-confirm code { padding: 0 var(--space-1); border-radius: var(--radius-xs); background: var(--surface-3); color: var(--text); }

/* ============================================================== drawer
 * Side panel for a record's details over a list. Desktop: 440 px from the right.
 * Phone: full screen. Read-only content; edits open a dialog or an inline form. */
.drawer { position: fixed; inset: 0 0 0 auto; z-index: var(--z-drawer); width: min(440px, 100vw); height: 100dvh; max-height: none; margin: 0; padding: 0; overflow-y: auto; border: 0; border-left: 1px solid var(--line-strong); border-radius: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }
.drawer[hidden] { display: none; }
.drawer::backdrop { background: var(--overlay); }
.drawer > header { position: sticky; top: 0; z-index: var(--z-raised); display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer > header h2, .drawer > header h3 { margin: 0; font-size: var(--text-lg); overflow-wrap: anywhere; }
.drawer > section { display: grid; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--line); }
.drawer > section > h3, .drawer > section > header h3 { margin: 0; font-size: var(--text-sm); color: var(--muted); font-weight: var(--weight-semibold); }
@media (max-width: 700px) { .drawer { width: 100vw; border-left: 0; z-index: var(--z-sheet); } }

/* =============================================================== menu */
.menu { position: relative; display: inline-block; }
.menu-list { position: absolute; z-index: var(--z-menu); top: calc(100% + 4px); left: 0; display: grid; min-width: 12rem; margin: 0; padding: var(--space-1); list-style: none; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); box-shadow: var(--shadow-1); }
.menu-list[hidden] { display: none; }
.menu-list [role="menuitem"] { display: flex; align-items: center; width: 100%; min-height: 36px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-xs); background: none; color: var(--text); font: var(--weight-regular) var(--text-base)/1.2 var(--font-sans); text-align: left; cursor: pointer; }
.menu-list [role="menuitem"]:hover, .menu-list [role="menuitem"]:focus-visible { background: var(--surface-3); outline-offset: -2px; }
.menu-list [role="menuitem"].destructive { color: var(--danger-text); }
.menu-list [role="separator"] { height: 1px; margin: var(--space-1) 0; background: var(--line); }

/* ============================================================== toasts
 * toast() in dom.js. One region, bottom right (above the phone nav). Toasts
 * confirm an action the person just took; they never carry the only copy of an error. */
.toast-region { position: fixed; z-index: var(--z-toast); right: var(--space-5); bottom: var(--space-5); display: grid; justify-items: end; gap: var(--space-2); width: min(26rem, calc(100vw - 2rem)); pointer-events: none; }
.toast, .ai-undo { display: flex; align-items: center; gap: var(--space-3); max-width: 100%; padding: var(--space-3) var(--space-4); border: 1px solid var(--line-strong); border-left: 3px solid var(--ok); border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-2); font-size: var(--text-base); pointer-events: auto; }
.toast > span { flex: 1; }
.toast.bad { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast.info, .ai-undo { border-left-color: var(--info); }
.toast .link-button { flex: none; }
@media (max-width: 999px) { .toast-region { right: var(--space-4); left: var(--space-4); bottom: calc(var(--nav-phone-h) + var(--space-3) + env(safe-area-inset-bottom)); width: auto; justify-items: stretch; } }

/* ======================================================== empty states
 * emptyState() in dom.js: an icon, one sentence that says what will appear here
 * and when, and at most one action. */
.empty-state, .empty-block { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-8) var(--space-4); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: var(--text-base); line-height: var(--leading); }
.empty-state > h3, .empty-state > strong { margin: 0; color: var(--text); font-size: var(--text-md); font-weight: var(--weight-semibold); }
.empty-state > p, .empty-block > p { margin: 0; max-width: 46ch; color: var(--muted); }
.panel .empty-state, .panel-table .empty-state { border: 0; background: none; }
.empty-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3); color: var(--muted); }
.empty-icon .ico { width: 20px; height: 20px; }

/* ================================================== loading / skeletons */
.skeleton { display: block; border-radius: var(--radius-xs); background: var(--surface-3); animation: skeleton-fade 1.4s ease-in-out infinite; }
.skeleton-line { height: .8em; margin: .35em 0; }
.skeleton-line.short { width: 40%; }
.skeleton-block { height: 4.5rem; border-radius: var(--radius); }
@keyframes skeleton-fade { 50% { opacity: .45; } }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--text); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
[aria-busy="true"] > .when-idle { display: none; }

/* ===================================================== timeline / thread */
.timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.timeline > li { position: relative; display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: var(--space-3); padding: var(--space-2) 0 var(--space-2) var(--space-5); font-size: var(--text-base); }
.timeline > li::before { content: ""; position: absolute; left: 3px; top: 1rem; width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.timeline > li::after { content: ""; position: absolute; left: 6px; top: 1.6rem; bottom: -.4rem; width: 2px; background: var(--line); }
.timeline > li:last-child::after { display: none; }
.timeline > li.ok::before { background: var(--ok); }
.timeline > li.warn::before, .timeline > li.pending::before { background: var(--warn); }
.timeline > li.bad::before { background: var(--danger); }
.timeline > li.info::before { background: var(--info); }
.timeline time { color: var(--faint); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.timeline p { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .timeline > li { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.thread { display: grid; gap: var(--space-3); max-width: var(--reading-max); margin: 0; padding: 0; list-style: none; }
.message { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.message.mine { background: var(--surface-2); }
.message.ai { border-left: 3px solid var(--accent); }
.message.internal { border-style: dashed; border-color: var(--warn); background: var(--warn-soft); }
.message-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); color: var(--muted); font-size: var(--text-sm); }
.message-meta strong { color: var(--text); }
.message-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: var(--leading-loose); }

/* ======================================================== list and detail
 * Support, approvals, interventions, work orders: a list 360–420 px wide and the
 * selected record filling the rest. .three-pane adds context (280 px) and
 * properties (300 px) around a conversation. Below 1000 px the detail replaces
 * the list (add .has-detail) and a breadcrumb leads back. */
.list-detail { display: grid; grid-template-columns: minmax(360px, 420px) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.list-detail.three-pane { grid-template-columns: 280px minmax(0, 1fr) 300px; }
.list-detail-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; max-height: 75dvh; overflow-y: auto; min-width: 0; }
.list-detail-detail { min-width: 0; }
.list-item { display: grid; gap: 2px; width: 100%; min-width: 0; padding: var(--space-3); border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.list-item:hover { background: var(--surface-2); }
.list-item[aria-current="true"], .list-item[aria-selected="true"] { background: var(--surface-2); border-color: var(--line-strong); box-shadow: inset 2px 0 0 var(--accent); }
.list-item small { color: var(--muted); font-size: var(--text-sm); }
@media (max-width: 999px) {
  .list-detail, .list-detail.three-pane { grid-template-columns: minmax(0, 1fr); }
  .list-detail.has-detail > .list-detail-list { display: none; }
}

/* ============================================================== wizard */
.steps { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin: 0 0 var(--space-5); padding: 0; list-style: none; counter-reset: step; font-size: var(--text-sm); }
.steps > li { display: flex; align-items: center; gap: var(--space-2); color: var(--muted); counter-increment: step; }
.steps > li::before { content: counter(step); display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.steps > li[aria-current="step"] { color: var(--text); font-weight: var(--weight-semibold); }
.steps > li[aria-current="step"]::before { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.steps > li.done::before { content: "✓"; border-color: var(--ok); color: var(--ok-text); }
.wizard-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--line); }

/* ======================================================= copyable value */
/* ============================================== truncation and wrapping
 * Record names, IDs, hostnames, IPs and money never break mid-word. Long free
 * text truncates (.truncate, with a title attribute holding the full text) or
 * clamps to two lines (.clamp-2). */
.nowrap { white-space: nowrap; }
.truncate { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
@media (min-width: 701px) {
  .data-table :is(.row-link, .mono, code, time), .data-table :is(td, th).num, .data-table td:first-child, .data-table td:first-child > :is(strong, a, button) { white-space: nowrap; }
  .data-table td:first-child:not(.select-col):not(:has(> input[type="checkbox"]:only-child)) { min-width: 9rem; }
}

.copy-value { display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%; }
.copy-value code { overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* FREE-ACCOUNTS: facts with one <div> per row (public/free-accounts.js) keep the .kv / .facts grid. */
.fa-facts > div { display: contents; }
.customer-name-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.sp-service-line { margin: var(--space-1) 0 0; }
