@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=Space+Grotesk:wght@400;500;600;700&family=Instrument+Sans:ital,wght@0,400;0,500;1,400&display=swap');

:root {
  --bg: #0a0b0e;
  --surface: #111318;
  --surface2: #181c24;
  --surface3: #1a1e2a;
  --border: #1e2330;
  --border-soft: rgba(30,35,48,0.6);
  --accent: #3b82f6;
  --accent2: #4af0b8;
  --accent3: #f04a6e;
  --accent4: #a855f7;
  --text: #e8eaf2;
  --text-read: #d1d5db;
  --muted: #6b7280;
  --muted2: #9ca3af;
  --warn: #f59e0b;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Instrument Sans', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  -webkit-text-size-adjust: 100%;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2a3050; border-radius: 3px; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: 280px;
  background: rgba(17,19,24,0.98);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-header {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}

.agency-dot {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.agency-dot svg { width: 20px; height: 20px; }
.agency-name {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}
.agency-sub {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.nav-section {
  padding: 24px 16px;
  flex: 1;
  overflow-y: auto;
}
.nav-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
  padding-left: 8px;
}

.report-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted2);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}
.nav-btn svg { width: 16px; height: 16px; opacity: 0.7; }
.nav-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
.nav-btn.active {
  background: rgba(59,130,246,0.1);
  border-color: rgba(59,130,246,0.2);
  color: var(--accent);
  font-weight: 600;
}
.nav-btn.active svg { opacity: 1; }

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
}
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent2);
  margin-bottom: 6px;
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent2);
}
.pulse {
  animation: pulse-dot 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
.access-level { color: var(--muted); }

/* ─── MAIN CONTENT ─── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: linear-gradient(135deg, #0d1117 0%, #0a0b0e 100%);
}

.topbar {
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: rgba(10,11,14,0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.breadcrumbs {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  color: var(--muted);
}
.separator { margin: 0 8px; opacity: 0.5; }
#current-report-name { color: var(--text); font-weight: 500; }

.action-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
}
.action-btn:hover {
  background: var(--surface3);
  border-color: var(--muted);
}

.reader-container {
  padding: 48px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  position: relative;
}

/* ─── LOADER ─── */
.loader {
  display: none;
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.loader.active { display: block; }
.spinner {
  width: 30px; height: 30px;
  border: 3px solid rgba(59,130,246,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── MARKDOWN STYLING (THE MAGIC) ─── */
.markdown-body {
  color: var(--text-read);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.markdown-body.visible {
  opacity: 1;
  transform: translateY(0);
}

.markdown-body h1 {
  font-family: 'Syne', sans-serif;
  font-size: 42px;
  font-weight: 800;
  color: white;
  line-height: 1.1;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.markdown-body h2 {
  font-family: 'Syne', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-top: 56px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.markdown-body h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

.markdown-body h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent2);
  margin-top: 40px;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.markdown-body p { margin-bottom: 20px; font-size: 16px; line-height: 1.7; }

.markdown-body strong { color: white; font-weight: 600; }

.markdown-body ul, .markdown-body ol {
  margin-bottom: 24px;
  padding-left: 20px;
}
.markdown-body li {
  margin-bottom: 10px;
  font-size: 15px;
  line-height: 1.6;
}
.markdown-body li::marker { color: var(--accent); }

/* Premium Blockquote styling (Executive Banner) */
.markdown-body blockquote {
  margin: 32px 0;
  padding: 24px 32px;
  background: linear-gradient(135deg, rgba(59,130,246,0.08) 0%, rgba(168,85,247,0.05) 100%);
  border: 1px solid rgba(59,130,246,0.18);
  border-radius: 12px;
  border-left: 4px solid var(--accent);
  position: relative;
}
.markdown-body blockquote p {
  margin: 0;
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}
.markdown-body blockquote p:not(:last-child) { margin-bottom: 16px; }

/* Code Blocks */
.markdown-body code {
  font-family: 'Space Grotesk', monospace;
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--accent2);
}
.markdown-body pre code {
  display: block;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  overflow-x: auto;
  line-height: 1.5;
  margin-bottom: 24px;
}

/* Beautiful Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 32px 0;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.markdown-body th {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(17,19,24,0.5);
}
.markdown-body td {
  padding: 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.markdown-body tr:last-child td { border-bottom: none; }
.markdown-body tr:hover td { background: var(--surface2); }

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed rgba(59,130,246,0.5);
  transition: all 0.2s ease;
}
.markdown-body a:hover {
  color: var(--accent2);
  border-bottom-color: var(--accent2);
}

/* Print styling */
@media print {
  .sidebar { display: none; }
  .topbar { display: none; }
  body { background: white; color: black; display: block; }
  .markdown-body { transform: none; opacity: 1; }
  .markdown-body h1 { color: black; border-bottom-color: #eee; }
  .markdown-body h2 { color: black; }
  .markdown-body h2::after { display: none; }
  .markdown-body strong { color: black; }
  .markdown-body blockquote { background: #f8f9fa; border: 1px solid #ddd; border-left: 4px solid #3b82f6; }
  .markdown-body blockquote p { color: black; }
  .markdown-body table { border-color: #ddd; background: white; }
  .markdown-body th { background: #f8f9fa; color: #555; border-color: #ddd; }
}

/* ─── DYNAMIC TOC ─── */
.nav-item-wrapper {
  margin-bottom: 4px;
}
.toc-container {
  padding-left: 20px;
  margin-top: 4px;
  margin-bottom: 8px;
  border-left: 1px solid rgba(59,130,246,0.2);
  margin-left: 14px;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
.toc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toc-link {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.2s ease;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc-link:hover {
  color: var(--accent2);
}
.toc-h1 {
  color: var(--text);
  font-weight: 500;
  margin-top: 4px;
}
.toc-h2 {
  padding-left: 12px;
  font-size: 11px;
}
.toc-h3 {
  padding-left: 24px;
  font-size: 10px;
  opacity: 0.8;
}
