/* ============================================================
   Stately Bio — Wellstats Viewer
   ============================================================ */

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

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Core palette */
  --bg:               #f0f4f8;
  --surface:          #ffffff;
  --surface-2:        #f8fafc;
  --surface-hover:    #f1f5fb;
  --border:           #e2e8f0;
  --border-strong:    #c8d3e0;

  /* Typography */
  --text:             #0f172a;
  --text-secondary:   #475569;
  --text-muted:       #94a3b8;

  /* Brand */
  --primary:          #4f46e5;
  --primary-dark:     #3730a3;
  --primary-hover:    #4338ca;
  --primary-light:    #eef2ff;
  --primary-subtle:   #e0e7ff;

  /* Semantic */
  --danger:           #dc2626;
  --danger-light:     #fee2e2;
  --success:          #059669;
  --success-light:    #d1fae5;
  --warning:          #d97706;
  --warning-light:    #fef3c7;

  /* Selection highlight */
  --sel:              #f59e0b;
  --sel-light:        #fffbeb;
  --sel-border:       #f59e0b;

  /* Geometry */
  --radius:           10px;
  --radius-sm:        6px;
  --radius-lg:        14px;

  /* Elevation */
  --shadow-xs:  0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm:  0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md:  0 4px 12px rgba(15,23,42,0.08), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg:  0 16px 32px rgba(15,23,42,0.12), 0 4px 8px rgba(15,23,42,0.06);

  /* Typography */
  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', Menlo, Consolas, monospace;

  /* Motion */
  --t-fast:    0.1s ease;
  --t-base:    0.18s ease;
  --t-slow:    0.3s ease;

  /* Layout */
  --panel-w:   280px;
  --header-h:  58px;
  --tabs-h:    44px;
  --filters-h: 56px;
}

/* ── Base ── */
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ── */
.header {
  display: flex; justify-content: space-between; align-items: center;
  height: var(--header-h);
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 200;
  gap: 16px;
}
.header-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
}
.header-logo {
  height: 28px; width: auto; flex-shrink: 0;
}
.header-left  { display: flex; align-items: center; gap: 14px; min-width: 0; }
.header-title {
  font-size: 15px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--text); white-space: nowrap; line-height: 1.2;
}
.header-divider {
  width: 1px; height: 22px; background: var(--border); flex-shrink: 0;
}
.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.user-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
}
.user-chip-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary-subtle); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.1px;
  white-space: nowrap;
}
.badge-loading { background: var(--warning-light); color: var(--warning); }
.badge-loading::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--warning); animation: pulse-dot 1.4s infinite;
}
.badge-ready { background: var(--success-light); color: var(--success); }
.badge-ready::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--success);
}
.badge-error { background: var(--danger-light); color: var(--danger); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-secondary);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all var(--t-base);
  text-decoration: none; white-space: nowrap; min-height: 36px;
  box-shadow: var(--shadow-xs);
  letter-spacing: -0.1px;
}
.btn:hover {
  background: var(--surface-hover); color: var(--text);
  border-color: var(--border-strong); box-shadow: var(--shadow-sm);
}
.btn-primary {
  background: var(--primary); color: #fff;
  border-color: transparent;
  box-shadow: 0 1px 4px rgba(79,70,229,0.3), 0 1px 2px rgba(79,70,229,0.2);
}
.btn-primary:hover {
  background: var(--primary-hover); border-color: transparent; color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,0.4);
}
.btn-sm  { padding: 5px 12px; font-size: 12px; min-height: 30px; box-shadow: none; }
.btn-block { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; pointer-events: none; }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 0; padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; height: var(--tabs-h);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 0 18px; border: none; background: none;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; border-bottom: 2.5px solid transparent;
  transition: all var(--t-base); white-space: nowrap; flex-shrink: 0;
  height: 100%; display: flex; align-items: center;
  letter-spacing: -0.1px;
}
.tab:hover { color: var(--text-secondary); background: var(--surface-hover); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── Filters Bar ── */
.filters-bar {
  display: flex; align-items: flex-end; gap: 14px;
  padding: 10px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; min-height: var(--filters-h);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.filter-group > label {
  font-size: 10.5px; color: var(--text-muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px;
}
.filter-group input,
.filter-group select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--font); background: var(--surface); color: var(--text);
  min-height: 34px; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.filter-select-short { height: 52px; min-width: 150px; }
.status-text { font-size: 12px; color: var(--text-muted); padding: 4px 0; align-self: flex-end; }

/* Selection pill in filters bar */
.selection-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px;
  background: var(--sel-light); border: 1px solid var(--sel-border);
  font-size: 11.5px; font-weight: 600; color: var(--warning);
  align-self: flex-end; cursor: default;
}
.selection-badge.hidden { display: none; }
.selection-badge-clear {
  cursor: pointer; color: var(--warning); opacity: 0.6;
  font-size: 13px; line-height: 1; padding: 0 1px;
}
.selection-badge-clear:hover { opacity: 1; }

/* ── Content & Layout ── */
.content { padding: 20px 28px; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.hidden { display: none !important; }

/* Panel layout: fixed sidebar + fluid plot */
.panel-layout {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  gap: 20px;
  min-height: calc(100vh - var(--header-h) - var(--tabs-h) - var(--filters-h) - 40px);
  align-items: start;
}

/* Sidebar panel */
.panel-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
  max-height: calc(100vh - var(--header-h) - var(--tabs-h) - var(--filters-h) - 40px);
  position: sticky;
  top: calc(var(--header-h) + var(--tabs-h) + var(--filters-h) + 20px);
}
.panel-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.9px;
  color: var(--text-muted);
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.panel-controls-inner { padding: 16px 18px 18px; }

.panel-plot { min-width: 0; }

/* Control groups */
.control-group { margin-bottom: 16px; }
.control-group:last-child { margin-bottom: 0; }
.control-group > label {
  display: block; font-size: 11px; color: var(--text-secondary);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 5px;
}
.control-group select,
.control-group input[type="text"],
.control-group input[type="number"] {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--font);
  background: var(--surface); color: var(--text);
  min-height: 34px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: auto;
}
.control-group select:focus,
.control-group input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.select-tall { height: 120px !important; }

/* Range slider */
.control-group input[type="range"] {
  width: 100%; height: 4px;
  -webkit-appearance: none; appearance: none;
  background: var(--border); border-radius: 2px; outline: none;
  margin: 10px 0 4px;
  cursor: pointer;
}
.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  background: var(--primary); border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px var(--primary);
  cursor: pointer; transition: transform var(--t-fast);
}
.control-group input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.control-group input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: none;
  background: var(--primary); cursor: pointer;
}

.help-text {
  font-size: 11.5px; color: var(--text-muted);
  margin-top: 18px; padding: 10px 12px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-strong);
  line-height: 1.6;
}

/* ── Chart containers ── */
.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-height: 420px; position: relative;
  overflow: hidden;
}
.chart-container-scroll { overflow-y: auto; max-height: calc(100vh - 240px); }

.chart-loading, .chart-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  z-index: 5; padding: 32px; text-align: center;
  border-radius: var(--radius);
}
.chart-loading { background: var(--surface); }
.chart-loading .spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.loading-text { font-size: 13px; color: var(--text-muted); }
.chart-empty { font-size: 13.5px; color: var(--text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sort chips ── */
.sort-chips {
  display: flex; align-items: center; gap: 5px; flex-wrap: nowrap;
  min-height: 32px; padding: 3px 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); min-width: 110px;
}
.sort-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px 3px 7px; border-radius: 5px;
  background: var(--primary-light); border: 1px solid var(--primary-subtle);
  font-size: 11px; font-weight: 600; color: var(--primary);
  white-space: nowrap; cursor: default; user-select: none;
}
.sort-chip.dragging { opacity: 0.25; }
.sort-chip-dir { cursor: pointer; font-size: 9px; padding: 0 2px; opacity: 0.7; }
.sort-chip-dir:hover { opacity: 1; }
.sort-chip-remove { cursor: pointer; font-size: 12px; color: var(--danger); margin-left: 2px; opacity: 0.6; }
.sort-chip-remove:hover { opacity: 1; }

/* ── Data Table ── */
.table-controls-bar {
  display: flex; align-items: flex-end; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  box-shadow: var(--shadow-xs);
}
.table-wrapper {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  overflow: auto; max-height: calc(100vh - 310px);
  -webkit-overflow-scrolling: touch;
}
#data-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px; font-family: var(--font-mono);
}
#data-table thead { position: sticky; top: 0; z-index: 10; }
#data-table th {
  background: var(--surface-2);
  padding: 9px 14px; text-align: left;
  font-weight: 700; font-family: var(--font); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.6px;
  border-bottom: 2px solid var(--border); white-space: nowrap;
  cursor: pointer; user-select: none; color: var(--text-secondary);
  transition: background var(--t-fast);
}
#data-table th:hover { background: var(--primary-light); color: var(--primary); }
#data-table th .sort-rank {
  display: inline-block; font-size: 9px; background: var(--primary);
  color: #fff; border-radius: 3px; padding: 0 3px; margin-right: 2px;
  vertical-align: middle;
}
#data-table td {
  padding: 6px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap; transition: background var(--t-fast);
}
#data-table tbody tr:hover td { background: var(--primary-light); }
#data-table tbody tr.row-selected td {
  background: var(--sel-light) !important;
  border-bottom-color: rgba(245,158,11,0.25);
}
#data-table tbody tr.row-selected:first-child td { border-top: 1px solid var(--sel-border); }
.table-pagination {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; justify-content: center;
}

/* ── Modal ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.45); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(3px);
}
.modal-content {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); max-width: 620px; width: 100%;
  max-height: 80vh; overflow: hidden;
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); text-align: right; }
.modal-actions { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.checkbox-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 2px;
}
.checkbox-grid label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; padding: 6px 8px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--t-fast);
}
.checkbox-grid label:hover { background: var(--primary-light); }

/* ── Load tab ── */
.load-section {
  background: var(--surface); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 16px;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.load-section h3 {
  font-size: 14px; font-weight: 700; margin-bottom: 14px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.load-section p { color: var(--text-secondary); font-size: 13px; margin-bottom: 14px; line-height: 1.6; }
.input-row { display: flex; gap: 10px; flex-wrap: wrap; }
.input-row input {
  flex: 1; min-width: 0; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--font-mono); min-height: 36px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input-row input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.experiment-select {
  width: 100%; font-family: var(--font-mono); font-size: 12.5px;
  margin-bottom: 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px;
}
.experiment-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.experiment-picker { margin-top: 12px; }

/* ── Browse panel ── */
.browse-panel {
  margin-top: 12px; padding: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 280px; overflow-y: auto;
  font-family: var(--font-mono); font-size: 12.5px;
}
.browse-panel .browse-item { padding: 8px 10px; cursor: pointer; border-radius: 4px; }
.browse-panel .browse-item:hover { background: var(--primary-light); }
.browse-panel .browse-item.file { color: var(--primary); }
.browse-panel .browse-current {
  padding: 8px 10px; margin-bottom: 10px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); word-break: break-all;
}

/* ── Login ── */
.login-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 20px; padding: 32px; background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 28px 32px; max-width: 280px; width: 100%; text-align: center;
}

/* ── Well image viewer ── */
.wi-image-wrapper {
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: #13151f;
  cursor: grab; position: relative; border-radius: var(--radius);
}
.wi-image-wrapper:active { cursor: grabbing; }
.wi-plate-grid {
  display: grid; grid-template-columns: repeat(12, 1fr);
  gap: 6px; padding: 16px;
  transform-origin: 0 0; transition: transform 0.06s ease-out;
}
.wi-grid-cell {
  background: #1e2130; aspect-ratio: 1.33;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; overflow: hidden; position: relative; min-width: 96px;
  border: 1px solid rgba(255,255,255,0.06); transition: box-shadow var(--t-fast);
}
.wi-grid-cell:hover { outline: 2px solid var(--primary); z-index: 10; }
.wi-grid-cell.wi-selected {
  outline: 2px solid var(--sel); z-index: 15;
  box-shadow: 0 0 0 4px rgba(245,158,11,0.2);
}
.wi-well-highlight {
  outline: 3px solid var(--danger) !important;
  z-index: 20; animation: wi-highlight-pulse 0.4s ease-in-out 3;
}
@keyframes wi-highlight-pulse {
  0%, 100% { outline-color: var(--danger); }
  50%       { outline-color: #fbbf24; }
}
.wi-grid-cell img { width: 100%; height: 100%; object-fit: contain; display: block; }
.wi-well-label {
  position: absolute; top: 4px; left: 6px;
  font-size: 9.5px; font-weight: 600; color: rgba(200,210,230,0.6);
  pointer-events: none; letter-spacing: 0.3px;
}
.wi-stats {
  margin-top: 16px; padding: 12px 14px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 12px; font-family: var(--font-mono); line-height: 2;
}
.wi-stats .wi-stat-row { display: flex; justify-content: space-between; gap: 10px; }
.wi-stats .wi-stat-label { color: var(--text-secondary); min-width: 0; word-break: break-all; }
.wi-stats .wi-stat-value { font-weight: 700; flex-shrink: 0; }

/* Cell calls canvas */
.cc-canvas-wrapper {
  position: relative; display: inline-block;
  max-width: 100%; line-height: 0;
}
.cc-canvas-wrapper canvas { display: block; max-width: 100%; }
.cc-canvas-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.cc-canvas-hover  { position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: crosshair; }
.cc-tooltip {
  display: none; position: absolute;
  background: rgba(8,10,20,0.95); color: #e8ecf4;
  padding: 9px 13px; border-radius: 8px;
  font-size: 11.5px; line-height: 1.65; pointer-events: none;
  white-space: nowrap; z-index: 100;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.55);
}
.cc-tooltip-title { font-weight: 700; margin-bottom: 6px; color: #fff; font-size: 12.5px; }
.cc-tooltip-row  { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.cc-tooltip-row.current { color: #fff; font-weight: 600; }
.cc-tooltip-row:not(.current) { color: #94a3b8; }
.cc-tooltip-bar  { display: inline-block; height: 5px; border-radius: 2px; min-width: 2px; }
.cc-legend { margin-top: 16px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 12px; }
.cc-legend-title { font-weight: 700; margin-bottom: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); }
.cc-legend-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.cc-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.cc-swatch-pos { background: rgba(0,200,0,0.7); }
.cc-swatch-neg { background: rgba(200,0,0,0.5); }

/* Well image — metadata column coloring sidebar */
.wi-meta-section {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.wi-meta-section-header {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 4px;
}
.wi-meta-cols { max-height: 160px; overflow-y: auto; margin-bottom: 6px; }
.wi-meta-col-group-label {
  font-size: 9.5px; font-weight: 600; color: var(--text-muted);
  letter-spacing: 0.4px; padding: 4px 0 2px;
}
.wi-meta-col-item {
  padding: 2px 6px; border-radius: 3px;
  font-size: 11.5px; font-family: var(--font-mono, monospace);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background 0.1s, color 0.1s;
}
.wi-meta-col-item:hover, .wi-meta-col-item.active {
  background: var(--primary-light, #eef2ff);
  color: var(--primary, #4f46e5);
}
.wi-meta-legend { font-size: 11px; color: var(--text); }
.wi-meta-legend-title {
  font-size: 10.5px; font-weight: 700;
  font-family: var(--font-mono, monospace);
  color: var(--text-secondary); margin-bottom: 4px;
}
.wi-meta-legend-item {
  display: flex; align-items: center; gap: 5px;
  margin-bottom: 2px; font-size: 10.5px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.wi-meta-legend-swatch {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0; display: inline-block;
}
.wi-meta-legend-bar { height: 9px; border-radius: 3px; width: 100%; margin-bottom: 2px; }
.wi-meta-legend-bar-labels {
  display: flex; justify-content: space-between;
  font-size: 9.5px; color: var(--text-muted);
  font-family: var(--font-mono, monospace);
}
/* Colored strip at bottom of each well cell when a metadata column is active */
.wi-grid-cell.wi-meta-colored::after {
  content: ''; position: absolute;
  bottom: 0; left: 0; right: 0; height: 5px;
  background: var(--wi-meta-color, transparent);
  z-index: 6;
}

/* Well image overlay */
.wi-overlay-layer { position: absolute; pointer-events: none; }
.wi-field-base-canvas, .wi-field-canvas { display: block; }
.wi-hover-capture { position: absolute; inset: 0; cursor: crosshair; z-index: 10; }
.wi-grid-cell-empty { background: #171923; opacity: 0.5; }
.wi-well-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pv-tooltip { position: absolute; }

/* ── Live Status tab ── */
.ls-status-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
}
.ls-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.ls-dot-idle    { background: var(--text-muted); }
.ls-dot-polling { background: #10b981; animation: pulse 1.5s infinite; }
.ls-dot-error   { background: var(--danger); }

.ls-grid-container { padding: 12px; overflow: auto; min-height: 320px; }

.ls-plate-section { margin-bottom: 24px; }
.ls-plate-title {
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.ls-plate-grid {
  display: grid;
  grid-template-columns: 20px repeat(12, 1fr);
  gap: 3px;
}
.ls-col-hdr, .ls-row-hdr {
  font-size: 9px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.ls-well {
  position: relative; aspect-ratio: 1; border-radius: 50%;
  overflow: hidden; background: var(--bg);
  border: 1px solid var(--border); cursor: default;
  transition: transform 0.12s;
}
.ls-well:hover { transform: scale(1.18); z-index: 10; }
.ls-well-active {
  border-color: var(--primary);
  animation: ls-appear 0.35s ease;
}
.ls-well-thumb {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
}
.ls-well-overlay {
  position: absolute; inset: 0; opacity: 0.45; pointer-events: none;
}
.ls-well-val {
  position: absolute; bottom: 1px; left: 0; right: 0;
  text-align: center; font-size: 7px; font-weight: 600;
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.85);
  pointer-events: none; line-height: 1.2;
}
@keyframes ls-appear {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 640px) {
  :root { --panel-w: 1fr; }
  .header { padding: 0 16px; }
  .header-title { font-size: 14px; }
  .user-chip { display: none; }
  .tabs { padding: 0 8px; }
  .tab { padding: 0 12px; font-size: 12.5px; }
  .filters-bar { padding: 10px 16px; gap: 10px; }
  .filter-group { width: 100%; }
  .filter-select-short { height: 46px; min-width: unset; width: 100%; }
  .content { padding: 14px 16px; }
  .panel-layout { grid-template-columns: 1fr; min-height: auto; }
  .panel-controls { max-height: none; position: static; }
  .chart-container { min-height: 280px; }
  .chart-container-scroll { max-height: 55vh; }
  .table-wrapper { max-height: 50vh; }
  .input-row { flex-direction: column; }
  .modal { padding: 10px; }
  .modal-content { max-height: 90vh; }
  .help-text { display: none; }
  .login-card { padding: 28px 24px; }
}
@media (min-width: 641px) and (max-width: 900px) {
  .panel-layout { grid-template-columns: 1fr; }
  .panel-controls { max-height: none; position: static; }
  .filter-group { min-width: 130px; }
  .content { padding: 16px 20px; }
}
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 46px; padding: 10px 18px; }
  .btn-sm { min-height: 38px; padding: 7px 14px; }
  .tab { padding: 0 16px; }
  .browse-panel .browse-item { padding: 12px 10px; }
  #data-table th { padding: 11px 14px; }
  #data-table td { padding: 9px 14px; }
}
@media (hover: hover) {
  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
}
