:root {
  --bg: #0a0d14;
  --glass: rgba(18, 22, 32, 0.62);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --text-dim: #8b93a7;
  --accent: #4f8cff;
  --accent-2: #4fe0c5;
  --danger: #ff5c5c;
  --warn: #f5c542;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  font-family: 'Heebo', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-family: 'Heebo', system-ui, sans-serif;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ============ shared HUD glass ============ */
.hud {
  position: fixed;
  z-index: 10;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.panel-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-title.small { font-size: 12px; margin-bottom: 10px; }

.demo-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(79,140,255,0.25), rgba(79,224,197,0.25));
  border: 1px solid rgba(79,140,255,0.4);
  color: #cfe0ff;
  white-space: nowrap;
}
.demo-badge.tiny { font-size: 9px; padding: 2px 7px; }

/* ============ TOP BAR ============ */
.hud-top {
  top: 16px;
  right: 16px;
  left: 16px;
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.hud-top-left, .hud-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}
.case-id {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.case-number {
  font-size: 12px;
  color: var(--accent-2);
  font-weight: 700;
}
.case-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.back-link {
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  transition: all 0.15s ease;
}
.back-link:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(79,140,255,0.1);
}

/* ============ SIDE PANELS ============ */
.hud-panel {
  top: 84px;
  bottom: 110px;
  width: 300px;
  border-radius: var(--radius);
  padding: 18px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.hud-left { right: 16px; }
.hud-right { left: 16px; display: flex; flex-direction: column; gap: 16px; }

.entity-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.entity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s ease;
}
.entity-item:hover { background: rgba(255,255,255,0.05); }
.entity-item.active {
  background: rgba(79,140,255,0.14);
  border-color: rgba(79,140,255,0.4);
}
.entity-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.entity-name { font-size: 13.5px; font-weight: 500; }
.entity-role { font-size: 11px; color: var(--text-dim); margin-right: auto; }

.detail-card {
  min-height: 90px;
  padding: 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
}
.detail-empty { color: var(--text-dim); font-size: 13px; line-height: 1.6; }
.detail-name { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.detail-role { font-size: 12px; color: var(--accent-2); margin-bottom: 10px; font-weight: 600; }
.detail-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.detail-facts li {
  font-size: 12.5px;
  color: var(--text-dim);
  padding-right: 14px;
  position: relative;
  line-height: 1.5;
}
.detail-facts li::before {
  content: '';
  position: absolute;
  right: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.insights-card, .financials-card {
  padding: 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
}
.insights-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.insights-list li {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  display: flex;
  gap: 8px;
}
.insight-icon { flex-shrink: 0; }

.fin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.fin-row { display: flex; flex-direction: column; gap: 4px; }
.fin-row-top { display: flex; justify-content: space-between; font-size: 12px; }
.fin-label { color: var(--text-dim); }
.fin-value { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.fin-bar-track { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; }
.fin-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }

/* ============ BOTTOM TIMELINE ============ */
.hud-bottom {
  left: 16px;
  right: 16px;
  bottom: 16px;
  border-radius: var(--radius);
  padding: 14px 22px 12px;
}
.timeline-wrap {
  position: relative;
  height: 46px;
  margin-bottom: 4px;
}
.timeline-track {
  position: relative;
  height: 4px;
  top: 21px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
}
.timeline-track::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.5;
}
.tl-marker {
  position: absolute;
  top: -13px;
  transform: translateX(50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  background: #171b26;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-dim);
  transition: all 0.15s ease;
  z-index: 2;
}
.tl-marker:hover { border-color: var(--accent); color: var(--text); }
.tl-marker.active {
  border-color: var(--accent-2);
  background: var(--accent-2);
  color: #071410;
  box-shadow: 0 0 16px rgba(79,224,197,0.6);
}
.timeline-event-label {
  font-size: 12.5px;
  color: var(--text-dim);
  text-align: center;
  min-height: 18px;
}
.timeline-event-label b { color: var(--text); font-weight: 700; }
.footer-credit {
  position: absolute;
  left: 22px;
  bottom: 10px;
  font-size: 10.5px;
  color: rgba(139,147,167,0.6);
}
[dir="rtl"] .footer-credit { left: auto; right: 22px; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 30;
  box-shadow: var(--shadow);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
  .hud-panel { width: 250px; }
}
@media (max-width: 760px) {
  .hud-top { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .case-title { font-size: 12px; }
  .hud-panel {
    position: fixed;
    width: auto;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 190px;
    max-height: 34vh;
  }
  .hud-left { bottom: 190px; }
  .hud-right { display: none; } /* collapse detail/insights on narrow screens; entity list remains primary */
  .hud-bottom { padding: 12px 14px 10px; }
}
