/* ==========================================================================
   DG Container List Inspector - Ultra-Modern Logistics Design System
   ========================================================================== */

:root {
  /* Color Palette - Maritime Dark Theme (Default) */
  --bg-main: #0a0f1d;
  --bg-card: rgba(18, 26, 47, 0.85);
  --bg-card-hover: rgba(24, 35, 62, 0.95);
  --bg-card-solid: #121a2f;
  --bg-subtle: rgba(255, 255, 255, 0.04);
  --bg-input: #0f1629;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --border-accent: rgba(56, 189, 248, 0.3);

  /* Primary Brand & Accents */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.35);
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-indigo: #6366f1;

  /* Typography Colors */
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-inverted: #0f172a;

  /* Table styling */
  --th-bg: #151f38;
  --th-text: #cbd5e1;
  --tr-stripe: rgba(255, 255, 255, 0.015);
  --tr-hover: rgba(56, 189, 248, 0.08);

  /* Shadows & Glassmorphism */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --card-blur: blur(16px);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
body.light-theme {
  --bg-main: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --bg-card-solid: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-subtle: #e2e8f0;
  --border-focus: #2563eb;
  --border-accent: rgba(37, 99, 235, 0.25);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --text-inverted: #f8fafc;

  --th-bg: #f1f5f9;
  --th-text: #334155;
  --tr-stripe: #f8fafc;
  --tr-hover: rgba(37, 99, 235, 0.05);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Ambient Background Lights */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
  transition: opacity 0.5s ease;
}

.glow-1 {
  width: 500px;
  height: 500px;
  top: -150px;
  right: -100px;
  background: radial-gradient(circle, #38bdf8, transparent 70%);
}

.glow-2 {
  width: 600px;
  height: 600px;
  bottom: -200px;
  left: -150px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
}

body.light-theme .ambient-glow {
  opacity: 0.15;
}

/* ==========================================================================
   Header Component
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-badge {
  position: relative;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1e3a8a, #0284c7);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.logo-pulse {
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 1.5px solid var(--accent-cyan);
  opacity: 0.6;
  animation: pulseGlow 2.5s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.08); opacity: 0.8; }
}

.header-title-group h1 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  display: inline-block;
  vertical-align: middle;
}

.title-with-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.header-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-stat-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 85px;
}

.header-stat-box.highlight {
  border-color: var(--border-accent);
  background: rgba(6, 182, 212, 0.08);
}

.stat-num {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-main);
}

.header-stat-box.highlight .stat-num {
  color: var(--accent-cyan);
}

.stat-lbl {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ==========================================================================
   Buttons & Badges
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #0284c7);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #0369a1);
  box-shadow: 0 6px 18px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-subtle);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-focus);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-sample {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-sample:hover {
  background: linear-gradient(135deg, #047857, #059669);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
}

.btn-danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--accent-rose);
}

.btn-danger-ghost:hover {
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.2);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-focus);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-accent {
  background: rgba(6, 182, 212, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-green {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.badge-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-rose {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(251, 113, 133, 0.3);
}

.badge-purple {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(192, 132, 252, 0.3);
}

.badge-tank {
  background: rgba(2, 132, 199, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.45);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  letter-spacing: 0.02em;
}

.badge-dv {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.25);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Main Layout & Upload Section
   ========================================================================== */

.app-main {
  max-width: 1720px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem 2rem;
  position: relative;
  z-index: 10;
}

.upload-section {
  margin-bottom: 2rem;
}

.drop-zone {
  background: var(--bg-card);
  backdrop-filter: var(--card-blur);
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2.2rem 2rem;
  text-align: center;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.drop-zone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  transform: scale(1.008);
  box-shadow: 0 0 30px var(--accent-cyan-glow);
}

.drop-zone-icon-wrapper {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  transition: var(--transition);
}

.drop-zone.dragover .drop-zone-icon-wrapper {
  transform: translateY(-4px) scale(1.1);
  color: #ffffff;
  background: var(--accent-cyan);
}

.drop-zone-icon {
  width: 32px;
  height: 32px;
}

.drop-zone-text h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.3rem;
}

.drop-zone-text p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.drop-zone-text code {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg-subtle);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  color: var(--accent-cyan);
}

.upload-btn-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  justify-content: center;
}

.drop-zone-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border-subtle);
  width: 100%;
  max-width: 800px;
}

.info-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.info-pill svg {
  color: var(--accent-cyan);
  flex-shrink: 0;
}

/* Processing Bar */
.processing-card {
  background: var(--bg-card);
  backdrop-filter: var(--card-blur);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.75rem;
  margin-top: 1rem;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.3s ease;
}

.processing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.processing-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #3b82f6);
  border-radius: 999px;
  transition: width 0.25s ease;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Global Controls Bar
   ========================================================================== */

.global-controls {
  background: var(--bg-card);
  backdrop-filter: var(--card-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1 1 280px;
  min-width: 250px;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 2.2rem 0.65rem 2.5rem;
  font-size: 0.88rem;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.search-input-wrapper input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.clear-search-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
}

.bay-filter-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.25rem;
}

.filter-chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.filter-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.range-row {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.range-row > .filter-label {
  align-self: center;
}

.range-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.range-input {
  width: 5.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.range-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.range-hint {
  align-self: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.range-hint strong {
  color: var(--text-main);
}

.sort-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.select-input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.select-input:focus {
  border-color: var(--border-focus);
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.action-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   File List Card Component
   ========================================================================== */

.file-lists-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.file-card {
  background: var(--bg-card);
  backdrop-filter: var(--card-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  animation: fadeIn 0.4s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* HERO TITLE: DATE MODIFIED */
.file-card-header {
  padding: 1.4rem 1.8rem;
  background: linear-gradient(180deg, rgba(30, 41, 69, 0.6) 0%, rgba(18, 26, 47, 0.4) 100%);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.file-hero-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.file-date-hero {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hero-calendar-icon {
  font-size: 1.4rem;
  color: var(--accent-cyan);
}

/* Primary Title of the List */
.file-date-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

body.light-theme .file-date-title {
  color: #0f172a;
}

.file-relative-time {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.file-meta-sub {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.file-name-chip {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  background: var(--bg-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.file-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* File Card Stats Bar */
.file-card-stats-bar {
  padding: 0.85rem 1.8rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.stats-badges-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.stat-pill.strong {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.3);
  color: #38bdf8;
}

.bay-distribution-pills {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.bay-pill {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.bay-pill.has-data {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.35);
  color: #60a5fa;
}

/* ==========================================================================
   High-Density Data Table
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  max-height: 650px;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.table-responsive::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.dg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
  white-space: nowrap;
}

.dg-table th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--th-bg);
  color: var(--th-text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 0.85rem;
  border-bottom: 2px solid var(--border-subtle);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.dg-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
  transition: background-color 0.15s ease;
}

.dg-table tbody tr:nth-child(even) {
  background-color: var(--tr-stripe);
}

.dg-table tbody tr:hover {
  background-color: var(--tr-hover);
}

/* Table Column Styles */
.col-idx {
  color: var(--text-dim);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.75rem;
  width: 35px;
  text-align: center;
}

.unit-cell {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
  color: #38bdf8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.unit-cell:hover {
  text-decoration: underline;
  color: #7dd3fc;
}

.copy-mini-btn {
  opacity: 0;
  font-size: 0.75rem;
  color: var(--text-dim);
  transition: opacity 0.15s;
}

.dg-table tr:hover .copy-mini-btn {
  opacity: 1;
}

.slot-badge {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  cursor: pointer;
}

.slot-badge:hover {
  background: rgba(56, 189, 248, 0.2);
}

/* Badges for Specific Fields */
.status-badge {
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.status-full {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.status-empty {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.move-badge {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
}

.move-export {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.move-import {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(165, 180, 252, 0.3);
}

.line-badge {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

/* Dangerous Goods (IMDG & UN) Badges */
.imdg-badge {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.imdg-flammable { /* Class 3 */
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.imdg-oxidizer { /* Class 5.1 */
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fde047;
}

.imdg-corrosive { /* Class 8 */
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #d8b4fe;
}

.imdg-toxic { /* Class 6 */
  background: rgba(236, 72, 153, 0.2);
  border: 1px solid rgba(236, 72, 153, 0.45);
  color: #f472b6;
}

.imdg-general {
  background: rgba(249, 115, 22, 0.2);
  border: 1px solid rgba(249, 115, 22, 0.45);
  color: #fdba74;
}

.un-badge {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  cursor: pointer;
}

.un-badge:hover {
  background: rgba(245, 158, 11, 0.22);
}

.empty-cell {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.75rem;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-card);
  backdrop-filter: var(--card-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  max-width: 600px;
  margin: 2rem auto;
  box-shadow: var(--shadow-sm);
}

.empty-icon-box {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.empty-state code {
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--accent-cyan);
}

/* ==========================================================================
   Modal Dialogs (Compare / Diff)
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem 1.75rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-title h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.share-card {
  max-width: 560px;
}

.share-intro,
.share-note {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.share-note {
  font-size: 0.8rem;
}

.share-quality {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.share-label {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.share-field-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.share-field {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  cursor: pointer;
  transition: var(--transition);
}

.share-field:hover {
  border-color: var(--border-accent);
}

.share-field input {
  margin-top: 0.2rem;
  accent-color: var(--primary);
}

.share-field span {
  display: flex;
  flex-direction: column;
  font-size: 0.86rem;
}

.share-field small {
  color: var(--text-dim);
  font-size: 0.74rem;
}

.share-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.share-spacer {
  flex: 1;
}

.compare-selectors {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--bg-subtle);
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.select-col {
  flex: 1 1 280px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.select-col label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.compare-arrow {
  font-size: 1.5rem;
  color: var(--accent-cyan);
}

.compare-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.summary-box {
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-box.green { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.25); }
.summary-box.red { background: rgba(244, 63, 94, 0.08); border-color: rgba(244, 63, 94, 0.25); }
.summary-box.yellow { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.25); }
.summary-box.gray { background: rgba(148, 163, 184, 0.08); border-color: rgba(148, 163, 184, 0.25); }

.summary-val {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
}

.summary-box.green .summary-val { color: #34d399; }
.summary-box.red .summary-val { color: #fb7185; }
.summary-box.yellow .summary-val { color: #fbbf24; }
.summary-box.gray .summary-val { color: #cbd5e1; }

.summary-lbl {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.compare-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.5rem;
  flex-wrap: wrap;
}

.compare-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.compare-tab.active {
  background: var(--primary);
  color: #ffffff;
}

.compare-table-wrapper {
  max-height: 450px;
  overflow-y: auto;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-accent);
  color: var(--text-main);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  pointer-events: auto;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(10px); }
}

/* ==========================================================================
   HAS-TOS 3D Yard Viewer & Timeline Slider Styles
   ========================================================================== */

.yard-3d-section {
  background: var(--bg-card);
  backdrop-filter: var(--card-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
  transition: var(--transition);
  animation: fadeIn 0.4s ease;
  position: relative;
}

.yard-3d-section:hover {
  border-color: var(--border-accent);
}

.yard-3d-header {
  padding: 1.25rem 1.75rem;
  background: linear-gradient(180deg, rgba(21, 31, 56, 0.7) 0%, rgba(15, 22, 41, 0.5) 100%);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.yard-3d-title-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.yard-badge-3d {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0284c7, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 14px var(--accent-cyan-glow);
}

.yard-3d-title-group h2 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

body.light-theme .yard-3d-title-group h2 {
  color: #0f172a;
}

.section-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.yard-3d-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.toolbar-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.toolbar-lbl {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.select-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.camera-btn-group {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.camera-btn-group .btn-icon {
  width: auto;
  height: auto;
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border: none;
  border-radius: 0;
  background: transparent;
}

.camera-btn-group .btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-cyan);
}

.camera-btn-group .btn-icon.active {
  background: var(--primary);
  color: #ffffff;
}

/* Export 3D Dropdown Menu */
.export-3d-dropdown-wrapper {
  position: relative;
}

.export-3d-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card-solid);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 0.5rem;
  min-width: 275px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  animation: slideDown 0.2s ease;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
}

.dropdown-item:hover {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  transform: translateX(3px);
}

.dropdown-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
}

.dropdown-text {
  display: flex;
  flex-direction: column;
}

.dropdown-text strong {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
}

.dropdown-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
  margin-top: 0.15rem;
}

/* ==========================================================================
   Timeline Date Slider Component
   ========================================================================== */

.timeline-slider-card {
  padding: 1.1rem 1.75rem;
  background: rgba(10, 15, 29, 0.75);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

body.light-theme .timeline-slider-card {
  background: #f1f5f9;
}

.timeline-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.timeline-active-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.timeline-cal-icon {
  font-size: 1.6rem;
  color: var(--accent-cyan);
}

.timeline-date-hero {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: -0.01em;
}

.timeline-file-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.timeline-track-wrapper {
  position: relative;
  width: 100%;
  padding: 0.5rem 0;
}

.timeline-range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1e293b, #334155);
  outline: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: var(--transition);
}

.timeline-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #38bdf8;
  border: 3px solid #ffffff;
  box-shadow: 0 0 12px var(--accent-cyan-glow), 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.timeline-range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #0284c7;
}

.timeline-range-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #38bdf8;
  border: 3px solid #ffffff;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
  cursor: pointer;
}

.slider-marks {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  padding: 0 10px;
  z-index: 1;
}

.slider-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.slider-mark.active {
  background: var(--accent-cyan);
  transform: scale(1.3);
}

.timeline-dates-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}

.timeline-chip {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-weight: 600;
  color: var(--text-muted);
}

/* ==========================================================================
   3D Viewport & Canvas
   ========================================================================== */

.viewport-3d-wrapper {
  position: relative;
  width: 100%;
  height: 580px;
  background: radial-gradient(circle at 50% 30%, #0d1527 0%, #050811 100%);
  overflow: hidden;
  transition: height 0.3s ease;
}

body.light-theme .viewport-3d-wrapper {
  background: radial-gradient(circle at 50% 30%, #e2e8f0 0%, #cbd5e1 100%);
}

/* Full screen: the 3D view on top, the DG segregation table below it */
.yard-stage.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
}
.yard-stage.fullscreen .viewport-3d-wrapper {
  flex: 1 1 auto;
  min-height: 45vh;
  height: auto !important;
  border-radius: 0;
}
.yard-stage.fullscreen .seg-panel {
  flex: 0 1 auto;
  max-height: 40vh;
  overflow: auto;
  padding-top: 10px;
}
.yard-stage.fullscreen .seg-list { max-height: none; }

.canvas-3d-container {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-3d-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  outline: none;
}

/* 3D Overlays */
.hud-overlay-top {
  position: absolute;
  top: 1rem;
  left: 1.25rem;
  right: 1.25rem;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 10;
}

.legend-pills {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(10px);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

body.light-theme .legend-pills {
  background: rgba(255, 255, 255, 0.85);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px currentColor;
}



/* 3D Tooltip */
.container-tooltip-3d {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  min-width: 230px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  transform: translate(15px, 15px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.tooltip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.5rem;
}

.tooltip-unit {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-cyan);
}

.tooltip-slot {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.15rem 0.4rem;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  border-radius: var(--radius-sm);
}

.tooltip-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
}

.tt-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--text-muted);
}

.tt-row strong {
  color: var(--text-main);
}

.tt-row.highlight-dg {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  color: #fca5a5;
}

.tt-row.highlight-dg strong {
  color: #f87171;
}

.tooltip-footer {
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  color: var(--text-dim);
  text-align: center;
  font-style: italic;
}



/* Helper Utilities */
.hidden {
  display: none !important;
}

/* ==========================================================================
   Print Stylesheet
   ========================================================================== */

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .ambient-glow,
  .app-header,
  .upload-section,
  .global-controls,
  .file-header-actions,
  .toast-container,
  .modal-overlay {
    display: none !important;
  }

  .app-main {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .file-card {
    box-shadow: none !important;
    border: 1px solid #000000 !important;
    margin-bottom: 2rem !important;
    page-break-after: always;
  }

  .file-card-header {
    background: #f1f5f9 !important;
    color: #000000 !important;
  }

  .file-date-title {
    color: #000000 !important;
    font-size: 1.2rem !important;
  }

  .table-responsive {
    max-height: none !important;
    overflow: visible !important;
  }

  .dg-table {
    font-size: 0.72rem !important;
  }

  .dg-table th {
    background: #e2e8f0 !important;
    color: #000000 !important;
  }

  .dg-table td {
    color: #000000 !important;
    border-color: #cbd5e1 !important;
  }
}

/* ==========================================================================
   DG SEGREGATION CHECK (IMDG Code)
   ========================================================================== */
.seg-panel {
  border-top: 1px solid var(--border-subtle);
  padding: 16px 20px 18px;
  background: var(--bg-card);
}
.seg-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.seg-title { flex: 1; min-width: 220px; }
.seg-title h3 { margin: 0; font-size: 1rem; font-family: 'Plus Jakarta Sans', sans-serif; }
.seg-sub { font-size: 0.75rem; color: var(--text-muted); }
.seg-summary {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}
.seg-summary.ok { color: #34d399; border-color: rgba(52, 211, 153, 0.35); background: rgba(16, 185, 129, 0.12); }
.seg-summary.bad { color: #fb7185; border-color: rgba(244, 63, 94, 0.4); background: rgba(244, 63, 94, 0.12); }
.seg-toggle { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.seg-list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}
.seg-empty { font-size: 0.85rem; color: var(--text-muted); padding: 6px 2px; }
.seg-actions { padding: 0 12px 8px; display: flex; gap: 8px; }
.seg-suggest-btn, .seg-link {
  font: inherit; font-size: 0.75rem; font-weight: 600; cursor: pointer;
  border-radius: 999px; padding: 4px 12px;
  border: 1px solid rgba(34, 197, 94, 0.45); background: rgba(34, 197, 94, 0.12); color: #4ade80;
}
.seg-suggest-btn:hover { background: rgba(34, 197, 94, 0.22); }
.seg-detail.suggest-open .seg-suggest-btn { background: #16a34a; color: #fff; }
.seg-link { border-color: var(--border-subtle); background: transparent; color: var(--text-muted); }
.seg-link:hover { color: var(--text-main); border-color: var(--border-accent); }
.seg-suggest:empty { display: none; }
.seg-suggest { margin: 0 12px 10px; padding: 10px 12px; border-radius: var(--radius-md); background: rgba(34, 197, 94, 0.06); border: 1px dashed rgba(34, 197, 94, 0.35); font-size: 0.78rem; display: grid; gap: 7px; }
.seg-sg-head code, .seg-plan-list code, .seg-sg-remark code { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.76rem; }
.seg-risk { display: inline-block; margin-left: 6px; font-size: 0.7rem; color: var(--text-muted); }
.seg-sg-sub { color: var(--text-muted); font-size: 0.74rem; }
.seg-sg-warn { color: #fbbf24; font-size: 0.74rem; }
.seg-sg-remark { color: #fbbf24; font-size: 0.76rem; line-height: 1.6; }
.seg-sg-remark select { margin: 0 4px; }
.seg-slots { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-slot {
  font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 6px 10px; border-radius: 10px; border: 1px solid rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.1); color: var(--text-main);
}
.seg-slot b { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.78rem; color: #4ade80; }
.seg-slot small { font-size: 0.66rem; color: var(--text-muted); }
.seg-slot:hover, .seg-slot.active { background: rgba(34, 197, 94, 0.25); border-color: #22c55e; }
.seg-sg-foot { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-plan { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.06); display: grid; gap: 8px; font-size: 0.8rem; }
.seg-plan.hidden { display: none; }
.seg-plan-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg-plan-head span { color: var(--text-muted); flex: 1; }
.seg-plan-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.seg-plan-list b { font-family: 'Plus Jakarta Sans', sans-serif; color: #4ade80; }
.seg-plan-list small { display: block; color: var(--text-muted); font-size: 0.7rem; }
.move-preview-hud {
  position: absolute; top: 3.6rem; left: 50%; transform: translateX(-50%); z-index: 25;
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; border-radius: 999px;
  background: rgba(15, 23, 42, 0.82); border: 1px solid rgba(34, 197, 94, 0.55); color: #e2e8f0; font-size: 0.78rem;
  backdrop-filter: blur(10px); max-width: calc(100% - 24px);
}
.move-preview-hud b { color: #4ade80; }
.move-preview-hud.hidden { display: none; }
.seg-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.75rem; color: var(--text-muted); }
.seg-legend small { color: var(--text-dim); }
.seg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.seg-dot-class { background: #f97316; box-shadow: 0 0 8px #f97316; }
.seg-dot-un { background: #a855f7; box-shadow: 0 0 8px #a855f7; }
.seg-basis { margin-top: 10px; font-size: 0.75rem; color: var(--text-muted); }
.seg-basis summary { cursor: pointer; }
.seg-basis p { margin: 6px 0 0; line-height: 1.5; }
.seg-extra { margin-top: 8px; font-size: 0.75rem; color: var(--text-dim); }
@media (max-width: 640px) {
  .seg-panel { padding: 14px 16px; }
  .move-preview-hud { flex-wrap: wrap; border-radius: 14px; justify-content: center; text-align: center; }
}

/* ==========================================================================
   3D VIEW NAVIGATION (rotate / pan mode, move pad, zoom, full screen)
   ========================================================================== */
.view-nav { position: absolute; z-index: 30; display: flex; gap: 8px; align-items: flex-end; user-select: none; -webkit-user-select: none; touch-action: none; }
.vn-col { display: flex; flex-direction: column; gap: 2px; padding: 3px; border-radius: 12px; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); }
.vn-col .vn-btn { width: 30px; height: 30px; }
.vn-btn { display: flex; align-items: center; justify-content: center; flex-direction: column; border: 1px solid transparent; border-radius: 9px; background: transparent; color: #e2e8f0; cursor: pointer; padding: 0; transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease; }
.vn-btn:hover { background: rgba(56, 189, 248, 0.22); border-color: rgba(56, 189, 248, 0.5); }
.vn-btn:active { transform: scale(0.94); }
.vn-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.vn-mode svg { width: 14px; height: 14px; }
.vn-mode .ic-pan, .vn-mode.active .ic-rotate { display: none; }
.vn-mode.active .ic-pan { display: block; }
.vn-mode.active { background: linear-gradient(135deg, #0ea5e9, #6366f1); border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.nav-mode-lbl { font-size: 8px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.vn-full .ic-exit, .is-fullscreen .vn-full .ic-enter { display: none; }
.is-fullscreen .vn-full .ic-exit { display: block; }
.viewport-3d-wrapper .view-nav { right: 0.8rem; bottom: 0.8rem; }
.yard-stage.fullscreen .view-nav { bottom: 0.8rem; }
@media (max-width: 640px) {
  .viewport-3d-wrapper .view-nav { right: 0.6rem; bottom: 0.6rem; transform: scale(0.9); transform-origin: bottom right; }
}

/* ==========================================================================
   APP SHELL — desktop-app layout (menu rail, top bar, full-size 3D workspace,
   DG dock, Timeline drawer, Units page, status bar)
   ========================================================================== */
body.app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  background: var(--bg-main);
}
.app-shell [hidden] { display: none !important; }

/* ---- Menu rail ---- */
.app-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 8px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(10, 15, 29, 0.98));
  border-right: 1px solid var(--border-subtle);
  z-index: 60;
  min-height: 0;
}
body.light-theme .app-rail { background: linear-gradient(180deg, #ffffff, #f1f5f9); }
.rail-logo svg { width: 44px; height: 44px; display: block; filter: drop-shadow(0 6px 14px rgba(56, 189, 248, 0.35)); }
.rail-nav { display: flex; flex-direction: column; gap: 6px; width: 100%; flex: 1; margin-top: 8px; }
.rail-foot { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.rail-btn {
  position: relative;
  width: 100%;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 2px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.rail-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.rail-lbl { font-size: 10.5px; font-weight: 700; letter-spacing: 0.01em; line-height: 1.1; text-align: center; }
.rail-btn:hover { background: var(--bg-subtle); color: var(--text-main); }
.rail-btn.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.9), rgba(99, 102, 241, 0.9));
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.28);
}
.rail-btn.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #38bdf8;
}
.rail-btn[data-toggle="seg"].active { background: rgba(249, 115, 22, 0.16); color: #fdba74; box-shadow: none; border-color: rgba(249, 115, 22, 0.35); }
.rail-btn[data-toggle="seg"].active::before { background: #f97316; }
.rail-badge {
  position: absolute;
  top: 5px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-main);
}
.rail-theme .theme-icon { font-size: 18px; }
.app-rail .export-3d-dropdown-wrapper { position: relative; width: 100%; }
.app-rail .export-3d-dropdown { position: absolute; left: calc(100% + 12px); top: 0; right: auto; z-index: 80; }

/* ---- Column: top bar / workspace / status bar ---- */
.app-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; height: 100dvh; }
.app-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  min-height: 58px;
  background: var(--bg-card);
  backdrop-filter: var(--card-blur);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 50;
  flex-wrap: wrap;
}
.tb-brand { display: flex; flex-direction: column; line-height: 1.05; margin-right: 4px; }
.tb-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tb-sub { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); }
.tb-open { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tb-open svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.tb-controls { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; flex-wrap: wrap; }
.app-shell .tb-controls .range-row { padding: 0; margin: 0; border: 0; align-items: center; gap: 8px; flex-wrap: nowrap; }
.app-shell .tb-controls .range-field { flex-direction: row; align-items: center; gap: 6px; font-size: 0.66rem; }
.app-shell .tb-controls .range-field .select-input, .app-shell .tb-controls .range-input { height: 34px; padding-top: 0; padding-bottom: 0; }
.app-shell .tb-controls .range-input { width: 70px; }
.app-shell .tb-controls .range-hint { display: none; }
.app-shell .tb-controls .search-input-wrapper { flex: 1; min-width: 200px; max-width: 360px; }
.app-shell .tb-controls .search-input-wrapper input { height: 36px; padding-top: 0; padding-bottom: 0; }
.view-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 26;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.view-toolbar .select-input { height: 32px; padding-top: 0; padding-bottom: 0; max-width: 180px; }
.view-toolbar .camera-btn-group { display: flex; gap: 3px; }
.view-toolbar .btn { height: 32px; }
.app-shell .tb-controls .range-row > .filter-label { display: none; }
.app-shell .tb-controls .range-row { padding: 4px 6px 4px 12px; border-radius: 12px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); }
.app-shell .tb-controls .range-row::before { content: 'RANGE'; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.14em; color: var(--text-dim); margin-right: 2px; }
.app-shell #rangeFullBlockBtn { white-space: nowrap; height: 30px; }
.app-workspace { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.app-statusbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 28px;
  padding: 0 14px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  white-space: nowrap;
  overflow: hidden;
}
.sb-item { display: inline-flex; align-items: center; }
.sb-item strong { color: var(--text-main); }
.sb-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 8px #22c55e; margin-right: 6px; }
.sb-spacer { flex: 1; }
.sb-muted { color: var(--text-dim); }
body:not(.has-data) .app-statusbar .sb-item:nth-child(n+3) { visibility: hidden; }

/* ---- Workspace: 3D stage + DG dock ---- */
.app-shell .yard-3d-section {
  position: absolute;
  inset: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  backdrop-filter: none;
  display: flex;
  flex-direction: column;
}
.app-shell .yard-3d-section.hidden { display: none !important; }
.app-shell .yard-stage:not(.fullscreen) { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.app-shell .yard-stage:not(.fullscreen) .viewport-3d-wrapper { flex: 1 1 auto; min-height: 0; height: auto; border-radius: 0; }
.app-shell .yard-stage:not(.fullscreen) .seg-panel {
  flex: 0 1 auto;
  max-height: 38%;
  overflow: auto;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
}
.app-shell .yard-stage:not(.fullscreen) .seg-list { max-height: none; }
.app-shell .yard-stage.seg-collapsed .seg-panel { display: none; }

/* ---- Welcome (no file yet) ---- */
.app-shell .empty-state.welcome {
  position: absolute;
  inset: 0;
  max-width: none;
  margin: 0;
  padding: 24px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.12), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.14), transparent 45%),
    var(--bg-main);
  display: grid;
  place-items: center;
  box-shadow: none;
}
.app-shell .empty-state.welcome.hidden { display: none !important; }
.welcome-card { width: min(620px, 100%); display: grid; gap: 18px; }
.welcome-brand { display: grid; justify-items: center; gap: 4px; }
.welcome-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 900;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
}
.welcome-sub { color: var(--text-muted); font-size: 0.85rem; font-weight: 600; text-align: center; }
.app-shell .welcome .drop-zone { padding: 2.4rem 1.5rem; }
.link-btn { background: none; border: 0; color: var(--text-muted); font: inherit; font-size: 0.82rem; cursor: pointer; }
.link-btn:hover { color: var(--text-main); }
.link-btn strong { color: #38bdf8; }

/* ---- Timeline drawer ---- */
.side-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: min(430px, calc(100% - 24px));
  z-index: 45;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--bg-card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: panelIn 0.18s ease;
}
@keyframes panelIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.panel-head h2 { margin: 0; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1.15rem; }
.panel-head p { margin: 2px 0 0; font-size: 0.78rem; color: var(--text-muted); }
.panel-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.panel-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}
.panel-close:hover { background: #ef4444; border-color: #ef4444; color: #fff; }
.panel-body { flex: 1; overflow: auto; padding: 14px 18px 18px; display: grid; gap: 14px; align-content: start; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-actions label { cursor: pointer; }
.panel-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-danger { justify-content: flex-end; padding-top: 6px; border-top: 1px solid var(--border-subtle); }
.side-panel .timeline-slider-card { padding: 14px; border-radius: 14px; border: 1px solid var(--border-subtle); }
.side-panel .timeline-header-row { flex-direction: column; align-items: stretch; gap: 10px; }
.side-panel .timeline-playback-controls { flex-wrap: wrap; }
.side-panel .sort-wrapper { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Units page ---- */
.page-panel {
  position: absolute;
  inset: 0;
  z-index: 46;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  animation: panelIn 0.18s ease;
}
.page-panel .panel-body { padding: 16px 20px 24px; }
.page-panel .bay-filter-group { display: flex; gap: 6px; flex-wrap: wrap; }
.page-panel .file-lists-container { margin: 0; }

/* ---- Small screens: rail becomes a bottom tab bar ---- */
@media (max-width: 760px) {
  body.app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .app-col { height: auto; min-height: 0; grid-row: 1; }
  .app-rail {
    grid-row: 2;
    flex-direction: row;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--border-subtle);
    gap: 2px;
  }
  .rail-logo { display: none; }
  .rail-nav { flex-direction: row; margin: 0; gap: 2px; }
  .rail-foot { width: auto; }
  .rail-btn { min-height: 52px; padding: 6px 2px; border-radius: 12px; }
  .rail-btn svg { width: 20px; height: 20px; }
  .rail-lbl { font-size: 9.5px; }
  .rail-btn.active::before { display: none; }
  .app-rail .export-3d-dropdown { left: auto; right: 0; top: auto; bottom: calc(100% + 10px); }
  .app-topbar { gap: 8px; padding: 8px 10px; }
  .tb-sub { display: none; }
  .tb-controls { order: 3; flex-basis: 100%; }
  .app-shell .tb-controls .range-row { flex-wrap: wrap; }
  .app-shell .tb-controls .search-input-wrapper { max-width: none; flex-basis: 100%; }
  .view-toolbar { top: 8px; right: 8px; }
  .view-toolbar .camera-btn-group, .view-toolbar .tb-wire { display: none; }
  .view-toolbar .select-input { max-width: 130px; }
  .app-statusbar { display: none; }
  .app-shell .yard-stage:not(.fullscreen) .seg-panel { max-height: 42%; }
  .side-panel { top: 8px; right: 8px; left: 8px; bottom: 8px; width: auto; }
}
.app-shell .hud-overlay-top { right: 590px; }
.app-shell .move-preview-hud { top: 62px; }
@media (max-width: 1100px) {
  .app-shell .hud-overlay-top { right: 1.25rem; top: 58px; }
  .app-shell .move-preview-hud { top: 104px; }
}
.page-panel .panel-body, .side-panel .panel-body { grid-template-columns: minmax(0, 1fr); }
.page-panel .file-card { max-width: 100%; }
.view-toolbar .btn, .view-toolbar .btn-outline { color: #e2e8f0; border-color: rgba(255, 255, 255, 0.16); }
.view-toolbar .btn.active { color: #fff; }
@media (max-width: 760px) {
  .app-shell .tb-controls .range-row { flex-wrap: nowrap; padding: 4px 6px; gap: 5px; width: 100%; }
  .app-shell .tb-controls .range-row::before, .app-shell .tb-controls .range-field > span { display: none; }
  .app-shell .tb-controls .range-input { width: 56px; }
  .app-shell .tb-controls .range-field .select-input { max-width: 110px; }
  .app-shell #rangeFullBlockBtn { padding: 0 8px; font-size: 0.72rem; }
  .app-shell .tb-controls { gap: 6px; }
  .app-shell .tb-controls .search-input-wrapper input { height: 34px; }
}

/* Printing from the app shell: only the unit lists */
@media print {
  body.app-shell { display: block; height: auto; overflow: visible; }
  .app-shell .app-rail, .app-shell .app-topbar, .app-shell .app-statusbar,
  .app-shell #yard3dSection, .app-shell #emptyState, .app-shell #panelTimeline,
  .app-shell .panel-head-actions, .app-shell #panelUnits .panel-row { display: none !important; }
  .app-shell .app-col, .app-shell .app-workspace { display: block; height: auto; overflow: visible; }
  .app-shell #panelUnits { display: block !important; position: static; background: #fff; }
  .app-shell #panelUnits .panel-body { overflow: visible; }
}

/* ---- Upcoming DG drawer ---- */
.side-panel-wide { width: min(500px, calc(100% - 24px)); }
.rail-badge-green { background: #16a34a; }
.up-file { font-size: 0.75rem; color: var(--text-muted); align-self: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.up-controls { gap: 8px; }
.app-shell .up-block { flex-direction: row; align-items: center; gap: 6px; }
.up-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.up-summary:empty { display: none; }
.up-pill { font-size: 0.74rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-subtle); background: var(--bg-subtle); }
.up-pill.ok { color: #4ade80; border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.1); }
.up-pill.bad { color: #fbbf24; border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.1); }
.up-list { display: grid; gap: 8px; }
.up-empty { font-size: 0.8rem; color: var(--text-muted); line-height: 1.55; padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--border-subtle); }
.up-item { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border-subtle); border-left: 4px solid #22c55e; background: var(--bg-subtle); display: grid; gap: 6px; }
.up-item.none { border-left-color: #f59e0b; }
.up-item.active { background: rgba(34, 197, 94, 0.08); border-color: #22c55e; }
.up-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.up-head code { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 0.82rem; }
.up-order { font-size: 0.66rem; font-weight: 800; color: var(--text-dim); }
.up-meta { font-size: 0.72rem; color: var(--text-muted); }
.up-dg { font-size: 0.66rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: rgba(239, 68, 68, 0.18); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); }
.up-slots { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.up-alt-lbl { font-size: 0.68rem; color: var(--text-dim); }
.up-slot.alt { opacity: 0.8; }
.up-slot.alt b { color: #86efac; font-size: 0.72rem; }

/* ---- AI Assistant drawer ---- */
.rail-ai svg { stroke: #c4b5fd; }
.rail-ai.active svg { stroke: #fff; }
.asst-panel { display: flex; flex-direction: column; }
.asst-settings { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 8px 18px; border-bottom: 1px solid var(--border-subtle); }
.asst-code { display: flex; align-items: center; gap: 8px; font-size: 0.72rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.asst-code input { width: 140px; height: 30px; }
.asst-notice { margin: 10px 18px 0; padding: 8px 12px; border-radius: 10px; font-size: 0.78rem; color: #fbbf24; background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.35); }
.asst-messages { flex: 1; min-height: 0; overflow: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.asst-msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; font-size: 0.84rem; line-height: 1.55; overflow-wrap: anywhere; }
.asst-msg p { margin: 0 0 6px; }
.asst-msg p:last-child { margin-bottom: 0; }
.asst-msg ul, .asst-msg ol { margin: 4px 0 6px; padding-left: 20px; }
.asst-msg li { margin: 2px 0; }
.asst-msg code { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.78rem; padding: 1px 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); }
.asst-msg .asst-h { font-weight: 800; margin-top: 4px; }
.asst-user { align-self: flex-end; background: linear-gradient(135deg, #0ea5e9, #6366f1); color: #fff; border-bottom-right-radius: 4px; }
.asst-bot { align-self: flex-start; background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-bottom-left-radius: 4px; }
.asst-thinking { color: var(--text-muted); animation: asstPulse 1s ease-in-out infinite alternate; }
@keyframes asstPulse { from { opacity: 0.45; } to { opacity: 1; } }
.asst-error { border-color: rgba(239, 68, 68, 0.45); color: #fca5a5; }
.asst-step { align-self: flex-start; font-size: 0.7rem; color: var(--text-dim); padding: 0 6px; }
.asst-unit { font: inherit; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.78rem; font-weight: 700; cursor: pointer; padding: 0 6px; border-radius: 6px; border: 1px solid rgba(56, 189, 248, 0.45); background: rgba(56, 189, 248, 0.12); color: #7dd3fc; }
.asst-unit:hover { background: rgba(56, 189, 248, 0.28); }
.asst-suggest { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 18px 8px; }
.asst-chip { font: inherit; font-size: 0.72rem; cursor: pointer; padding: 5px 10px; border-radius: 999px; border: 1px solid rgba(139, 92, 246, 0.4); background: rgba(139, 92, 246, 0.1); color: var(--text-main); }
.asst-chip:hover { background: rgba(139, 92, 246, 0.25); }
.asst-disclaimer { margin: 0; padding: 6px 18px 0; font-size: 0.68rem; color: var(--text-dim); border-top: 1px solid var(--border-subtle); }
.asst-form { display: flex; gap: 8px; padding: 6px 18px 16px; }
.asst-form textarea { flex: 1; resize: none; font: inherit; font-size: 0.85rem; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--bg-input); color: var(--text-main); }
.asst-form textarea:focus { outline: none; border-color: var(--border-focus); }
.asst-form .btn { align-self: stretch; min-width: 48px; font-size: 1.1rem; }
/* ---- Blocks with DG conflicts (whole file) ---- */
.seg-blocks { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.seg-blocks-lbl { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); margin-right: 2px; }
.seg-block-chip { font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; border: 1px solid var(--border-subtle); background: var(--bg-subtle); color: var(--text-main); font-size: 0.74rem; }
.seg-block-chip b { font-family: 'Plus Jakarta Sans', sans-serif; }
.seg-block-chip span { min-width: 20px; padding: 1px 7px; border-radius: 999px; font-weight: 800; font-size: 0.7rem; text-align: center; background: #f97316; color: #0f172a; }
.seg-block-chip.lvl-3 span { background: #ef4444; color: #fff; }
.seg-block-chip.lvl-4 span { background: #d946ef; color: #fff; }
.seg-block-chip.lvl-1 span { background: #facc15; }
.seg-block-chip.current { border-color: #38bdf8; box-shadow: 0 0 0 1px #38bdf8 inset; }
.seg-block-chip:hover { background: var(--tr-hover); }
.seg-blocks-note { font-size: 0.72rem; color: #fbbf24; }

/* ---- Settings page ---- */
.settings-body { max-width: 980px; }
.set-card { padding: 16px 18px; border-radius: 16px; border: 1px solid var(--border-subtle); background: var(--bg-card); display: grid; gap: 12px; }
.set-card h3 { margin: 0; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1rem; }
.set-help { margin: 0; font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }
.set-field { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 0.85rem; }
.set-field > span small { display: block; color: var(--text-dim); font-size: 0.72rem; }
.set-field input { width: 90px; }
.set-classes { display: flex; gap: 6px; flex-wrap: wrap; }
.set-class { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-subtle); background: var(--bg-subtle); cursor: pointer; }
.set-class:has(input:checked) { border-color: #ef4444; background: rgba(239, 68, 68, 0.14); color: #fca5a5; }
.set-table-wrap { overflow-x: auto; }
.set-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.set-table th { text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); padding: 6px 8px; border-bottom: 1px solid var(--border-subtle); }
.set-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-subtle); }
.set-table td:first-child { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; }
.set-table input[type="number"] { width: 72px; }
.set-table input[type="text"] { width: 110px; }
.set-table .muted { color: var(--text-dim); font-size: 0.74rem; }
.set-del { background: none; border: 0; color: var(--text-dim); cursor: pointer; font-size: 1rem; }
.set-del:hover { color: #ef4444; }
.set-add { display: flex; gap: 8px; }
.set-add input { width: 150px; }
.set-info ul { margin: 0; padding-left: 18px; font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; }
.set-status { font-size: 0.75rem; color: #4ade80; min-height: 1em; }
/* Terminal rule findings in the DG panel */
.seg-rules { margin-top: 8px; padding: 8px 12px; border-radius: 12px; border: 1px solid rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.07); font-size: 0.78rem; }
.seg-rules summary { cursor: pointer; font-weight: 700; color: #fbbf24; }
.seg-rules ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.seg-rules .rule-unit { font: inherit; font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 0.76rem; background: none; border: 0; color: #7dd3fc; cursor: pointer; padding: 0; }
.set-class input { width: auto; height: auto; margin: 0; accent-color: #ef4444; }
.set-table input[type="checkbox"] { width: auto; height: auto; accent-color: #38bdf8; }
.seg-quality { border-color: rgba(148, 163, 184, 0.35); background: rgba(148, 163, 184, 0.07); }
.seg-quality summary { color: var(--text-main); }
.dq-types { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.dq-type { font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); color: var(--text-muted); }
.dq-type b { color: var(--text-main); }
.seg-quality li.dq-high::marker { color: #ef4444; }
.seg-quality li.dq-medium::marker { color: #f59e0b; }
.seg-quality li.dq-low::marker { color: #94a3b8; }

/* ==========================================================================
   2026 REFRESH — design tokens and chrome for the whole app
   (deep-navy glass, sky → indigo → violet accent, softer radii, spring motion)
   ========================================================================== */
:root {
  --bg-main: #070a14;
  --bg-card: rgba(12, 17, 32, 0.78);
  --bg-card-hover: rgba(18, 25, 46, 0.92);
  --bg-card-solid: #0c1120;
  --bg-subtle: rgba(148, 163, 184, 0.07);
  --bg-input: rgba(255, 255, 255, 0.04);
  --border-subtle: rgba(148, 163, 184, 0.13);
  --border-accent: rgba(56, 189, 248, 0.35);
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-glow: rgba(56, 189, 248, 0.35);
  --grad-accent: linear-gradient(135deg, #38bdf8 0%, #6366f1 55%, #a855f7 100%);
  --text-main: #eef2f8;
  --text-muted: #9aa8bd;
  --text-dim: #66748b;
  --th-bg: #0f1628;
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
  --radius-md: 12px;
  --radius-lg: 18px;
  --ease-spring: cubic-bezier(0.2, 0.85, 0.25, 1);
}
body.light-theme {
  --bg-main: #f3f6fb;
  --bg-card: rgba(255, 255, 255, 0.82);
  --bg-card-solid: #ffffff;
  --bg-subtle: rgba(15, 23, 42, 0.04);
  --bg-input: #ffffff;
  --border-subtle: rgba(15, 23, 42, 0.09);
  --primary: #0284c7;
  --text-main: #0b1220;
  --text-muted: #475569;
  --text-dim: #8392a7;
  --shadow-lg: 0 30px 60px -24px rgba(15, 23, 42, 0.25);
}
body.app-shell {
  background:
    radial-gradient(1100px 620px at 105% -10%, rgba(99, 102, 241, 0.13), transparent 60%),
    radial-gradient(900px 520px at -10% 110%, rgba(14, 165, 233, 0.1), transparent 60%),
    var(--bg-main);
}
::selection { background: rgba(56, 189, 248, 0.35); }
.app-shell ::-webkit-scrollbar { width: 10px; height: 10px; }
.app-shell ::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.22); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
.app-shell ::-webkit-scrollbar-thumb:hover { background-color: rgba(148, 163, 184, 0.4); }
.app-shell ::-webkit-scrollbar-track { background: transparent; }

/* Rail: dark glass with a glowing active pill */
.app-rail {
  background: linear-gradient(180deg, rgba(10, 14, 28, 0.86), rgba(6, 9, 18, 0.92));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid rgba(148, 163, 184, 0.1);
}
body.light-theme .app-rail { background: rgba(255, 255, 255, 0.8); }
.rail-btn { transition: background 0.25s ease, color 0.25s ease, transform 0.35s var(--ease-spring), box-shadow 0.3s ease; }
.rail-btn:hover { transform: translateY(-1px); }
.rail-btn:active { transform: scale(0.96); }
.rail-btn.active {
  background: var(--grad-accent);
  box-shadow: 0 10px 26px -8px rgba(99, 102, 241, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.rail-btn.active::before { background: linear-gradient(180deg, #38bdf8, #a855f7); box-shadow: 0 0 12px #38bdf8; }
.rail-btn.active svg { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25)); }

/* Top bar, status bar */
.app-topbar { background: rgba(8, 12, 24, 0.66); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); }
body.light-theme .app-topbar { background: rgba(255, 255, 255, 0.72); }
.tb-title { background: var(--grad-accent); -webkit-background-clip: text; background-clip: text; }
.app-statusbar { background: rgba(8, 12, 24, 0.7); }
body.light-theme .app-statusbar { background: rgba(255, 255, 255, 0.75); }
body[data-panel="home"] .app-topbar, body[data-panel="home"] .app-statusbar { display: none; }

/* Buttons & inputs */
.btn { border-radius: 11px; transition: transform 0.3s var(--ease-spring), box-shadow 0.25s ease, background 0.2s ease, border-color 0.2s ease, filter 0.2s ease; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--grad-accent);
  border: 0;
  color: #fff;
  box-shadow: 0 8px 22px -10px rgba(99, 102, 241, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn-primary:hover { background: var(--grad-accent); filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 14px 30px -12px rgba(99, 102, 241, 0.9); }
.btn-outline:hover { border-color: var(--border-accent); background: rgba(56, 189, 248, 0.08); }
.select-input, .range-input, .search-input-wrapper input { border-radius: 11px; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.select-input:focus, .range-input:focus, .search-input-wrapper input:focus { box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.15); }
.filter-chip { border-radius: 999px; transition: all 0.25s var(--ease-spring); }

/* Drawers & pages: glass with a spring entrance */
.side-panel {
  background: rgba(10, 14, 28, 0.8);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 22px;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: panelIn2 0.5s var(--ease-spring);
}
body.light-theme .side-panel { background: rgba(255, 255, 255, 0.86); box-shadow: 0 40px 80px -30px rgba(15, 23, 42, 0.3); }
@keyframes panelIn2 { from { opacity: 0; transform: translateX(28px) scale(0.98); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
.page-panel { animation: pageIn 0.5s var(--ease-spring); }
@keyframes pageIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.panel-head h2 { font-weight: 800; letter-spacing: -0.01em; }
.seg-panel { background: rgba(8, 12, 24, 0.82); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
body.light-theme .seg-panel { background: rgba(255, 255, 255, 0.86); }
.view-toolbar, .view-nav { border-radius: 16px; }
.modal-card { border-radius: 22px; }
.toast { border-radius: 14px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }

/* Assistant drawer */
.asst-msg { animation: msgIn 0.45s var(--ease-spring); border-radius: 16px; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.asst-user { background: var(--grad-accent); box-shadow: 0 10px 24px -14px rgba(99, 102, 241, 0.9); }
.asst-bot { background: rgba(148, 163, 184, 0.07); }
.asst-step { animation: msgIn 0.35s var(--ease-spring); }
.asst-notice { color: #7dd3fc; background: rgba(56, 189, 248, 0.08); border-color: rgba(56, 189, 248, 0.3); }
body.light-theme .asst-notice { color: #0369a1; }
.asst-form textarea { border-radius: 14px; }

/* ==========================================================================
   HOME HERO — greeting, AI chat bar, DG conflict briefing (js/hero.js)
   ========================================================================== */
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

.hero {
  --a1: #38bdf8; --a2: #22d3ee; --a3: #a78bfa; --h-bg: #061320;
  --h-text: #f5f7fb;
  --h-muted: rgba(226, 232, 240, 0.74);
  --h-dim: rgba(203, 213, 225, 0.52);
  --h-glass: rgba(9, 13, 26, 0.56);
  --h-glass-strong: rgba(8, 11, 22, 0.8);
  --h-tile: rgba(255, 255, 255, 0.035);
  --h-line: rgba(255, 255, 255, 0.09);
  --h-warn: #fdba74;
  position: absolute;
  inset: 0;
  z-index: 47;
  overflow: hidden;
  isolation: isolate;
  color: var(--h-text);
  background: var(--h-bg);
  transition: background 1.6s ease;
}
.hero[data-period="morning"] { --a1: #ffb36b; --a2: #ff6f91; --a3: #7cc4ff; --h-bg: #140f1f; }
.hero[data-period="afternoon"] { --a1: #38bdf8; --a2: #22d3ee; --a3: #a78bfa; --h-bg: #061320; }
.hero[data-period="evening"] { --a1: #f472b6; --a2: #a855f7; --a3: #fb923c; --h-bg: #130a22; }
.hero[data-period="night"] { --a1: #818cf8; --a2: #22d3ee; --a3: #c084fc; --h-bg: #05070f; }
body.light-theme .hero, .hero.is-day {
  --h-text: #0b1220;
  --h-muted: #3b4a61;
  --h-dim: #74839a;
  --h-glass: rgba(255, 255, 255, 0.6);
  --h-glass-strong: rgba(255, 255, 255, 0.88);
  --h-tile: rgba(255, 255, 255, 0.6);
  --h-line: rgba(15, 23, 42, 0.09);
  --h-warn: #c2410c;
}
body.light-theme .hero[data-period="morning"], .hero.is-day[data-period="morning"] { --a1: #f59e0b; --a2: #f43f5e; --a3: #0ea5e9; --h-bg: #fbf0e8; }
body.light-theme .hero[data-period="afternoon"], .hero.is-day[data-period="afternoon"] { --a1: #0284c7; --a2: #06b6d4; --a3: #7c3aed; --h-bg: #e8f2fb; }
body.light-theme .hero[data-period="evening"], .hero.is-day[data-period="evening"] { --a1: #db2777; --a2: #9333ea; --a3: #ea580c; --h-bg: #f3ebf8; }
body.light-theme .hero[data-period="night"], .hero.is-day[data-period="night"] { --a1: #4f46e5; --a2: #0891b2; --a3: #9333ea; --h-bg: #e6e8f5; }

.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; transition: transform 0.6s var(--ease-spring), filter 0.6s ease; }
.hero.no-webgl .hero-canvas { display: none; }

/* Aurora: three drifting light blobs with mouse parallax */
.hero-aurora {
  position: absolute;
  inset: -15%;
  z-index: 1;
  pointer-events: none;
  filter: blur(70px);
  opacity: 0.42;
  mix-blend-mode: screen;
  translate: calc((var(--px, 0.5) - 0.5) * -40px) calc((var(--py, 0.5) - 0.5) * -30px);
  transition: translate 1.2s var(--ease-spring);
}
body.light-theme .hero-aurora, .hero.is-day .hero-aurora { mix-blend-mode: multiply; opacity: 0.22; }
.hero-aurora i { position: absolute; width: 52vmax; height: 52vmax; border-radius: 50%; animation: aurora 22s ease-in-out infinite alternate; }
.hero-aurora i:nth-child(1) { left: -6%; top: -18%; background: radial-gradient(circle, var(--a1), transparent 62%); }
.hero-aurora i:nth-child(2) { right: -10%; top: -6%; background: radial-gradient(circle, var(--a2), transparent 62%); animation-delay: -7s; animation-duration: 26s; }
.hero-aurora i:nth-child(3) { left: 30%; bottom: -30%; background: radial-gradient(circle, var(--a3), transparent 62%); animation-delay: -13s; opacity: 0.7; }
@keyframes aurora {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(6vmax, 4vmax, 0) scale(1.15); }
  100% { transform: translate3d(-5vmax, 2vmax, 0) scale(0.92); }
}
/* Readability veil behind the text + bottom fade + film grain */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 52% at 50% 26%, color-mix(in srgb, var(--h-bg) 72%, transparent), transparent 72%),
    linear-gradient(180deg, color-mix(in srgb, var(--h-bg) 40%, transparent) 0%, transparent 30%, transparent 60%, color-mix(in srgb, var(--h-bg) 85%, transparent) 100%);
}
.hero-grain {
  position: absolute;
  inset: -50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
body.light-theme .hero-grain, .hero.is-day .hero-grain { opacity: 0.05; }
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

.hero-scroll {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  transition: opacity 0.38s ease, transform 0.38s ease, filter 0.38s ease;
}
.hero-inner { max-width: 1180px; margin: 0 auto; padding: clamp(36px, 9vh, 104px) clamp(16px, 4vw, 48px) 72px; }

/* Leaving Home: content zooms past, the hero yard clears into the 3D yard it mirrors */
.hero.is-leaving .hero-scroll { opacity: 0; transform: scale(1.04); filter: blur(10px); }
.hero.is-leaving .hero-canvas { transform: none; filter: none; }

/* Meta chips */
.hero-meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--h-muted);
  background: var(--h-glass);
  border: 1px solid var(--h-line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.hero-live { color: var(--h-text); font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 600; letter-spacing: 0.04em; }
.hero-live i { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; animation: livePulse 2s infinite; }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); } 70% { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.hero-demo { color: var(--h-text); border-color: color-mix(in srgb, var(--a1) 45%, transparent); }
.hero-demo b { font-size: 0.64rem; letter-spacing: 0.14em; padding: 2px 7px; border-radius: 6px; color: #0b0f19; background: linear-gradient(135deg, var(--a1), var(--a2)); }
.hero-chip-link { color: var(--a1); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Greeting: letters build on (AE text animator), the name wipes in with a living gradient */
.hero-greet {
  margin: 22px 0 12px;
  text-align: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: clamp(2.5rem, 6.6vw, 5.8rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  perspective: 900px;
  text-wrap: balance;
}
.hero-greet .w, .hg-tail { display: inline-block; white-space: nowrap; }
.hero-greet .ch { display: inline-block; opacity: 0; transform: translateY(0.5em) rotateX(-80deg); filter: blur(12px); transform-origin: 50% 100%; }
.hero-greet.play .ch { animation: chIn 0.95s var(--ease-spring) forwards; animation-delay: calc(var(--i) * 32ms + 140ms); }
@keyframes chIn { to { opacity: 1; transform: none; filter: blur(0); } }
.hg-comma, .hg-bang { opacity: 0; }
.hero-greet.play .hg-comma, .hero-greet.play .hg-bang { animation: fadeIn 0.6s ease forwards; animation-delay: var(--name-delay, 600ms); }
.hg-name {
  position: relative;
  display: inline-block;
  padding: 0 0.06em 0.08em;
  background: linear-gradient(100deg, var(--a1), var(--a2) 35%, var(--a3) 65%, var(--a1));
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  cursor: text;
  outline: none;
  clip-path: inset(0 100% 0 0);
}
.hero-greet.play .hg-name { animation: wipeIn 1.1s cubic-bezier(0.7, 0, 0.2, 1) var(--name-delay, 600ms) forwards, shimmer 9s linear infinite; }
.hg-name::after {
  content: '';
  position: absolute;
  left: 0.06em;
  right: 0.06em;
  bottom: 0.02em;
  height: 0.06em;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--a1), var(--a2), var(--a3));
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0.8;
}
.hero-greet.play .hg-name::after { animation: lineIn 0.9s var(--ease-spring) calc(var(--name-delay, 600ms) + 650ms) forwards; }
.hg-name:hover::after { opacity: 1; }
.hg-name[contenteditable="true"] { clip-path: none; animation: shimmer 9s linear infinite; caret-color: var(--a1); }
.hg-name[contenteditable="true"]::after { transform: scaleX(1); opacity: 1; animation: none; }
@keyframes wipeIn { from { clip-path: inset(0 100% 0 0); filter: blur(8px); } to { clip-path: inset(0 0 0 0); filter: blur(0); } }
@keyframes lineIn { to { transform: scaleX(1); } }
@keyframes shimmer { from { background-position: 0% 50%; } to { background-position: 250% 50%; } }
@keyframes fadeIn { to { opacity: 1; } }

.hero-lede { max-width: 700px; margin: 0 auto 30px; text-align: center; font-size: clamp(1rem, 1.45vw, 1.18rem); line-height: 1.6; color: var(--h-muted); text-wrap: balance; }
.hero-lede b { color: var(--h-text); }
.hero-lede .lede-alert { color: var(--h-warn); }

/* Entrance choreography (replayed each time Home opens) */
.hero.enter .hero-meta { animation: heroUp 0.9s var(--ease-spring) 0.05s both; }
.hero.enter .hero-lede { animation: heroUp 0.9s var(--ease-spring) 0.95s both; }
.hero.enter .hero-ask { animation: heroUp 1s var(--ease-spring) 1.1s both; }
.hero.enter .brief { animation: heroUp 1.1s var(--ease-spring) 1.45s both; }
.hero.enter .sg-chip { animation: heroUp 0.8s var(--ease-spring) both; animation-delay: calc(1.3s + var(--i) * 80ms); }
@keyframes heroUp { from { opacity: 0; translate: 0 26px; filter: blur(8px); } to { opacity: 1; translate: 0 0; filter: blur(0); } }

/* AI chat bar: rotating conic ring + glow */
.hero-ask { position: relative; max-width: 780px; margin: 0 auto; border-radius: 24px; }
.ask-ring {
  position: absolute;
  inset: -1.5px;
  border-radius: 25.5px;
  background: conic-gradient(from var(--ang), var(--a1), var(--a2), var(--a3), transparent 62%, var(--a1));
  animation: ringSpin 6s linear infinite;
}
.ask-ring::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  filter: blur(26px);
  opacity: 0.4;
  transition: opacity 0.5s ease;
}
.hero-ask:focus-within .ask-ring::after, .hero-ask:hover .ask-ring::after { opacity: 0.85; }
.hero-ask:focus-within .ask-ring { animation-duration: 2.6s; }
@keyframes ringSpin { to { --ang: 360deg; } }
.ask-body {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 68px;
  padding: 0 10px 0 20px;
  border-radius: 23px;
  overflow: hidden;
  background: var(--h-glass-strong);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}
.ask-body::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.22) 50%, transparent 70%);
  transform: translateX(-120%);
}
.hero-ask.launch .ask-body::after { transition: transform 0.55s ease; transform: translateX(120%); }
.hero-ask.launch .ask-send svg { animation: sendOff 0.45s ease-in forwards; }
@keyframes sendOff { 60% { transform: translateX(18px); opacity: 0; } 61% { transform: translateX(-18px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.hero-ask.shake { animation: shake 0.4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.ask-spark { display: grid; place-items: center; color: var(--a1); }
.ask-spark svg { width: 24px; height: 24px; fill: currentColor; animation: twinkle 3.2s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(0.82) rotate(18deg); opacity: 0.7; } }
.ask-field { position: relative; flex: 1; min-width: 0; height: 100%; }
.ask-field input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--h-text);
  font: inherit;
  font-size: 1.06rem;
  font-weight: 500;
}
.ask-ph {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--h-dim);
  font-size: 1.06rem;
  transition: opacity 0.2s ease;
}
.ask-ph::after { content: ''; display: inline-block; width: 2px; height: 1.1em; margin-left: 2px; vertical-align: -0.18em; background: var(--a1); animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.hero-ask.has-text .ask-ph { opacity: 0; }
.ask-kbd {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 7px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.78rem;
  color: var(--h-dim);
  border: 1px solid var(--h-line);
  background: var(--h-tile);
  transition: opacity 0.2s ease;
}
.hero-ask:focus-within .ask-kbd { opacity: 0; }
.ask-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  color: #0b0f19;
  background: linear-gradient(135deg, var(--a1), var(--a2));
  box-shadow: 0 10px 26px -8px var(--a2), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.35s var(--ease-spring), box-shadow 0.3s ease;
}
.ask-send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s var(--ease-spring); }
.ask-send:hover { transform: scale(1.07); box-shadow: 0 14px 32px -8px var(--a2); }
.ask-send:hover svg { transform: translateX(2px); }
.ask-send:active { transform: scale(0.94); }
.ask-fly {
  position: fixed;
  z-index: 9999;
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  background: var(--grad-accent);
  box-shadow: 0 18px 40px -12px rgba(99, 102, 241, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transform-origin: right top;
}

.hero-suggest { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; max-width: 860px; margin: 16px auto 0; }
.sg-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--h-line);
  background: var(--h-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--h-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, transform 0.35s var(--ease-spring), background 0.25s ease;
}
.sg-chip:hover { color: var(--h-text); border-color: color-mix(in srgb, var(--a1) 60%, transparent); background: color-mix(in srgb, var(--a1) 12%, var(--h-glass)); transform: translateY(-2px); }

/* Shared hero buttons */
.hbtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 12px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.35s var(--ease-spring), box-shadow 0.3s ease, background 0.25s ease, border-color 0.25s ease;
}
.hbtn-solid { border: 0; color: #0b0f19; background: linear-gradient(135deg, var(--a1), var(--a2)); box-shadow: 0 10px 24px -10px var(--a2); }
.hbtn-solid:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -10px var(--a2); }
.hbtn-solid span { transition: transform 0.3s var(--ease-spring); }
.hbtn-solid:hover span { transform: translateX(3px); }
.hbtn-ghost { color: var(--h-text); border: 1px solid var(--h-line); background: var(--h-tile); }
.hbtn-ghost:hover { border-color: color-mix(in srgb, var(--a1) 50%, transparent); transform: translateY(-1px); }

/* Briefing card */
.brief {
  position: relative;
  margin-top: clamp(44px, 9vh, 92px);
  padding: clamp(18px, 2.4vw, 28px);
  border-radius: 28px;
  background: var(--h-glass);
  border: 1px solid var(--h-line);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  box-shadow: 0 50px 100px -50px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
body.light-theme .brief, .hero.is-day .brief { box-shadow: 0 50px 100px -50px rgba(15, 23, 42, 0.35); }
.brief::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--a1), var(--a2), var(--a3), transparent);
}
.brief-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brief-eyebrow { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.22em; text-transform: uppercase; color: var(--a1); }
.brief-head h2 { margin: 4px 0 2px; font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: clamp(1.4rem, 2.4vw, 1.9rem); letter-spacing: -0.02em; }
.brief-sub { margin: 0; font-size: 0.8rem; color: var(--h-dim); }
.brief-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.brief-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0 16px;
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--h-text);
  border: 1px solid var(--h-line);
  background: var(--h-tile);
}
.brief-banner code { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.8em; padding: 1px 6px; border-radius: 6px; background: var(--h-tile); border: 1px solid var(--h-line); }
.brief-banner.is-critical { background: linear-gradient(90deg, rgba(239, 68, 68, 0.16), rgba(239, 68, 68, 0.04)); border-color: rgba(239, 68, 68, 0.38); }
.brief-banner.is-warn { background: linear-gradient(90deg, rgba(245, 158, 11, 0.16), rgba(245, 158, 11, 0.04)); border-color: rgba(245, 158, 11, 0.38); }
.brief-banner.is-ok { background: linear-gradient(90deg, rgba(34, 197, 94, 0.16), rgba(34, 197, 94, 0.04)); border-color: rgba(34, 197, 94, 0.38); }
.banner-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.banner-pulse { position: relative; flex: none; width: 12px; height: 12px; border-radius: 50%; background: #ef4444; }
.is-warn .banner-pulse { background: #f59e0b; }
.banner-pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite; }
@keyframes ping { 75%, 100% { transform: scale(3); opacity: 0; } }
.banner-ok { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #22c55e; color: #fff; font-weight: 800; }

/* KPI tiles with ring meters */
.brief-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.brief-kpis:empty, .brief-sev:empty, .brief-blocks:empty, .brief-cards:empty { display: none; }
.kpi {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--h-tile);
  border: 1px solid var(--h-line);
}
.kpi::before { content: ''; position: absolute; width: 140px; height: 140px; right: -50px; top: -60px; border-radius: 50%; background: radial-gradient(circle, var(--accent), transparent 70%); opacity: 0.2; }
.kpi-ring { flex: none; width: 54px; height: 54px; transform: rotate(-90deg); }
.kpi-track { fill: none; stroke: var(--h-line); stroke-width: 5; }
.kpi-meter { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-dasharray: var(--len); stroke-dashoffset: var(--len); filter: drop-shadow(0 0 6px var(--accent)); transition: stroke-dashoffset 1.6s var(--ease-spring) 0.25s; }
.kpi.in .kpi-meter { stroke-dashoffset: var(--off); }
.kpi-text { position: relative; display: grid; min-width: 0; }
.kpi-val { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 2.1rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi-lbl { margin-top: 4px; font-size: 0.74rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--h-muted); }
.kpi-sub { font-size: 0.72rem; color: var(--h-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Severity mix */
.brief-sev { margin-top: 18px; }
.sev-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--h-dim); }
.sev-bar { position: relative; display: flex; gap: 3px; height: 12px; border-radius: 99px; overflow: hidden; background: var(--h-line); }
.sev-seg { width: 0; border-radius: 99px; background: var(--c); box-shadow: 0 0 16px var(--c); transition: width 1.3s var(--ease-spring); transition-delay: calc(0.3s + var(--d)); }
.sev-bar.in .sev-seg { width: var(--w); }
.sev-bar::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent); transform: translateX(-100%); animation: sweep 3.2s ease-in-out 2s infinite; }
@keyframes sweep { 60%, 100% { transform: translateX(100%); } }
.sev-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 0.76rem; color: var(--h-muted); }
.sev-legend span { display: inline-flex; align-items: center; gap: 7px; }
.sev-legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--c); box-shadow: 0 0 8px var(--c); }
.sev-legend b { color: var(--h-text); }
.sev-legend .is-zero { opacity: 0.4; }

/* Blocks */
.brief-blocks { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 18px 0 16px; }
.blk-lbl { margin-right: 4px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--h-dim); }
.blk {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--h-line);
  background: var(--h-tile);
  color: var(--h-text);
  font: inherit;
  font-size: 0.8rem;
  overflow: hidden;
  cursor: default;
}
.blk::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c); box-shadow: 0 0 10px var(--c); }
.blk b { font-family: 'Plus Jakarta Sans', sans-serif; }
.blk span { color: var(--c); font-weight: 700; }
.blk small { color: var(--h-dim); }
.blk.has { cursor: pointer; transition: transform 0.35s var(--ease-spring), border-color 0.25s ease, opacity 0.8s ease, translate 0.8s var(--ease-spring); }
.blk.has:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 55%, transparent); }

/* Conflict cards: tilt + cursor spotlight */
.brief-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.cc {
  position: relative;
  padding: 16px 16px 14px 18px;
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  outline: none;
  background: var(--h-tile);
  border: 1px solid var(--h-line);
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: opacity 0.8s ease, translate 0.8s var(--ease-spring), transform 0.4s var(--ease-spring), border-color 0.3s ease, box-shadow 0.3s ease;
  transition-delay: calc(var(--i, 0) * 70ms), calc(var(--i, 0) * 70ms), 0s, 0s, 0s;
}
.cc::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--lv); box-shadow: 0 0 18px var(--lv); }
.cc-spot { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s ease; background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--lv) 22%, transparent), transparent 62%); }
.cc:hover, .cc:focus-visible { border-color: color-mix(in srgb, var(--lv) 55%, transparent); box-shadow: 0 28px 50px -26px color-mix(in srgb, var(--lv) 75%, transparent); }
.cc:hover .cc-spot, .cc:focus-visible .cc-spot { opacity: 1; }
.cc-head { position: relative; display: flex; align-items: center; gap: 10px; }
.cc-lvl {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 34px;
  padding: 0 8px;
  border-radius: 11px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--lv);
  background: color-mix(in srgb, var(--lv) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--lv) 45%, transparent);
}
.cc.is-critical .cc-lvl::after { content: ''; position: absolute; inset: -1px; border-radius: inherit; border: 1px solid var(--lv); animation: lvlPing 2s ease-out infinite; }
@keyframes lvlPing { from { transform: scale(1); opacity: 0.9; } to { transform: scale(1.5); opacity: 0; } }
.cc-term { display: grid; font-weight: 700; font-size: 0.92rem; line-height: 1.25; min-width: 0; }
.cc-term small { font-size: 0.7rem; font-weight: 600; color: var(--h-dim); }
.cc-block { margin-left: auto; padding: 4px 9px; border-radius: 8px; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.74rem; font-weight: 600; color: var(--h-muted); border: 1px solid var(--h-line); }
.cc-pair { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 8px; margin: 16px 0 14px; }
.cc-unit { display: grid; justify-items: center; gap: 8px; min-width: 0; text-align: center; }
.cc-unit > div { display: grid; min-width: 0; max-width: 100%; }
.cc-unit b { font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-unit small { font-size: 0.7rem; color: var(--h-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: 'Plus Jakarta Sans', sans-serif; }
.hz {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 4px;
  border-radius: 5px;
  transform: rotate(45deg);
  background: var(--hz-bg);
  border: 2px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25), 0 6px 14px -6px rgba(0, 0, 0, 0.6);
}
.hz b { transform: rotate(-45deg); padding: 1px 3px; border-radius: 4px; font-size: 0.58rem; font-weight: 900; line-height: 1.2; color: #fff; background: rgba(10, 12, 20, 0.78); }
.cc-link { display: grid; justify-items: center; gap: 6px; width: 66px; padding-top: 14px; }
.cc-link i { display: block; width: 100%; height: 2px; background: repeating-linear-gradient(90deg, var(--lv) 0 6px, transparent 6px 11px); background-size: 22px 2px; animation: dash 0.9s linear infinite; filter: drop-shadow(0 0 4px var(--lv)); }
.cc-link span { font-size: 0.64rem; color: var(--h-dim); white-space: nowrap; }
@keyframes dash { to { background-position: 22px 0; } }
.cc-foot { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cc-ref { padding: 3px 8px; border-radius: 7px; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.7rem; color: var(--h-muted); background: var(--h-tile); border: 1px solid var(--h-line); }
.cc-go { font-size: 0.78rem; font-weight: 700; color: var(--lv); opacity: 0.7; transform: translateX(-4px); transition: opacity 0.3s ease, transform 0.35s var(--ease-spring); }
.cc:hover .cc-go, .cc:focus-visible .cc-go { opacity: 1; transform: none; }
.brief-more { display: flex; justify-content: center; margin-top: 16px; }
.brief-more:empty { display: none; }
.brief-basis { margin: 20px 0 0; font-size: 0.72rem; text-align: center; color: var(--h-dim); }

/* Scroll reveal */
.hero .reveal { opacity: 0; translate: 0 18px; transition: opacity 0.8s ease, translate 0.8s var(--ease-spring); }
.hero .reveal.in { opacity: 1; translate: 0 0; }
.hero .cc.reveal { transition: opacity 0.8s ease, translate 0.8s var(--ease-spring), transform 0.4s var(--ease-spring), border-color 0.3s ease, box-shadow 0.3s ease; transition-delay: calc(var(--i, 0) * 70ms), calc(var(--i, 0) * 70ms), 0s, 0s, 0s; }

@media (max-width: 980px) {
  .brief-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .hero-inner { padding-top: 28px; padding-bottom: 40px; }
  .hero-greet { margin-top: 16px; }
  .ask-body { height: 58px; padding-left: 14px; }
  .ask-send { width: 44px; height: 44px; border-radius: 13px; }
  .ask-kbd { display: none; }
  .ask-field input, .ask-ph { font-size: 0.96rem; }
  .brief { border-radius: 22px; }
  .brief-actions { width: 100%; }
  .brief-actions .hbtn { flex: 1; justify-content: center; }
  .brief-cards { grid-template-columns: minmax(0, 1fr); }
  .kpi { padding: 12px; gap: 10px; }
  .kpi-ring { width: 42px; height: 42px; }
  .kpi-val { font-size: 1.6rem; }
  #heroDate { display: none; }
  .rail-nav { overflow-x: auto; scrollbar-width: none; }
  .rail-nav::-webkit-scrollbar { display: none; }
  .rail-nav .rail-btn { flex: 0 0 64px; }
  .rail-foot { flex-direction: row; }
  .rail-foot .rail-btn { flex: 0 0 52px; }
}
@media (prefers-reduced-motion: reduce) {
  .hero *, .hero *::before, .hero *::after { animation: none !important; transition: none !important; }
  .hero .ch, .hero .reveal, .hg-comma, .hg-bang { opacity: 1 !important; transform: none !important; translate: none !important; filter: none !important; }
  .hg-name { clip-path: none !important; }
  .hg-name::after { transform: scaleX(1); }
  .kpi-meter { stroke-dashoffset: var(--off); }
  .sev-seg { width: var(--w); }
}
body.light-theme .hero .hbtn-solid, body.light-theme .ask-send, body.light-theme .hero-demo b, .hero.is-day .hbtn-solid, .hero.is-day .ask-send, .hero.is-day .hero-demo b { color: #fff; }

/* ==========================================================================
   MENU DRAWER — the rail becomes a drawer behind a three-line button (js/shell.js)
   ========================================================================== */
body.app-shell { grid-template-columns: minmax(0, 1fr); }
.menu-toggle {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 130;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 13px;
  border: 1px solid var(--border-subtle);
  background: rgba(10, 14, 28, 0.55);
  color: var(--text-main);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 8px 24px -14px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.35s var(--ease-spring);
}
body.light-theme .menu-toggle { background: rgba(255, 255, 255, 0.72); }
.menu-toggle:hover { border-color: var(--border-accent); }
.menu-toggle:active { transform: scale(0.94); }
.menu-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.mt-lines { position: relative; display: block; width: 18px; height: 12px; }
.mt-lines i {
  position: absolute;
  left: 0;
  height: 1.6px;
  border-radius: 2px;
  background: currentColor;
  transition: top 0.4s var(--ease-spring), transform 0.45s var(--ease-spring), width 0.35s var(--ease-spring), opacity 0.2s ease;
}
.mt-lines i:nth-child(1) { top: 0; width: 18px; }
.mt-lines i:nth-child(2) { top: 5.2px; width: 11px; }
.mt-lines i:nth-child(3) { top: 10.4px; width: 15px; }
.menu-toggle:hover .mt-lines i { width: 18px; }
body.menu-open .mt-lines i:nth-child(1) { top: 5.2px; width: 18px; transform: rotate(45deg); }
body.menu-open .mt-lines i:nth-child(2) { opacity: 0; transform: translateX(-6px); }
body.menu-open .mt-lines i:nth-child(3) { top: 5.2px; width: 18px; transform: rotate(-45deg); }
.mt-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 2px var(--bg-main), 0 0 8px #ef4444; }
body.menu-open .mt-dot { opacity: 0; }
.menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(2, 6, 16, 0.38);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
body.light-theme .menu-scrim { background: rgba(15, 23, 42, 0.16); }
body.menu-open .menu-scrim { opacity: 1; pointer-events: auto; }

.app-shell .app-rail {
  position: fixed;
  top: 8px;
  left: 8px;
  bottom: 8px;
  width: 256px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 10px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(10, 14, 28, 0.88);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.75);
  transform: translateX(calc(-100% - 16px));
  opacity: 0;
  visibility: hidden;
  transition: transform 0.5s var(--ease-spring), opacity 0.3s ease, visibility 0s linear 0.5s;
}
body.light-theme.app-shell .app-rail { background: rgba(255, 255, 255, 0.92); box-shadow: 0 40px 80px -30px rgba(15, 23, 42, 0.3); }
body.menu-open .app-rail { transform: none; opacity: 1; visibility: visible; transition: transform 0.5s var(--ease-spring), opacity 0.3s ease, visibility 0s; }
.app-shell .rail-logo { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 4px 10px 52px; border-bottom: 1px solid var(--border-subtle); }
.app-shell .rail-logo svg { width: 28px; height: 28px; filter: none; }
.rail-brand { display: grid; line-height: 1.15; }
.rail-brand b { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 0.95rem; letter-spacing: 0.05em; background: var(--grad-accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rail-brand small { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); }
.app-shell .rail-nav { flex: 1; flex-direction: column; gap: 2px; margin: 4px 0 0; overflow-y: auto; overflow-x: visible; }
.app-shell .rail-foot { flex-direction: column; gap: 2px; width: 100%; padding-top: 8px; border-top: 1px solid var(--border-subtle); }
.app-shell .rail-btn,
.app-shell .rail-nav .rail-btn,
.app-shell .rail-foot .rail-btn {
  flex: none;
  flex-direction: row;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 11px;
}
.app-shell .rail-btn svg { width: 18px; height: 18px; flex: none; }
.app-shell .rail-lbl { font-size: 0.84rem; font-weight: 600; letter-spacing: 0; text-align: left; }
.app-shell .rail-btn:hover { transform: translateX(2px); }
.app-shell .rail-btn.active::before { display: none; }
.app-shell .rail-btn.active { box-shadow: 0 8px 20px -12px rgba(99, 102, 241, 0.8); }
.app-shell .rail-badge { position: static; margin-left: auto; box-shadow: none; }
.app-shell .rail-theme .theme-icon { width: 18px; font-size: 15px; text-align: center; }
.app-shell .app-rail .export-3d-dropdown-wrapper { width: 100%; }
.app-shell .app-rail .export-3d-dropdown { position: static; top: auto; right: auto; bottom: auto; left: auto; min-width: 0; margin: 4px 0 6px; box-shadow: none; }
body.menu-open .rail-nav > *, body.menu-open .rail-foot > * { animation: menuItem 0.5s var(--ease-spring) both; animation-delay: calc(var(--k, 0) * 22ms + 60ms); }
@keyframes menuItem { from { opacity: 0; translate: -14px 0; } to { opacity: 1; translate: 0 0; } }
.app-shell .app-topbar { padding-left: 66px; }
@media (max-width: 760px) {
  body.app-shell { grid-template-rows: minmax(0, 1fr); }
  .app-shell .app-rail { grid-row: auto; width: min(290px, calc(100vw - 16px)); padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(148, 163, 184, 0.14); }
  .app-shell .rail-logo { display: flex; }
  .app-shell .rail-nav { overflow-x: visible; }
  .app-shell .rail-btn, .app-shell .rail-nav .rail-btn, .app-shell .rail-foot .rail-btn { min-height: 44px; }
  .app-shell .rail-lbl { font-size: 0.9rem; }
  .app-shell .app-topbar { padding-left: 62px; }
}
@media print { .menu-toggle, .menu-scrim { display: none !important; } }

/* ==========================================================================
   HOME — sleeker scale + fog over the 3D background (text stays readable)
   ========================================================================== */
.hero-inner { max-width: 1060px; padding-top: clamp(64px, 11vh, 112px); }
.hero-chip { height: 28px; padding: 0 12px; font-size: 0.72rem; }
.hero-greet { margin: 18px 0 8px; font-size: clamp(1.9rem, 4vw, 3.3rem); font-weight: 700; letter-spacing: -0.03em; }
.hero-lede { max-width: 600px; margin-bottom: 24px; font-size: clamp(0.9rem, 1.1vw, 1rem); }
.hero-ask { max-width: 660px; border-radius: 18px; }
.ask-ring { inset: -1px; border-radius: 19px; }
.ask-ring::after { opacity: 0.2; filter: blur(20px); }
.hero-ask:focus-within .ask-ring::after, .hero-ask:hover .ask-ring::after { opacity: 0.5; }
.ask-body { height: 54px; gap: 10px; padding: 0 7px 0 16px; border-radius: 17px; }
.ask-spark svg { width: 18px; height: 18px; }
.ask-field input, .ask-ph { font-size: 0.94rem; }
.ask-kbd { min-width: 22px; height: 22px; font-size: 0.7rem; }
.ask-send { width: 40px; height: 40px; border-radius: 12px; box-shadow: 0 6px 18px -8px var(--a2); }
.ask-send svg { width: 18px; height: 18px; }
.hero-suggest { margin-top: 12px; gap: 6px; }
.sg-chip { padding: 6px 12px; font-size: 0.74rem; font-weight: 500; }
.hbtn { height: 34px; padding: 0 13px; border-radius: 10px; font-size: 0.78rem; }
.brief { margin-top: clamp(36px, 7vh, 68px); padding: clamp(16px, 2vw, 22px); border-radius: 22px; }
.brief-eyebrow { font-size: 0.6rem; }
.brief-head h2 { font-size: clamp(1.1rem, 1.6vw, 1.3rem); font-weight: 700; }
.brief-sub { font-size: 0.74rem; }
.brief-banner { margin: 16px 0 12px; padding: 10px 14px; border-radius: 13px; font-size: 0.82rem; }
.banner-pulse { width: 9px; height: 9px; }
.brief-kpis { gap: 10px; }
.kpi { gap: 12px; padding: 12px 14px; border-radius: 15px; }
.kpi-ring { width: 40px; height: 40px; }
.kpi-val { font-size: 1.5rem; font-weight: 700; }
.kpi-lbl { font-size: 0.64rem; }
.kpi-sub { font-size: 0.68rem; }
.brief-sev { margin-top: 14px; }
.sev-bar { height: 7px; }
.sev-head, .blk-lbl { font-size: 0.6rem; }
.sev-legend { font-size: 0.7rem; }
.brief-blocks { margin: 14px 0 12px; }
.blk { padding: 6px 10px 6px 12px; border-radius: 10px; font-size: 0.74rem; }
.brief-cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.cc { padding: 13px 14px 12px 16px; border-radius: 16px; }
.cc-lvl { min-width: 34px; height: 28px; border-radius: 9px; font-size: 0.8rem; }
.cc-term { font-size: 0.82rem; }
.cc-term small, .cc-unit small { font-size: 0.66rem; }
.cc-block { font-size: 0.68rem; padding: 3px 8px; }
.cc-unit b { font-size: 0.74rem; }
.cc-pair { margin: 12px 0 10px; }
.hz { width: 24px; height: 24px; }
.cc-ref, .cc-go { font-size: 0.68rem; }
.brief-basis { font-size: 0.66rem; }

/* Fog: the 3D yard sits behind a soft blur and drifting mist; it clears while a conflict card is hovered */
.hero-canvas { filter: blur(3px) saturate(0.85); transform: scale(1.03); transition: filter 0.8s ease, transform 0.6s var(--ease-spring); }
.hero.peek .hero-canvas { filter: blur(0) saturate(1); }
.hero.is-leaving .hero-canvas { transform: none; filter: none; }
.hero-aurora { opacity: 0.28; }
.hero { --h-fog: rgba(150, 165, 190, 0.16); }
body.light-theme .hero, .hero.is-day { --h-fog: rgba(255, 255, 255, 0.7); }
.hero::before {
  background:
    radial-gradient(ellipse 75% 55% at 50% 28%, color-mix(in srgb, var(--h-bg) 82%, transparent), transparent 75%),
    linear-gradient(180deg, color-mix(in srgb, var(--h-bg) 55%, transparent) 0%, color-mix(in srgb, var(--h-bg) 20%, transparent) 40%, color-mix(in srgb, var(--h-bg) 35%, transparent) 70%, color-mix(in srgb, var(--h-bg) 90%, transparent) 100%);
  transition: opacity 0.8s ease;
}
.hero.peek::before { opacity: 0.55; }
.hero-fog { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; transition: opacity 0.8s ease; }
.hero.peek .hero-fog { opacity: 0.35; }
.hero-fog i {
  position: absolute;
  left: -30%;
  width: 160%;
  height: 50%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, var(--h-fog), transparent 68%);
  filter: blur(30px);
  animation: fogDrift 38s ease-in-out infinite alternate;
}
.hero-fog i:nth-child(1) { top: 2%; }
.hero-fog i:nth-child(2) { top: 38%; animation-duration: 52s; animation-delay: -18s; opacity: 0.8; }
.hero-fog i:nth-child(3) { top: 70%; animation-duration: 46s; animation-delay: -9s; opacity: 0.6; }
@keyframes fogDrift { from { transform: translateX(-8%) scaleY(0.9); } to { transform: translateX(8%) scaleY(1.1); } }
@media (max-width: 760px) {
  .hero-inner { padding-top: 64px; }
  .ask-body { height: 50px; }
  .kpi-val { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-canvas { transform: none; }
}

/* Home → 3D yard: the veils clear while the hero yard flies onto the yard's camera (js/hero.js leaveHome) */
.hero.is-leaving::before, .hero.is-leaving::after, .hero.is-leaving .hero-aurora, .hero.is-leaving .hero-grain, .hero.is-leaving .hero-fog { opacity: 0; transition: opacity 0.7s ease; }
.hero.is-leaving .hero-scroll { transition-duration: 0.5s; translate: 0 -18px; }
.hero.is-leaving .hero-canvas { transition: filter 0.7s ease, transform 0.7s var(--ease-spring); }

/* Flight HUD: destination, progress, skip hint */
.hero-warp {
  position: absolute;
  left: 50%;
  bottom: clamp(28px, 9vh, 84px);
  z-index: 5;
  display: grid;
  justify-items: center;
  gap: 6px;
  width: min(420px, calc(100% - 32px));
  padding: 14px 18px 12px;
  border: 1px solid var(--h-line);
  border-radius: 16px;
  background: var(--h-glass);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  color: var(--h-text);
  text-align: center;
  opacity: 0;
  translate: -50% 16px;
  pointer-events: none;
  transition: opacity 0.35s ease, translate 0.5s var(--ease-spring);
}
.hero-warp.on { opacity: 1; translate: -50% 0; }
.hero.is-exiting .hero-warp { opacity: 0; translate: -50% -10px; }
.hw-kicker { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--a1); }
.hw-title { font-size: 0.95rem; font-family: 'Plus Jakarta Sans', sans-serif; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-bar { position: relative; width: 100%; height: 3px; border-radius: 3px; background: var(--h-line); overflow: hidden; }
.hw-bar i { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, var(--a1), var(--a2)); transform: scaleX(0); }
.hero-warp.on .hw-bar i { animation: hwFill var(--dur, 1.2s) cubic-bezier(0.65, 0, 0.35, 1) forwards; }
@keyframes hwFill { to { transform: scaleX(1); } }
.hw-skip { font-size: 0.68rem; color: var(--h-dim); }

/* Hand-off: the yard is already showing the same picture underneath; the hero fades off it */
.app-shell .hero.is-exiting[hidden] { display: block !important; }
/* (.app-shell outranks .hero.enter, which also animates the hero) */
.app-shell .hero.is-exiting { position: fixed; inset: 0; pointer-events: none; animation: heroHandOff 0.6s ease forwards; }
@keyframes heroHandOff { to { opacity: 0; } }

/* …while the yard's chrome slides in around it */
body.yard-enter .app-topbar { animation: chromeDrop 0.6s var(--ease-spring) both; }
body.yard-enter .app-statusbar { animation: chromeRise 0.6s var(--ease-spring) 0.08s both; }
body.yard-enter .view-toolbar,
body.yard-enter .legend-pills,
body.yard-enter .view-nav { animation: chromePop 0.55s var(--ease-spring) 0.15s both; }
body.yard-enter .seg-panel { animation: chromeRise 0.65s var(--ease-spring) 0.12s both; }
@keyframes chromeDrop { from { translate: 0 -100%; opacity: 0; } }
@keyframes chromeRise { from { translate: 0 36px; opacity: 0; } }
@keyframes chromePop { from { scale: 0.94; opacity: 0; } }

/* Back to Home: the hero fades in over the yard it starts from */
.hero.enter { animation: heroBack 0.45s ease both; }
@keyframes heroBack { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .hero.enter, .hero.is-exiting, body.yard-enter * { animation: none !important; }
}

/* DG Segregation Check: conflict cards with the Home look, in a sideways row.
   Hover / focus looks at the pair in 3D, a click focuses it and opens the details below (app.js renderSegDetail) */
.seg-panel { --h-tile: var(--bg-subtle); --h-line: var(--border-subtle); --h-dim: var(--text-muted); --h-muted: var(--text-muted); }
.seg-list.seg-track {
  display: flex;
  gap: 12px;
  max-height: none;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 12px;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.seg-track > .seg-card { flex: 0 0 min(330px, 82vw); scroll-snap-align: start; }
.seg-track > .seg-empty { flex: 1; }
.seg-card.open { border-color: var(--lv); box-shadow: 0 0 0 1px var(--lv), 0 18px 40px -24px var(--lv); }
.seg-card.open .cc-go { opacity: 1; transform: none; }

.seg-detail {
  position: absolute;
  z-index: 26;
  left: 12px;
  top: 58px;
  width: min(360px, 42%);
  max-height: calc(100% - 70px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px 14px 14px 18px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--lv) 45%, var(--border-subtle));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--lv) 10%, transparent), transparent 55%),
    color-mix(in srgb, var(--bg-card) 90%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: inset 3px 0 0 var(--lv), 0 24px 50px -20px rgba(0, 0, 0, 0.55);
  scrollbar-width: thin;
  animation: sdIn 0.35s var(--ease-spring) both;
}
@keyframes sdIn { from { opacity: 0; translate: -16px 0; } }
.sd-head { display: flex; align-items: center; gap: 10px; }
.sd-title { display: grid; flex: 1; min-width: 0; }
.sd-title b { font-size: 0.95rem; font-family: 'Plus Jakarta Sans', sans-serif; }
.sd-title small { font-size: 0.72rem; color: var(--text-muted); }
.sd-close { flex: none; width: 30px; height: 30px; border-radius: 9px; cursor: pointer; font: inherit; color: var(--text-muted); background: transparent; border: 1px solid var(--border-subtle); }
.sd-close:hover { color: var(--text-main); border-color: var(--lv); }
.sd-pair { display: grid; gap: 6px; margin: 12px 0 14px; }
.sd-unit { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 14px 8px 8px; border-radius: 12px; background: var(--bg-card); border: 1px solid var(--border-subtle); }
.sd-unit > div { display: grid; min-width: 0; }
.sd-unit b { font-size: 0.84rem; }
.sd-unit small { font-size: 0.7rem; color: var(--text-muted); }
.sd-vs { justify-self: center; font-weight: 800; line-height: 1; color: var(--lv); transform: rotate(90deg); }
.sd-grid { display: grid; gap: 16px; }
.sd-grid h4 { margin: 0 0 8px; font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.sd-reasons, .sd-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 0.8rem; line-height: 1.5; }
.sd-reasons code { margin-right: 6px; padding: 1px 6px; border-radius: 6px; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.72rem; background: var(--bg-card); border: 1px solid var(--border-subtle); }
.sd-notes { margin-top: 10px; font-size: 0.76rem; color: var(--text-muted); }
.sd-tag { display: inline-block; margin-right: 6px; padding: 1px 7px; border-radius: 999px; font-size: 0.64rem; font-weight: 700; vertical-align: 1px; }
.sd-tag.cls { color: #f97316; background: rgba(249, 115, 22, 0.12); border: 1px solid rgba(249, 115, 22, 0.35); }
.sd-tag.un { color: #a855f7; background: rgba(168, 85, 247, 0.12); border: 1px solid rgba(168, 85, 247, 0.35); }
.sd-check { display: grid; grid-template-columns: 76px 1fr; align-items: start; gap: 8px; margin-bottom: 8px; font-size: 0.8rem; line-height: 1.5; }
.sd-ok, .sd-bad { padding: 2px 8px; border-radius: 7px; text-align: center; font-size: 0.64rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.sd-ok { color: #22c55e; background: rgba(34, 197, 94, 0.12); }
.sd-bad { color: #ef4444; background: rgba(239, 68, 68, 0.12); }
.sd-verdict { margin: 6px 0 0; font-size: 0.78rem; font-weight: 700; color: var(--lv); }
.seg-detail .sd-actions { padding: 10px 0 0; }
.seg-detail .sd-actions .seg-suggest-btn { width: 100%; padding: 7px 12px; border-radius: 10px; text-align: left; }
.seg-detail .seg-suggest { margin: 8px 0 0; }
@media (max-width: 760px) {
  .seg-detail { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 48%; animation-name: sdUp; }
}
@keyframes sdUp { from { opacity: 0; translate: 0 16px; } }
@media (prefers-reduced-motion: reduce) { .seg-detail { animation: none; } }

/* ==========================================================================
   Sleek chrome: glass top bar over the 3D yard, glass view toolbar / legend,
   compact DG dock, slim scrollbars
   ========================================================================== */
.app-shell { --tb-h: 52px; --glass: rgba(10, 15, 30, 0.42); --glass-line: rgba(255, 255, 255, 0.1); }
body.light-theme.app-shell { --glass: rgba(255, 255, 255, 0.55); --glass-line: rgba(15, 23, 42, 0.1); }

/* Slim scrollbars everywhere */
* { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, 0.35) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.3); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(148, 163, 184, 0.55); }
::-webkit-scrollbar-corner { background: transparent; }

/* Top bar: transparent glass floating over the yard */
.app-shell .app-topbar {
  gap: 10px;
  min-height: var(--tb-h);
  padding-top: 6px;
  padding-bottom: 6px;
  padding-right: 10px;
  flex-wrap: nowrap;
  background: linear-gradient(180deg, var(--glass), transparent 140%);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--glass-line);
}
body.light-theme.app-shell .app-topbar { background: linear-gradient(180deg, var(--glass), rgba(255, 255, 255, 0.2) 140%); }
.app-shell .tb-title { font-size: 1.05rem; }
.app-shell .tb-sub { font-size: 0.58rem; }
.tb-icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-line);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, color 0.2s ease;
}
.tb-icon-btn:hover { color: #fff; background: rgba(56, 189, 248, 0.2); border-color: rgba(56, 189, 248, 0.5); }
body.light-theme .tb-icon-btn:hover { color: #0369a1; }
.tb-icon-btn:active { transform: scale(0.94); }
.tb-icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app-shell .tb-open { margin-left: auto; color: #fff; background: linear-gradient(135deg, #0ea5e9, #6366f1); border-color: transparent; box-shadow: 0 6px 16px -8px rgba(99, 102, 241, 0.9); }
.app-shell .tb-open:hover { color: #fff; filter: brightness(1.12); }
.app-shell .tb-controls { flex-wrap: nowrap; gap: 8px; }
.app-shell .tb-controls .range-row { padding: 2px 4px 2px 10px; gap: 6px; border-radius: 11px; background: rgba(255, 255, 255, 0.04); border-color: var(--glass-line); }
.app-shell .tb-controls .range-row::before { font-size: 0.56rem; }
.app-shell .tb-controls .range-field { font-size: 0.6rem; gap: 5px; color: var(--text-dim); }
.app-shell .tb-controls .range-field .select-input, .app-shell .tb-controls .range-input { height: 28px; font-size: 0.8rem; background: transparent; border-color: transparent; }
.app-shell .tb-controls .range-field .select-input:hover, .app-shell .tb-controls .range-input:hover,
.app-shell .tb-controls .range-field .select-input:focus, .app-shell .tb-controls .range-input:focus { border-color: var(--glass-line); background: rgba(255, 255, 255, 0.05); }
.app-shell .tb-controls .range-input { width: 52px; }
.app-shell .tb-controls #rangeFullBlockBtn { height: 26px; padding: 0 10px; font-size: 0.72rem; }
.app-shell .tb-controls .search-input-wrapper { max-width: 300px; }
.app-shell .tb-controls .search-input-wrapper input { height: 32px; font-size: 0.8rem; background: rgba(255, 255, 255, 0.04); border-color: var(--glass-line); border-radius: 10px; }

/* Desktop: the top bar floats over the workspace, so the yard runs underneath the glass */
@media (min-width: 761px) {
  .app-shell .app-col { position: relative; }
  .app-shell .app-topbar { position: absolute; top: 0; left: 0; right: 0; }
  .app-shell .yard-stage:not(.fullscreen) .view-toolbar { top: calc(var(--tb-h) + 10px); }
  .app-shell .yard-stage:not(.fullscreen) .hud-overlay-top { top: calc(var(--tb-h) + 10px); }
  .app-shell .yard-stage:not(.fullscreen) .move-preview-hud { top: calc(var(--tb-h) + 54px); }
  .app-shell .yard-stage:not(.fullscreen) .seg-detail { top: calc(var(--tb-h) + 54px); max-height: calc(100% - var(--tb-h) - 66px); }
  .app-shell .side-panel { top: calc(var(--tb-h) + 10px); }
  .app-shell .page-panel, .app-shell .empty-state.welcome { top: var(--tb-h); }
}

/* View toolbar and legend: small glass bars */
.view-toolbar {
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  box-shadow: 0 8px 22px -12px rgba(0, 0, 0, 0.55);
}
.view-toolbar .select-input { height: 28px; max-width: 140px; font-size: 0.76rem; border-radius: 9px; background-color: transparent; border-color: transparent; }
.view-toolbar .select-input:hover { background-color: rgba(255, 255, 255, 0.06); }
.view-toolbar .btn { height: 28px; font-size: 0.74rem; }
.view-toolbar .camera-btn-group { gap: 1px; padding: 0; background: transparent; border: 0; border-radius: 9px; }
.view-toolbar .camera-btn-group .btn-icon { height: 28px; padding: 0 10px; border-radius: 8px; font-weight: 600; }
.view-toolbar .camera-btn-group .btn-icon.active { background: rgba(56, 189, 248, 0.22); color: #fff; box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.5); }
body.light-theme .view-toolbar .camera-btn-group .btn-icon.active { color: #0369a1; }
.view-toolbar .btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.view-toolbar #camResetBtn, .view-toolbar .tb-icon { width: 30px; padding: 0; display: grid; place-items: center; }
.view-toolbar .tb-wire { padding: 0 10px; border-radius: 8px; background: transparent; border-color: transparent; }
.view-toolbar .tb-wire:hover, .view-toolbar .tb-icon:hover { background: rgba(255, 255, 255, 0.08); }
body.light-theme .view-toolbar .btn, body.light-theme .view-toolbar .btn-outline { color: var(--text-main); }
.legend-pills {
  gap: 2px;
  padding: 3px 8px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
}
body.light-theme .legend-pills { background: var(--glass); }
.legend-item { font-size: 0.68rem; padding: 2px 5px; }
.legend-dot { width: 7px; height: 7px; }

/* Hover tooltip: placed by positionTooltip (kept inside the 3D view) */
.container-tooltip-3d { transform: none; transition: opacity 0.15s ease; }

/* DG dock: compact, sized to its content so the cards fit without scrolling */
.app-shell .yard-stage:not(.fullscreen) .seg-panel { max-height: 46%; padding: 8px 14px 6px; }
.seg-panel .seg-head { gap: 8px 12px; }
.seg-panel .seg-title { flex: 0 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.seg-panel .seg-title h3 { font-size: 0.9rem; white-space: nowrap; }
.seg-panel .seg-sub { font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-panel .seg-legend { margin-left: auto; font-size: 0.68rem; gap: 10px; }
.seg-panel .seg-summary { font-size: 0.72rem; padding: 3px 10px; }
.seg-panel #segResolveAllBtn { height: 28px; font-size: 0.74rem; }
.seg-panel .seg-toggle { font-size: 0.72rem; }
.seg-panel .seg-blocks { margin-top: 6px; }
.seg-panel .seg-list.seg-track { margin-top: 8px; gap: 10px; padding: 2px 2px 6px; }
.seg-track > .seg-card { flex-basis: min(290px, 80vw); padding: 10px 12px 9px 14px; border-radius: 14px; }
.seg-card .cc-lvl { min-width: 30px; height: 26px; border-radius: 8px; font-size: 0.78rem; }
.seg-card .cc-term { font-size: 0.8rem; }
.seg-card .cc-term small, .seg-card .cc-unit small { font-size: 0.64rem; }
.seg-card .cc-block { font-size: 0.64rem; padding: 2px 7px; }
.seg-card .cc-pair { margin: 8px 0 7px; gap: 6px; }
.seg-card .cc-unit { gap: 5px; }
.seg-card .cc-unit b { font-size: 0.72rem; }
.seg-card .hz { width: 20px; height: 20px; margin: 3px; }
.seg-card .hz b { font-size: 0.5rem; }
.seg-card .cc-link { width: 56px; padding-top: 10px; }
.seg-card .cc-ref, .seg-card .cc-go { font-size: 0.64rem; }
.seg-panel .seg-basis { margin-top: 4px; font-size: 0.68rem; }
.seg-panel .seg-extra { margin-top: 4px; font-size: 0.68rem; }
.view-toolbar .tb-wire.active, .view-toolbar .tb-icon.active { color: #fff; background: rgba(56, 189, 248, 0.22); box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.5); }
.app-shell .tb-title { background: linear-gradient(90deg, #7dd3fc, #a5b4fc 60%, #d8b4fe); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 1px 8px rgba(56, 189, 248, 0.35)); }
body.light-theme.app-shell .tb-title { background: linear-gradient(90deg, #0284c7, #4f46e5 60%, #9333ea); -webkit-background-clip: text; background-clip: text; filter: none; }
.app-shell .tb-sub { color: var(--text-muted); }

/* Resolve-all plan: slim bar + sideways move cards */
.seg-panel .seg-plan { margin-top: 8px; padding: 0; gap: 8px; border: 0; background: transparent; font-size: 0.78rem; }
.seg-panel .seg-plan-head {
  flex-wrap: nowrap;
  gap: 10px;
  padding: 6px 6px 6px 8px;
  border-radius: 12px;
  border: 1px solid rgba(34, 197, 94, 0.3);
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.12), rgba(34, 197, 94, 0.03));
}
.mv-badge { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: rgba(34, 197, 94, 0.16); font-size: 0.85rem; flex: none; }
.seg-plan-title { display: grid; flex: 1; min-width: 0; line-height: 1.2; }
.seg-plan-title b { font-size: 0.84rem; }
.seg-plan-title small { font-size: 0.68rem; color: var(--text-muted); }
.seg-plan-result { flex: none; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.seg-plan-result.ok { color: #4ade80; background: rgba(34, 197, 94, 0.14); border: 1px solid rgba(34, 197, 94, 0.35); }
.seg-plan-result.warn { color: #fbbf24; background: rgba(245, 158, 11, 0.14); border: 1px solid rgba(245, 158, 11, 0.35); }
.seg-plan-head #segPlanPreview { height: 28px; font-size: 0.74rem; flex: none; }
.seg-plan-head .sd-close { width: 28px; height: 28px; }
.mv-track { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; }
.mv-card {
  position: relative;
  flex: 0 0 min(250px, 78vw);
  scroll-snap-align: start;
  display: grid;
  gap: 8px;
  padding: 10px 12px 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  outline: none;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  box-shadow: inset 3px 0 0 var(--lv);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s var(--ease-spring);
}
.mv-card:hover, .mv-card:focus-visible { transform: translateY(-2px); border-color: color-mix(in srgb, var(--lv) 55%, transparent); }
.mv-card.active { border-color: #22c55e; box-shadow: inset 3px 0 0 #22c55e, 0 0 0 1px #22c55e, 0 14px 30px -18px #22c55e; }
.mv-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mv-step { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 7px; font-size: 0.7rem; font-weight: 800; color: var(--lv); background: color-mix(in srgb, var(--lv) 15%, transparent); border: 1px solid color-mix(in srgb, var(--lv) 45%, transparent); }
.mv-card .hz { width: 20px; height: 20px; margin: 3px; }
.mv-card .hz b { font-size: 0.5rem; }
.mv-unit { display: grid; min-width: 0; line-height: 1.25; }
.mv-unit b { font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-unit small { font-size: 0.64rem; color: var(--text-muted); }
.mv-route { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; }
.mv-slot { padding: 3px 7px; border-radius: 7px; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 0.7rem; white-space: nowrap; }
.mv-slot.from { color: var(--text-muted); background: var(--bg-card); border: 1px solid var(--border-subtle); text-decoration: line-through; text-decoration-color: rgba(148, 163, 184, 0.5); }
.mv-slot.to { color: #4ade80; font-weight: 700; background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.4); }
body.light-theme .mv-slot.to { color: #15803d; }
.mv-arrow { position: relative; height: 2px; }
.mv-arrow i { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, #22c55e 0 5px, transparent 5px 9px); background-size: 18px 2px; animation: dash 0.9s linear infinite; }
.mv-arrow::after { content: ''; position: absolute; right: -1px; top: -3px; border: 4px solid transparent; border-left: 6px solid #22c55e; border-right: 0; }
.mv-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.mv-chip { padding: 1px 7px; border-radius: 999px; font-size: 0.62rem; color: var(--text-muted); background: var(--bg-card); border: 1px solid var(--border-subtle); }
.mv-chip.lvl { color: var(--lv); border-color: color-mix(in srgb, var(--lv) 45%, transparent); font-weight: 700; }
.mv-chip.warn { color: #fbbf24; border-color: rgba(245, 158, 11, 0.45); }
.seg-panel .seg-plan .seg-extra { margin-top: 0; }
.seg-panel .seg-plan-head > span { flex: none; }
.seg-detail .btn { height: 28px; padding: 0 12px; font-size: 0.74rem; }
.seg-detail .seg-sg-remark select { height: 28px; font-size: 0.74rem; }

/* Top bar range: on the right next to Open file, readable labels on the glass, no number spinners */
.app-shell .tb-controls .search-input-wrapper { order: 1; }
.app-shell .tb-controls .range-row { order: 2; margin-left: auto; }
.app-shell .tb-controls .range-row::before { content: none; }
.app-shell .tb-controls .range-field { color: var(--text-muted); font-weight: 700; letter-spacing: 0.08em; }
.app-shell .tb-controls .range-field .select-input, .app-shell .tb-controls .range-input { color: var(--text-main); font-weight: 600; }
.app-shell .tb-controls .range-input { width: 46px; text-align: center; -moz-appearance: textfield; appearance: textfield; }
.app-shell .tb-controls .range-input::-webkit-outer-spin-button,
.app-shell .tb-controls .range-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.app-shell .tb-controls #rangeFullBlockBtn { color: var(--text-main); }
.app-shell .tb-controls .search-input-wrapper input::placeholder { color: var(--text-muted); opacity: 1; }
.app-shell .tb-controls .search-icon { color: var(--text-muted); }
.app-shell .tb-open { margin-left: 0; }

/* One typeface everywhere: Plus Jakarta Sans (codes and numbers keep aligned digits) */
code, kbd, samp, pre, .mono, input, select, textarea, button { font-family: 'Plus Jakarta Sans', sans-serif; }
code, kbd, samp, .mono, .cc-unit b, .sd-unit b, .mv-unit b, .mv-slot, .tooltip-unit, .tooltip-slot { font-variant-numeric: tabular-nums; }

/* Home at sunset (matches the 3D yard's sky): dusk plum background, orange / pink / indigo accents, light text in either theme */
.hero[data-period="sunset"] { --a1: #fb923c; --a2: #f472b6; --a3: #818cf8; --h-bg: #1b1433; }
body.light-theme .hero[data-period="sunset"] {
  --h-text: #f5f7fb; --h-muted: rgba(226, 232, 240, 0.74); --h-dim: rgba(203, 213, 225, 0.52);
  --h-glass: rgba(9, 13, 26, 0.56); --h-glass-strong: rgba(8, 11, 22, 0.8); --h-tile: rgba(255, 255, 255, 0.035);
  --h-line: rgba(255, 255, 255, 0.09); --h-warn: #fdba74; --h-fog: rgba(150, 165, 190, 0.16);
}

/* The 3D yard is always at dusk, so everything floating over it keeps the dark glass in both themes */
body.light-theme.app-shell .app-topbar,
body.light-theme .view-toolbar,
body.light-theme .legend-pills,
body.light-theme .view-nav,
body.light-theme .move-preview-hud,
body.light-theme .container-tooltip-3d,
body.light-theme.app-shell .menu-toggle {
  --glass: rgba(10, 15, 30, 0.42);
  --glass-line: rgba(255, 255, 255, 0.1);
  --bg-subtle: rgba(255, 255, 255, 0.06);
  --bg-input: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(56, 189, 248, 0.45);
  --text-main: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  color: var(--text-main);
}
body.light-theme.app-shell .app-topbar { background: linear-gradient(180deg, var(--glass), transparent 140%); }
body.light-theme.app-shell .tb-title { background: linear-gradient(90deg, #7dd3fc, #a5b4fc 60%, #d8b4fe); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 1px 8px rgba(56, 189, 248, 0.35)); }
body.light-theme .tb-icon-btn:hover { color: #fff; }
body.light-theme .view-toolbar .camera-btn-group .btn-icon.active { color: #fff; }
body.light-theme.app-shell .menu-toggle { background: rgba(10, 14, 28, 0.55); }
body.light-theme .move-preview-hud { background: rgba(10, 15, 30, 0.72); }
body.light-theme .container-tooltip-3d { background: rgba(15, 23, 42, 0.92); }
body.light-theme .app-shell .tb-controls .search-input-wrapper input, body.light-theme.app-shell .tb-controls .search-input-wrapper input { color: var(--text-main); }

/* Suggest safe slot reads clearly on light cards */
body.light-theme .seg-suggest-btn { color: #15803d; border-color: rgba(22, 163, 74, 0.45); background: rgba(34, 197, 94, 0.12); }
body.light-theme .seg-detail.suggest-open .seg-suggest-btn { color: #fff; background: #16a34a; }
.cc.is-away .cc-go { color: var(--h-muted); }

/* What changed since the previous file, handover button */
.seg-changes { font-size: 0.7rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border-subtle); background: var(--bg-subtle); color: var(--text-muted); white-space: nowrap; }
.seg-changes .up { color: #f97316; } .seg-changes .down { color: #22c55e; }
.seg-changes small { color: var(--text-dim); }
.seg-panel .seg-report-btn { height: 28px; font-size: 0.74rem; }

/* New tag and status pill on conflict cards (Home and yard) */
.cc-new { flex: none; padding: 2px 7px; border-radius: 999px; font-size: 0.6rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #fff; background: linear-gradient(135deg, #0ea5e9, #6366f1); box-shadow: 0 4px 12px -4px rgba(14, 165, 233, 0.8); }
.cc-status { padding: 1px 8px; border-radius: 999px; font-size: 0.62rem; font-weight: 700; border: 1px solid; }
.st-moving { color: #60a5fa; border-color: rgba(96, 165, 250, 0.45); background: rgba(59, 130, 246, 0.12); }
.st-accepted { color: #4ade80; border-color: rgba(74, 222, 128, 0.45); background: rgba(34, 197, 94, 0.12); }
.st-escalated { color: #c084fc; border-color: rgba(192, 132, 252, 0.45); background: rgba(168, 85, 247, 0.12); }
.st-open { color: #fca5a5; border-color: rgba(252, 165, 165, 0.4); background: rgba(239, 68, 68, 0.1); }
body.light-theme .st-moving { color: #1d4ed8; } body.light-theme .st-accepted { color: #15803d; }
body.light-theme .st-escalated { color: #7c3aed; } body.light-theme .st-open { color: #b91c1c; }
.cc.is-handled { opacity: 0.62; }
.cc.is-handled:hover, .cc.is-handled.open { opacity: 1; }

/* Status in the conflict pop-up */
.sd-status { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin-top: 10px; padding: 3px; border-radius: 10px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); }
.sd-st { font: inherit; font-size: 0.7rem; font-weight: 700; padding: 5px 2px; border-radius: 7px; cursor: pointer; color: var(--text-muted); background: transparent; border: 1px solid transparent; }
.sd-st:hover { color: var(--text-main); }
.sd-st.on.st-open { color: #fca5a5; background: rgba(239, 68, 68, 0.14); border-color: rgba(252, 165, 165, 0.4); }
.sd-st.on.st-moving { color: #93c5fd; background: rgba(59, 130, 246, 0.16); border-color: rgba(96, 165, 250, 0.45); }
.sd-st.on.st-accepted { color: #86efac; background: rgba(34, 197, 94, 0.16); border-color: rgba(74, 222, 128, 0.45); }
.sd-st.on.st-escalated { color: #d8b4fe; background: rgba(168, 85, 247, 0.16); border-color: rgba(192, 132, 252, 0.45); }
body.light-theme .sd-st.on.st-open { color: #b91c1c; } body.light-theme .sd-st.on.st-moving { color: #1d4ed8; }
body.light-theme .sd-st.on.st-accepted { color: #15803d; } body.light-theme .sd-st.on.st-escalated { color: #7c3aed; }
.sd-note { width: 100%; margin-top: 6px; height: 30px; padding: 0 10px; border-radius: 9px; font: inherit; font-size: 0.74rem; color: var(--text-main); background: var(--bg-subtle); border: 1px solid var(--border-subtle); }
.sd-note:focus { outline: none; border-color: var(--lv); }

/* A list older than a shift */
.sb-stale { color: #fbbf24; font-weight: 700; }

/* Home: file age, what changed, arriving DG */
.hero-stale { color: #fbbf24; border-color: rgba(251, 191, 36, 0.45); font-weight: 700; }
.brief-changes { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 9px 14px; border-radius: 14px; font-size: 0.82rem; color: var(--h-muted); background: var(--h-tile); border: 1px solid var(--h-line); }
.brief-changes .bc-ico { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 8px; font-weight: 800; color: var(--a1); background: color-mix(in srgb, var(--a1) 14%, transparent); }
.brief-changes b.up { color: #fb923c; } .brief-changes b.down { color: #4ade80; }
.brief-changes code { font-family: inherit; font-variant-numeric: tabular-nums; font-size: 0.76rem; padding: 0 5px; border-radius: 5px; background: var(--h-tile); border: 1px solid var(--h-line); }
.brief-upcoming { margin-top: 16px; }
.bu-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.bu-sub { font-size: 0.78rem; color: var(--h-muted); flex: 1; }
.bu-bad { color: #fbbf24; }
.bu-head .hbtn { padding: 6px 12px; font-size: 0.76rem; }
.bu-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.bu-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 12px 8px 8px; border-radius: 14px; background: var(--h-tile); border: 1px solid var(--h-line); }
.bu-item .hz { width: 22px; height: 22px; }
.bu-unit { display: grid; min-width: 0; flex: 1; }
.bu-unit b { font-size: 0.8rem; }
.bu-unit small { font-size: 0.68rem; color: var(--h-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bu-arrow { color: var(--h-dim); }
.bu-slot { flex: none; padding: 3px 8px; border-radius: 8px; font-size: 0.74rem; font-weight: 700; font-variant-numeric: tabular-nums; color: #4ade80; background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.4); }
.bu-slot.none { color: #fbbf24; background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.4); }

/* Focus / preview banner: next to the conflict pop-up rather than under it */
.app-shell .viewport-3d-wrapper:has(.seg-detail:not([hidden])) .move-preview-hud { left: calc(50% + min(360px, 42%) / 2 + 6px); max-width: calc(100% - min(360px, 42%) - 36px); }

/* Tablets and narrow desktops: a tighter top bar, the legend under the view toolbar */
@media (min-width: 761px) and (max-width: 1100px) {
  .app-shell .tb-brand { display: none; }
  .app-shell .tb-controls .search-input-wrapper { min-width: 120px; max-width: 220px; flex: 1 1 120px; }
  .app-shell .tb-controls .range-field > span { display: none; }
  .app-shell .tb-controls .range-row { gap: 4px; padding-left: 6px; }
  .app-shell .yard-stage:not(.fullscreen) .hud-overlay-top { top: calc(var(--tb-h) + 52px); right: auto; }
  .app-shell .yard-stage:not(.fullscreen) .seg-detail { top: calc(var(--tb-h) + 96px); max-height: calc(100% - var(--tb-h) - 108px); }
  .app-shell .yard-stage:not(.fullscreen) .move-preview-hud { top: calc(var(--tb-h) + 96px); }
  .view-toolbar .tb-wire { display: none; }
}
@media (min-width: 761px) and (max-width: 900px) {
  .app-shell .tb-controls #rangeFullBlockBtn { display: none; }
  .app-shell .viewport-3d-wrapper:has(.seg-detail:not([hidden])) .move-preview-hud { display: none; }
}
