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

:root {
  --bg:             #090d13;
  --panel:          #0f141c;
  --panel-hdr:      #0b1017;
  --sidebar-bg:     #080c12;
  --appbar-bg:      #0a0f16;
  --border:         #1f2b39;
  --border-2:       #2e4258;
  --input-bg:       #0c1219;

  --text:           #b5c5d3;
  --text-strong:    #dce8f2;
  --muted:          #8095a8;
  --muted-2:        #5f7388;

  --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:    #d9847f;

  --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:   #070b11;
  --scroll-track-2: #0c1219;
  --scroll-thumb:   #31475d;
  --scroll-thumb-hover: #466783;
  --scroll-thumb-active: #8fb7d6;

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

/* ===================== 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(--border);
}

*::-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(--border-2);
  border-radius: 0;
  padding: 8px 10px;
  font: 12px "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0;
}

.fleet-search-input:focus,
.fleet-page-size:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(122, 184, 230, 0.25);
}

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

.perf-monitor {
  position: fixed;
  bottom: 6px;
  right: 8px;
  z-index: 9999;
  padding: 3px 8px;
  background: rgba(8, 14, 22, 0.82);
  border: 1px solid var(--border-2);
  color: var(--muted-2);
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  pointer-events: none;
  white-space: nowrap;
}

/* ===================== 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(--border);
  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-mono);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

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,
.overview-strip,
.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(--border);
  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);
}

/* Cyan top accent */
.sidebar::before {
  content: '';
  display: block;
  flex-shrink: 0;
  height: 2px;
  background: linear-gradient(90deg,
    var(--info-fg) 0%,
    rgba(122, 184, 230, 0.4) 55%,
    transparent 100%);
}

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

.brand-text {
  min-width: 0;
  flex: 1;
}

.brand-name {
  margin: 0;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--muted-2);
  font-size: 9.5px;
  letter-spacing: 0.03em;
}

.brand-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--normal);
  box-shadow: 0 0 6px rgba(59, 141, 102, 0.7);
  flex-shrink: 0;
  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(--border-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;
}

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

.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(--border);
  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(--border);
  color: var(--muted-2);
  font-size: 8.5px;
  font-family: "JetBrains Mono", monospace;
  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(--border);
  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(--border);
  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: flex;
  align-items: stretch;
  flex: 1;
  overflow-x: auto;
  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(--border);
  flex: 0 0 auto;
  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: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  overflow: hidden;
}

.appbar-time-cell {
  margin-left: auto;
  padding-right: 16px;
}

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

/* Appbar badges (with LED dot) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border: 1px solid var(--border-2);
  background: #0f1720;
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  max-width: 100%;
  text-overflow: ellipsis;
  overflow: hidden;
}

.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;
  gap: 4px;
  padding: 1px 6px;
  border: 1px solid var(--border-2);
  background: #0f1720;
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  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(--border);
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

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

/* Two-column: Asset Health */
.pane-two-col {
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 0.8fr);
  align-content: start;
}

.overview-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
}

.overview-card {
  min-width: 0;
  padding: 11px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
}

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

.overview-card strong {
  display: block;
  margin-top: 6px;
  color: var(--text-strong);
  font-family: "JetBrains Mono", monospace;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

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

.pane-condition .kpi-strip { grid-area: kpis; }
.pane-condition .metric-status-panel { grid-area: status; }

.pane-condition .engineering-summary-panel { grid-area: summary; }
.pane-condition .sensor-profile-panel      { grid-area: profile; }
.pane-condition .interpretation-panel { grid-area: notes; }
.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 {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  align-content: start;
}

/* 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(--border);
  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: #0891b2;
  border-bottom: 2px solid rgba(0,0,0,0.25);
  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(--border);
  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: #07121d;
  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 rgba(0,0,0,0.30);
  background: rgba(0,0,0,0.15);
  color: #071018;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.panel-meta {
  color: rgba(7, 18, 29, 0.62);
  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(--border-2);
  background: var(--input-bg);
  color: var(--text);
  font-size: 12px;
  border-radius: 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

select:not(:disabled) {
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-strong) 50%),
    linear-gradient(135deg, var(--text-strong) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) 50%,
    calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  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 rgba(104, 153, 196, 0.22);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border-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;
}

.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(--border);
}

.asset-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.asset-table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  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 td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  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: rgba(122, 184, 230, 0.04);
}

.asset-row:hover {
  background: rgba(104, 153, 196, 0.06);
}

.asset-row.active {
  background: rgba(122, 184, 230, 0.12);
  box-shadow: inset 3px 0 0 var(--info-fg);
}

.asset-id {
  color: var(--text-strong);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
}

.numeric {
  font-family: "JetBrains Mono", monospace;
  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(--border);
  color: var(--muted-2);
  font-family: "JetBrains Mono", monospace;
  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(--border-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(--border-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(--border-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 rgba(150, 118, 44, 0.4);
  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;
}

.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(--border);
  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: "JetBrains Mono", monospace;
  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: "JetBrains Mono", monospace;
  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%;
  height: 360px;
  overflow: hidden;
  background: #0b1119;
  border: 1px solid var(--border);
}

.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;
  min-width: 0;
  overflow: hidden;
}

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

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

.trend-status.ok {
  color: #7cc7a3;
}

.trend-status.warning {
  color: #d6b260;
}

.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(--border);
  background: #0d151f;
  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: "JetBrains Mono", monospace;
  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(--border-2);
  background: rgba(122, 184, 230, 0.05);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

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

.indicator-grid {
  display: grid;
  grid-template-columns: minmax(68px, 0.85fr) repeat(4, minmax(68px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  font-family: "JetBrains Mono", monospace;
  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: "JetBrains Mono", "Consolas", "Courier New", monospace;
  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: "JetBrains Mono", "Consolas", "Courier New", monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.indicator-grid > .indicator-row-label {
  background: rgba(122, 184, 230, 0.05);
}

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

.engineering-grid > div {
  border: 1px solid var(--border);
  background: #0d151f;
  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: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 600;
}

.fft-note {
  margin: 4px 0 6px;
  padding: 7px 8px;
  border-left: 3px solid var(--border-2);
  background: rgba(122, 184, 230, 0.07);
  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: "JetBrains Mono", monospace;
  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(--border-2);
  background: var(--control-bg);
  border-radius: 0;
}

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

.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(--border-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(--border-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(--border-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(--border);
  border-left: 3px solid var(--border-2);
  background: var(--input-bg);
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  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(--border);
}

.device-config-summary > div {
  min-width: 0;
  padding: 8px 10px;
  background: #0d151f;
}

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

.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(--border);
}

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

.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(--border-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(--border);
}

.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(--border);
  background: #0d151f;
}

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

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

.threshold-save-actions .form-note {
  max-width: 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 > span:first-child {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-status-row > span:last-child {
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
  color: var(--text-soft);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
}

.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(--border);
}

.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: "JetBrains Mono", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

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

.report-recorder {
  display: grid;
  gap: 12px;
}

.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(--border);
}

.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: "JetBrains Mono", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.report-file-row {
  grid-column: span 2;
}

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

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

@media (max-width: 900px) {
  .threshold-groups,
  .metric-status-grid,
  .report-status-grid,
  .device-config-summary,
  .system-health-grid {
    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(--border);
  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: "JetBrains Mono", monospace;
  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;
}

/* ===================== 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);
  }

  .pane-two-col {
    grid-template-columns: 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;
  }

  /* Preset buttons compact */
  .fft-band-presets .seg-btn {
    min-width: 58px;
    padding: 3px 5px;
    font-size: 9px;
  }

  .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(--border);
    border-bottom: 1px solid var(--border);
  }

  .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(--border-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(--border);
    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: 40px;
    height: 40px;
    padding: 0;
    gap: 0;
    align-items: stretch;
  }

  .appbar-breadcrumb {
    display: none;
  }

  .appbar-indicators {
    grid-column: 2;
    grid-row: 1;
    height: 40px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    flex-wrap: nowrap;
    flex: none;
    padding: 0;
    border-top: none;
    width: 100%;
  }

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

  .appbar-cell {
    flex: 0 0 auto;
    height: 100%;
    padding: 0 12px;
    border-left: 1px solid var(--border);
    border-right: 0;
  }

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

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

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

  .pane-condition .engineering-summary-panel,
  .pane-condition .sensor-profile-panel,
  .pane-condition .interpretation-panel,
  .pane-condition .indicators-panel {
    grid-area: auto;
  }

  .kpi-strip,
  .pane-condition .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .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: 36px;
    height: 36px;
  }
  .appbar-time-cell { display: none; }
  .appbar-indicators { height: 36px; }

  .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: 40px;
  }

  /* KPI single column */
  .kpi-strip {
    grid-template-columns: 1fr;
  }

  .overview-strip {
    grid-template-columns: 1fr;
  }

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

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

  .asset-table { min-width: 680px; }

  .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;
  }

  .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;
  }

  .panel-toolbar .chart-control-inline,
  .panel-toolbar .fft-axis-field,
  .panel-toolbar .fft-band-field {
    width: 100%;
    justify-content: space-between;
  }

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

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

  .panel-toolbar .segmented {
    flex: 1;
  }

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

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

  /* Segmented controls fill available space */
  .segmented {
    flex: 1;
  }

  .seg-btn {
    flex: 1;
    min-width: 0;
  }

  .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);
  }

  .pane-two-col {
    grid-template-columns: minmax(0, 2.4fr) minmax(300px, 0.9fr);
  }

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

/* Per-plot status footer: truthful state under every chart */
.chart-status {
  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(--border);
  background: #0b1119;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
  overflow: hidden;
}

/* ============================================================
   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(--border);
  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 ───────────────────────────────── */
.ai-prediction-main {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.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;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.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;
}

/* ── Confidence 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(--border);
  border-bottom: 1px solid var(--border);
}

.ai-decision-line {
  display: flex;
  justify-content: space-between;
  gap: 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;
}

.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(--border-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(--border-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(--border-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(--border);
  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(--border-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(--border-2));
  color: var(--accent);
}

.ai-signature-card-outside .ai-signature-badge,
.ai-signature-card-invalid .ai-signature-badge {
  border-color: var(--border-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(--border);
  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(--border);
  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(--border);
  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(--border-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(--border);
}

.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(--border);
}

.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;
}

.ai-threshold-config {
  border-top: 1px solid var(--border);
  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(--border);
  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(--border-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(--border-2));
}

.ai-chip-fallback {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border-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(--border-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;
}

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

.ai-feature-checks {
  display: flex;
  flex-direction: column;
  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(--border, #2a4053);
  background: #0a141e;
  color: var(--text-secondary, #9fb3c6);
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 12px;
}

.ai-feature-count.is-warning {
  border-color: #9b7a2f;
  color: #e0b85a;
}

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

/* Clickable checkbox labels */
.ai-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  padding: 5px 8px 5px 6px;
  border-left: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
  line-height: 1.3;
}

.ai-check-item:hover {
  background: var(--control-hover);
  color: var(--text-strong);
  border-left-color: rgba(122, 184, 230, 0.3);
}

.ai-check-item:has(input:checked) {
  border-left-color: var(--accent);
  color: var(--text-strong);
}

/* ── Custom JetBrains-style checkbox ────────────────────────── */
.ai-check-item input[type="checkbox"] {
  /* Fully custom — 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(--border-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: rgba(122, 184, 230, 0.06);
}

/* 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 rgba(122, 184, 230, 0.32), 0 0 0 1px var(--accent);
}

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

.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(--border);
}

.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(--border-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: 100%;
}

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

.ai-btn-train {
  background: var(--info);
  border-color: var(--info);
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.07em;
  width: 100%;
  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: 1;
}

/* 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: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 14px;
}

.ai-training-actions .ai-btn-train,
.ai-training-actions .ai-model-delete {
  width: 100%;
  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(--border);
  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(--border);
}

.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(--border-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: 16px;
  bottom: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.vs-toast {
  border: 1px solid var(--border-2);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0;
  opacity: 0.98;
  transform: translateY(0);
  transition: opacity 0.22s ease, transform 0.22s ease;
  overflow-wrap: anywhere;
}

.vs-toast-success {
  border-color: var(--normal);
  background: var(--normal-bg);
  color: var(--normal-fg);
}

.vs-toast-error {
  border-color: var(--critical);
  background: var(--critical-bg);
  color: var(--critical-fg);
}

.vs-toast-warn {
  border-color: var(--warning);
  background: var(--warning-bg);
  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;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}

/* ── Advanced / Experimental shape features section ────────── */
.ai-advanced-section {
  margin-top: 8px;
  border: 1px solid var(--border, #ddd);
  border-radius: 4px;
  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-mono, 'JetBrains Mono', monospace);
}

.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) {
  /* Stack Y min/max row fully on mobile */
  .y-minmax-row {
    width: 100%;
    justify-content: space-between;
  }

  .y-range-input {
    width: 72px;  /* more finger-friendly */
    flex: 1;
    min-width: 0;
  }

  .y-pan-btn {
    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;
  }

  /* Overview strip: 2 cols even on phone (condensed numbers) */
  .overview-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Between 600px and 900px: ensure overview strip is 3 cols */
@media (min-width: 601px) and (max-width: 900px) {
  .overview-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* 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;
  
