/* =========================================================================
   PINOYFLUX DESIGN SYSTEM — ACHROMATIC LIQUID GLASS × LINEAR × GRAFANA
   Pure Obsidian Neutrals, Specular Glass Surfaces, Strict 90/10 Color Discipline
   100% Self-Hosted Offline Typography (Inter + IBM Plex Mono)
   ========================================================================= */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('inter-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('inter-latin-500-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('inter-latin-600-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('inter-latin-700-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('ibm-plex-mono-latin-500-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('ibm-plex-mono-latin-600-normal.woff2') format('woff2');
}

:root {
  /* True Neutral Obsidian Palette (Zero Blue-Slate Cast) */
  --bg: #08080a;
  --surface: #101013;
  --surface-alt: #0c0c0f;
  --surface-elevated: #16161b;
  --surface-hover: rgba(255, 255, 255, 0.045);

  /* Achromatic Apple-Inspired Liquid Glass (Refractive Neutral, Not Cyan) */
  --glass-bg: rgba(16, 16, 20, 0.72);
  --glass-bg-strong: rgba(20, 20, 25, 0.84);
  --glass-pill: linear-gradient(180deg, rgba(255, 255, 255, 0.115), rgba(255, 255, 255, 0.055));
  --glass-border: rgba(255, 255, 255, 0.085);
  --glass-border-strong: rgba(255, 255, 255, 0.15);
  --glass-specular: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 -1px 0 rgba(255, 255, 255, 0.025);

  /* Hairline Dividers */
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* High-Contrast Ink Hierarchy (WCAG 2.1 AA+ Verified) */
  --text: #f4f4f6;
  --text-secondary: #a1a1aa;
  --text-muted: #8b8b97;

  /* Solid Monochrome Primary Action (Linear / Apple / Vercel Restraint) */
  --cta-bg: #f4f4f6;
  --cta-hover: #ffffff;
  --cta-ink: #09090b;

  /* Precision Focus & Data Trace Accent (Used Sparingly — Focus Rings & Charts) */
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-muted: rgba(96, 165, 250, 0.12);
  --accent-border: rgba(96, 165, 250, 0.34);

  /* Strict Semantic Telemetry Status Only */
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.11);
  --success-border: rgba(52, 211, 153, 0.28);

  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.11);
  --warning-border: rgba(251, 191, 36, 0.32);

  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.34);

  /* Geometry & Depth */
  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius-md: 13px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-elevated: 0 24px 60px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.11);

  /* Physics-Based Easing & Motion */
  --ease-out-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring-fallback: cubic-bezier(0.34, 1.36, 0.64, 1);
  --ease-spring: linear(
    0, 0.014 1.1%, 0.056 2.3%, 0.207 4.9%, 0.684 12.1%, 0.879 15.8%,
    0.996 19.2%, 1.045 22.1%, 1.06 25.1%, 1.053 28.4%, 1.019 36.2%,
    0.999 44.8%, 0.995 54%, 1.001 73%, 1
  );

  /* Typography */
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  color-scheme: dark;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(1000px 480px at 50% -18%, rgba(255, 255, 255, 0.032), transparent 64%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.5;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(161, 161, 170, 0.22);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(161, 161, 170, 0.38);
  border: 2px solid transparent;
  background-clip: content-box;
}

[hidden] {
  display: none !important;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link:focus-visible {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.55rem 0.95rem;
  background: var(--cta-bg);
  color: var(--cta-ink);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
  box-shadow: var(--shadow-elevated);
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lucide {
  width: 16px;
  height: 16px;
  stroke-width: 1.65;
  flex-shrink: 0;
  vertical-align: middle;
}

.icon-sm .lucide,
.lucide.icon-sm {
  width: 14px;
  height: 14px;
}

/* =========================================================================
   SAME-DOCUMENT VIEW TRANSITIONS
   ========================================================================= */

::view-transition-old(workspace-view),
::view-transition-new(workspace-view) {
  animation-duration: 180ms;
  animation-timing-function: var(--ease-out-smooth);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

/* =========================================================================
   DEDICATED FULL-SCREEN LOGIN — ASYMMETRIC EDITORIAL SPLIT + LIQUID GLASS
   ========================================================================= */

.auth-body {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  min-height: 100svh;
  background: var(--bg);
}

.auth-editorial {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.75rem 3.25rem;
  border-right: 1px solid var(--border);
  background:
    radial-gradient(640px 440px at 15% 22%, rgba(255, 255, 255, 0.045), transparent 62%),
    radial-gradient(480px 360px at 82% 84%, rgba(96, 165, 250, 0.05), transparent 60%),
    #0a0a0d;
  overflow: hidden;
}

.auth-editorial-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
}

.auth-editorial-copy {
  max-width: 460px;
  margin: auto 0;
  padding: 2rem 0;
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

.auth-kicker-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.auth-editorial-copy h2 {
  margin: 0;
  font-size: clamp(1.75rem, 2.8vw, 2.35rem);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -0.035em;
  color: var(--text);
}

.auth-editorial-copy p {
  margin: 1rem 0 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.auth-specs {
  margin-top: 2.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.auth-spec-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.auth-spec-item span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.auth-spec-item strong {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
}

.auth-editorial-foot {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.25rem 1.5rem;
  width: 100%;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(28px) saturate(165%);
  -webkit-backdrop-filter: blur(28px) saturate(165%);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-lg);
  padding: 2.15rem 2rem;
  box-shadow: var(--shadow-elevated);
}

.auth-brand-mobile {
  display: none;
  align-items: center;
  gap: 0.7rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  flex-shrink: 0;
  display: block;
}

.auth-wordmark {
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.15;
}

.auth-wordmark span,
.brand-title span {
  color: var(--text-secondary);
  font-weight: 500;
}

.auth-system-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.auth-header {
  margin-bottom: 1.5rem;
}

.auth-header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}

.auth-subtitle {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-wrap > .input-leading-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
  display: inline-flex;
  align-items: center;
}

.auth-form input {
  width: 100%;
  font-family: var(--sans);
  font-size: max(0.95rem, 1em);
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  background: rgba(8, 8, 10, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.auth-form .input-icon-wrap input {
  padding-left: 2.5rem;
}

.auth-form input:hover {
  border-color: var(--border-strong);
}

.auth-form input:focus {
  border-color: rgba(255, 255, 255, 0.36);
  background: rgba(8, 8, 10, 0.94);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.07);
}

.auth-form input[name='setupCode'] {
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

.auth-form input[aria-invalid='true'] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.14);
}

.password-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  color: var(--text-secondary);
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 500;
  min-height: 28px;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-xs);
}

.password-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: transparent;
}

.auth-submit {
  width: 100%;
  min-height: 44px;
  margin-top: 0.45rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-submit.is-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.auth-notice {
  margin-bottom: 1.1rem;
  padding: 0.72rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 0.81rem;
}

.auth-notice.warn {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: #fde68a;
}

.auth-notice p {
  margin: 0;
}

.auth-blocked-hint {
  margin-top: 0.5rem !important;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.auth-error {
  margin-bottom: 1.1rem;
  padding: 0.72rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: #fecaca;
  font-size: 0.81rem;
}

/* =========================================================================
   APPLICATION SHELL — ACHROMATIC LIQUID GLASS SIDEBAR & TOPBAR
   ========================================================================= */

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(28px) saturate(165%);
  -webkit-backdrop-filter: blur(28px) saturate(165%);
  border-right: 1px solid var(--glass-border);
  padding: 1rem 0.75rem 0.9rem;
  overflow-y: auto;
  z-index: 25;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.25rem 0.5rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.4rem;
}

.brand-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0;
  line-height: 1.15;
  color: var(--text);
}

.brand-device {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-top: 0.14rem;
  letter-spacing: 0.04em;
}

.side-nav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  flex: 1;
}

/* True Achromatic Apple Liquid Glass Sliding Active Pill */
.nav-active-pill {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--glass-pill);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--glass-specular), 0 4px 14px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  opacity: 0;
  z-index: 0;
  will-change: transform, height;
}

.nav-active-pill.is-ready {
  opacity: 1;
}

.nav-group-label {
  position: relative;
  z-index: 1;
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0.95rem 0.6rem 0.3rem;
}

.side-nav a,
.side-nav-action {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.825rem;
  font-weight: 500;
  min-height: 34px;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.nav-item-main {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.side-nav a .lucide,
.side-nav-action .lucide {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  transition: color 140ms ease;
}

.side-nav a:hover,
.side-nav-action:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: transparent;
}

.side-nav a:hover .lucide,
.side-nav-action:hover .lucide {
  color: var(--text-secondary);
}

.side-nav a[aria-current='page'] {
  color: #ffffff;
  font-weight: 500;
}

.side-nav a[aria-current='page'] .lucide {
  color: #ffffff;
}

.side-nav:not(.has-pill) a[aria-current='page'] {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

@media (forced-colors: active) {
  .nav-active-pill {
    display: none;
  }

  .side-nav a[aria-current='page'] {
    border-inline-start: 3px solid CanvasText;
  }
}

.nav-badge {
  background: var(--warning);
  color: #09090b;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0.05rem 0.42rem;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 0.85rem 0.35rem 0;
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.db-mini-status {
  display: grid;
  gap: 0.28rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.db-mini-status div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.db-mini-status strong {
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.account-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.48rem 0.35rem 0.1rem;
  border-top: 1px solid var(--border-subtle);
}

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--border-strong);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.account-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.account-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-role {
  font-family: var(--mono);
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* =========================================================================
   MAIN WORKSPACE & CALM TRANSLUCENT TOPBAR (NO RAINBOW BADGE SOUP)
   ========================================================================= */

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.72rem 1.75rem;
  background: var(--glass-bg);
  backdrop-filter: blur(28px) saturate(165%);
  -webkit-backdrop-filter: blur(28px) saturate(165%);
  border-bottom: 1px solid var(--glass-border);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.page-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-right: 0.45rem;
}

.topbar-meta-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-left: 0.65rem;
  border-left: 1px solid var(--border);
}

.workspace-body {
  padding: 1.25rem 1.75rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  max-width: 1460px;
  width: 100%;
}

/* =========================================================================
   SLIM TELEMETRY STATUS STRIP (REPLACES BULKY ALERT BOX)
   ========================================================================= */

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.1rem 0 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.status-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16);
  flex-shrink: 0;
}

.status-bar.warn .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18);
}

.status-bar.critical .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

.status-bar strong {
  font-family: var(--mono);
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.03em;
}

.status-bar.warn strong {
  color: var(--warning);
}

.status-bar.critical strong {
  color: var(--danger);
}

.status-bar span {
  font-size: 0.81rem;
  color: var(--text-secondary);
}

.action-toast {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-pill);
}

.action-toast:empty {
  display: none;
}

/* =========================================================================
   SURFACES & REFINED SUBTLE STATUS CHIPS
   ========================================================================= */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.35rem;
  box-shadow: var(--shadow-card);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  padding: 0.18rem 0.52rem;
  border-radius: var(--radius-xs);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.025em;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-secondary);
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.badge-cyan {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
}

.badge-cyan::before {
  background: var(--accent);
}

.badge-ok {
  color: #d1fae5;
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.2);
}

.badge-ok::before {
  background: var(--success);
}

.badge-warn {
  color: #fef3c7;
  background: rgba(251, 191, 36, 0.085);
  border-color: rgba(251, 191, 36, 0.24);
}

.badge-warn::before {
  background: var(--warning);
}

.badge-danger {
  color: #fee2e2;
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.28);
}

.badge-danger::before {
  background: var(--danger);
}

.badge-neutral {
  color: var(--text-secondary);
}

/* =========================================================================
   LAYOUT GRIDS & CLEAN EDITORIAL HEADINGS
   ========================================================================= */

.page-view {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  view-transition-name: workspace-view;
}

.page-view[hidden] {
  view-transition-name: none;
}

.split-asymmetric {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(0, 1fr);
  gap: 1.15rem;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

h3 {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.mono-dim {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.hint {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.hint code,
.info-banner code,
.data-table code {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  padding: 0.08rem 0.35rem;
  border-radius: 5px;
}

/* =========================================================================
   UNIFIED ARCHITECTURAL INSTRUMENT DECK (ZERO CARD-ITIS)
   ========================================================================= */

.instrument-deck {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.readout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cell {
  position: relative;
  padding: 1.25rem 1.35rem 1.15rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  transition: background-color 180ms ease;
}

.cell:last-child {
  border-right: none;
}

.cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.cell .k {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}

.cell-icon {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
}

.cell .v {
  font-family: var(--mono);
  font-size: 2.15rem;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.04em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.cell .v small {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-muted);
  margin-left: 0.2rem;
}

.cell p {
  margin: 0.55rem 0 0;
  font-size: 0.73rem;
  color: var(--text-muted);
}

/* Whisper-thin 2px bottom hairline threshold indicator */
.sensor-meter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.sensor-meter-fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  background: rgba(255, 255, 255, 0.28);
}

@media (prefers-reduced-motion: no-preference) {
  .sensor-meter-fill {
    transition: transform 360ms var(--ease-out-smooth), background-color 200ms ease;
  }
}

.cell.nominal .sensor-meter-fill {
  background: rgba(52, 211, 153, 0.55);
}

.cell.warn {
  background: rgba(251, 191, 36, 0.045);
}

.cell.warn .v,
.cell.warn .cell-icon {
  color: var(--warning);
}

.cell.warn .sensor-meter-fill {
  background: var(--warning);
}

.cell.critical {
  background: rgba(248, 113, 113, 0.065);
}

.cell.critical .v,
.cell.critical .cell-icon {
  color: var(--danger);
}

.cell.critical .sensor-meter-fill {
  background: var(--danger);
}

/* Integrated Operational Metadata Ribbon directly inside the Instrument Deck */
.instrument-ribbon {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}

.instrument-ribbon .ribbon-item {
  padding: 0.78rem 1.35rem;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.16rem;
}

.instrument-ribbon .ribbon-item:last-child {
  border-right: none;
}

.ribbon-item .k {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
}

.ribbon-item strong {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.ribbon-item small {
  font-size: 0.71rem;
  color: var(--text-muted);
}

/* Unified Hairline KPI Strip for Secondary Pages (AUTO, Sleep, Analytics, Testing) */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  overflow: hidden;
  margin-top: 0.35rem;
}

.kpi-box {
  padding: 0.85rem 1rem;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.kpi-box:last-child {
  border-right: none;
}

.kpi-box .k {
  font-size: 0.69rem;
  font-weight: 500;
  color: var(--text-muted);
}

.kpi-box strong {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-box small {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.snapshot-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  overflow: hidden;
  margin-top: 0.8rem;
}

.snapshot-item {
  padding: 0.75rem 0.9rem;
  border-right: 1px solid var(--border-subtle);
}

.snapshot-item:last-child {
  border-right: none;
}

.snapshot-item .k {
  display: block;
  font-size: 0.67rem;
  font-weight: 500;
  color: var(--text-muted);
}

.snapshot-item strong {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--mono);
  font-size: 1.02rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* =========================================================================
   BUTTONS, INPUTS & UNTITLED-UI / LINEAR FORM CONTROLS
   ========================================================================= */

button,
select,
input {
  font-family: var(--sans);
  font-size: 0.825rem;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.8rem;
  min-height: 36px;
}

input,
select {
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

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

input:focus,
select:focus {
  border-color: rgba(255, 255, 255, 0.34);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.065);
}

input[type='number'],
input[type='datetime-local'] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 220ms var(--ease-spring-fallback);
}

@supports (transition-timing-function: linear(0, 1)) {
  @media (prefers-reduced-motion: no-preference) {
    button {
      transition-timing-function: ease, ease, ease, var(--ease-spring);
    }
  }
}

button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.09);
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.34rem 0.7rem;
  min-height: 32px;
  font-size: 0.78rem;
}

/* Crisp High-Contrast Solid Monochrome Primary Button */
.btn-primary {
  background: var(--cta-bg);
  border-color: var(--cta-bg);
  color: var(--cta-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.btn-primary:hover:not(:disabled) {
  background: var(--cta-hover);
  border-color: var(--cta-hover);
  color: var(--cta-ink);
}

.btn-warn {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning);
}

.btn-warn:hover:not(:disabled) {
  border-color: var(--warning);
  background: rgba(251, 191, 36, 0.18);
}

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

.btn-danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: rgba(248, 113, 113, 0.2);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

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

.btn-mode.active,
.btn-fan.active {
  background: var(--cta-bg);
  border-color: var(--cta-bg);
  color: var(--cta-ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.65rem;
  align-items: end;
  margin-bottom: 0.9rem;
}

.filter-bar .field,
.stack-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.filter-bar label,
.stack-form label {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.filter-bar select,
.filter-bar input,
.stack-form input,
.stack-form select {
  width: 100%;
}

.filter-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.inline-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.unit {
  text-transform: none;
}

.backup-filename {
  display: inline-block;
  max-width: 158px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.user-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 96px auto;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.85rem;
}

.user-add-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.user-add-form label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.user-add-form button {
  white-space: nowrap;
}

.inline-form {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1.2fr auto;
  gap: 0.55rem;
  margin-top: 0.85rem;
  align-items: end;
}

.inline-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.inline-form label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* =========================================================================
   RECOMMENDATIONS, BANNERS & RESULTS
   ========================================================================= */

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

.rec-item {
  border: 1px solid var(--border);
  border-left: 2px solid var(--text-secondary);
  background: var(--surface-alt);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
}

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

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

.rec-item strong {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  margin-bottom: 0.16rem;
  color: var(--text);
}

.rec-item div {
  color: var(--text-secondary);
}

.info-banner {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.72rem 0.95rem;
  font-size: 0.81rem;
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
}

.info-banner.warn {
  border-color: var(--warning-border);
  background: rgba(251, 191, 36, 0.065);
  color: #fde68a;
}

.result-card,
.pending-box {
  margin-top: 0.75rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.72rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  font-variant-numeric: tabular-nums;
}

.pending-box:empty {
  display: none;
}

.empty-state {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.81rem;
  line-height: 1.55;
}

/* =========================================================================
   GRAFANA-STYLE ECHARTS & ACHROMATIC GLASS SEGMENTED CONTROLS
   ========================================================================= */

.echarts-box {
  position: relative;
  width: 100%;
  height: 272px;
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.echarts-canvas {
  width: 100%;
  height: 100%;
}

.echarts-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  font-size: 0.81rem;
  color: var(--text-muted);
  pointer-events: none;
}

.chart-frame.is-echarts-active {
  display: none;
}

.chart-frame {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 0.45rem;
  align-items: stretch;
}

.chart-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--text-muted);
  text-align: right;
  padding: 0.2rem 0;
  font-variant-numeric: tabular-nums;
}

.waveform {
  width: 100%;
  height: 180px;
  display: block;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.waveform .chart-grid {
  stroke: rgba(255, 255, 255, 0.055);
  stroke-width: 1;
}

.waveform .chart-area {
  fill: rgba(96, 165, 250, 0.1);
}

.waveform path#wave,
.waveform path#analytics-wave {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.75;
  vector-effect: non-scaling-stroke;
}

.waveform .chart-thresh-warn {
  stroke: var(--warning);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.85;
  vector-effect: non-scaling-stroke;
}

.waveform .chart-thresh-crit {
  stroke: var(--danger);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.88;
  vector-effect: non-scaling-stroke;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
  font-variant-numeric: tabular-nums;
}

.chart-labels strong {
  color: var(--text);
  font-weight: 500;
}

/* Hide duplicated start/end timestamps when ECharts owns the X axis */
.chart-labels.echarts-owned .axis-edge-fallback {
  display: none;
}

.chart-hover-readout {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text);
  min-height: 1.1rem;
}

/* Achromatic Apple Liquid Glass Segmented Control */
.metric-switcher {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

.metric-switcher button {
  min-height: 26px;
  padding: 0.16rem 0.62rem;
  font-size: 0.73rem;
  font-family: var(--sans);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  box-shadow: none;
  color: var(--text-secondary);
}

.metric-switcher button:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border-color: transparent;
}

.metric-switcher button[aria-pressed='true'] {
  background: var(--glass-pill);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: var(--glass-specular), 0 2px 8px rgba(0, 0, 0, 0.28);
}

.chart-legend {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
}

.legend-dash {
  display: inline-block;
  width: 12px;
  border-top: 1.5px dashed var(--warning);
}

.legend-dash.crit {
  border-top-color: var(--danger);
}

.compare-filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.65rem;
  align-items: end;
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  margin-bottom: 0.9rem;
  border-top: 1px solid var(--border-subtle);
}

.compare-filter-row .field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.compare-filter-row label {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.compare-filter-row input {
  width: 100%;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  font-size: 0.74rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-inline input[type='checkbox'] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--cta-bg);
  cursor: pointer;
}

.password-change-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: end;
}

.password-change-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.password-change-form label {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.password-change-form button {
  white-space: nowrap;
}

/* =========================================================================
   TABLES — CARBON / LINEAR HIGH-CONTRAST DATA GRID
   ========================================================================= */

.table-wrap {
  overflow: auto;
  max-block-size: min(460px, 68vh);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.79rem;
}

.data-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
}

.data-table th,
.data-table td {
  padding: 0.56rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.two-col .data-table th,
.two-col .data-table td {
  padding: 0.48rem 0.52rem;
  font-size: 0.76rem;
}

.data-table th {
  font-size: 0.67rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(12, 12, 15, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.055em;
}

.data-table td.num,
.data-table th.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.data-table td.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr {
  transition: background-color 110ms ease;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.028);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.empty-cell {
  text-align: center !important;
  color: var(--text-muted);
  padding: 1.5rem !important;
}

.data-table input[type='number'] {
  width: 78px;
  min-height: 30px;
  padding: 0.22rem 0.42rem;
  font-size: 0.76rem;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* =========================================================================
   PROGRESS BAR, KV LISTS & FOOTER
   ========================================================================= */

.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.progress-fill {
  height: 100%;
  background: var(--cta-bg);
  border-radius: var(--radius-pill);
}

@media (prefers-reduced-motion: no-preference) {
  .progress-fill {
    transition: width 320ms var(--ease-out-smooth);
  }
}

.kv-list {
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

.kv-list > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.48rem;
}

.kv-list > div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.kv-list dt {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.kv-list dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.77rem;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 0 0;
  margin-top: auto;
  font-size: 0.73rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}

/* =========================================================================
   ACHROMATIC LIQUID GLASS NATIVE CONFIRMATION DIALOG
   ========================================================================= */

dialog.confirm-dialog {
  padding: 0;
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-lg);
  background: var(--glass-bg-strong);
  backdrop-filter: blur(32px) saturate(170%);
  -webkit-backdrop-filter: blur(32px) saturate(170%);
  box-shadow: var(--shadow-elevated);
  color: var(--text);
  width: min(444px, calc(100vw - 2rem));
  max-width: 100%;
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 240ms;
  transition-timing-function: var(--ease-out-smooth);
  transition-behavior: allow-discrete;
}

@media (prefers-reduced-motion: no-preference) {
  dialog.confirm-dialog {
    transform: translateY(10px) scale(0.96);
  }
}

dialog.confirm-dialog[open]:not([data-closing]) {
  display: flex;
  flex-direction: column;
  opacity: 1;

  @starting-style {
    opacity: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    transform: translateY(0) scale(1);

    @starting-style {
      transform: translateY(10px) scale(0.96);
    }
  }
}

dialog.confirm-dialog[open][data-closing] {
  display: flex;
  flex-direction: column;
  opacity: 0;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog.confirm-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  overflow: hidden;
  overscroll-behavior: contain;
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 240ms;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog.confirm-dialog[open]:not([data-closing])::backdrop {
  background-color: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  @starting-style {
    background-color: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.confirm-dialog,
  dialog.confirm-dialog::backdrop {
    transition-duration: 100ms;
  }
}

.dialog-body {
  padding: 1.45rem 1.5rem;
}

.dialog-body h1 {
  margin: 0 0 0.5rem;
  font-size: 1.04rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.dialog-body p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  padding: 0.95rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(8, 8, 10, 0.42);
}

/* =========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================= */

.mobile-only {
  display: none;
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@media (max-width: 1024px) {
  .auth-body {
    grid-template-columns: 1fr;
  }

  .auth-editorial {
    display: none;
  }

  .auth-brand-mobile {
    display: flex;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 264px;
    z-index: 40;
    transform: translateX(-105%);
    background: var(--glass-bg-strong);
  }

  @media (prefers-reduced-motion: no-preference) {
    .sidebar {
      transition: transform 240ms var(--ease-out-smooth);
    }
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.65);
  }

  .mobile-only {
    display: inline-flex;
  }

  .topbar {
    padding: 0.68rem 1rem;
  }

  .topbar-meta-group {
    padding-left: 0;
    border-left: none;
  }

  .workspace-body {
    padding: 1rem;
  }

  .readout,
  .instrument-ribbon,
  .kpi-strip,
  .snapshot-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cell,
  .instrument-ribbon .ribbon-item,
  .kpi-box,
  .snapshot-item {
    border-bottom: 1px solid var(--border-subtle);
  }

  .split-asymmetric,
  .two-col,
  .inline-form,
  .user-add-form,
  .password-change-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .workspace-body {
    padding: 0.85rem;
  }

  .topbar {
    padding: 0.62rem 0.85rem;
  }

  .readout,
  .instrument-ribbon,
  .kpi-strip,
  .snapshot-strip {
    grid-template-columns: 1fr;
  }

  .cell,
  .instrument-ribbon .ribbon-item,
  .kpi-box,
  .snapshot-item {
    border-right: none;
  }

  .echarts-box {
    height: 210px;
  }
}

@media (pointer: coarse) {
  button,
  select,
  input {
    min-height: 44px;
  }

  .metric-switcher button {
    min-height: 36px;
  }
}

/* =====================================================
   Added for the real hardware (7 sensors, buzzer, LED, tests)
===================================================== */

.readout-sub {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--border-subtle);
}

.readout.is-stale .v { opacity: 0.55; }

.lv-warn   { color: #fbbf24; }
.lv-danger { color: #f87171; font-weight: 600; }
.lv-low    { color: #93c5fd; }

.led-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.5rem;
  border-radius: 50%;
  vertical-align: middle;
  background: #52525b;
}
.led-dot.g { background: #34d399; box-shadow: 0 0 8px rgba(52, 211, 153, 0.6); }
.led-dot.y { background: #fbbf24; box-shadow: 0 0 8px rgba(251, 191, 36, 0.6); }
.led-dot.r { background: #f87171; box-shadow: 0 0 8px rgba(248, 113, 113, 0.6); }
.led-dot.b { background: linear-gradient(90deg, #34d399, #fbbf24, #f87171); }
.led-dot.o { background: #52525b; box-shadow: none; }

@media (prefers-reduced-motion: no-preference) {
  .led-dot.b { animation: led-blink 1.8s steps(1, end) infinite; }
}
@keyframes led-blink {
  0%   { background: #34d399; }
  33%  { background: #fbbf24; }
  66%  { background: #f87171; }
}

.sensor-test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.sensor-test {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
}

.sensor-test .st-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.sensor-test .st-values { min-height: 3.4em; line-height: 1.7; }

.maint-locked { opacity: 0.45; pointer-events: none; }

.auth-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 1.1rem;
  padding: 0.25rem;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}
.auth-tabs a {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}
.auth-tabs a.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #f4f4f6);
}

a.side-nav-action { text-decoration: none; }

/* =====================================================
   Maintenance page: manual control cards, switches, segmented buttons
===================================================== */

.ctrl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.ctrl-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.1rem 1.15rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
}

.ctrl-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.ctrl-title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.ctrl-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.ctrl-title strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
}

.ctrl-title small {
  display: block;
  margin-top: 0.1rem;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.ctrl-card .hint { margin: 0; }

.ctrl-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
}

/* on / off switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.switch-track {
  position: relative;
  width: 2.4rem;
  height: 1.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  transition: background-color 180ms ease;
}

.switch-thumb {
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: #f4f4f6;
  transition: transform 180ms ease;
}

.switch.is-on .switch-track { background: #34d399; }
.switch.is-on .switch-thumb { transform: translateX(1.05rem); }
.switch:focus-visible .switch-track { outline: 2px solid #93c5fd; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .switch-track, .switch-thumb { transition: none; }
}

/* segmented buttons (buzzer, fan speed, LED colour) */
.segmented {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.seg-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.4rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.seg-btn:hover { background: rgba(255, 255, 255, 0.06); color: #f4f4f6; }
.seg-btn.active { background: rgba(255, 255, 255, 0.16); color: #ffffff; }
.seg-btn:focus-visible { outline: 2px solid #93c5fd; outline-offset: 1px; }

.swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: #52525b;
}
.swatch.g { background: #34d399; }
.swatch.y { background: #fbbf24; }
.swatch.r { background: #f87171; }
