/* ============================================================
   PIDSense Design System
   Doaz Inc. — P&ID Intelligence Engine
   ============================================================ */

:root {
  /* Brand Colors */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-bg: #eff6ff;

  --secondary: #0f172a;
  --secondary-light: #1e293b;

  --accent: #06b6d4;
  --accent-light: #22d3ee;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --error: #ef4444;
  --error-bg: #fef2f2;

  /* Magenta Principle — uncertain items */
  --uncertain: #d946ef;
  --uncertain-bg: #fdf4ff;

  /* Neutrals */
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

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

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

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

/* ============================================================
   Reset & Base
   ============================================================ */

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   Layout
   ============================================================ */

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.9);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--secondary);
}

.logo span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.status-dot.active { background: var(--success); }
.status-dot.idle { background: var(--text-muted); }

main {
  flex: 1;
  padding: var(--space-xl);
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================================
   Upload Zone
   ============================================================ */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  background: var(--surface);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.upload-zone.dragover {
  transform: scale(1.01);
}

.upload-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-md);
  background: var(--primary-bg);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-icon svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

.upload-zone h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.upload-zone p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.upload-btn {
  margin-top: var(--space-md);
  padding: 10px 28px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.upload-btn:hover {
  background: var(--primary-dark);
}

/* ============================================================
   Analysis Dashboard
   ============================================================ */

.dashboard {
  display: none;
}

.dashboard.visible {
  display: block;
}

/* When the page loads showing the Overview library (no PDF uploaded in this tab),
   hide session-specific widgets to avoid empty "-" placeholders. */
body.no-active-session .file-info-bar,
body.no-active-session .sheet-grid-section,
body.no-active-session .analysis-controls {
  display: none;
}

.file-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
}

.file-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.file-icon {
  width: 40px;
  height: 40px;
  background: var(--error-bg);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--error);
  font-size: 0.7rem;
  font-weight: 700;
}

.file-details h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.file-details p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.file-actions {
  display: flex;
  gap: var(--space-sm);
}

/* Sheet Grid */

.sheet-grid-section {
  margin-bottom: var(--space-xl);
}

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

.section-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
}

.sheet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.sheet-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.sheet-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-bg), var(--shadow-md);
}

.sheet-card.analyzed {
  border-color: var(--success);
}

.sheet-card.analyzing {
  border-color: var(--warning);
}

.sheet-thumb {
  width: 100%;
  aspect-ratio: 1.414;
  background: #f1f5f9;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.sheet-label {
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
}

.sheet-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.sheet-badge.ready {
  background: var(--primary-bg);
  color: var(--primary);
}

.sheet-badge.done {
  background: var(--success-bg);
  color: var(--success);
}

.sheet-badge.running {
  background: var(--warning-bg);
  color: var(--warning);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================================
   Analysis Controls
   ============================================================ */

.analysis-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

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

.control-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.control-group select,
.control-group input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
  min-width: 160px;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: 0.85rem;
}

.toggle-switch input {
  width: 40px;
  height: 22px;
  appearance: none;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-switch input::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked {
  background: var(--primary);
}

.toggle-switch input:checked::after {
  transform: translateX(18px);
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-success {
  background: #16a34a;
  color: white;
}

.btn-success:hover {
  background: #15803d;
}

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

/* ============================================================
   Results Panel
   ============================================================ */

.results-section {
  display: none;
}

.results-section.visible {
  display: block;
}

.results-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

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

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

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

.result-card-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.count-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 999px;
  font-weight: 700;
}

.result-card-body {
  padding: var(--space-md);
  max-height: 480px;
  overflow-y: auto;
}

/* Entity Tables */

.entity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.entity-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.entity-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.entity-table tr:hover td {
  background: var(--primary-bg);
}

.tag-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--primary-dark);
}

.confidence-bar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.confidence-fill {
  height: 6px;
  border-radius: 3px;
  min-width: 40px;
  max-width: 60px;
}

.confidence-fill.high { background: var(--success); }
.confidence-fill.medium { background: var(--warning); }
.confidence-fill.low { background: var(--error); }

.confidence-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Summary Stats */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  text-align: center;
}

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

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* JSON Viewer */

.json-viewer {
  background: var(--secondary);
  color: #e2e8f0;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.7;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.json-key { color: #7dd3fc; }
.json-string { color: #86efac; }
.json-number { color: #fbbf24; }
.json-bool { color: #c084fc; }
.json-null { color: #94a3b8; }

/* ============================================================
   Relationship Graph Panel
   ============================================================ */

.relationship-list {
  list-style: none;
}

.relationship-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.rel-from, .rel-to {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 0.78rem;
}

.rel-type {
  font-size: 0.65rem;
  padding: 2px 8px;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}

.rel-arrow {
  color: var(--text-muted);
}

/* ============================================================
   Interlock Cards
   ============================================================ */

.interlock-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
}

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

.interlock-id {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--error);
  font-size: 0.85rem;
}

.interlock-trigger {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.interlock-trigger strong {
  color: var(--text);
}

.interlock-actions {
  margin-top: var(--space-sm);
  padding-left: var(--space-md);
  list-style: none;
}

.interlock-actions li {
  font-size: 0.78rem;
  padding: 2px 0;
  color: var(--text-secondary);
}

.interlock-actions li::before {
  content: '\2192  ';
  color: var(--warning);
}

/* ============================================================
   Loading / Progress
   ============================================================ */

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.loading-overlay.visible {
  display: flex;
}

.loading-content {
  text-align: center;
  max-width: 400px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--space-md);
}

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

.loading-content h3 {
  font-size: 1.05rem;
  margin-bottom: var(--space-xs);
}

.loading-content p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: var(--space-md);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 2px;
  transition: width 0.3s ease;
  animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ============================================================
   Tabs
   ============================================================ */

.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 2px;
  margin-bottom: var(--space-md);
  border: 1px solid var(--border);
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  flex: 1;
  text-align: center;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================================
   Empty States
   ============================================================ */

.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.85rem;
}

/* ============================================================
   Toast Notifications
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  min-width: 300px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.toast.success {
  background: var(--success);
  color: white;
}

.toast.error {
  background: var(--error);
  color: white;
}

.toast.info {
  background: var(--primary);
  color: white;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   Visual Inspection Viewer
   ============================================================ */

:root {
  --viewer-equipment: #8b5cf6;
  --viewer-instruments: #06b6d4;
  --viewer-pipes: #94a3b8;
  --viewer-butterfly: #2563eb;
  --viewer-diaphragm: #f59e0b;
  --viewer-bgg: #10b981;
  --viewer-other: #a855f7;
  --viewer-canvas-bg: #0f172a;
}

.viewer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--space-md);
  height: 78vh;
  min-height: 540px;
}

@media (max-width: 1100px) {
  .viewer-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.viewer-image-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 540px;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-wrap: wrap;
}

.viewer-tool-group {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.viewer-tool-btn {
  width: 30px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

.viewer-tool-btn:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.viewer-tool-btn:active {
  background: var(--primary);
  color: white;
}

.viewer-zoom-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  width: 44px;
  text-align: center;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.viewer-tool-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.viewer-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.viewer-toggle-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
}

.viewer-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

.viewer-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, #f1f5f9 25%, transparent 25%) -10px 0,
    linear-gradient(225deg, #f1f5f9 25%, transparent 25%) -10px 0,
    linear-gradient(315deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%);
  background-size: 20px 20px;
  background-color: #fafbfc;
}

.viewer-empty,
.viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-xl);
  pointer-events: none;
}

.viewer-empty svg {
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.viewer-empty p,
.viewer-loading p {
  font-size: 0.85rem;
}

.viewer-stage {
  position: absolute;
  inset: 0;
  overflow: auto;
  cursor: grab;
}

.viewer-stage.panning {
  cursor: grabbing;
}

.viewer-img-wrap {
  position: relative;
  display: inline-block;
  transform-origin: 0 0;
  will-change: transform;
}

.viewer-img-wrap img {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

.viewer-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.viewer-svg .viewer-bbox {
  fill-opacity: 0.08;
  stroke-width: 2;
  cursor: pointer;
  pointer-events: all;
  transition: fill-opacity 0.12s, stroke-width 0.12s;
}

.viewer-svg .viewer-bbox:hover {
  fill-opacity: 0.22;
  stroke-width: 3;
}

.viewer-svg .viewer-bbox.selected {
  fill-opacity: 0.32;
  stroke-width: 3.5;
  filter: drop-shadow(0 0 6px currentColor);
}

.viewer-svg .viewer-bbox.dimmed {
  fill-opacity: 0;
  stroke-opacity: 0.18;
}

.viewer-svg .viewer-label-bg {
  fill: white;
  stroke-width: 1;
  pointer-events: none;
}

.viewer-svg .viewer-label-text {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  dominant-baseline: middle;
}

.viewer-svg .viewer-bbox-group.dimmed .viewer-label-bg,
.viewer-svg .viewer-bbox-group.dimmed .viewer-label-text {
  opacity: 0.18;
}

.viewer-svg.no-labels .viewer-label-bg,
.viewer-svg.no-labels .viewer-label-text {
  display: none;
}

.viewer-svg.no-bboxes .viewer-bbox {
  display: none;
}

/* ─── Sidebar ─── */

.viewer-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewer-sidebar-section {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.viewer-sidebar-section:last-child {
  border-bottom: none;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.viewer-sidebar-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.viewer-sidebar-title h4 {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.viewer-list-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}

.viewer-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.viewer-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}

.viewer-filter-chip:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.viewer-filter-chip.active {
  background: var(--secondary);
  border-color: var(--secondary);
  color: white;
}

.viewer-filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--filter-color, var(--text-muted));
  flex-shrink: 0;
}

.viewer-filter-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  opacity: 0.7;
}

.viewer-entity-list {
  flex: 1;
  overflow-y: auto;
  margin: 0 calc(-1 * var(--space-md)) calc(-1 * var(--space-md));
  padding: 0 var(--space-md) var(--space-md);
}

.viewer-list-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: var(--space-lg) 0;
}

.viewer-entity-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
  border: 1px solid transparent;
}

.viewer-entity-row:hover {
  background: var(--bg);
}

.viewer-entity-row.selected {
  background: var(--primary-bg);
  border-color: var(--primary);
}

.viewer-entity-row.hidden {
  display: none;
}

.viewer-entity-color {
  width: 4px;
  height: 28px;
  border-radius: 2px;
  background: var(--row-color, var(--text-muted));
  flex-shrink: 0;
}

.viewer-entity-info {
  flex: 1;
  min-width: 0;
}

.viewer-entity-tag {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-entity-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* ============================================================
   Phase A — Review Cockpit (공정 관리자용 통합 검토 화면)
   ============================================================ */

:root {
  --cockpit-status-open:         #94a3b8;   /* slate */
  --cockpit-status-needs-review: #f59e0b;   /* amber */
  --cockpit-status-verified:     #10b981;   /* emerald */
  --cockpit-status-rejected:     #ef4444;   /* red */
  --cockpit-edit-panel-width:    420px;
}

.tab-badge-new {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  vertical-align: 1px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  margin-right: 6px;
}

#tab-cockpit { padding: 0; }

.cockpit-layout {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  min-height: 700px;
}

/* ---- Phase 5 — Process Engineer Daily View hero ---- */
.cockpit-daily-hero {
  margin: 16px 16px 0;
  padding: 18px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1e3a8a 0%, #312e81 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(30, 58, 138, 0.2);
}
.cockpit-daily-headline-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.cockpit-daily-greeting {
  margin: 0 0 4px 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: #c7d2fe;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cockpit-daily-headline {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
}
.cockpit-daily-actions a {
  background: #fbbf24;
  color: #422006;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.86rem;
  text-decoration: none;
}
.cockpit-daily-actions a:hover { background: #f59e0b; }
.cockpit-daily-pattern-row {
  display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap;
}
.cockpit-daily-pattern {
  flex: 1 1 240px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
}
.cockpit-daily-pattern-title {
  font-weight: 600; font-size: 0.84rem; line-height: 1.3;
}
.cockpit-daily-pattern-action {
  font-size: 0.74rem; color: #c7d2fe; margin-top: 4px;
}
.cockpit-daily-list {
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  padding: 4px 0;
  max-height: 380px;
  overflow-y: auto;
}
.cockpit-daily-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
}
.cockpit-daily-item:last-child { border-bottom: none; }
.cockpit-daily-item-rank {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: #1e3a8a; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem;
}
.cockpit-daily-item-sev {
  font-size: 0.66rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.cockpit-daily-item-sev.sev-catastrophic { background: #fee2e2; color: #7f1d1d; }
.cockpit-daily-item-sev.sev-major        { background: #fed7aa; color: #9a3412; }
.cockpit-daily-item-sev.sev-moderate     { background: #dbeafe; color: #1d4ed8; }
.cockpit-daily-item-sev.sev-minor        { background: #d1fae5; color: #065f46; }
.cockpit-daily-item-sev.sev-negligible   { background: #f1f5f9; color: #475569; }
.cockpit-daily-item-body {
  display: flex; flex-direction: column; gap: 2px;
}
.cockpit-daily-item-title {
  font-size: 0.88rem; font-weight: 600; color: #1e293b;
}
.cockpit-daily-item-why {
  font-size: 0.76rem; color: #64748b; line-height: 1.35;
}
.cockpit-daily-item-meta {
  font-size: 0.72rem; color: #94a3b8;
  display: flex; gap: 10px; align-items: center;
}
.cockpit-daily-item-sheet {
  background: #f1f5f9; padding: 2px 7px; border-radius: 4px;
  font-family: 'SF Mono', Menlo, monospace;
  white-space: nowrap;
}

/* ---- Phase 6 — Drawing-marker overlay modal ---- */
.cockpit-drawing-modal {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center;
}
.cockpit-drawing-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.65);
}
.cockpit-drawing-modal-card {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: min(960px, 92vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.cockpit-drawing-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.cockpit-drawing-modal-header h3 {
  margin: 0; font-size: 1rem; font-weight: 600; color: #1e293b;
}
.cockpit-drawing-modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; color: #64748b;
}
.cockpit-drawing-modal-body {
  padding: 14px 16px; overflow: auto;
}
.cockpit-drawing-modal-stage {
  position: relative;
  aspect-ratio: 4/3;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}
.cockpit-drawing-modal-stage img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.cockpit-drawing-modal-stage svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
}
.cockpit-drawing-modal-stage svg rect {
  fill: rgba(239, 68, 68, 0.15);
  stroke: #ef4444;
  stroke-width: 4;
}
.cockpit-drawing-modal-stage svg text {
  fill: #ef4444;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
}
.cockpit-drawing-modal-meta {
  margin-top: 10px;
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 0.84rem; color: #475569;
}

/* ---- Phase 6 — Score breakdown tooltip ---- */
.cockpit-daily-score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: #f1f5f9; color: #1e293b;
  padding: 2px 8px; border-radius: 4px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.72rem; font-weight: 600;
  cursor: help;
  position: relative;
}
.cockpit-daily-score-badge:hover .cockpit-daily-score-tip {
  display: block;
}
.cockpit-daily-score-tip {
  display: none;
  position: absolute;
  right: 0; top: calc(100% + 4px);
  background: #1e293b; color: #fff;
  padding: 8px 10px; border-radius: 6px;
  width: 220px;
  text-align: left;
  font-weight: 400;
  z-index: 100;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.cockpit-daily-score-tip-row {
  display: flex; justify-content: space-between;
  font-size: 0.7rem; padding: 1px 0;
}
.cockpit-daily-score-tip-row.total {
  border-top: 1px dashed rgba(255, 255, 255, 0.2);
  margin-top: 4px; padding-top: 4px;
  font-weight: 600;
}

/* ---- Phase 6 — Per-item actions ---- */
.cockpit-daily-item-actions {
  display: flex; gap: 4px;
  margin-top: 6px;
}
.cockpit-daily-action {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: inherit;
}
.cockpit-daily-action:hover { background: #e2e8f0; }
.cockpit-daily-action.active.action-reviewed { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.cockpit-daily-action.active.action-snoozed  { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.cockpit-daily-action.active.action-dismissed { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }

.cockpit-daily-item.is-reviewed,
.cockpit-daily-item.is-snoozed,
.cockpit-daily-item.is-dismissed {
  opacity: 0.55;
}
.cockpit-daily-item.is-reviewed .cockpit-daily-item-title {
  text-decoration: line-through;
  text-decoration-color: rgba(0, 0, 0, 0.3);
}

/* ---- Phase 7-A — Progress badge + actor input ---- */
.cockpit-daily-progress-row {
  display: flex; align-items: center; gap: 16px;
  margin-top: 6px; flex-wrap: wrap;
}
.cockpit-daily-progress {
  display: inline-flex; align-items: center;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.78rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.cockpit-daily-progress.is-fully-reviewed {
  background: #10b981;
  border-color: #34d399;
}
.cockpit-daily-actor-wrap {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.78rem; color: rgba(255, 255, 255, 0.85);
}
.cockpit-daily-actor-wrap input {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 3px 8px; border-radius: 4px;
  font-size: 0.78rem; min-width: 180px;
  font-family: inherit;
}
.cockpit-daily-actor-wrap input::placeholder { color: rgba(255, 255, 255, 0.55); }
.cockpit-daily-actor-wrap input:focus {
  outline: none;
  border-color: #fbbf24;
  background: rgba(255, 255, 255, 0.2);
}

/* ---- Phase 4 — SIL verification draft panel ---- */
.cockpit-sil-panel {
  margin: 12px 16px 0;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: linear-gradient(to bottom, #ecfdf5, #fff);
}
.cockpit-sil-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cockpit-sil-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 0.9rem; color: #047857;
}
.cockpit-sil-stats {
  font-size: 0.74rem; font-weight: 600; color: #475569;
  background: #f1f5f9; padding: 2px 9px; border-radius: 999px;
}
.cockpit-sil-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cockpit-sil-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600;
  background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1;
}
.cockpit-sil-pill.sil-4   { background: #fee2e2; color: #7f1d1d; border-color: #f87171; }
.cockpit-sil-pill.sil-3   { background: #fed7aa; color: #9a3412; border-color: #fdba74; }
.cockpit-sil-pill.sil-2   { background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.cockpit-sil-pill.sil-1   { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.cockpit-sil-pill.sil-none { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.cockpit-sil-list {
  margin: 12px 0 0; max-height: 380px; overflow-y: auto;
  border-top: 1px dashed #e2e8f0;
}
.cockpit-sil-sif {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px; padding: 6px 4px;
  border-bottom: 1px dashed #f1f5f9;
  font-size: 0.78rem;
}
.cockpit-sil-sif-tag {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.72rem; color: #475569; white-space: nowrap;
}
.cockpit-sil-sif-name { color: #1e293b; line-height: 1.4; }
.cockpit-sil-sif-meta { font-size: 0.68rem; color: #94a3b8; white-space: nowrap; }

/* ---- Phase 3 — HAZOP study draft panel ---- */
.cockpit-hazop-panel {
  margin: 12px 16px 0;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: linear-gradient(to bottom, #fef2f2, #fff);
}
.cockpit-hazop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.cockpit-hazop-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #b91c1c;
}
.cockpit-hazop-stats {
  font-size: 0.74rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  padding: 2px 9px;
  border-radius: 999px;
}
.cockpit-hazop-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.cockpit-hazop-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.cockpit-hazop-pill.sev-catastrophic { background: #fee2e2; color: #7f1d1d; border-color: #f87171; }
.cockpit-hazop-pill.sev-major        { background: #fef3c7; color: #b45309; border-color: #fbbf24; }
.cockpit-hazop-pill.sev-moderate     { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.cockpit-hazop-pill.sev-minor        { background: #dcfce7; color: #166534; border-color: #86efac; }
.cockpit-hazop-list {
  margin: 12px 0 0;
  max-height: 380px;
  overflow-y: auto;
  border-top: 1px dashed #e2e8f0;
}
.cockpit-hazop-node {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #f1f5f9;
  border-radius: 6px;
  background: #fff;
}
.cockpit-hazop-node-title {
  font-weight: 600;
  font-size: 0.84rem;
  color: #1e293b;
}
.cockpit-hazop-node-meta {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 2px;
}
.cockpit-hazop-deviation {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 4px 0;
  border-top: 1px dashed #f1f5f9;
  font-size: 0.78rem;
}
.cockpit-hazop-deviation-tag {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.72rem;
  color: #475569;
  white-space: nowrap;
}
.cockpit-hazop-deviation-desc {
  color: #1e293b;
  line-height: 1.4;
}
.cockpit-hazop-deviation-counts {
  font-size: 0.7rem;
  color: #94a3b8;
  white-space: nowrap;
}

/* ---- Phase 2.5 — Validation findings panel (Rule Engine UI) ---- */
.cockpit-validation-panel {
  margin: 12px 16px 0;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: linear-gradient(to bottom, #fffbeb, #fff);
}
.cockpit-validation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.cockpit-validation-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #b45309;
}
.cockpit-validation-total {
  background: #f59e0b;
  color: #fff;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.cockpit-validation-filters {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cockpit-validation-select {
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.78rem;
  background: #fff;
}
.cockpit-validation-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.cockpit-validation-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.cockpit-validation-pill.sev-high   { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.cockpit-validation-pill.sev-medium { background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.cockpit-validation-pill.sev-low    { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.cockpit-validation-pill.sev-info   { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.cockpit-validation-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  max-height: 340px;
  overflow-y: auto;
  border-top: 1px dashed #e2e8f0;
}
.cockpit-validation-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 8px 4px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 120ms ease;
}
.cockpit-validation-item:hover { background: #fef9c3; }
.cockpit-validation-item-rule {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.74rem;
  color: #475569;
  white-space: nowrap;
}
.cockpit-validation-item-msg {
  font-size: 0.82rem;
  color: #1e293b;
  line-height: 1.4;
}
.cockpit-validation-item-tag {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.72rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ---- Project Switcher Bar (A2) ---- */
.cockpit-project-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: linear-gradient(to bottom, #f8fafc, #fff);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.cockpit-project-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 200px;
}
.cockpit-project-icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cockpit-project-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cockpit-project-doc-info {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.cockpit-project-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.cockpit-stat-card {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.78rem;
}
.cockpit-stat-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}
.cockpit-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.cockpit-stat-card.total .cockpit-stat-value         { color: var(--text); }
.cockpit-stat-card.verified .cockpit-stat-value      { color: var(--cockpit-status-verified); }
.cockpit-stat-card.needs-review .cockpit-stat-value  { color: var(--cockpit-status-needs-review); }
.cockpit-stat-card.low-conf .cockpit-stat-value      { color: #dc2626; }
.cockpit-stat-card.modified .cockpit-stat-value      { color: #ea580c; }

/* ---- Mode Toggle ---- */
.cockpit-mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.cockpit-mode-btn {
  padding: 5px 10px;
  border: none;
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-right: 1px solid var(--border);
}
.cockpit-mode-btn:last-child { border-right: none; }
.cockpit-mode-btn:hover { background: #f0f9ff; }
.cockpit-mode-btn.active {
  background: var(--text);
  color: #fff;
  font-weight: 600;
}

/* ---- Compare panel ---- */
.cockpit-compare-panel {
  background: #fef9c3;
  border-bottom: 1px solid #fde047;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cockpit-compare-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cockpit-compare-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: #854d0e;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cockpit-compare-select {
  padding: 5px 8px;
  border: 1px solid #fde047;
  border-radius: 4px;
  background: #fff;
  font-size: 0.82rem;
  font-family: inherit;
  min-width: 200px;
  flex: 1;
  max-width: 320px;
  cursor: pointer;
}
.cockpit-compare-select:focus {
  outline: none;
  border-color: #ca8a04;
}
.cockpit-compare-arrow {
  font-size: 1.1rem;
  color: #ca8a04;
  font-weight: 700;
}

/* ---- Diff summary ---- */
.cockpit-diff-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cockpit-diff-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1.5px solid;
  background: #fff;
}
.cockpit-diff-card-value {
  font-weight: 800;
  font-size: 1.05rem;
  font-family: var(--font-mono);
}
.cockpit-diff-card-label {
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cockpit-diff-card.added    { border-color: #86efac; color: #166534; background: #f0fdf4; }
.cockpit-diff-card.removed  { border-color: #fca5a5; color: #991b1b; background: #fef2f2; }
.cockpit-diff-card.modified { border-color: #fcd34d; color: #854d0e; background: #fffbeb; }
.cockpit-diff-card.rename   { border-color: #c4b5fd; color: #5b21b6; background: #f5f3ff; }
.cockpit-diff-card.unchanged{ border-color: var(--border);  color: var(--text-muted); background: #fff; }
.cockpit-diff-card.offset   { border-color: #93c5fd; color: #1d4ed8; background: #eff6ff; }
.cockpit-diff-carry-btn     { margin-left: auto; align-self: center; font-size: 0.78rem; padding: 6px 10px; }

.cockpit-diff-by-type {
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.cockpit-diff-by-type-item {
  display: inline-block;
  margin-right: 12px;
  font-family: var(--font-mono);
}

/* ---- Diff filter chips ---- */
.cockpit-chip-diff[data-value="added"]    { color: #166534; }
.cockpit-chip-diff[data-value="removed"]  { color: #991b1b; }
.cockpit-chip-diff[data-value="modified"] { color: #854d0e; }
.cockpit-chip-diff.active[data-value="added"]    { background: #16a34a; border-color: #16a34a; color: #fff; }
.cockpit-chip-diff.active[data-value="removed"]  { background: #dc2626; border-color: #dc2626; color: #fff; }
.cockpit-chip-diff.active[data-value="modified"] { background: #d97706; border-color: #d97706; color: #fff; }

/* ---- Diff row colors (left strip) ---- */
.cockpit-row[data-diff="added"]            .cockpit-status-strip { background: #16a34a !important; }
.cockpit-row[data-diff="removed"]          .cockpit-status-strip { background: #dc2626 !important; }
.cockpit-row[data-diff="modified"]         .cockpit-status-strip { background: #d97706 !important; }
.cockpit-row[data-diff="rename_candidate"] .cockpit-status-strip { background: #8b5cf6 !important; }
.cockpit-row[data-diff="renamed"]          .cockpit-status-strip { background: #6d28d9 !important; }

.cockpit-row[data-diff="added"]    td:first-of-type ~ td:nth-child(2) { color: #166534; font-weight: 600; }
.cockpit-row[data-diff="removed"]  { opacity: 0.85; text-decoration: line-through; text-decoration-color: rgba(220,38,38,0.4); }

/* Diff badge in row */
.cockpit-diff-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: inherit;
}
.cockpit-diff-badge.added            { background: #dcfce7; color: #166534; }
.cockpit-diff-badge.removed          { background: #fee2e2; color: #991b1b; }
.cockpit-diff-badge.modified         { background: #fef3c7; color: #854d0e; }
.cockpit-diff-badge.rename_candidate { background: #ede9fe; color: #5b21b6; }
.cockpit-diff-badge.renamed          { background: #c4b5fd; color: #4c1d95; font-weight: 700; }
.cockpit-diff-badge::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  font-size: 0.66rem;
  text-align: center;
  line-height: 8px;
}
.cockpit-diff-badge.added::before            { content: '+'; }
.cockpit-diff-badge.removed::before          { content: '−'; }
.cockpit-diff-badge.modified::before         { content: '~'; }
.cockpit-diff-badge.rename_candidate::before { content: '↻'; }
.cockpit-diff-badge.renamed::before          { content: '✓'; }

/* ---- Diff change detail (in edit panel) ---- */
.cockpit-diff-changes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.cockpit-diff-change {
  padding: 8px 10px;
  border-left: 3px solid #d97706;
  background: #fffbeb;
  border-radius: 0 4px 4px 0;
}
.cockpit-diff-change-field {
  font-size: 0.7rem;
  font-weight: 700;
  color: #854d0e;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cockpit-diff-change-values {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: center;
  margin-top: 3px;
  font-size: 0.84rem;
  font-family: var(--font-mono);
}
.cockpit-diff-old {
  background: #fef2f2;
  padding: 2px 6px;
  border-radius: 3px;
  color: #991b1b;
  text-decoration: line-through;
  text-decoration-color: rgba(153,27,27,0.4);
  word-break: break-word;
}
.cockpit-diff-arrow {
  color: var(--text-muted);
  font-weight: 700;
}
.cockpit-diff-new {
  background: #f0fdf4;
  padding: 2px 6px;
  border-radius: 3px;
  color: #166534;
  font-weight: 600;
  word-break: break-word;
}

/* ---- Toolbar ---- */
.cockpit-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cockpit-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cockpit-search-wrap {
  position: relative;
  flex: 1;
  max-width: 600px;
}

.cockpit-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.cockpit-search-input {
  width: 100%;
  padding: 9px 32px 9px 36px;
  font-size: 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cockpit-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.cockpit-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: var(--border);
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cockpit-search-clear:hover { background: var(--text-muted); color: #fff; }

.cockpit-summary {
  font-size: 0.81rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.cockpit-count-display { font-weight: 600; color: var(--text); }

/* ---- Facet chips ---- */
.cockpit-facets {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: center;
}

.cockpit-facet-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cockpit-facet-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 2px;
}

.cockpit-chip-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.cockpit-chip {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.cockpit-chip:hover {
  border-color: var(--accent);
  background: #f0f7ff;
}
.cockpit-chip.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
  font-weight: 600;
}
.cockpit-chip-quick {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}
.cockpit-chip-quick:hover { background: #ffedd5; }
.cockpit-chip-quick.active { background: #ea580c; color: #fff; border-color: #ea580c; }

.cockpit-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.cockpit-status-dot.status-open         { background: var(--cockpit-status-open); }
.cockpit-status-dot.status-needs-review { background: var(--cockpit-status-needs-review); }
.cockpit-status-dot.status-verified     { background: var(--cockpit-status-verified); }
.cockpit-status-dot.status-rejected     { background: var(--cockpit-status-rejected); }

.cockpit-sheet-select {
  font-size: 0.78rem;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
  cursor: pointer;
}

/* ---- Phase 2.10-B — Multi-sheet thumbnail strip ---- */
.cockpit-sheet-strip {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 12px 16px 0;
  background: linear-gradient(to bottom, #f8fafc, #ffffff);
  overflow: hidden;
}
.cockpit-sheet-strip-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: #f1f5f9;
}
.cockpit-sheet-strip-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: #334155;
}
.cockpit-sheet-strip-count {
  background: #6366f1;
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.cockpit-sheet-strip-status {
  font-size: 0.72rem;
  color: #64748b;
  margin-left: auto;
}
.cockpit-sheet-strip-scroll {
  /* Phase 7-K — Strip is now a vertical metadata table, not a horizontal
     thumbnail row. Engineer differentiates sheets by parsed title-block
     fields, not pixel previews. */
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 12px 14px;
  overflow-x: auto;
  scrollbar-width: thin;
}

/* Phase 7-K — sheet metadata table */
.cockpit-sheet-table-head {
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
}
.cockpit-sheet-table-stats {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.84rem; color: #475569;
}
.cockpit-sheet-table-stats strong { color: #0f172a; font-size: 0.9rem; }
.cockpit-sheet-refresh-btn { margin-left: auto; font-size: 0.78rem; padding: 5px 10px; }
.cockpit-sheet-table-row {
  display: grid;
  grid-template-columns: 60px 220px 80px 110px 1fr 80px 80px;
  gap: 8px;
  padding: 8px 6px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  align-items: center;
  font-size: 0.82rem;
  transition: background 100ms;
}
.cockpit-sheet-table-row:hover { background: #f8fafc; }
.cockpit-sheet-table-row.active { background: #eff6ff; border-left: 3px solid #2563eb; padding-left: 3px; }
.cockpit-sheet-table-header-row {
  background: #f1f5f9;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  cursor: default;
}
.cockpit-sheet-table-header-row:hover { background: #f1f5f9; }
.cockpit-sheet-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cockpit-sheet-cell.cell-ttl {
  white-space: normal;
  font-weight: 500;
  color: #0f172a;
}
.cockpit-sheet-cell.cell-ent { text-align: right; font-family: 'SF Mono', Menlo, monospace; }
.cockpit-sheet-cell.cell-actions { text-align: right; }
.cockpit-sheet-missing {
  color: #b91c1c;
  font-style: italic;
  font-size: 0.74rem;
  background: #fef2f2;
  border: 1px dashed #fca5a5;
  border-radius: 4px;
  padding: 1px 6px;
}
.cockpit-sheet-edit-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.74rem;
  cursor: pointer;
  font-family: inherit;
}
.cockpit-sheet-edit-btn:hover { background: #e2e8f0; color: #0f172a; }

/* Phase 7-K — sheet edit modal */
.cockpit-sheet-edit-modal {
  position: fixed; inset: 0; z-index: 1300;
  display: flex; align-items: center; justify-content: center;
}
.cockpit-sheet-edit-backdrop {
  position: absolute; inset: 0; background: rgba(15, 23, 42, 0.6);
}
.cockpit-sheet-edit-card {
  position: relative; background: #fff;
  border-radius: 10px; padding: 20px 24px;
  width: min(560px, 92vw); max-height: 90vh; overflow: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.cockpit-sheet-edit-card h3 {
  margin: 0 0 14px; color: #1e293b; font-size: 1.05rem;
}
.cockpit-sheet-edit-card form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.cockpit-sheet-edit-card label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.78rem; color: #475569; font-weight: 500;
}
.cockpit-sheet-edit-card label input {
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.86rem;
  font-family: inherit;
  color: #0f172a;
}
.cockpit-sheet-edit-card label input:focus {
  outline: none; border-color: #2563eb;
}
.cockpit-sheet-edit-actions {
  grid-column: 1 / -1;
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 8px;
}
.cockpit-sheet-edit-actions .btn { padding: 7px 14px; font-size: 0.86rem; }
.cockpit-sheet-card {
  flex: 0 0 auto;
  width: 140px;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 4px;
  background: #fff;
  transition: border-color 120ms ease, transform 120ms ease;
}
.cockpit-sheet-card:hover { transform: translateY(-1px); border-color: #cbd5e1; }
.cockpit-sheet-card.active { border-color: #6366f1; box-shadow: 0 0 0 1px #6366f133; }
.cockpit-sheet-card-img {
  width: 100%;
  aspect-ratio: 4/3;
  background: #f1f5f9;
  border-radius: 4px;
  display: block;
  object-fit: contain;
  border: 1px solid #e2e8f0;
}
.cockpit-sheet-card-img.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: #94a3b8;
}
.cockpit-sheet-card-meta {
  margin-top: 4px;
  font-size: 0.72rem;
  line-height: 1.3;
}
.cockpit-sheet-card-tag {
  font-weight: 600;
  color: #1e293b;
}
.cockpit-sheet-card-title {
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cockpit-sheet-card-counts {
  color: #94a3b8;
  font-size: 0.66rem;
  margin-top: 2px;
}

/* ---- Main: grid + edit panel ---- */
.cockpit-main {
  display: grid;
  grid-template-columns: 1fr var(--cockpit-edit-panel-width);
  min-height: 600px;
  background: var(--bg);
}

.cockpit-grid-pane {
  position: relative;
  overflow: auto;
  min-height: 600px;
  max-height: calc(100vh - 280px);
  background: #fff;
  border-right: 1px solid var(--border);
}

.cockpit-grid-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  height: 100%;
}
.cockpit-grid-empty p { margin: 12px 0 0; font-size: 0.9rem; }
.cockpit-grid-empty-hint { font-size: 0.78rem !important; color: var(--text-muted); margin-top: 4px !important; }

/* ---- Grid table ---- */
.cockpit-grid-wrap { width: 100%; }

.cockpit-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.81rem;
  table-layout: fixed;
}

.cockpit-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 8px;
  text-align: left;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

.cockpit-col-status   { width: 6px;  padding: 0 !important; }
.cockpit-col-sheet    { width: 60px; text-align: center !important; }
.cockpit-col-type     { width: 88px; }
.cockpit-col-tag      { width: 18%; min-width: 130px; }
.cockpit-col-category { width: 22%; }
.cockpit-col-line     { width: 18%; }
.cockpit-col-conf     { width: 60px; text-align: center !important; }
.cockpit-col-mod      { width: 50px; text-align: center !important; }

.cockpit-row {
  cursor: pointer;
  transition: background-color 0.1s;
}
.cockpit-row:hover { background: #f0f9ff; }
.cockpit-row.selected {
  background: #e0f2fe !important;
  box-shadow: inset 3px 0 0 var(--accent);
}
.cockpit-row td {
  padding: 7px 8px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cockpit-row td.cockpit-cell-status {
  padding: 0 !important;
  border-bottom: 1px solid #f1f5f9;
}
.cockpit-cell-status .cockpit-status-strip {
  width: 6px;
  height: 100%;
  min-height: 32px;
  display: block;
}
.cockpit-row[data-status="open"]         .cockpit-status-strip { background: var(--cockpit-status-open); }
.cockpit-row[data-status="needs_review"] .cockpit-status-strip { background: var(--cockpit-status-needs-review); }
.cockpit-row[data-status="verified"]     .cockpit-status-strip { background: var(--cockpit-status-verified); }
.cockpit-row[data-status="rejected"]     .cockpit-status-strip { background: var(--cockpit-status-rejected); }

.cockpit-type-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 7px;
  border-radius: 10px;
  white-space: nowrap;
}
.cockpit-type-pill[data-type="valve"]               { background: #dbeafe; color: #1e40af; }
.cockpit-type-pill[data-type="equipment"]           { background: #ede9fe; color: #5b21b6; }
.cockpit-type-pill[data-type="instrument"]          { background: #cffafe; color: #155e75; }
.cockpit-type-pill[data-type="pipe"]                { background: #f1f5f9; color: #475569; }
.cockpit-type-pill[data-type="off_page_connector"]  { background: #fce7f3; color: #9d174d; }

.cockpit-cell-tag {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
}
.cockpit-cell-tag-empty {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
  font-family: inherit;
}

.cockpit-conf-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 3px;
}
.cockpit-conf-high { background: #dcfce7; color: #166534; }
.cockpit-conf-mid  { background: #fef3c7; color: #854d0e; }
.cockpit-conf-low  { background: #fee2e2; color: #991b1b; }

.cockpit-mod-marker {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
  line-height: 18px;
  border: 1px solid #fcd34d;
}
.cockpit-mod-marker.added {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.cockpit-row.low-confidence td {
  background: linear-gradient(to right, #fef3c7 0%, #fff 30%);
}

/* ---- Edit panel (right side) ---- */
.cockpit-edit-panel {
  background: #fff;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.cockpit-edit-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  height: 100%;
}
.cockpit-edit-empty p { margin: 8px 0 0; font-size: 0.9rem; }
.cockpit-edit-hint { font-size: 0.76rem !important; color: var(--text-muted); }

.cockpit-edit-body { padding: 16px 20px; }

.cockpit-edit-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.cockpit-edit-tag {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}
.cockpit-edit-tag-empty {
  color: var(--text-muted);
  font-style: italic;
  font-family: inherit;
  font-weight: 400;
}
.cockpit-edit-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.cockpit-edit-meta-item {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

/* ---- Connector "Jump to Peer" card (Phase B Sprint 2.1) ---- */
.cockpit-connector-peer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  padding: 12px;
  background: linear-gradient(to right, #fdf2f8, #fce7f3);
  border: 1px solid #f9a8d4;
  border-radius: 8px;
}
.cockpit-connector-peer-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9d174d;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cockpit-connector-peer-arrow {
  font-size: 1rem;
}
.cockpit-connector-peer-summary {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.cockpit-connector-peer-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.cockpit-connector-peer-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.cockpit-connector-peer-jump {
  background: linear-gradient(135deg, #db2777, #be185d);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 7px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.1s;
}
.cockpit-connector-peer-jump:hover { transform: translateY(-1px); }
.cockpit-connector-peer-no-pair {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================================
   Phase B Sprint 2.2 — Line Impact Card
   ============================================================ */
.cockpit-line-impact {
  margin: 12px 0;
  padding: 12px;
  background: linear-gradient(to right, #ecfeff, #cffafe);
  border: 1px solid #67e8f9;
  border-radius: 8px;
}
.cockpit-line-impact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.cockpit-line-impact-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #155e75;
}
.cockpit-line-impact-key {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #0e7490;
  background: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #67e8f9;
}
.cockpit-line-impact-summary {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.4;
}
.cockpit-line-impact-summary strong { color: var(--text); }
.cockpit-line-impact-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}
.cockpit-line-impact-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}
.cockpit-line-impact-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  font-size: 0.82rem;
  border: 1px solid transparent;
}
.cockpit-line-impact-item:hover {
  background: #f0f9ff;
  transform: translateX(2px);
  border-color: #67e8f9;
}
.cockpit-line-impact-tag {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}
.cockpit-line-impact-tag-empty {
  color: var(--text-muted);
  font-style: italic;
}
.cockpit-line-impact-meta {
  flex: 1;
  font-size: 0.74rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cockpit-line-impact-status {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.cockpit-line-impact-status[data-s="verified"]    { background: var(--cockpit-status-verified); }
.cockpit-line-impact-status[data-s="needs_review"]{ background: var(--cockpit-status-needs-review); }
.cockpit-line-impact-status[data-s="open"]        { background: var(--cockpit-status-open); }
.cockpit-line-impact-status[data-s="approved"]    { background: #14b8a6; }
.cockpit-line-impact-status[data-s="submitted_for_approval"] { background: #6366f1; }

/* ============================================================
   Phase B Sprint 3.1 — Approval workflow status colors
   ============================================================ */
.cockpit-status-toggle button[data-status="approved"].active {
  background: #14b8a6;
  color: #fff;
}
.cockpit-status-toggle button[data-status="submitted_for_approval"].active {
  background: #6366f1;
  color: #fff;
}

.cockpit-status-dot.status-approved              { background: #14b8a6; }
.cockpit-status-dot.status-submitted_for_approval{ background: #6366f1; }

.cockpit-row[data-status="approved"]              .cockpit-status-strip { background: #14b8a6; }
.cockpit-row[data-status="submitted_for_approval"].cockpit-status-strip { background: #6366f1; }

.cockpit-approval-card {
  margin: 12px 0;
  padding: 12px;
  background: linear-gradient(to right, #f5f3ff, #eef2ff);
  border: 1px solid #c4b5fd;
  border-radius: 8px;
}
.cockpit-approval-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.cockpit-approval-input {
  flex: 1;
  min-width: 150px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
}
.cockpit-approval-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.btn-submit-approval {
  background: #6366f1;
  border-color: #6366f1;
}
.btn-approve {
  background: #14b8a6;
  border-color: #14b8a6;
}
.btn-reject {
  background: #ef4444;
  border-color: #ef4444;
}
.cockpit-approval-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.cockpit-approval-meta strong { color: var(--text); }

/* ============================================================
   Phase B Sprint 3.2 — Audit Search modal
   ============================================================ */
.header-audit-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  font-family: inherit;
  transition: background 0.12s;
}
.header-audit-btn:hover { background: #f0f9ff; border-color: var(--accent); }

/* ---- Phase 7-I — Language toggle ---- */
.header-lang-toggle {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  font-family: inherit;
  padding: 4px 8px;
  cursor: pointer;
}
.header-lang-toggle:hover  { background: #f0f9ff; border-color: var(--accent); }
.header-lang-toggle:focus  { outline: none; border-color: var(--accent); }

.audit-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 250;
  display: flex; align-items: center; justify-content: center;
}
.audit-modal-backdrop {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.5);
}
.audit-modal-card {
  position: relative;
  width: 880px; max-width: 95vw;
  max-height: 88vh;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.audit-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fafafa, #fff);
}
.audit-modal-header h3 { margin: 0; font-size: 1rem; font-weight: 700; color: var(--text); }
.audit-modal-body {
  padding: 14px 18px;
  overflow-y: auto;
  flex: 1;
}

.audit-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.audit-filter { display: flex; flex-direction: column; gap: 3px; }
.audit-filter label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.audit-filter input,
.audit-filter select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.84rem;
  font-family: inherit;
  background: #fff;
}
.audit-filter input:focus,
.audit-filter select:focus {
  outline: none;
  border-color: var(--accent);
}
.audit-filter-wide { grid-column: span 2; }

.audit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.audit-result-count {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.audit-results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 380px;
  overflow-y: auto;
}
.audit-results-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.86rem;
}
.audit-result-item {
  display: grid;
  grid-template-columns: 130px 80px 100px 1fr;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.82rem;
  cursor: pointer;
}
.audit-result-item:hover { background: #f8fafc; }
.audit-result-time {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
}
.audit-result-actor {
  font-weight: 600;
  color: var(--text);
}
.audit-result-action-pill {
  display: inline-block;
  padding: 1px 7px;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 3px;
  width: fit-content;
}
.audit-result-action-pill[data-action="create"] { background: #dbeafe; color: #1e40af; }
.audit-result-action-pill[data-action="update"] { background: #fef3c7; color: #92400e; }
.audit-result-action-pill[data-action="verify"] { background: #dcfce7; color: #166534; }
.audit-result-action-pill[data-action="reanalyze"] { background: #f1f5f9; color: #475569; }
.audit-result-action-pill[data-action="reject"] { background: #fee2e2; color: #991b1b; }

.audit-result-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  word-break: break-word;
}
.audit-result-entity {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
}
.audit-result-detail {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.cockpit-status-toggle {
  display: flex;
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.cockpit-status-toggle button {
  flex: 1;
  padding: 8px 10px;
  border: none;
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-right: 1px solid var(--border);
  transition: all 0.15s;
}
.cockpit-status-toggle button:last-child { border-right: none; }
.cockpit-status-toggle button:hover { background: #f8fafc; }
.cockpit-status-toggle button.active { font-weight: 700; }
.cockpit-status-toggle button[data-status="open"].active {
  background: var(--cockpit-status-open); color: #fff;
}
.cockpit-status-toggle button[data-status="needs_review"].active {
  background: var(--cockpit-status-needs-review); color: #fff;
}
.cockpit-status-toggle button[data-status="verified"].active {
  background: var(--cockpit-status-verified); color: #fff;
}

.cockpit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 11px;
}
.cockpit-field-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cockpit-field input,
.cockpit-field select,
.cockpit-field textarea {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.84rem;
  font-family: inherit;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}
.cockpit-field input[data-mono="true"] {
  font-family: var(--font-mono);
  font-weight: 600;
}
.cockpit-field input:focus,
.cockpit-field select:focus,
.cockpit-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

.cockpit-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cockpit-field-modified {
  font-size: 0.68rem;
  color: var(--cockpit-status-needs-review);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.cockpit-section-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 16px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.cockpit-save-bar {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 0 4px;
  margin-top: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.cockpit-save-status {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.cockpit-save-status.success { color: var(--cockpit-status-verified); font-weight: 600; }
.cockpit-save-status.error { color: var(--cockpit-status-rejected); font-weight: 600; }

/* ---- Audit log timeline ---- */
.cockpit-audit-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.cockpit-audit-item {
  position: relative;
  padding: 8px 0 8px 22px;
  font-size: 0.78rem;
  border-left: 2px solid var(--border);
  margin-left: 8px;
}
.cockpit-audit-item::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  border: 2px solid #fff;
}
.cockpit-audit-item[data-action="create"]::before    { background: #3b82f6; }
.cockpit-audit-item[data-action="update"]::before    { background: #f59e0b; }
.cockpit-audit-item[data-action="verify"]::before    { background: var(--cockpit-status-verified); }
.cockpit-audit-item[data-action="reject"]::before    { background: var(--cockpit-status-rejected); }
.cockpit-audit-item[data-action="reanalyze"]::before { background: #94a3b8; }

.cockpit-audit-line1 {
  font-weight: 600;
  color: var(--text);
  display: flex;
  gap: 6px;
  align-items: center;
}
.cockpit-audit-action {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--border);
  color: var(--text);
}
.cockpit-audit-action[data-action="create"]    { background: #dbeafe; color: #1e40af; }
.cockpit-audit-action[data-action="update"]    { background: #fef3c7; color: #92400e; }
.cockpit-audit-action[data-action="verify"]    { background: #dcfce7; color: #166534; }
.cockpit-audit-action[data-action="reanalyze"] { background: #f1f5f9; color: #475569; }

.cockpit-audit-line2 {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* ============================================================
   Phase B Sprint 1 — Comments / Notifications / Assignee
   ============================================================ */

/* ---- Header user + notification bell ---- */
.header-user {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.header-user-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.header-user-icon {
  position: absolute;
  left: 8px;
  color: var(--text-muted);
  pointer-events: none;
}
.header-user input {
  padding: 4px 8px 4px 26px;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  width: 90px;
  font-family: inherit;
}
.header-user input:focus {
  outline: none;
  border-color: var(--accent);
  width: 130px;
}
.header-bell {
  position: relative;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.12s;
}
.header-bell:hover { background: #f0f9ff; }
.header-bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #dc2626;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1.5px solid #fff;
}

.header-notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 400px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.12);
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.header-notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  background: #f8fafc;
}
.header-notif-mark-all {
  font-size: 0.72rem;
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}
.header-notif-mark-all:hover { text-decoration: underline; }
.header-notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  max-height: 350px;
}
.header-notif-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
}
.header-notif-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.1s;
}
.header-notif-item:hover { background: #f8fafc; }
.header-notif-item.unread { background: #eff6ff; border-left: 3px solid var(--accent); }
.header-notif-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}
.header-notif-kind-pill {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
}
.header-notif-kind-pill[data-kind="mention"]       { background: #fef3c7; color: #854d0e; }
.header-notif-kind-pill[data-kind="assigned"]      { background: #dbeafe; color: #1e40af; }
.header-notif-kind-pill[data-kind="comment_reply"] { background: #ede9fe; color: #5b21b6; }
.header-notif-kind-pill[data-kind="review_request"]{ background: #cffafe; color: #155e75; }
.header-notif-actor { font-weight: 600; color: var(--text); }
.header-notif-time { font-size: 0.7rem; color: var(--text-muted); margin-left: auto; }
.header-notif-body {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ---- Cockpit edit panel: Assignee + Comment thread ---- */
.cockpit-assignee-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  padding: 8px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.cockpit-assignee-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.cockpit-assignee-input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.84rem;
  background: #fff;
  font-family: inherit;
}
.cockpit-assignee-input:focus { outline: none; border-color: var(--accent); }
.cockpit-assignee-current {
  padding: 2px 8px;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ---- Comment thread ---- */
.cockpit-comments {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cockpit-comment-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
}
.cockpit-comment {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.82rem;
}
.cockpit-comment.reply {
  margin-left: 18px;
  background: #f8fafc;
}
.cockpit-comment-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.cockpit-comment-author {
  font-weight: 700;
  color: var(--text);
  font-size: 0.78rem;
}
.cockpit-comment-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.cockpit-comment-delete {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.74rem;
  padding: 0 2px;
}
.cockpit-comment-delete:hover { color: var(--cockpit-status-rejected); }
.cockpit-comment-body {
  font-size: 0.84rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.cockpit-mention {
  background: #fef3c7;
  color: #854d0e;
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 600;
}
.cockpit-comment-reply-btn {
  font-size: 0.72rem;
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  margin-top: 4px;
  padding: 0;
}
.cockpit-comment-reply-btn:hover { text-decoration: underline; }

.cockpit-comment-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.cockpit-comment-form-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.cockpit-comment-textarea {
  width: 100%;
  min-height: 50px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.84rem;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.cockpit-comment-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}
.cockpit-comment-form-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.cockpit-comment-hint {
  flex: 1;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.cockpit-comment-replying {
  font-size: 0.74rem;
  color: var(--text-secondary);
  background: #fef3c7;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cockpit-comment-cancel-reply {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ---- MOC Export bar + modal ---- */
.cockpit-moc-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(to right, #ecfdf5, #f0fdf4);
  border: 1px solid #86efac;
  border-radius: 6px;
  margin-top: 4px;
}
.cockpit-moc-hint {
  flex: 1;
  font-size: 0.84rem;
  color: #166534;
  font-weight: 500;
}

.cockpit-moc-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cockpit-moc-modal-backdrop {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.5);
}
.cockpit-moc-modal-card {
  position: relative;
  width: 480px;
  max-width: 90vw;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  overflow: hidden;
}
.cockpit-moc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fafafa, #fff);
}
.cockpit-moc-modal-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.cockpit-moc-modal-close {
  width: 26px; height: 26px;
  border: none;
  background: var(--border);
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text);
}
.cockpit-moc-modal-close:hover { background: var(--text-muted); color: #fff; }

.cockpit-moc-modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cockpit-moc-modal-status {
  font-size: 0.84rem;
  padding: 8px 0;
  color: var(--text-secondary);
  min-height: 20px;
}
.cockpit-moc-modal-status.success { color: var(--cockpit-status-verified); font-weight: 600; }
.cockpit-moc-modal-status.error { color: var(--cockpit-status-rejected); font-weight: 600; }
.cockpit-moc-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: #fafafa;
}

/* ============================================================
   Phase A.2 — Overview Dashboard
   ============================================================ */

#tab-overview { padding: 0; }

.overview-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px;
}

.overview-welcome {
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 20px 24px;
  text-align: center;
}
.overview-welcome h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  color: var(--text);
}
.overview-welcome p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.overview-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.overview-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}
.overview-section-header h3 {
  display: inline;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.overview-section-count {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  background: var(--text);
  color: #fff;
  border-radius: 10px;
  font-size: 0.74rem;
  font-weight: 600;
}
.overview-section-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.overview-search {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.82rem;
  font-family: inherit;
  width: 200px;
}
.overview-search:focus {
  outline: none;
  border-color: var(--accent);
  width: 280px;
}

/* ---- Project grid ---- */
.overview-project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px;
}

.overview-grid-loading,
.overview-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.overview-project-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  transition: all 0.15s;
  cursor: pointer;
  position: relative;
}
.overview-project-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(37,99,235,0.08);
  transform: translateY(-1px);
}

.overview-project-card-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 7px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.overview-project-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overview-project-card-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.overview-project-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  margin-bottom: 10px;
  padding: 8px;
  background: #fafafa;
  border-radius: 5px;
}
.overview-project-stat {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 0.78rem;
}
.overview-project-stat-value {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
}
.overview-project-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.overview-project-stat[data-kind="verified"] .overview-project-stat-value { color: var(--cockpit-status-verified); }
.overview-project-stat[data-kind="needs_review"] .overview-project-stat-value { color: var(--cockpit-status-needs-review); }
.overview-project-stat[data-kind="low_conf"] .overview-project-stat-value { color: #dc2626; }

.overview-project-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}
.overview-project-card-actions .btn {
  flex: 1;
  font-size: 0.78rem;
  padding: 5px 8px;
}

/* ---- Phase 7-B' — Project review-focus strip ---- */
.overview-project-focus {
  margin: 8px 0 4px;
  padding: 8px 10px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.overview-project-focus-header {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.overview-project-focus-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #475569;
}
.overview-project-focus-summary {
  font-size: 0.74rem;
  color: #475569;
}
.overview-project-focus-summary strong { color: #0f172a; }
.overview-project-focus-warn { color: #b91c1c; font-weight: 600; }
.overview-project-focus-ok   { color: #047857; font-weight: 600; }
.overview-project-focus-chips {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.overview-project-focus-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-left: 3px solid #94a3b8;     /* state colour stripe */
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.74rem;
  color: #1e293b;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  max-width: 100%;
  transition: background 0.15s;
}
.overview-project-focus-chip:hover { background: #f1f5f9; }
.overview-project-focus-chip.state-todo     { border-left-color: #ef4444; }   /* red — needs attention */
.overview-project-focus-chip.state-progress { border-left-color: #f59e0b; }   /* amber — in progress */
.overview-project-focus-chip.state-done     { border-left-color: #10b981; }   /* green — fully reviewed */
.overview-project-focus-chip-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.overview-project-focus-chip-progress {
  background: #f1f5f9;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.68rem;
  color: #475569;
  font-family: 'SF Mono', Menlo, monospace;
}
.overview-project-focus-chip-sev {
  font-size: 0.68rem;
  color: #b45309;
  font-weight: 600;
}
.overview-project-focus-chip-sev[data-cat] { color: #b91c1c; }

/* ---- Activity list ---- */
.overview-activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
}
.overview-activity-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.86rem;
}
.overview-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.1s;
}
.overview-activity-item:hover { background: #f8fafc; }
.overview-activity-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.overview-activity-icon[data-kind^="comment"] { background: #ede9fe; color: #5b21b6; }
.overview-activity-icon[data-kind^="revision:create"] { background: #dbeafe; color: #1e40af; }
.overview-activity-icon[data-kind^="revision:verify"] { background: #dcfce7; color: #166534; }
.overview-activity-icon[data-kind^="revision:update"] { background: #fef3c7; color: #92400e; }
.overview-activity-icon[data-kind^="revision:reanalyze"] { background: #f1f5f9; color: #475569; }
.overview-activity-icon[data-kind^="diff"] { background: #ede9fe; color: #5b21b6; }

.overview-activity-content {
  flex: 1;
  min-width: 0;
}
.overview-activity-summary {
  color: var(--text);
  word-break: break-word;
}
.overview-activity-meta {
  display: flex;
  gap: 8px;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.overview-activity-actor {
  font-weight: 600;
  color: var(--text-secondary);
}

/* ---- New Project Modal ---- */
.overview-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.overview-modal-backdrop {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.5);
}
.overview-modal-card {
  position: relative;
  width: 480px; max-width: 90vw;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  overflow: hidden;
}
.overview-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fafafa, #fff);
}
.overview-modal-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.overview-modal-body {
  padding: 16px 18px;
  display: flex; flex-direction: column;
  gap: 10px;
}
.overview-upload-zone {
  padding: 24px;
  border: 2px dashed var(--border);
  border-radius: 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}
.overview-upload-zone:hover {
  border-color: var(--accent);
  background: #f0f9ff;
}
.overview-upload-zone.dragover {
  border-color: var(--accent);
  background: #eff6ff;
}
.overview-upload-filename {
  margin-top: 6px !important;
  color: var(--accent) !important;
  font-weight: 600 !important;
  font-family: var(--font-mono);
  font-size: 0.78rem !important;
}

/* ============================================================
   Phase A.2 — Feedback Widget (FAB + Modal)
   ============================================================ */

.feedback-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 22px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  transition: all 0.15s;
}
.feedback-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.22);
  background: var(--accent);
}
.feedback-fab svg { flex-shrink: 0; }

.feedback-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 250;
  display: flex; align-items: center; justify-content: center;
}
.feedback-modal-backdrop {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.5);
}
.feedback-modal-card {
  position: relative;
  width: 480px; max-width: 90vw;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  overflow: hidden;
}
.feedback-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fafafa, #fff);
}
.feedback-modal-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.feedback-modal-body {
  padding: 16px 18px;
  display: flex; flex-direction: column;
  gap: 10px;
}
.feedback-hint {
  margin: 0 0 4px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}
.feedback-categories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding-top: 4px;
}
.feedback-categories label {
  font-size: 0.84rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 5px;
  transition: background 0.1s;
}
.feedback-categories label:hover { background: #f8fafc; }
.feedback-categories input { cursor: pointer; }

.feedback-context-preview {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background: #fafafa;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  word-break: break-all;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1280px) {
  .cockpit-main { grid-template-columns: 1fr 360px; }
  :root { --cockpit-edit-panel-width: 360px; }
}

@media (max-width: 1024px) {
  .cockpit-main { grid-template-columns: 1fr; }
  .cockpit-edit-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 500px;
  }
}

@media (max-width: 768px) {
  main { padding: var(--space-md); }
  .sheet-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .analysis-controls { flex-direction: column; align-items: stretch; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  header { padding: var(--space-sm) var(--space-md); }
  .file-info-bar { flex-direction: column; gap: var(--space-md); }
  .cockpit-facets { gap: 8px; }
  .cockpit-facet-group { width: 100%; }
}
