/* ============================================================================
   BacCelScale — Unified A+B+C Loop Application
   app.css — Global styles, layout, shared components
   ============================================================================ */

/* --------------------------------------------------------------------------
   CSS Variables
   -------------------------------------------------------------------------- */
:root {
  /* Brand & accent */
  --accent: #1a5f7a;
  --accent-light: #e8f4f8;
  --accent-hover: #154e65;

  /* Part colors */
  --part-a: #1a5f7a;     /* Explore — teal */
  --part-b: #2d8659;     /* Capture — green */
  --part-c: #9a6400;     /* Learn   — amber */
  --integration: #7a3e9d; /* Cross-loop — purple */

  /* Part light tints */
  --part-a-light: #e8f4f8;
  --part-b-light: #e6f5ed;
  --part-c-light: #fef7e6;
  --integration-light: #f3ebf8;

  /* Status colors */
  --success: #16a34a;
  --success-light: #dcfce7;
  --partial: #d97706;
  --partial-light: #fef3c7;
  --failed: #dc2626;
  --failed-light: #fee2e2;
  --inprogress: #2563eb;
  --inprogress-light: #dbeafe;

  /* Neutrals */
  --bg: #fafafa;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --border-focus: #1a5f7a;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --text-inverse: #ffffff;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.14);

  /* Geometry */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Layout */
  --nav-height: 48px;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 14px;
  --font-size-md: 15px;
  --font-size-lg: 18px;
  --font-size-xl: 22px;
  --font-size-2xl: 28px;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 350ms ease;
}

/* --------------------------------------------------------------------------
   CSS Reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* --------------------------------------------------------------------------
   Scrollbar Styling
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */
#main-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  z-index: 1000;
  gap: var(--space-lg);
}

.nav-brand {
  font-weight: 700;
  font-size: var(--font-size-md);
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin: 0 auto;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 var(--space-md);
  height: var(--nav-height);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color var(--transition-normal), border-color var(--transition-normal);
  position: relative;
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab.active {
  color: var(--text-primary);
}

/* Active tab color per view */
.nav-tab.active[data-view="canvas"] {
  border-bottom-color: var(--part-a);
  color: var(--part-a);
}

.nav-tab.active[data-view="monitor"] {
  border-bottom-color: var(--part-b);
  color: var(--part-b);
}

.nav-tab.active[data-view="evaluate"] {
  border-bottom-color: var(--part-c);
  color: var(--part-c);
}

.tab-icon {
  font-size: 16px;
  line-height: 1;
}

.tab-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: var(--gray-200);
  color: var(--gray-600);
  margin-right: 4px;
}
.nav-tab.active .tab-label {
  background: currentColor;
  color: #fff;
}
.nav-tab[data-view="canvas"] .tab-label { background: var(--part-a); color: #fff; }
.nav-tab[data-view="monitor"] .tab-label { background: var(--part-b); color: #fff; }
.nav-tab[data-view="evaluate"] .tab-label { background: var(--part-c); color: #fff; }
.nav-tab:not(.active)[data-view="canvas"] .tab-label { background: var(--gray-200); color: var(--part-a); }
.nav-tab:not(.active)[data-view="monitor"] .tab-label { background: var(--gray-200); color: var(--part-b); }
.nav-tab:not(.active)[data-view="evaluate"] .tab-label { background: var(--gray-200); color: var(--part-c); }

/* LIVE badge */
.tab-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--success);
  color: var(--text-inverse);
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Connection status */
.nav-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition-normal);
}

.status-dot.connected {
  background: var(--success);
}

.status-dot.disconnected {
  background: var(--failed);
}

.status-dot.connecting {
  background: var(--partial);
  animation: badge-pulse 1.5s ease-in-out infinite;
}

.status-text {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Views
   -------------------------------------------------------------------------- */
.view {
  position: absolute;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.view.active {
  display: block;
  opacity: 1;
}

.view-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-lg);
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.card-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.card-body {
  padding: var(--space-lg);
}

.card-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* Card accent border variants */
.card--part-a { border-top: 3px solid var(--part-a); }
.card--part-b { border-top: 3px solid var(--part-b); }
.card--part-c { border-top: 3px solid var(--part-c); }
.card--integration { border-top: 3px solid var(--integration); }

/* Clickable card */
.card--clickable {
  cursor: pointer;
}

.card--clickable:hover {
  border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-sm);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  height: auto;
  min-height: 80px;
  padding: var(--space-sm);
  resize: vertical;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%236b7280' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--failed);
  margin-top: 2px;
}

.form-row {
  display: flex;
  gap: var(--space-md);
}

.form-row > .form-group {
  flex: 1;
}

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-check-label {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 var(--space-md);
  height: 36px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), box-shadow var(--transition-fast),
              opacity var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
  border: none;
}

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

/* Primary */
.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* Secondary */
.btn-secondary {
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

/* Danger */
.btn-danger {
  background: var(--failed);
  color: var(--text-inverse);
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

/* Success */
.btn-success {
  background: var(--success);
  color: var(--text-inverse);
}

.btn-success:hover:not(:disabled) {
  background: #15803d;
}

/* Part-colored buttons */
.btn-part-a { background: var(--part-a); color: var(--text-inverse); }
.btn-part-a:hover:not(:disabled) { background: var(--accent-hover); }

.btn-part-b { background: var(--part-b); color: var(--text-inverse); }
.btn-part-b:hover:not(:disabled) { background: #246e49; }

.btn-part-c { background: var(--part-c); color: var(--text-inverse); }
.btn-part-c:hover:not(:disabled) { background: #7d5200; }

/* Size variants */
.btn-sm {
  height: 28px;
  padding: 0 var(--space-sm);
  font-size: var(--font-size-xs);
}

.btn-lg {
  height: 44px;
  padding: 0 var(--space-xl);
  font-size: var(--font-size-md);
}

/* Icon button */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
}

/* --------------------------------------------------------------------------
   Badges & Tags
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: 10px;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-partial { background: var(--partial-light); color: var(--partial); }
.badge-failed  { background: var(--failed-light);  color: var(--failed); }
.badge-info    { background: var(--inprogress-light); color: var(--inprogress); }
.badge-muted   { background: #f3f4f6; color: var(--text-secondary); }

.badge-part-a { background: var(--part-a-light); color: var(--part-a); }
.badge-part-b { background: var(--part-b-light); color: var(--part-b); }
.badge-part-c { background: var(--part-c-light); color: var(--part-c); }
.badge-integration { background: var(--integration-light); color: var(--integration); }

/* --------------------------------------------------------------------------
   Charts
   -------------------------------------------------------------------------- */
.chart-container {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: var(--space-lg);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.chart-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
}

.chart-actions {
  display: flex;
  gap: var(--space-xs);
}

.chart-range-btn {
  padding: 4px 10px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chart-range-btn:hover {
  background: var(--bg);
}

.chart-range-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.chart-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 280px;
}

.chart-canvas-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 90vw;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Toast Notifications
   -------------------------------------------------------------------------- */
#toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 3000;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  min-width: 280px;
  max-width: 420px;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--accent);
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.toast.visible {
  transform: translateX(0);
  opacity: 1;
}

.toast.dismissing {
  transform: translateX(120%);
  opacity: 0;
}

.toast-success { border-left-color: var(--success); }
.toast-info    { border-left-color: var(--accent); }
.toast-warning { border-left-color: var(--partial); }
.toast-error   { border-left-color: var(--failed); }

.toast-icon {
  flex-shrink: 0;
  font-size: 16px;
}

.toast-message {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.toast-close:hover {
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.table tbody tr:hover {
  background: rgba(26, 95, 122, 0.02);
}

.table tbody tr.selected {
  background: var(--accent-light);
}

/* --------------------------------------------------------------------------
   Empty States
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.empty-state-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  max-width: 360px;
  margin-bottom: var(--space-lg);
}

/* --------------------------------------------------------------------------
   Loading & Spinners
   -------------------------------------------------------------------------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(250, 250, 250, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* --------------------------------------------------------------------------
   Grid Layouts
   -------------------------------------------------------------------------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

/* --------------------------------------------------------------------------
   Section Headers
   -------------------------------------------------------------------------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.section-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.section-description {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Stat Cards (KPI boxes)
   -------------------------------------------------------------------------- */
.stat-card {
  padding: var(--space-md);
}

.stat-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-unit {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 2px;
}

.stat-change {
  font-size: var(--font-size-xs);
  margin-top: 2px;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--failed); }
.stat-change.neutral  { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Dividers & Separators
   -------------------------------------------------------------------------- */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}

.divider-vertical {
  width: 1px;
  background: var(--border);
  align-self: stretch;
}

/* --------------------------------------------------------------------------
   Tooltip (CSS-only)
   -------------------------------------------------------------------------- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--text-primary);
  color: var(--text-inverse);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Progress Bar
   -------------------------------------------------------------------------- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width var(--transition-normal);
}

.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--partial); }
.progress-fill.danger  { background: var(--failed); }

/* --------------------------------------------------------------------------
   Tabs (inline, used within views)
   -------------------------------------------------------------------------- */
.inline-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-md);
}

.inline-tab {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.inline-tab:hover {
  color: var(--text-primary);
}

.inline-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Accordion
   -------------------------------------------------------------------------- */
.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.accordion-header:hover {
  background: var(--bg);
}

.accordion-arrow {
  transition: transform var(--transition-normal);
  font-size: 12px;
  color: var(--text-muted);
}

.accordion-header.open .accordion-arrow {
  transform: rotate(90deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
}

.accordion-body.open {
  max-height: 2000px;
}

/* --------------------------------------------------------------------------
   Responsive Breakpoints
   -------------------------------------------------------------------------- */

/* Tablet and below */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .view-content {
    padding: var(--space-md);
  }
}

/* Mobile */
@media (max-width: 768px) {
  #main-nav {
    padding: 0 var(--space-md);
    gap: var(--space-sm);
  }

  .nav-brand {
    font-size: var(--font-size-sm);
  }

  .nav-tab {
    padding: 0 var(--space-sm);
    font-size: var(--font-size-xs);
  }

  .tab-icon {
    font-size: 14px;
  }

  .status-text {
    display: none;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .modal {
    width: 95vw;
    max-height: 90vh;
  }

  .chart-canvas-wrapper {
    height: 200px;
  }

  .view-content {
    padding: var(--space-sm);
  }
}

/* Large screens */
@media (min-width: 1440px) {
  .view-content {
    max-width: 1600px;
  }
}

/* --------------------------------------------------------------------------
   Print Styles
   -------------------------------------------------------------------------- */
@media print {
  #main-nav {
    display: none;
  }

  #toast-container {
    display: none;
  }

  .view {
    position: static;
    display: none !important;
    opacity: 1 !important;
    overflow: visible;
  }

  .view.active {
    display: block !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .btn {
    display: none;
  }

  body {
    background: white;
    overflow: visible;
  }
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.text-muted   { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--text-primary); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--failed); }
.text-warning { color: var(--partial); }

.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.text-lg { font-size: var(--font-size-lg); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-center { text-align: center; }
.text-right  { text-align: right; }

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.mr-sm { margin-right: var(--space-sm); }
.ml-sm { margin-left: var(--space-sm); }

.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-wrap { flex-wrap: wrap; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}


/* ============================================================================
   === CANVAS VIEW ===
   Part A: Exploration Space — infinite canvas styles.
   All classes prefixed with `cv-` to avoid collisions with shared styles.
   ============================================================================ */

/* --------------------------------------------------------------------------
   Canvas Viewport & World
   -------------------------------------------------------------------------- */
.cv-viewport {
  position: absolute;
  top: 0;
  left: 256px;
  right: 0;
  bottom: 0;
  transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
  cursor: grab;
  background-color: var(--bg);
  background-image: radial-gradient(circle, #d4d4d4 1px, transparent 1px);
  background-size: 20px 20px;
}

.cv-viewport.grabbing { cursor: grabbing; }

.cv-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
}

/* --------------------------------------------------------------------------
   SVG Arrow Layer
   -------------------------------------------------------------------------- */
.cv-arrow-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 10000px;
  height: 10000px;
  pointer-events: none;
  overflow: visible;
  z-index: 15;
}

.cv-arrow-layer path { pointer-events: stroke; cursor: pointer; }
.cv-arrow-layer path:hover { stroke-width: 3.5 !important; filter: drop-shadow(0 0 4px rgba(0,0,0,0.15)); }

.cv-arrow-label-group { pointer-events: auto; cursor: default; }
.cv-arrow-label-bg { fill: white; stroke: var(--border); stroke-width: 1; rx: 8; ry: 8; }
.cv-arrow-label-text { font-family: var(--font-family); font-size: 10px; fill: var(--text-secondary); font-weight: 500; text-anchor: middle; dominant-baseline: central; cursor: pointer; }
.cv-arrow-label-text:hover { fill: var(--accent); text-decoration: underline; }

.cv-arrow-delete-btn { pointer-events: auto; cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.cv-arrow-label-group:hover .cv-arrow-delete-btn { opacity: 1; }
.cv-arrow-delete-bg { fill: var(--failed); rx: 6; ry: 6; }
.cv-arrow-delete-text { fill: white; font-size: 10px; font-weight: 700; font-family: var(--font-family); text-anchor: middle; dominant-baseline: central; }

.cv-arrow-label-input-wrapper {
  position: absolute;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cv-arrow-label-input {
  width: 160px;
  height: 28px;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 12px;
  font-family: var(--font-family);
  outline: none;
  background: white;
  box-shadow: var(--shadow-lg);
}

.cv-arrow-label-confirm-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cv-arrow-label-confirm-btn:hover { background: var(--accent-hover); }

/* --------------------------------------------------------------------------
   Group Regions
   -------------------------------------------------------------------------- */
.cv-group-region {
  position: absolute;
  border: 2px dashed;
  border-radius: var(--radius-xl);
  padding: 20px;
  padding-top: 48px;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.3s ease;
}

.cv-group-region.collapsed { padding-top: 20px; min-height: 56px !important; overflow: hidden; }

.cv-group-header {
  position: absolute;
  top: 10px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  cursor: grab;
  z-index: 2;
  user-select: none;
}

.cv-group-header:hover .cv-group-name { text-decoration: underline; }
.cv-group-header.dragging-group { cursor: grabbing; }

.cv-group-name { font-weight: 700; font-size: 13px; letter-spacing: 0.3px; text-transform: uppercase; }
.cv-group-count { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; color: white; }
.cv-group-collapse-icon { font-size: 11px; color: var(--text-muted); transition: transform 0.2s; }
.cv-group-region.collapsed .cv-group-collapse-icon { transform: rotate(-90deg); }

.cv-group-name-input {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  border: 2px solid var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  outline: none;
  font-family: var(--font-family);
  width: 180px;
  background: white;
}

.cv-group-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  pointer-events: auto;
  z-index: 3;
}

.cv-group-resize-handle::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(0,0,0,0.2);
  border-bottom: 2px solid rgba(0,0,0,0.2);
}

.cv-group-region:hover .cv-group-resize-handle::after { border-color: rgba(0,0,0,0.4); }

.cv-group-region.cv-drop-target {
  border-style: solid !important;
  border-width: 3px !important;
  background: rgba(26, 95, 122, 0.08) !important;
  transition: all 0.15s ease;
}

/* Built-in direction group colors */
.cv-group-temp-stability { border-color: rgba(26, 95, 122, 0.3); background: rgba(26, 95, 122, 0.04); }
.cv-group-temp-stability .cv-group-name { color: #1a5f7a; }
.cv-group-temp-stability .cv-group-count { background: #1a5f7a; }

.cv-group-media-opt { border-color: rgba(217, 119, 6, 0.3); background: rgba(217, 119, 6, 0.04); }
.cv-group-media-opt .cv-group-name { color: #b45309; }
.cv-group-media-opt .cv-group-count { background: #d97706; }

.cv-group-strain-id { border-color: rgba(22, 163, 74, 0.3); background: rgba(22, 163, 74, 0.04); }
.cv-group-strain-id .cv-group-name { color: #16a34a; }
.cv-group-strain-id .cv-group-count { background: #16a34a; }

/* --------------------------------------------------------------------------
   Experiment Cards
   -------------------------------------------------------------------------- */
.cv-exp-card {
  position: absolute;
  width: 200px;
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  cursor: grab;
  user-select: none;
  z-index: 10;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, opacity 0.3s ease, transform 0.15s ease;
  overflow: hidden;
}

.cv-exp-card:hover { box-shadow: var(--shadow-lg); border-color: var(--accent); z-index: 15; }
.cv-exp-card.dragging { cursor: grabbing; box-shadow: var(--shadow-xl); z-index: 100; transform: scale(1.03); }
.cv-exp-card.selected { border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.15), var(--shadow-lg); }
.cv-exp-card.faded { opacity: 0.3; }
.cv-exp-card.highlighted { box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.25), var(--shadow-lg); }

.cv-card-thumbnail {
  width: 200px;
  height: 120px;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cv-card-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.cv-placeholder-icon { font-size: 36px; opacity: 0.3; }

.cv-outcome-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.cv-outcome-success { background: var(--success); }
.cv-outcome-partial { background: var(--partial); }
.cv-outcome-failed { background: var(--failed); }
.cv-outcome-inprogress { background: var(--inprogress); }

.cv-duration-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.cv-live-indicator {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--success);
  color: white;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  animation: badge-pulse 2s ease-in-out infinite;
}

.cv-card-body { padding: 10px 12px 12px; }
.cv-card-id { font-size: 10px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.3px; margin-bottom: 2px; }
.cv-card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; line-height: 1.3; }
.cv-card-params { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; }
.cv-card-rationale { font-size: 10px; color: var(--text-muted); font-style: italic; line-height: 1.35; }

.cv-card-protocol-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
}

.cv-deviation-count { color: var(--partial); font-weight: 600; }

/* Card connectors */
.cv-card-connector {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid white;
  box-shadow: 0 1px 6px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.2s, transform 0.15s;
  cursor: crosshair;
  z-index: 50;
  pointer-events: none;
}

.cv-exp-card:hover .cv-card-connector { opacity: 1; pointer-events: auto; }
.cv-card-connector:hover { transform: scale(1.4); background: var(--accent-hover); }

.cv-connector-right { right: -11px; top: 50%; margin-top: -11px; }
.cv-connector-left  { left: -11px; top: 50%; margin-top: -11px; }
.cv-connector-bottom { bottom: -11px; left: 50%; margin-left: -11px; }
.cv-connector-top { top: -11px; left: 50%; margin-left: -11px; }

/* --------------------------------------------------------------------------
   Filter Sidebar
   -------------------------------------------------------------------------- */
.cv-filter-bar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 256px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 8px rgba(0,0,0,0.04);
  z-index: 500;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.cv-filter-bar.collapsed { transform: translateX(-256px); }

.cv-sidebar-toggle {
  position: absolute;
  top: 14px;
  left: 264px;
  width: 26px;
  height: 26px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 510;
  font-size: 16px;
  line-height: 1;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
  user-select: none;
}

.cv-sidebar-toggle:hover { background: #f1f5f9; color: var(--accent); }
.cv-filter-bar.collapsed ~ .cv-sidebar-toggle { left: 8px; }

.cv-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  white-space: nowrap;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cv-brand span { font-weight: 400; color: var(--text-muted); font-size: 11px; display: block; margin-top: 2px; }

.cv-filter-group { display: flex; flex-direction: column; gap: 6px; padding: 10px 16px; }
.cv-filter-group label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; white-space: nowrap; }
.cv-filter-separator { height: 1px !important; width: auto !important; margin: 0 !important; background: #f1f5f9 !important; }

.cv-search-input {
  width: 100%;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 10px 0 32px;
  font-size: 12px;
  font-family: var(--font-family);
  outline: none;
  background-color: #f8fafc;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  transition: border-color 0.2s;
}

.cv-search-input:focus { border-color: var(--accent); background-color: white; }

.cv-select { width: 100%; height: 32px; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0 8px; font-size: 12px; font-family: var(--font-family); background: #f8fafc; }
.cv-select:focus { border-color: var(--accent); background: white; }

.cv-outcome-filters { display: flex; gap: 4px; flex-wrap: wrap; }

.cv-outcome-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  background: white;
}

.cv-outcome-chip.active { border-color: currentColor; background: currentColor; }
.cv-outcome-chip.active span { color: white; }
.cv-outcome-chip .cv-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cv-outcome-chip.active .cv-dot { background: white !important; }

.cv-outcome-chip[data-outcome="success"] { color: var(--success); }
.cv-outcome-chip[data-outcome="partial"] { color: var(--partial); }
.cv-outcome-chip[data-outcome="failed"] { color: var(--failed); }
.cv-outcome-chip[data-outcome="inprogress"] { color: var(--inprogress); }

.cv-temp-slider-container { display: flex; align-items: center; gap: 6px; }

.cv-temp-slider-container input[type="range"] {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #e2e8f0;
  border-radius: 2px;
  outline: none;
}

.cv-temp-slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.cv-temp-value { font-size: 11px; color: var(--text-secondary); min-width: 36px; }
.cv-clear-btn { background: var(--failed); color: white; border: none; border-radius: var(--radius-sm); padding: 4px 10px; font-size: 11px; cursor: pointer; font-family: var(--font-family); }
.cv-filter-count { font-size: 11px; color: var(--text-secondary); margin-left: 4px; }

/* --------------------------------------------------------------------------
   Toolbar
   -------------------------------------------------------------------------- */
.cv-toolbar {
  position: absolute;
  top: 12px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 500;
}

.cv-toolbar-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: #475569;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}

.cv-toolbar-btn:hover { background: #f1f5f9; border-color: var(--accent); color: var(--accent); }
.cv-toolbar-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.cv-toolbar-divider { height: 1px; background: var(--border); margin: 4px 0; }
.cv-toolbar-btn-wide { width: auto; padding: 0 12px; font-size: 11px; font-weight: 600; gap: 4px; white-space: nowrap; }
.cv-toolbar-btn-new-dir { width: auto; padding: 0 12px; font-size: 11px; font-weight: 600; gap: 4px; white-space: nowrap; }

/* Layout dropdown */
.cv-layout-dropdown {
  position: absolute;
  top: 92px;
  right: 62px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 510;
  display: none;
  overflow: hidden;
  min-width: 180px;
}

.cv-layout-dropdown.visible { display: block; }
.cv-layout-option { padding: 10px 14px; font-size: 12px; cursor: pointer; transition: background 0.1s; display: flex; align-items: center; gap: 8px; }
.cv-layout-option:hover { background: #f1f5f9; }
.cv-lo-icon { font-size: 14px; width: 20px; text-align: center; }

/* --------------------------------------------------------------------------
   Detail Modal (canvas-specific, with grow animation)
   -------------------------------------------------------------------------- */
.cv-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  z-index: 800;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.cv-modal-overlay.visible { display: flex; opacity: 1; }

.cv-detail-modal {
  width: 620px;
  max-height: 85vh;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow-y: auto;
  transform: scale(0.3);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  transform-origin: var(--modal-origin-x, 50%) var(--modal-origin-y, 50%);
}

.cv-modal-overlay.visible .cv-detail-modal { transform: scale(1); opacity: 1; }

.cv-modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 24px 24px 0; }
.cv-modal-header-info { flex: 1; }
.cv-modal-id { font-size: 11px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.3px; }
.cv-modal-title { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-top: 4px; }
.cv-modal-direction-badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; margin-top: 6px; }

.cv-modal-close {
  width: 32px; height: 32px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: white; display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-size: 16px; color: var(--text-muted); transition: all 0.15s; flex-shrink: 0; margin-left: 12px;
}
.cv-modal-close:hover { background: #f1f5f9; color: var(--text-primary); }

.cv-modal-gallery { display: flex; gap: 8px; padding: 16px 24px; overflow-x: auto; }
.cv-modal-gallery-img { width: 140px; height: 100px; border-radius: var(--radius-md); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 24px; opacity: 0.4; }

.cv-modal-section { padding: 0 24px; margin-bottom: 16px; }
.cv-modal-section-title { font-size: 12px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.cv-st-icon { font-size: 14px; }

.cv-meta-table { width: 100%; border-collapse: collapse; }
.cv-meta-table td { padding: 6px 0; font-size: 13px; border-bottom: 1px solid #f1f5f9; }
.cv-meta-table td:first-child { color: var(--text-secondary); font-weight: 500; width: 140px; }
.cv-meta-table td:last-child { color: var(--text-primary); }

.cv-sparkline-row { display: flex; gap: 12px; }
.cv-sparkline-card { flex: 1; background: #f8fafc; border-radius: var(--radius-md); padding: 10px 12px; border: 1px solid #f1f5f9; }
.cv-sparkline-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.cv-sparkline-value { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.cv-sparkline-unit { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.cv-sparkline-canvas { width: 100%; height: 36px; margin-top: 4px; }

.cv-eval-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cv-eval-item { background: #f8fafc; border-radius: var(--radius-md); padding: 10px 12px; border: 1px solid #f1f5f9; }
.cv-eval-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.cv-eval-value { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-top: 2px; }

.cv-rationale-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius-md); padding: 12px 14px; font-size: 13px; color: #92400e; font-style: italic; line-height: 1.5; }

.cv-provenance-link {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: #f8fafc; border-radius: var(--radius-md); border: 1px solid #f1f5f9;
  font-size: 13px; color: var(--accent); font-weight: 500; cursor: pointer;
  transition: background 0.15s; margin-bottom: 4px;
}
.cv-provenance-link:hover { background: #f1f5f9; }

.cv-modal-actions { display: flex; gap: 8px; padding: 16px 24px 24px; flex-wrap: wrap; }
.cv-modal-action-btn {
  padding: 8px 16px; border-radius: var(--radius-md); font-size: 12px; font-weight: 600;
  font-family: var(--font-family); cursor: pointer; transition: all 0.15s;
  border: 1px solid var(--border); background: white; color: #475569;
}
.cv-modal-action-btn:hover { background: #f1f5f9; border-color: var(--accent); color: var(--accent); }
.cv-modal-action-btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.cv-modal-action-btn.primary:hover { background: var(--accent-hover); }

/* --------------------------------------------------------------------------
   Minimap
   -------------------------------------------------------------------------- */
.cv-minimap {
  position: absolute;
  bottom: 16px;
  left: 272px;
  transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
  width: 200px;
  height: 140px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 500;
  overflow: hidden;
}

.cv-minimap canvas { width: 100%; height: 100%; }
.cv-minimap-viewport { position: absolute; border: 2px solid var(--accent); background: rgba(26, 95, 122, 0.08); border-radius: 2px; pointer-events: none; }

.cv-zoom-info {
  position: absolute;
  bottom: 168px;
  left: 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  z-index: 500;
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   Facilitator Panel — hidden in production. Was used during Session 2 co-design.
   To re-enable, remove the display:none rule below.
   -------------------------------------------------------------------------- */
.cv-facilitator-toggle,
.cv-facilitator-panel,
#canvas-facilitator-toggle,
#canvas-facilitator-panel { display: none !important; }

.cv-facilitator-toggle {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px 10px 0 0;
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  z-index: 600;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cv-facilitator-toggle:hover { background: var(--accent-hover); }
.cv-facilitator-toggle.panel-open { bottom: 280px; }

.cv-facilitator-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 280px;
  background: white;
  border-top: 2px solid var(--accent);
  z-index: 590;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 20px 32px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
}

.cv-facilitator-panel.visible { transform: translateY(0); }
.cv-facilitator-title { font-size: 16px; font-weight: 700; color: var(--accent); margin-bottom: 12px; }
.cv-facilitator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.cv-facilitator-q { padding: 10px 14px; background: #f8fafc; border-radius: var(--radius-md); border-left: 3px solid var(--accent); }
.cv-q-num { font-size: 10px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.cv-q-text { font-size: 13px; color: var(--text-primary); line-height: 1.45; }
.cv-q-hci { font-size: 11px; color: var(--text-muted); font-style: italic; margin-top: 4px; }

/* --------------------------------------------------------------------------
   Concentration Calculator Panel
   -------------------------------------------------------------------------- */
.cv-calc-panel {
  position: absolute;
  top: 0;
  right: -340px;
  width: 340px;
  height: 100%;
  background: white;
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 16px rgba(0,0,0,0.08);
  z-index: 700;
  overflow-y: auto;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-family);
  padding: 0;
}

.cv-calc-panel.visible { right: 0; }

.cv-calc-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); background: #f8fafc; position: sticky; top: 0; z-index: 2; }
.cv-calc-header-title { font-size: 15px; font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 8px; }

.cv-calc-close {
  width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: white; display: flex; align-items: center; justify-content: center; cursor: pointer;
  font-size: 14px; color: var(--text-muted); transition: all 0.15s;
}
.cv-calc-close:hover { background: #f1f5f9; color: var(--text-primary); }

.cv-calc-section { padding: 14px 18px; border-bottom: 1px solid #f1f5f9; }
.cv-calc-section-title { font-size: 11px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

.cv-calc-volume-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cv-calc-volume-row label { font-size: 12px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.cv-calc-volume-row input { width: 80px; height: 28px; border: 1px solid #d0d5dd; border-radius: var(--radius-sm); padding: 0 8px; font-size: 12px; font-family: var(--font-family); outline: none; text-align: right; }
.cv-calc-volume-row input:focus { border-color: var(--accent); }
.cv-unit { font-size: 11px; color: var(--text-muted); }

.cv-calc-ingredient-header { display: grid; grid-template-columns: 1fr 60px 60px; gap: 6px; margin-bottom: 4px; }
.cv-calc-ingredient-header span { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }

.cv-calc-ingredient-row { display: grid; grid-template-columns: 1fr 60px 60px; gap: 6px; align-items: center; margin-bottom: 6px; padding: 6px 0; border-bottom: 1px solid #f8fafc; }
.cv-calc-ingredient-row select,
.cv-calc-ingredient-row input { height: 28px; border: 1px solid #d0d5dd; border-radius: var(--radius-sm); padding: 0 6px; font-size: 11px; font-family: var(--font-family); outline: none; background: white; }
.cv-calc-ingredient-row select:focus,
.cv-calc-ingredient-row input:focus { border-color: var(--accent); }

.cv-calc-mass-display { font-size: 11px; font-weight: 600; color: var(--accent); text-align: right; background: #f0fdf4; border-radius: var(--radius-sm); height: 28px; display: flex; align-items: center; justify-content: flex-end; padding: 0 8px; border: 1px solid #dcfce7; }

.cv-calc-add-btn { display: flex; align-items: center; gap: 4px; padding: 6px 10px; background: none; border: 1px dashed #d0d5dd; border-radius: var(--radius-sm); font-size: 11px; font-weight: 500; color: var(--text-secondary); cursor: pointer; font-family: var(--font-family); margin-top: 6px; transition: all 0.15s; }
.cv-calc-add-btn:hover { border-color: var(--accent); color: var(--accent); background: #f0f9ff; }

.cv-calc-remove-btn { width: 20px; height: 20px; border: none; background: none; color: var(--failed); cursor: pointer; font-size: 14px; padding: 0; line-height: 1; opacity: 0.5; transition: opacity 0.15s; }
.cv-calc-remove-btn:hover { opacity: 1; }

.cv-calc-scale-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cv-calc-scale-row label { font-size: 12px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; min-width: 56px; }
.cv-calc-scale-row input { width: 70px; height: 28px; border: 1px solid #d0d5dd; border-radius: var(--radius-sm); padding: 0 8px; font-size: 12px; font-family: var(--font-family); outline: none; text-align: right; }
.cv-calc-scale-row input:focus { border-color: var(--accent); }
.cv-calc-scale-factor { font-size: 13px; font-weight: 700; color: var(--accent); background: #f0f9ff; padding: 4px 10px; border-radius: var(--radius-sm); text-align: center; margin-top: 6px; }

.cv-calc-preset-btn { display: block; width: 100%; text-align: left; padding: 8px 12px; margin-bottom: 4px; border: 1px solid var(--border); border-radius: var(--radius-md); background: white; cursor: pointer; font-family: var(--font-family); font-size: 12px; font-weight: 500; color: var(--text-primary); transition: all 0.15s; }
.cv-calc-preset-btn:hover { background: #f0f9ff; border-color: var(--accent); }
.cv-preset-desc { display: block; font-size: 10px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }

.cv-calc-use-btn { width: 100%; padding: 10px 16px; background: var(--accent); color: white; border: none; border-radius: var(--radius-md); font-size: 12px; font-weight: 600; font-family: var(--font-family); cursor: pointer; transition: background 0.15s; margin-top: 8px; }
.cv-calc-use-btn:hover { background: var(--accent-hover); }

/* --------------------------------------------------------------------------
   Protocol Section (in modal)
   -------------------------------------------------------------------------- */
.cv-protocol-selector { width: 100%; height: 34px; border: 1px solid #d0d5dd; border-radius: var(--radius-md); padding: 0 10px; font-size: 12px; font-family: var(--font-family); outline: none; background: white; cursor: pointer; margin-bottom: 10px; }
.cv-protocol-selector:focus { border-color: var(--accent); }

.cv-protocol-steps { list-style: none; padding: 0; margin: 0; }
.cv-protocol-step { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.cv-protocol-step:last-child { border-bottom: none; }
.cv-protocol-step input[type="checkbox"] { margin-top: 2px; accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }
.cv-protocol-step-text { font-size: 13px; color: var(--text-primary); flex: 1; line-height: 1.4; }

.cv-step-field { display: inline-block; width: 50px; height: 22px; border: 1px solid #d0d5dd; border-radius: 4px; padding: 0 4px; font-size: 11px; font-family: var(--font-family); outline: none; text-align: center; vertical-align: middle; }
.cv-step-field:focus { border-color: var(--accent); }

.cv-protocol-deviation-toggle { font-size: 10px; color: var(--partial); cursor: pointer; white-space: nowrap; border: none; background: none; padding: 2px 4px; font-family: var(--font-family); font-weight: 500; transition: color 0.15s; }
.cv-protocol-deviation-toggle:hover { color: #b45309; }

.cv-protocol-deviation-note { width: 100%; margin-top: 4px; padding: 6px 8px; border: 1px solid #fde68a; border-radius: var(--radius-sm); background: #fffbeb; font-size: 11px; font-family: var(--font-family); color: #92400e; outline: none; resize: vertical; min-height: 32px; }
.cv-protocol-deviation-note:focus { border-color: var(--partial); }

.cv-protocol-deviation-display { margin-top: 4px; padding: 4px 8px; background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius-sm); font-size: 11px; color: #92400e; font-style: italic; }

.cv-protocol-link-calc { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--accent); cursor: pointer; text-decoration: none; font-weight: 500; border: none; background: none; font-family: var(--font-family); padding: 0; margin-left: 4px; }
.cv-protocol-link-calc:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Canvas Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .cv-filter-bar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px; }
  .cv-filter-separator { display: none; }
  .cv-search-input { width: 100%; }
  .cv-detail-modal { width: 95vw; max-height: 90vh; }
  .cv-minimap { width: 140px; height: 100px; }
}


/* ============================================================================
   MONITOR VIEW (Part B: Data Capture Dashboard)
   ============================================================================ */

/* --------------------------------------------------------------------------
   Monitor Layout
   -------------------------------------------------------------------------- */
.monitor-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-height));
  overflow: hidden;
}

.monitor-main {
  display: grid;
  grid-template-columns: 240px 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* --------------------------------------------------------------------------
   Sensor Status Bar (full width top bar)
   -------------------------------------------------------------------------- */
.monitor-status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xs) var(--space-md);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  min-height: 40px;
}

.status-bar-section {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-bar-right {
  margin-left: auto;
}

.status-bar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.status-bar-sep {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  user-select: none;
}

.status-bar-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Sensor Chips
   -------------------------------------------------------------------------- */
.sensor-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.sensor-chip-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sensor-chip-value {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  min-width: 32px;
  text-align: right;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.sensor-chip-unit {
  font-size: 10px;
  color: var(--text-muted);
}

.sensor-chip--temp .sensor-chip-value  { color: var(--part-a); }
.sensor-chip--hum .sensor-chip-value   { color: var(--part-b); }
.sensor-chip--press .sensor-chip-value { color: var(--part-c); }
.sensor-chip--air .sensor-chip-value   { color: var(--failed); }

.sensor-chip-flash {
  animation: chip-flash 0.3s ease;
}

@keyframes chip-flash {
  0%   { transform: scale(1); font-weight: 600; }
  50%  { transform: scale(1.15); font-weight: 800; }
  100% { transform: scale(1); font-weight: 600; }
}

/* --------------------------------------------------------------------------
   Monitor Sidebar
   -------------------------------------------------------------------------- */
.monitor-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-sm);
  gap: var(--space-sm);
}

.sidebar-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  overflow: hidden;
}

.sidebar-section--grow {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.sidebar-section-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--part-b);
}

.sidebar-section-body {
  padding: var(--space-sm);
}

.sidebar-timeline-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* --------------------------------------------------------------------------
   Experiment Cards in Sidebar
   -------------------------------------------------------------------------- */
.experiment-active-card {
  padding: var(--space-sm);
}

.experiment-active-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.experiment-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  animation: badge-pulse 2s ease-in-out infinite;
}

.experiment-active-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.experiment-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.experiment-form {
  padding: var(--space-sm);
}

.experiment-form .form-group {
  margin-bottom: var(--space-sm);
}

.experiment-form .form-label {
  font-size: 10px;
  margin-bottom: 2px;
}

.experiment-form .form-input,
.experiment-form .form-select,
.experiment-form .form-textarea {
  height: 30px;
  font-size: var(--font-size-xs);
  padding: 0 6px;
}

.experiment-form .form-textarea {
  height: auto;
  min-height: 40px;
  padding: 4px 6px;
}

.experiment-form .form-row {
  gap: var(--space-xs);
}

/* --------------------------------------------------------------------------
   Monitor Content Area
   -------------------------------------------------------------------------- */
.monitor-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-md);
  gap: var(--space-md);
  min-height: 0;
}

/* --------------------------------------------------------------------------
   Time Range Bar
   -------------------------------------------------------------------------- */
.monitor-time-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-shrink: 0;
}

.monitor-time-buttons {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Chart Grid (2x2)
   -------------------------------------------------------------------------- */
.monitor-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Bottom Panels Grid
   -------------------------------------------------------------------------- */
.monitor-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* --------------------------------------------------------------------------
   Monitor Statistics Table
   -------------------------------------------------------------------------- */
.monitor-stats-table {
  font-size: var(--font-size-xs);
}

.monitor-stats-table th {
  font-size: 10px;
  padding: var(--space-xs) var(--space-sm);
}

.monitor-stats-table td {
  padding: var(--space-xs) var(--space-sm);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Event Timeline (Sidebar)
   -------------------------------------------------------------------------- */
.event-timeline-item {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border);
}

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

.event-timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.event-timeline-content {
  flex: 1;
  min-width: 0;
}

.event-timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  margin-bottom: 2px;
}

/* --------------------------------------------------------------------------
   Photo Gallery Grid
   -------------------------------------------------------------------------- */
.monitor-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-xs);
}

.gallery-thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  background: var(--bg);
  transition: transform var(--transition-fast);
}

.gallery-thumb:hover {
  transform: scale(1.03);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-status {
  font-size: var(--font-size-xs);
}

.photo-modal-content-inner {
  text-align: center;
}

/* --------------------------------------------------------------------------
   Alert Items
   -------------------------------------------------------------------------- */
.alert-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border);
}

.alert-item:last-child {
  border-bottom: none;
}

#m-alerts-panel {
  max-height: 200px;
  overflow-y: auto;
}

/* --------------------------------------------------------------------------
   Analytics Modal Extras
   -------------------------------------------------------------------------- */
.analytics-modal-content .inline-tabs {
  margin-bottom: var(--space-md);
}

.phase-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  flex: 1;
}

.phase-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: #fff;
}

.phase-dot--active  { background: var(--part-b); }
.phase-dot--done    { background: var(--success); }
.phase-dot--pending { background: var(--text-muted); }

/* --------------------------------------------------------------------------
   Sensor Test Modal Extras
   -------------------------------------------------------------------------- */
.sensor-test-content .grid-3 {
  gap: var(--space-xs);
}

.sensor-test-content .card.p-sm {
  padding: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Monitor View — Responsive
   -------------------------------------------------------------------------- */

/* Tablet */
@media (max-width: 1024px) {
  .monitor-main {
    grid-template-columns: 200px 1fr;
  }

  .monitor-chart-grid {
    grid-template-columns: 1fr 1fr;
  }

  .monitor-bottom-grid {
    grid-template-columns: 1fr;
  }

  .monitor-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
}

/* Mobile */
@media (max-width: 768px) {
  .monitor-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .monitor-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 300px;
    overflow-y: auto;
  }

  .monitor-chart-grid {
    grid-template-columns: 1fr;
  }

  .monitor-bottom-grid {
    grid-template-columns: 1fr;
  }

  .monitor-status-bar {
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
  }

  .sensor-chip-label {
    display: none;
  }

  .monitor-time-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .monitor-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .status-bar-sep {
    display: none;
  }

  .monitor-status-bar {
    flex-wrap: wrap;
  }

  .monitor-chart-grid .chart-canvas-wrapper {
    height: 180px;
  }
}


/* ============================================================================
   EVALUATE VIEW — Part C: Learning
   ============================================================================ */

/* --------------------------------------------------------------------------
   Experiment Context Bar
   -------------------------------------------------------------------------- */
.eval-experiment-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  background: var(--part-c-light);
  border: 1px solid rgba(154, 100, 0, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
}

.eval-exp-id {
  font-weight: 700;
  font-size: var(--font-size-sm);
  color: var(--part-c);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  white-space: nowrap;
}

.eval-exp-details {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eval-exp-status {
  margin-left: auto;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 10px;
  background: var(--success-light);
  color: var(--success);
  white-space: nowrap;
  flex-shrink: 0;
}

.eval-exp-status--active {
  background: var(--inprogress-light);
  color: var(--inprogress);
}

/* --------------------------------------------------------------------------
   Step Indicator
   -------------------------------------------------------------------------- */
.eval-step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.eval-step-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  transition: all var(--transition-normal);
  white-space: nowrap;
  flex-shrink: 0;
}

.eval-step-item:hover {
  background: rgba(154, 100, 0, 0.06);
}

.eval-step-item.active {
  background: var(--part-c);
  color: var(--text-inverse);
}

.eval-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: 700;
  background: var(--part-c-light);
  color: var(--part-c);
  flex-shrink: 0;
  transition: all var(--transition-normal);
}

.eval-step-item.active .eval-step-num {
  background: rgba(255, 255, 255, 0.3);
  color: var(--text-inverse);
}

.eval-step-item.completed .eval-step-num {
  background: var(--success-light);
  color: var(--success);
}

.eval-step-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition-normal);
}

.eval-step-item.active .eval-step-label {
  color: var(--text-inverse);
  font-weight: 600;
}

.eval-step-item.completed .eval-step-label {
  color: var(--text-primary);
}

.eval-step-arrow {
  color: var(--border);
  font-size: 16px;
  margin: 0 var(--space-xs);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Step Content Container
   -------------------------------------------------------------------------- */
.eval-step-container {
  margin-bottom: var(--space-xl);
}

/* --------------------------------------------------------------------------
   Form Row (3-column variant for evaluate)
   -------------------------------------------------------------------------- */
.eval-form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-md);
}

/* --------------------------------------------------------------------------
   Radio & Checkbox Groups (evaluate-specific)
   -------------------------------------------------------------------------- */
.eval-radio-group {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.eval-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
}

/* --------------------------------------------------------------------------
   Photo Upload
   -------------------------------------------------------------------------- */
.eval-photo-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--bg);
}

.eval-photo-upload:hover {
  border-color: var(--part-c);
  background: rgba(154, 100, 0, 0.04);
}

.eval-upload-icon {
  font-size: 32px;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.eval-upload-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.eval-upload-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* --------------------------------------------------------------------------
   Mini Charts (Step 2: Review Process)
   -------------------------------------------------------------------------- */
.eval-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.eval-mini-chart {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.eval-chart-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.eval-chart-range {
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

.eval-chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 100px;
}

.eval-chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.eval-anomaly-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.eval-anomaly-tag {
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--partial-light);
  color: var(--partial);
}

/* No data state within steps */
.eval-no-data {
  padding: var(--space-xl);
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Prompt Box (amber-themed question prompts)
   -------------------------------------------------------------------------- */
.eval-prompt-box {
  background: rgba(154, 100, 0, 0.06);
  border: 1px solid rgba(154, 100, 0, 0.25);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-top: var(--space-md);
}

.eval-prompt-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.eval-prompt-icon {
  font-size: var(--font-size-md);
}

.eval-prompt-text {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--part-c);
}

.eval-prompt-textarea {
  width: 100%;
  margin-top: var(--space-xs);
  padding: var(--space-sm);
  border: 1px solid rgba(154, 100, 0, 0.25);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  min-height: 60px;
  resize: vertical;
  background: var(--card-bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.eval-prompt-textarea:focus {
  border-color: var(--part-c);
  box-shadow: 0 0 0 3px rgba(154, 100, 0, 0.1);
}

/* --------------------------------------------------------------------------
   Timeline (Step 3: Review Annotations)
   -------------------------------------------------------------------------- */
.eval-timeline {
  position: relative;
  padding-left: 28px;
  margin-bottom: var(--space-md);
}

.eval-timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.eval-timeline-item {
  position: relative;
  margin-bottom: var(--space-md);
  padding: var(--space-md);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: box-shadow var(--transition-normal);
}

.eval-timeline-item:hover {
  box-shadow: var(--shadow-sm);
}

.eval-timeline-item::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--part-c);
  border: 2px solid var(--card-bg);
}

/* Timeline dot colors per event type */
.eval-timeline-item.intervention::before { background: #17a2b8; }
.eval-timeline-item.observation::before  { background: var(--success); }
.eval-timeline-item.measurement::before  { background: #7a3e9d; }
.eval-timeline-item.milestone::before    { background: #2563eb; }
.eval-timeline-item.contamination::before { background: var(--failed); }

.eval-tl-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.eval-tl-time {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.eval-tl-type {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.eval-tl-type.intervention   { background: #e0f7fa; color: #00838f; }
.eval-tl-type.observation    { background: var(--success-light); color: var(--success); }
.eval-tl-type.measurement    { background: #ede7f6; color: #5e35b1; }
.eval-tl-type.milestone      { background: var(--inprogress-light); color: var(--inprogress); }
.eval-tl-type.contamination  { background: var(--failed-light); color: var(--failed); }

.eval-tl-content {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: var(--space-xs);
}

.eval-tl-sensor {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  margin-bottom: var(--space-sm);
}

/* "Did this affect the outcome?" row */
.eval-tl-affect {
  margin-top: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.eval-tl-affect-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

.eval-tl-affect-btns {
  display: flex;
  gap: var(--space-xs);
}

.eval-tl-affect-btn {
  font-size: var(--font-size-xs);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  font-family: var(--font-family);
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.eval-tl-affect-btn:hover {
  border-color: var(--part-c);
  background: rgba(154, 100, 0, 0.06);
  color: var(--part-c);
}

.eval-tl-affect-btn.selected {
  background: var(--part-c);
  color: var(--text-inverse);
  border-color: var(--part-c);
}

/* --------------------------------------------------------------------------
   Comparison Grid (Step 4)
   -------------------------------------------------------------------------- */
.eval-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.eval-compare-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: var(--card-bg);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.eval-compare-card:hover,
.eval-compare-card.selected {
  border-color: var(--part-c);
  box-shadow: 0 0 0 3px rgba(154, 100, 0, 0.1);
}

.eval-cc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.eval-cc-id {
  font-weight: 700;
  font-size: var(--font-size-sm);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--part-c);
}

.eval-cc-outcome {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.eval-cc-outcome.good    { background: var(--success-light); color: var(--success); }
.eval-cc-outcome.partial { background: var(--partial-light); color: var(--partial); }
.eval-cc-outcome.failed  { background: var(--failed-light);  color: var(--failed); }

.eval-cc-params {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  line-height: 1.6;
}

.eval-cc-similarity {
  margin-top: var(--space-sm);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.eval-similarity-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.eval-similarity-fill {
  height: 100%;
  background: var(--part-c);
  border-radius: 2px;
  transition: width var(--transition-normal);
}

/* --------------------------------------------------------------------------
   Overlay Charts (Step 4)
   -------------------------------------------------------------------------- */
.eval-overlay-section {
  margin-top: var(--space-md);
}

.eval-overlay-chart {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.eval-oc-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.eval-overlay-canvas-wrap {
  position: relative;
  width: 100%;
  height: 140px;
}

.eval-overlay-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.eval-overlay-legend {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.eval-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.eval-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Tags (Step 5: Parameters to keep / change)
   -------------------------------------------------------------------------- */
.eval-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.eval-tag {
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: default;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  transition: all var(--transition-fast);
}

.eval-tag--keep.selected {
  border-color: rgba(45, 134, 89, 0.4);
  background: var(--part-b-light);
  color: var(--part-b);
}

.eval-tag--change.selected {
  border-color: rgba(154, 100, 0, 0.4);
  background: var(--part-c-light);
  color: var(--part-c);
}

.eval-tag-remove {
  font-size: 12px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
  line-height: 1;
}

.eval-tag-remove:hover {
  opacity: 1;
}

.eval-tag-input-wrap {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  align-items: center;
}

.eval-tag-input {
  flex: 1;
  max-width: 280px;
}

/* --------------------------------------------------------------------------
   Learning Log Section
   -------------------------------------------------------------------------- */
.eval-learning-log-section {
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

.eval-log-entries {
  margin-top: var(--space-sm);
}

.eval-insight-entry {
  padding: var(--space-md);
  border-left: 3px solid var(--part-c);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--part-c);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: var(--space-sm);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal);
}

.eval-insight-entry:hover {
  box-shadow: var(--shadow-md);
}

.eval-ie-date {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.eval-ie-text {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: var(--space-sm);
}

.eval-ie-links {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.eval-ie-link {
  font-size: var(--font-size-xs);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--part-c-light);
  color: var(--part-c);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.eval-ie-link:hover {
  background: var(--part-c);
  color: var(--text-inverse);
}

/* --------------------------------------------------------------------------
   Evaluate View — Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .eval-chart-grid {
    grid-template-columns: 1fr;
  }

  .eval-comparison-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .eval-experiment-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .eval-exp-status {
    margin-left: 0;
  }

  .eval-form-row-3 {
    grid-template-columns: 1fr;
  }

  .eval-step-indicator {
    padding: var(--space-sm);
  }

  .eval-step-item {
    padding: var(--space-xs) var(--space-sm);
  }

  .eval-step-label {
    display: none;
  }

  .eval-tl-affect {
    flex-direction: column;
    align-items: flex-start;
  }

  .eval-overlay-legend {
    flex-direction: column;
    gap: var(--space-xs);
  }
}


/* ============================================================================
   === SETTINGS VIEW ===
   Part D: Device Management & System Configuration.
   All classes prefixed with `settings-` to avoid collisions with shared styles.
   ============================================================================ */

/* --------------------------------------------------------------------------
   Settings: Active tab color
   -------------------------------------------------------------------------- */
.nav-tab.active[data-view="settings"] {
  border-bottom-color: var(--text-secondary);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Settings: Content wrapper (narrower than other views)
   -------------------------------------------------------------------------- */
.settings-content {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* --------------------------------------------------------------------------
   Settings: Page header
   -------------------------------------------------------------------------- */
.settings-header {
  margin-bottom: var(--space-xs);
}

.settings-page-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.settings-page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* --------------------------------------------------------------------------
   Settings: Section cards
   -------------------------------------------------------------------------- */
.settings-section {
  overflow: visible;
}

.settings-section-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.settings-section-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Settings: Device list
   -------------------------------------------------------------------------- */
.settings-device-list {
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.settings-device-list .empty-state {
  padding: var(--space-xl) var(--space-md);
}

/* --------------------------------------------------------------------------
   Settings: Device card
   -------------------------------------------------------------------------- */
.settings-device-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border-left: 4px solid var(--text-muted);
  transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.settings-device-card:hover {
  box-shadow: var(--shadow-md);
}

.settings-device--connected {
  border-left-color: var(--success);
}

.settings-device--disconnected {
  border-left-color: var(--failed);
}

.settings-device--error {
  border-left-color: var(--partial);
}

/* Device card: top row */
.settings-device-top {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.settings-device-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.settings-device-dot--connected {
  background: var(--success);
  box-shadow: 0 0 6px rgba(22, 163, 74, 0.4);
}

.settings-device-dot--disconnected {
  background: var(--failed);
}

.settings-device-dot--error {
  background: var(--partial);
  animation: badge-pulse 2s ease-in-out infinite;
}

.settings-device-name {
  font-weight: 600;
  font-size: var(--font-size-md);
  color: var(--text-primary);
  flex: 1;
}

/* Device card: details */
.settings-device-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-md);
  padding-left: calc(10px + var(--space-sm));
}

.settings-device-detail {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.settings-device-detail strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* Device card: actions */
.settings-device-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-left: calc(10px + var(--space-sm));
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Settings: Link experiment dropdown
   -------------------------------------------------------------------------- */
.settings-link-dropdown {
  position: relative;
  display: inline-block;
}

.settings-link-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  padding: var(--space-xs) 0;
}

.settings-link-item {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-link-item:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.settings-link-item.text-muted {
  cursor: default;
  color: var(--text-muted);
}

.settings-link-item.text-muted:hover {
  background: transparent;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Settings: Add device form
   -------------------------------------------------------------------------- */
.settings-add-form {
  padding: var(--space-md) var(--space-lg) var(--space-lg);
}

.settings-form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* --------------------------------------------------------------------------
   Settings: Test connection result
   -------------------------------------------------------------------------- */
.settings-test-result {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-top: var(--space-sm);
}

.settings-test-result--loading {
  background: var(--inprogress-light);
  color: var(--inprogress);
}

.settings-test-result--success {
  background: var(--success-light);
  color: var(--success);
}

.settings-test-result--error {
  background: var(--failed-light);
  color: var(--failed);
}

.settings-test-icon {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
}

.settings-test-text {
  flex: 1;
  line-height: 1.4;
}

.settings-test-spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Settings: System info panel
   -------------------------------------------------------------------------- */
.settings-system-info {
  padding: var(--space-md) var(--space-lg);
}

.settings-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
}

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

.settings-info-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.settings-info-value {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
}

/* --------------------------------------------------------------------------
   Settings: Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .settings-content {
    padding: var(--space-md);
  }

  .settings-page-title {
    font-size: var(--font-size-xl);
  }

  .settings-device-list {
    padding: var(--space-sm);
  }

  .settings-device-card {
    padding: var(--space-sm);
  }

  .settings-device-details {
    padding-left: 0;
  }

  .settings-device-actions {
    padding-left: 0;
  }

  .settings-add-form {
    padding: var(--space-sm) var(--space-md) var(--space-md);
  }

  .settings-form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-info-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .settings-info-value {
    text-align: left;
  }
}


/* ============================================================================
   === LOGIN SCREEN ===
   Full-viewport centered login card.
   ============================================================================ */

/* --------------------------------------------------------------------------
   Login: Screen layout
   -------------------------------------------------------------------------- */
.login-screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f7fa 0%, #e8f4f8 40%, #fafafa 100%);
  z-index: 5000;
}

/* --------------------------------------------------------------------------
   Login: Card
   -------------------------------------------------------------------------- */
.login-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 90vw;
  max-width: 400px;
  overflow: hidden;
}

.login-header {
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  text-align: center;
}

.login-brand {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
  line-height: 1.5;
}

.login-form {
  padding: 0 var(--space-xl) var(--space-xl);
}

.login-form .form-group {
  margin-bottom: var(--space-md);
}

.login-form .form-input {
  height: 42px;
  font-size: var(--font-size-base);
}

.login-form .form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.12);
}

/* --------------------------------------------------------------------------
   Login: Submit button
   -------------------------------------------------------------------------- */
.login-submit-btn {
  width: 100%;
  height: 44px;
  margin-top: var(--space-sm);
  font-size: var(--font-size-md);
  font-weight: 600;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.login-submit-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

/* --------------------------------------------------------------------------
   Login: Error message
   -------------------------------------------------------------------------- */
.login-error {
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--failed-light);
  color: var(--failed);
  font-size: var(--font-size-sm);
  line-height: 1.4;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Login: Spinner inside button
   -------------------------------------------------------------------------- */
.spinner-sm {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

/* --------------------------------------------------------------------------
   Login: Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .login-card {
    width: 95vw;
    border-radius: var(--radius-lg);
  }

  .login-header {
    padding: var(--space-lg) var(--space-lg) var(--space-md);
  }

  .login-form {
    padding: 0 var(--space-lg) var(--space-lg);
  }
}


/* ============================================================================
   === READ-ONLY BANNER ===
   Shown for viewer role.
   ============================================================================ */

.readonly-banner {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  height: 28px;
  background: var(--partial-light);
  color: var(--partial);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  z-index: 999;
  border-bottom: 1px solid rgba(217, 119, 6, 0.2);
}

.readonly-icon {
  font-size: 12px;
}

/* Shift views down when banner is visible */
.readonly-banner:not(.hidden) ~ .view {
  top: calc(var(--nav-height) + 28px);
}


/* ============================================================================
   === NAV USER MENU ===
   User info and logout in the navigation bar.
   ============================================================================ */

.nav-user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-right: var(--space-md);
  padding-right: var(--space-md);
  border-right: 1px solid var(--border);
}

.nav-user-name {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.nav-user-role-badge {
  font-size: 10px;
  padding: 1px 6px;
}

.nav-logout-btn {
  font-size: var(--font-size-xs);
  height: 24px;
  padding: 0 var(--space-sm);
  color: var(--text-muted);
}

.nav-logout-btn:hover {
  color: var(--failed);
}

/* --------------------------------------------------------------------------
   Role Badges — Color per role
   -------------------------------------------------------------------------- */
.badge-role-admin     { background: var(--part-a-light); color: var(--part-a); }
.badge-role-editor    { background: var(--part-b-light); color: var(--part-b); }
.badge-role-commenter { background: var(--partial-light); color: var(--partial); }
.badge-role-viewer    { background: #f3f4f6; color: var(--text-secondary); }

/* --------------------------------------------------------------------------
   Role restrictions
   -------------------------------------------------------------------------- */
.role-restricted {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Nav responsive: hide user name on small screens
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .nav-user-name {
    display: none;
  }

  .nav-user-menu {
    margin-right: var(--space-sm);
    padding-right: var(--space-sm);
  }
}


/* ============================================================================
   === USER MANAGEMENT ===
   Admin panel for managing users.
   ============================================================================ */

/* --------------------------------------------------------------------------
   User list
   -------------------------------------------------------------------------- */
.settings-user-list {
  padding: var(--space-md) var(--space-lg);
}

.settings-user-table {
  width: 100%;
}

.settings-user-table td {
  vertical-align: middle;
}

.settings-user-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.settings-user-status-dot.active {
  background: var(--success);
}

.settings-user-status-dot.inactive {
  background: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Add user form
   -------------------------------------------------------------------------- */
.settings-add-user-wrapper {
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  border-top: 1px solid var(--border);
}

.settings-add-user-toggle {
  margin-bottom: var(--space-md);
}

.settings-add-user-form {
  padding: var(--space-md);
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Edit user modal form
   -------------------------------------------------------------------------- */
.settings-edit-user-form .form-group {
  margin-bottom: var(--space-md);
}


/* ============================================================================
   === AUDIT LOG ===
   Admin panel for viewing activity logs.
   ============================================================================ */

/* --------------------------------------------------------------------------
   Audit content area
   -------------------------------------------------------------------------- */
.settings-audit-content {
  padding: var(--space-md) var(--space-lg);
}

/* --------------------------------------------------------------------------
   Audit filter bar
   -------------------------------------------------------------------------- */
.settings-audit-filters {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.settings-audit-filter-select {
  width: auto;
  min-width: 130px;
  height: 32px;
  font-size: var(--font-size-xs);
}

.settings-audit-search {
  width: auto;
  min-width: 160px;
  flex: 1;
  max-width: 240px;
  height: 32px;
  font-size: var(--font-size-xs);
}

/* --------------------------------------------------------------------------
   Audit table
   -------------------------------------------------------------------------- */
.settings-audit-table {
  width: 100%;
  font-size: var(--font-size-xs);
}

.settings-audit-table th {
  font-size: 10px;
}

.settings-audit-table td {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-xs);
}

.settings-audit-row {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.settings-audit-row:hover {
  background: rgba(26, 95, 122, 0.03);
}

.settings-audit-row.selected {
  background: var(--accent-light);
}

/* --------------------------------------------------------------------------
   Audit action badges
   -------------------------------------------------------------------------- */
.settings-audit-action-badge {
  font-size: 10px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Audit detail row (expanded)
   -------------------------------------------------------------------------- */
.settings-audit-detail-row td {
  padding: 0;
}

.settings-audit-detail-cell {
  background: var(--bg);
  border-left: 3px solid var(--accent);
}

.settings-audit-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-xs) var(--space-md);
  padding: var(--space-md);
}

.settings-audit-detail-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.settings-audit-detail-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.settings-audit-detail-value {
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  word-break: break-all;
}

/* --------------------------------------------------------------------------
   Audit pagination
   -------------------------------------------------------------------------- */
.settings-audit-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.settings-audit-page-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Audit responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .settings-audit-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-audit-filter-select,
  .settings-audit-search {
    width: 100%;
    max-width: none;
  }

  .settings-audit-detail-grid {
    grid-template-columns: 1fr;
  }

  .settings-audit-pagination {
    flex-direction: column;
    gap: var(--space-sm);
    align-items: flex-start;
  }
}


/* ============================================================================
   PARAMETER SPACE COVERAGE MAP (canvas.js overlay)
   ============================================================================ */
.cv-coverage-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.cv-coverage-overlay.visible {
  display: flex;
  opacity: 1;
}

.cv-coverage-container {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  max-width: 800px;
  width: 90%;
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  transform: scale(0.9);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.cv-coverage-overlay.visible .cv-coverage-container {
  transform: scale(1);
  opacity: 1;
}

.cv-coverage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.cv-coverage-header h3 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.cv-coverage-axes {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.cv-coverage-axes label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.cv-coverage-axes select {
  font-size: var(--font-size-sm);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-family);
  cursor: pointer;
}

.cv-coverage-axes select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(26, 95, 122, 0.15);
}

.cv-coverage-close {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-family);
  transition: all 0.15s;
}

.cv-coverage-close:hover {
  background: #f1f5f9;
  border-color: var(--accent);
  color: var(--accent);
}

.cv-coverage-legend {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.cv-coverage-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.cv-coverage-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.cv-coverage-grid {
  display: grid;
  gap: 2px;
  margin: var(--space-md) 0;
}

.cv-cov-cell {
  min-height: 40px;
  min-width: 40px;
  border-radius: 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: transform 0.1s, outline-color 0.1s;
  position: relative;
}

.cv-cov-cell:hover {
  transform: scale(1.08);
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  z-index: 2;
}

.cv-cov-cell.cv-cov-cell-empty {
  cursor: crosshair;
}

.cv-cov-cell.cv-cov-cell-empty:hover::after {
  content: '+ Plan';
  position: absolute;
  font-size: 9px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.2px;
}

.cv-cov-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.cv-cov-label {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

.cv-cov-label-x {
  font-size: 10px;
}

.cv-cov-label-y {
  justify-content: flex-end;
  padding-right: 6px;
}

.cv-coverage-axis-labels {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-xs);
}

.cv-coverage-axis-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cv-coverage-summary {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
  line-height: 1.5;
}

.cv-coverage-cell-list {
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

.cv-coverage-cell-list-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.cv-coverage-cell-list-item {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  padding: 2px 0;
  cursor: pointer;
}

.cv-coverage-cell-list-item:hover {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-width: 600px) {
  .cv-coverage-container { max-width: 98vw; padding: var(--space-md); }
  .cv-coverage-header { flex-direction: column; align-items: flex-start; }
  .cv-cov-cell { min-height: 32px; min-width: 32px; }
}


/* ============================================================================
   GROWTH PHASE MARKERS (evaluate.js — eCO2 chart overlay)
   ============================================================================ */
.eval-phase-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.eval-phase-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.eval-phase-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.eval-phase-summary {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Evaluate empty state — clickable experiment list
   -------------------------------------------------------------------------- */
.eval-empty-list {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.eval-list-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-md);
  text-align: left;
}

.eval-experiment-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
}

.eval-experiment-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: white;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, transform 0.15s;
}

.eval-experiment-card:hover {
  border-color: var(--accent, #3b82f6);
  transform: translateY(-1px);
}

.eval-card-name {
  flex: 1 1 auto;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
}

.eval-card-meta {
  flex: 0 0 auto;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-right: var(--space-md);
  text-align: left;
}

.eval-experiment-card .btn-sm {
  flex: 0 0 auto;
}

/* Cross-view sync indicator on Evaluate Step 1 */
.eval-save-indicator-row {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-md);
  font-size: var(--font-size-xs);
}
.eval-outcome-save-indicator {
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.04);
}
.eval-outcome-save-indicator.saved {
  color: #047857;
  background: rgba(4, 120, 87, 0.08);
}
.eval-outcome-save-indicator.failed {
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
}

/* Outcome chip on Canvas cards */
.cv-card-outcome-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 999px;
  margin-right: 4px;
}
.cv-card-outcome-chip--success { background: #d1fae5; color: #065f46; }
.cv-card-outcome-chip--partial { background: #fef3c7; color: #92400e; }
.cv-card-outcome-chip--failure { background: #fee2e2; color: #991b1b; }
.cv-card-outcome-chip--inconclusive { background: #e5e7eb; color: #374151; }
.cv-card-outcome-metrics {
  display: flex;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Playground (Data) view
   -------------------------------------------------------------------------- */
#view-playground { padding: 0; }
.pg-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 56px);
  background: #f9fafb;
}
.pg-sidebar {
  background: white;
  border-right: 1px solid var(--border-color, #e5e7eb);
  overflow-y: auto;
  padding: var(--space-md);
}
.pg-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pg-section {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.pg-section:last-child { border-bottom: none; }
.pg-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
}
.pg-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.pg-link-btn {
  background: none;
  border: none;
  color: var(--accent, #3b82f6);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
}
.pg-link-btn:hover { text-decoration: underline; }

.pg-experiment-list { margin-top: var(--space-sm); max-height: 320px; overflow-y: auto; }
.pg-experiment-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
}
.pg-experiment-row:hover { background: #f3f4f6; }
.pg-experiment-row input[type="checkbox"] { margin-top: 2px; }
.pg-experiment-meta { flex: 1; min-width: 0; }
.pg-experiment-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pg-experiment-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.pg-sensor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-top: var(--space-sm);
}
.pg-sensor-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
}
.pg-sensor-chip:hover { background: #f3f4f6; }
.pg-sensor-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pg-sensor-text { color: var(--text-primary); }
.pg-axis-label { font-size: 11px; min-width: 60px; color: var(--text-muted); }

/* Toolbar */
.pg-toolbar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
  padding: var(--space-md);
  background: white;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  flex-wrap: wrap;
}
.pg-tool-group { display: flex; flex-direction: column; gap: 2px; }
.pg-tool-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.pg-tool-group .form-select { min-width: 150px; }
.pg-custom-range { flex-direction: row; align-items: center; gap: 6px; }
.pg-tool-sep { color: var(--text-muted); font-size: 11px; }
.pg-tool-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }

/* Chart area — definite height so Chart.js (with maintainAspectRatio:false) sizes correctly.
   `flex: 1` alone wasn't enough because the canvas inherited a 0-height box in some
   browsers when sibling stats panel pushed back. */
.pg-chart-wrap {
  height: 480px;
  min-height: 360px;
  padding: var(--space-md);
  background: white;
  margin: var(--space-md);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-md);
  overflow: auto;
  position: relative;
}
.pg-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
}
.pg-empty, .pg-empty-small {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 14px;
}
.pg-empty-small { padding: 12px; font-size: 12px; }
.pg-loading { text-align: center; color: var(--text-muted); padding: 40px; }
.pg-error {
  color: #b91c1c;
  background: #fee2e2;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
}

/* Correlation matrix */
.pg-corr-table {
  border-collapse: collapse;
  margin: 0 auto;
  font-size: 12px;
}
.pg-corr-table th,
.pg-corr-table td {
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  text-align: center;
  min-width: 60px;
  font-weight: 500;
}
.pg-corr-table thead th {
  background: #f3f4f6;
  font-weight: 700;
  position: sticky;
  top: 0;
}
.pg-corr-table tbody th {
  background: #f3f4f6;
  font-weight: 700;
  text-align: right;
}

/* Stats panel */
.pg-stats-wrap {
  padding: 0 var(--space-md) var(--space-md) var(--space-md);
  overflow-y: auto;
  max-height: 320px;
}
.pg-stats-title {
  margin: 0 0 var(--space-sm) 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.pg-stats-card {
  background: white;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
}
.pg-stats-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-sm);
}
.pg-stats-name {
  font-weight: 600;
  font-family: monospace;
  color: var(--text-primary);
}
.pg-stats-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.pg-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.pg-stats-table th,
.pg-stats-table td {
  text-align: right;
  padding: 4px 8px;
  border-bottom: 1px solid #f3f4f6;
}
.pg-stats-table th { font-weight: 700; color: var(--text-muted); }
.pg-stats-table th:first-child,
.pg-stats-table td:first-child { text-align: left; }
