/* ============================================================
  IVSS Industrial Monitoring - Enterprise UI
  Design language: aerospace console (Boeing / Airbus inspired)
  Deep graphite surfaces, avionics cyan accents, mono typography
  ============================================================ */

:root {
  --line: transparent;
  --line-2: transparent;
  --bg:             #090d13;
  --panel:          #0f141c;
  --panel-hdr:      #0b1017;
  --sidebar-bg:     #080c12;
  --appbar-bg:      #0a0f16;
  --border:         #1f2b39;
  --border-2:       #2e4258;
  --input-bg:       #0c1219;
  --panel-2:        #111925;
  --panel-header-bg: #101822;
  --panel-header-bg-2: #0c131b;
  --panel-header-border: #243447;
  --panel-header-accent: #3e739f;

  --text:           #b5c5d3;
  --text-strong:    #dce8f2;
  --text-soft:      #c6d4df;
  --muted:          #8095a8;
  --muted-2:        #7389a0;

  --normal:         #3b8d66;
  --normal-bg:      rgba(59, 141, 102, 0.14);
  --normal-fg:      #7cc7a3;

  --warning:        #a48232;
  --warning-bg:     rgba(164, 130, 50, 0.16);
  --warning-fg:     #d6b260;

  --critical:       #95433d;
  --critical-bg:    rgba(149, 67, 61, 0.16);
  --critical-fg:    #e8a09b;

  --info:           #3e739f;
  --info-fg:        #7ab8e6;
  --accent:         #7ab8e6;
  --control-bg:     #0b121a;
  --control-hover:  #122231;
  --control-active: #8fb7d6;
  --control-active-text: #071018;

  --axis-x:         #5590ba;
  --axis-y:         #549870;
  --axis-z:         #a88840;

  --scroll-track:   #090d13;
  --scroll-track-2: #0c1219;
  --scroll-thumb:   #2e4258;
  --scroll-thumb-hover: #3e739f;
  --scroll-thumb-active: #7ab8e6;

  /* Typography system */
  --font-ui: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --font-display: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;

  /* Secondary "AI" accent — pairs with --accent on the
     Pattern Recognizer page only. Cyan-to-violet is a restrained
     neural/AI motif that stays inside the existing cool palette. */
  --ai-accent-2: #9d8ce6;
}

/* ===================== JETBRAINS-STYLE SCROLLBARS ===================== */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--scroll-track);
  box-shadow: inset 0 0 0 1px var(--line);
}

*::-webkit-scrollbar-thumb {
  min-height: 34px;
  min-width: 34px;
  background: var(--scroll-thumb);
  border: 2px solid var(--scroll-track);
  border-radius: 0;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

*::-webkit-scrollbar-thumb:active {
  background: var(--scroll-thumb-active);
}

*::-webkit-scrollbar-corner {
  background: var(--bg);
  box-shadow: inset 1px 1px 0 var(--border);
}

.table-shell,
.pagination-controls,
.ai-label-list,
.event-log,
.operations-grid {
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

.fleet-search-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 140px;
  gap: 8px;
  margin: 0 0 10px;
}

.fleet-search-input,
.fleet-page-size {
  min-height: 36px;
  width: 100%;
  background: var(--input-bg);
  color: var(--text-strong);
  border: 1px solid var(--line-2);
  border-radius: 0;
  padding: 8px 10px;
  font: 12px var(--font-ui);
  letter-spacing: 0;
}

.fleet-search-input:focus,
.fleet-page-size:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ===================== PERFORMANCE MONITOR ===================== */

.perf-monitor {
  position: fixed;
  bottom: 6px;
  right: 8px;
  z-index: 9999;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--panel-hdr) 82%, transparent);
  border: 1px solid var(--line-2);
  color: var(--muted-2);
  font-family: var(--font-ui);
  font-size: 9.5px;
  pointer-events: none;
  white-space: nowrap;
}

.metric-card strong,
.engineering-grid dd,
.selected-detail dd {
  transition: color 180ms ease, background-color 300ms ease, text-shadow 300ms ease;
}

.metric-card strong,
.engineering-grid dd,
.selected-detail dd,
.system-health-grid dd,
.detail-list dd,
.appbar-item strong,
.status-value,
.kpi-value,
.chart-stat-value,
.axis-value,
.ai-confidence-pct,
.ai-signature-meter-value,
.ai-status-value,
.fleet-table td,
.asset-table td,
.value-mono,
code,
pre {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.value-updated {
  color: var(--text-strong);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 18%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .metric-card strong,
  .engineering-grid dd,
  .selected-detail dd {
    transition: none;
  }

  .value-updated {
    text-shadow: none;
  }
}

/* ===================== SIDEBAR TOGGLE (mobile hamburger) ===================== */

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 100%;
  min-width: 44px;
  padding: 0 12px;
  background: var(--control-bg);
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--text);
  font-size: 17px;
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.sidebar-toggle:hover  { background: var(--control-hover); color: var(--text-strong); }
.sidebar-toggle:active,
.sidebar-toggle[aria-expanded="true"] {
  background: var(--control-active);
  color: var(--control-active-text);
}

/* ===================== RESET / BASE ===================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  min-width: 0;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  height: 100dvh;
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.startup-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-strong);
  transition: opacity 220ms ease, visibility 220ms ease;
}

.startup-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.startup-card {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 16px;
  padding: 22px 24px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
}

.startup-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--panel-header-accent);
  pointer-events: none;
}

.startup-mark {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  align-self: center;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
}

.startup-pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: startup-dot 1.15s ease-in-out infinite;
}

.startup-copy {
  min-width: 0;
}

.startup-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.startup-status {
  min-height: 18px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
}

@keyframes startup-dot {
  0%, 100% { opacity: 0.45; transform: scale(0.82); }
  50% { opacity: 1; transform: scale(1); }
}

.startup-checks {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.startup-checks span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  background: color-mix(in srgb, var(--accent) 5.5%, transparent);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.startup-checks i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--normal-fg);
  box-shadow: 0 0 12px color-mix(in srgb, var(--normal-fg) 50%, transparent);
}

.startup-signal {
  grid-column: 1 / -1;
  position: relative;
  height: 2px;
  overflow: hidden;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.startup-signal span {
  display: block;
  width: 34%;
  height: 100%;
  background: var(--accent);
  animation: startup-signal-sweep 1.65s ease-in-out infinite;
}

@keyframes startup-signal-sweep {
  0% { transform: translateX(-120%); opacity: 0; }
  18% { opacity: 1; }
  82% { opacity: 1; }
  100% { transform: translateX(320%); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .startup-screen,
  .startup-signal span {
    animation: none;
    transition: none;
  }
}

@media (max-width: 560px) {
  .startup-card {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 28px 22px 24px;
  }

  .startup-mark {
    grid-row: auto;
    width: 72px;
    height: 72px;
  }

  .startup-checks,
  .startup-signal {
    grid-column: 1;
  }

  .startup-checks span {
    flex: 1 1 auto;
    justify-content: center;
  }
}

canvas,
img,
svg,
video,
select,
input,
button,
table {
  max-width: 100%;
}

canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

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

button {
  touch-action: manipulation;
  cursor: pointer;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Prevent layout overflow in all critical containers */
.app-shell,
.dashboard,
.appbar,
.appbar-indicators,
.operations-grid,
.panel,
.panel-header,
.panel-body,
.panel-toolbar,
.kpi-strip,
.asset-table,
.table-shell,
.chart-wrap,
.trend-grid,
.trend-subpanel,
.trend-chart-body,
.trend-chart-wrap,
.report-recorder,
.system-health-grid,
.bearing-grid,
.detail-list,
.indicator-grid {
  min-width: 0;
}

/* ===================== LAYOUT SHELL ===================== */

.app-shell {
  display: grid;
  grid-template-columns: 206px minmax(0, 1fr);
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
}

/* ===================== SIDEBAR ===================== */

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  overflow: hidden;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

.nav-list::-webkit-scrollbar {
  width: 8px;
}

.nav-list::-webkit-scrollbar-track {
  background: transparent;
  box-shadow: inset 1px 0 0 var(--border);
}

.nav-list::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 2px solid var(--sidebar-bg);
}

/* ── Brand block ── */
.brand-block {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.brand-lockup {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 5px;
}

.brand-owner {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-owner[hidden] {
  display: none;
}

.brand-company,
.brand-department {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.brand-company {
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.035em;
}

.brand-department {
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
}

.brand-version {
  margin: 0;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.1;
  text-transform: uppercase;
}

.brand-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--normal);
  box-shadow: 0 0 6px color-mix(in srgb, var(--normal) 70%, transparent);
  flex-shrink: 0;
  margin-top: 2px;
  animation: sidebar-pulse 2.8s ease-in-out infinite;
}

@keyframes sidebar-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ── Nav structure ── */
.nav-list {
  display: flex;
  flex-direction: column;
  padding: 4px 0 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-color: var(--scroll-thumb) transparent;
}

.nav-section {
  padding-top: 10px;
}

.nav-section:first-child {
  padding-top: 6px;
}

.nav-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 4px 14px 5px;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.nav-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.nav-items {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 3px 8px;
}

/* ── Nav item ── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 0;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease;
  -webkit-user-select: none;
  user-select: none;
}

.nav-item + .nav-item {
  margin-top: -1px;
}

.nav-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--muted-2);
  opacity: 0.75;
  transition: color 130ms ease, opacity 130ms ease;
}

.nav-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Items overlap by 1px so neighbouring borders merge into one line. The
   item being highlighted must sit above its neighbours, or the next item
   paints over its bottom border and the highlight looks cut off. */
.nav-item:hover,
.nav-item:focus-visible,
.nav-item.active {
  z-index: 1;
}

/* Hover */
.nav-item:hover {
  background: var(--control-hover);
  border-color: var(--info);
  color: var(--text-strong);
}

/* Keyboard focus: drawn inside the item, because overflow: hidden would clip
   an outline drawn outside it. */
.nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
  border-color: var(--info);
}

.nav-item:hover .nav-item-icon {
  color: var(--info-fg);
  opacity: 1;
}

/* Active */
.nav-item.active {
  background: var(--control-active);
  border-color: var(--control-active);
  color: var(--control-active-text);
  font-weight: 800;
  box-shadow: none;
}

.nav-item.active .nav-item-icon {
  color: var(--control-active-text);
  opacity: 1;
}

/* ── Footer ── */
.sidebar-footer {
  margin-top: auto;
  padding: 10px 13px 12px;
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--sidebar-bg);
}

.sidebar-footer-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted-2);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.sidebar-footer-value {
  display: block;
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.sidebar-version {
  display: block;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 8.5px;
  font-family: var(--font-ui);
  letter-spacing: 0.04em;
}

/* ===================== DASHBOARD ===================== */

.dashboard {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
}

/* ===================== APPBAR ===================== */

.appbar {
  display: flex;
  align-items: stretch;
  height: 42px;
  border-bottom: 1px solid var(--line);
  background: var(--appbar-bg);
  flex-shrink: 0;
  overflow: hidden;
}

.appbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border-right: 1px solid var(--line);
  flex-shrink: 0;
  white-space: nowrap;
}

.breadcrumb-root {
  color: var(--muted);
  font-size: 11.5px;
}

.breadcrumb-sep {
  color: var(--muted-2);
  font-size: 12px;
}

.breadcrumb-current {
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
}

.appbar-indicators {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  max-width: 640px;
  align-items: stretch;
  flex: 1;
  overflow-x: hidden;
  overflow-y: hidden;
  scrollbar-width: none;
}

.appbar-indicators::-webkit-scrollbar {
  display: none;
}

.appbar-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 0 14px;
  border-left: 1px solid var(--line);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

.appbar-cell:first-child {
  border-left: 0;
}

.cell-label {
  color: var(--muted-2);
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.cell-mono {
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* ===================== STATUS BADGES ===================== */

/* Appbar badges (with LED dot) */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-inline-size: 96px;
  padding: 1px 7px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 100%;
  text-overflow: ellipsis;
  overflow: hidden;
}

.appbar .badge {
  min-inline-size: 104px;
}

.badge::before {
  content: '';
  display: inline-block;
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
}

/* Status pills (inline in tables, KPI cards) */
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-inline-size: 82px;
  padding: 1px 6px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill::before {
  content: '';
  display: inline-block;
  flex-shrink: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted-2);
}

/* Severity modifiers — shared by .badge and .status-pill */
.pill-normal {
  border-color: var(--normal);
  color: var(--normal-fg);
  background: var(--normal-bg);
}
.pill-normal::before  { background: var(--normal); }

.pill-warning {
  border-color: var(--warning);
  color: var(--warning-fg);
  background: var(--warning-bg);
}
.pill-warning::before { background: var(--warning); }

.pill-danger {
  border-color: var(--critical);
  color: var(--critical-fg);
  background: var(--critical-bg);
}
.pill-danger::before  { background: var(--critical); }

/* ===================== OPERATIONS GRID (TAB CONTAINER) ===================== */

.operations-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: 100%;
}

/* Tab panes — hidden by default, flex column when active */
.tab-pane {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.tab-pane.active {
  display: flex;
}

/* Inner pane grids — gap-as-border technique */
.pane-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--line);
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.pane-grid > * { min-width: 0; }

/* Sensor Fleet: keep the wide table unobstructed and place its detail panel below. */
.pane-fleet {
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}

/* Condition Status: kpi row spanning full width, then 2-col below */
.pane-condition {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "profile"
    "card"
    "status"
    "indicators";
  align-content: start;
}

.pane-condition .metric-status-panel { grid-area: status; }
.pane-condition .sensor-card-panel { grid-area: card; }

.pane-condition .sensor-profile-panel      { grid-area: profile; }
.pane-condition .indicators-panel     { grid-area: indicators; }

/* Configuration: thresholds are the primary working area; bearing reference supports it. */
.pane-config {
  grid-template-columns: minmax(0, 0.65fr) minmax(0, 1.35fr);
  flex: 0 0 auto;
  min-height: auto;
  align-content: start;
  align-items: start;
  background: transparent;
}

.pane-logs {
  /* A fixed 40/60 split made both children narrower than their controls once
     the sidebar was subtracted from the viewport. auto-fit responds to the
     space inside this pane: two columns only when each can remain useful,
     otherwise the recorder and logs stack without horizontal overflow. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 880px), 1fr));
  grid-auto-rows: max-content;
  align-content: start;
}

.pane-logs > .panel {
  min-width: 0;
  overflow: hidden;
}

/* Panes that should fill remaining height */
.pane-fill {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Event log expands to fill pane */
.pane-event-log {
  flex: 1;
  max-height: none !important;
}

/* Chart body expands to fill pane */
.pane-chart-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 12px;
}

/* Chart wrap fills available space in full-pane chart views */
.pane-chart-wrap {
  flex: 1;
  height: auto !important;
  min-height: 300px;
}

/* ===================== PANEL ===================== */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  overflow-wrap: anywhere;
}

/* Panel header bar */
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel-header-bg);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 3px 0 0 var(--panel-header-accent);
  flex-shrink: 0;
}

.panel-title {
  min-width: 0;
  flex-shrink: 1;
}

.panel-meta {
  min-width: 0;
  text-align: right;
  flex-shrink: 2;
}

/* Panel sub-toolbar — sits below panel-header, holds chart controls */
.panel-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 5px 12px;
  background: var(--panel-hdr);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  max-width: 100%;
  /* overflow: hidden removed — was clipping wrapped toolbar rows */
}

.panel-toolbar .chart-control-inline,
.panel-toolbar .fft-axis-field,
.panel-toolbar .fft-band-field,
.panel-toolbar .fft-band-presets,
.panel-toolbar .segmented {
  flex-shrink: 0;
  min-width: 0;
}

.panel-title {
  color: var(--text-strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.15;
  white-space: normal;
  word-break: break-word;
}

.panel-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 1;
}

.ylock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.panel-meta {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: normal;
  text-align: right;
  min-width: 0;
  line-height: 1.2;
  word-break: break-word;
}

/* Panel content padding */
.panel-body {
  padding: 10px 12px 12px;
}

.chart-panel-body {
  padding: 10px 12px;
}

/* ===================== FORM ELEMENTS ===================== */

.field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.field span {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line-2);
  background: var(--input-bg);
  color: var(--text);
  font-size: 12px;
  border-radius: 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

/* Keep native select controls on the same type scale as the surrounding UI.
   A later touch-device rule used to force every select to 16px while labels,
   buttons and table text remained 9-12px. Besides looking unrelated to the
   dashboard, the enlarged native value also made compact toolbars reflow.
   Options inherit this face/size when the platform allows native menu styling. */
select,
select option,
select optgroup {
  font-family: var(--font-ui);
  font-size: 12px;
}

select option,
select optgroup {
  font: inherit;
}

select:not(:disabled) {
  cursor: pointer;
  background-image: var(--select-arrow, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23dce8f2'/%3E%3C/svg%3E"));
  background-position: calc(100% - 10px) 50%;
  background-size: 10px 6px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

input:not(:disabled),
select:not(:disabled) {
  color: var(--text-strong);
}

input:disabled,
select:disabled {
  cursor: not-allowed;
}

input:focus,
select:focus {
  border-color: var(--info-fg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--info) 22%, transparent);
}

input::placeholder {
  color: var(--muted-2);
  opacity: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  border-radius: 0;
  cursor: pointer;
  align-self: flex-start;
}

.btn:hover {
  background: var(--control-hover);
  border-color: var(--info);
  color: var(--text-strong);
}

.btn:active,
.btn.is-active {
  background: var(--control-active);
  border-color: var(--control-active);
  color: var(--control-active-text);
}

.btn-secondary {
  background: var(--control-bg);
  color: var(--muted);
}

.btn.is-running {
  border-color: var(--control-active);
  background: var(--control-active);
  color: var(--control-active-text);
}

/* ===================== ASSET SELECTOR ===================== */

.asset-selector {
  max-width: 300px;
  margin-bottom: 10px;
}

/* ===================== ASSET TABLE ===================== */

.table-shell {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
}

.asset-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  table-layout: auto;
}

.asset-table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-hdr);
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  vertical-align: middle;
}

.asset-table th.sortable-header {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 120ms ease, background-color 120ms ease;
}

.asset-table th.sortable-header::after {
  content: "↕";
  display: inline-block;
  margin-left: 6px;
  color: var(--muted-2);
  font-size: 10px;
}

.asset-table th.sortable-header[aria-sort="ascending"]::after { content: "↑"; color: var(--info-fg); }
.asset-table th.sortable-header[aria-sort="descending"]::after { content: "↓"; color: var(--info-fg); }
.asset-table th.sortable-header:hover,
.asset-table th.sortable-header:focus-visible {
  color: var(--text-strong);
  background: var(--control-hover);
  outline: none;
}

.asset-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 11.5px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.asset-table tr:last-child td {
  border-bottom: 0;
}

.col-num,
.asset-table .col-num {
  text-align: right;
}

.asset-row {
  cursor: pointer;
}

.asset-row:nth-child(even) {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.asset-row:hover {
  background: color-mix(in srgb, var(--info) 6%, transparent);
}

.asset-row.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 3px 0 0 var(--info-fg);
}

.asset-id {
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
}

.numeric {
  font-family: var(--font-ui);
  font-size: 11px;
  text-align: right;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 6px 0 0;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-family: var(--font-ui);
  font-size: 10px;
}

.pagination-summary {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.pagination-controls {
  display: inline-flex;
  align-items: center;
  gap: 0;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-left: 1px solid var(--line-2);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.page-btn:first-child {
  border-left: 0;
}

.page-btn:hover:not(:disabled) {
  background: var(--control-hover);
  color: var(--text-strong);
}

.page-btn.is-active {
  background: var(--control-active);
  color: var(--control-active-text);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pagination-gap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 28px;
  border-left: 1px solid var(--line-2);
  color: var(--muted-2);
}

.empty-cell {
  color: var(--muted);
  text-align: center !important;
  font-size: 11.5px;
  padding: 22px 10px !important;
  font-style: italic;
}

/* ===================== OFFLINE BANNER ===================== */

.warning-banner {
  margin-bottom: 10px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
  border-left: 3px solid var(--warning);
  color: var(--warning-fg);
  background: var(--warning-bg);
  font-size: 11.5px;
  line-height: 1.45;
}

.hidden { display: none; }

/* ===================== DETAIL LIST ===================== */

.detail-list,
.profile-grid {
  margin: 0;
}

/* A note with nothing in it takes no space. */
.form-note:empty,
.ai-note:empty,
.theme-help:empty { display: none; }

/* The selected-sensor panel spans the fleet width, so its facts can flow as
   compact cards instead of forming one unnecessarily tall side column. */
.selected-asset .detail-list {
  display: flex;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.selected-asset .detail-list div,
.selected-asset .detail-list div:last-child {
  grid-template-columns: minmax(100px, 0.9fr) minmax(0, 1.1fr);
  flex: 1 1 210px;
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.detail-list div,
.profile-grid div {
  display: grid;
  grid-template-columns: minmax(100px, 0.9fr) minmax(0, 1.1fr);
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.detail-list div:last-child,
.profile-grid div:last-child {
  border-bottom: 0;
}

.detail-list dt,
.detail-list dd,
.profile-grid dt,
.profile-grid dd {
  margin: 0;
}

.detail-list dt,
.profile-grid dt {
  color: var(--muted-2);
  font-size: 10.5px;
  font-weight: 600;
}

.detail-list dd,
.profile-grid dd {
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 10.5px;
  text-align: right;
  overflow-wrap: anywhere;
}

/* ===================== KPI STRIP ===================== */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border);
}

.kpi-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 12px 10px;
  min-height: 74px;
  background: var(--panel);
}

.kpi-label {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.kpi-value {
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  flex: 1;
  display: flex;
  align-items: center;
}

.kpi-status {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ===================== CHARTS ===================== */

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-inline-size: 0;
  height: 360px;
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.trend-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  min-width: 0;
}

.trend-window-field {
  min-width: 220px;
  max-width: 260px;
}

.trend-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-width: 0;
}

.trend-acceleration { order: 1; }
.trend-velocity    { order: 2; }
.trend-displacement{ order: 3; }
.trend-frequency   { order: 4; }
.trend-temperature { order: 5; }

.trend-subpanel .panel-body {
  padding: 10px;
}

.trend-chart-body {
  padding: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.trend-chart-wrap {
  height: 360px;
  min-width: 0;
}

.chart-ma-control {
  min-width: 128px;
}

.chart-ma-control .mini-select {
  min-width: 72px;
  height: 30px;
  padding: 4px 26px 4px 8px;
}

.frequency-summary-shell {
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-hdr) 76%, transparent);
}

.frequency-summary-table {
  width: 100%;
  border-collapse: collapse;
  /* Columns size to their content, so a value or heading can never spill
     into its neighbour. If even that does not fit, the shell scrolls. */
  table-layout: auto;
}

.frequency-summary-table [id^="freqSummaryConfidence"] {
  cursor: help;
}

.freq-confidence-high {
  color: var(--normal-fg);
}

.freq-confidence-medium {
  color: var(--warning-fg);
}

.freq-confidence-low {
  color: var(--critical-fg);
}

.frequency-summary-table th,
.frequency-summary-table td {
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.frequency-summary-table th {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.frequency-summary-table th:first-child,
.frequency-summary-table td:first-child {
  width: 1%;
  text-align: left;
}

.frequency-summary-table tr:last-child th,
.frequency-summary-table tr:last-child td {
  border-bottom: 0;
}

.frequency-summary-table th:last-child,
.frequency-summary-table td:last-child {
  border-right: 0;
}

.chart-render-loader {
  position: relative;
  height: 3px;
  width: 100%;
  overflow: hidden;
  background: color-mix(in srgb, var(--panel-2) 72%, transparent);
  opacity: 0;
  transform: scaleX(0.985);
  transform-origin: left center;
  transition: opacity 120ms ease, transform 160ms ease;
}

.chart-render-loader::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 -38%;
  width: 38%;
  background: var(--accent);
  animation: chart-render-loader-sweep 900ms ease-in-out infinite;
}

.trend-subpanel.is-chart-updating .chart-render-loader {
  opacity: 1;
  transform: scaleX(1);
}

@keyframes chart-render-loader-sweep {
  0%   { transform: translateX(0); }
  100% { transform: translateX(365%); }
}

@media (prefers-reduced-motion: reduce) {
  .chart-render-loader,
  .chart-render-loader::before {
    transition: none;
    animation: none;
  }

  .chart-render-loader::before {
    left: 0;
    width: 100%;
    background: var(--accent);
    opacity: 0.62;
  }
}

.trend-status {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.trend-status.ok {
  color: var(--normal-fg);
}

.trend-status.warning {
  color: var(--warning-fg);
}

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

.trend-stats-panel {
  margin-top: 10px;
}

.trend-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 8px;
}

.trend-stats-grid > div {
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 8px;
}

.trend-stats-grid dt,
.trend-stats-grid dd {
  margin: 0;
}

.trend-stats-grid dt {
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.trend-stats-grid dd {
  margin-top: 4px;
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
}

.fft-wrap {
  height: 220px;
  margin-top: 8px;
}

/* ===================== MAINTENANCE NOTES ===================== */

.hint-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hint-list li {
  padding: 8px 10px;
  border-left: 2px solid var(--line-2);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

/* ===================== FAULT INDICATORS ===================== */

.indicator-grid {
  display: grid;
  grid-template-columns: minmax(120px, 0.95fr) minmax(78px, 0.72fr) repeat(4, minmax(74px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 11px;
  overflow-x: auto;
}

.indicator-grid > div {
  padding: 6px 9px;
  background: var(--panel);
  min-width: 0;
  overflow-wrap: anywhere;
}

.indicator-head {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.indicator-grid > .indicator-head {
  background: var(--panel-hdr);
}

.indicator-row-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.indicator-grid > .indicator-row-label,
.indicator-grid > .indicator-metric {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.indicator-metric {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-strong);
}

.indicator-metric-repeat {
  color: transparent;
}

.indicator-spike {
  color: var(--warning-fg);
  font-weight: 800;
}

.indicator-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

.engineering-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.engineering-grid > div {
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 8px;
  min-width: 0;
}

.engineering-grid dt,
.engineering-grid dd {
  margin: 0;
}

.engineering-grid dt {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.engineering-grid dd {
  margin-top: 5px;
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
}

.fft-note {
  margin: 4px 0 6px;
  padding: 7px 8px;
  border-left: 3px solid var(--line-2);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--muted);
  font-size: 11px;
}

/* ===================== FFT PANEL ===================== */

.fft-axis-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.fft-axis-field span {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.fft-axis-field select {
  width: 90px;
  padding: 2px 6px;
  font-size: 11px;
}

.fft-meta-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.placeholder-text {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.fft-meta-right {
  text-align: right;
}

.fft-peaks {
  margin-bottom: 4px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 10.5px;
  line-height: 1.5;
}

/* ===================== CHART CONTROLS ===================== */

.chart-control-cluster {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}

.chart-control-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chart-control-inline span {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.chart-control-inline select {
  width: 64px;
  padding: 2px 6px;
  font-size: 11px;
}

.fft-band-field input {
  width: 74px;
  padding: 2px 6px;
  font-size: 11px;
}

.x-window-field input {
  width: 56px;
  padding: 2px 6px;
  font-size: 11px;
}

.x-window-presets {
  display: inline-flex;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  border-radius: 0;
}

.x-window-presets .seg-btn {
  min-width: 36px;
  padding: 3px 5px;
  font-size: 10px;
}

.fft-band-sep {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}

.fft-band-presets {
  display: inline-flex;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  border-radius: 0;
}

.fft-band-presets .seg-btn {
  min-width: 66px;
  padding: 3px 7px;
  font-size: 9.5px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  border-radius: 0;
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-right: 1px solid var(--line-2);
  background: var(--control-bg);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  min-width: 58px;
  min-height: 28px;
  cursor: pointer;
  border-radius: 0;
}

.seg-btn:last-child {
  border-right: 0;
}

.seg-btn:hover {
  color: var(--text-strong);
  background: var(--control-hover);
}

.seg-btn:active,
.seg-btn.is-active {
  color: var(--control-active-text);
  background: var(--control-active);
}

.chart-control-note {
  margin: 6px 0 0;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.02em;
}

/* ===================== BEARING CALCULATOR ===================== */

.bearing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.bearing-panel .panel-meta {
  flex: 0 1 auto;
  text-align: right;
  white-space: nowrap;
}

.bearing-btn {
  align-self: end;
}

.bearing-results {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-2);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.9;
}

/* ===================== THRESHOLD FORM ===================== */

.threshold-form {
  display: grid;
  gap: 12px;
}

.device-config-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 1px;
  margin-bottom: 10px;
  background: var(--border);
  border: 1px solid var(--line);
}

.device-config-summary > div {
  min-width: 0;
  padding: 8px 10px;
  background: var(--panel-2);
}

.device-config-summary span {
  display: block;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.config-location-view { display: flex; align-items: center; gap: 8px; margin-top: 4px; min-width: 0; }
.config-location-view strong { margin-top: 0 !important; flex: 1 1 auto; min-width: 0; }
.config-location-form { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; min-width: 0; }
.config-location-form input { flex-basis: 100% !important; }
.config-location-form[hidden], .config-location-view[hidden] { display: none; }
.config-location-form input {
  flex: 1 1 auto; min-width: 0; height: 26px; padding: 0 6px;
  border: 1px solid var(--line-2); border-radius: 0;
  background: var(--input-bg, var(--control-bg)); color: var(--text-strong);
  font: inherit; font-size: 11px;
}
.config-location-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.config-location-btn {
  flex: none; height: 26px; padding: 0 8px;
  border: 1px solid var(--line-2); border-radius: 0;
  background: var(--control-bg); color: var(--muted);
  font: inherit; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer;
}
.config-location-btn:hover:not(:disabled) { background: var(--control-hover); border-color: var(--info); color: var(--text-strong); }
.config-location-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.config-location-btn:disabled { opacity: 0.5; cursor: wait; }
.config-location-btn.is-primary { color: var(--text-strong); border-color: var(--info); }

.device-config-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--text-strong);
  font-size: 11px;
  overflow-wrap: anywhere;
}

/* ── Threshold stacked layout (replaces horizontal table) ──── */
.threshold-stack {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
}

.thresh-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.thresh-row:last-child {
  border-bottom: none;
}

.thresh-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.thresh-label {
  flex: 1;
  color: var(--text-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.thresh-axis {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.thresh-row-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.thresh-field-label {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.thresh-row-inputs input[type="number"] {
  width: 110px;
  padding: 5px 7px;
  font-size: 11px;
}

.thresh-unit {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.threshold-toggle span::before {
  content: '';
  width: 6px;
  height: 6px;
  margin-right: 6px;
  background: currentColor;
}

.threshold-toggle {
  position: relative;
  display: inline-flex;
  width: 144px;
  max-width: 100%;
  height: 24px;
  margin: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.threshold-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.threshold-toggle span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.threshold-toggle span::after {
  content: 'Disabled';
}

.threshold-toggle input:checked + span {
  border-color: var(--normal);
  background: var(--normal-bg);
  color: var(--normal-fg);
}

.threshold-toggle input:checked + span::after {
  content: 'Enabled';
}

.threshold-toggle input:focus-visible + span {
  outline: 2px solid var(--info-fg);
  outline-offset: 2px;
}

.compact-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--text);
  font-size: 11px;
  text-transform: none;
}

.strategy-fieldset,
.threshold-group {
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
}

.strategy-fieldset legend,
.threshold-group legend {
  padding: 0 5px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.strategy-fieldset {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.strategy-fieldset label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-soft);
  font-size: 11px;
}

.strategy-fieldset input {
  appearance: auto;
  -webkit-appearance: radio;
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  min-width: 14px;
  margin: 0;
  padding: 0;
  accent-color: var(--info-fg);
}

.threshold-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.threshold-group {
  display: grid;
  gap: 8px;
}

.threshold-unit {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.strategy-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.threshold-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  align-items: stretch;
  gap: 10px;
}

.calibration-actions {
  display: grid;
  align-items: start;
  gap: 7px;
}

.threshold-save-actions {
  display: grid;
  align-items: start;
  gap: 7px;
}

.threshold-action-block {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.threshold-action-block .btn {
  width: 100%;
  min-height: 34px;
}

.calibration-readout {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 10px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.threshold-save-actions .form-note {
  max-width: none;
}

/* ============================================================
   Configuration page polish — scoped to #pane-configuration so
   .btn/.thresh-row/.threshold-toggle keep their existing look
   everywhere else they're reused across the app.
   ============================================================ */

/* Left accent bar per threshold row: green once the alarm is armed, amber
   if values are saved but the toggle is still off (a real footgun - typing
   numbers in doesn't do anything by itself). Driven by classes app.js
   toggles in updateThreshRowArmedHints() from the actual input/checkbox
   state, not guessed from CSS. */
:is(#pane-configuration, #pane-manual-threshold) .thresh-row {
  border-left: 3px solid transparent;
  transition: border-color 200ms ease, background 200ms ease;
}

:is(#pane-configuration, #pane-manual-threshold) .thresh-row.thresh-row-armed {
  border-left-color: var(--normal);
  background: color-mix(in srgb, var(--panel) 96%, var(--normal) 4%);
}

:is(#pane-configuration, #pane-manual-threshold) .thresh-row.thresh-row-unarmed-configured {
  border-left-color: var(--warning);
}

:is(#pane-configuration, #pane-manual-threshold) .thresh-row.thresh-row-unarmed-configured::after {
  content: "Values are set but this alarm is off \2014 flip the toggle to start evaluating it.";
  margin-top: 2px;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--line));
  background: var(--warning-bg);
  color: var(--warning-fg);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
}

/* Toggle switch: smooth colour transition instead of an instant snap, plus
   a small sliding dot inside the existing square track so the on/off state
   reads as a real switch rather than a two-word label swap. */
:is(#pane-configuration, #pane-manual-threshold) .threshold-toggle span {
  position: relative;
  padding-left: 14px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

:is(#pane-configuration, #pane-manual-threshold) .threshold-toggle span::before {
  position: absolute;
  left: 8px;
  top: 50%;
  margin-right: 0;
  border-radius: 50%;
  transform: translateY(-50%);
  transition: left 160ms ease, background 160ms ease;
}

:is(#pane-configuration, #pane-manual-threshold) .threshold-toggle input:checked + span::before {
  left: calc(100% - 14px);
}

/* Warning vs Alarm inputs: the focus ring colour echoes the severity each
   column feeds, reinforcing the meaning without adding more text. */
:is(#pane-configuration, #pane-manual-threshold) .thresh-row-inputs input[type="number"]:nth-of-type(1):focus {
  border-color: var(--warning);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--warning) 45%, transparent);
}

:is(#pane-configuration, #pane-manual-threshold) .thresh-row-inputs input[type="number"]:nth-of-type(2):focus {
  border-color: var(--critical);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--critical) 45%, transparent);
}

/* Primary vs secondary action hierarchy: Save is the commit action for the
   whole form; Calibrate is a supporting utility. Only one of them should
   read as "the" button on the page. */
:is(#pane-configuration, #pane-manual-threshold) .threshold-save-actions .btn {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--control-bg));
  color: var(--text-strong);
  font-weight: 800;
}

:is(#pane-configuration, #pane-manual-threshold) .threshold-save-actions .btn:hover {
  background: color-mix(in srgb, var(--accent) 28%, var(--control-bg));
  border-color: var(--accent);
}

#pane-configuration .bearing-btn {
  border-color: var(--info);
  color: var(--text-strong);
}

#pane-configuration .bearing-btn:hover {
  background: color-mix(in srgb, var(--info) 20%, var(--control-bg));
}

@media (prefers-reduced-motion: reduce) {
  :is(#pane-configuration, #pane-manual-threshold) .thresh-row,
  :is(#pane-configuration, #pane-manual-threshold) .threshold-toggle span,
  :is(#pane-configuration, #pane-manual-threshold) .threshold-toggle span::before {
    transition: none;
  }
}

.metric-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  padding: 0;
  background: var(--border);
}

.metric-status-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 11px 12px;
  background: var(--panel);
}

.metric-status-row .status-pill {
  min-inline-size: 96px;
}

.metric-status-row > span:first-child {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Only matches the Overall Asset Health row, whose value is a sentence. The
   three metric rows end in a .metric-axis-breakdown instead, so this rule no
   longer applies to them - no :last-child span exists there. */
.metric-status-row > span:last-child {
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
  color: var(--text-soft);
  font-family: var(--font-ui);
  font-size: 11.5px;
  line-height: 1.5;
}

/* Per-axis readings under each metric.
   X/Y/Z sit in three fixed equal columns and Magnitude takes a full-width row
   of its own. Letting all four auto-fit instead would reflow to 4/3/2 columns
   depending on how wide the parent cell happened to be at a given viewport,
   which strands Magnitude alone in a ragged position. Magnitude is also the
   value the thresholds actually compare against, so giving it its own line is
   the honest hierarchy rather than a layout workaround. */
.metric-axis-breakdown {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 8px;
  margin: 2px 0 0;
  min-width: 0;
}

.metric-axis-breakdown > div {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.metric-axis-breakdown dt {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-axis-breakdown dd {
  margin: 0;
  min-width: 0;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  /* Readings are short tokens like "3.6099" or "Not Available". Breaking
     mid-number would be unreadable, so wrap between words only and let the
     rare long token clip rather than fragment a digit string. */
  overflow-wrap: break-word;
}

.metric-axis-magnitude {
  grid-column: 1 / -1;
  padding-top: 5px;
  border-top: 1px solid var(--line);
}

.metric-axis-magnitude dt {
  color: var(--muted);
}

.metric-axis-magnitude dd {
  color: var(--text-strong);
  font-size: 12.5px;
  font-weight: 600;
}

.overall-health-row {
  border-left: 2px solid var(--accent);
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.system-health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--line);
}

.system-health-grid > div {
  min-width: 0;
  padding: 10px 11px;
  background: var(--panel);
}

.system-health-grid dt,
.system-health-grid dd {
  margin: 0;
}

.system-health-grid dt {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.system-health-grid dd {
  margin-top: 5px;
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* ===================== REPORTS ===================== */

.report-recorder {
  display: grid;
  gap: 14px;
  container-type: inline-size;
  container-name: recording-panel;
}

.recording-steps {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(250px, 1.25fr) minmax(180px, auto);
  gap: 10px;
}

.recording-step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.recording-step > div { min-width: 0; }

.recording-step-number {
  display: grid;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--text-strong);
  font-weight: 800;
}

.recording-step-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.recording-step strong {
  display: block;
  color: var(--text-strong);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.recording-step select { width: 100%; }
.recording-action-step .btn { width: 100%; }

.recording-live-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.recording-live-banner > div { display: grid; gap: 3px; }
.recording-live-banner strong { color: var(--text-strong); font-size: 12px; }
.recording-live-banner.is-recording {
  border-color: color-mix(in srgb, var(--normal) 55%, var(--line));
  background: color-mix(in srgb, var(--normal) 8%, var(--panel));
}

.recording-indicator-dot {
  display: inline-block;
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--muted-2);
}

.is-recording > .recording-indicator-dot,
.recording-live-banner.is-recording .recording-indicator-dot {
  background: var(--normal);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--normal) 55%, transparent);
  animation: recording-pulse 1.5s ease-out infinite;
}

@keyframes recording-pulse {
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}

.fleet-recording-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.fleet-recording-state .recording-indicator-dot { margin-top: 0; }
.fleet-recording-state.is-recording { color: var(--normal-fg); }

.recording-details {
  border: 1px solid var(--line);
  background: var(--panel);
}

.recording-details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  color: var(--text-strong);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
  list-style: none;
}

.recording-details summary::-webkit-details-marker { display: none; }
.recording-details:not([open]) > :not(summary) { display: none; }

.recording-details > .report-status-grid,
.recording-details > .recording-guide { border-inline: 0; border-bottom: 0; }

/* The recorder can occupy half or all of the Logs pane. Container queries
   make its controls respond to that real width instead of the browser width. */
@container recording-panel (max-width: 760px) {
  .recording-steps {
    grid-template-columns: 1fr;
  }

  .recording-action-step {
    align-items: stretch;
  }

  .report-status-primary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recording-details > .report-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container recording-panel (max-width: 430px) {
  .report-status-primary {
    grid-template-columns: 1fr;
  }

  .report-file-row {
    grid-column: auto;
  }

  .recording-details > .report-status-grid {
    grid-template-columns: 1fr;
  }
}

.report-actions {
  display: grid;
  grid-template-columns: minmax(190px, 300px) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.report-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--border);
  border: 1px solid var(--line);
}

.report-status-grid > div {
  min-width: 0;
  padding: 10px 11px;
  background: var(--panel);
}

.report-status-grid dt,
.report-status-grid dd {
  margin: 0;
}

.report-status-grid dt {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.report-status-grid dd {
  margin-top: 5px;
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.report-file-row {
  grid-column: 1 / -1;
}

.report-download {
  color: var(--info-fg);
  text-decoration: none;
}

.report-download:hover {
  color: var(--text-strong);
}

.recording-guide {
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.recording-guide strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text-strong);
  font-size: 11px;
}

.recording-guide p {
  margin: 3px 0;
}

.recording-guide code {
  color: var(--info-fg);
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .threshold-groups,
  .metric-status-grid,
  .report-status-grid,
  .device-config-summary,
  .system-health-grid {
    grid-template-columns: 1fr;
  }

  .recording-steps { grid-template-columns: 1fr; }

  .strategy-fieldset {
    grid-template-columns: 1fr;
  }

  .strategy-actions,
  .threshold-actions,
  .calibration-actions,
  .threshold-save-actions,
  .report-actions {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .report-file-row {
    grid-column: auto;
  }
}

/* ===================== EVENT LOG ===================== */

.event-panel {
  display: flex;
  flex-direction: column;
  /* No padding — header + scrollable log fill the panel */
}

.event-log {
  display: grid;
  max-height: 600px;
  overflow-y: auto;
  background: var(--panel);
}

.event-item {
  min-width: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
}

.event-item:last-child {
  border-bottom: 0;
}

.event-item.pill-warning {
  border-left-color: var(--warning);
}

.event-item.pill-danger {
  border-left-color: var(--critical);
}

.event-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted-2);
  font-family: var(--font-ui);
  font-size: 9.5px;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.event-msg {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.45;
}

/* ============================================================
   Logs page polish — scoped to #pane-reports IDs/classes that
   only exist on this page, so nothing here touches the Sensors
   page's pagination or any other reused component.
   ============================================================ */

/* "This list updates live" indicator next to the System Logs title. */
.live-pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--normal-fg);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--normal-fg) 55%, transparent);
  animation: live-pulse-ring 2.2s ease-out infinite;
}

@keyframes live-pulse-ring {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--normal-fg) 55%, transparent); }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 6px transparent; }
}

/* Give each severity its own colour on the actual word, not just the left
   accent bar - this is the fastest thing an engineer's eye can scan for. */
.event-item .event-sev {
  font-weight: 800;
}

.event-item.pill-normal .event-sev { color: var(--normal-fg); }
.event-item.pill-warning .event-sev { color: var(--warning-fg); }
.event-item.pill-danger .event-sev { color: var(--critical-fg); }

/* Previously only warning/danger rows had a left accent; normal rows had
   none at all, so a calm log looked "unstyled" rather than "all clear". */
.event-item.pill-normal {
  border-left-color: color-mix(in srgb, var(--normal) 55%, transparent);
}

.event-item.event-item-filtered-out {
  display: none;
}

/* Filter bar: quick severity chips + a free-text filter over whatever is
   currently loaded on this page (pagination still comes from the server,
   this just narrows what's visible without another round trip). */
.event-log-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-hdr);
}

.event-log-search {
  flex: 1 1 220px;
  min-width: 0;
  padding: 6px 9px;
  font-size: 11px;
}

.event-log-chips {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  max-width: 100%;
  gap: 1px;
  border: 1px solid var(--line-2);
  background: var(--border-2);
}

.event-log-chip {
  min-width: 0;
  padding: 6px 10px;
  border: 0;
  background: var(--control-bg);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.event-log-chip:hover {
  background: var(--control-hover);
  color: var(--text-strong);
}

.event-log-chip.is-active {
  background: var(--control-active);
  color: var(--control-active-text);
}

.event-log-chip-normal.is-active { background: var(--normal); color: var(--control-active-text); }
.event-log-chip-warning.is-active { background: var(--warning); color: var(--control-active-text); }
.event-log-chip-danger.is-active { background: var(--critical); color: var(--control-active-text); }

.event-log-filter-empty {
  margin: 0;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 11px;
}

.event-log-filter-empty.hidden {
  display: none;
}

/* Recorder panel: the Start/Stop button is the primary action here. */
#recordToggleBtn {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--control-bg));
  color: var(--text-strong);
  font-weight: 800;
}

#recordToggleBtn:hover {
  background: color-mix(in srgb, var(--accent) 28%, var(--control-bg));
}

#recordToggleBtn.is-active,
#recordToggleBtn.is-running {
  border-color: var(--critical);
  background: color-mix(in srgb, var(--critical) 22%, var(--control-bg));
  color: var(--critical-fg);
}

/* Recorder stat cells: a thin top accent per cell reads as a small
   instrument cluster rather than a plain definition list. */
.report-status-grid > div {
  position: relative;
  border-top: 2px solid var(--line-2);
}

/* System Logs pagination specifically (not the Sensors page, which reuses
   the same .pagination-bar/.pagination-controls markup): smooth hover/
   active transitions instead of an instant colour snap. */
#systemLogPagination .page-btn {
  transition: background 140ms ease, color 140ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .live-pulse-dot {
    animation: none;
  }
}

/* ===================== RESPONSIVE — 1400px ===================== */

@media (max-width: 1400px) {
  .trend-stats-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }
}

/* ===================== RESPONSIVE — 1200px ===================== */

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 192px minmax(0, 1fr);
  }

  .chart-wrap        { height: 300px; }
  .trend-chart-wrap  { height: 300px; }
  .trend-stats-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }
}

/* ===================== RESPONSIVE — 1024px (large tablet / small laptop) ===================== */

@media (max-width: 1024px) {
  /* Sidebar gets a bit narrower — still visible */
  .app-shell {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  /* Panel toolbars: allow more generous wrap spacing */
  .panel-toolbar {
    gap: 6px 10px;
    padding: 6px 10px;
  }

  /* FFT band inputs — slightly narrower */
  .fft-band-field input {
    width: 64px;
  }

  /* Tablet-width buttons are touch targets, not mouse targets - taller and
     easier to hit, not more compact. The previous rule shrank padding and
     font-size here, making the button smaller right at the breakpoint where
     fingers (not a mouse cursor) start doing the tapping. */
  .fft-band-presets .seg-btn {
    min-width: 58px;
    min-height: 36px;
    padding: 6px 8px;
  }

  .trend-stats-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .engineering-grid {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }
}

/* ===================== RESPONSIVE - 900px (tablet / mobile drawer nav) ===================== */

@media (max-width: 900px) {
  body { font-size: 12px; }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar-toggle {
    display: flex;
    grid-column: 1;
    grid-row: 1;
    height: 36px;
    min-width: 44px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .sidebar {
    display: none;
    position: fixed;
    top: 8px;
    left: 8px;
    right: auto;
    z-index: 220;
    width: min(360px, calc(100vw - 16px));
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    flex-direction: column;
    border: 1px solid var(--line-2);
    background: var(--sidebar-bg);
    overflow: hidden;
    box-shadow: 0 14px 42px rgba(0, 0, 0, 0.72);
  }

  .sidebar.open {
    display: flex;
  }

  .brand-block {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }

  .nav-list {
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 6px 0 10px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .nav-section {
    display: block;
    padding-top: 8px;
  }

  .nav-section:first-child {
    padding-top: 4px;
  }

  .nav-group-label {
    display: flex;
    padding: 6px 14px 5px;
  }

  .nav-items {
    flex-direction: column;
    gap: 0;
    padding: 3px 8px;
  }

  .nav-item {
    min-height: 42px;
    gap: 10px;
    padding: 10px 11px;
    border-radius: 0;
    box-shadow: none;
    font-size: 12px;
    white-space: normal;
  }

  .nav-item-icon {
    display: flex;
    width: 18px;
    height: 18px;
  }

  .nav-item:hover {
    background: var(--control-hover);
    border-color: var(--info);
  }

  .nav-item.active {
    background: var(--control-active);
    border-color: var(--control-active);
    color: var(--control-active-text);
    box-shadow: none;
  }

  .sidebar-footer {
    display: block;
    padding: 10px 14px 12px;
    flex: 0 0 auto;
  }

  .appbar {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-rows: auto;
    height: auto;
    min-height: 40px;
    padding: 0;
    gap: 0;
    align-items: stretch;
  }

  .appbar-breadcrumb {
    display: none;
  }

  .appbar-indicators {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    height: auto;
    min-height: 40px;
    overflow: visible;
    scrollbar-width: none;
    padding: 0;
    border-top: none;
    width: 100%;
  }

  .appbar-indicators::-webkit-scrollbar {
    display: none;
  }

  .appbar-cell {
    min-width: 0;
    min-height: 38px;
    height: auto;
    padding: 4px 8px;
    border-left: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-right: 0;
  }

  .appbar-cell:first-child {
    border-left: 0;
  }

  /* All pane grids collapse to single column */
  .pane-fleet,
  .pane-condition,
  .pane-config,
  .pane-logs {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: none;
  }

  .pane-condition .sensor-profile-panel,
  .pane-condition .sensor-card-panel,
  .pane-condition .metric-status-panel,
  .pane-condition .indicators-panel {
    grid-area: auto;
  }

  .bearing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .event-log { max-height: 360px; }

  .trend-stats-grid {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }

  .engineering-grid {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }

  .trend-chart-wrap  { height: 280px; }
  .chart-wrap        { height: 280px; }

  /* Panel toolbars: items wrap naturally — already flex-wrap */
  .panel-toolbar {
    padding: 6px 10px;
    gap: 6px 10px;
  }
}

/* ===================== RESPONSIVE — 600px (mobile) ===================== */

@media (max-width: 600px) {
  .appbar {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-rows: auto;
    height: auto;
    min-height: 36px;
  }
  .appbar-indicators {
    /* !important: a later @media (max-width: 700px) rule targets the same
       selector/property and would otherwise win on source order at any
       width <=600px too, re-applying its 2-column layout to the 3 cells
       this block leaves visible and producing a lopsided 2+1 row. This is
       the only place in the cascade that knows 3 (not 6) cells are visible
       here, so it must win regardless of where either rule sits in the file. */
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    min-height: 36px;
  }

  .appbar-cell {
    min-height: 38px;
    padding: 3px 6px;
  }

  .cell-label {
    font-size: 7.5px;
  }

  .cell-mono,
  .appbar .badge {
    font-size: 9.5px;
  }

  .appbar .badge {
    min-inline-size: 0;
    width: 100%;
  }

  .sidebar {
    top: 6px;
    left: 6px;
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    max-height: calc(100dvh - 12px);
    overflow: hidden;
  }

  .brand-block {
    padding: 11px 12px;
  }

  .nav-item {
    min-height: 44px;
  }

  .kpi-value { font-size: 18px; }

  .chart-wrap       { height: 240px; }
  .fft-wrap         { height: 190px; }
  .trend-chart-wrap { height: 240px; }

  .table-shell {
    overflow-x: visible;
    border: 0;
  }

  .asset-table,
  .asset-table tbody,
  .asset-table tr,
  .asset-table td {
    display: block;
    width: 100%;
  }

  .asset-table {
    min-width: 0;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
  }

  .asset-table thead {
    display: none;
  }

  .asset-table tr.asset-row {
    margin: 0 0 8px;
    border: 1px solid var(--line);
    background: var(--panel);
  }


  .asset-table td {
    display: grid;
    grid-template-columns: minmax(82px, 0.42fr) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 7px 9px;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }

  .asset-table td:last-child {
    border-bottom: 0;
  }

  .asset-table td::before {
    content: attr(data-label);
    color: var(--muted-2);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .asset-table .col-num {
    text-align: left;
  }

  .asset-table .empty-cell {
    display: block;
    padding: 14px 10px;
  }

  .asset-table .empty-cell::before {
    content: none;
  }

  .fleet-search-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-list div {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .detail-list dd {
    text-align: left;
    font-size: 11px;
  }

  .indicator-grid {
    grid-template-columns: minmax(112px, 0.95fr) minmax(74px, 0.72fr) repeat(4, minmax(72px, 1fr));
    min-width: 660px;
    font-size: 10px;
  }

  .indicator-grid > div {
    padding: 6px 7px;
  }

  .indicator-head {
    font-size: 8px;
    letter-spacing: 0.05em;
  }

  .bearing-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .fft-meta-row {
    flex-direction: column;
  }

  .fft-meta-right {
    text-align: left;
  }

  /* Panel toolbar: stack vertically on very small screens */
  .panel-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
  }

  /* justify-content was space-between: with only a short label and one
     control per row, the free space in a 346px-wide row went entirely into
     the gap between them instead of into the control, so "X Window" sat at
     the far left, the actual input floated in the middle, and the "s" unit
     landed alone at the far right edge. flex-start keeps label and control
     adjacent, the way every other stacked field on this page already reads. */
  .panel-toolbar .chart-control-inline,
  .panel-toolbar .fft-axis-field,
  .panel-toolbar .fft-band-field {
    width: 100%;
    justify-content: flex-start;
  }

  .panel-toolbar .fft-band-presets {
    width: 100%;
  }

  .panel-toolbar .fft-band-presets .seg-btn {
    flex: 1;
    min-width: 0;
  }

  /* Band inputs full-width on mobile */
  .fft-band-field input {
    width: 60px;
  }

  /* Scale/Y-Range are 2-option toggles (Linear/Log, Auto/Locked). flex:1
     used to stretch each button to fill whatever the row had left after the
     label - about 155px per button - producing oversized pills with far
     more padding than "LINEAR" or "LOCKED" needs. Sized to content instead,
     matching the compact look these same toggles already have on tablet and
     desktop. The 4-button x-window/fft-band preset groups keep their own
     flex:1 rules (below/elsewhere) and are unaffected by this. */
  .segmented {
    flex: 0 0 auto;
  }

  .seg-btn {
    flex: 0 0 auto;
  }

  .event-log { max-height: 280px; }

  .trend-stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .engineering-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .ai-threshold-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===================== LARGE SCREEN — 1500px ===================== */

@media (min-width: 1500px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .chart-wrap { height: 400px; }
  .trend-chart-wrap { height: 400px; }
}

/* Per-plot debug footer: available for diagnostics, hidden in operator UI */
.chart-status {
  display: none;
  max-width: 100%;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  padding: 7px 9px;
  margin: 6px 0 0;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
  overflow: hidden;
}

.trend-summary-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: min(360px, 100%);
  justify-content: flex-end;
}

.trend-summary-picker > span {
  flex: 0 0 auto;
  white-space: nowrap;
}

.trend-summary-picker .mini-select {
  flex: 0 1 220px;
}

.mini-select {
  min-width: 150px;
  max-width: 100%;
  height: 34px;
  padding: 0 34px 0 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  letter-spacing: 0;
}

@media (max-width: 700px) {
  .trend-summary-picker {
    width: 100%;
    justify-content: space-between;
  }

  .mini-select {
    min-width: 0;
    flex: 1;
  }
}

/* ============================================================
   AI CONDITION CLASSIFIER — complete styles
   ============================================================ */

/* ── Grid layout for the AI pane ───────────────────────────── */
.pane-ai,
.pane-ai-monitor {
  /* 2-col on desktop: prediction card full-width top, panels share the row below */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-content: start;
}

.pane-ai-config {
  /* AI Configuration tab has only the settings panel — single column, max-width constrained */
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr) minmax(320px, 0.9fr);
  align-content: start;
}

.pane-ai-config .ai-config-panel {
  grid-column: 1;
  max-width: none;
  width: 100%;
}

/* Prediction card spans full width */
.ai-prediction-card {
  grid-column: 1 / -1;
}

/* Config + Labels + Recording in a row, then Dataset + Training */
.pane-ai-config .ai-config-panel    { grid-column: 1; }
.pane-ai-config .ai-labels-panel    { grid-column: 2; }
.pane-ai-config .ai-recording-panel { grid-column: 3; }
.pane-ai-config .ai-dataset-panel   { grid-column: 1 / 3; }
.pane-ai-config .ai-training-panel  { grid-column: 3; }

@media (max-width: 1180px) {
  .pane-ai,
  .pane-ai-monitor {
    grid-template-columns: 1fr 1fr;
  }
  .pane-ai-config {
    grid-template-columns: 1fr 1fr;
  }
  .ai-prediction-card { grid-column: 1 / -1; }
  .pane-ai-config .ai-config-panel    { grid-column: 1; }
  .pane-ai-config .ai-labels-panel    { grid-column: 2; }
  .pane-ai-config .ai-recording-panel { grid-column: 1 / -1; }
  .pane-ai-config .ai-dataset-panel   { grid-column: 1; }
  .pane-ai-config .ai-training-panel  { grid-column: 2; }
}

@media (max-width: 1024px) {
  .pane-ai,
  .pane-ai-monitor {
    grid-template-columns: 1fr;
  }
  .pane-ai-config {
    grid-template-columns: 1fr;
  }
  .ai-prediction-card,
  .ai-config-panel,
  .ai-labels-panel,
  .ai-recording-panel,
  .ai-dataset-panel,
  .ai-training-panel {
    grid-column: 1;
  }
  .pane-ai-config .ai-config-panel,
  .pane-ai-config .ai-labels-panel,
  .pane-ai-config .ai-recording-panel,
  .pane-ai-config .ai-dataset-panel,
  .pane-ai-config .ai-training-panel {
    grid-column: 1;
  }
}

/* ── Model status bar ──────────────────────────────────────── */
.ai-model-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.ai-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ai-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-2);
  flex-shrink: 0;
}

.ai-dot-idle    { background: var(--muted-2); }
.ai-dot-ready   { background: var(--normal-fg); box-shadow: 0 0 5px var(--normal-fg); }
.ai-dot-training{ background: var(--warning-fg); animation: ai-pulse 1s infinite; }
.ai-dot-failed  { background: var(--critical-fg); }

@keyframes ai-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.ai-model-version {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.ai-model-sensor {
  font-size: 10px;
  color: var(--muted-2);
  margin-left: auto;
}

/* ── Main prediction display ───────────────────────────────── */
/* Two-card split: text summary on the left, round match gauge on the
   right. Using grid (not the old flex row) keeps the two halves as
   independent boxes so the gauge can grow into a large round "LCD"
   panel without the label text reflowing around it. */
.ai-prediction-main {
  display: grid;
  /* Even 50/50 split: text summary left, live scope right. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 16px;
  margin-bottom: 12px;
}

.ai-prediction-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.ai-prediction-right {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-prediction-label-area {
  flex: 1;
  min-width: 0;
}

.ai-pred-stable-label {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-strong);
  line-height: 1.1;
  /* Wraps rather than truncating. This is the headline result - "Unknown
     vibration pattern" was being cut to an ellipsis at tablet widths, hiding
     the single most important word on the page. Pattern names are
     user-defined, so there is no length that is safe to assume. */
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 0;
}

.ai-pred-stable-label.ai-pred-classified {
  color: var(--normal-fg);
}

.ai-pred-stable-label.ai-pred-fallback {
  color: var(--warning-fg);
}

.ai-pred-stable-label.ai-pred-not-ready {
  color: var(--muted);
}

.ai-pred-sublabel {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Overall match ring ─────────────────────────────────────── */
.ai-confidence-ring-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.ai-confidence-ring {
  width: 72px;
  height: 72px;
}

.ai-confidence-ring circle:last-child {
  transition: stroke-dashoffset 520ms cubic-bezier(.18,.82,.22,1), stroke 240ms ease;
}

.ai-confidence-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: 0.04em;
}

/* ── Fallback banner ───────────────────────────────────────── */
.ai-fallback-banner {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  color: var(--warning-fg);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}

/* ── Signature comparison bars ──────────────────────────────────────── */
.ai-prob-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.ai-decision-summary {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ai-decision-line {
  display: grid;
  grid-template-columns: minmax(80px, 0.4fr) minmax(0, 1fr);
  align-items: baseline;
  gap: 4px 12px;
  font-size: 11px;
  line-height: 1.4;
}

.ai-decision-line span {
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 9px;
  font-weight: 800;
}

.ai-decision-line strong {
  color: var(--text-strong);
  text-align: right;
  /* pre-line honours the explicit newline in the Analysis timing text (see
     aiCalculationText) while still wrapping normally everywhere else. */
  white-space: pre-line;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ai-signature-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 7px;
}

.ai-signature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.ai-signature-card {
  min-width: 0;
  min-height: 172px;
  padding: 10px;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  color: var(--text);
  transition: border-color 420ms ease, background 420ms ease, box-shadow 420ms ease;
}

.ai-signature-card-closest {
  border-color: var(--accent);
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--accent) 70%, transparent);
}

.ai-signature-card-matched {
  border-color: color-mix(in srgb, var(--normal) 72%, var(--line-2));
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--normal) 64%, transparent);
}

.ai-signature-card-ambiguous {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line-2));
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--accent) 40%, transparent);
}

.ai-signature-card-outside,
.ai-signature-card-invalid {
  border-color: var(--line);
  background: color-mix(in srgb, var(--control-bg) 96%, var(--muted-2) 4%);
}

.ai-signature-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
}

.ai-signature-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text-strong);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-signature-badge {
  flex: 0 1 auto;
  max-width: 58%;
  padding: 2px 5px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  line-height: 1.2;
  text-align: right;
  text-transform: uppercase;
}

.ai-signature-card-matched .ai-signature-badge {
  border-color: var(--normal);
  color: var(--normal-fg);
}

.ai-signature-card-ambiguous .ai-signature-badge {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--line-2));
  color: var(--accent);
}

.ai-signature-card-outside .ai-signature-badge,
.ai-signature-card-invalid .ai-signature-badge {
  border-color: var(--line-2);
  color: var(--muted);
}

.ai-signature-card-main {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 7px 0;
}

.ai-signature-meter {
  position: relative;
  width: 72px;
  height: 72px;
}

.ai-signature-meter svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ai-signature-meter circle {
  fill: none;
  stroke-width: 5;
}

.ai-signature-meter-track {
  stroke: var(--border);
}

.ai-signature-meter-value {
  stroke: var(--accent);
  stroke-dasharray: 150.8;
  stroke-dashoffset: 150.8;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 760ms cubic-bezier(.22,.72,.24,1), stroke 420ms ease;
  will-change: stroke-dashoffset;
}

.ai-signature-meter-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-strong);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.ai-signature-trend {
  min-width: 0;
}

.ai-signature-trend > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted-2);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-signature-sparkline {
  display: block;
  width: 100%;
  height: 48px;
  overflow: visible;
}

.ai-signature-sparkline path {
  fill: none;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: stroke 420ms ease, opacity 420ms ease;
}

.ai-signature-distance {
  padding: 5px 0;
  border-top: 1px solid var(--line);
  color: var(--text-strong);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.ai-signature-channel-matches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.ai-signature-channel-matches span {
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.ai-signature-channel-matches strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 13px;
}

.ai-signature-boundaries {
  display: none;
}

.ai-signature-boundaries {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 9px;
}

.ai-signature-boundaries span {
  min-width: 0;
  padding: 5px;
  border: 1px solid var(--line);
  text-align: center;
}

.ai-signature-boundaries strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 10px;
}

@media (max-width: 420px) {
  .ai-signature-channel-matches {
    grid-template-columns: 1fr;
  }

  .ai-signature-boundaries {
    grid-template-columns: 1fr;
  }
}

.ai-signature-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted-2);
  font-size: 8px;
  text-transform: uppercase;
}

.ai-signature-warning {
  display: inline-grid;
  min-width: 28px;
  height: 15px;
  padding: 0 4px;
  place-items: center;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-weight: 800;
  font-size: 7px;
}

.ai-signature-details-toggle {
  margin-top: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.ai-signature-details {
  display: grid;
  gap: 3px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.ai-signature-details > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 9px;
}

.ai-signature-details span {
  color: var(--muted-2);
}

.ai-signature-details strong {
  min-width: 0;
  color: var(--text);
  text-align: right;
  overflow-wrap: anywhere;
}

.ai-signature-toggle {
  align-self: flex-start;
  min-height: 32px;
  margin-top: 4px;
}

.ai-prob-empty {
  font-size: 11px;
  color: var(--muted-2);
  padding: 4px 0;
}

.ai-prob-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(80px, 1fr) minmax(86px, 120px);
  align-items: center;
  gap: 8px;
  transform-origin: center left;
  transition: background 180ms ease, border-color 180ms ease;
}

.ai-prob-row-enter {
  animation: ai-row-in 360ms cubic-bezier(.2,.8,.2,1) both;
}

.ai-prob-row-top {
  animation: ai-row-glow 700ms ease;
}

.ai-prob-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-prob-label.ai-prob-top {
  color: var(--text-strong);
  font-weight: 700;
}

.ai-prob-bar-track {
  height: 8px;
  background: var(--border);
  overflow: hidden;
}

.ai-prob-bar-fill {
  height: 100%;
  background: var(--info);
  transition: width 720ms cubic-bezier(.18,.82,.22,1), background 220ms ease, box-shadow 220ms ease;
  will-change: width;
}

.ai-prob-bar-fill.ai-prob-fill-top {
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent);
}

.ai-prob-pct {
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Prediction meta row ───────────────────────────────────── */
.ai-class-gate {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0 10px;
  border-top: 1px solid var(--line);
}

.ai-gate-title {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.ai-class-gate-results {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ai-gate-row {
  display: grid;
  grid-template-columns: minmax(100px, 150px) 76px minmax(80px, 1fr) minmax(160px, 240px);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ai-gate-label,
.ai-gate-status,
.ai-gate-detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.ai-gate-label {
  color: var(--text-strong);
  font-weight: 700;
}

.ai-gate-status {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ai-gate-accept .ai-gate-status { color: var(--normal-fg); }
.ai-gate-reject .ai-gate-status { color: var(--warning-fg); }
.ai-gate-disabled .ai-gate-status { color: var(--muted); }
.ai-gate-disabled .ai-gate-fill { background: var(--muted-2); }

.ai-gate-track {
  height: 7px;
  background: var(--border);
  overflow: hidden;
}

.ai-gate-fill {
  height: 100%;
  background: var(--info);
  transition: width 0.35s ease;
}

.ai-gate-reject .ai-gate-fill {
  background: var(--warning);
}

.ai-gate-detail {
  color: var(--muted-2);
  text-align: right;
}

.ai-abnormal-reason {
  padding: 6px 8px;
  border: 1px solid var(--warning);
  background: var(--warning-bg);
  color: var(--warning-fg);
  font-size: 10px;
  font-weight: 700;
}

/* Decision engine detail: the moving-window accumulator's own live numbers -
   the thing that actually decides stableStatus/stableLabel. Kept visually
   distinct (accent border, not accept/reject red-green) since it explains a
   mechanism, not a pass/fail verdict. */
.ai-decision-engine {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--panel) 85%, var(--accent) 6%);
  flex-direction: column;
  gap: 6px;
}

/* display is conditional (not a bare declaration on .ai-decision-engine)
   so the shared .hidden{display:none} utility - defined earlier in this
   file at identical specificity - still wins the cascade when JS toggles
   it via showHide(). A bare "display: flex" here previously beat .hidden
   by source order alone, leaving an empty flex box visible at all times. */
.ai-decision-engine:not(.hidden) {
  display: flex;
}

.ai-engine-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

/* One-line, plain-language summary of what this whole box is. Kept to a
   single short sentence - row labels below are self-descriptive on their
   own, with the fuller definition available as a native hover tooltip
   (title attribute) instead of always-visible prose. */
.ai-engine-subtitle {
  margin: 0 0 2px;
  color: var(--text-soft);
  font-size: 10.5px;
  line-height: 1.5;
}

.ai-engine-row {
  display: grid;
  grid-template-columns: minmax(130px, 210px) minmax(60px, 1fr) minmax(70px, auto);
  align-items: center;
  gap: 8px;
}

.ai-engine-row > span:first-child {
  font-size: 10px;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}

.ai-engine-row > strong {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.ai-engine-bar {
  height: 6px;
  background: var(--border);
  overflow: hidden;
}

.ai-engine-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.35s ease;
}

.ai-engine-bar-fill-warn {
  background: var(--warning);
}

.ai-engine-pending {
  font-size: 10px;
  color: var(--warning-fg);
}

.ai-engine-pending strong {
  color: var(--text-strong);
}

/* On wide desktop viewports the prediction card can be well over 1000px
   across, which stretched these bars into oversized, hard-to-read meters.
   Capping the bar/track itself (not the grid column) keeps every label and
   number exactly where it was - the bar just stops growing and settles at
   a normal progress-bar width, with a little breathing room to its right.
   Mobile (<=640px, already single-column below) is left alone. */
@media (min-width: 641px) {
  #pane-ai-classifier .ai-gate-track,
  #pane-ai-classifier .ai-engine-bar {
    max-width: 260px;
  }
}

@media (max-width: 640px) {
  .ai-engine-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
  .ai-engine-row > strong {
    text-align: left;
  }
}

.ai-threshold-config {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
}

.ai-threshold-toggle-row {
  margin-bottom: 10px;
}

.ai-threshold-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.ai-prediction-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-bottom: 10px;
}

.ai-prediction-meta > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-prediction-meta span {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.ai-prediction-meta strong {
  font-size: 11px;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-rejected-status { color: var(--warning-fg) !important; }

/* ── Recent windows strip ──────────────────────────────────── */
.ai-recent-preds {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-recent-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
}

.ai-recent-list {
  display: flex;
  flex-wrap: wrap;
  column-gap: 6px;
  row-gap: 5px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}

.ai-recent-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.ai-recent-arrow-enter {
  animation: none;
}

.ai-recent-chip {
  display: inline-block;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  background: var(--control-bg);
  border: 1px solid var(--line-2);
  color: var(--text);
  letter-spacing: 0.03em;
  transform-origin: center;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.ai-recent-chip-enter {
  animation: none;
}

.ai-recent-chip-new {
  animation: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line-2));
}

.ai-chip-fallback {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line-2));
  color: var(--text);
  background: color-mix(in srgb, var(--control-bg) 90%, var(--accent) 10%);
}

@keyframes ai-row-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes ai-row-glow {
  0%   { background: color-mix(in srgb, var(--accent) 16%, transparent); }
  100% { background: transparent; }
}

@keyframes ai-chip-in {
  from { opacity: 1; transform: none; }
  to   { opacity: 1; transform: none; }
}

@keyframes ai-chip-arrow-in {
  from { opacity: 1; transform: none; }
  to   { opacity: 1; transform: none; }
}

@keyframes ai-chip-soft-flash {
  0% {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
  }
  100% {
    border-color: var(--line-2);
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-prob-row-enter,
  .ai-prob-row-top,
  .ai-recent-chip-enter,
  .ai-recent-chip-new,
  .ai-recent-arrow-enter {
    animation: none;
  }
  .ai-prob-bar-fill,
  .ai-recent-chip,
  .ai-signature-meter-value,
  .ai-signature-card,
  .ai-confidence-ring circle:last-child {
    transition: none;
  }
}

@media (max-width: 640px) {
  .ai-signature-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .ai-signature-card {
    min-height: 0;
  }

  .ai-signature-card-main {
    grid-template-columns: 72px minmax(0, 1fr);
  }
}

/* ── Feature checkboxes ────────────────────────────────────── */
.ai-feature-schema {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 0;
}

/* Groups a Pattern Settings field cluster (Signals / Recognition Behaviour)
   into one visually bounded block instead of a continuous run of loosely
   related rows - gives each concern its own edge to stop at. */
.ai-settings-card {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, var(--control-bg) 8%);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-settings-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.ai-settings-card-head .ai-section-label {
  flex: 1 1 auto;
}

/* Collapsed: sits compactly next to the label on the same row (shrinks
   rather than forcing the row wider - flex-shrink:0 + the default
   min-width:auto on a flex item is what let the closed chip get away
   with looking fine while silently setting up an overflow once opened).
   Open: the <details> (summary chip + body box together) claims the full
   row width so .whats-this-body wraps normally inside the card instead of
   being sized to its longest unwrapped line and blowing out past the
   viewport edge. */
.ai-settings-card-head .whats-this {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.ai-settings-card-head .whats-this[open] {
  flex-basis: 100%;
}

.ai-settings-card-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.ai-settings-card-foot .ai-feature-count {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.ai-settings-card-foot .ai-note {
  flex: 1 1 220px;
  margin: 0;
}

/* Compact "Current Sensor / Device" line - a read-only label, not an input,
   so it no longer needs to look like a full-width form field. */
.ai-settings-sensor-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-current-sensor {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-current-sensor-inline {
  min-height: 26px;
  padding: 0 10px;
  font-size: 12px;
  width: auto;
  flex: 0 0 auto;
  max-width: 260px;
}

/* Compact, non-stretching chips instead of one column stacked full-height
   or a grid that stretches four items across the entire panel width. */
.ai-feature-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-descriptor-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin-bottom: 10px;
}

.ai-feature-count {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 12px;
}

.ai-feature-count.is-warning {
  border-color: var(--warning);
  color: var(--warning-fg);
}

@media (max-width: 700px) {
  .ai-descriptor-checks { grid-template-columns: 1fr; }
}

/* Clickable checkbox labels - compact chips that size to their own content
   and sit flush together on the left, rather than one full-width row or a
   grid stretched thin across the whole panel. */
.ai-check-item {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
  line-height: 1.3;
  white-space: nowrap;
}

.ai-check-item:hover {
  background: var(--control-hover);
  color: var(--text-strong);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.ai-check-item:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--control-bg));
  color: var(--text-strong);
}

/* Custom checkbox controls */
.ai-check-item input[type="checkbox"] {
  /* Fully custom checkbox, no browser chrome */
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 15px;
  height: 15px;
  min-width: 15px;
  padding: 0;
  margin: 0;
  border: 1.5px solid var(--line-2);
  background: var(--input-bg);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 0;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  outline: none;
  vertical-align: middle;
}

/* Hover: accent border */
.ai-check-item:hover input[type="checkbox"]:not(:checked):not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

/* Checked: filled with accent, dark tick */
.ai-check-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

/* Tick mark via pseudo-element */
.ai-check-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: 1.5px solid var(--control-active-text);
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* Focus ring */
.ai-check-item input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 32%, transparent), 0 0 0 1px var(--accent);
}

/* Disabled */
.ai-check-item input[type="checkbox"]:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--line);
}

.ai-check-item:has(input:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--muted);
}

.ai-schema-warning {
  font-size: 11px;
  color: var(--warning-fg);
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  padding: 5px 8px;
}

/* ── Label management ──────────────────────────────────────── */
.ai-label-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 40px;
  margin-bottom: 10px;
  max-height: 160px;
  overflow-y: auto;
}

.ai-label-empty {
  font-size: 11px;
  color: var(--muted-2);
  padding: 6px 0;
}

.ai-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: var(--control-bg);
  border: 1px solid var(--line);
}

.ai-label-chip {
  flex: 1;
  font-size: 11px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-label-normal {
  color: var(--normal-fg);
}

.ai-label-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted-2);
  font-size: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.ai-label-delete:hover:not(:disabled) {
  background: var(--critical-bg);
  border-color: var(--critical);
  color: var(--critical-fg);
}

.ai-label-delete:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ai-label-add {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.ai-label-add input {
  flex: 1;
  min-width: 0;
}

.ai-label-add .btn {
  flex-shrink: 0;
  width: auto;
  min-width: 70px;
}

/* ── Notes ─────────────────────────────────────────────────── */
.ai-note {
  font-size: 10px;
  color: var(--muted-2);
  line-height: 1.5;
  margin: 6px 0 0;
}

.ai-note em {
  color: var(--muted);
  font-style: normal;
  font-weight: 600;
}

.ai-note-ok   { color: var(--normal-fg); }
.ai-note-warn { color: var(--warning-fg); }

/* ── AI buttons ─────────────────────────────────────────────── */
.ai-btn-sm {
  font-size: 10px;
  min-height: 30px;
  padding: 5px 10px;
  /* width: auto — buttons size to their label, not the full container */
  width: auto;
  align-self: flex-start;
}

.ai-btn-record {
  background: var(--critical-bg);
  border-color: var(--critical);
  color: var(--critical-fg);
  font-size: 11px;
  letter-spacing: 0.06em;
  width: auto;
}

.ai-btn-record:hover {
  background: var(--critical);
  color: var(--text-strong);
}

.ai-btn-train {
  background: var(--info);
  border-color: var(--info);
  color: var(--control-active-text);
  font-size: 11px;
  letter-spacing: 0.07em;
  width: auto;
  min-width: 180px;
  min-height: 38px;
  margin-bottom: 14px;
}

.ai-btn-train:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--control-active-text);
}

.ai-btn-train:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-danger {
  background: var(--critical-bg);
  border-color: var(--critical);
  color: var(--critical-fg);
}

.btn-danger:hover:not(:disabled) {
  background: var(--critical);
  color: var(--text-strong);
}

.btn-danger:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Recording controls ────────────────────────────────────── */
.ai-recording-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.ai-record-actions {
  display: flex;
  gap: 6px;
}

.ai-record-actions .btn {
  flex: 0 1 auto;
}

/* Recording live status */
.ai-recording-status {
  background: var(--critical-bg);
  border: 1px solid var(--critical);
  padding: 8px 10px;
}

.ai-rec-dot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-rec-dot-blink {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--critical-fg);
  flex-shrink: 0;
  animation: ai-pulse 0.8s infinite;
}

.ai-rec-status-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--critical-fg);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ai-rec-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 12px;
}

.ai-rec-stats > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ai-rec-stats span {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.ai-rec-stats strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

/* ── Dataset summary ───────────────────────────────────────── */
.ai-dataset-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.ai-dataset-total {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 4px;
}

.ai-dataset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto 32px;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--control-bg);
  border-left: 3px solid transparent;
}

.ai-ds-ok   { border-left-color: var(--normal); }
.ai-ds-warn { border-left-color: var(--warning); }

.ai-dataset-label {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-dataset-count {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ai-dataset-req {
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.ai-ds-ok   .ai-dataset-req { color: var(--normal-fg); }
.ai-ds-warn .ai-dataset-req { color: var(--warning-fg); }

.ai-dataset-delete {
  width: 32px;
  height: 32px;
  min-width: 32px;
  font-size: 12px;
  color: var(--muted);
}

.ai-dataset-delete:hover:not(:disabled) {
  background: var(--critical-bg);
  border-color: var(--critical);
  color: var(--critical-fg);
}

.ai-model-delete {
  margin-top: 8px;
  width: auto;
  align-self: flex-start;
}

.ai-dataset-actions {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Training panel ────────────────────────────────────────── */
.ai-training-status {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding-top: 4px;
}

.ai-training-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.ai-training-actions .ai-btn-train,
.ai-training-actions .ai-model-delete {
  width: auto;
  min-height: 40px;
  margin: 0;
}

.ai-training-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ai-training-metrics .ai-train-state-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--control-bg);
}

.ai-training-metrics .ai-train-state-row strong {
  width: 100%;
  text-align: left;
}

.ai-train-message-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: start;
  padding: 8px;
  border: 1px solid var(--line);
}

.ai-train-message-row > span:last-child {
  text-align: left;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.ai-train-state-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  min-width: 0;
}

.ai-train-state-row > span:first-child {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
  min-width: 0;
}

.ai-train-state-row > strong,
.ai-train-state-row > span:last-child {
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-train-state-row.ai-train-message-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 5px;
}

.ai-train-state-row.ai-train-message-row > span:last-child {
  width: 100%;
  text-align: left;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.ai-train-progress-wrap {
  height: 4px;
  background: var(--border);
  overflow: hidden;
  margin: 2px 0;
}

.ai-train-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

.ai-train-result {
  padding: 8px;
  background: var(--normal-bg);
  border: 1px solid var(--normal);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.ai-train-error {
  padding: 8px;
  background: var(--critical-bg);
  border: 1px solid var(--critical);
  color: var(--critical-fg);
  font-size: 11px;
  line-height: 1.5;
  margin-top: 4px;
  word-break: break-word;
}

/* ── btn-icon helper (used by label delete) ─────────────────── */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--muted-2);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

@media (max-width: 820px) {
  .panel-header {
    flex-direction: column;
    gap: 2px;
  }

  .panel-meta {
    text-align: left;
  }

  .ai-prediction-main {
    align-items: flex-start;
  }

  .ai-pred-stable-label {
    white-space: normal;
    font-size: 22px;
  }

  .ai-label-add,
  .ai-record-actions {
    flex-direction: column;
  }

  .ai-label-add .btn,
  .ai-record-actions .btn {
    min-height: 40px;
    width: 100%;
  }

  .ai-dataset-row {
    grid-template-columns: minmax(0, 1fr) auto 32px;
  }

  .ai-dataset-count {
    grid-column: 1;
  }

  .ai-dataset-req {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .ai-dataset-delete {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .ai-gate-row {
    grid-template-columns: minmax(0, 1fr) 82px;
  }

  .ai-gate-track,
  .ai-gate-detail {
    grid-column: 1 / -1;
  }

  .ai-gate-detail {
    text-align: left;
    white-space: normal;
  }

  .ai-train-state-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .ai-train-state-row > strong,
  .ai-train-state-row > span:last-child {
    text-align: left;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 520px) {
  .ai-training-actions,
  .ai-training-metrics {
    grid-template-columns: 1fr;
  }

  .ai-train-message-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

.btn-icon:hover:not(:disabled) {
  background: var(--critical-bg);
  border-color: var(--critical);
  color: var(--critical-fg);
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.vs-toast-stack {
  position: fixed;
  right: 14px;
  top: 54px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(340px, calc(100vw - 28px));
  pointer-events: none;
}

.vs-toast {
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.32);
  padding: 9px 11px;
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: 0;
  opacity: 0.96;
  transform: translateY(0);
  transition: opacity 0.22s ease, transform 0.22s ease;
  overflow-wrap: anywhere;
}

.vs-toast-success {
  border-color: var(--normal);
  background: var(--panel);
  color: var(--text-strong);
}

.vs-toast-error {
  border-color: var(--critical);
  background: var(--panel);
  color: var(--critical-fg);
}

.vs-toast-warn {
  border-color: var(--warning);
  background: var(--panel);
  color: var(--warning-fg);
}

.vs-toast-info {
  border-color: var(--accent);
  background: var(--panel-2);
  color: var(--text);
}

.vs-toast-fade {
  opacity: 0;
  transform: translateY(6px);
}

@media (max-width: 640px) {
  .vs-toast-stack {
    right: 10px;
    top: 50px;
    width: calc(100vw - 20px);
  }
}

/* ── Advanced / Experimental shape features section ────────── */
.ai-advanced-section {
  margin-top: 8px;
  border: 1px solid var(--border, #ddd);
  border-radius: 3px;
  padding: 4px 8px 8px;
}
.ai-advanced-section summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  padding: 4px 0;
}
.ai-advanced-section summary::-webkit-details-marker { display: none; }
.ai-advanced-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.ai-advanced-badge {
  font-size: 9px;
  font-weight: 600;
  background: var(--warning-bg, #fff3cd);
  color: var(--warning-fg, #856404);
  border-radius: 3px;
  padding: 1px 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Y-axis manual range row (min / max inputs + pan buttons) ── */
.y-minmax-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.y-range-input {
  width: 62px;
  padding: 2px 5px;
  font-size: 11px;
  text-align: right;
  font-family: var(--font-ui);
}

.y-range-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.y-pan-btn {
  min-width: 26px;
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1;
}

.y-pan-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Responsive improvements (layout audit patch) ──────────── */

/* Y min/max row: allow wrapping on narrow toolbar widths */
@media (max-width: 820px) {
  .y-minmax-row {
    flex-wrap: wrap;
    gap: 4px 6px;
  }
  .y-range-input {
    width: 54px;
  }
}

@media (max-width: 600px) {
  /* justify-content:space-between combined with wrapping re-distributed
     free space between every item on each wrapped line, so "Y min", its
     input, "max", its input, and the two pan buttons landed with uneven,
     disconnected gaps instead of reading as one control. flex-start plus a
     fixed gap keeps each label glued to its input; the inputs still grow to
     fill the row via flex so it doesn't end up sparse either. */
  .y-minmax-row {
    width: 100%;
    justify-content: flex-start;
    gap: 6px 8px;
  }

  .y-range-input {
    width: 72px;  /* more finger-friendly */
    flex: 1 1 72px;
    min-width: 0;
  }

  .y-pan-btn {
    flex: 0 0 auto;
    min-width: 36px;
    padding: 4px 8px;
  }

  /* x-window presets: fill the row */
  .x-window-presets {
    width: 100%;
  }
  .x-window-presets .seg-btn {
    flex: 1;
    min-width: 0;
  }

  /* Wider x-window input on mobile */
  .x-window-field input {
    width: 64px;
  }

  /* Trend stats: always 1 col on phone */
  .trend-stats-grid {
    grid-template-columns: 1fr !important;
  }

}

/* Panel header: ensure panel-meta doesn't bleed over panel-title */
@media (max-width: 640px) {
  .panel-header {
    flex-direction: column;
    gap: 2px;
  }

  .panel-meta {
    text-align: left;
  }

  .panel-title-wrap {
    width: 100%;
    flex-wrap: wrap;
    gap: 4px;
  }
}

/* Trend toolbar: let the status text wrap */
.trend-toolbar {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Ensure panel body never overflows its container */
.panel-body {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* Appbar cells: no text overflow at narrow widths */
.appbar-cell {
  min-width: 0;
  flex-shrink: 1;
}

.appbar-cell > span,
.appbar-cell > strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 600px) {
  .badge,
  .status-pill {
    min-inline-size: 74px;
  }

  .appbar .badge {
    min-inline-size: 0;
    width: 100%;
  }
}
/* ===================================================================
   AI EXPERIENCE - clean professional styling
   Scoped to the two AI panes. No decorative background animation and no
   glow; only purposeful micro-interactions (hover / focus / expand).
   All motion respects prefers-reduced-motion.
   =================================================================== */

#pane-ai-classifier,
#pane-ai-configuration {
  position: relative;
}

/* Panels: solid, crisp, restrained hover -------------------------- */
#pane-ai-classifier .panel,
#pane-ai-configuration .panel {
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
#pane-ai-classifier .panel:hover,
#pane-ai-configuration .panel:hover {
  border-color: var(--line-2);
  box-shadow: 0 6px 22px -18px rgba(0, 0, 0, 0.9);
}

/* Plain-language intro strip -------------------------------------- */
.ai-intro {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.15rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--panel-header-accent);
  border-radius: 0;
  background: var(--panel-2);
}
/* Same SVG glyph as the matching sidebar nav item (currentColor keeps it
   in sync with the accent colour below) - previously a bespoke CSS-drawn
   shape per page that didn't match its own nav icon. */
.ai-intro-icon {
  display: inline-grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  position: relative;
  flex: 0 0 auto;
  border-radius: 0;
  background: var(--control-bg);
  border: 1px solid var(--line-2);
  color: var(--accent);
  overflow: hidden;
}
.ai-intro-icon svg {
  display: block;
}
.ai-intro-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-strong);
}
.ai-intro-sub {
  flex: 1 1 320px;
  min-width: 220px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Numbered step badge in panel headers ---------------------------- */
.panel-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.ai-step-badge {
  display: inline-grid;
  place-items: center;
  width: 1.55em;
  height: 1.55em;
  flex: 0 0 auto;
  border-radius: 0;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Expandable "What's this?" explainer (native <details>, no JS) ---- */
.whats-this {
  margin: 0 0 0.55rem;
}
.whats-this > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.18rem 0.5rem 0.18rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--control-bg);
  transition: color 0.15s ease, border-color 0.15s ease;
  user-select: none;
}
.whats-this > summary::-webkit-details-marker { display: none; }
.whats-this > summary::before {
  content: "?";
  display: inline-grid;
  place-items: center;
  width: 1.15em;
  height: 1.15em;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.7em;
}
.whats-this:hover > summary { color: var(--text-soft); border-color: var(--line-2); }
.whats-this[open] > summary { color: var(--text-soft); }
.whats-this-body {
  margin-top: 0.45rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--text-soft);
  font-size: 0.8rem;
  line-height: 1.55;
  /* Belt-and-braces: whatever box this ends up inside of (flex row, grid
     cell, etc.), it must wrap to that container's width rather than being
     sized to its longest unwrapped line and overflowing past the edge. */
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
}
.whats-this-body strong { color: var(--text-strong); }
.whats-this-body .term { color: var(--accent); font-weight: 600; }

/* Definition-list variant of the explainer body: short dt/dd pairs that
   match the exact on-screen labels 1:1, instead of one dense paragraph
   trying to define five things at once. */
.ai-explainer-list {
  margin: 0;
}
.ai-explainer-list dt {
  margin: 0.5rem 0 0.15rem;
  color: var(--text-strong);
  font-weight: 700;
}
.ai-explainer-list dt:first-child {
  margin-top: 0;
}
.ai-explainer-list dd {
  margin: 0 0 0 0;
}

/* Live scope: fills its half of the card. The round progress ring that used
   to sit here was removed - the same match percentage is already stated in
   the summary text and the meta grid, so a third copy of it was repetition. */
#pane-ai-classifier .ai-confidence-ring-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  height: auto;
  margin-inline: auto;
  border-radius: 50%;
  background: color-mix(in srgb, var(--panel-hdr) 70%, var(--control-bg) 30%);
}

/* Live wave scope sits inside the ring: the dial face, with the progress
   The canvas clips its own drawing to a circle (see ai-wave-scope.js) -
   border-radius alone is not reliable for canvas painting, which is what
   let crest lines escape through the corners. */
#pane-ai-classifier .ai-wave-scope {
  position: absolute;
  /* !important is required, not stylistic: the global `canvas` reset near the
     top of this file sets width/height to 100% !important for chart canvases,
     which outranks even an ID selector. Without matching !important here the
     canvas ignores this box entirely. */
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  border-radius: 50%;
  pointer-events: none;
  display: block;
}

/* Buttons: restrained hover --------------------------------------- */
#pane-ai-classifier .btn,
#pane-ai-configuration .btn {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* Configuration page: guided-workflow board ----------------------- */
#pane-ai-configuration .pane-ai-config {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}
/* Full-width steps stack; labels (2) + record (3) share one row. The
   per-panel grid-column for labels/recording is reset to auto, otherwise the
   base 3-column placement leaves them pinned to columns 2/3 and the recording
   card overflows the 2-column grid. */
#pane-ai-configuration .pane-ai-config > .ai-intro,
#pane-ai-configuration .pane-ai-config .ai-workflow-panel,
#pane-ai-configuration .pane-ai-config .ai-config-panel,
#pane-ai-configuration .pane-ai-config .ai-dataset-panel,
#pane-ai-configuration .pane-ai-config .ai-training-panel {
  grid-column: 1 / -1;
}
#pane-ai-configuration .pane-ai-config .ai-labels-panel,
#pane-ai-configuration .pane-ai-config .ai-recording-panel {
  grid-column: auto;
}
@media (max-width: 1024px) {
  #pane-ai-configuration .pane-ai-config { grid-template-columns: 1fr; }
  #pane-ai-configuration .pane-ai-config > * { grid-column: 1 / -1; }
}

.ai-workflow-panel .panel-header {
  min-height: 42px;
}

.ai-workflow-panel .panel-body {
  padding: 12px;
}

.ai-workflow-step-hidden {
  display: none !important;
}

.ai-workflow-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  isolation: isolate;
}

.ai-workflow-cables {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}

/* Static "wire" track between cards - no motion here; the arrows on top are
   what light up. */
.ai-workflow-cables path {
  fill: none;
  stroke: var(--border-2);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 5 6;
  opacity: 0.55;
}

/* One fixed arrow per connector, pointing from step N to step N+1. The
   arrows never move - they sit still and periodically light up left to
   right (step 1's arrow, then step 2's, then step 3's...), then everything
   goes dark for a few seconds before the next sweep. */
.ai-cable-chevron path {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.ai-cable-chevron {
  stroke: var(--border-2);
  opacity: 0.55;
  animation-name: aiChevronSweep;
  animation-duration: 4.6s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

@keyframes aiChevronSweep {
  0%   { stroke: var(--border-2); opacity: 0.55; filter: none; }
  6%   { stroke: var(--accent); opacity: 1; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 65%, transparent)); }
  16%  { stroke: var(--border-2); opacity: 0.55; filter: none; }
  100% { stroke: var(--border-2); opacity: 0.55; filter: none; }
}

.ai-workflow-card {
  position: relative;
  z-index: 1;
  min-height: 118px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, var(--control-bg) 12%);
  cursor: grab;
  user-select: none;
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.ai-workflow-card:active {
  cursor: grabbing;
}

.ai-workflow-card:hover,
.ai-workflow-card:focus-visible {
  border-color: var(--accent);
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.55);
}

.ai-workflow-card:active {
  transform: translateY(-1px) scale(0.99);
}

.ai-workflow-card.is-active {
  border-color: var(--normal);
  background: color-mix(in srgb, var(--panel) 76%, var(--normal) 12%);
  box-shadow: inset 3px 0 0 var(--normal-fg);
}

.ai-workflow-card.is-dragging {
  opacity: 0.58;
  transform: scale(0.985);
}

.ai-workflow-card.is-drop-target {
  border-color: var(--normal);
  background: color-mix(in srgb, var(--panel) 78%, var(--normal) 10%);
}

.ai-workflow-node {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--text-strong);
  background: color-mix(in srgb, var(--control-bg) 72%, var(--accent) 28%);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s ease;
}

/* Completed-step indicator: a small checkmark badge on the numbered node,
   driven by real progress (labels added, samples recorded, model trained)
   rather than just which card is open. */
.ai-workflow-card.is-complete .ai-workflow-node {
  border-color: var(--normal-fg);
}

.ai-workflow-card.is-complete .ai-workflow-node::after {
  content: '\2713';
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--normal-fg);
  color: var(--panel);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--panel);
}

/* Small bounce the instant a step flips from incomplete to complete - a
   quick, satisfying "nice, that's done" beat rather than a silent state change. */
.ai-workflow-card.is-complete.ai-step-just-completed .ai-workflow-node::after {
  animation: aiCheckPop 0.42s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes aiCheckPop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Progress badge (label/sample counts) in the corner of a workflow card. */
.ai-workflow-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 7px;
  border-radius: 3px;
  color: var(--normal-fg);
  background: color-mix(in srgb, var(--panel) 70%, var(--normal) 16%);
  border: 1px solid color-mix(in srgb, var(--normal-fg) 40%, var(--line) 60%);
  white-space: nowrap;
}

/* Overall setup progress, shown in the Setup Flow panel header. */
.ai-workflow-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ai-workflow-progress-bar {
  position: relative;
  width: 90px;
  height: 6px;
  border-radius: 3px;
  background: var(--control-bg);
  border: 1px solid var(--line);
  overflow: hidden;
  flex-shrink: 0;
}

.ai-workflow-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--normal-fg);
  border-radius: inherit;
  transition: width 0.4s cubic-bezier(.16, 1, .3, 1);
}

.ai-workflow-progress-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ai-workflow-progress.is-complete .ai-workflow-progress-label {
  color: var(--normal-fg);
}

/* Panel entrance: a quick settle-in rather than an instant, jarring swap
   whenever a workflow step opens. */
@keyframes aiPanelPop {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-panel-pop {
  animation: aiPanelPop 0.32s cubic-bezier(.16, 1, .3, 1);
}

.ai-workflow-card strong {
  color: var(--text-strong);
  font-size: 14px;
  line-height: 1.2;
}

.ai-workflow-card > span:not(.ai-workflow-node):not(.ai-workflow-badge) {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 1180px) {
  .ai-workflow-board {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 720px) {
  .ai-workflow-board {
    grid-template-columns: 1fr;
  }

  .ai-workflow-card {
    min-height: 92px;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
  }

  .ai-workflow-card > span:not(.ai-workflow-node):not(.ai-workflow-badge) {
    grid-column: 2;
  }

  /* Keep the title clear of the absolutely positioned progress badge. */
  .ai-workflow-card:has(.ai-workflow-badge) strong {
    padding-right: 72px;
  }
}

/* Respect reduced-motion ------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  #pane-ai-classifier .panel,
  #pane-ai-configuration .panel,
  #pane-ai-classifier .btn,
  #pane-ai-configuration .btn,
  .whats-this > summary,
  .whats-this > summary::after,
  #aiConfidenceArc {
    transition: none !important;
  }

  .ai-cable-chevron,
  .ai-workflow-card.is-complete.ai-step-just-completed .ai-workflow-node::after,
  .ai-panel-pop,
  .ai-workflow-card {
    animation: none !important;
    transition: none !important;
  }

  .ai-workflow-card:hover,
  .ai-workflow-card:focus-visible,
  .ai-workflow-card:active {
    transform: none !important;
  }
}

/* ===================== UI CLEANUP PASS ===================== */

@media (prefers-reduced-motion: reduce) {
  .startup-pulse-dot {
    animation: none;
  }
}

#pane-ai-classifier .ai-prediction-card .panel-body {
  display: grid;
  gap: 10px;
}

#pane-ai-classifier .ai-prediction-main {
  margin: 0;
}

#pane-ai-classifier .ai-pred-stable-label {
  font-size: clamp(20px, 3.4vw, 30px);
}

#pane-ai-classifier .ai-decision-summary,
#pane-ai-classifier .ai-prediction-meta,
#pane-ai-classifier .ai-recent-preds {
  margin-bottom: 0;
}

#pane-ai-classifier .ai-signature-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

#pane-ai-classifier .ai-signature-card {
  min-height: 0;
  padding: 11px;
  background: color-mix(in srgb, var(--panel) 82%, var(--control-bg) 18%);
}

#pane-ai-classifier .ai-signature-card-main {
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 12px;
}

#pane-ai-classifier .ai-signature-meter {
  width: 64px;
  height: 64px;
}

#pane-ai-classifier .ai-signature-meter-text {
  font-size: 11px;
}

#pane-ai-classifier .ai-signature-sparkline {
  height: 42px;
}

#pane-ai-classifier .ai-signature-badge,
#pane-ai-classifier .ai-signature-warning {
  border-color: var(--line-2);
  color: var(--muted);
  background: transparent;
}

#pane-ai-classifier .ai-signature-card-matched .ai-signature-badge,
#pane-ai-classifier .ai-signature-card-closest .ai-signature-badge {
  border-color: color-mix(in srgb, var(--normal-fg) 55%, var(--line-2));
  color: var(--normal-fg);
}

#pane-ai-classifier .ai-signature-card-outside .ai-signature-badge,
#pane-ai-classifier .ai-signature-card-invalid .ai-signature-badge {
  border-color: var(--line);
  color: var(--muted-2);
}

#pane-ai-classifier .ai-signature-channel-matches span {
  padding: 5px;
}

#pane-ai-classifier .ai-signature-details-toggle {
  color: var(--muted);
}

#pane-ai-configuration .panel-body {
  display: grid;
  gap: 10px;
}

#pane-ai-configuration .ai-threshold-config,
#pane-ai-configuration .ai-feature-schema {
  margin-top: 0;
}

#pane-ai-configuration .ai-training-status,
#pane-ai-configuration .ai-dataset-summary,
#pane-ai-configuration .ai-label-list {
  max-width: 100%;
}

#pane-ai-configuration .ai-training-panel .panel-body {
  gap: 12px;
}

#pane-ai-configuration .ai-training-actions {
  margin-bottom: 2px;
}

#pane-ai-configuration .ai-training-actions .ai-btn-train {
  min-width: 160px;
}

#pane-ai-configuration .ai-training-metrics {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

#pane-ai-classifier .btn,
#pane-ai-configuration .btn {
  max-width: 260px;
  white-space: nowrap;
}

#pane-ai-classifier .ai-label-add .btn,
#pane-ai-configuration .ai-label-add .btn {
  max-width: none;
}

#pane-ai-classifier .panel,
#pane-ai-configuration .panel {
  box-shadow: none;
}

/* ============================================================
   AI-Futuristic accents — Pattern Recognizer page only.
   Restrained sci-fi/HUD touches layered onto the aerospace-
   console base: top rule, corner frame, radar-ping
   "live" dot, glow states. Everything below is scoped under
   #pane-ai-classifier so Pattern Setup and the rest of the
   dashboard keep their current look untouched. All motion is
   disabled under prefers-reduced-motion at the end of this block.
   ============================================================ */

/* The Decision Explanation block (gate rows + Decision Engine panel)
   was unconditionally display:none in its base rule with nothing ever
   setting it visible again — both were rendering correctly underneath
   but were completely invisible on the page. Reveal it here. */
#pane-ai-classifier .ai-class-gate {
  display: flex;
}

/* Prediction card and restrained status accents. */
#pane-ai-classifier .ai-prediction-card {
  position: relative;
  /* Deliberately NOT overflow:hidden. This element is a full-width CSS
     Grid item inside .pane-grid (the real scroll container, which has
     overflow-y:auto). Per the grid spec, a grid item's automatic minimum
     size drops to 0 whenever its own overflow is anything but visible -
     so overflow:hidden here let the grid row shrink to fit the viewport
     and silently clipped everything below the fold, with no scrollbar
     ever appearing anywhere (nothing "escaped" this box to be detected
     as overflow by an ancestor). None of the decorations below need
     clipping: they're all inset:0 and self-clip to their own box via
     normal background-image/box painting. */
  background: var(--panel);
}

/* Keep the content above the card's decorative border accents. */
#pane-ai-classifier .ai-prediction-card > .panel-header,
#pane-ai-classifier .ai-prediction-card > .panel-body {
  position: relative;
}

/* Static top rule. The animated scan sweep was decoration that carried no
   information, so it is gone with the rest of the glow. */
#pane-ai-classifier .ai-prediction-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--border-2);
  z-index: 1;
}

#pane-ai-classifier .ai-prediction-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  border: 1px solid var(--accent);
}

#pane-ai-classifier .ai-status-dot {
  position: relative;
}

/* Left/right split: the text summary reads as its own card beside
   the round gauge, instead of blending into the panel background. */
#pane-ai-classifier .ai-prediction-left {
  background: color-mix(in srgb, var(--panel) 82%, var(--control-bg) 18%);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 14px 16px;
}

#pane-ai-classifier .ai-prediction-left > *:last-child {
  margin-bottom: 0;
}

/* .ai-prediction-label-area carries flex:1 from the original horizontal
   layout, where it grew sideways next to the ring. Inside this vertical
   column that same rule grows downward instead, pushing the result rows to
   the bottom of the card and opening a large empty gap in the middle. */
#pane-ai-classifier .ai-prediction-left > .ai-prediction-label-area {
  flex: 0 0 auto;
}

/* Glows removed throughout this pane - flat, clean surfaces only.
   State is carried by colour, weight and layout, never by a halo. */

/* Signature cards keep the inset accent bar (a real state indicator) but
   no outer glow. */
#pane-ai-classifier .ai-signature-card-closest {
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--accent) 70%, transparent);
}

#pane-ai-classifier .ai-signature-card-matched {
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--normal) 64%, transparent);
}

#pane-ai-classifier .ai-gate-accept .ai-gate-fill {
  background: var(--normal-fg);
}

#pane-ai-classifier .ai-engine-bar-fill {
  background: var(--accent);
}

#pane-ai-classifier .ai-engine-bar-fill-warn {
  background: var(--warning);
  box-shadow: none;
}

#pane-ai-classifier .ai-decision-engine {
  border-left-color: var(--ai-accent-2);
}

#pane-ai-classifier .ai-engine-title {
  color: var(--ai-accent-2);
}

/* The decorative pane animations these disabled (scan sweep, icon ring,
   radar ping, spinning bezel) have all been removed outright. The wave
   scope handles prefers-reduced-motion itself, in ai-wave-scope.js. */

@media (max-width: 820px) {
  .appbar {
    height: auto;
    min-height: 42px;
  }

  .appbar-indicators {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  .appbar-cell {
    min-height: 42px;
  }

  #pane-ai-classifier .ai-prediction-main {
    align-items: center;
  }
}

@media (max-width: 560px) {
  .startup-card {
    grid-template-columns: 1fr;
    gap: 12px;
    text-align: left;
  }

  .startup-mark {
    width: 34px;
    height: 34px;
  }

  .ai-intro {
    padding: 0.6rem;
  }

  .ai-intro-sub {
    flex-basis: 100%;
    min-width: 0;
  }

  #pane-ai-classifier .ai-signature-card-main {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  #pane-ai-classifier .ai-signature-meter {
    width: 56px;
    height: 56px;
  }

  #pane-ai-classifier .btn,
  #pane-ai-configuration .btn {
    width: 100%;
    max-width: none;
  }
}

/* ===================== RESPONSIVE HARDENING PASS ===================== */

/* Keep status chips visually stable as text changes between NORMAL / WARNING / OFFLINE. */
.status-pill {
  min-inline-size: 92px;
  max-inline-size: 100%;
  text-align: center;
}

.appbar .badge {
  inline-size: min(118px, 100%);
}

@media (max-width: 1200px) {
  /* Threshold editing is the main workflow here; the bearing helper was too cramped on tablets. */
  .pane-config {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .operations-grid {
    overscroll-behavior: contain;
  }

  .panel-header {
    align-items: stretch;
  }

  .panel-title,
  .panel-meta {
    max-width: 100%;
  }

  .panel-meta {
    text-align: left;
    color: var(--muted-2);
  }

  .metric-status-row {
    grid-template-columns: minmax(0, 1fr) minmax(92px, auto);
    gap: 6px 10px;
  }

  .metric-status-row .status-pill {
    justify-self: end;
  }

  .profile-grid div {
    grid-template-columns: minmax(110px, 0.72fr) minmax(0, 1.28fr);
  }

  /* Text card + round gauge stop fitting side by side on tablet widths -
     stack them so neither one gets squeezed. */
  .ai-prediction-main {
    grid-template-columns: 1fr;
  }

  /* Stacked, the scope would otherwise take a full 520px band and push the
     result text off screen. Cap it so both halves stay readable. */
  #pane-ai-classifier .ai-confidence-ring-wrap {
    max-width: 340px;
  }
}

@media (max-width: 600px) {
  #pane-ai-classifier .ai-confidence-ring-wrap {
    max-width: 260px;
  }
}

@media (max-width: 700px) {
  .appbar-indicators {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .appbar-cell {
    padding-inline: 8px;
  }

  .appbar .badge {
    inline-size: 100%;
    min-inline-size: 0;
  }

  .kpi-strip {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

  .kpi-card {
    min-height: 68px;
    padding: 9px 10px;
  }

  .threshold-stack,
  .threshold-groups,
  .metric-status-grid,
  .system-health-grid,
  .report-status-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .threshold-actions,
  .threshold-save-actions,
  .report-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .threshold-action-block .btn,
  .threshold-save-actions .btn {
    width: 100%;
    max-width: none;
  }

  .ai-model-status-bar {
    gap: 6px 8px;
  }

  .ai-model-sensor {
    flex-basis: 100%;
    margin-left: 0;
  }

  .ai-prediction-main {
    gap: 12px;
  }

  .ai-pred-stable-label {
    white-space: normal;
  }

  .ai-prediction-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .panel-body,
  .chart-panel-body,
  .trend-chart-body,
  .pane-chart-body {
    padding: 9px 10px 10px;
  }

  .panel-header {
    padding: 8px 10px;
  }

  .profile-grid div {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }

  .profile-grid dd {
    text-align: left;
  }

  .indicator-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    overflow-x: hidden;
    gap: 1px;
    font-size: 10.5px;
  }

  .indicator-grid > .indicator-head {
    display: none;
  }

  .indicator-grid > .indicator-metric {
    grid-column: 1 / -1;
    color: var(--muted);
    background: var(--panel-hdr);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .indicator-grid > .indicator-metric-repeat {
    display: none;
  }

  .indicator-grid > .indicator-row-label {
    grid-column: 1 / -1;
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    color: var(--text-strong);
  }

  .indicator-grid > .indicator-metric:nth-child(6n + 9),
  .indicator-grid > .indicator-metric:nth-child(6n + 10),
  .indicator-grid > .indicator-metric:nth-child(6n + 11),
  .indicator-grid > .indicator-metric:nth-child(6n + 12),
  .indicator-grid > div:nth-child(6n + 9),
  .indicator-grid > div:nth-child(6n + 10),
  .indicator-grid > div:nth-child(6n + 11),
  .indicator-grid > div:nth-child(6n + 12) {
    display: grid;
    gap: 2px;
  }

  .indicator-grid > div:nth-child(6n + 9)::before { content: "Moving Avg"; }
  .indicator-grid > div:nth-child(6n + 10)::before { content: "Std Dev"; }
  .indicator-grid > div:nth-child(6n + 11)::before { content: "Peak / Avg"; }
  .indicator-grid > div:nth-child(6n + 12)::before { content: "Spike"; }

  .indicator-grid > div:nth-child(6n + 9)::before,
  .indicator-grid > div:nth-child(6n + 10)::before,
  .indicator-grid > div:nth-child(6n + 11)::before,
  .indicator-grid > div:nth-child(6n + 12)::before {
    color: var(--muted-2);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .ai-intro {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    align-items: start;
  }

  .ai-intro-sub {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .ai-confidence-ring-wrap,
  .ai-confidence-ring {
    width: 60px;
    height: 60px;
  }

  .ai-prediction-meta {
    grid-template-columns: minmax(0, 1fr);
  }

  .ai-decision-line {
    display: grid;
    grid-template-columns: minmax(92px, 0.46fr) minmax(0, 1fr);
    gap: 6px 10px;
  }

  .ai-decision-line span {
    overflow-wrap: normal;
    word-break: normal;
  }

  .ai-decision-line strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@media (prefers-reduced-motion: reduce) {
  .recording-indicator-dot { animation: none !important; }
}

.reading-cell {
  min-width: 150px;
}

.reading-value,
.reading-unavailable,
.reading-detail,
.status-detail {
  display: block;
}

.reading-value {
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-weight: 700;
  white-space: nowrap;
}

.reading-unavailable {
  color: var(--muted-2);
  font-weight: 700;
}

.reading-detail,
.status-detail {
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 9px;
  line-height: 1.35;
}

/* Durable-history controls deliberately use only theme variables so the
   calculator and default palettes remain visually consistent. */
.hourly-history-panel { min-height: min(76vh, 760px); }
.hourly-history-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 10px; }
.hourly-history-toolbar .field { min-width: 190px; }
.history-button-group { display: inline-flex; border: 1px solid var(--line-2); background: var(--control-bg); }
.history-button-group button { border: 0; border-right: 1px solid var(--line-2); background: transparent; color: var(--text); font: 600 11px var(--font-mono); padding: 8px 10px; min-height: 38px; cursor: pointer; }
.history-button-group button:last-child { border-right: 0; }
.history-button-group button:hover, .history-button-group button.active { background: var(--control-active); color: var(--control-active-text); }
.hourly-history-help { color: var(--muted); font-size: 11px; margin: 0 0 12px; line-height: 1.55; }
.box-plot-key { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: -3px 0 12px; color: var(--text); font-size: 10px; }
/* Needed because .box-plot-key is declared after the generic .hidden rule with
   equal specificity, so display:flex would otherwise win and the box-plot key
   would stay visible in points mode - explaining quartiles that are not drawn. */
.box-plot-key.hidden { display: none; }
.box-plot-key span { display: inline-flex; align-items: center; gap: 7px; }
.box-plot-key b { display: inline-block; flex: 0 0 auto; position: relative; width: 18px; height: 12px; color: var(--magnitude); }
.box-key-shape { border: 1px solid currentColor; background: color-mix(in srgb, currentColor 16%, transparent); }
.median-key-shape::before { content: ''; position: absolute; left: 1px; right: 1px; top: 5px; border-top: 2px solid currentColor; }
.whisker-key-shape::before { content: ''; position: absolute; left: 8px; top: 1px; height: 10px; border-left: 1px solid currentColor; }
.whisker-key-shape::after { content: ''; position: absolute; left: 4px; top: 1px; width: 9px; height: 8px; border-top: 1px solid currentColor; border-bottom: 1px solid currentColor; }
.point-key-shape::before { content: ''; position: absolute; width: 7px; height: 7px; left: 6px; top: 3px; border-radius: 50%; background: currentColor; }
.hourly-history-explainer { margin: 0 0 12px; border: 1px solid var(--line); background: var(--panel); }
.hourly-history-explainer > summary { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 12px; color: var(--text-strong); cursor: pointer; font-size: 11px; font-weight: 700; line-height: 1.35; list-style: none; }
.hourly-history-explainer > summary::-webkit-details-marker { display: none; }
.hourly-history-explainer:not([open]) > :not(summary) { display: none; }
.boxplot-anatomy { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; align-items: center; padding: 14px 16px 4px; border-top: 1px solid var(--line); }
.boxplot-anatomy-figure { position: relative; width: 110px; height: 190px; margin: 0 auto; color: var(--magnitude); }
.anatomy-whisker { position: absolute; left: 50%; width: 2px; transform: translateX(-50%); background: currentColor; }
.anatomy-whisker-top { top: 18px; height: 48px; }
.anatomy-whisker-bottom { top: 124px; height: 48px; }
.anatomy-cap { position: absolute; left: 35px; width: 40px; height: 2px; background: currentColor; }
.anatomy-cap-top { top: 18px; }
.anatomy-cap-bottom { top: 172px; }
.anatomy-box { position: absolute; left: 20px; top: 66px; width: 70px; height: 59px; border: 2px solid currentColor; background: color-mix(in srgb, currentColor 18%, transparent); }
.anatomy-median { position: absolute; left: 20px; top: 94px; width: 70px; height: 3px; background: var(--text-strong); }
.anatomy-orientation { position: absolute; left: 0; color: var(--muted-2); font-size: 7px; white-space: nowrap; }
.anatomy-orientation-high { top: 0; }
.anatomy-orientation-low { bottom: 0; }
.boxplot-anatomy-list { display: grid; gap: 7px; margin: 0; min-width: 0; }
.boxplot-anatomy-list > div { min-width: 0; }
.boxplot-anatomy-list dt { display: flex; align-items: center; gap: 7px; color: var(--text-strong); font-size: 10px; font-weight: 700; }
.boxplot-anatomy-list dd { margin: 2px 0 0 20px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.anatomy-swatch { display: inline-block; position: relative; flex: 0 0 14px; width: 14px; height: 10px; color: var(--magnitude); }
.anatomy-swatch-min::before, .anatomy-swatch-max::before { content: ''; position: absolute; left: 6px; top: 0; width: 2px; height: 10px; background: currentColor; }
.anatomy-swatch-min::after, .anatomy-swatch-max::after { content: ''; position: absolute; left: 2px; width: 10px; height: 2px; background: currentColor; }
.anatomy-swatch-min::after { top: 8px; }
.anatomy-swatch-max::after { top: 0; }
.anatomy-swatch-q1, .anatomy-swatch-q3 { border: 1px solid currentColor; background: color-mix(in srgb, currentColor 18%, transparent); }
.anatomy-swatch-median::before { content: ''; position: absolute; left: 0; right: 0; top: 4px; height: 2px; background: var(--text-strong); }
.hourly-history-explainer-note { margin: 0; padding: 4px 16px 14px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.hourly-history-chart-wrap { width: 100%; max-width: 100%; min-width: 0; height: min(62vh, 560px); min-height: 320px; position: relative; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); }
.hourly-history-chart-wrap canvas { touch-action: none; cursor: grab; }

.hourly-history-chart-wrap canvas:active { cursor: grabbing; }

/* Trends page charts carry the same custom Y-axis pinch/wheel zoom and
   drag-to-pan gestures as the 6-Month History chart above, so they need the
   same `touch-action: none`. Without it the browser claims a two-finger
   vertical gesture for its own page scroll/zoom and fires pointercancel
   part-way through, which silently kills the pinch after a few frames (the
   handler simply stops receiving pointermove events). `ns-resize` advertises
   that these charts move vertically; the JS swaps in `grabbing` mid-drag. */
.trend-chart-wrap canvas { touch-action: none; cursor: grab; }

.trend-chart-wrap canvas:active { cursor: grabbing; }
@media (max-width: 720px) {
  .hourly-history-chart-wrap { min-height: 280px; height: 52vh; }
  .hourly-history-toolbar .field { width: 100%; }
  /* Every ancestor of this toolbar clips horizontal overflow (see .tab-pane,
     .operations-grid) and none of them re-opens scrolling for it, so a
     non-wrapping button group wider than the panel - the 5-button Zoom
     controls group is the tallest risk - is silently cut off with no way to
     reach the hidden buttons (Reset among them) on a phone-width screen.
     Let each group wrap onto its own rows instead, mirroring the same fix
     already used for .panel-toolbar/.fft-band-presets/.segmented above. */
  .history-button-group { width: 100%; flex-wrap: wrap; }
  .history-button-group button { flex: 1 1 auto; min-width: 64px; }
  .boxplot-anatomy { grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding-inline: 10px; }
  .boxplot-anatomy-figure { transform: scale(.82); transform-origin: center; }
  .hourly-history-explainer-note { padding-inline: 10px; }
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-SemiBold.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

/* ============================================================
   Fleet table on tablets (601px - 1024px).

   The asset table (now 5 columns) sets min-width: 700px, so inside
   .table-shell (overflow-x: auto) every tablet had to be scrolled sideways to
   read Severity or Recording. The card layout that already exists for phones
   was only applied at <= 600px, leaving the entire tablet range - which is the
   plant engineer's most likely device - with the worst of both: too narrow for
   the table, too wide to get the cards.

   These are the same declarations as the <= 600px block, promoted to cover
   tablets too. Desktop (>= 1025px) keeps the real table, where the table fits.
   ============================================================ */
@media (min-width: 601px) and (max-width: 1024px) {
  .table-shell {
    overflow-x: visible;
    border: 0;
  }

  .asset-table,
  .asset-table tbody,
  .asset-table tr,
  .asset-table td {
    display: block;
    width: 100%;
  }

  .asset-table {
    min-width: 0;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
  }

  .asset-table thead {
    display: none;
  }

  .asset-table tr.asset-row {
    margin: 0 0 8px;
    border: 1px solid var(--line);
    background: var(--panel);
  }


  .asset-table td {
    display: grid;
    /* Wider label column than on phones: tablets have the room, and it keeps
       the label/value pairs on a single readable baseline. */
    grid-template-columns: minmax(120px, 0.28fr) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }

  .asset-table td:last-child {
    border-bottom: 0;
  }

  .asset-table td::before {
    content: attr(data-label);
    color: var(--muted-2);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .asset-table .col-num {
    text-align: left;
  }

  .asset-table .empty-cell {
    display: block;
    padding: 14px 10px;
  }

  .asset-table .empty-cell::before {
    content: none;
  }
}

/* ============================================================
   Touch targets on phones and tablets (<= 1024px).

   The Trend Analysis chart controls were laid out for a mouse and kept those
   dimensions on touch devices: segmented buttons 28px tall, the Y-range and
   X-window number inputs 21px, moving-average selects 30px. A machine sweep of
   every pane at six viewports found ~30 distinct controls under 32px, all of
   them on the page an engineer actually drives from a tablet at the machine.

   Sized to 38px, which clears the 32px audit threshold with margin while
   staying well below the row heights, so no toolbar re-wraps. Applied only at
   touch widths - the desktop layout is unchanged.
   ============================================================ */
@media (max-width: 1024px) {
  .seg-btn,
  .x-window-presets .seg-btn,
  .fft-band-presets .seg-btn {
    min-height: 38px;
    padding-block: 6px;
  }

  .chart-ma-control .mini-select,
  .mini-select {
    height: 38px;
    min-height: 38px;
  }

  .y-range-input,
  .x-window-field input,
  .chart-controls input[type="number"],
  .chart-controls input[type="text"] {
    min-height: 38px;
    padding-block: 6px;
  }

  /* Five columns on a phone: tighter padding and a lighter heading style so
     they fit side by side. */
  .frequency-summary-table th,
  .frequency-summary-table td {
    padding: 7px 5px;
    font-size: 11px;
  }

  .frequency-summary-table th {
    font-size: 9px;
    letter-spacing: 0.04em;
  }
}

/* Base control sizing on touch devices.

   The rules above fixed the Trend Analysis toolbar specifically, but the sweep
   then showed the same problem app-wide: bare selects at 31px, text/number
   inputs at 31px (21px for the unstyled X-window boxes), <summary> disclosure
   toggles at 24px, buttons at 30px. Rather than chase individual ids, size the
   controls themselves - one rule, every pane, and new controls inherit it.
   Checkboxes stay smaller by nature; their label is the real hit area. */
@media (max-width: 1024px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]),
  select,
  textarea,
  button,
  .btn {
    min-height: 38px;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]),
  textarea {
    /* Dashboard control scale: deliberately small and identical to the
       dropdowns. Overrides the browser/iOS default sizing. */
    font-size: 12px;
  }

  select {
    font-size: 12px;
  }

  summary {
    min-height: 38px;
    display: flex;
    align-items: center;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
  }

  /* A checkbox stays visually small, so the wrapping <label> has to carry the
     tap area - it is what a finger actually hits. Without this the alarm
     toggles were 20px targets on a phone. */
  label.threshold-toggle,
  label:has(> input[type="checkbox"]),
  label:has(> input[type="radio"]) {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
  }
}

/* The X Window / Y-range toolbar rows on Trend Analysis put a required-16px
   number input (see the iOS zoom rule above - it cannot go smaller) directly
   beside labels and segmented buttons still on the 9-11px control scale. Both
   sides already share the same 38px touch height, so the boxes line up, but
   the text inside them does not: the input reads roughly twice the size of
   its own row. Nudging just this row's neighbours up narrows that gap without
   touching font-size on any actual input (the 16px protection stays exactly
   as it is) and without changing every other 9-11px control on the page. */
@media (max-width: 1024px) {
  .chart-control-inline span,
  .fft-band-sep {
    font-size: 11px;
  }

  .x-window-presets .seg-btn,
  .chart-control-inline select,
  .y-pan-btn {
    font-size: 12px;
  }
}

/* The fleet remains card-based on phones/tablets, while its real table header
   becomes a compact horizontal sort strip. Kept at the end of the responsive
   cascade so older card-layout rules cannot hide it. */
@media (max-width: 1024px) {
  .asset-table thead {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    overflow-x: auto;
    border: 1px solid var(--line);
    scrollbar-width: thin;
  }

  .asset-table thead tr {
    display: flex;
    width: max-content;
    min-width: 100%;
  }

  .asset-table thead th.sortable-header {
    display: block;
    flex: 0 0 auto;
    min-height: 38px;
    padding: 10px 12px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    touch-action: manipulation;
  }

  .asset-table thead th.sortable-header:last-child { border-right: 0; }
}
[data-admin-only] {
  display: none !important;
}

body.admin-authenticated [data-admin-only] {
  display: revert !important;
}

/* Restoring an admin-only anchor with `display: revert` gives it the browser's
   inline display, which breaks the icon/label flex row. Keep admin navigation
   identical to every other sidebar item at every responsive breakpoint. */
body.admin-authenticated .nav-item[data-admin-only] {
  display: flex !important;
  flex-direction: row;
  align-items: center;
}

.admin-access-section {
  margin-top: auto;
  padding-top: 1rem;
}

.fleet-delete-btn {
  border: 1px solid var(--danger, #d45b5b);
  background: transparent;
  color: var(--danger, #d45b5b);
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  cursor: pointer;
  border-radius: 3px;
  vertical-align: middle;
}

.fleet-admin-cell {
  width: 44px;
  min-width: 44px;
  padding-top: 4px !important;
  padding-bottom: 4px !important;
  text-align: center;
}

.fleet-delete-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fleet-delete-btn:hover,
.fleet-delete-btn:focus-visible {
  background: color-mix(in srgb, var(--danger, #d45b5b) 14%, transparent);
}

.fleet-delete-btn:disabled {
  cursor: not-allowed;
  opacity: .38;
}

.fleet-delete-btn.is-deleting .fleet-delete-icon {
  animation: fleet-delete-pulse .75s ease-in-out infinite alternate;
}

@keyframes fleet-delete-pulse {
  to { opacity: .25; }
}

/* ============================================================
   LAYOUT AUDIT FIXES (2026-10-26)
   Kept at the end of the cascade on purpose: earlier responsive blocks set
   fixed chart heights and stack every control on its own row, which left
   phone plots with ~120px of drawing area. Aerospace-console look unchanged.
   ============================================================ */

/* --- Touch targets: pan arrows and chart presets were 26x38px. */
@media (pointer: coarse) {
  .y-pan-btn { min-width: 40px; min-height: 40px; }
  .x-window-presets .seg-btn,
  .segmented .seg-btn { min-height: 40px; }
}

/* --- Tablet and phone: charts get a viewport-relative height so the plot,
   not the chrome around it, takes the space. */
@media (max-width: 1024px) {
  .trend-chart-wrap,
  .chart-wrap.trend-chart-wrap { height: clamp(300px, 46dvh, 460px); }
  .trend-chart-body { padding: 6px; }
  .y-minmax-row:has(.y-range-input:disabled) { display: none; }
}

/* --- Phones. */
@media (max-width: 600px) {
  .trend-chart-wrap,
  .chart-wrap.trend-chart-wrap { height: clamp(300px, 54dvh, 460px); }
  .trend-chart-body { padding: 4px; }
  .trend-subpanel .panel-body { padding: 4px; }

  /* Trend controls: a compact two-column board instead of one control per row.
     Each control keeps its small caption above it, console style. */
  .trend-subpanel .panel-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: end;
  }
  .trend-subpanel .panel-toolbar > * { min-width: 0; width: 100%; }
  .trend-subpanel .panel-toolbar .x-window-presets,
  .trend-subpanel .panel-toolbar .chart-ma-control,
  .trend-subpanel .panel-toolbar .y-minmax-row { grid-column: 1 / -1; }
  .trend-subpanel .panel-toolbar .x-window-field { grid-column: 1 / -1; }
  .trend-subpanel .panel-toolbar .chart-ma-control { order: 3; }
  .trend-subpanel .panel-toolbar .y-minmax-row { order: 4; }
  .trend-subpanel .x-window-field { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
  .trend-subpanel .x-window-field input { width: 100%; min-width: 0; height: 36px; font-size: 13px; }
  .trend-subpanel .x-window-presets { display: grid; grid-template-columns: repeat(4, 1fr); }
  .trend-subpanel .chart-control-inline:not(.x-window-field):not(.y-minmax-row) {
    display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  }
  .trend-subpanel .chart-control-inline .segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .trend-subpanel .chart-ma-control { flex-direction: row !important; align-items: center !important; justify-content: space-between; }
  .trend-subpanel .chart-ma-control .mini-select { width: 55%; height: 36px; }
  .trend-subpanel .y-minmax-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) 40px 40px; align-items: center; gap: 6px; }
  .trend-subpanel .y-minmax-row:has(.y-range-input:disabled) { display: none; }

  .hourly-history-chart-wrap { height: clamp(320px, 58dvh, 520px); min-height: 300px; }

  /* Long panel titles beside a meta line collided at 360-390px. */
  /* Earlier phone rules stack the header in a column; never let that column wrap
     sideways (it pushed the meta line off the right edge). */
  .panel-header { flex-wrap: nowrap; }
  .panel-header .panel-meta { text-align: left; }

  /* Selects that kept intrinsic width inside the recorder steps. */
  .report-recorder select,
  .report-recorder .mini-select { width: 100%; }
}

/* --- Landscape phones: viewport is short, so fill height with the plot. */
@media (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .trend-chart-wrap,
  .chart-wrap.trend-chart-wrap { height: max(240px, 78dvh); }
  .hourly-history-chart-wrap { height: max(240px, 74dvh); min-height: 240px; }
}

/* Small laptops: the sidebar label "Pattern Recognizer" was ellipsised. */
@media (min-width: 1025px) and (max-width: 1200px) {
  .nav-item-label { letter-spacing: 0; font-size: 11.5px; }
}

/* 6-Month History controls on phones: Metric full width, Resolution and
   Value scale side by side, so the plot is not pushed below the fold. */
@media (max-width: 600px) {
  .hourly-history-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: end; }
  .hourly-history-toolbar > * { min-width: 0; width: 100%; }
  .hourly-history-toolbar > .field:first-child,
  .hourly-history-toolbar > :not(.field) { grid-column: 1 / -1; }
  .hourly-history-toolbar .field { min-width: 0; }
  .hourly-history-toolbar .field select { font-size: 11px; padding-left: 8px; padding-right: 22px; text-overflow: ellipsis; }
}

/* ============================================================
   VERSION PANEL (sidebar header)
   Owner (optional) on top, then a labelled version tag, with a live
   connection indicator on the right that follows the real server state.
   ============================================================ */
.brand-block {
  align-items: center;
}
.brand-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-meta-label {
  color: var(--muted-2);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.brand-version {
  padding: 2px 6px;
  border: 1px solid var(--line-2);
  background: var(--control-bg);
  color: var(--text-strong);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: none;
}
.brand-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid var(--line);
  background: var(--panel-hdr);
}
.brand-status-text {
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.brand-status-dot { margin-top: 0; background: var(--muted-2); box-shadow: none; animation: none; }
.brand-status-dot.is-normal  { background: var(--normal);   box-shadow: 0 0 6px color-mix(in srgb, var(--normal) 70%, transparent); animation: sidebar-pulse 2.8s ease-in-out infinite; }
.brand-status-dot.is-warning { background: var(--warning);  box-shadow: 0 0 6px color-mix(in srgb, var(--warning) 70%, transparent); }
.brand-status-dot.is-danger  { background: var(--critical); box-shadow: 0 0 6px color-mix(in srgb, var(--critical) 70%, transparent); }
.brand-status:has(.is-normal)  .brand-status-text { color: var(--normal-fg); }
.brand-status:has(.is-warning) .brand-status-text { color: var(--warning-fg); }
.brand-status:has(.is-danger)  .brand-status-text { color: var(--critical-fg); }

/* Sensor list: name with its ID underneath, five clear columns. */
.asset-table td.asset-name { white-space: nowrap; }
.sensor-name { display: block; color: var(--text-strong); font-weight: 600; }
.sensor-id   { display: block; margin-top: 2px; color: var(--muted-2); font-size: 10px; }

/* Narrow desktop sidebar (180-192px): keep the version tag readable by showing
   only the status dot; the colour and tooltip still carry the state. */
@media (min-width: 901px) and (max-width: 1200px) {
  .brand-status-text { display: none; }
  .brand-status { padding: 4px 6px; }
}

/* ---- CONTROL FONT OVERRIDE ----
   One small font size for every text box, search box and dropdown at all
   viewport widths, regardless of browser defaults. */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]),
select,
select option,
select optgroup,
textarea {
  font-size: 12px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ---- ADMIN THEME PICKER ---- */
.theme-help { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr)); gap: 8px; margin-bottom: 14px; }
.theme-swatch {
  display: flex; flex-direction: column; gap: 6px; align-items: stretch; padding: 8px;
  background: var(--control-bg); color: var(--text); border: 1px solid var(--line-2);
  border-radius: 3px; font: inherit; font-size: 11px; text-align: left; cursor: pointer;
}
.theme-swatch:hover { background: var(--control-hover); }
.theme-swatch[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-swatch { display: grid; grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; column-gap: 6px; border-radius: 1px; }
.theme-sample { grid-column: 1 / -1; display: block; padding: 6px; border: 1px solid var(--line); border-radius: 1px; }
.theme-sample-panel { display: grid; gap: 5px; padding: 6px 7px 7px; border: 1px solid; border-radius: 1px; }
.theme-sample-rule { display: block; height: 2px; width: 42%; }
.theme-sample-text { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; line-height: 1; }
.theme-sample-lines { display: grid; gap: 3px; }
.theme-sample-lines i { display: block; height: 2px; }
.theme-sample-lines i:nth-child(1) { width: 92%; }
.theme-sample-lines i:nth-child(2) { width: 70%; }
.theme-sample-lines i:nth-child(3) { width: 82%; }
.theme-name { align-self: center; color: var(--text-strong); font-weight: 600; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.theme-mode { align-self: center; color: var(--muted); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.theme-custom { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.theme-custom input[type="color"] { width: 56px; height: 32px; padding: 2px; background: var(--input-bg); border: 1px solid var(--line-2); border-radius: 3px; }
.theme-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-preview-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9999; display: flex; flex-wrap: wrap;
  gap: 8px; align-items: center; justify-content: center; padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--panel-hdr); color: var(--text-strong); border-top: 2px solid var(--accent);
  font-size: 12px;
}
.theme-preview-text { flex: 1 1 220px; min-width: 0; }
body.theme-testing { padding-bottom: 64px; }
.pane-config .theme-panel, .pane-config #displayPanel { grid-column: 1 / -1; }

/* ============================================================
   MOBILE UX REDESIGN (phones, <= 600px)
   Principles: one finger always scrolls the page; controls are compact
   (32px segmented/inputs, like UISegmentedControl) instead of 38-40px
   slabs; the chart, not its toolbar, owns the screen; the sensor list is a
   two-line card, not a five-row form.
   ============================================================ */

/* Touch: a single finger must scroll the page even when it lands on a chart.
   Vertical movement belongs to the browser; horizontal drag/pinch still
   reaches the chart's own handlers. Mouse behaviour is unchanged. */
@media (pointer: coarse) {
  .trend-chart-wrap canvas,
  .hourly-history-chart-wrap canvas { touch-action: pan-y; }
}

@media (max-width: 600px) {
  /* ---- Compact control scale ---- */
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]),
  select, textarea, button, .btn { min-height: 32px; }
  .btn { padding-top: 6px; padding-bottom: 6px; }
  .x-window-presets .seg-btn,
  .segmented .seg-btn { min-height: 30px; padding: 0 6px; font-size: 11px; }
  .y-pan-btn { min-width: 32px; min-height: 30px; }
  .trend-subpanel .x-window-field input { height: 30px; }
  .trend-subpanel .chart-ma-control .mini-select { height: 30px; }
  .panel-header { padding-top: 8px; padding-bottom: 8px; }

  /* Long unit legend under the page title is noise on a phone. */
  #trendUnitLabel { display: none; }
  .trend-toolbar { padding-top: 4px; padding-bottom: 4px; }

  /* ---- Trend controls: three tight rows instead of five loose ones ----
       row 1: time window presets
       row 2: Scale | Y-range
       row 3: Moving avg | X window */
  .trend-subpanel .panel-toolbar { gap: 6px; padding: 6px; }
  .trend-subpanel .panel-toolbar > :nth-child(2) { order: 1; grid-column: 1 / -1; }
  .trend-subpanel .panel-toolbar > :nth-child(3) { order: 2; grid-column: auto; }
  .trend-subpanel .panel-toolbar > :nth-child(5) { order: 3; grid-column: auto; }
  .trend-subpanel .panel-toolbar > :nth-child(4) { order: 4; grid-column: auto; }
  .trend-subpanel .panel-toolbar > :nth-child(1) { order: 5; grid-column: auto; }
  .trend-subpanel .panel-toolbar > :nth-child(6) { order: 6; grid-column: 1 / -1; }
  .trend-subpanel .chart-control-inline:not(.x-window-field):not(.y-minmax-row):not(.chart-ma-control) {
    flex-direction: row; align-items: center; gap: 6px;
  }
  .trend-subpanel .chart-control-inline > span { font-size: 9px; letter-spacing: 0.06em; flex: 0 0 auto; }
  .trend-subpanel .chart-control-inline .segmented { flex: 1 1 auto; min-width: 0; }
  .trend-subpanel .chart-ma-control { gap: 6px; }
  .trend-subpanel .chart-ma-control .mini-select { width: auto; flex: 1 1 auto; min-width: 0; }
  .trend-subpanel .x-window-field { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; }

  .trend-chart-wrap,
  .chart-wrap.trend-chart-wrap { height: clamp(260px, 42dvh, 380px); }

  /* ---- Sensor list: two-line cards ---- */
  .asset-table tr.asset-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name sev" "read stat" "seen seen";
    column-gap: 10px; row-gap: 2px;
    padding: 10px 12px; margin-bottom: 8px;
    border-radius: 3px;
  }
  .asset-table tr.asset-row > td {
    display: block; width: auto; padding: 0; border: 0; min-width: 0;
  }
  .asset-table tr.asset-row > td::before { content: none; }
  .asset-table tr.asset-row > td:nth-child(1) { grid-area: name; font-size: 14px; font-weight: 700; }
  .asset-table tr.asset-row > td:nth-child(4) { grid-area: sev; justify-self: end; }
  .asset-table tr.asset-row > td:nth-child(3) { grid-area: read; align-self: end; }
  .asset-table tr.asset-row > td:nth-child(2) { grid-area: stat; justify-self: end; align-self: end; }
  .asset-table tr.asset-row > td:nth-child(5) { grid-area: seen; color: var(--muted); font-size: 11px; }
  .asset-table tr.asset-row > td:nth-child(6) { grid-area: seen; justify-self: end; }
  .asset-table tr.asset-row .status-pill { min-height: 0; padding: 3px 8px; font-size: 10px; white-space: nowrap; }
  .asset-table tr.asset-row .reading-value { font-size: 13px; }
  .asset-table tr.asset-row .reading-detail,
  .asset-table tr.asset-row .status-detail { font-size: 10px; }
  .asset-table td.asset-name { white-space: normal; overflow-wrap: anywhere; }

  /* ---- 6-Month History: controls first, explanations on demand ---- */
  .hourly-history-help,
  .box-plot-key { display: none; }
  .hourly-history-toolbar { gap: 6px; }
  .history-button-group button { min-height: 30px; padding: 0 8px; font-size: 11px; }
  .hourly-history-chart-wrap { height: clamp(260px, 46dvh, 420px); min-height: 240px; }

  /* Search/page-size boxes on the fleet and logs pages. */
  #deviceSearchInput, #devicePageSize, #systemLogSearch { min-height: 34px; }
}

@media (max-width: 600px) {
  /* Search and page size share one row. */
  .fleet-search-row { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 6px; align-items: center; }
  .fleet-search-row > * { min-width: 0; width: 100%; }
  .fleet-search-row .fleet-page-size { padding-left: 8px; }
}

/* ---- CHART EXPLORE MODE (touch) ----
   Default: one finger scrolls the page (canvas touch-action: pan-y, above).
   Explore on: the chart takes every touch and the page cannot scroll or
   rubber-band while it is held. */
.chart-explore-btn, .chart-explore-hint { display: none; }
@media (pointer: coarse) {
  .trend-chart-wrap, .hourly-history-chart-wrap { position: relative; }
  /* The Explore button gets its own strip under the chart so it never covers the time axis labels.
     Chart.js sizes the canvas to the content box, so the padding is simply left free. */
  .hourly-history-chart-wrap { box-sizing: border-box; padding-bottom: 42px; }
  .trend-chart-wrap canvas, .hourly-history-chart-wrap canvas {
    -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  }
  .chart-explore-btn {
    display: block; position: absolute; bottom: 7px; right: 8px; z-index: 5;
    min-height: 28px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 3px;
    background: var(--control-bg); color: var(--text-strong); font: inherit; font-size: 11px;
    letter-spacing: 0.04em; touch-action: manipulation;
  }
  .chart-explore { outline: 2px solid var(--accent); outline-offset: -2px; }
  .chart-explore .chart-explore-btn { background: var(--control-active); color: var(--control-active-text); border-color: var(--control-active); }
  .chart-explore canvas { touch-action: none; }
  .chart-explore .chart-explore-hint {
    display: block; position: absolute; left: 8px; right: 8px; top: 30px; z-index: 4; padding: 3px 8px;
    border-radius: 3px; background: var(--panel-hdr); color: var(--muted); font-size: 10px; text-align: center;
    pointer-events: none; animation: chart-hint-fade 4s ease forwards;
  }
  body.chart-exploring, body.chart-exploring .tab-pane { overscroll-behavior: none; }
}
@keyframes chart-hint-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ---- FINAL UX AUDIT ---- */
/* Which sensor am I looking at? Shown on every per-sensor page. */

/* Keyboard users always see where focus is (WCAG 2.4.7). :where() keeps the
   specificity low so any component's own focus style still wins. */
:where(a, button, select, input, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   SENSOR CARDS (optional alternative to the table)
   Layout follows the Magazoo admin cards: responsive grid, a small
   status line on top, bold title with its ID beneath, the key figure,
   then a hairline-separated action row. Console styling: square
   corners, hairline borders, severity colour on the top edge.
   ============================================================ */
.fleet-view-toggle { align-self: stretch; }
.fleet-view-toggle .seg-btn { min-width: 64px; }
.fleet-search-row { grid-template-columns: minmax(220px, 1fr) 140px auto; }

.fleet-cards-wrap { display: none; }
.asset-inventory[data-fleet-view="cards"] .fleet-cards-wrap { display: block; }
.asset-inventory[data-fleet-view="cards"] .table-shell { display: none; }

.fleet-cards-toolbar {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
  color: var(--muted); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
}
.fleet-cards-toolbar label { flex: none; white-space: nowrap; }
.fleet-cards-toolbar .mini-select { flex: 0 1 220px; width: auto; min-width: 140px; height: 34px; }
.fleet-sort-dir { flex: none; width: 34px; height: 34px; min-width: 34px; padding: 0; border: 1px solid var(--line-2); }
@media (max-width: 600px) { .fleet-cards-toolbar .mini-select { flex: 1 1 auto; } }

.fleet-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
  gap: 12px; list-style: none; margin: 0; padding: 0;
}
.fleet-cards-empty {
  grid-column: 1 / -1; padding: 22px 12px; text-align: center; font-style: italic; color: var(--muted);
  border: 1px solid var(--line); background: var(--panel-2);
}
.fleet-card {
  --tone: var(--muted-2);
  display: flex; flex-direction: column; min-width: 0; padding: 0; overflow: hidden; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 0;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.fleet-card[data-sev="normal"]  { --tone: var(--normal); }
.fleet-card[data-sev="warning"] { --tone: var(--warning); }
.fleet-card[data-sev="danger"]  { --tone: var(--critical); }
.fleet-card:hover { border-color: var(--muted-2); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
.fleet-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fleet-card[data-online="0"] .fleet-card-body { opacity: 0.78; }
.fleet-card-body { display: flex; flex: 1; flex-direction: column; min-width: 0; padding: 12px 12px 0; }
.fleet-card-title {
  display: flex; align-items: center; margin: 0 0 12px; min-width: 0;
  font-size: 15px; font-weight: 700; line-height: 1.35; letter-spacing: 0;
}
.fleet-card-select {
  min-width: 0; padding: 0; border: 0; background: none; color: var(--text-strong);
  font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.fleet-card-id { margin: 0 0 12px; color: var(--muted-2); font-size: 10px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fleet-card-reading { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.fleet-card-value { color: var(--text-strong); font-size: 24px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.fleet-card-unavailable { color: var(--muted); font-size: 14px; font-weight: 600; line-height: 1.3; }
.fleet-card-sub { color: var(--muted-2); font-size: 10px; line-height: 1.4; }
.fleet-card-detail { margin: 0 0 8px; color: var(--warning-fg); font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }

.fleet-card-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; padding-bottom: 10px;
  color: var(--muted-2); font-size: 10px;
}
.fleet-card-state {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; background: none; border: 0; padding: 0;
  color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fleet-card-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.fleet-card-state.pill-normal .fleet-card-dot  { background: var(--normal); }
.fleet-card-state.pill-warning .fleet-card-dot { background: var(--warning); }
.fleet-card-state.pill-danger .fleet-card-dot  { background: var(--critical); }
.fleet-card-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-top: 1px solid var(--line); padding: 4px 0;
}
.fleet-card-actions > div { display: flex; gap: 16px; }
.fleet-card-link {
  min-height: 32px; padding: 0; border: 0; background: none; color: var(--accent);
  font: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
}
.fleet-card-link:hover { color: var(--text-strong); }
.fleet-card-actions .fleet-delete-btn { margin: 0; }
.fleet-card .fleet-recording-state { flex: none; }

@media (max-width: 600px) {
  .fleet-search-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .fleet-search-row .fleet-search-input { grid-column: 1 / -1; }
  .fleet-view-toggle { display: flex; }
  .fleet-view-toggle .seg-btn { flex: 1 1 0; min-height: 34px; }
  .fleet-cards { grid-template-columns: 1fr; gap: 10px; }
  .fleet-card-value { font-size: 22px; }
}

/* ============================================================
   SENSOR TABLE - desktop refinement
   Severity edge on every row, status as dot + word, and the reading
   cell carries the admin-chosen readings with minimal trend lines (same as the cards). The <= 1024px stacked layout keeps the plain rows.
   ============================================================ */
@media (min-width: 1025px) {
  .asset-table { min-width: 860px; }
  .asset-table th { padding: 10px 14px; }
  .asset-table td { padding: 12px 14px; }
  .asset-row { --tone: var(--muted-2); box-shadow: inset 3px 0 0 var(--tone); transition: background 0.15s; }
  .asset-row[data-sev="normal"]  { --tone: var(--normal); }
  .asset-row[data-sev="warning"] { --tone: var(--warning); }
  .asset-row[data-sev="danger"]  { --tone: var(--critical); }
  .asset-row.active { box-shadow: inset 3px 0 0 var(--tone), inset 0 0 0 1px var(--accent); }
  .asset-row.active .sensor-name { color: var(--accent); }
  .asset-table .sensor-name { font-size: 13px; }
  .asset-table .sensor-id { font-size: 10px; letter-spacing: 0.02em; }

}


/* Cards have no picture header: severity shows as a coloured top edge and a pill in the label row. */
.fleet-card { border-top: 3px solid var(--tone); }

.display-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 8px; margin: 0 0 14px; }
.display-option {
  display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 12px;
  padding: 12px 14px; cursor: pointer; background: var(--panel-2); border: 1px solid var(--line-2);
  transition: border-color 0.12s, background 0.12s;
}
.display-option:hover { border-color: var(--muted-2); }
.display-option:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); }
.display-option:has(input:focus-visible) { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 32%, transparent); }
.display-option.is-disabled { opacity: 0.5; cursor: not-allowed; }
/* The global input rule makes every input full-width with no native look, so the
   checkbox is drawn explicitly (same square tick as the pattern-setup checkboxes). */
.display-option input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; position: relative; width: 18px; height: 18px; min-width: 18px;
  margin: 1px 0 0; padding: 0; border: 1.5px solid var(--line-2); border-radius: 0; background: var(--input-bg);
  box-shadow: none; cursor: inherit;
}
.display-option input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.display-option input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
  border: solid var(--control-active-text); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.display-option input[type="checkbox"]:focus { box-shadow: none; }
.display-option strong { display: block; color: var(--text-strong); font-size: 12px; line-height: 1.35; }
.display-option small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.display-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.display-count { color: var(--muted); font-size: 11px; }

/* ============================================================
   SENSOR READINGS - label, value and a Task-Manager-style graph window
   (admin chooses 1-4 quantities; see display-admin.js)
   ============================================================ */
.fleet-readings { display: grid; gap: 10px 22px; min-width: 0; }
.fleet-reading {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto; column-gap: 12px; align-items: center; min-width: 0;
}
.fleet-reading-label { grid-column: 1; grid-row: 1; color: var(--muted-2); font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fleet-reading-value { grid-column: 1; grid-row: 2; color: var(--text-strong); font-size: 14px; font-weight: 700; line-height: 1.35; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The graph window: framed box, faint grid, filled trend, dashed warning
   (amber) and critical (red) levels, tinted by the current level. */
.fleet-mini {
  --graph: var(--normal);
  grid-column: 2; grid-row: 1 / span 3; align-self: center; position: relative; display: block; width: 92px; height: 38px; overflow: hidden;
  background: color-mix(in srgb, var(--graph) 6%, var(--bg, #0b1017));
  border: 1px solid color-mix(in srgb, var(--graph) 55%, var(--line-2));
}
.fleet-mini.is-warn { --graph: var(--warning); }
.fleet-mini.is-crit { --graph: var(--critical); }
.fleet-mini svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fleet-mini .line { fill: none; stroke: var(--graph); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.fleet-mini .area { fill: var(--graph); opacity: 0.26; stroke: none; }
.fleet-mini .lvl-warn, .fleet-mini .lvl-crit { fill: none; stroke-width: 1; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
.fleet-mini .lvl-warn { stroke: var(--warning); }
.fleet-mini .lvl-crit { stroke: var(--critical); }
.fleet-mini.is-empty { opacity: 0.5; background: color-mix(in srgb, var(--muted-2) 8%, var(--bg, #0b1017)); border-color: var(--line-2); }

/* Table: each reading is ONE tight group - label and number with its own graph
   right beside them - and readings are clearly separated, so a graph can never
   be mistaken for its neighbour's. */
.asset-table .fleet-reading { grid-template-columns: auto auto; justify-content: start; column-gap: 12px; }
.asset-table .fleet-reading-value { min-width: 78px; }
@media (min-width: 1025px) {
  .reading-cell .fleet-readings[data-count="2"], .reading-cell .fleet-readings[data-count="3"], .reading-cell .fleet-readings[data-count="4"] { grid-template-columns: repeat(2, max-content); column-gap: 0; }
  .reading-cell .fleet-readings[data-count="2"] .fleet-reading + .fleet-reading,
  .reading-cell .fleet-readings[data-count="3"] .fleet-reading:nth-child(even),
  .reading-cell .fleet-readings[data-count="4"] .fleet-reading:nth-child(even) { margin-left: 24px; padding-left: 24px; border-left: 1px solid var(--line-2); }
  .asset-table td.reading-cell { min-width: 220px; }
}
/* Table (tablet/phone, stacked rows): readings sit side by side, wrapping as needed. */
@media (max-width: 1024px) {
  .asset-table .fleet-readings { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 18px; }
}
/* Cards: one reading per row, label and value left, graph window right. */
.fleet-card .fleet-readings { gap: 8px; margin-bottom: 12px; }
.fleet-card .fleet-reading-value { font-size: 16px; }
.fleet-card .fleet-readings[data-count="1"] .fleet-reading-value { font-size: 24px; }
.fleet-card .fleet-mini { width: 108px; height: 40px; }
.fleet-card .fleet-readings[data-count="1"] .fleet-reading { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
.fleet-card .fleet-readings[data-count="1"] .fleet-mini { grid-column: 1; grid-row: 4; width: 100%; height: 56px; margin-top: 10px; }
.fleet-card .fleet-reading + .fleet-reading { border-top: 1px solid var(--line); padding-top: 8px; }

/* Card header: name first (what the eye looks for), severity at the right. */
.fleet-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 2px; min-width: 0; }
.fleet-card-head .fleet-card-title { flex: 1; min-width: 0; margin: 0; display: flex; align-items: center; gap: 8px; }
.fleet-card-head .status-pill { flex: none; min-height: 0; padding: 2px 7px; font-size: 9px; white-space: nowrap; margin-top: 2px; }
.fleet-card-body > .fleet-card-id { margin-bottom: 14px; }
.fleet-card-head + .fleet-readings, .fleet-card-head + .fleet-card-reading { margin-top: 12px; }

/* Level legend under each value. Shown in cards only; in the table the graph tooltip carries it. */
.fleet-reading-levels { display: none; grid-column: 1; grid-row: 3; margin-top: 2px; color: var(--muted-2); font-size: 9px; letter-spacing: 0.03em; white-space: normal; }
.fleet-card .fleet-reading-levels { display: block; }

/* ============================================================
   CONFIGURATION PAGE ARRANGEMENT
   Thresholds (the main job) on the left, the bearing calculator beside it
   in a comfortable 2-column form, admin-only panels as full-width rows below.
   ============================================================ */
.pane-config { grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.9fr); }
.pane-config > .config-panel { order: 1; grid-column: 1; }
.pane-config > .bearing-panel { order: 2; grid-column: 2; }
.pane-config > .theme-panel { order: 3; }
.pane-config > #displayPanel { order: 4; }

.bearing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; margin-bottom: 12px; }
/* Labels can wrap to two lines; pin them to the bottom so every input lines up. */
.bearing-grid .field { display: grid; grid-template-rows: auto auto; align-content: end; gap: 4px; }
.bearing-grid .field > span { display: flex; align-items: flex-end; line-height: 1.25; }
.bearing-grid .bearing-btn { grid-column: 1 / -1; align-self: stretch; min-height: 36px; margin-top: 2px; }
.bearing-results { line-height: 1.7; }

@media (max-width: 1200px) {
  .pane-config > .config-panel, .pane-config > .bearing-panel { grid-column: 1 / -1; }
  .bearing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bearing-grid .bearing-btn { grid-column: auto; margin-top: 0; align-self: end; }
}
@media (max-width: 720px) {
  .bearing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bearing-grid .bearing-btn { grid-column: 1 / -1; margin-top: 2px; }
}
@media (max-width: 420px) {
  .bearing-grid { grid-template-columns: minmax(0, 1fr); }
}


/* ============================================================
   STANDALONE ICON BUTTONS
   Root cause of the clipped sort arrow: standalone buttons reused .seg-btn,
   the style for buttons INSIDE a joined group. That style draws only a right
   divider, strips it from the last child, uses a 10px caps font and grows to
   38px on touch widths - so a lone button lost its right border, its arrow
   shrank to a speck and its size drifted from the control beside it.
   .icon-btn is a self-contained square: full border on all four sides, an
   SVG icon (never a text glyph whose size depends on the font), and the same
   height as the field it sits next to.
   ============================================================ */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; min-width: 34px; min-height: 0; padding: 0;
  border: 1px solid var(--line-2); border-radius: 0;
  background: var(--control-bg); color: var(--text-strong);
  cursor: pointer; line-height: 0;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.icon-btn:hover:not(:disabled) { background: var(--control-hover); border-color: var(--accent); }
.icon-btn:active:not(:disabled) { background: var(--control-active); color: var(--control-active-text); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn svg, .ai-label-delete svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.icon-btn .icon-arrow { transition: transform 160ms ease; }
.icon-btn.is-down .icon-arrow { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .icon-btn, .icon-btn .icon-arrow { transition: none; } }

/* Sort-direction button: same height as the sort select beside it. */
.fleet-cards-toolbar .icon-btn { width: 34px; height: 34px; }

/* Y-axis pan buttons: same height as the min/max fields they act on. */
.y-minmax-row .y-range-input { height: 28px; min-height: 28px; }
.y-minmax-row .icon-btn.y-pan-btn { width: 28px; height: 28px; min-width: 28px; min-height: 28px; padding: 0; }
.y-minmax-row .icon-btn.y-pan-btn svg { width: 14px; height: 14px; }
@media (max-width: 1024px) {
  .y-minmax-row .y-range-input { height: 38px; min-height: 38px; }
  .y-minmax-row .icon-btn.y-pan-btn { width: 38px; height: 38px; min-width: 38px; min-height: 38px; }
}

/* Label delete: a drawn cross, not a 10px text glyph. */
.ai-label-delete svg { width: 14px; height: 14px; }

/* Page numbers were 10px - too small to read at a glance. */
.page-btn { font-size: 11px; }
@media (max-width: 1024px) {
  /* Touch widths grow the sort select to 38px; the button must follow. */
  .fleet-cards-toolbar .icon-btn { width: 38px; height: 38px; min-width: 38px; }
}

/* ============================================================
   PATTERN RECOGNIZER - REVAMP
   Information is laid out in the order the questions arise:
     1. What is the machine doing?   -> the verdict, largest type, colour + words
     2. How sure is it?              -> three facts: match, confirmed by, freshness
     3. Is this live?                -> 3D motion scope beside the verdict
     4. Why?                         -> every recorded pattern on one shared scale
     5. How exactly?                 -> mechanics folded away (progressive disclosure)
   State colour lives in ONE place (the top rule and the verdict text), so it
   is read pre-attentively instead of competing with decorative accents.
   ============================================================ */
#pane-ai-classifier .pane-ai-monitor { grid-template-columns: minmax(0, 1fr); gap: 12px; background: var(--bg); }
#pane-ai-classifier .rx-head,
#pane-ai-classifier .rx-card { grid-column: 1 / -1; }

/* Page head */
.rx-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px; padding: 2px 2px 0; }
.rx-head-text { min-width: 0; flex: 1 1 420px; }
.rx-title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: 0.01em; color: var(--text-strong); }
.rx-sub { margin: 4px 0 0; max-width: 72ch; font-size: 12px; line-height: 1.5; color: var(--muted); }
#pane-ai-classifier .rx-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0; padding: 7px 12px; border: 1px solid var(--line); background: var(--panel); }
#pane-ai-classifier .rx-status .ai-model-version,
#pane-ai-classifier .rx-status .ai-model-sensor { font-size: 11px; color: var(--muted); }
#pane-ai-classifier .rx-status .ai-model-version:empty,
#pane-ai-classifier .rx-status .ai-model-sensor:empty { display: none; }

/* Card + state tone */
#pane-ai-classifier .rx-card { --rx-tone: var(--muted); padding: 0; display: block; }
#pane-ai-classifier .rx-card[data-state="matched"] { --rx-tone: var(--normal-fg); }
#pane-ai-classifier .rx-card[data-state="unknown"],
#pane-ai-classifier .rx-card[data-state="ambiguous"] { --rx-tone: var(--warning-fg); }
#pane-ai-classifier .rx-card[data-state="low_signal"],
#pane-ai-classifier .rx-card[data-state="no_data"] { --rx-tone: var(--info-fg, var(--info)); }
#pane-ai-classifier .rx-card::before { height: 3px; background: var(--rx-tone); transition: background-color 300ms ease; }
#pane-ai-classifier .rx-card::after { display: none; }

/* 1. Hero: verdict left, live motion right */
.rx-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr); border-bottom: 1px solid var(--line); }
.rx-verdict { display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 26px 28px 22px; }
.rx-kicker { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
#pane-ai-classifier .rx-verdict .ai-pred-stable-label {
  margin: -6px 0 0; font-size: clamp(26px, 3.2vw, 40px); font-weight: 700; line-height: 1.08; letter-spacing: -0.01em;
  color: var(--rx-tone); overflow-wrap: anywhere; text-shadow: none;
}
#pane-ai-classifier .rx-card[data-state="not_ready"] .rx-verdict .ai-pred-stable-label { color: var(--text-strong); font-size: clamp(22px, 2.6vw, 30px); }
#pane-ai-classifier .rx-verdict .ai-pred-sublabel { margin: -6px 0 0; max-width: 60ch; font-size: 13px; line-height: 1.5; color: var(--text-soft, var(--text)); }
#pane-ai-classifier .rx-verdict .ai-fallback-banner { margin: 0; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--warning) 55%, var(--line)); background: var(--warning-bg); color: var(--warning-fg); font-size: 12px; }

/* Facts: three equal tiles, numbers large enough to read across a room */
.rx-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 4px 0 0; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 70%, var(--control-bg) 30%); }
.rx-fact { min-width: 0; padding: 11px 14px 12px; }
.rx-fact + .rx-fact { border-left: 1px solid var(--line); }
.rx-fact dt { margin: 0 0 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.rx-fact dd { margin: 0; display: grid; gap: 6px; }
.rx-fact dd strong { font-size: 20px; font-weight: 700; line-height: 1.1; color: var(--text-strong); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rx-fact dd strong.is-delayed { color: var(--warning-fg); }
.rx-fact-note { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rx-meter { display: block; height: 4px; background: var(--border); overflow: hidden; }
.rx-meter i { display: block; height: 100%; width: 0; background: var(--rx-tone); transition: width 760ms cubic-bezier(.2,.7,.2,1), background-color 300ms ease; }

/* Recent results: oldest -> newest, the newest emphasised */
#pane-ai-classifier .rx-history { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; padding: 0; border: 0; background: none; }
#pane-ai-classifier .rx-history .ai-recent-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
#pane-ai-classifier .rx-history .ai-recent-list { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }

/* Empty state: say what to do next, not just that nothing is there */
.rx-cta { display: none; padding: 14px 16px; border: 1px dashed var(--line-2); background: color-mix(in srgb, var(--panel) 80%, var(--control-bg) 20%); }
.rx-cta p { margin: 0 0 10px; font-size: 12px; line-height: 1.5; color: var(--text); }
.rx-cta .rx-cta-note { margin: 0; color: var(--muted); }
body.admin-authenticated .rx-cta .rx-cta-note { display: none; }
#pane-ai-classifier .rx-card[data-state="not_ready"]:not([data-model="ready"]):not([data-model="remote_waiting"]) .rx-cta { display: block; }
#pane-ai-classifier .rx-card[data-state="not_ready"] .rx-facts,
#pane-ai-classifier .rx-card[data-state="not_ready"] .rx-history { display: none; }

/* Live motion */
.rx-motion { display: flex; flex-direction: column; gap: 10px; min-width: 0; margin: 0; padding: 18px 20px 16px; border-left: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 88%, var(--bg) 12%); }
.rx-motion-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rx-motion-title { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-strong); }
.rx-motion-state { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); text-align: right; }
.rx-motion-state.is-live { color: var(--normal-fg); }
.rx-motion-state.is-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
#pane-ai-classifier .rx-scope-wrap { width: 100%; max-width: 340px; margin: 0 auto; background: color-mix(in srgb, var(--panel-hdr) 65%, var(--control-bg) 35%); box-shadow: inset 0 0 0 1px var(--line); }
#pane-ai-classifier .rx-scope-wrap .ai-wave-scope { pointer-events: auto; cursor: grab; touch-action: pan-y; }
#pane-ai-classifier .rx-scope-wrap .ai-wave-scope.is-orbiting { cursor: grabbing; }
.rx-axes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); }
.rx-axis { display: grid; gap: 3px; min-width: 0; padding: 7px 9px; }
.rx-axis + .rx-axis { border-left: 1px solid var(--line); }
.rx-axis b { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.rx-axis strong { font-size: 12px; font-weight: 600; color: var(--text-strong); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rx-axis-x b { color: var(--axis-x); }
.rx-axis-y b { color: var(--axis-y); }
.rx-axis-z b { color: var(--axis-z); }
.rx-axis-hz b { color: var(--muted); }

/* 2. Evidence: every recorded pattern as a row on one shared 0-100% scale */
.rx-ranking { padding: 20px 28px 22px; }
.rx-section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 10px; }
.rx-section-title { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-strong); }
.rx-section-meta { font-size: 11px; color: var(--muted); }
#pane-ai-classifier .rx-ranking .ai-prob-bars { display: block; margin: 0; padding: 0; border: 0; background: none; }
#pane-ai-classifier .rx-ranking .ai-signature-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; border-bottom: 1px solid var(--line); }
#pane-ai-classifier .rx-ranking .ai-signature-card {
  display: grid; grid-template-columns: minmax(150px, 0.9fr) minmax(0, 2.4fr);
  align-items: center; gap: 4px 20px; min-height: 0; padding: 12px 12px 11px 14px; border: 0; border-top: 1px solid var(--line);
  border-radius: 0; background: transparent; box-shadow: none;
}
#pane-ai-classifier .rx-ranking .ai-signature-card-closest,
#pane-ai-classifier .rx-ranking .ai-signature-card-matched { background: color-mix(in srgb, var(--panel) 85%, var(--control-bg) 15%); box-shadow: inset 3px 0 0 var(--accent); }
#pane-ai-classifier .rx-ranking .ai-signature-card-matched { box-shadow: inset 3px 0 0 var(--normal-fg); }
#pane-ai-classifier .rx-ranking .ai-signature-card-ambiguous { box-shadow: inset 3px 0 0 var(--warning-fg); }
#pane-ai-classifier .rx-ranking .ai-signature-card-outside .ai-signature-name,
#pane-ai-classifier .rx-ranking .ai-signature-card-invalid .ai-signature-name { color: var(--muted); }
#pane-ai-classifier .rx-ranking .ai-signature-card-header { grid-area: head; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; margin: 0; }
#pane-ai-classifier .rx-ranking .ai-signature-name { font-size: 14px; font-weight: 700; color: var(--text-strong); overflow-wrap: anywhere; }
#pane-ai-classifier .rx-ranking .ai-signature-badge { padding: 1px 6px; font-size: 9px; letter-spacing: 0.08em; border: 1px solid var(--line-2); color: var(--muted); background: transparent; white-space: nowrap; }
#pane-ai-classifier .rx-ranking .ai-signature-card-main { grid-area: main; display: grid; grid-template-columns: minmax(0, 1fr) 110px; align-items: center; gap: 16px; margin: 0; }
#pane-ai-classifier .rx-ranking .ai-signature-meter { display: grid; grid-template-columns: minmax(0, 1fr) 46px; align-items: center; gap: 12px; width: auto; height: auto; }
.ai-signature-bar { position: relative; display: block; height: 10px; background: color-mix(in srgb, var(--border) 70%, transparent); overflow: hidden; }
.ai-signature-bar-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); transition: width 760ms cubic-bezier(.2,.7,.2,1), background-color 300ms ease; }
#pane-ai-classifier .rx-ranking .ai-signature-meter-text { position: static; transform: none; font-size: 15px; font-weight: 700; text-align: right; color: var(--text-strong); font-variant-numeric: tabular-nums; }
#pane-ai-classifier .rx-ranking .ai-signature-trend { display: block; min-width: 0; }
#pane-ai-classifier .rx-ranking .ai-signature-trend > span { display: none; }
#pane-ai-classifier .rx-ranking .ai-signature-card { grid-template-areas: "head main" "dist dist" "ch ch" "foot foot"; }
#pane-ai-classifier .rx-ranking .ai-signature-distance { grid-area: dist; margin: 0; font-size: 11px; color: var(--muted); }
#pane-ai-classifier .rx-ranking .ai-signature-channel-matches { grid-area: ch; display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 0; }
#pane-ai-classifier .rx-ranking .ai-signature-channel-matches span { padding: 0; border: 0; background: none; font-size: 11px; color: var(--muted); }
#pane-ai-classifier .rx-ranking .ai-signature-channel-matches strong { margin-left: 4px; font-size: 11px; color: var(--text); }
#pane-ai-classifier .rx-ranking .ai-signature-footer { grid-area: foot; display: flex; gap: 10px; margin: 0; padding: 0; border: 0; font-size: 11px; color: var(--muted); }
/* Secondary numbers sit in one quiet line under the bar, on wide screens. */
@media (min-width: 821px) {
  /* Desktop: example count sits under the name, the level/pattern split
     under the bar. "Close / not close" is already the badge, so the
     sentence form is only shown on narrow screens. */
  #pane-ai-classifier .rx-ranking .ai-signature-card { grid-template-areas: "head main" "foot more"; }
  #pane-ai-classifier .rx-ranking .ai-signature-card > .ai-signature-distance { display: none; }
  #pane-ai-classifier .rx-ranking .ai-signature-channel-matches { grid-area: more; }
}
#pane-ai-classifier .rx-ranking .ai-signature-toggle { margin-top: 10px; max-width: none; }
#pane-ai-classifier .rx-ranking .ai-prob-empty { padding: 14px 0 2px; font-size: 12px; color: var(--muted); }
#pane-ai-classifier .rx-ranking .ai-decision-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 12px; }

/* Sparkline: the last few checks for this pattern, no chart furniture. */
#pane-ai-classifier .rx-ranking .ai-signature-sparkline { display: block; width: 100%; height: 28px; }

/* 3. Mechanics, folded away */
.rx-details { border-top: 1px solid var(--line); }
.rx-details > summary { display: flex; align-items: center; gap: 10px; padding: 14px 28px; cursor: pointer; list-style: none; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.rx-details > summary::-webkit-details-marker { display: none; }
.rx-details > summary:hover { color: var(--text-strong); }
.rx-details > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rx-details-body { display: grid; gap: 16px; padding: 0 28px 22px; }
#pane-ai-classifier .rx-details .ai-class-gate { margin: 0; padding: 0; border: 0; background: none; }
#pane-ai-classifier .rx-details .ai-prediction-meta { margin: 0; }
.rx-glossary { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.5; }
.rx-glossary dt { font-weight: 700; color: var(--text-strong); }
.rx-glossary dd { margin: 0; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .rx-meter i, .ai-signature-bar-fill, .rx-details > summary::before, #pane-ai-classifier .rx-card::before { transition: none; }
}

/* Tablet: the verdict keeps the top; motion drops beneath it */
@media (max-width: 1100px) {
  .rx-hero { grid-template-columns: minmax(0, 1fr); }
  .rx-motion { border-left: 0; border-top: 1px solid var(--line); }
  #pane-ai-classifier .rx-scope-wrap { max-width: 300px; }
}
@media (max-width: 820px) {
  #pane-ai-classifier .rx-ranking .ai-signature-card { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "main" "dist" "ch" "foot"; gap: 8px; }
  #pane-ai-classifier .rx-ranking .ai-signature-card-main { grid-template-columns: minmax(0, 1fr) 84px; }
}
/* Phone */
@media (max-width: 600px) {
  .rx-verdict { padding: 18px 16px 16px; gap: 12px; }
  .rx-motion { padding: 14px 16px; }
  .rx-ranking { padding: 16px; }
  .rx-details > summary { padding: 14px 16px; }
  .rx-details-body { padding: 0 16px 18px; }
  .rx-fact { padding: 9px 10px 10px; }
  .rx-fact dd strong { font-size: 16px; }
  .rx-axes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rx-axis:nth-child(3) { border-left: 0; }
  .rx-axis:nth-child(n+3) { border-top: 1px solid var(--line); }
  .rx-glossary { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .rx-glossary dd { margin-bottom: 8px; }
  #pane-ai-classifier .rx-card .btn.rx-cta-btn { width: auto; }
}
/* Revamp fixes from visual review */
#pane-ai-classifier .rx-head { padding: 14px 16px; border: 1px solid var(--line); border-left: 3px solid var(--panel-header-accent); background: var(--panel-2); }
#pane-ai-classifier .rx-ranking .ai-signature-warning { padding: 1px 6px; font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; border: 1px solid color-mix(in srgb, var(--warning) 50%, var(--line-2)); color: var(--warning-fg); background: transparent; }
#pane-ai-classifier .rx-ranking .ai-signature-warning.hidden { display: none; }
#pane-ai-classifier .rx-ranking .ai-signature-footer { align-items: center; }
#pane-ai-classifier .rx-ranking .ai-signature-samples { font-size: 11px; letter-spacing: 0; text-transform: none; color: var(--muted); }
#pane-ai-classifier .rx-ranking .ai-signature-channel-matches span { display: inline-flex; align-items: baseline; gap: 4px; min-height: 0; text-transform: none; letter-spacing: 0; }
#pane-ai-classifier .rx-ranking .ai-signature-channel-matches strong { margin: 0; display: inline; }
@media (min-width: 1101px) { #pane-ai-classifier .rx-scope-wrap { max-width: 320px; } }
/* Last checks anchor to the bottom of the verdict column so it lines up with
   the scope readouts instead of leaving a hole under the facts. */
@media (min-width: 1101px) { #pane-ai-classifier .rx-history { margin-top: auto; padding-top: 6px; } }
/* Nothing to compare yet: the empty-state call to action says it once. */
#pane-ai-classifier .rx-card[data-state="not_ready"] .rx-ranking { display: none; }
@media (max-width: 600px) { .rx-fact-note { white-space: normal; } }
.rx-cta .rx-cta-retrain { display: none; }
#pane-ai-classifier .rx-card[data-model="not_ready"] .rx-cta .rx-cta-retrain { display: block; }
#pane-ai-classifier .rx-card[data-model="not_ready"] .rx-cta .rx-cta-untrained { display: none; }
/* Details rows: label | result | bar fills the space | figure, at readable size. */
#pane-ai-classifier .rx-details .ai-class-gate { flex-direction: column; gap: 12px; }
#pane-ai-classifier .rx-details .ai-class-gate-results { display: grid; gap: 8px; width: 100%; }
#pane-ai-classifier .rx-details .ai-gate-row { grid-template-columns: 150px minmax(120px, 200px) minmax(80px, 1fr) minmax(150px, 220px); gap: 12px; }
#pane-ai-classifier .rx-details .ai-gate-label,
#pane-ai-classifier .rx-details .ai-gate-status,
#pane-ai-classifier .rx-details .ai-gate-detail { font-size: 11px; }
#pane-ai-classifier .rx-details .ai-gate-track,
#pane-ai-classifier .rx-details .ai-engine-bar { width: 100%; max-width: none; }
#pane-ai-classifier .rx-details .ai-engine-row { grid-template-columns: minmax(150px, 230px) minmax(80px, 1fr) 110px; gap: 12px; }
#pane-ai-classifier .rx-details .ai-engine-row > span:first-child,
#pane-ai-classifier .rx-details .ai-engine-row > strong { font-size: 11px; }
@media (max-width: 820px) {
  #pane-ai-classifier .rx-details .ai-gate-row { grid-template-columns: minmax(0, 1fr) auto; }
  #pane-ai-classifier .rx-details .ai-gate-track { grid-column: 1 / -1; }
  #pane-ai-classifier .rx-details .ai-gate-detail { grid-column: 1 / -1; text-align: left; }
  #pane-ai-classifier .rx-details .ai-engine-row { grid-template-columns: minmax(0, 1fr) auto; }
  #pane-ai-classifier .rx-details .ai-engine-bar { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 820px) {
  /* Proximity: a bar belongs to the label directly above it. */
  #pane-ai-classifier .rx-details .ai-engine-row,
  #pane-ai-classifier .rx-details .ai-gate-row { row-gap: 5px; }
  #pane-ai-classifier .rx-details .ai-engine-row + .ai-engine-row,
  #pane-ai-classifier .rx-details .ai-gate-row + .ai-gate-row { margin-top: 10px; }
}

/* "No limit set": a measurement nobody has put limits on is neither good nor
   bad - neutral grey, never the green that would claim it was judged. */
.status-pill.pill-neutral { color: var(--muted); background: transparent; border-color: var(--line-2); }
.status-pill.pill-neutral::before { background: var(--muted-2); box-shadow: none; }

/* Motion scope: size switch, scale label and physics line. */
.rx-scope-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.rx-scale-toggle { display: flex; flex: 1 1 100%; min-width: 0; }
.rx-scale-toggle .seg-btn { flex: 1 1 0; min-width: 0; padding: 3px 4px; white-space: nowrap; }
.rx-scale-toggle .seg-btn:first-child { flex-grow: 1.6; }
.rx-scale-label { font-size: 11px; color: var(--text-strong); font-variant-numeric: tabular-nums; }

/* Icon-only chart controls: stroke icons that match .icon-btn. */
.ctl-svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.seg-btn.seg-icon { min-width: 36px; padding: 0 8px; line-height: 0; }
.x-window-presets .seg-btn.seg-icon { min-width: 36px; padding: 0 5px; }
.chart-control-inline .ctl-icon { display: inline-flex; align-items: center; color: var(--muted-2); line-height: 0; }
.chart-control-inline .ctl-icon .ctl-svg { width: 15px; height: 15px; }
@media (max-width: 760px) {
  .seg-btn.seg-icon { min-height: 40px; }
  .trend-subpanel .chart-control-inline .segmented .seg-icon { width: 100%; }
}
.history-button-group button:has(.ctl-svg), .config-location-btn:has(.ctl-svg) { display: inline-flex; align-items: center; justify-content: center; line-height: 0; min-width: 40px; }
.config-location-btn:has(.ctl-svg) { min-height: 38px; padding: 0 10px; }

/* Pattern recognizer: bigger scope. */
.rx-hero { grid-template-columns: minmax(0, 1fr) minmax(380px, 1fr); }
#pane-ai-classifier .rx-scope-wrap { max-width: 460px; }
@media (max-width: 1100px) {
  .rx-hero { grid-template-columns: minmax(0, 1fr); }
  #pane-ai-classifier .rx-scope-wrap { max-width: 440px; }
}
@media (min-width: 1101px) { #pane-ai-classifier .rx-scope-wrap { max-width: 460px; } }
@media (max-width: 820px) { #pane-ai-classifier .rx-scope-wrap { max-width: none; } }

/* One control height: dropdowns, boxes and buttons that sit side by side match. */
:root { --ctl-h: 34px; }
@media (max-width: 760px) { :root { --ctl-h: 40px; } }
select,
input[type="text"], input[type="number"], input[type="search"], input[type="password"],
.seg-btn, .icon-btn, .history-button-group button,
#recordToggleBtn, .config-location-btn,
.panel-toolbar button, .panel-toolbar input:not([type="checkbox"]):not([type="radio"]), .panel-toolbar select {
  box-sizing: border-box;
  height: var(--ctl-h) !important;
  min-height: var(--ctl-h) !important;
}
.icon-btn { width: var(--ctl-h); min-width: var(--ctl-h); }
.segmented { align-items: stretch; }
.chart-control-inline, .x-window-field { align-items: center; }
.ctl-svg { width: 18px; height: 18px; stroke-width: 2; }
.chart-control-inline .ctl-icon .ctl-svg { width: 17px; height: 17px; }
.seg-btn.seg-icon .ctl-svg { width: 20px; height: 20px; stroke-width: 1.8; }

/* Phone: tidy two-column chart controls.
   Row 1 presets, row 2 scale | range, row 3 average | window, row 4 y min/max. */
@media (max-width: 760px) {
  .trend-subpanel .panel-toolbar { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; align-items: stretch; }
  .trend-subpanel .panel-toolbar > * { width: 100%; min-width: 0; grid-column: auto; }
  .trend-subpanel .panel-toolbar > .panel-meta { display: none; }
  .trend-subpanel .panel-toolbar > .x-window-presets { order: 1; grid-column: 1 / -1; }
  .trend-subpanel .panel-toolbar > .chart-control-inline:has(.segmented[aria-label*="scale"]) { grid-column: auto; order: 2; }
  .trend-subpanel .panel-toolbar > .chart-control-inline:has(.segmented[aria-label*="y-range"]) { grid-column: auto; order: 3; }
  .trend-subpanel .panel-toolbar > .chart-ma-control { order: 4; grid-column: auto; }
  .trend-subpanel .panel-toolbar > .x-window-field { order: 5; grid-column: auto; }
  .trend-subpanel .panel-toolbar > .y-minmax-row { order: 6; grid-column: 1 / -1; }
  .trend-subpanel .panel-toolbar > .chart-control-inline:has(.segmented) > .ctl-icon { display: none; }
  .trend-subpanel .chart-control-inline .segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .trend-subpanel .chart-ma-control,
  .trend-subpanel .x-window-field { display: grid !important; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; }
  .trend-subpanel .chart-ma-control { grid-template-columns: auto minmax(0, 1fr); }
  .trend-subpanel .chart-ma-control .mini-select,
  .trend-subpanel .x-window-field input { width: 100% !important; font-size: 14px; }
}
@media (max-width: 760px) { .trend-subpanel .chart-ma-control .mini-select { border: 1px solid var(--line-2); background-color: var(--control-bg); } }

/* Font Awesome style: solid, filled glyphs. */
.ctl-svg { width: auto; height: 15px; fill: currentColor; stroke: none; }
.seg-btn.seg-icon .ctl-svg { width: auto; height: 16px; stroke: none; }
.chart-control-inline .ctl-icon .ctl-svg { width: auto; height: 15px; }

.y-tools { display: inline-flex; gap: 4px; }
@media (max-width: 760px) {
  .trend-subpanel .y-minmax-row { grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) !important; }
  .trend-subpanel .y-minmax-row .y-tools { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .trend-subpanel .y-minmax-row .y-tools .icon-btn { width: 100%; }
}
.seg-btn.seg-icon .ctl-svg[viewBox="0 0 36 18"] { height: 18px; }

/* Auto mode: hide the min/max boxes only; pan and zoom buttons stay. */
.y-minmax-row:has(.y-range-input:disabled) { display: inline-flex !important; }
.y-minmax-row:has(.y-range-input:disabled) > span:not(.y-tools),
.y-minmax-row:has(.y-range-input:disabled) > .y-range-input { display: none; }
@media (max-width: 760px) {
  .trend-subpanel .y-minmax-row:has(.y-range-input:disabled) { display: grid !important; }
}

/* Configuration > thresholds: one tidy card per measurement.
   Name + unit on the left, On/Off switch on the right, then Warning | Critical. */
.threshold-stack { gap: 1px; display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.thresh-row { gap: 10px; padding: 12px 14px; }
.thresh-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.thresh-label { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.thresh-label .thresh-unit { margin: 0; font-size: 11px; font-weight: 600; color: var(--muted); }
.thresh-row-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-width: none; }
.thresh-row-single .thresh-row-inputs { grid-template-columns: minmax(0, 1fr); max-width: none; }
.thresh-field { display: flex; flex-direction: column; gap: 4px; margin: 0; min-width: 0; }
.thresh-field-label { font-size: 10px; }
.thresh-row-inputs input[type="number"] { width: 100%; min-width: 0; font-size: 14px; padding: 0 10px; }
.thresh-field.is-warning input:focus { border-color: var(--warning); box-shadow: 0 0 0 1px color-mix(in srgb, var(--warning) 45%, transparent); }
.thresh-field.is-critical input:focus { border-color: var(--critical); box-shadow: 0 0 0 1px color-mix(in srgb, var(--critical) 45%, transparent); }
/* Compact On/Off switch (was a wide "Disabled" box). */
.threshold-toggle, :is(#pane-configuration, #pane-manual-threshold) .threshold-toggle { width: 72px; height: var(--ctl-h); flex: none; }
.threshold-toggle span::after { content: 'Off'; }
.threshold-toggle input:checked + span::after { content: 'On'; }
:is(#pane-configuration, #pane-manual-threshold) .threshold-toggle span { padding-left: 22px; font-size: 11px; }
:is(#pane-configuration, #pane-manual-threshold) .threshold-toggle span::before { left: 8px; }
:is(#pane-configuration, #pane-manual-threshold) .threshold-toggle input:checked + span { padding-left: 8px; padding-right: 22px; }
:is(#pane-configuration, #pane-manual-threshold) .threshold-toggle input:checked + span::before { left: calc(100% - 14px); }
:is(#pane-configuration, #pane-manual-threshold) .thresh-row.thresh-row-unarmed-configured::after { content: "Alarm is off"; }
@media (max-width: 760px) {
  .thresh-row-inputs, .thresh-row-single .thresh-row-inputs { max-width: none; }
  .thresh-row-single .thresh-row-inputs { grid-template-columns: minmax(0, 1fr); }
}

/* dl containers (a11y): keep the old div-grid look */
dl.trend-stats-grid, dl.system-health-grid { margin-block: 0; margin-inline: 0; }
.pane-condition:focus-visible { outline: 1px solid var(--accent, #4aa3ff); outline-offset: 2px; }

/* Selected sensor bar: one consistent strip at the top of every per-sensor page. */
.sensor-bar {
  position: sticky; top: 0; z-index: 40; flex: none; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 14px 6px 16px;
  background: var(--panel-hdr, var(--panel));
  border-bottom: 1px solid var(--line-2); box-shadow: inset 4px 0 0 var(--accent);
}
.sensor-bar-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(122, 184, 230, 0.22); flex: none; }
.sensor-bar-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); flex: none; }
.sensor-bar-name { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; font-weight: 800; letter-spacing: 0.04em; color: var(--text-strong); }
.sensor-bar-change {
  flex: none; padding: 5px 12px; border: 1px solid var(--line-2); background: var(--control-bg); color: var(--text);
  font: inherit; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
.sensor-bar-change:hover { border-color: var(--accent); color: var(--text-strong); }
@media (max-width: 760px) {
  .sensor-bar { gap: 8px; min-height: 52px; padding: 6px 10px 6px 14px; }
  .sensor-bar-tag { display: none; }
  .sensor-bar-name { font-size: 18px; }
  .sensor-bar-change { min-height: 40px; }
}
/* Chart status line (gaps, waiting...) as a visible banner instead of loose text */
.trend-status { padding: 8px 12px; border: 1px solid var(--line-2); border-left-width: 4px; background: var(--control-bg); font-size: 13px; }
.trend-status.warning { border-color: var(--warning); background: var(--warning-bg); color: var(--warning-fg); }
.trend-status.ok { border-color: var(--normal); background: var(--normal-bg); }

/* Old small sensor labels are replaced by the big sensor banner. */
.ai-settings-sensor-row > .ai-section-label, .ai-settings-sensor-row > #aiDeviceSelector,
#pane-ai-classifier .rx-status .ai-model-sensor { display: none !important; }
.ai-settings-sensor-row { display: block; }

/* ===================== Configuration tabs ===================== */
.cfg-tabs {
  flex: none; display: flex; gap: 2px; padding: 0 12px; overflow-x: auto; scrollbar-width: none;
  background: var(--panel-header-bg); border-bottom: 1px solid var(--line-2);
}
.cfg-tabs::-webkit-scrollbar { display: none; }
.cfg-tab {
  flex: none; position: relative; padding: 13px 18px 11px; border: 0; border-bottom: 3px solid transparent; background: transparent;
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  white-space: nowrap;
}
.cfg-tab:hover { color: var(--text-strong); background: rgba(122, 184, 230, 0.06); }
.cfg-tab[aria-selected="true"] { color: var(--text-strong); border-bottom-color: var(--accent); background: rgba(122, 184, 230, 0.10); }
.pane-config { display: block; padding: 12px 12px 24px; width: 100%; }
/* body.admin-authenticated [data-admin-only] forces display:revert, so the tab rules must outrank it. */
.pane-config > [data-cfg-section],
body.admin-authenticated .pane-config > [data-cfg-section] { display: none !important; width: 100%; max-width: none; margin: 0; }
.pane-config > [data-cfg-section].cfg-active,
body.admin-authenticated .pane-config > [data-cfg-section].cfg-active { display: block !important; }
/* Only the Thresholds tab is about the selected sensor */
#pane-configuration > .sensor-bar { display: none; }
@media (max-width: 760px) {
  .cfg-tabs { padding: 0 6px; }
  .cfg-tab { padding: 14px 14px 12px; min-height: 44px; }
  .pane-config { padding: 10px 8px 20px; }
}

/* ===================== Trend plot show / hide ===================== */
.trend-subpanel > .panel-header { align-items: center; }
.plot-eye { margin-left: auto; flex: none; width: 40px; padding: 0; }
.plot-hidden-note { display: none; margin-left: 10px; padding: 1px 8px; border: 1px solid var(--line-2); color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.trend-subpanel.is-plot-hidden .plot-hidden-note { display: inline-block; }
.trend-subpanel.is-plot-hidden > :not(.panel-header) { display: none !important; }
.trend-subpanel.is-plot-hidden .panel-title { color: var(--muted); }
.trend-subpanel.is-plot-hidden .plot-eye { color: var(--accent); }

@media (max-width: 900px) { .threshold-stack { grid-template-columns: minmax(0, 1fr); } }

/* A range this resolution does not keep must look unavailable, not just ignore clicks. */
.history-button-group button:disabled { opacity: 0.35; cursor: not-allowed; }

/* History is reloading (resolution / measurement changed): show it, never the old plot. */
.hourly-history-chart-wrap.is-loading::after {
  content: 'Loading...'; position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; pointer-events: none;
}
.hourly-history-chart-wrap.is-loading canvas { opacity: 0.25; }

/* =====================================================================
   TREND TOOLBAR - final layout (supersedes the earlier layered overrides)
   Every control is a flat square: no heavy borders, same size, wrapping
   in tidy groups. The plot header is one slim row; the eye is small.
   ===================================================================== */


.trend-subpanel .panel-toolbar {
  display: flex !important; flex-direction: row !important; flex-wrap: wrap !important;
  align-items: center !important; justify-content: flex-start !important;
  gap: 8px 16px !important; padding: 8px 10px !important; grid-template-columns: none !important;
}
.trend-subpanel .panel-toolbar > * { width: auto !important; min-width: 0 !important; grid-column: auto !important; flex: none !important; }
/* order: presets, window box, scale, Y mode, moving average, Y range + pan/zoom */
.trend-subpanel .panel-toolbar > .x-window-presets { order: 1 !important; }
.trend-subpanel .panel-toolbar > .x-window-field   { order: 2 !important; }
.trend-subpanel .panel-toolbar > :nth-child(3)     { order: 3 !important; }
.trend-subpanel .panel-toolbar > :nth-child(5)     { order: 4 !important; }
.trend-subpanel .panel-toolbar > .chart-ma-control { order: 5 !important; }
.trend-subpanel .panel-toolbar > .y-minmax-row     { order: 6 !important; }

.trend-subpanel .panel-toolbar .x-window-presets,
.trend-subpanel .panel-toolbar .segmented {
  display: flex !important; gap: 4px !important; border: 0 !important; background: transparent !important;
  width: auto !important; grid-template-columns: none !important;
}
.trend-subpanel .panel-toolbar .chart-control-inline {
  display: flex !important; flex-direction: row !important; align-items: center !important; gap: 6px !important;
}
/* The button icons explain themselves; keep a label glyph only beside typed inputs */
.trend-subpanel .panel-toolbar .chart-control-inline:not(.x-window-field):not(.chart-ma-control):not(.y-minmax-row) > .ctl-icon { display: none !important; }

/* Typed inputs: same height, no frame, a quiet underline */
.trend-subpanel .panel-toolbar :is(input, select) {
  height: var(--sq) !important; min-height: var(--sq) !important; border: 0 !important; border-radius: 1px !important;
  background-color: color-mix(in srgb, var(--text) 8%, var(--panel-2, transparent)) !important; color: var(--text-strong); box-shadow: none;
  font-size: 13px; padding: 0 8px;
}
.trend-subpanel .panel-toolbar .x-window-field input { width: 72px !important; text-align: right; }
.trend-subpanel .panel-toolbar .chart-ma-control .mini-select { width: 68px !important; padding-right: 24px; }
.trend-subpanel .panel-toolbar .y-range-input { width: 80px !important; text-align: right; }
.trend-subpanel .panel-toolbar .fft-band-sep, .trend-subpanel .panel-toolbar .y-minmax-row > span:not(.y-tools) { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.trend-subpanel .panel-toolbar > .y-minmax-row { display: flex !important; flex-wrap: wrap !important; align-items: center !important; gap: 6px !important; }
.trend-subpanel .panel-toolbar .y-minmax-row:has(.y-range-input:disabled) > :not(.y-tools) { display: none !important; }
.trend-subpanel .panel-toolbar .y-tools { display: flex !important; gap: 4px !important; width: auto !important; grid-column: auto !important; grid-template-columns: none !important; }

/* Plot header: one slim row, eye tucked at the right */
.trend-subpanel > .panel-header {
  display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; align-items: center !important;
  min-height: 0 !important; padding: 3px 6px 3px 12px !important; gap: 8px !important;
}
.trend-subpanel > .panel-header .panel-title-wrap { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trend-subpanel > .panel-header .plot-eye {
  width: 32px !important; height: 32px !important; min-width: 32px !important; min-height: 32px !important; padding: 0 !important;
  margin: 0 0 0 auto !important; border: 0 !important; background: transparent !important; color: var(--muted); flex: none !important;
}
.trend-subpanel > .panel-header .plot-eye:hover { color: var(--text-strong); background: var(--control-hover) !important; }
.trend-subpanel.is-plot-hidden > .panel-header .plot-eye { color: var(--accent); }

/* Toolbar width guards (outrank earlier mobile rules) */
.trend-subpanel .panel-toolbar .chart-control-inline.x-window-field input[type] { width: 64px !important; max-width: 64px !important; }
.trend-subpanel .panel-toolbar .y-minmax-row input.y-range-input { width: 76px !important; max-width: 76px !important; }
.trend-subpanel .panel-toolbar > .y-minmax-row { max-width: 100% !important; display: flex !important; }
.trend-subpanel .panel-toolbar > .y-minmax-row:has(.y-range-input:disabled) { display: flex !important; }

/* Filled glyph icons inside icon buttons (zoom +/-): the generic stroke-icon rule must not blank them */
.icon-btn svg.ctl-svg, .icon-btn svg.ctl-svg path { fill: currentColor; stroke: none; }

/* =====================================================================
   CONTROL SURFACES - one rule for Trends and 6-Month History:
   no border (0px), 1px corner radius, the shape is seen by the fill.
   ===================================================================== */
.trend-subpanel, .hourly-history-toolbar { --sq: 36px; }
@media (max-width: 760px), (pointer: coarse) { .trend-subpanel, .hourly-history-toolbar { --sq: 40px; } }
.history-button-group {
  display: inline-flex !important; flex-wrap: nowrap; gap: 4px; border: 0 !important; background: transparent !important; width: auto !important;
}
.trend-subpanel .panel-toolbar :is(.seg-btn, .icon-btn),
.history-button-group button {
  border: 0 !important; border-radius: 1px !important; box-shadow: none !important;
  height: var(--sq, 36px) !important; min-height: var(--sq, 36px) !important; min-width: var(--sq, 36px) !important;
  font: 600 11px var(--font-mono); letter-spacing: normal; text-transform: none; margin: 0;
  padding: 0 8px !important; flex: none !important;
  background: color-mix(in srgb, var(--text) 8%, var(--panel-2, transparent)); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}
.trend-subpanel .panel-toolbar button:has(svg),
.history-button-group button:has(.ctl-svg) { width: var(--sq, 36px) !important; padding: 0 !important; }
.trend-subpanel .panel-toolbar button:hover:not(:disabled),
.history-button-group button:hover:not(:disabled) { background: var(--control-hover); color: var(--text-strong); }
.trend-subpanel .panel-toolbar button:is(.is-active, [aria-pressed="true"], :active):not(:disabled),
.history-button-group button:is(.active, [aria-pressed="true"]):not(:disabled) { background: var(--control-active); color: var(--control-active-text); }
.history-button-group button .ctl-svg { height: 16px; width: auto; fill: currentColor; stroke: none; }
.trend-subpanel .panel-toolbar button:disabled { opacity: 0.35; cursor: not-allowed; }
.trend-subpanel .panel-toolbar button .ctl-svg { height: 16px; width: auto; }
.hourly-history-toolbar :is(select, input:not([type=checkbox])) {
  border: 0 !important; border-radius: 1px !important; box-shadow: none !important;
  background-color: color-mix(in srgb, var(--text) 8%, var(--panel-2, transparent)) !important;
  height: var(--sq, 36px) !important; min-height: var(--sq, 36px) !important; color: var(--text-strong);
}
.config-location-btn, .trend-subpanel .panel-toolbar .y-range-input { border-radius: 1px !important; }

/* History toolbar on phone: selects keep their grid, button groups pack side by side */
@media (max-width: 760px), (pointer: coarse) {
  .hourly-history-toolbar { display: flex !important; flex-wrap: wrap !important; gap: 8px 12px !important; align-items: flex-end !important; }
  .hourly-history-toolbar > .field { flex: 1 1 calc(50% - 8px) !important; width: auto !important; }
  .hourly-history-toolbar > .field:first-child { flex-basis: 100% !important; }
  .hourly-history-toolbar > .history-button-group { grid-column: auto !important; width: auto !important; }
}

/* =====================================================================
   NO BROWSER-DEFAULT CONTROLS (Chrome, Edge, Safari, Firefox, mobile)
   Every native widget look is switched off and replaced by the dashboard's
   own flat style: spin arrows, checkbox, colour swatch, search clear,
   autofill tint, focus ring, tap flash and the dropdown list.
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
:root { color-scheme: dark; }
button, input, select, textarea { -webkit-appearance: none; -moz-appearance: none; appearance: none; font-family: inherit; }
button { border-radius: 0; }

/* Number boxes: no up/down spin arrows (the keyboard arrow keys still step the value) */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; display: none; }

/* Search / text: no built-in clear or reveal glyphs */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
input::-ms-clear, input::-ms-reveal { display: none; }

/* Browser autofill must not paint its own yellow/blue box */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text-strong);
  caret-color: var(--text-strong);
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset;
  box-shadow: 0 0 0 1000px var(--input-bg) inset;
  transition: background-color 9999s ease-out 0s;
}

/* Dropdown list: same colours as the dashboard where the browser allows it */
select option, select optgroup { background-color: var(--input-bg); color: var(--text-strong); }

/* Colour pickers: just the swatch */
input[type="color"] { cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 1px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 1px; }

/* Checkboxes: flat square, tick drawn with CSS so it looks the same everywhere */
input[type="checkbox"] {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  display: inline-grid; place-content: center; flex: none;
  width: 16px; min-width: 16px; height: 16px; padding: 0; margin: 0;
  border: 0; border-radius: 1px; cursor: pointer; vertical-align: middle;
  background: color-mix(in srgb, var(--text) 14%, var(--input-bg));
  box-shadow: none;
}
input[type="checkbox"]::before {
  content: ""; width: 8px; height: 4px; margin-top: -1px;
  border-left: 2px solid var(--control-active-text); border-bottom: 2px solid var(--control-active-text);
  transform: rotate(-45deg) scale(0); transition: transform 90ms ease;
}
input[type="checkbox"]:checked { background: var(--control-active); }
input[type="checkbox"]:checked::before { transform: rotate(-45deg) scale(1); }
input[type="checkbox"]:disabled { opacity: 0.4; cursor: not-allowed; }

/* Focus: one thin accent ring, never the browser's blue/black default */
:focus { outline: none; }
:is(button, a, summary, [tabindex], [role="tab"], [role="button"]):focus-visible {
  outline: 1px solid var(--accent); outline-offset: 1px;
}
:is(input, select, textarea):focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--info-fg) !important; }
input[type="checkbox"]:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; box-shadow: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }

/* Summary triangles: hidden everywhere (custom markers are drawn where wanted) */
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::marker { content: ""; }

/* "Paused" time badge: shown while a trend shows earlier readings; tap to go live */
.xlive-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; margin: 0;
  border: 0 !important; border-radius: 1px; box-shadow: none;
  background: color-mix(in srgb, var(--warning, #d9a441) 22%, transparent); color: var(--text-strong);
  font: 700 9px var(--font-mono, monospace); letter-spacing: 0.08em; cursor: pointer; white-space: nowrap;
}
.trend-subpanel .xlive-badge { height: 20px !important; min-height: 0 !important; min-width: 0 !important; width: auto !important; padding: 0 8px !important; align-self: center; flex: none; }
.xlive-badge:hover { background: color-mix(in srgb, var(--warning, #d9a441) 38%, transparent); }
.xlive-badge[hidden] { display: none !important; }

/* Touch pad over the Trends plot area: it takes the touches for pan/pinch; the rest of the page scrolls */
.trend-chart-wrap { position: relative; }
.trend-touch-pad { position: absolute; z-index: 3; touch-action: none; -webkit-user-select: none; user-select: none; background: transparent; }
@media (pointer: coarse) { .trend-chart-wrap canvas { touch-action: pan-y; } }


/* ===================== ALARM SOUND BUTTON ===================== */
.alarm-btn {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  align-self: center;
  width: 32px;
  height: 32px;
  margin: 0 10px 0 auto;
  padding: 6px;
  border: 0;
  border-radius: 1px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
}
.alarm-btn[hidden] { display: none; }
.alarm-btn svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.alarm-btn .alarm-speaker { fill: currentColor; stroke: none; }
.alarm-btn .alarm-slash { display: none; }
.alarm-btn[data-state="muted"] .alarm-waves { display: none; }
.alarm-btn[data-state="muted"] .alarm-slash { display: inline; }
/* Blocked by the browser: waves dimmed and blinking, so the viewer knows to tap. */
.alarm-btn[data-state="locked"] { color: var(--warning-fg); }
.alarm-btn[data-state="locked"] .alarm-waves { opacity: 0.35; animation: alarm-pulse 1.2s steps(2, end) infinite; }
.alarm-btn[data-state="armed"] { color: var(--text); }
.alarm-btn[data-state="warning"] { background: var(--warning); color: #111; animation: alarm-pulse 1s steps(2, end) infinite; }
.alarm-btn[data-state="critical"] { background: var(--critical); color: #fff; animation: alarm-pulse 0.5s steps(2, end) infinite; }
.alarm-btn[data-state="muted"] { color: var(--muted, var(--text-soft)); }
.alarm-btn[data-state="muted"][data-alert="warning"] { color: var(--warning-fg); box-shadow: inset 0 0 0 1px var(--warning); }
.alarm-btn[data-state="muted"][data-alert="critical"] { color: var(--critical-fg, var(--critical)); box-shadow: inset 0 0 0 1px var(--critical); }
.alarm-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
@keyframes alarm-pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .alarm-btn[data-state] { animation: none; } }
/* Narrow screens lay the top bar out as a grid; give the alarm button its own column. */
@media (max-width: 900px) {
  .appbar.has-alarm { grid-template-columns: 44px minmax(0, 1fr) 40px; }
  .appbar.has-alarm .alarm-btn { grid-column: 3; grid-row: 1; margin: 0 4px; justify-self: center; }
}

/* ===================== THRESHOLDS: ONE GROUP PER QUANTITY =====================
   Heading (quantity + unit), then one compact row per channel:
   Magnitude / X / Y / Z  [switch]  Warning  Critical.
   Column labels show on the first row only; every input keeps an aria-label. */
.thresh-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.thresh-group-head { padding: 12px 14px 6px; }
.thresh-group-head .thresh-label { font-size: 13px; font-weight: 700; }
.thresh-group .thresh-row.thresh-row-axis {
  display: grid;
  grid-template-columns: 92px auto minmax(0, 1fr);
  align-items: end;
  column-gap: 12px;
  row-gap: 6px;
  padding: 5px 14px;
  border-bottom: 0;
}
.thresh-group .thresh-row-axis:last-child { padding-bottom: 12px; }
/* Name and switch become their own grid columns, lined up with the inputs. */
.thresh-group .thresh-row-axis .thresh-row-head { display: contents; }
.thresh-group .thresh-row-axis .thresh-axis,
.thresh-group .thresh-row-axis .threshold-toggle { align-self: end; height: 34px; display: flex; align-items: center; margin: 0; }
.thresh-axis { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--text); white-space: nowrap; }
.thresh-group .thresh-row-axis + .thresh-row-axis .thresh-field-label { display: none; }
:is(#pane-configuration, #pane-manual-threshold) .thresh-group .thresh-row-axis.thresh-row-unarmed-configured::after { grid-column: 1 / -1; }
@media (max-width: 560px) {
  .thresh-group .thresh-row.thresh-row-axis { grid-template-columns: 74px auto minmax(0, 1fr); column-gap: 8px; padding: 5px 10px; }
  .thresh-group-head { padding: 10px 10px 4px; }
}

/* Alarm stability (hysteresis + confirmation), below the sensor thresholds. */
.alarm-stability { margin-top: 14px; padding: 12px 14px; background: var(--panel); border-top: 1px solid var(--line); }
.alarm-stability-head { margin-bottom: 4px; }
.alarm-stability-fields { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.alarm-stability-fields .thresh-field { width: 120px; }
.alarm-stability-danger { flex: 1 1 220px; margin: 0; }

/* Threshold rows reserve a 3px status stripe; keep the axis names on the same left edge as the group title. */
.thresh-group .thresh-row.thresh-row-axis { padding-left: 11px; }
@media (max-width: 560px) { .thresh-group .thresh-row.thresh-row-axis { padding-left: 7px; } }

/* Warning and Critical closer together than the alarm hysteresis band. */
:is(#pane-configuration, #pane-manual-threshold) .thresh-row.thresh-row-tight { border-left-color: var(--warning); }
:is(#pane-configuration, #pane-manual-threshold) .thresh-row.thresh-row-tight::after {
  content: attr(data-tight-hint);
  grid-column: 1 / -1;
  margin-top: 2px;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--line));
  background: var(--warning-bg);
  color: var(--warning-fg);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
}

/* Name the sensor itself reports, shown under an admin-set name. */
.config-name-reported { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; letter-spacing: 0.02em; }
.config-name-reported[hidden] { display: none; }

/* Sensor summary on Configuration: boxes share each row evenly (no empty
   filler block), and every value sits on the same line whether or not the
   box has an edit button. */
.device-config-summary { display: flex; flex-wrap: wrap; }
.device-config-summary > div { flex: 1 1 180px; }
.device-config-summary > div > strong,
.device-config-summary .config-location-view { min-height: 34px; display: flex; align-items: center; margin-top: 4px; }
.device-config-summary .config-location-view[hidden] { display: none; }
.config-location-view[hidden] + .config-name-reported { display: none; }

/* ===================== CONFIGURATION LAYOUT (2026-11) =====================
   One action bar under the thresholds, one control height for every field,
   checkbox and button, and buttons only as wide as their label. Alarm
   stability is a setting for all sensors, so it lives on the Alarm tab. */

/* Thresholds: a single footer bar instead of two boxed half-width buttons.
   Calibrate (+ its status) on the left, Save on the right, message below. */
:is(#pane-configuration, #pane-manual-threshold) .threshold-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}
:is(#pane-configuration, #pane-manual-threshold) .calibration-actions {
  display: flex; flex-direction: row; align-items: center; gap: 12px; min-width: 0;
}
:is(#pane-configuration, #pane-manual-threshold) .threshold-save-actions { display: flex; justify-content: flex-end; }
:is(#pane-configuration, #pane-manual-threshold) .threshold-actions .btn {
  width: auto; min-width: 200px; height: var(--ctl-h); min-height: var(--ctl-h); padding: 0 18px; flex: none;
}
:is(#pane-configuration, #pane-manual-threshold) .calibration-readout { font-size: 11px; line-height: 1.4; }
:is(#pane-configuration, #pane-manual-threshold) .threshold-note { grid-column: 1 / -1; max-width: none; }

/* Temperature uses the same row layout as the other quantities; its one
   limit sits in the Warning column. */
.thresh-row-temperature .thresh-row-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* One checkbox style for setting switches: same height as a field. */
.alarm-check {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0;
  height: var(--ctl-h); padding: 0 12px; margin: 0; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--panel-2);
  color: var(--text-strong); font-size: 12px; font-weight: 600; line-height: 1.3;
}
.alarm-check:hover { border-color: var(--muted-2); }
.alarm-check:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel-2)); }
.alarm-check:has(input:focus-visible) { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 32%, transparent); }
/* The checkbox itself uses the global flat checkbox style. */
.alarm-check span { min-width: 0; }

/* Alarm tab: two panels with the same rhythm (text, controls, Save on the right). */
#alarmPanel .theme-help, #alarmStabilityPanel .theme-help { margin: 0 0 12px; max-width: 920px; }
#alarmPanel .btn, #alarmStabilityPanel .btn {
  width: auto; height: var(--ctl-h); min-height: var(--ctl-h); padding: 0 16px; flex: none;
}
.alarm-sound-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.alarm-sound-row .alarm-check { flex: 0 1 auto; }
.alarm-sound-row #alarmSaveBtn, .alarm-stability-fields #alarmStabilitySaveBtn { min-width: 96px; margin-left: auto; align-self: flex-end; }
.alarm-test-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.alarm-test-label { margin-right: 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.alarm-test-row .btn { min-width: 92px; }
#alarmStabilityPanel { margin-top: 12px; }
#alarmStabilityPanel .alarm-stability { margin: 0; padding: 0; border: 0; background: none; }
#alarmStabilityPanel .alarm-stability-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
#alarmStabilityPanel .alarm-stability-fields .thresh-field { width: 130px; flex: none; }
#alarmStabilityPanel .alarm-stability-fields input[type="number"] { height: var(--ctl-h); }
#alarmStabilityPanel .alarm-stability-danger { flex: 0 1 auto; }

@media (max-width: 760px) {
  :is(#pane-configuration, #pane-manual-threshold) .threshold-actions { grid-template-columns: minmax(0, 1fr); }
  :is(#pane-configuration, #pane-manual-threshold) .calibration-actions { flex-direction: column; align-items: stretch; gap: 6px; }
  :is(#pane-configuration, #pane-manual-threshold) .threshold-actions .btn { width: 100%; min-width: 0; }
  :is(#pane-configuration, #pane-manual-threshold) .threshold-save-actions { display: block; }
  .alarm-check { height: auto; min-height: var(--ctl-h); padding: 8px 12px; flex: 1 1 100%; }
  .alarm-sound-row #alarmSaveBtn, .alarm-stability-fields #alarmStabilitySaveBtn { width: 100%; margin-left: 0; }
  #alarmStabilityPanel .alarm-stability-fields .thresh-field { flex: 1 1 calc(50% - 6px); width: auto; }
  .alarm-test-label { flex: 1 1 100%; }
  .alarm-test-row .btn { flex: 1 1 0; min-width: 0; }
}

/* Sensor facts strip: all five facts on one row when there is room, and an
   even wrap (no lone "State" cell) when there is not. */
#sensorProfilePanel .device-config-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
#sensorProfilePanel .device-config-summary > div { min-width: 0; }
#sensorProfilePanel .device-config-summary strong { overflow-wrap: anywhere; }
@media (max-width: 560px) {
  #sensorProfilePanel .device-config-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #sensorProfilePanel .device-config-summary > :first-child { grid-column: 1 / -1; }
}

/* "Alarm is off" (limits typed in but the switch is off): a small amber note
   under the switch instead of a full-width bar under every row, and the
   switch itself outlined in amber, so the table stays easy to scan. */
:is(#pane-configuration, #pane-manual-threshold) .thresh-group .thresh-row-axis.thresh-row-unarmed-configured::after {
  content: "Alarm is off";
  grid-column: 2 / 3;
  margin: -2px 0 0; padding: 0; border: 0; background: none;
  color: var(--warning-fg, var(--warning)); font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
  line-height: 1.2; text-align: center; text-transform: uppercase; white-space: nowrap;
}
:is(#pane-configuration, #pane-manual-threshold) .thresh-row.thresh-row-unarmed-configured .threshold-toggle span { border-color: color-mix(in srgb, var(--warning) 60%, var(--line-2)); }

/* Sensor list: installed location under the name and ID, one line, ellipsis. */
.sensor-location {
  display: flex; align-items: center; gap: 5px; margin-top: 4px;
  /* Fill the column's full width without widening it: the location shows as
     much text as fits at any screen size and ends in an ellipsis only when
     the column is genuinely too narrow. */
  width: 0; min-width: 100%; max-width: 100%;
  color: var(--muted); font-size: 11px; line-height: 1.3;
}
.sensor-location-icon { flex: none; width: auto; height: 10px; fill: currentColor; opacity: 0.8; }
.sensor-location-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fleet-card-location { margin: -8px 0 12px; min-width: 0; }
.fleet-card-location .sensor-location { max-width: 100%; margin-top: 0; }

/* ===================== ISO SEVERITY (2026-11) ===================== */
/* Zone colours: A and B healthy, C caution, D critical. */
:root { --iso-a: var(--normal); --iso-b: color-mix(in srgb, var(--normal) 55%, var(--warning)); --iso-c: var(--warning); --iso-d: var(--critical); }

.iso-root { display: grid; gap: 12px; }
.iso-root .panel-body > p { margin: 0 0 10px; max-width: 980px; color: var(--text); line-height: 1.6; font-size: 12.5px; }
.iso-root .panel-body > p strong, .iso-callout strong { color: var(--text-strong); }
.iso-h { margin: 18px 0 8px; color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.iso-muted { color: var(--muted); }
.iso-loading { color: var(--muted); }
.iso-table-wrap { overflow-x: auto; margin: 0 0 10px; }
.iso-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.iso-table th, .iso-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.iso-table thead th { background: var(--panel-header-bg, var(--panel-2)); color: var(--text-strong); font-weight: 700; font-size: 11.5px; letter-spacing: 0.03em; }
.iso-table .iso-subhead th { background: var(--panel-2); color: var(--muted); font-weight: 600; }
.iso-table .num { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.iso-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--panel-2) 45%, transparent); }
.iso-table tr.is-current td { background: color-mix(in srgb, var(--accent) 16%, var(--panel)) !important; color: var(--text-strong); font-weight: 600; }
.iso-table tr.is-current td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.iso-here { display: inline-block; margin-left: 8px; padding: 1px 7px; background: var(--accent); color: var(--control-active-text); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.iso-callout { margin: 10px 0 12px; padding: 10px 14px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-size: 12.5px; line-height: 1.55; }
.iso-callout.is-caution { border-color: color-mix(in srgb, var(--warning) 55%, var(--line)); background: var(--warning-bg); color: var(--warning-fg); }
.iso-callout.is-caution strong { color: var(--warning-fg); }
.iso-callout.is-note { border-color: color-mix(in srgb, var(--normal) 45%, var(--line)); background: var(--normal-bg); color: var(--normal-fg); }
.iso-callout.is-note strong { color: var(--normal-fg); }
.iso-ref.is-applicable > .panel-header { box-shadow: inset 3px 0 0 var(--accent); }
.iso-ivss-note { padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--panel-2); }
.iso-refs { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; font-size: 12px; }
.iso-refs li { display: grid; grid-template-columns: auto 1fr; column-gap: 6px; }
.iso-refs li > span:last-child { grid-column: 2; color: var(--muted); }
.iso-ref-n { color: var(--text-strong); font-weight: 700; }
.iso-refs a { color: var(--accent); }

.iso-zone-chip { display: inline-grid; place-items: center; width: 22px; height: 22px; font-weight: 800; font-size: 12px; color: #fff; }
.iso-zone-a { background: var(--iso-a); } .iso-zone-b { background: var(--iso-b); } .iso-zone-c { background: var(--iso-c); } .iso-zone-d { background: var(--iso-d); }
.iso-zone-c.iso-zone-chip, .iso-zone-b.iso-zone-chip { color: #111; }

/* "Where this asset falls" */
.iso-position-grid { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.7fr) minmax(280px, 1.6fr); gap: 12px; }
.iso-fact { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 12px 14px; border: 1px solid var(--line); background: var(--panel-2); }
.iso-fact > strong { color: var(--text-strong); font-size: 14px; line-height: 1.35; }
.iso-fact .btn { align-self: flex-start; width: auto; margin-top: 4px; height: var(--ctl-h); padding: 0 14px; }
.iso-fact-label { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.iso-fact-label em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 500; }
.iso-limits { font-size: 12px; color: var(--muted); line-height: 1.45; }
.iso-limits.is-on { color: var(--accent); font-weight: 600; }
.iso-zone-big { align-self: flex-start; padding: 6px 14px; font-size: 20px; font-weight: 800; letter-spacing: 0.02em; color: #fff; }
.iso-zone-big.iso-zone-b, .iso-zone-big.iso-zone-c { color: #111; }
.iso-zone-big.is-none { background: var(--panel); color: var(--muted); border: 1px solid var(--line-2); font-size: 15px; }
.iso-fact-zone > span:last-child { font-size: 12.5px; line-height: 1.45; color: var(--text); }
.iso-empty { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.iso-empty p { margin: 0; max-width: 760px; line-height: 1.55; }
.iso-empty .btn { width: auto; height: var(--ctl-h); padding: 0 18px; }
.iso-axis-table { margin-top: 12px; }
.iso-axis-table td, .iso-axis-table th { text-align: center; }
.iso-axis-table th[scope="row"] { color: var(--text-strong); }

.iso-scale { padding: 18px 0 2px; }
.iso-scale-track { position: relative; height: 22px; background: var(--panel); border: 1px solid var(--line-2); }
.iso-scale-seg { position: absolute; top: 0; bottom: 0; display: grid; place-items: center; opacity: 0.38; }
.iso-scale-seg b { color: #fff; font-size: 11px; text-shadow: 0 0 2px rgba(0,0,0,0.6); }
.iso-scale-seg.is-current { opacity: 1; }
.iso-scale-marker { position: absolute; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; background: var(--text-strong); }
.iso-scale-marker span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 2px; padding: 0 5px; background: var(--text-strong); color: var(--bg); font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.iso-scale-ticks { position: relative; height: 26px; margin-top: 3px; }
.iso-scale-ticks span { position: absolute; transform: translateX(-50%); color: var(--text); font-size: 10.5px; text-align: center; line-height: 1.15; font-variant-numeric: tabular-nums; }
.iso-scale-ticks small { display: block; color: var(--muted); font-size: 9px; }

/* General Info card */
.iso-config-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); background: var(--panel-2); }
.iso-config-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 320px; }
.iso-config-label { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.iso-config-text strong { color: var(--text-strong); font-size: 13px; }
.iso-config-limits { color: var(--muted); font-size: 12px; line-height: 1.45; }
.iso-config-limits.is-on { color: var(--accent); font-weight: 600; }
.iso-config-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.iso-config-actions .btn { width: auto; height: var(--ctl-h); min-height: var(--ctl-h); padding: 0 16px; }

/* Manual Threshold while ISO limits are on */
.iso-managed-note { margin: 0 0 12px; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); color: var(--text); font-size: 12.5px; line-height: 1.55; }
.iso-managed-note strong { color: var(--text-strong); }
.iso-managed-note .btn { width: auto; height: 28px; min-height: 28px; padding: 0 12px; margin-left: 8px; vertical-align: middle; }
.thresh-group.is-iso-locked .is-iso-row { opacity: 0.85; }
.thresh-group.is-iso-locked input:disabled { cursor: not-allowed; }
.iso-lock-tag { margin-left: auto; padding: 2px 8px; background: var(--accent); color: var(--control-active-text); font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.thresh-group-head:has(.iso-lock-tag) { display: flex; align-items: center; gap: 8px; }

/* Wizard */
.iso-wizard-overlay { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(4, 8, 12, 0.62); }
.iso-wizard { display: flex; flex-direction: column; width: min(760px, 100%); max-height: calc(100vh - 32px); background: var(--panel); border: 1px solid var(--line-2); box-shadow: 0 18px 60px rgba(0,0,0,0.45); }
.iso-wizard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.iso-wizard-head h2 { margin: 2px 0 0; color: var(--text-strong); font-size: 17px; }
.iso-wizard-kicker { color: var(--accent); font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.iso-wizard-close { width: 34px; height: 34px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-size: 14px; cursor: pointer; }
.iso-wizard-steps { display: flex; gap: 4px; margin: 0; padding: 10px 18px; list-style: none; border-bottom: 1px solid var(--line); overflow-x: auto; }
.iso-wizard-steps li { display: flex; align-items: center; gap: 6px; padding: 4px 8px; color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.iso-wizard-steps li span { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--line-2); font-size: 10px; }
.iso-wizard-steps li.is-current { color: var(--text-strong); }
.iso-wizard-steps li.is-current span { background: var(--accent); border-color: var(--accent); color: var(--control-active-text); }
.iso-wizard-steps li.is-done span { border-color: var(--accent); color: var(--accent); }
.iso-wizard-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 18px; outline: none; }
.iso-wizard-body h3 { margin: 0 0 10px; color: var(--text-strong); font-size: 14px; }
.iso-wizard-body h4 { margin: 14px 0 8px; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.iso-wizard-body p { margin: 0 0 10px; font-size: 12.5px; line-height: 1.55; }
.iso-choices { display: grid; gap: 8px; margin-bottom: 12px; }
.iso-choices-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.iso-choice { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; }
.iso-choice:hover { border-color: var(--muted-2); }
.iso-choice.is-selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel-2)); }
.iso-choice input { margin-top: 2px; flex: none; accent-color: var(--accent); }
.iso-choice strong { display: block; color: var(--text-strong); font-size: 12.5px; }
.iso-choice small { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.iso-suggested { position: absolute; top: 8px; right: 10px; padding: 1px 6px; background: var(--accent); color: var(--control-active-text); font-size: 9.5px; font-style: normal; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.iso-field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 10px; }
.iso-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.iso-field > span:first-child { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.iso-field > span:first-child em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 500; }
.iso-field small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.iso-field-wide { margin-top: 4px; }
.iso-field-wide input { height: var(--ctl-h); }
.iso-input { display: flex; align-items: stretch; }
.iso-input input { flex: 1 1 auto; min-width: 0; height: var(--ctl-h); }
.iso-input em { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line-2); border-left: 0; background: var(--panel-2); color: var(--muted); font-size: 11.5px; font-style: normal; white-space: nowrap; }
.iso-toggle-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; margin-bottom: 12px; }
.iso-toggle-row.is-disabled { opacity: 0.6; cursor: not-allowed; }
.iso-toggle-row input { margin-top: 2px; flex: none; }
.iso-toggle-row strong { display: block; color: var(--text-strong); font-size: 12.5px; }
.iso-toggle-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.iso-limits-box { padding: 12px; border: 1px solid var(--line); margin-bottom: 12px; }
.iso-limits-box.is-off { opacity: 0.5; }
.iso-limits-box .iso-table th[scope="row"] { color: var(--text-strong); width: 40%; }
.iso-help { margin-top: 6px; }
.iso-help summary { cursor: pointer; color: var(--accent); font-size: 12px; margin-bottom: 8px; }
.iso-result { color: var(--text-strong); font-weight: 600; }
.iso-summary th[scope="row"] { width: 42%; color: var(--muted); font-weight: 600; }
.iso-wizard-error { margin: 0; padding: 8px 18px; background: var(--critical-bg); color: var(--critical-fg); font-size: 12.5px; }
.iso-wizard-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.iso-wizard-foot .btn { width: auto; min-width: 96px; height: var(--ctl-h); min-height: var(--ctl-h); padding: 0 16px; }
.iso-wizard-spacer { flex: 1; }

@media (max-width: 900px) {
  .iso-position-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .iso-choices-2 { grid-template-columns: 1fr; }
  .iso-wizard-overlay { padding: 0; place-items: stretch; }
  .iso-wizard { max-height: 100vh; height: 100%; border: 0; }
  .iso-wizard-foot { flex-wrap: wrap; }
  .iso-wizard-foot .btn { flex: 1 1 auto; }
  .iso-wizard-remove { flex-basis: 100% !important; }
  .iso-wizard-spacer { display: none; }
  .iso-table th, .iso-table td { padding: 8px; }
  .iso-config-actions, .iso-config-actions .btn { width: 100%; }
}
.iso-wizard [hidden] { display: none !important; }
.thresh-group.is-iso-locked .is-iso-row .threshold-toggle input:disabled { opacity: 0 !important; }
.thresh-group.is-iso-locked .is-iso-row .threshold-toggle { cursor: not-allowed; }
.iso-table { min-width: 460px; }
.iso-table th, .iso-table td { word-break: normal; overflow-wrap: normal; }
.iso-table td:first-child { white-space: nowrap; }
.iso-summary, .iso-limits-box .iso-table, .iso-axis-table { min-width: 0; }
.iso-summary td:first-child, .iso-summary th { white-space: normal; }

/* Stepped severity chart: zone colours per column; the asset's column is lit
   and its current zone glows. */
:root { --iso-a: #6fbf73; --iso-b: #f0d264; --iso-c: #f08a6e; --iso-d: #b8433f; }
.iso-chart-wrap { overflow-x: auto; margin: 0 0 14px; }
.iso-chart { display: grid; grid-auto-rows: minmax(40px, auto); min-width: 640px; border: 2px solid var(--line-2); background: var(--panel); }
.iso-chart > div { min-width: 0; }
.iso-chart-title, .iso-chart-head, .iso-chart-unit, .iso-chart-foot, .iso-chart-footlabel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 10px 8px; text-align: center; border: 1px solid var(--line); color: var(--text); font-size: 12px; line-height: 1.35; }
.iso-chart-title strong { color: var(--iso-c); font-size: 16px; letter-spacing: 0.02em; }
.iso-chart-title span, .iso-chart-footlabel { color: var(--text-strong); font-weight: 700; }
.iso-chart-head strong { display: block; color: var(--text-strong); font-size: 13px; }
.iso-chart-head.is-top { border-bottom-width: 1px; }
.iso-chart-unit { color: var(--muted); font-size: 10.5px; }
.iso-chart-foot { position: relative; color: var(--text-strong); font-weight: 700; font-size: 13px; border-top: 2px solid var(--line-2); }
.iso-chart-footlabel { border-top: 2px solid var(--line-2); }
.iso-chart-foot .iso-here { margin: 4px 0 0; }
.iso-chart-tick { position: relative; border-right: 1px solid var(--line); }
.iso-chart-tick::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; border-bottom: 1px solid var(--line); }
.iso-chart-tick span { position: absolute; left: 50%; bottom: 0; z-index: 2; transform: translate(-50%, 50%); padding: 2px 8px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--panel); color: var(--text-strong); font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.iso-chart-block { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px; text-align: center; color: #14202b; border: 1px solid rgba(10, 20, 30, 0.55); transition: opacity 0.2s, filter 0.2s; }
.iso-chart-block b { font-size: 15px; line-height: 1; }
.iso-chart-block span { font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; line-height: 1.2; }
.iso-chart-block.iso-zone-d { color: #fff; }
.iso-chart-block.is-na { background: repeating-linear-gradient(135deg, var(--panel-2) 0 10px, var(--panel) 10px 20px); color: var(--muted); border-color: var(--line); }
.iso-chart-block.is-na span { text-transform: none; letter-spacing: 0; font-size: 11.5px; font-weight: 600; }
/* When an asset is classified: other columns step back, its zone glows. */
.iso-chart.has-asset .iso-chart-block:not(.is-asset) { opacity: 0.28; filter: saturate(0.6); }
.iso-chart.has-asset .iso-chart-block.is-asset:not(.is-now) { opacity: 0.6; }
.iso-chart-block.is-now { z-index: 3; opacity: 1; outline: 2px solid #fff; outline-offset: -2px; box-shadow: 0 0 0 1px rgba(255,255,255,0.5), 0 0 22px 6px var(--iso-glow), inset 0 0 18px rgba(255,255,255,0.35); animation: iso-glow 2.2s ease-in-out infinite; }
.iso-chart-block.iso-zone-a { --iso-glow: var(--iso-a); } .iso-chart-block.iso-zone-b { --iso-glow: var(--iso-b); } .iso-chart-block.iso-zone-c { --iso-glow: var(--iso-c); } .iso-chart-block.iso-zone-d { --iso-glow: #ff5a52; }
@keyframes iso-glow { 0%, 100% { box-shadow: 0 0 0 1px rgba(255,255,255,0.5), 0 0 14px 3px var(--iso-glow), inset 0 0 14px rgba(255,255,255,0.25); } 50% { box-shadow: 0 0 0 1px rgba(255,255,255,0.7), 0 0 30px 10px var(--iso-glow), inset 0 0 22px rgba(255,255,255,0.45); } }
@media (prefers-reduced-motion: reduce) { .iso-chart-block.is-now { animation: none; } }
.iso-chart-head.is-asset, .iso-chart-foot.is-asset { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); color: var(--text-strong); }
.iso-chart-lane { position: relative; z-index: 4; pointer-events: none; }
.iso-chart-marker { position: absolute; left: -4px; right: -4px; height: 0; border-top: 2px solid #fff; filter: drop-shadow(0 0 3px rgba(0,0,0,0.9)); }
.iso-chart-marker span { position: absolute; right: 8px; top: 0; transform: translateY(-50%); padding: 2px 8px; background: #fff; color: #0b1017; font-size: 11px; font-weight: 800; white-space: nowrap; }
/* zone chips and the scale use the same colours */
.iso-zone-chip, .iso-zone-big, .iso-scale-seg b { color: #14202b; }
.iso-zone-d.iso-zone-chip, .iso-zone-big.iso-zone-d { color: #fff; }
.iso-wizard-sensor { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }
.iso-choices-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.iso-result-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; padding: 9px 12px; border-left: 3px solid var(--accent); background: var(--panel-2); }
.iso-result-line span { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.iso-result-line strong { color: var(--text-strong); font-size: 13.5px; }
.iso-result-line em { color: var(--muted); font-style: normal; font-size: 12px; }
.iso-result-line.is-empty { border-left-color: var(--line-2); }
.iso-field select { height: var(--ctl-h); min-width: 0; }
@media (max-width: 560px) { .iso-choices-3 { grid-template-columns: 1fr; } }
.iso-choice input[type="radio"] { appearance: auto; -webkit-appearance: radio; width: 16px; height: 16px; min-width: 16px; min-height: 0; padding: 0; margin: 2px 0 0; border: 0; background: none; box-shadow: none; flex: none; }
.iso-choice > span { min-width: 0; flex: 1 1 auto; }

/* =====================================================================
   Calm layer (2026-11-13)
   Fewer boxes inside boxes: sections are separated by space and a single
   hairline instead of nested frames. Colours come from the theme variables,
   so every theme keeps working.
   ===================================================================== */

/* ---- Menu: plain list, icon on the left ---- */
.nav-list { padding: 4px 8px 14px; }
.nav-section { padding-top: 16px; }
.nav-section:first-child { padding-top: 8px; }
.nav-group-label { padding: 0 10px 6px; letter-spacing: 0.12em; }
.nav-group-label::after { display: none; }
.nav-items { padding: 0; gap: 2px; }
.nav-item {
  border: 0;
  background: transparent;
  padding: 9px 10px;
  gap: 12px;
  font-size: 13px;
}
.nav-item + .nav-item { margin-top: 0; }
.nav-item-icon { width: 18px; height: 18px; opacity: 1; }
.nav-item-icon svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--control-hover); }
.nav-item.active {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--text-strong);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-item.active .nav-item-icon { color: var(--accent); }
.admin-access-section .nav-item { border: 0; background: transparent; }

/* ---- Menu on phones and tablets: a grid of tiles ---- */
@media (max-width: 900px) {
  .sidebar {
    left: 8px;
    right: 8px;
    width: auto;
    height: auto;
    max-height: calc(100dvh - 16px);
  }
  /* One continuous grid: the group headings are dropped so no tile is left alone on a row. */
  .nav-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
    align-content: start;
  }
  .nav-section, .nav-items { display: contents; }
  .nav-group-label { display: none; }
  .nav-list .nav-item,
  body.admin-authenticated .nav-list .nav-item[data-admin-only] {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    min-height: 78px;
    padding: 10px 6px;
    background: var(--control-bg);
    font-size: 12px;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
  }
  .nav-item-icon, .nav-item-icon svg { width: 22px; height: 22px; }
  .nav-item-label { flex: 0 0 auto; overflow: visible; }
  .nav-item.active { box-shadow: inset 0 -3px 0 var(--accent); }
  .nav-list .admin-access-section .nav-item { grid-column: 1 / -1; flex-direction: row; min-height: 44px; background: transparent; }
}
@media (max-width: 340px) {
  .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Sections: no frame, no header strip ---- */
.panel {
  border-color: transparent;
  box-shadow: none;
}
.panel-header {
  background: transparent;
  border-bottom: 0;
  box-shadow: none;
  padding: 14px 12px 6px;
  align-items: center;
}
.panel-title { font-size: 12px; letter-spacing: 0.05em; }
/* A section inside a section is just a block with a hairline above it. */
.panel .panel {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
}

/* ---- Fact grids: values on hairlines, not in cells ---- */
.detail-list,
.system-health-grid,
.device-config-summary,
.report-status-grid,
.indicator-grid,
.table-shell,
.threshold-stack,
.frequency-summary-shell {
  border: 0;
  background: transparent;
}
.detail-list > div,
.system-health-grid > div,
.device-config-summary > div,
.report-status-grid > div {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.chart-wrap.trend-chart-wrap,
.hourly-history-chart-wrap { border: 0; background: transparent; }
.iso-config-card { border: 0; border-top: 1px solid var(--line); background: transparent; padding-left: 0; padding-right: 0; }

/* ---- Chart controls: quiet icons, grouped by a thin divider ---- */
.trend-subpanel .panel-toolbar {
  background: transparent;
  border: 0;
  padding-top: 2px;
  padding-bottom: 8px;
}
.trend-subpanel .panel-toolbar :is(input, select) {
  background-color: transparent !important;
  border-bottom: 1px solid var(--line-2) !important;
}
.trend-subpanel .panel-toolbar :is(input, select):focus { border-bottom-color: var(--accent) !important; }
@media (min-width: 761px) {
  /* A hairline between control groups instead of a box around each one. */
  .trend-subpanel .panel-toolbar { column-gap: 0 !important; }
  .trend-subpanel .panel-toolbar > * { padding: 0 12px; border-left: 1px solid var(--line); }
  .trend-subpanel .panel-toolbar > :first-child,
  .trend-subpanel .panel-toolbar > .x-window-presets { padding-left: 0; border-left: 0; }
}

/* ---- Layout details ---- */
@media (min-width: 901px) { .app-shell { grid-template-columns: 228px minmax(0, 1fr); } }
.selected-asset .detail-list { border: 0; background: transparent; gap: 0 24px; }
.selected-asset .detail-list div,
.selected-asset .detail-list div:last-child { border: 0; border-bottom: 1px solid var(--line); background: transparent; padding-left: 0; padding-right: 0; }

/* ---- Less to read ---- */
.trend-status.ok { display: none; }          /* only speak up when data quality is not OK */
#trendUnitLabel { display: none; }           /* units are on each chart axis */
.detail-list div[hidden], .profile-grid div[hidden] { display: none; }

/* Sections sit apart with space between them, not on a grid of lines. */
.pane-grid { gap: 10px; background: transparent; border-top: 0; }
.metric-status-grid { gap: 0; background: transparent; }
.metric-status-row { background: transparent; }
.metric-status-row + .metric-status-row { border-left: 1px solid var(--line); }
@media (max-width: 900px) {
  .metric-status-row + .metric-status-row { border-left: 0; border-top: 1px solid var(--line); }
}
.hourly-history-help { display: none; }      /* the same text is under "What am I looking at?" */

/* =====================================================================
   Sensor cards (2026-11-13): a filled surface whose title band carries the
   status colour, instead of outlines around the card and everything inside it.
   ===================================================================== */
.fleet-cards { gap: 10px; }
.fleet-card,
.fleet-card:hover {
  border: 0;
  background: var(--panel-2);
  box-shadow: none;
  transform: none;
}
.fleet-card:hover { background: color-mix(in srgb, var(--text-strong) 4%, var(--panel-2)); }
/* The selected sensor is a tinted surface, not an outline. */
.fleet-card.active {
  background: color-mix(in srgb, var(--accent) 13%, var(--panel-2));
  box-shadow: none;
}
.fleet-card-body { padding: 12px 14px 0; }
/* Status: coloured dot and word, no box. */
.fleet-card-head .status-pill {
  border: 0;
  background: transparent;
  padding: 0;
  margin-top: 4px;
  font-size: 10px;
}
/* Trend graph: no frame, a faint floor only. */
.fleet-card .fleet-mini {
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--graph) 45%, transparent);
  background: transparent;
}
.fleet-card .fleet-reading + .fleet-reading { border-top: 0; padding-top: 0; }
.fleet-card-actions { border-top: 0; }
.fleet-card-actions .fleet-delete-btn { border-color: transparent; opacity: 0.75; }
.fleet-card-actions .fleet-delete-btn:hover,
.fleet-card-actions .fleet-delete-btn:focus-visible { opacity: 1; }

/* ---- Phones: same information in about half the height ---- */
@media (max-width: 600px) {
  .fleet-cards { gap: 8px; }
  .fleet-card-body {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 10px;
    padding: 10px 12px 2px;
  }
  .fleet-card-head { flex: 1 1 100%; margin-bottom: 0; }
  .fleet-card-select { font-size: 14px; }
  /* Sensor ID and location share one line. */
  .fleet-card-body > .fleet-card-id { flex: 0 1 auto; margin: 0; min-width: 0; }
  .fleet-card-location { flex: 1 1 0; margin: 0; min-width: 0; }
  /* Readings side by side, each with its graph underneath. */
  .fleet-card .fleet-readings,
  .fleet-card .fleet-card-reading { flex: 1 1 100%; margin: 8px 0 6px; }
  .fleet-card .fleet-readings { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
  .fleet-card .fleet-readings[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
  .fleet-card .fleet-reading { grid-template-columns: minmax(0, 1fr); row-gap: 0; align-content: start; }
  .fleet-card .fleet-reading-value,
  .fleet-card .fleet-readings[data-count="1"] .fleet-reading-value { font-size: 18px; line-height: 1.25; }
  .fleet-card .fleet-reading-levels { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .fleet-card .fleet-mini,
  .fleet-card .fleet-readings[data-count="1"] .fleet-mini { grid-column: 1; grid-row: 4; width: 100%; height: 26px; margin-top: 4px; }
  .fleet-card-detail { flex: 1 1 100%; margin-bottom: 4px; }
  /* Connection state and the links share the last line. */
  .fleet-card-meta { flex: 1 1 auto; margin-top: 0; padding-bottom: 0; justify-content: flex-start; gap: 10px; }
  .fleet-card-actions { flex: 0 0 auto; padding: 0; gap: 4px; }
  .fleet-card-actions > div { gap: 14px; }
}

/* =====================================================================
   Startup screen and admin button (2026-11-14)
   ===================================================================== */

/* ---- Startup: a vibration trace being drawn, no card ---- */
.startup-card {
  width: min(300px, calc(100vw - 48px));
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  text-align: center;
  animation: startup-rise 420ms ease-out both;
}
.startup-card::before { display: none; }
.startup-wave { display: block; width: 100%; height: auto; overflow: visible; }
.startup-wave path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.startup-wave-base { stroke: color-mix(in srgb, var(--accent) 22%, transparent); stroke-width: 1.5; }
.startup-wave-run {
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-dasharray: 26 74;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 65%, transparent));
  animation: startup-trace 1.7s linear infinite;
}
.startup-kicker { margin: 0; color: var(--text-strong); font-size: 11px; letter-spacing: 0.22em; }
.startup-status { min-height: 16px; margin: 8px 0 0; font-size: 12px; }
.startup-status::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: startup-dots 1.4s steps(1, end) infinite;
}
@keyframes startup-trace { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes startup-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes startup-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@media (prefers-reduced-motion: reduce) {
  .startup-card, .startup-wave-run, .startup-status::after { animation: none; }
  .startup-wave-run { stroke-dasharray: none; }
}

/* ---- Admin login: a real button at the foot of the menu ---- */
.admin-access-section { margin-top: auto; padding-top: 14px; }
.admin-access-section .nav-item.admin-access-link {
  padding: 11px 12px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--text-strong);
  font-weight: 600;
  border-radius: 3px;
  transition: background 130ms ease, transform 130ms ease;
}
.admin-access-link .nav-item-icon { color: var(--accent); }
.admin-access-link .admin-lock-open { display: none; }
.admin-access-arrow { font-size: 17px; line-height: 1; color: var(--accent); transition: transform 130ms ease; }
.admin-access-section .nav-item.admin-access-link:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.admin-access-link:hover .admin-access-arrow { transform: translateX(3px); }
.admin-access-link:active { transform: scale(0.985); }
/* Signed in: quiet, so logging out is available but not inviting. */
body.admin-authenticated .admin-access-section .nav-item.admin-access-link {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
body.admin-authenticated .admin-access-link .nav-item-icon { color: var(--normal-fg); }
body.admin-authenticated .admin-access-link .admin-lock-closed,
body.admin-authenticated .admin-access-arrow { display: none; }
body.admin-authenticated .admin-access-link .admin-lock-open { display: inline; }
body.admin-authenticated .admin-access-section .nav-item.admin-access-link:hover { background: var(--control-hover); color: var(--text-strong); }
@media (max-width: 900px) {
  .nav-list .admin-access-section .nav-item.admin-access-link {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    min-height: 46px;
    gap: 10px;
    font-size: 13px;
  }
  .admin-access-link .nav-item-icon, .admin-access-link .nav-item-icon svg { width: 18px; height: 18px; }
}

/* =====================================================================
   Pattern Recognizer, calm pass (2026-11-14)
   One surface: no frame inside a frame, nothing said twice.
   ===================================================================== */
/* Head: a plain line. The sensor is already named in the bar above. */
#pane-ai-classifier .rx-head { padding: 4px 2px 0; border: 0; background: transparent; align-items: center; }
#pane-ai-classifier .rx-status { padding: 0; border: 0; background: transparent; }
#pane-ai-classifier .rx-status .ai-model-sensor { display: none; }
#pane-ai-classifier .rx-status .ai-status-chip { border: 0; background: transparent; padding: 0; }
/* Not ready: the headline says it; drop the kicker and the dashed box. */
#pane-ai-classifier .rx-card[data-state="not_ready"] .rx-kicker { display: none; }
.rx-cta { padding: 0; border: 0; background: transparent; }
.rx-cta p:last-child { margin-bottom: 0; }
#pane-ai-classifier .rx-card[data-state="not_ready"] .rx-details { display: none; }
/* Facts and axis readouts: values on the surface, spaced, not boxed. */
.rx-facts { border: 0; background: transparent; gap: 0 28px; }
.rx-fact { padding: 0; }
.rx-fact + .rx-fact { border-left: 0; }
.rx-axes { border: 0; gap: 0 18px; }
.rx-axis { padding: 0; }
.rx-axis + .rx-axis { border-left: 0; }
.rx-axis strong { font-size: 13px; }
/* Visualizer: same surface as the verdict; the active button already names the scale. */
.rx-motion { background: transparent; gap: 14px; }
#pane-ai-classifier .rx-scope-wrap { background: transparent; box-shadow: none; }
.rx-scale-label { display: none; }
.rx-hero { border-bottom: 0; }
#pane-ai-classifier .rx-ranking .ai-signature-grid { border-bottom: 0; }
#pane-ai-classifier .rx-ranking .ai-signature-badge,
#pane-ai-classifier .rx-ranking .ai-signature-warning { border: 0; padding: 0; }
@media (max-width: 1100px) { .rx-motion { border-top: 0; } }
@media (max-width: 600px) {
  .rx-fact { padding: 0; }
  .rx-facts { gap: 0 16px; }
  .rx-axes { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 10px; }
  .rx-axis:nth-child(n+3) { border-top: 0; }
  .rx-axis strong { font-size: 12px; }
}
/* The verdict headline already states readiness; the head line repeated it. */
#pane-ai-classifier .rx-head { display: none; }

/* 6-Month History: the panel is a flex child of a fixed-height pane and was
   allowed to shrink below its content, so the chart's time axis spilled out
   past the panel's background. Let the pane scroll instead. */
.hourly-history-panel { flex-shrink: 0; }
/* Last checks: plain words in a row, the newest one stronger. No chip frames. */
#pane-ai-classifier .rx-history .ai-recent-chip { padding: 0; border: 0; background: transparent; box-shadow: none; color: var(--muted); font-size: 12px; }
#pane-ai-classifier .rx-history .ai-recent-chip-new { color: var(--text-strong); font-weight: 700; }
#pane-ai-classifier .rx-history .ai-chip-fallback { color: var(--warning-fg); }
#pane-ai-classifier .rx-history .ai-recent-list { gap: 2px 6px; }
/* Show the six most recent checks (chip, arrow, chip ...). */
#pane-ai-classifier .rx-history .ai-recent-list > :nth-last-child(n+12) { display: none; }

/* =====================================================================
   Sensor card status band (2026-11-14)
   The card's title band is tinted with its status colour: the whole top of
   the card says normal / warning / critical, where a side stripe only
   suited table rows. Flat tint, no gradient.
   ===================================================================== */
.fleet-card .fleet-card-head {
  margin: -12px -14px 10px;
  padding: 10px 14px;
  align-items: center;
  background: color-mix(in srgb, var(--tone) 15%, var(--panel-2));
}
.fleet-card.active .fleet-card-head { background: color-mix(in srgb, var(--tone) 22%, var(--panel-2)); }
.fleet-card-head .status-pill { margin-top: 0; }
@media (max-width: 600px) {
  .fleet-card .fleet-card-head { flex: 1 1 calc(100% + 24px); margin: -10px -12px 6px; padding: 8px 12px; }
}

/* =====================================================================
   Flat surfaces (2026-11-15)
   Neutral border lines are now invisible (--line / --line-2, see :root);
   boxes are told apart by a flat background fill instead of an outline,
   and the decorative side stripes, dots and hairline grids are gone.
   ===================================================================== */
body {
  /* One "raised" fill for controls and inner boxes, derived from the theme. */
  --fill: color-mix(in srgb, var(--text-strong) 6%, var(--panel));
  --fill-hover: color-mix(in srgb, var(--text-strong) 11%, var(--panel));
  --control-bg: var(--fill);
  --control-hover: var(--fill-hover);
  --input-bg: var(--fill);
}

/* Hairline grids drawn with a background behind 1px gaps */
.nav-group-label::after,
.pane-grid, .kpi-strip, .indicator-grid, .device-config-summary,
.metric-status-grid, .system-health-grid, .report-status-grid, .event-log-chips,
#pane-ai-classifier .ai-prediction-card::before { background: transparent; }
.nav-group-label::after { display: none; }

/* Decorative side stripes */
.panel-header, .iso-ref.is-applicable > .panel-header,
.overall-health-row, .vs-toast,
.ai-signature-card-closest, .ai-signature-card-matched, .ai-signature-card-ambiguous,
#pane-ai-classifier .ai-signature-card-closest, #pane-ai-classifier .ai-signature-card-matched,
#pane-ai-classifier .rx-ranking .ai-signature-card-matched,
#pane-ai-classifier .rx-ranking .ai-signature-card-ambiguous,
.ai-workflow-card.is-active, .nav-item.active,
.iso-table tr.is-current td:first-child { box-shadow: none; }
.overall-health-row, .ai-decision-engine, .ai-intro, .whats-this-body,
.iso-ivss-note, .iso-result-line, #pane-ai-classifier .rx-head { border-left-color: transparent; }
/* ...replaced by fills where the stripe carried meaning */
.ai-signature-card-matched, #pane-ai-classifier .rx-ranking .ai-signature-card-matched { background: var(--normal-bg); }
.ai-signature-card-ambiguous, #pane-ai-classifier .rx-ranking .ai-signature-card-ambiguous { background: var(--warning-bg); }
.ai-workflow-card.is-active { background: var(--normal-bg); }
.iso-table tr.is-current td { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text-strong); }

/* Sensor bar: name on a flat band. No stripe, no dot, no underline. */
.sensor-bar { border-bottom: 0; box-shadow: none; background: var(--panel-2); padding-left: 16px; }
.sensor-bar-dot { display: none; }
.sensor-bar-change { border-color: transparent; background: var(--fill); }
.sensor-bar-change:hover { border-color: transparent; background: var(--fill-hover); }

/* Status pills and chips: tinted fill, no outline */
.status-pill, .appbar-pill, .pill, .chip, .badge,
.status-normal, .status-warning, .status-danger, .status-critical { border-color: transparent !important; }

/* Inner boxes that relied on an outline now sit on the raised fill */
.iso-position .iso-card, .iso-empty, .iso-ivss-note, .iso-result-line,
.ai-workflow-card, .recording-step, .whats-this, details.whats-this,
.trend-status, .ai-intro, #pane-ai-classifier .rx-head { background: var(--fill); }

/* Pattern Setup: active step is a fill, not an outline; step numbers are plain tiles */
.ai-workflow-card.is-active { border-color: transparent; }
.ai-workflow-node { border-color: transparent; }
/* The main action on a form reads as a filled accent button, not an outlined box */
#recordToggleBtn, .rx-cta-btn, [data-iso-classify-live], [data-iso-classify] {
  border-color: transparent;
  background: color-mix(in srgb, var(--accent) 24%, var(--panel));
  color: var(--text-strong);
}
#recordToggleBtn:hover, .rx-cta-btn:hover, [data-iso-classify-live]:hover, [data-iso-classify]:hover {
  background: color-mix(in srgb, var(--accent) 34%, var(--panel));
}
.iso-empty { padding: 12px 14px; }
.iso-empty p { margin: 0; }

/* =====================================================================
   Selected sensor: no outline, no wash, no stripe. The selected sensor's
   name turns accent and carries a filled check badge, in cards and rows.
   ===================================================================== */
.fleet-card.active { background: var(--panel-2); box-shadow: none; }
.fleet-card.active .fleet-card-head { background: color-mix(in srgb, var(--tone) 15%, var(--panel-2)); }
.fleet-card:not(.active):hover { background: var(--panel-2); }
.fleet-card.active .fleet-card-select,
.asset-row.active .sensor-name { color: var(--accent); }
/* Rows: no selection frame or stripe, no per-cell fills */
.asset-row.active,
.asset-table tr.asset-row.active,
.asset-table tr.asset-row.active td { background: transparent; box-shadow: none; border-left-color: transparent; }
/* Table rows: the Severity column already shows status, so no side stripe. */
.asset-row, .asset-row.active { box-shadow: none; }
/* Stacked rows on phones and tablets look like the cards: one flat surface,
   no status stripe, sparkline without a frame. */
@media (max-width: 1024px) {
  .asset-table tr.asset-row,
  .asset-table tr.asset-row.active { background: var(--panel-2); box-shadow: none; border-color: transparent; }
  .asset-table tr.asset-row td { background: transparent; }
}
.fleet-mini { border-color: transparent; }
.fleet-delete-btn { border-color: transparent; }

/* Notices are fills, not framed boxes */
.iso-managed-note { border-color: transparent; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }

/* =====================================================================
   Vibration report wizard (2026-11-15). Flat fills, no outlines.
   ===================================================================== */
#hourlyReportPdf { background: color-mix(in srgb, var(--accent) 26%, var(--panel)); color: var(--text-strong); }
#hourlyReportPdf:hover { background: color-mix(in srgb, var(--accent) 38%, var(--panel)); }
#hourlyReportPdf .rep-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rep-overlay { position: fixed; inset: 0; z-index: 2100; display: grid; place-items: center; padding: 16px; background: rgba(4, 8, 12, 0.66); }
.rep-dialog { display: flex; flex-direction: column; width: min(460px, 100%); max-height: calc(100dvh - 32px); background: var(--panel); border-radius: 3px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5); overflow: hidden; animation: rep-in 160ms ease-out both; }
@keyframes rep-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rep-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 6px; }
.rep-head h2 { margin: 0; color: var(--text-strong); font-size: 18px; font-weight: 700; letter-spacing: 0; text-transform: none; }
.rep-sensor { margin: 4px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.rep-close { flex: none; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--fill); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; }
.rep-close:hover { background: var(--fill-hover); color: var(--text-strong); }
.rep-steps { display: flex; gap: 6px; margin: 0; padding: 12px 20px 4px; list-style: none; }
.rep-steps li { flex: 1 1 0; display: flex; align-items: center; gap: 8px; padding-top: 9px; border-top: 3px solid var(--fill-hover); color: var(--muted); font-size: 12px; font-weight: 600; }
.rep-steps li span { display: none; }
.rep-steps li.is-done { border-top-color: color-mix(in srgb, var(--accent) 55%, var(--panel)); color: var(--text); }
.rep-steps li.is-current { border-top-color: var(--accent); color: var(--text-strong); }
.rep-body { flex: 1 1 auto; min-height: 212px; padding: 16px 20px 6px; overflow-y: auto; }
.rep-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rep-chip, .rep-tile, .rep-btn { border: 0; font: inherit; cursor: pointer; color: var(--text); background: var(--fill); transition: background 120ms ease, color 120ms ease; }
.rep-chip { min-height: 46px; padding: 0 8px; border-radius: 3px; font-size: 13px; font-weight: 600; }
.rep-chip:hover, .rep-tile:hover:not(:disabled) { background: var(--fill-hover); }
.rep-chip.is-on { background: var(--accent); color: var(--control-active-text, #071018); }
.rep-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.rep-dates[hidden] { display: none; }
.rep-dates label, .rep-form label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; }
.rep-dates input, .rep-form input, .rep-form textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 3px; background: var(--fill); color: var(--text-strong); font: inherit; font-size: 13px; color-scheme: inherit; }
.rep-form textarea { min-height: 72px; resize: vertical; }
.rep-range { margin: 16px 0 0; color: var(--text-strong); font-size: 13px; font-variant-numeric: tabular-nums; }
.rep-group { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.rep-tiles + .rep-group { margin-top: 16px; }
.rep-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rep-tile { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: 3px; font-size: 13px; text-align: left; }
.rep-tile small { display: block; color: var(--muted); font-size: 10.5px; }
.rep-tile:disabled { opacity: 0.5; cursor: not-allowed; }
.rep-check { flex: none; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 3px; background: var(--fill-hover); }
.rep-tile.is-on { background: color-mix(in srgb, var(--accent) 20%, var(--panel)); color: var(--text-strong); }
.rep-tile.is-on .rep-check { background: var(--accent); }
.rep-tile.is-on .rep-check::after { content: ""; width: 9px; height: 5px; margin-top: -2px; border-left: 2px solid var(--control-active-text, #071018); border-bottom: 2px solid var(--control-active-text, #071018); transform: rotate(-45deg); }
.rep-form { display: grid; gap: 12px; }
.rep-error { margin: 0; padding: 4px 20px 0; color: var(--critical-fg); font-size: 12px; }
.rep-foot { display: flex; justify-content: space-between; gap: 10px; padding: 14px 20px 20px; }
.rep-btn { min-height: 42px; padding: 0 18px; border-radius: 3px; font-size: 13px; font-weight: 700; }
.rep-btn:hover:not(:disabled) { background: var(--fill-hover); }
.rep-btn[hidden] { display: none; }
.rep-btn-primary { margin-left: auto; min-width: 132px; background: var(--accent); color: var(--control-active-text, #071018); }
.rep-btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, var(--text-strong)); }
.rep-btn:disabled { cursor: default; opacity: 0.75; }
.rep-btn.is-busy { background: var(--fill-hover); color: var(--text-strong); }
.rep-dialog :is(button, input, textarea):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 600px) {
  .rep-overlay { padding: 0; place-items: end stretch; }
  .rep-dialog { width: 100%; max-height: 92dvh; border-radius: 3px 3px 0 0; }
  .rep-foot { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .rep-dialog { animation: none; } }

/* =====================================================================
   Phone dialogs and Safari's toolbar (2026-11-15)
   iOS Safari draws its bottom toolbar over the page. With viewport-fit=cover
   the toolbar's height arrives as env(safe-area-inset-bottom); every dialog
   footer pads by it so its buttons sit above the toolbar, not under it.
   ===================================================================== */
@media (max-width: 560px) {
  .iso-wizard-overlay { padding: 0; place-items: stretch; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
  .iso-wizard { width: 100%; height: 100%; max-height: 100%; min-height: 0; }
  .iso-wizard-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); gap: 8px; }
  .iso-wizard-foot .btn { flex: 1 1 0; min-width: 0; }
  .iso-wizard-remove { order: 3; flex-basis: 100% !important; }
}
@media (max-width: 600px) {
  .rep-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}

/* =====================================================================
   ISO classification wizard without outlines (2026-11-15)
   Same language as the sensor cards: flat fills, selection shown by a tint
   and the filled radio, notices as tinted bands. No borders anywhere.
   ===================================================================== */
.iso-wizard, .iso-wizard * { border-color: transparent !important; }
.iso-wizard-close { background: var(--fill); border-radius: 50%; }
.iso-wizard-close:hover { background: var(--fill-hover); color: var(--text-strong); }
.iso-wizard-steps li span { background: var(--fill); }
.iso-wizard-steps li.is-done span { background: color-mix(in srgb, var(--accent) 24%, var(--panel)); color: var(--text-strong); }
.iso-choice { background: var(--fill); }
.iso-choice:hover { background: var(--fill-hover); }
.iso-choice.is-selected { background: color-mix(in srgb, var(--accent) 20%, var(--panel)); }
.iso-choice.is-selected strong { color: var(--accent); }
.iso-toggle-row { background: var(--fill); }
.iso-limits-box { background: var(--fill); }
.iso-input em { background: var(--fill-hover); }
.iso-callout { background: var(--fill); }
.iso-callout.is-caution { background: var(--warning-bg); }
.iso-callout.is-note { background: var(--normal-bg); }
.iso-wizard-foot .btn { background: var(--fill); color: var(--text); }
.iso-wizard-foot .btn:hover:not(:disabled) { background: var(--fill-hover); color: var(--text-strong); }
.iso-wizard-foot [data-iso-next] { background: var(--accent); color: var(--control-active-text, #071018); }
.iso-wizard-foot [data-iso-next]:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, var(--text-strong)); color: var(--control-active-text, #071018); }
.iso-wizard-foot .iso-wizard-remove { color: var(--critical-fg); }

/* Pattern Setup flow: flat step cards. The dashed cable/arrow layer bled
   through the tinted active card, so it is gone; order is carried by the
   step numbers. No outlines, rings or lift on hover, done steps read as a
   filled green tile with a check instead of an outlined tile. */
.ai-workflow-cables { display: none; }
.ai-workflow-card,
.ai-workflow-card:hover,
.ai-workflow-card:focus-visible,
.ai-workflow-card.is-active,
.ai-workflow-card.is-drop-target { border-color: transparent; box-shadow: none; transform: none; }
.ai-workflow-card:hover,
.ai-workflow-card:focus-visible { background: var(--fill-hover); }
.ai-workflow-card.is-active,
.ai-workflow-card.is-active:hover { background: color-mix(in srgb, var(--normal) 16%, var(--panel)); }
.ai-workflow-card.is-drop-target { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); }
.ai-workflow-card:active { transform: none; }
.ai-workflow-node,
.ai-workflow-card.is-complete .ai-workflow-node { border: 0; }
.ai-workflow-card.is-complete .ai-workflow-node {
  background: color-mix(in srgb, var(--normal) 55%, var(--panel));
  color: transparent;
}
.ai-workflow-card.is-complete .ai-workflow-node::after {
  inset: 0;
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-strong);
  font-size: 14px;
}
.ai-workflow-badge { border-color: transparent; background: color-mix(in srgb, var(--normal) 22%, var(--panel)); }
.whats-this > summary,
.whats-this:hover > summary { border-color: transparent; }
.whats-this > summary::before { border-color: transparent; background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* ISO wizard: rendered cut-away illustrations on the asset/mounting cards.
   The radio stays for keyboard/screen readers but is visually replaced by a
   ✓ tile, matching the selection language elsewhere. */
.iso-choice.has-art { flex-direction: column; gap: 0; padding: 10px 12px 12px; }
.iso-choice.has-art input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.iso-choice.has-art > span { width: 100%; }
.iso-art { position: relative; display: block; width: 100%; max-width: 208px; aspect-ratio: 16 / 10; margin: 0 auto 8px; }
.iso-art img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.22)); transition: transform 0.25s ease; }
.iso-choice.has-art:hover .iso-art img { transform: translateY(-2px); }
.iso-choice.has-art::after {
  content: "✓"; position: absolute; top: 8px; right: 8px; width: 20px; height: 20px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--accent); color: var(--control-active-text, #06110c);
  opacity: 0; transform: scale(0.6); transition: opacity 0.15s ease, transform 0.15s ease;
}
.iso-choice.has-art.is-selected::after { opacity: 1; transform: scale(1); }
.iso-choice.has-art,
.iso-choice.has-art.is-selected { border-color: transparent; outline: none; }
.iso-choice.has-art:has(input:focus-visible) { background: var(--fill-hover); }
.iso-choice.has-art.is-selected:has(input:focus-visible) { background: color-mix(in srgb, var(--accent) 26%, var(--panel)); }
@media (max-width: 560px) {
  .iso-choice.has-art { flex-direction: row; }
  .iso-choice.has-art > span { display: grid; grid-template-columns: 112px 1fr; column-gap: 12px; align-items: center; }
  .iso-art { grid-row: span 3; margin: 0; }
  .iso-choice.has-art > span > :not(.iso-art) { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { .iso-art img, .iso-choice.has-art::after { transition: none; } }

/* Help videos: "?" in the top bar opens the page's walkthrough in a popup. */
.help-btn {
  -webkit-appearance: none; appearance: none;
  flex: 0 0 auto; align-self: center;
  width: 32px; height: 32px; margin: 0 10px 0 auto; padding: 0;
  border: 0; border-radius: 1px;
  background: var(--panel-2); color: var(--text-strong);
  font: 700 15px/32px var(--font-ui); text-align: center; cursor: pointer;
}
.help-btn[hidden] { display: none; }
.alarm-btn:not([hidden]) ~ .help-btn { margin-left: 0; }
.alarm-btn:not([hidden]):has(~ .help-btn:not([hidden])) { margin-right: 6px; }
.help-btn:hover { background: var(--fill-hover); }
.help-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
@media (max-width: 900px) {
  .appbar.has-help { grid-template-columns: 44px minmax(0, 1fr) 40px; }
  .appbar.has-help .help-btn { grid-column: 3; grid-row: 1; margin: 0 4px; justify-self: center; }
  .appbar.has-help.has-alarm { grid-template-columns: 44px minmax(0, 1fr) 40px 40px; }
  .appbar.has-help.has-alarm .alarm-btn { grid-column: 3; margin: 0 4px; }
  .appbar.has-help.has-alarm .help-btn { grid-column: 4; }
}
.help-video {
  width: min(1100px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 2px;
  background: var(--panel); color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.help-video::backdrop { background: rgba(4, 7, 11, 0.72); }
.help-video-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; }
.help-video-title { color: var(--text-strong); font-size: 14px; letter-spacing: 0.02em; }
.help-video-tabs { display: flex; gap: 4px; margin-left: auto; }
.help-video-tabs button {
  border: 0; border-radius: 1px; padding: 6px 10px; cursor: pointer;
  background: var(--fill); color: var(--muted); font: 600 11px var(--font-ui); letter-spacing: 0.04em; text-transform: uppercase;
}
.help-video-tabs button[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 22%, var(--panel)); color: var(--text-strong); }
.help-video-close {
  width: 32px; height: 32px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--fill); color: var(--text-strong); font-size: 18px; line-height: 32px;
}
.help-video-tabs:empty + .help-video-close { margin-left: auto; }
.help-video-close:hover, .help-video-tabs button:hover { background: var(--fill-hover); }
.help-video-player { display: block; width: 100%; max-height: calc(100dvh - 92px); background: #000; aspect-ratio: 16 / 9; }
@media (max-width: 560px) {
  .help-video { width: 100vw; max-width: 100vw; max-height: 100dvh; margin: auto 0; border-radius: 0; }
  .help-video-head { flex-wrap: wrap; }
}

/* ===== Assets: machines with their sensors on numbered locations ===== */
.assets-grid { grid-template-columns: minmax(0, 1fr); }
.asset-add-btn { margin-left: auto; }
.asset-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.asset-card { padding: 0; overflow: hidden; }
.asset-card-open {
  display: block; width: 100%; padding: 10px 12px 0; border: 0; background: transparent; cursor: pointer;
}
.asset-card .fleet-card-body { padding-top: 6px; }
.asset-card .fleet-card-id { margin-bottom: 8px; }
.asset-card-iso { margin: 6px 0 12px; color: var(--muted); font-size: 11px; }
.asset-card.active::after {
  content: "✓"; position: absolute; top: 8px; right: 8px; width: 20px; height: 20px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--accent); color: var(--control-active-text, #06110c);
}
.asset-card { position: relative; }
.fleet-card-state.pill-neutral .fleet-card-dot { background: var(--muted-2); }
.fleet-card-state.pill-offline .fleet-card-dot { background: var(--muted-2); }

.asset-art { position: relative; display: block; width: 100%; aspect-ratio: 16 / 10; }
.asset-art img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.22)); }
.asset-art-lg { max-width: 760px; }
.asset-pin {
  position: absolute; transform: translate(-50%, -50%); z-index: 1;
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center;
  font: 700 11px/1 var(--font-ui); font-variant-numeric: tabular-nums;
  background: var(--normal); color: #06110c;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--normal) 28%, transparent);
}
.asset-art-sm .asset-pin { width: 16px; height: 16px; font-size: 9px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--normal) 28%, transparent); }
.asset-pin.is-warning { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 30%, transparent); }
.asset-pin.is-danger { background: var(--critical); color: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--critical) 30%, transparent); }
.asset-pin.is-offline { background: var(--muted-2); color: var(--panel); box-shadow: none; }
.asset-pin.is-empty { background: var(--panel-2); color: var(--muted); box-shadow: none; }
button.asset-pin { cursor: pointer; }
button.asset-pin:hover { transform: translate(-50%, -50%) scale(1.12); }
button.asset-pin:focus-visible { outline: 2px solid var(--text-strong); outline-offset: 2px; }

.asset-detail .panel-meta { margin-left: 10px; }
.asset-detail-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
.asset-detail-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.asset-detail-cond { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0; color: var(--muted); font-size: 12px; }
.asset-locs, .asset-place-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.asset-locs > li { margin: 0; }
.asset-loc {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-areas: "num name value" "num sensor value";
  column-gap: 10px; align-items: center; padding: 8px 10px; background: var(--fill);
}
.asset-loc-num {
  grid-area: num; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--normal); color: #06110c;
}
.asset-loc.is-warning .asset-loc-num { background: var(--warning); }
.asset-loc.is-danger .asset-loc-num { background: var(--critical); color: #fff; }
.asset-loc.is-offline .asset-loc-num { background: var(--muted-2); color: var(--panel); }
.asset-loc.is-empty .asset-loc-num { background: var(--panel-2); color: var(--muted); }
.asset-loc-name { grid-area: name; color: var(--muted); font-size: 11px; }
.asset-loc-sensor {
  grid-area: sensor; justify-self: start; max-width: 100%; padding: 0; border: 0; background: none;
  color: var(--text-strong); font: 600 13px var(--font-ui); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
button.asset-loc-sensor { cursor: pointer; }
button.asset-loc-sensor:hover { color: var(--accent); }
.asset-loc.is-empty .asset-loc-sensor { color: var(--muted-2); font-weight: 400; }
.asset-loc-value { grid-area: value; color: var(--text-strong); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.asset-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.asset-detail-actions .asset-delete { margin-left: auto; }

/* Editor (shares the ISO wizard shell) */
.asset-type-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.asset-type-choices .iso-art { max-width: none; }
.asset-details { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 20px; align-items: center; }
.asset-details-fields { display: grid; gap: 14px; }
.asset-place { display: grid; gap: 14px; }
.asset-place .asset-art-lg { max-width: 560px; margin: 0 auto; }
.asset-place-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.asset-place-row { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: end; padding: 10px; background: var(--fill); }
.asset-place-row .asset-loc-num { grid-area: auto; align-self: end; margin-bottom: calc((var(--ctl-h) - 22px) / 2); background: var(--panel-2); color: var(--text-strong); }
.asset-place-field select { width: 100%; }

@media (max-width: 900px) {
  .asset-detail-body { grid-template-columns: minmax(0, 1fr); }
  .asset-type-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .asset-cards { grid-template-columns: minmax(0, 1fr); }
  .asset-type-choices { grid-template-columns: minmax(0, 1fr); }
  .asset-details { grid-template-columns: minmax(0, 1fr); }
  .asset-details-art { max-width: 240px; }
  .asset-place-list { grid-template-columns: minmax(0, 1fr); }
  .asset-pin { width: 18px; height: 18px; font-size: 10px; }
}
.asset-pin, button.asset-pin { min-width: 0; min-height: 0; line-height: 1; }
@media (max-width: 560px) { .asset-pin, button.asset-pin { width: 22px; height: 22px; } .asset-art-sm .asset-pin { width: 16px; height: 16px; } }
/* Location pins are always perfect circles. */
.asset-pin, button.asset-pin { box-sizing: border-box; aspect-ratio: 1 / 1; flex: none; border-radius: 50%; padding: 0; }
.asset-art-sm .asset-pin { width: 16px !important; height: 16px !important; }
.asset-art-lg .asset-pin { width: 22px !important; height: 22px !important; }
.asset-type-choices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .asset-type-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .asset-type-choices { grid-template-columns: minmax(0, 1fr); } }
.asset-cell { display: flex; align-items: center; gap: 12px; }
.asset-cell-text { display: flex; flex-direction: column; min-width: 0; }
.asset-thumb { flex: none; width: 112px; }
@media (max-width: 560px) { .asset-thumb { width: 88px; } }
.asset-type-group { margin: 0 0 18px; }
.asset-type-group h4 { margin: 0 0 8px; color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.asset-type-group .iso-choice small { font-size: 10.5px; }
.sensor-bar-asset {
  margin-left: 10px; padding: 3px 8px; border: 0; border-radius: 1px; cursor: pointer;
  background: var(--fill); color: var(--muted); font: 600 11px var(--font-ui);
  max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sensor-bar-asset:hover { background: var(--fill-hover); color: var(--text-strong); }
@media (max-width: 560px) {
  .asset-type-choices .iso-art { max-width: 132px; }
  .asset-card .asset-art { max-width: 300px; margin: 0 auto; }
  .sensor-bar-asset { max-width: 40%; }
}
/* ISO wizard, "Something else": ways forward instead of a dead end. */
.iso-next-ways { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 10px; }
.iso-way {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 0; border-radius: 1px;
  background: var(--fill); color: var(--text); text-align: left; cursor: pointer; font: inherit;
}
.iso-way strong { color: var(--text-strong); font-size: 13px; }
.iso-way small { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.iso-way:hover, .iso-way:focus-visible { background: color-mix(in srgb, var(--accent) 18%, var(--panel)); }
@media (max-width: 560px) { .iso-next-ways { grid-template-columns: minmax(0, 1fr); } }

/* Asset editor: each location opens a search popup instead of a dropdown. */
.asset-place-row { position: relative; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; }
.asset-place-row .asset-loc-num { margin-bottom: 0; align-self: center; }
.asset-place-row.is-set .asset-loc-num { background: var(--normal); color: #06110c; }
.asset-place-field { display: grid; gap: 4px; min-width: 0; }
.asset-place-label { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.asset-pick {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: center; column-gap: 10px;
  width: 100%; min-height: var(--ctl-h); padding: 6px 10px; border: 0; border-radius: 1px; cursor: pointer;
  background: var(--panel-2); color: var(--text-strong); font: inherit; text-align: left;
}
.asset-pick:hover, .asset-pick:focus-visible { background: var(--fill-hover); }
.asset-pick-name, .asset-pick-empty { grid-column: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-pick-empty { color: var(--muted); }
.asset-pick-id { grid-column: 1; color: var(--muted); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-pick-icon { grid-column: 2; grid-row: 1 / span 2; width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.asset-pick-clear { width: 30px; height: 30px; border: 0; border-radius: 50%; cursor: pointer; background: transparent; color: var(--muted); font-size: 13px; }
.asset-pick-clear:hover { background: var(--fill-hover); color: var(--text-strong); }

.sensor-picker-overlay { position: fixed; inset: 0; z-index: 2100; display: grid; place-items: start center; padding: 9vh 16px 16px; background: rgba(4, 7, 11, 0.55); }
.sensor-picker {
  width: min(620px, 100%); max-height: 78vh; display: flex; flex-direction: column;
  background: var(--panel); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.sp-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 6px 16px; }
.sp-head h3 { flex: 1; margin: 0; color: var(--text-strong); font-size: 14px; }
.sp-head .asset-loc-num { background: var(--panel-2); color: var(--text-strong); }
.sp-search { display: flex; align-items: center; gap: 10px; margin: 8px 16px 10px; padding: 0 14px; border-radius: 3px; background: var(--panel-2); }
.sp-search:focus-within { background: color-mix(in srgb, var(--accent) 12%, var(--panel-2)); }
.sp-search svg { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.sp-search input { flex: 1; min-width: 0; height: 44px; border: 0; outline: 0; background: transparent; color: var(--text-strong); font: 14px var(--font-ui); }
.sp-search input::-webkit-search-cancel-button { cursor: pointer; }
.sp-list { margin: 0; padding: 0 8px; list-style: none; overflow-y: auto; }
.sp-list li[data-index] { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 10px; cursor: pointer; }
.sp-list li.is-active { background: var(--fill-hover); }
.sp-list li.is-blocked { cursor: not-allowed; opacity: 0.5; }
.sp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.sp-dot.is-online { background: var(--normal); }
.sp-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sp-name { color: var(--text-strong); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-meta { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-list mark { background: transparent; color: var(--accent); font-weight: 700; }
.sp-check { width: 20px; height: 20px; display: grid; place-items: center; background: var(--accent); color: var(--control-active-text, #06110c); font-size: 12px; font-weight: 700; }
.sp-none { padding: 18px 10px; color: var(--muted); font-size: 13px; }
.sp-foot { margin: 0; padding: 10px 18px 14px; color: var(--muted); font-size: 11px; }
@media (max-width: 560px) {
  .sensor-picker-overlay { padding: 0; place-items: stretch; }
  .sensor-picker { width: 100%; max-height: none; height: 100dvh; }
}
.sp-search input, .sp-search input:focus, .sp-search input:focus-visible { border: 0 !important; outline: 0 !important; box-shadow: none !important; background: transparent !important; }
.asset-pick, .asset-pick:focus, .asset-pick:focus-visible { border: 0 !important; outline: 0 !important; box-shadow: none !important; }
.asset-pick:focus-visible { background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); }

/* ===================== ASSET WORKSPACE ===================== */
/* Menu items whose pages now live inside an asset (its tabs). */
.nav-item[hidden], .nav-section[hidden] { display: none !important; }

.asset-ws { flex: none; position: sticky; top: 0; z-index: 45; background: var(--panel-hdr, var(--panel)); border-bottom: 1px solid var(--line-2); }
.asset-ws[hidden] { display: none; }
.asset-ws-top { display: flex; align-items: center; gap: 14px; padding: 10px 16px 6px; min-width: 0; }
.asset-ws-back {
  flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px 6px 6px; min-height: 0;
  border: 1px solid var(--line-2); background: var(--control-bg); color: var(--text); font: inherit; font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; border-radius: 3px;
}
.asset-ws-back svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.asset-ws-back:hover { border-color: var(--accent); color: var(--text-strong); }
.asset-ws-thumb { flex: none; width: 76px; }
.asset-ws-thumb .asset-pin { width: 11px; height: 11px; font-size: 0; border-width: 1px; }
.asset-ws-title { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.asset-ws-title h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: 0.02em; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-ws-title span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-ws-top > .fleet-card-state { flex: none; font-size: 10px; }

.asset-ws-tabs { display: flex; gap: 2px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.asset-ws-tabs::-webkit-scrollbar { display: none; }
.asset-ws-tab {
  flex: none; min-height: 0; padding: 10px 14px 9px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
}
.asset-ws-tab:hover { color: var(--text-strong); }
.asset-ws-tab.is-current { color: var(--text-strong); border-bottom-color: var(--accent); }
.asset-ws-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.asset-ws-locs { display: flex; gap: 6px; padding: 8px 16px 10px; overflow-x: auto; border-top: 1px solid var(--line); scrollbar-width: thin; }
.asset-ws-loc {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 0; max-width: 240px; padding: 5px 10px 5px 6px;
  border: 1px solid var(--line-2); border-radius: 3px; background: var(--control-bg); color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
.asset-ws-loc:hover { border-color: var(--accent); }
.asset-ws-loc.is-current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--control-bg)); box-shadow: 0 0 0 1px var(--accent) inset; }
.asset-ws-loc .asset-loc-num { flex: none; }
.asset-ws-loc.is-warning .asset-loc-num { background: var(--warning); }
.asset-ws-loc.is-danger .asset-loc-num { background: var(--critical); color: #fff; }
.asset-ws-loc.is-offline .asset-loc-num { background: var(--muted-2); color: var(--panel); }
.asset-ws-loc-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.asset-ws-loc-text span { font-size: 12px; font-weight: 700; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-ws-loc-text small { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-ws-own { flex: none; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); border: 1px solid var(--accent); border-radius: 3px; padding: 1px 4px; }

/* Inside an asset its header names the sensor; the per-page sensor bar would repeat it. */
body.asset-ws-on .tab-pane > .sensor-bar { display: none; }
/* Assets page: the list, or (inside an asset) its Overview. */
body.asset-ws-on #pane-assets .asset-inventory { display: none; }
body:not(.asset-ws-on) #assetLimitScope,
body:not(.asset-ws-on) #assetPatterns,
body:not(.asset-ws-on) #assetIsoZones,
body:not(.asset-ws-on) .asset-ws-empty { display: none; }
body:not(.asset-ws-nosensors) .asset-ws-empty { display: none; }
body.asset-ws-on.asset-ws-nosensors #pane-condition-status > :not(.asset-ws-empty),
body.asset-ws-on.asset-ws-nosensors #pane-iso-severity > :not(.asset-ws-empty),
body.asset-ws-on.asset-ws-nosensors #pane-manual-threshold > :not(.asset-ws-empty),
body.asset-ws-on.asset-ws-nosensors #pane-ai-classifier > :not(.asset-ws-empty),
body.asset-ws-on.asset-ws-nosensors #pane-ai-configuration > :not(.asset-ws-empty) { display: none !important; }
.asset-ws-empty h3 { margin: 0; font-size: 16px; color: var(--text-strong); }
#pane-assets .asset-detail .panel-header { display: none; }

/* A page that belongs to an asset, opened for a sensor that is on none. */
body:not(.asset-needed) .asset-needed-note { display: none; }
body.asset-needed #pane-manual-threshold > :not(.asset-needed-note):not(.sensor-bar),
body.asset-needed #pane-ai-classifier > :not(.asset-needed-note):not(.sensor-bar),
body.asset-needed #pane-ai-configuration > :not(.asset-needed-note):not(.sensor-bar) { display: none !important; }
.asset-needed-note .panel-body, .asset-ws-empty .panel-body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 22px; }
.asset-needed-note h3 { margin: 0; font-size: 16px; color: var(--text-strong); }
.asset-needed-note p, .asset-ws-empty p { margin: 0; color: var(--muted); max-width: 60ch; }

/* ISO tab: zones of every location */
.asset-iso-zones .panel-header { display: flex; align-items: center; gap: 12px; }
.asset-iso-btn { margin-left: auto; }
.asset-iso-table td { vertical-align: middle; }
.asset-iso-table td:first-child { display: flex; align-items: center; gap: 8px; }
.asset-iso-detail, .ap-detail-note { margin: 10px 0 0; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }

/* Thresholds tab: which limits the form edits */
.asset-limit-scope .panel-body { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.als-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.als-option { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--control-bg); cursor: pointer; }
.als-option:hover { border-color: var(--accent); }
.als-option.is-current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--control-bg)); }
.als-option input { margin: 3px 0 0; accent-color: var(--accent); }
.als-option span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.als-option strong { color: var(--text-strong); font-size: 13px; }
.als-option small { color: var(--muted); font-size: 12px; }
.als-status { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0; color: var(--muted); font-size: 12px; }

/* Patterns tab: every location's model */
.asset-patterns .panel-body { display: flex; flex-direction: column; gap: 12px; }
.ap-state { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; padding: 12px 14px; border: 1px solid var(--line-2); border-left: 4px solid var(--accent); border-radius: 3px; background: var(--panel-2); }
.ap-state-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.ap-state-label { font-size: 20px; font-weight: 800; color: var(--text-strong); }
.ap-state-label.is-special { color: var(--muted); font-size: 16px; }
.ap-state > span:last-child { color: var(--muted); font-size: 12px; }
.ap-locs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.ap-loc-btn {
  width: 100%; min-height: 0; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-areas: "num text pat" "num status status";
  gap: 4px 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--control-bg); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.ap-loc-btn:hover { border-color: var(--accent); }
.ap-loc.is-current .ap-loc-btn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.ap-loc-btn .asset-loc-num { grid-area: num; }
.ap-loc-text { grid-area: text; display: flex; flex-direction: column; min-width: 0; }
.ap-loc-name { font-size: 13px; font-weight: 700; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-loc-text small { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-loc-pattern { grid-area: pat; display: inline-flex; align-items: baseline; gap: 4px; font-size: 13px; font-weight: 800; color: var(--text-strong); }
.ap-loc-pattern small { font-size: 10px; font-weight: 600; color: var(--muted); }
.ap-loc-pattern.is-special, .ap-loc-pattern.is-none { color: var(--muted); font-weight: 600; }
.ap-loc-status { grid-area: status; font-size: 11px; line-height: 1.35; color: var(--muted); }
.ap-admin { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.ap-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.ap-row-label { flex: none; width: 72px; font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.ap-row select { width: auto; min-width: 120px; }
.ap-labels { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-label { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border: 1px solid var(--line-2); border-radius: 3px; font-size: 12px; font-weight: 700; color: var(--text-strong); background: var(--panel-2); }
.ap-label button { min-height: 0; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; font-size: 11px; }
.ap-label button:hover:not(:disabled) { color: var(--critical); background: var(--fill-hover); }
.ap-add { display: flex; gap: 6px; }
.ap-add input { width: 200px; }
.ap-hint { flex-basis: 100%; margin-left: 82px; color: var(--muted); font-size: 11px; }
.ap-live { color: var(--warning); font-weight: 700; font-size: 12px; }
.ap-advanced { margin: 0; }
.linklike { min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

@media (max-width: 760px) {
  .asset-ws { position: static; }
  .asset-ws-top { gap: 10px; padding: 8px 12px 4px; }
  .asset-ws-back span { display: none; }
  .asset-ws-back { padding: 6px; }
  .asset-ws-thumb { width: 56px; }
  .asset-ws-title h2 { font-size: 17px; }
  .asset-ws-top > .fleet-card-state { display: none; }
  .asset-ws-tabs { padding: 0 4px; }
  .asset-ws-tab { padding: 10px 10px 9px; font-size: 11px; }
  .asset-ws-locs { padding: 8px 12px 10px; }
  .ap-row-label { width: 100%; }
  .ap-hint { margin-left: 0; }
  .ap-add { flex: 1 1 100%; }
  .ap-add input { flex: 1; width: auto; }
}
.als-option input[type="radio"] { flex: none; width: 16px; height: 16px; min-width: 0; min-height: 0; margin: 2px 0 0; padding: 0; border: 0; box-shadow: none; appearance: auto; -webkit-appearance: radio; background: none; }
/* Inside an asset the Patterns panel above owns setup; the location detail below keeps its live view. */
body.asset-ws-on #pane-ai-classifier .rx-head .rx-title,
body.asset-ws-on #pane-ai-classifier #aiSetupCta { display: none; }
body.asset-ws-on #pane-ai-classifier .rx-head { justify-content: flex-end; }

/* Patterns: the add-pattern field on phones */
@media (max-width: 760px) {
  .ap-add { display: flex; width: 100%; }
  .ap-add input { flex: 1 1 auto; min-width: 0; width: auto; }
  .ap-add .btn { flex: none; width: auto !important; min-width: 72px; }
  /* ISO zones by location: one card per location instead of a wide table */
  .asset-iso-table thead { display: none; }
  .asset-iso-table, .asset-iso-table tbody { display: block; width: 100%; }
  .asset-iso-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "loc zone" "sensor zone" "vel zone"; gap: 2px 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
  .asset-iso-table td { display: block; padding: 0; border: 0; text-align: left; }
  .asset-iso-table td:nth-child(1) { grid-area: loc; font-weight: 700; color: var(--text-strong); }
  .asset-iso-table td:nth-child(2) { grid-area: sensor; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .asset-iso-table td:nth-child(3) { grid-area: vel; font-size: 13px; }
  .asset-iso-table td:nth-child(4) { grid-area: zone; align-self: center; }
  .asset-iso-zones .panel-header { flex-wrap: wrap; }
  /* Assets as a table on phones: one compact row card each */
  .assets-table thead { display: none; }
  .assets-table, .assets-table tbody { display: block; width: 100%; }
  .assets-table tr { display: grid; grid-template-columns: 112px auto minmax(0, 1fr); grid-template-areas: "art name name" "art cond cnt" "art iso iso"; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
  .assets-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .assets-table td::before { content: none !important; display: none !important; }
  .assets-table td.asset-cell { display: contents; }
  .assets-table .asset-thumb { grid-area: art; width: 112px; align-self: center; }
  .assets-table .asset-cell-text { grid-area: name; }
  .assets-table td[data-label="Condition"] { grid-area: cond; display: flex; align-items: center; gap: 10px; }
  .assets-table td[data-label="Sensors"] { grid-area: cnt; color: var(--muted); font-size: 12px; align-self: center; }
  .assets-table td[data-label="Sensors"]::after { content: " sensors"; }
  .assets-table td[data-label="ISO"] { grid-area: iso; color: var(--muted); font-size: 12px; }
  .assets-table .sensor-name { font-weight: 700; color: var(--text-strong); overflow-wrap: anywhere; }
  .assets-table .sensor-id { font-size: 11px; color: var(--muted); }
}

/* Sensors tab: location chips, and the Status / Trends switch for the chosen sensor */
.asset-ws-row { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); min-width: 0; }
.asset-ws-row > .asset-ws-locs { flex: 1 1 auto; min-width: 0; border-top: 0; }
.asset-ws-sub { flex: none; display: inline-flex; margin-right: 16px; border: 1px solid var(--line-2); border-radius: 3px; overflow: hidden; }
.asset-ws-subtab { min-height: 0; padding: 7px 16px; border: 0; background: var(--control-bg); color: var(--muted); font: inherit; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
.asset-ws-subtab + .asset-ws-subtab { border-left: 1px solid var(--line-2); }
.asset-ws-subtab:hover { color: var(--text-strong); }
.asset-ws-subtab.is-current { background: color-mix(in srgb, var(--accent) 22%, var(--control-bg)); color: var(--text-strong); }
.asset-ws-subtab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
body.asset-ws-on.asset-ws-nosensors #pane-trend-analysis > :not(.asset-ws-empty) { display: none !important; }
@media (max-width: 760px) {
  .asset-ws-row { flex-direction: column; align-items: stretch; gap: 0; }
  .asset-ws-sub { margin: 0 12px 10px; display: flex; }
  .asset-ws-subtab { flex: 1; }
}

/* Loading a newly chosen sensor: the page area under the asset header only. */
.tab-pane.is-sensor-loading { position: relative; }
.pane-loading {
  position: absolute; inset: 0; z-index: 30; display: flex; justify-content: center; align-items: flex-start;
  padding-top: min(18vh, 160px);
  background: color-mix(in srgb, var(--bg, var(--panel)) 82%, transparent); backdrop-filter: blur(2px);
  animation: pane-loading-in 120ms ease-out;
}
.pane-loading-card { width: min(320px, 70%); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pane-loading-card p { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; text-align: center; }
@keyframes pane-loading-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pane-loading { animation: none; } }

/* Pattern location cards: name and sensor on their own line, the pattern under them. */
.ap-loc-btn { grid-template-columns: 26px minmax(0, 1fr); grid-template-areas: "num text" "num pat" "num status"; align-items: start; }
.ap-loc-btn .asset-loc-num { align-self: start; margin-top: 2px; }
.ap-loc-pattern { justify-self: start; font-size: 15px; }

/* ===================== ASSET SCREENING ===================== */
.asset-screening { display: flex; flex-direction: column; gap: 0; }
.sc-decision .panel-body { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.sc-decision { border-left: 4px solid var(--muted-2); }
.sc-decision.is-attention { border-left-color: var(--critical); }
.sc-decision.is-watch { border-left-color: var(--warning); }
.sc-decision.is-ok { border-left-color: var(--normal); }
.sc-dec-top { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.sc-dec-top .fleet-card-state { font-size: 11px; }
.sc-headline { margin: 0; font-size: 17px; font-weight: 700; color: var(--text-strong); line-height: 1.35; flex: 1 1 320px; }
.sc-also { margin: 0; color: var(--text); font-size: 13px; }
.sc-speed { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.sc-cautions { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.sc-cautions li { padding: 8px 12px; border-left: 3px solid var(--warning); background: color-mix(in srgb, var(--warning) 9%, transparent); color: var(--text); font-size: 12.5px; line-height: 1.4; }
.sc-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 14px; align-items: end; padding: 12px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--panel-2); }
.sc-settings label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.sc-settings label.sc-check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.sc-settings label.sc-check input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); }
.sc-settings-actions { display: flex; gap: 8px; }
.sc-settings p { grid-column: 1 / -1; margin: 0; font-size: 11.5px; }
.sc-ind-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.sc-ind { padding: 12px 14px; border: 1px solid var(--line-2); border-left: 3px solid var(--warning); border-radius: 3px; background: var(--panel-2); display: flex; flex-direction: column; gap: 8px; }
.sc-ind-head { display: flex; align-items: center; gap: 8px; }
.sc-ind-head strong { color: var(--text-strong); font-size: 14px; text-transform: capitalize; }
.sc-tag { font-size: 9.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--warning); border: 1px solid var(--warning); border-radius: 3px; padding: 1px 5px; }
.sc-ev { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 3px; color: var(--text); font-size: 12.5px; line-height: 1.4; }
.sc-check-next { margin: 0; font-size: 12.5px; color: var(--text); line-height: 1.4; }
.sc-check-next span { display: inline-block; margin-right: 6px; font-size: 9.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.sc-none { color: var(--text); font-size: 13px; padding: 4px 0; }
.sc-notchecked { margin: 10px 0 0; font-size: 12px; }
.sc-loc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.sc-loc { border: 1px solid var(--line-2); border-radius: 3px; background: var(--panel-2); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sc-loc header { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sc-loc-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.sc-loc-name strong { color: var(--text-strong); font-size: 13px; }
.sc-loc-name small { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-axes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.sc-axes li { display: grid; grid-template-columns: 52px minmax(0, 1.2fr) minmax(0, 1fr) 76px; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sc-axes li.sc-axes-head { border-top: 0; padding: 0 0 2px; font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.sc-axis { font-weight: 700; color: var(--text-strong); display: flex; flex-direction: column; line-height: 1.1; }
.sc-axis small { font-size: 9px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.sc-freq { display: inline-flex; align-items: center; gap: 6px; }
.sc-freq.is-unused { color: var(--muted); }
.sc-harm { font-size: 10.5px; padding: 1px 5px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text-strong); }
.sc-harm.is-line { background: color-mix(in srgb, var(--warning) 22%, transparent); }
.sc-vel { color: var(--text); }
.sc-ratio { justify-self: end; font-weight: 700; }
.sc-ratio.is-normal { color: var(--normal-fg, var(--normal)); }
.sc-ratio.is-increased { color: var(--warning); }
.sc-ratio.is-high { color: var(--critical); }
.sc-ratio.is-dropped { color: var(--warning); }
.sc-ratio.is-none { color: var(--muted); font-weight: 400; font-size: 11px; }
.sc-q { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--normal); flex: none; vertical-align: middle; }
.sc-q.is-high { background: var(--normal); }
.sc-q.is-medium { background: color-mix(in srgb, var(--normal) 40%, transparent); }
.sc-q.is-low { border-color: var(--muted-2); }
.panel-meta .sc-q { margin: 0 3px 0 8px; }
.sc-trend { margin: 0; font-size: 12px; color: var(--warning); }
body.asset-ws-on.asset-ws-nosensors #pane-asset-screening > :not(.asset-ws-empty) { display: none !important; }
@media (max-width: 760px) {
  .sc-headline { font-size: 15px; }
  .sc-axes li { grid-template-columns: 40px minmax(0, 1.2fr) minmax(0, 1fr) 56px; gap: 6px; font-size: 12px; }
}

/* Inside an asset the whole page scrolls as one: no page area gets its own
   small scroll box (the asset header and the page below share one scroll). */
body.asset-ws-on .tab-pane.active { flex: 0 0 auto; min-height: auto; }
body.asset-ws-on .tab-pane.active > .pane-grid { flex: 0 0 auto; min-height: auto; overflow-y: visible; }
/* Patterns: teaching is a section that opens when needed; the live view follows the location cards. */
.ap-setup { border: 1px solid var(--line-2); border-radius: 3px; background: var(--panel-2); }
.ap-setup > summary { display: flex; align-items: baseline; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; }
.ap-setup > summary::-webkit-details-marker { display: none; }
.ap-setup > summary span { font-weight: 700; color: var(--text-strong); font-size: 13px; letter-spacing: 0.04em; }
.ap-setup > summary small { color: var(--muted); font-size: 12px; }
.ap-setup .ap-admin { border-top: 1px solid var(--line); margin: 0; padding: 12px 14px 14px; }
.ap-detail-note { margin: 4px 0 0; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }

/* Screening, plain-language first */
.sc-hero .panel-body { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.sc-hero { border-left: 5px solid var(--muted-2); }
.sc-hero.is-normal { border-left-color: var(--normal); }
.sc-hero.is-warning { border-left-color: var(--warning); }
.sc-hero.is-danger { border-left-color: var(--critical); }
.sc-status { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; color: var(--text-strong); letter-spacing: 0.01em; }
.sc-status i { width: 12px; height: 12px; border-radius: 50%; background: var(--muted-2); flex: none; }
.sc-hero.is-normal .sc-status i { background: var(--normal); }
.sc-hero.is-warning .sc-status i { background: var(--warning); }
.sc-hero.is-danger .sc-status i { background: var(--critical); }
.sc-sentence { margin: 0; font-size: 15px; line-height: 1.5; color: var(--text); max-width: 70ch; }
.sc-plain-locs { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.sc-plain-locs li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--panel-2); font-size: 13px; }
.sc-pl-name { color: var(--text-strong); font-weight: 600; }
.sc-pl-val { font-weight: 700; }
.sc-pl-val.is-normal { color: var(--normal-fg, var(--normal)); }
.sc-pl-val.is-warning { color: var(--warning); }
.sc-pl-val.is-danger { color: var(--critical); }
.sc-pl-val.is-neutral { color: var(--muted); font-weight: 500; }
.sc-tips { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.sc-tips li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 10px 12px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 9%, var(--panel-2)); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); font-size: 13px; color: var(--text); }
.sc-tips li span { flex: 1 1 260px; }
.sc-cause-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.sc-cause { padding: 14px; border: 1px solid var(--line-2); border-left: 3px solid var(--warning); border-radius: 3px; background: var(--panel-2); display: flex; flex-direction: column; gap: 6px; }
.sc-cause strong { color: var(--text-strong); font-size: 14.5px; line-height: 1.35; }
.sc-cause p { margin: 0; color: var(--text); font-size: 13px; line-height: 1.45; }
.sc-why summary { cursor: pointer; color: var(--accent); font-size: 12px; }
.sc-why ul { margin: 6px 0 0; padding-left: 16px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.sc-disclaimer { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.sc-nocause { margin: 0; color: var(--text); font-size: 13px; }
.sc-eng > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; cursor: pointer; list-style: none; }
.sc-eng > summary::-webkit-details-marker { display: none; }
.sc-eng > summary span { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.sc-eng .panel-body { display: flex; flex-direction: column; gap: 10px; }
.sc-eng-speed { margin: 0; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.sc-legend { display: flex; flex-wrap: wrap; align-items: start; gap: 12px 32px; margin: 0; padding-block: 6px; }
.sc-legend dt { margin: 0 0 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.sc-legend dd { display: flex; flex-wrap: wrap; gap: 5px 16px; margin: 0; font-size: 12px; line-height: 1.5; color: var(--text); }
.sc-legend dd > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.sc-settings em { font-style: normal; color: var(--muted); }
@media (max-width: 760px) {
  .sc-status { font-size: 19px; }
  .sc-sentence { font-size: 14px; }
}

.sc-plain-locs li.is-warning .asset-loc-num { background: var(--warning); }
.sc-plain-locs li.is-danger .asset-loc-num { background: var(--critical); color: #fff; }
.sc-plain-locs li.is-neutral .asset-loc-num { background: var(--muted-2); color: var(--panel); }

/* Screening: vibration vs motor speed (1×/2×/3×) charts */
.sc-causes .panel-header .sc-disclaimer { margin: 0 0 0 auto; font-size: 11px; text-transform: none; letter-spacing: 0; }
.sc-charts .panel-header { flex-wrap: wrap; gap: 8px 16px; }
.sc-chart-key { margin-left: auto; display: flex; gap: 14px; font-size: 11px; color: var(--muted); }
.sc-chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.sc-key-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--normal); display: inline-block; }
.sc-key-dot.is-hollow { background: transparent; border: 2px solid var(--muted-2); width: 6px; height: 6px; }
.sc-chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.sc-chart-card { margin: 0; padding: 12px 14px 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 3px; min-width: 0; }
.sc-chart-card figcaption { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-strong); margin-bottom: 10px; }
.sc-chart { position: relative; }
.sc-chart.is-empty { height: 150px; display: grid; place-items: center; color: var(--muted); }
.sc-plot { position: relative; height: 170px; margin: 18px 0 0; border-bottom: 1px solid var(--border-2); }
.sc-band { position: absolute; top: -18px; bottom: 0; background: rgba(122, 184, 230, 0.08); border-left: 1px dashed rgba(122, 184, 230, 0.45); border-right: 1px dashed rgba(122, 184, 230, 0.45); min-width: 2px; }
.sc-band b { position: absolute; top: 0; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--accent); white-space: nowrap; }
.sc-band small { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); white-space: nowrap; }
.sc-hline { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--border-2); pointer-events: none; }
.sc-hline em { position: absolute; right: 0; bottom: 1px; font-size: 10px; font-style: normal; color: var(--muted); background: var(--panel-2); padding: 0 3px; }
.sc-hline.is-watch { border-top-color: rgba(164, 130, 50, 0.6); }
.sc-hline.is-watch em { color: var(--warning-fg); }
.sc-hline.is-attention { border-top-color: rgba(149, 67, 61, 0.7); }
.sc-hline.is-attention em { color: var(--critical-fg); }
.sc-pin { --c: var(--normal); position: absolute; bottom: 0; width: 2px; margin-left: calc(-1px + var(--nudge, 0px)); background: var(--c); min-height: 2px; }
.sc-pin i { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); width: 20px; height: 20px; border-radius: 50%; background: var(--c); color: var(--control-active-text); font-size: 10px; font-weight: 700; font-style: normal; display: grid; place-items: center; }
.sc-pin.is-warning { --c: var(--warning); }
.sc-pin.is-danger { --c: var(--critical); }
.sc-pin.is-danger i { color: #fff; }
.sc-pin.is-neutral { --c: var(--info); }
.sc-pin.is-unreliable { background: transparent; border-left: 2px dotted var(--muted-2); width: 0; }
.sc-pin.is-unreliable i { background: var(--panel-2); border: 2px solid var(--muted-2); color: var(--muted); width: 16px; height: 16px; }
.sc-xaxis { display: flex; justify-content: space-between; gap: 8px; margin-top: 22px; font-size: 10px; color: var(--muted); }
@media (max-width: 640px) {
  .sc-plot { height: 140px; }
  .sc-chart-grid { grid-template-columns: 1fr; }
  .sc-chart-key { margin-left: 0; }
}
.asset-ws-tab .asset-ws-beta { margin-left: 6px; padding: 1px 5px; border: 1px solid var(--border-2); border-radius: 3px; font-size: 9px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); vertical-align: 2px; }
.asset-ws-tab.is-current .asset-ws-beta { color: var(--warning-fg); border-color: rgba(164, 130, 50, 0.6); }
.sensor-card-panel { padding: 0; background: transparent; border: 0; }
.sensor-card-one { display: block; margin: 0; padding: 0; list-style: none; height: 100%; }
.sensor-card-one .fleet-card { height: 100%; }
.sensor-card-one .fleet-card:hover { transform: none; box-shadow: none; border-color: var(--border); }
.sensor-profile-panel > summary { cursor: pointer; list-style: none; }
.sensor-profile-panel > summary::-webkit-details-marker { display: none; }

/* Keep selection visible across the card without changing its dimensions. */
.fleet-card.active {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* Paint a selection bar inside the name cell, keeping its full text width. */
.asset-table tr.asset-row.active > td.asset-name {
  box-shadow: inset 2px 0 var(--accent);
}
body.asset-ws-on.asset-ws-nosensors #pane-hourly-history > :not(.asset-ws-empty) { display: none !important; }

/* Square-cornered look: controls and badges use at most 3px corners.
   Only small status dots, the round sensor markers on machine pictures and
   the circular gauges stay round. */
.recording-step-number, .help-video-close, .rep-close, .iso-wizard-close, .asset-pick-clear, .ap-label button,
.whats-this > summary::before, .asset-loc-num, .ws-loc-num { border-radius: 3px; }

/* Leader lines: numbered machine points joined to their labels */
[data-leaders] { position: relative; }
.asset-leaders { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 1; }
.asset-leaders path { fill: none; stroke: var(--normal); stroke-width: 1.2; opacity: 0.85; }
.asset-leaders circle { fill: var(--normal); }
.asset-leaders .is-warning path { stroke: var(--warning); } .asset-leaders .is-warning circle { fill: var(--warning); }
.asset-leaders .is-danger path { stroke: var(--critical); } .asset-leaders .is-danger circle { fill: var(--critical); }
.asset-leaders .is-offline path, .asset-leaders .is-empty path { stroke: var(--muted-2); stroke-dasharray: 3 3; }
.asset-leaders .is-offline circle, .asset-leaders .is-empty circle { fill: var(--muted-2); }
.asset-detail-body > .asset-art, .asset-detail-body > .asset-detail-side { position: relative; z-index: 2; }
.asset-detail-body .asset-pin { z-index: 3; }
.asset-detail-body { column-gap: 56px; }

/* Asset identity card in the asset header */
.asset-id-card { display: flex; align-items: center; gap: 34px; min-width: 0; flex: 1 1 auto; padding: 8px 14px 8px 8px; border: 1px solid var(--border); border-radius: 3px; background: var(--panel-2); }
.asset-id-art { flex: none; width: 150px; }
.asset-id-art .asset-art { width: 150px; }
.asset-id-art img { width: 100%; height: auto; display: block; }
.asset-id-info { min-width: 0; position: relative; z-index: 2; }
.asset-id-points { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; }
.asset-id-points li { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 12px; color: var(--text); }
.asset-id-points li .asset-loc-num { width: 16px; height: 16px; font-size: 9px; flex: none; align-self: center; }
.asset-id-points li span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-id-points li small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-id-card .asset-art-sm .asset-pin { z-index: 3; }
@media (max-width: 640px) {
  .asset-id-card { gap: 22px; padding: 6px 8px 6px 4px; }
  .asset-id-art, .asset-id-art .asset-art { width: 104px; }
  .asset-id-points li small { display: none; }
}
.asset-id-points li.is-warning .asset-loc-num { background: var(--warning); }
.asset-id-points li.is-danger .asset-loc-num { background: var(--critical); color: #fff; }
.asset-id-points li.is-offline .asset-loc-num { background: var(--muted-2); color: var(--panel); }

/* Screening: probable issues first */
.sc-issues .panel-header { display: flex; align-items: center; gap: 12px; }
.sc-issues .panel-header .sc-status { margin: 0 0 0 auto; font-size: 13px; }
.sc-issue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sc-issue { padding: 10px 12px; border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: 3px; background: var(--panel-2); }
.sc-issues.is-danger .sc-issue { border-left-color: var(--critical); }
.sc-issue-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.sc-issue-head strong { color: var(--text-strong); font-size: 14px; }
.sc-issue-at { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.sc-at { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.sc-at .asset-loc-num { width: 16px; height: 16px; font-size: 9px; }
.sc-issue p { margin: 4px 0 0; color: var(--text); font-size: 13px; }
.sc-issue .sc-why { margin-top: 4px; }
.sc-none { margin: 0; font-size: 14px; color: var(--text-strong); }
.sc-issues .sc-disclaimer { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.sc-eng .sc-chart-grid { margin: 8px 0 14px; }
.sc-chart-card figcaption .sc-chart-key { margin-left: auto; font-weight: 400; }

/* Selected sensor detail: each value in its own box under its label, so no
   value can be read as belonging to the neighbouring label. */
.detail-list.detail-tiles { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; border: 1px solid var(--border); border-radius: 3px; margin: 0; }
.detail-list.detail-tiles > div { display: flex !important; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 4px; padding: 8px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 0 -1px -1px 0; min-width: 0; grid-template-columns: none !important; }
.detail-list.detail-tiles > div[hidden] { display: none !important; }
.detail-list.detail-tiles dt { margin: 0; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); text-align: left !important; }
.detail-list.detail-tiles dd { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-strong); text-align: left !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
@media (max-width: 640px) {
  .sc-issues .panel-header { flex-direction: row !important; justify-content: space-between !important; text-align: left !important; align-items: center !important; }
  .sc-issues .panel-header .sc-status { font-size: 12px; }
}

/* Card beside Readings only when Readings still has room for its three
   columns; narrower, they stack (side by side at 1024 px squeezed the
   Readings headings into one letter per line). */
@media (min-width: 1360px) {
  .pane-condition {
    grid-template-columns: minmax(260px, 0.85fr) minmax(0, 2.15fr);
    grid-template-areas:
      "profile profile"
      "card status"
      "indicators indicators";
  }
}
@media (max-width: 1359px) {
  .sensor-card-one .fleet-card { height: auto; }
}
.sc-issues .panel-header { flex-direction: row !important; justify-content: space-between !important; text-align: left !important; align-items: center !important; }
/* Readings: headings wrap between words, never inside one ("ACCELERATI / ON"). */
.metric-status-row > span:first-child { word-break: normal !important; overflow-wrap: normal !important; hyphens: none; min-width: 0; }

/* A point whose sensor is online and sending readings pulses: a ring in the
   point's status colour grows and fades every 2 s. */
.asset-pin.is-live { overflow: visible; }
.asset-pin.is-live::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid var(--pulse, var(--normal)); pointer-events: none;
  animation: asset-pin-pulse 2s ease-out infinite;
}
.asset-pin.is-live.is-warning { --pulse: var(--warning); }
.asset-pin.is-live.is-danger { --pulse: var(--critical); }
@keyframes asset-pin-pulse {
  0% { transform: scale(1); opacity: 0.9; }
  70% { transform: scale(2.1); opacity: 0; }
  100% { transform: scale(2.1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .asset-pin.is-live::after { animation: none; opacity: 0.5; } }

/* Asset editor: the steps are buttons */
.iso-wizard-steps li .ae-step { display: inline-flex; align-items: center; gap: 6px; padding: 0; margin: 0; border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; min-height: 0; min-width: 0; white-space: nowrap; }
.iso-wizard-steps li .ae-step:hover { color: var(--text-strong); }
.iso-wizard-steps li .ae-step:hover span { border-color: var(--accent); }
.iso-wizard-steps li .ae-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.iso-wizard-steps li .ae-step[aria-disabled="true"] { cursor: not-allowed; opacity: 0.55; }
.iso-wizard-steps li .ae-step[aria-current="step"] { cursor: default; }

/* Patterns: every location card the same width and height, whatever it shows
   (trained or not, one line of status or two). */
.ap-locs { grid-auto-rows: 1fr; align-items: stretch; }
.ap-locs > .ap-loc { display: flex; min-width: 0; margin: 0; }
.ap-locs .ap-loc-btn { flex: 1 1 auto; height: 100%; align-content: start; box-sizing: border-box; }
.ap-locs .ap-loc-status { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; min-width: 0; }

/* Sensor list table (desktop): share the width by what each column needs.
   Status, severity, last seen and admin hold short fixed words, so they
   shrink to fit; the sensor column (name, ID, installed location) gets a
   real share so the location is not cut off; readings take the rest. */
@media (min-width: 1025px) {
  .sensor-fleet-table th:nth-child(1) { width: 30%; min-width: 240px; }
  .sensor-fleet-table th:nth-child(2),
  .sensor-fleet-table th:nth-child(4),
  .sensor-fleet-table th:nth-child(6) { width: 1%; white-space: nowrap; }
  .sensor-fleet-table td:nth-child(2),
  .sensor-fleet-table td:nth-child(4) { white-space: nowrap; padding-right: 22px; }
  /* "a few seconds ago" may wrap; the column keeps a steady width. */
  .sensor-fleet-table th:nth-child(5) { width: 104px; white-space: nowrap; }
  .sensor-fleet-table td:nth-child(5) { white-space: normal; overflow-wrap: normal; }
  .sensor-fleet-table td.asset-name .sensor-name,
  .sensor-fleet-table td.asset-name .sensor-id { display: block; overflow: hidden; text-overflow: ellipsis; }
}
/* Narrow desktops: give the sensor column a little less and let the status
   words wrap, so nothing is pushed off the right edge. */
@media (min-width: 1025px) and (max-width: 1279px) {
  .sensor-fleet-table th:nth-child(1) { width: 34%; min-width: 200px; }
  .sensor-fleet-table td:nth-child(2) { white-space: normal; overflow-wrap: normal; word-break: normal; padding-right: 10px; }
  .sensor-fleet-table td:nth-child(2) .fleet-card-state { white-space: normal; overflow-wrap: normal; word-break: normal; }
  .sensor-fleet-table th, .sensor-fleet-table td { padding-left: 8px; padding-right: 8px; }
  /* Each reading: label, value, then its graph underneath, so the column
     needs about half the width. Several readings stack. */
  .sensor-fleet-table { min-width: 0; }
  .sensor-fleet-table td.reading-cell { min-width: 0; }
  .sensor-fleet-table .reading-cell .fleet-readings { grid-template-columns: minmax(0, 1fr) !important; row-gap: 10px; }
  .sensor-fleet-table .reading-cell .fleet-reading + .fleet-reading { margin-left: 0 !important; padding-left: 0 !important; border-left: 0 !important; }
  .sensor-fleet-table .fleet-reading { grid-template-columns: minmax(0, 1fr); }
  .sensor-fleet-table .fleet-reading .fleet-mini { grid-column: 1; grid-row: 4; width: 100%; max-width: 132px; height: 28px; margin-top: 4px; }
  .sensor-fleet-table .fleet-reading-value { min-width: 0; }
}

/* Status / Trends / 6-Month History inside the sensor bar (sensor on no asset). */
.sensor-bar .sensor-bar-views { margin: 0; }
@media (max-width: 760px) {
  .sensor-bar { flex-wrap: wrap; }
  .sensor-bar .sensor-bar-views { order: 10; flex: 1 1 100%; display: flex; margin: 2px 0 4px; }
  .sensor-bar .sensor-bar-views .asset-ws-subtab { flex: 1; min-height: 40px; padding: 7px 8px; }
}

/* Readings: every group starts at the top with the same header line (name
   left, status right), and a value never breaks across lines, so X, Y, Z and
   Magnitude line up across Acceleration, Velocity and Displacement. */
.metric-status-row { align-content: start; align-items: center; }
.metric-status-row > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 22px; }
.metric-status-row .status-pill { justify-self: end; white-space: nowrap; }
.metric-axis-breakdown dd { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
.overall-health-row > span:last-child { align-self: start; }

/* Sensor Profile: the editable general info sits on top, the read-only
   details below it, divided by a line. */
#sensorProfilePanel .device-config-summary { gap: 12px 18px; margin-bottom: 4px; }
#sensorProfilePanel .iso-config-card { margin-top: 12px; }
#sensorProfilePanel .profile-grid { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* Sensor Profile header: arrow and title together on the left. */
#sensorProfilePanel > summary { display: flex; flex-direction: row !important; justify-content: flex-start !important; align-items: center !important; text-align: left !important; gap: 0; }
/* Read-only details as label-over-value tiles, the same as the general info
   above, instead of a label and a value at opposite ends of a wide row. */
#sensorProfilePanel .profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 18px; }
#sensorProfilePanel .profile-grid > div { display: block; padding: 0; border: 0; min-width: 0; }
#sensorProfilePanel .profile-grid dt { color: var(--muted-2); font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px; }
#sensorProfilePanel .profile-grid dd { color: var(--text); text-align: left; overflow-wrap: anywhere; }

/* ---- Bearing check (Screening) ---- */
.iso-wizard.is-narrow { width: min(620px, 100%); }
.brg-form .brg-wide { grid-column: 1 / -1; margin-bottom: 12px; }
.brg-form .iso-field input { height: var(--ctl-h); }
.brg-form .iso-field-row > p { margin: 0; }
.brg-preview { margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); background: var(--panel-2); }
.brg-preview p { margin: 0; }
.brg-preview-title { color: var(--muted); font-size: 10.5px !important; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px !important; }
.brg-preview-list, .sc-brg-bands { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.brg-preview-list li { display: grid; grid-template-columns: minmax(0, 1.6fr) 0.7fr 0.8fr minmax(0, 1.4fr); gap: 8px; align-items: baseline; font-size: 12px; }
.brg-preview-list li > span:nth-child(2), .brg-preview-list li > span:nth-child(3) { font-variant-numeric: tabular-nums; color: var(--text-strong); }
.brg-preview-list .is-on, .sc-brg-bands .is-on > span:last-child { color: var(--normal-fg, #5fbf8f); }
.brg-preview-list .is-off, .sc-brg-bands .is-off > span:last-child { color: var(--muted); }
.sc-brg-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sc-brg-box h3 { margin: 0 0 6px; color: var(--text-strong); font-size: 13px; }
.sc-brg-box h3 em { color: var(--muted); font-style: normal; font-weight: 500; }
.sc-brg-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; margin: 8px 0 0; padding: 0; list-style: none; }
.sc-brg { padding: 10px 12px; border: 1px solid var(--line); background: var(--panel-2); min-width: 0; }
.sc-brg-head { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.sc-brg-name { color: var(--text-strong); font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-brg-what { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-brg-head .btn { flex: none; width: auto; min-width: 64px; }
.sc-brg-bands { margin-top: 8px; }
.sc-brg-bands li { display: grid; grid-template-columns: minmax(0, 1.3fr) 0.6fr minmax(0, 1.6fr); gap: 8px; align-items: baseline; font-size: 11.5px; }
.sc-brg-bands li > span:nth-child(2) { color: var(--text-strong); font-variant-numeric: tabular-nums; }
/* Bearing bands on the frequency plot: amber, labels inside the plot so they
   never collide with the 1x/2x/3x labels above it. */
.sc-bband { position: absolute; top: 0; bottom: 0; background: rgba(230, 170, 90, 0.12); border-left: 1px dashed rgba(230, 170, 90, 0.6); border-right: 1px dashed rgba(230, 170, 90, 0.6); }
.sc-bband b { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); font-size: 10px; color: #e0a45a; white-space: nowrap; }
.sc-bband.is-off { background: repeating-linear-gradient(135deg, rgba(150,160,170,0.10) 0 4px, transparent 4px 8px); border-color: rgba(150,160,170,0.4); }
.sc-bband.is-off b { color: var(--muted); }
.sc-blind { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, rgba(120,130,140,0.12) 0 3px, transparent 3px 7px); pointer-events: auto; }
@media (max-width: 560px) {
  .brg-preview-list li { grid-template-columns: minmax(0, 1fr) auto auto; }
  .brg-preview-list li > span:last-child { grid-column: 1 / -1; }
  .sc-brg-list { grid-template-columns: 1fr; }
}

/* Bearing card head: number, name and button on one line, what was entered
   underneath, so nothing is cut off on a phone. */
.sc-brg-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "num name btn" "num what btn"; column-gap: 8px; row-gap: 2px; align-items: center; }
.sc-brg-head > .asset-loc-num { grid-area: num; }
.sc-brg-head > .sc-brg-name { grid-area: name; white-space: normal; }
.sc-brg-head > .sc-brg-what { grid-area: what; white-space: normal; }
.sc-brg-head > .btn { grid-area: btn; }

/* ---- Asset editor: build the machine from parts ---- */
.mb-builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px; align-items: start; }
.mb-steps { display: grid; gap: 12px; min-width: 0; }
.mb-field { margin: 0; padding: 0; border: 0; min-width: 0; }
.mb-field legend { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 0; color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.mb-field legend b { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--line-2); color: var(--text-strong); font-size: 10px; }
.mb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mb-chip { position: relative; display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-size: 12px; cursor: pointer; line-height: 1.2; }
.mb-chip input { position: absolute; opacity: 0; pointer-events: none; }
.mb-chip:hover { border-color: var(--muted-2); }
.mb-chip.is-selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel-2)); color: var(--text-strong); }
.mb-chip:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.mb-preview { margin: 0; padding: 10px; border: 1px solid var(--line); background: var(--panel-2); min-width: 0; }
.mb-preview.is-empty { display: grid; place-items: center; min-height: 220px; }
.mb-preview figcaption { margin-top: 8px; font-size: 12px; }
.mb-preview figcaption > strong { display: block; color: var(--text-strong); font-size: 12.5px; margin-bottom: 6px; }
.mb-plan p { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 4px !important; }
.mb-plan p > strong { min-width: 62px; color: var(--muted); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.mb-pos { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; }
.mb-more { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.mb-more > summary { cursor: pointer; color: var(--accent); font-size: 12px; margin-bottom: 10px; }
.mb-first, .mb-then { margin-left: 8px; padding: 1px 6px; font-size: 9.5px; font-style: normal; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; vertical-align: 1px; }
.mb-first { background: var(--accent); color: var(--control-active-text); }
.mb-then { border: 1px solid var(--line-2); color: var(--muted); }
.mb-why { margin-top: 4px; font-size: 11.5px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.mb-why > summary { display: inline; cursor: pointer; color: var(--accent); font-size: 11px; }
.mb-why p { margin: 6px 0 0; color: var(--text); line-height: 1.5; }
.mb-why ul { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 0 0; padding: 0; list-style: none; }
.mb-why a { color: var(--accent); font-size: 11px; }
@media (max-width: 760px) {
  .mb-builder { grid-template-columns: 1fr; }
  .mb-preview { order: -1; }
}

/* Asset editor, Sensors step: the number lines up with its sensor box (not
   with the middle of label + box), and a one-line box centres its text. */
.asset-place-row { grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: center; row-gap: 6px; }
.asset-place-row > .asset-place-field { display: contents; }
.asset-place-row > .asset-loc-num { grid-column: 1; grid-row: 2; align-self: center; margin: 0; }
.asset-place-row .asset-place-label { grid-column: 2 / -1; grid-row: 1; }
.asset-place-row .asset-pick { grid-column: 2; grid-row: 2; }
.asset-place-row > .asset-pick-clear { grid-column: 3; grid-row: 2; align-self: center; }
.asset-pick { grid-template-rows: none; align-content: center; }
.asset-pick-icon { grid-row: 1; align-self: center; }
.asset-pick:has(.asset-pick-id) .asset-pick-icon { grid-row: 1 / span 2; }
/* Rows in the two-column list start at the top: an open "Why here?" in one
   row never stretches or re-centres its neighbour. */
.asset-place-list { align-items: start; }
.asset-place-row { align-self: start; align-content: start; }
.asset-place-row .mb-why { grid-column: 2 / -1; grid-row: 3; margin-top: 0; }

/* ==== Dialogs: one design ====
   Every pop-up (asset editor, ISO wizard, report, sensor picker, bearing,
   confirmations, help video) uses the same shell: dim backdrop, panel with a
   1px border and square corners, a header with a small accent kicker, the
   title and a square close button, the body, and a footer with the main
   action on the right. Sizes: small 460, narrow 620, regular 760 px. */
.iso-wizard-overlay, .rep-overlay, .sensor-picker-overlay { background: rgba(4, 8, 12, 0.62); }
.iso-wizard, .rep-dialog, .sensor-picker, .help-video { background: var(--panel); border: 1px solid var(--line-2); border-radius: 0; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45); }
.iso-wizard.is-small { width: min(460px, 100%); }
.rep-dialog { width: min(620px, 100%); animation: none; }
.sensor-picker { width: min(620px, 100%); }
/* Header */
.rep-head, .sp-head, .help-video-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.rep-head h2, .help-video-title { display: block; margin: 2px 0 0; color: var(--text-strong); font-size: 17px; font-weight: 700; letter-spacing: 0; text-transform: none; }
.sp-head h3 { margin: 2px 0 0; color: var(--text-strong); font-size: 17px; }
.sp-head > div, .rep-head > div, .help-video-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.rep-sensor { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.iso-wizard-sensor { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.iso-wizard-close, .rep-close, .help-video-close, .sp-head .iso-wizard-close { flex: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line-2); border-radius: 0; background: var(--panel-2); color: var(--text); font-size: 14px; line-height: 1; cursor: pointer; }
.iso-wizard-close:hover, .rep-close:hover, .help-video-close:hover { background: var(--fill-hover); color: var(--text-strong); }
.help-video-head { align-items: center; }
/* Steps: numbered squares, the same in every wizard */
.rep-steps { display: flex; gap: 4px; margin: 0; padding: 10px 18px; list-style: none; border-bottom: 1px solid var(--line); overflow-x: auto; }
.rep-steps li { flex: none; display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-top: 0; color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.rep-steps li span { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--line-2); font-size: 10px; }
.rep-steps li.is-current { color: var(--text-strong); }
.rep-steps li.is-current span { background: var(--accent); border-color: var(--accent); color: var(--control-active-text); }
.rep-steps li.is-done { color: var(--muted); }
.rep-steps li.is-done span { border-color: var(--accent); color: var(--accent); }
/* Body */
.rep-body { padding: 16px 18px; }
.sp-search { margin: 12px 18px 10px; }
/* Error strip */
.rep-error { margin: 0; padding: 8px 18px; background: var(--critical-bg); color: var(--critical-fg); font-size: 12.5px; }
/* Footer: actions on the right, the main one last */
.rep-foot { display: flex; align-items: center; justify-content: flex-start; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.rep-btn { min-width: 96px; height: var(--ctl-h); min-height: var(--ctl-h); padding: 0 16px; border: 1px solid var(--line-2); border-radius: 0; background: var(--panel-2); color: var(--text-strong); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.rep-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--control-active-text); }
.rep-btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.iso-wizard-foot .btn-danger { background: var(--critical-bg); }
.sp-foot { padding: 8px 18px 12px; border-top: 1px solid var(--line); margin: 0; }
@media (max-width: 560px) {
  .rep-overlay, .sensor-picker-overlay { padding: 0; place-items: stretch; }
  .rep-dialog, .sensor-picker { width: 100%; max-height: 100dvh; height: 100%; border: 0; }
  .rep-foot { flex-wrap: wrap; }
  .rep-foot .rep-btn { flex: 1 1 auto; }
  .rep-foot .iso-wizard-spacer { display: none; }
}

/* The main action of every dialog is the one filled button, on the right. */
.iso-wizard-foot .btn:not(.btn-secondary):not(.btn-danger) { background: var(--accent); border-color: var(--accent); color: var(--control-active-text); }
.iso-wizard-foot .btn:not(.btn-secondary):not(.btn-danger):hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.iso-wizard-foot .btn-secondary, .rep-btn:not(.rep-btn-primary) { background: var(--panel-2); color: var(--text-strong); }
/* Alignment sweep fixes. */
@media (max-width: 600px) {
  .asset-card .fleet-card-body > .fleet-card-meta { margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; align-self: center; }
}
.ap-add { align-items: stretch; }
.ap-add input, .ap-add .btn { height: var(--ctl-h); min-height: var(--ctl-h); box-sizing: border-box; margin: 0; }
@media (max-width: 600px) {
  .asset-card .fleet-card-body > .fleet-card-id { margin-bottom: 0; }
  .asset-card .fleet-card-body { row-gap: 8px; }
}

/* Asset cards: one clear stack at every width. Name on its own line, the type
   under it, then status and ISO. No row mixes a large and a small text. */
.asset-card .fleet-card-body { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title title" "id id" "meta meta" "iso iso"; row-gap: 4px; column-gap: 12px; align-items: center; align-content: start; padding: 8px 14px 12px; }
.asset-card .fleet-card-body > .fleet-card-title { grid-area: title; margin: 0; }
.asset-card .fleet-card-body > .fleet-card-id { grid-area: id; margin: 0 0 6px; white-space: normal; }
.asset-card .fleet-card-body > .fleet-card-meta { grid-area: meta; margin: 0; padding: 0; justify-content: flex-start; gap: 10px; }
.asset-card .fleet-card-body > .asset-card-iso { grid-area: iso; margin: 0; }
@media (max-width: 600px) {
  .asset-card .fleet-card-body { grid-template-areas: "title title" "id id" "meta iso"; padding: 8px 12px 12px; }
  .asset-card .fleet-card-body > .asset-card-iso { text-align: right; }
}
/* Patterns location cards: the number sits on the name's line. */
.ap-loc-btn .asset-loc-num { margin-top: 0; }
.ap-loc-btn .ap-loc-text { line-height: 22px; min-height: 22px; }

/* Close buttons: one design everywhere. A large, round, quiet button with a
   thin drawn cross (two hairlines) instead of a text glyph, so the stroke is
   the same weight in every browser and font. */
.iso-wizard-close, .rep-close, .help-video-close, .sp-head .iso-wizard-close {
  position: relative; flex: none; display: block; width: 40px; height: 40px; padding: 0; border: 0 !important; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 0; line-height: 0; cursor: pointer; overflow: hidden;
  transition: background-color .12s ease, color .12s ease;
}
.iso-wizard-close::before, .iso-wizard-close::after, .rep-close::before, .rep-close::after, .help-video-close::before, .help-video-close::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 1.5px; margin: -0.75px 0 0 -10px; border-radius: 1px; background: currentColor;
}
.iso-wizard-close::before, .rep-close::before, .help-video-close::before { transform: rotate(45deg); }
.iso-wizard-close::after, .rep-close::after, .help-video-close::after { transform: rotate(-45deg); }
.iso-wizard-close:hover, .rep-close:hover, .help-video-close:hover { background: var(--fill); color: var(--text-strong); }
.iso-wizard-close:focus-visible, .rep-close:focus-visible, .help-video-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.iso-wizard-head { align-items: center; }
.help-video-close { background: var(--fill); color: var(--text-strong); }
/* Small remove buttons (sensor slot, pattern label) use the same thin cross, smaller. */
.asset-pick-clear, .ap-label button { position: relative; font-size: 0; line-height: 0; overflow: hidden; }
.asset-pick-clear::before, .asset-pick-clear::after, .ap-label button::before, .ap-label button::after {
  content: ""; position: absolute; left: 50%; top: 50%; height: 1.5px; margin-top: -0.75px; border-radius: 1px; background: currentColor;
}
.asset-pick-clear::before, .asset-pick-clear::after { width: 14px; margin-left: -7px; }
.ap-label button::before, .ap-label button::after { width: 10px; margin-left: -5px; }
.asset-pick-clear::before, .ap-label button::before { transform: rotate(45deg); }
.asset-pick-clear::after, .ap-label button::after { transform: rotate(-45deg); }
@media (pointer: coarse) { .iso-wizard-close, .rep-close, .help-video-close { width: 44px; height: 44px; } }

/* ===== Asset workspace: Overview shows the big picture; the other tabs show a
   slim sticky band under the tabs (picture, locations with live values,
   report). The page below always uses the full width. ===== */
.asset-ws-top { padding: 8px 16px 4px; }
.asset-ws-title h2 { font-size: 18px; }
.asset-detail-body > .asset-art { view-transition-name: asset-art; }

.asset-pass {
  flex: none; position: sticky; top: var(--ws-h, 96px); z-index: 44;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-width: 0;
  margin: 0; padding: 8px 16px; border-bottom: 1px solid var(--line-2); background: var(--panel-2);
  view-transition-name: asset-pass;
}
.asset-pass[hidden], body:not(.asset-ws-on) .asset-pass, body[data-asset-tab="overview"] .asset-pass { display: none !important; }
.asset-pass-art { flex: none; display: block; width: 104px; }
.asset-pass-art .asset-art { display: block; width: 100%; view-transition-name: asset-art; }
.asset-pass-art img { display: block; width: 100%; height: auto; }
.asset-pass-art .asset-pin { display: none; }
.asset-pass-id { display: none; }
.asset-pass-locs { flex: 1 1 280px; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.asset-pass-locs > li { flex: 0 1 auto; min-width: 0; max-width: 100%; }
.asset-pass-locs .asset-ws-loc { max-width: 100%; }
.asset-pass-locs .asset-ws-loc.is-static { cursor: default; }
.asset-pass-locs .asset-ws-loc.is-static:hover { border-color: var(--line-2); }
.asset-pass-locs .asset-ws-loc-text { flex: 1 1 auto; min-width: 0; }
.asset-ws-loc-val { flex: none; margin-left: 8px; color: var(--text-strong); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.asset-ws-loc-val:empty { display: none; }
.asset-pass-foot { flex: none; margin-left: auto; display: flex; align-items: center; }
.asset-pass-iso { display: none; }
@media (max-width: 900px) {
  .asset-pass { position: static; padding: 8px 12px; gap: 8px 12px; }
  .asset-pass-art { width: 88px; }
  .asset-pass-locs { flex: 1 1 160px; display: grid; grid-template-columns: minmax(0, 1fr); }
  .asset-pass-locs > li, .asset-pass-locs .asset-ws-loc { width: 100%; }
  .asset-pass-locs .asset-ws-loc-text small { display: none; }
  .asset-pass-foot { flex: 1 1 100%; margin: 0; justify-content: flex-end; }
}

/* Tab change: the browser morphs the picture; elsewhere the page fades in. */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.2s; }
::view-transition-group(asset-art), ::view-transition-group(asset-pass) { animation-duration: 0.42s; animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes wsIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.operations-grid.ws-swap > .tab-pane.active, .operations-grid.ws-swap > .asset-pass { animation: wsIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .operations-grid.ws-swap > * { animation: none !important; }
}

/* Close buttons: square with a 3 px corner, a large thin cross. */
.iso-wizard-close, .rep-close, .help-video-close, .sp-head .iso-wizard-close {
  width: 40px; height: 40px; border-radius: 3px; border: 1px solid var(--line-2) !important; background: var(--fill); color: var(--text-strong);
}
.iso-wizard-close:hover, .rep-close:hover, .help-video-close:hover { background: var(--fill-hover); border-color: var(--muted-2) !important; }
.asset-pick-clear, .ap-label button { border-radius: 3px; }

/* Screening: one card; issues and tips as cards. */
#assetScreening { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sc-hero { border-left-width: 3px; }
.sc-hero .panel-body { padding: 16px 18px; gap: 14px; }
.sc-none { margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.sc-sentence { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.sc-disclaimer { margin: 10px 0 0; font-size: 11px; color: var(--muted); }
.sc-issue-list { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 10px; align-items: stretch; }
.sc-issue-list > .sc-issue { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; padding: 12px 14px; border: 1px solid var(--line-2); border-left: 3px solid var(--warning); border-radius: 3px; background: var(--panel-2); }
.sc-issue-list > .sc-issue p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.sc-issue-list > .sc-issue .sc-why { margin-top: auto; }
.sc-tips { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 10px; margin-top: 0; }
.sc-tips li { flex-direction: column; align-items: stretch; justify-content: space-between; gap: 10px; min-width: 0; border: 1px solid var(--line-2); }
.sc-tips li span { flex: 0 0 auto; font-weight: 600; color: var(--text-strong); }
.sc-tips li .btn { align-self: flex-start; }
.ap-state { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }

/* Configuration > Theme > Font */
.font-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.font-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--panel-2); cursor: pointer; min-width: 0; }
.font-card[hidden] { display: none; }
.font-card input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.font-card:hover { border-color: var(--muted-2); }
.font-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: color-mix(in srgb, var(--accent) 10%, var(--panel-2)); }
.font-card:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.font-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.font-card-head strong { color: var(--text-strong); font-size: 12px; }
.font-card-head em { font-style: normal; color: var(--muted); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.font-card.is-saved .font-card-head em::after { content: " · in use"; color: var(--accent); }
.font-sample { font-size: 20px; line-height: 1.25; color: var(--text-strong); overflow-wrap: anywhere; }
.font-digits { font-size: 12px; color: var(--muted); }
.font-card small { color: var(--muted); font-size: 11px; line-height: 1.35; }

/* ISO notice on Thresholds: the sentence, then its button on the right (below on a phone). */
.iso-managed-note:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.iso-managed-note .iso-managed-text { flex: 1 1 320px; min-width: 0; }
.iso-managed-note .btn { flex: none; margin-left: 0; }
/* Overview: the sensor list keeps a sensible width so the picture gets the room
   and the leader lines stay short on wide screens. */
@media (min-width: 901px) {
  .asset-detail-body { grid-template-columns: minmax(0, 1fr) minmax(280px, 440px); column-gap: 40px; }
}
/* Patterns: location cards wide enough for their status line. */
.ap-locs { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
/* Guard: the asset header and its picture strip exist only inside an asset,
   and the strip never on Overview (which has the big picture). */
body:not(.asset-ws-on) #assetWorkspace,
body:not(.asset-ws-on) #assetPass,
body[data-asset-tab="overview"] #assetPass { display: none !important; }

/* Tabs: the current tab is marked by a quiet filled block, no underline. */
.asset-ws-tabs { padding: 4px 12px 8px; gap: 4px; }
.asset-ws-tab { border-bottom: 0 !important; border-radius: 3px; padding: 8px 12px; }
.asset-ws-tab.is-current { background: var(--fill); color: var(--text-strong); }
.asset-ws-tab:hover:not(.is-current) { background: color-mix(in srgb, var(--fill) 50%, transparent); }

/* Icon buttons in the asset strip: thin line icons, square, 3 px corners. */
.asset-pass-foot .ico-btn { box-sizing: border-box; flex: 0 0 38px; display: inline-grid; place-items: center; width: 38px; height: 38px; min-height: 0; padding: 0; border: 1px solid var(--border-2); border-radius: 3px; background: transparent; color: var(--muted); cursor: pointer; transition: background-color .12s, color .12s, border-color .12s; }
.asset-pass-foot .ico-btn:hover:not(:disabled) { color: var(--text-strong); background: var(--fill); }
.ico-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ico-btn:disabled { opacity: .4; cursor: not-allowed; }
.asset-pass-foot .ico-btn:is(.is-current, :active):not(:disabled) { color: var(--text-strong); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.asset-pass-foot { gap: 6px; }
.asset-ico-group { display: inline-flex; gap: 6px; margin: 0 6px 0 0; padding: 0 12px 0 0; border: 0; border-right: 1px solid var(--line); border-radius: 0; overflow: visible; }
@media (max-width: 900px) {
  .asset-pass-foot { display: flex; flex: 1 1 100%; justify-content: flex-end; }
  .asset-ico-group { margin: 0 auto 0 0; display: inline-flex; }
  .asset-ws-tabs { padding: 4px 8px 6px; }
}

/* Native disclosures share one compact chevron, including nested help. */
details > summary { --disclosure-angle: -45deg; }
details[open] > summary { --disclosure-angle: 45deg; }
details:not(.whats-this):not(.sc-eng) > summary::before,
.whats-this > summary::after,
.sc-eng > summary > span:first-child::before {
  content: "";
  display: inline-block;
  box-sizing: border-box;
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  color: var(--text-soft);
  transform: rotate(var(--disclosure-angle));
  vertical-align: 0.12em;
}
:is(.sensor-profile-panel, .mb-more, .mb-why, .iso-help, .sc-why, #frequencyDebug) > summary::before,
.sc-eng > summary > span:first-child::before { margin-inline: 1px 8px; }

:is(.sensor-profile-panel, .recording-details, .hourly-history-explainer, .rx-details, .ap-setup, .sc-eng) > summary {
  padding-block: 6px;
  min-height: 32px;
  box-sizing: border-box;
}
@media (pointer: coarse) {
  details > summary { min-height: 38px; }
}
.mb-family { display: block; margin: 10px 0 6px; color: var(--muted); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.mb-field legend + .mb-family { margin-top: 2px; }
/* ISO tab: which location and direction is worst right now. */
.asset-iso-headline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: 3px; background: var(--panel-2); font-size: 13px; }
.asset-iso-headline .iso-zone-chip { width: auto; padding-inline: 6px; white-space: nowrap; flex: none; }
.asset-iso-headline > span:first-child { color: var(--muted); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.asset-iso-worst { margin-left: 6px; padding: 1px 6px; border: 1px solid var(--line-2); border-radius: 3px; font-style: normal; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* Screening > Machine details: the form in clear rows, the sensor range tucked away. */
.sc-settings { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.sc-settings > label.sc-check { align-self: end; min-height: 38px; }
.sc-settings-actions { grid-column: 1 / -1; }
.sc-range { grid-column: 1 / -1; border: 1px solid var(--line-2); border-radius: 3px; background: var(--panel); }
.sc-range > summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; font-size: 12px; color: var(--text-strong); list-style: none; }
.sc-range > summary::-webkit-details-marker { display: none; }
.sc-range > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .12s; flex: none; }
.sc-range[open] > summary::before { transform: rotate(45deg); }
.sc-range > summary em { margin-left: auto; font-size: 11px; color: var(--muted); }
.sc-range > p { margin: 0; padding: 0 12px 10px; font-size: 11.5px; color: var(--muted); }
.sc-range-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 110px 110px; align-items: center; gap: 10px 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.sc-range-row.is-unknown { box-shadow: inset 3px 0 0 var(--warning); }
.sc-range-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sc-range-name strong { font-size: 13px; color: var(--text-strong); overflow-wrap: anywhere; }
.sc-range-name small { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.sc-settings .sc-range-row label { gap: 3px; font-size: 10px; }
.sc-range-row input { width: 100%; min-width: 0; }
.sc-range-row input:disabled { opacity: .6; }
@media (max-width: 600px) { .sc-range-row { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); } .sc-range-name { grid-column: 2 / -1; } .sc-range-row label:first-of-type { grid-column: 2; } }
.sc-range-row > .asset-loc-num { grid-column: 1; grid-row: 1; order: 0; align-self: center; justify-self: start; margin: 0; }
.sc-range-row > .sc-range-name { grid-column: 2; grid-row: 1; }
.sc-range-row > label:nth-of-type(1) { grid-column: 3; grid-row: 1; }
.sc-range-row > label:nth-of-type(2) { grid-column: 4; grid-row: 1; }
@media (max-width: 600px) {
  .sc-range-row { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); }
  .sc-range-row > .sc-range-name { grid-column: 2 / -1; grid-row: 1; }
  .sc-range-row > label:nth-of-type(1) { grid-column: 2; grid-row: 2; }
  .sc-range-row > label:nth-of-type(2) { grid-column: 3; grid-row: 2; }
}

/* Screening: a thin line icon for every situation. */
.sc-ico { flex: none; width: 20px; height: 20px; color: var(--muted); }
.sc-ico-lg { width: 26px; height: 26px; color: var(--warning); }
.sc-ico-xl { width: 44px; height: 44px; stroke-width: 1.25; }
.sc-state { display: flex; align-items: center; gap: 16px; }
.sc-state > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sc-state.is-normal .sc-ico-xl { color: var(--normal); }
.sc-state.is-warning .sc-ico-xl { color: var(--warning); }
.sc-state.is-danger .sc-ico-xl { color: var(--critical); }
.sc-state .sc-none { color: var(--text-strong); font-size: 16px; }
.sc-issue-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.sc-issues.is-danger .sc-ico-lg { color: var(--critical); }
.sc-tips li { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 10px 12px; }
.sc-tips li > .sc-ico { width: 24px; height: 24px; color: var(--accent); margin-top: 1px; }
.sc-tips li > span { grid-column: 2; }
.sc-tips li > .btn { grid-column: 2; justify-self: start; }
.sc-legal { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 11px; line-height: 1.5; color: var(--muted); max-width: 110ch; }

/* ISO qualification and monitoring availability */
.asset-iso-qual { margin: 8px 0 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 2px; background: var(--panel-hdr); color: var(--text); font-size: 12px; line-height: 1.5; }
.asset-iso-qual p { margin: 0; }
.asset-iso-qual ul { margin: 6px 0 0; padding-left: 18px; }
.asset-iso-qual li.is-limited { color: var(--warning); }
.asset-iso-qual li.is-unverified { color: var(--muted); }
.mh-state.is-ok { color: var(--normal); }
.mh-state.is-down { color: var(--warning); }
#monitoringHealthPanel { margin-top: 12px; }

/* Alarm register */
#alarmRegisterPanel { margin-bottom: 12px; }
.al-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.al-item { padding: 9px 11px; border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: 2px; background: var(--panel-hdr); }
.al-item.is-critical { border-left-color: var(--critical); }
.al-head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.al-level { font-size: 11px; letter-spacing: .1em; color: var(--warning); }
.al-item.is-critical .al-level { color: var(--critical); }
.al-name { color: var(--text-strong); font-weight: 700; }
.al-reason, .al-action { margin: 5px 0 0; font-size: 12.5px; line-height: 1.5; }
.al-action span { margin-right: 6px; color: var(--accent); font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.al-ack { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 7px; font-size: 12px; }
.al-unacked { color: var(--warning); font-weight: 700; }
.al-acked { color: var(--muted); }
.al-form { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.al-form input { flex: 1 1 160px; min-width: 0; }

/* Plant summary */
.ps-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.ps-tile { padding: 9px 11px; border: 1px solid var(--border); border-radius: 2px; background: var(--panel-hdr); }
.ps-tile strong { display: block; font-size: 22px; line-height: 1.1; color: var(--text-strong); }
.ps-tile span { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ps-tile.is-critical strong { color: var(--critical); } .ps-tile.is-warning strong, .ps-tile.is-watch strong { color: var(--warning); } .ps-tile.is-normal strong { color: var(--normal); }
.ps-table td { vertical-align: top; font-size: 12.5px; line-height: 1.5; }
.ps-open { padding: 0; border: 0; background: none; color: var(--text-strong); font: inherit; font-weight: 700; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--border-2); text-underline-offset: 3px; }
.ps-open:hover { color: var(--accent); }
.ps-chip { display: inline-block; padding: 2px 7px; border-radius: 2px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; border: 1px solid var(--border-2); color: var(--muted); white-space: nowrap; }
.ps-chip.is-critical { color: var(--critical); border-color: var(--critical); } .ps-chip.is-warning, .ps-chip.is-watch { color: var(--warning); border-color: var(--warning); } .ps-chip.is-normal { color: var(--normal); border-color: var(--normal); }
.ps-trend.is-up { color: var(--warning); font-weight: 400; }
.ps-mon.is-down { color: var(--warning); } .ps-mon.is-ok { color: var(--normal); }
.ps-note { margin-top: 10px; }
