/* INV-20260916-001 combined case report — design tokens */
:root {
  --bg: #14171a;
  --bg-raised: #1a1e23;
  --bg-raised-2: #20252b;
  --border: #2c3138;
  --border-soft: #232830;
  --text: #e7e9ec;
  --text-muted: #9aa2ad;
  --text-faint: #676f79;
  --accent: #3fb6ac;
  --accent-soft: rgba(63, 182, 172, 0.14);
  --danger: #e0616b;
  --danger-soft: rgba(224, 97, 107, 0.14);
  --warn: #d9a441;
  --warn-soft: rgba(217, 164, 65, 0.14);
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
  --radius: 8px;
  --maxw: 900px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(20, 23, 26, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar .case-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.topbar .case-title {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.risk-pill {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(224, 97, 107, 0.35);
  white-space: nowrap;
}
.menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ---------- Layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  max-width: 1400px;
  margin: 0 auto;
}

/* ---------- Sidebar / TOC ---------- */
.sidebar {
  position: sticky;
  top: 49px;
  height: calc(100vh - 49px);
  overflow-y: auto;
  padding: 20px 14px 40px 20px;
  border-right: 1px solid var(--border-soft);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.toc-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin: 0 0 10px 0;
}
.toc { list-style: none; margin: 0 0 24px 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 5px 8px;
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}
.toc a:hover { background: var(--bg-raised); color: var(--text); text-decoration: none; }
.toc a.active { background: var(--accent-soft); color: var(--accent); }
.toc .lvl2 { font-weight: 500; margin-top: 4px; }
.toc .lvl3 a { padding-left: 20px; font-size: 12.5px; color: var(--text-faint); }
.toc .lvl3 a:hover { color: var(--text-muted); }

.sidebar-cta {
  display: block;
  margin-top: 6px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text);
  text-align: center;
  transition: border-color 0.15s;
}
.sidebar-cta:hover { border-color: var(--accent); text-decoration: none; color: var(--accent); }

/* ---------- Main content ---------- */
main { padding: 0; min-width: 0; }
.doc {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px 32px 120px;
}

.doc h1 {
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.doc h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 48px 0 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  scroll-margin-top: 64px;
}
.doc h2:first-of-type { border-top: none; padding-top: 0; margin-top: 24px; }
.doc h3 {
  font-size: 15.5px;
  font-weight: 700;
  margin: 28px 0 10px;
  color: var(--text);
  scroll-margin-top: 64px;
}
.doc p { margin: 0 0 14px; color: #d4d7db; }
.doc ul, .doc ol { margin: 0 0 14px; padding-left: 22px; color: #d4d7db; }
.doc li { margin-bottom: 6px; }
.doc strong { color: var(--text); font-weight: 600; }
.doc code {
  font-family: var(--mono);
  font-size: 0.87em;
  background: var(--bg-raised-2);
  padding: 1px 5px;
  border-radius: 4px;
  color: #ffd39a;
}
.doc pre {
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.65;
  margin: 0 0 20px;
}
.doc pre code { background: none; padding: 0; color: var(--text-muted); }
.doc hr { display: none; }
.doc blockquote {
  margin: 0 0 14px;
  padding: 2px 16px;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
}

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 0 22px; border: 1px solid var(--border-soft); border-radius: var(--radius); }
.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}
.doc th, .doc td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: top;
}
.doc th {
  background: var(--bg-raised-2);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.doc tr:last-child td { border-bottom: none; }
.doc tr:hover td { background: rgba(255,255,255,0.015); }

/* Grade / status chips inside table text */
.doc td code { color: #ffd39a; }

/* section jump-to-map link */
.jump-map {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -6px 0 20px;
  padding: 7px 12px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}
.jump-map:hover { text-decoration: none; background: rgba(63,182,172,0.22); }

/* ---------- Relationship map section ---------- */
.map-section {
  margin: 48px 0 56px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.map-intro { margin-bottom: 16px; }
.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.map-toolbar button {
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.map-toolbar button:hover { border-color: var(--accent); color: var(--text); }
.map-toolbar button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.map-toolbar .sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.map-toolbar input[type="text"] {
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  width: 170px;
}
.map-toolbar input[type="text"]::placeholder { color: var(--text-faint); }

.map-canvas-wrap {
  position: relative;
  border: 1px solid var(--border-soft);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  background: radial-gradient(ellipse at 50% 0%, rgba(63,182,172,0.05), transparent 60%), var(--bg-raised);
  height: 600px;
  overflow: hidden;
}
.legend-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 14px;
  background: var(--bg-raised-2);
  border: 1px solid var(--border-soft);
  border-top: none;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  font-size: 11px;
  color: var(--text-muted);
}
#graph-svg { width: 100%; height: 100%; display: block; cursor: grab; }
#graph-svg:active { cursor: grabbing; }

.node-label {
  font-family: var(--sans);
  font-size: 10.5px;
  fill: var(--text);
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--bg-raised);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.link-label {
  font-family: var(--sans);
  font-size: 9px;
  fill: var(--text-faint);
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--bg-raised);
  stroke-width: 3px;
}

.legend-item { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.map-hint {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  color: var(--text-faint);
  background: rgba(20,23,26,0.85);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 6px 10px;
}

.detail-panel {
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-raised);
  display: none;
}
.detail-panel.visible { display: block; }
.detail-panel .dp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.detail-panel .dp-title { font-size: 15px; font-weight: 700; color: var(--text); }
.detail-panel .dp-type {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-top: 3px;
}
.detail-panel .dp-close {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}
.detail-panel .dp-close:hover { color: var(--text); }
.detail-panel .dp-body { font-size: 13.5px; color: #d4d7db; line-height: 1.6; }
.detail-panel .dp-section {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 5px;
}
.detail-panel .dp-links {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-faint);
}
.detail-panel .dp-links a {
  font-family: var(--mono);
  margin-right: 8px;
}
.map-empty-hint { font-size: 12.5px; color: var(--text-faint); margin-top: 10px; }

/* ---------- Footer ---------- */
.doc-footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- Mobile ---------- */
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .menu-btn { display: flex; }
  .sidebar {
    position: fixed;
    top: 49px;
    left: 0;
    bottom: 0;
    width: 78vw;
    max-width: 300px;
    background: var(--bg);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 20px 0 40px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim {
    display: none;
    position: fixed;
    inset: 49px 0 0 0;
    background: rgba(0,0,0,0.5);
    z-index: 45;
  }
  .sidebar-scrim.visible { display: block; }
  .doc { padding: 28px 18px 100px; }
  .topbar .case-title { display: none; }
  .map-canvas-wrap { height: 460px; }
}
