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

:root {
  --sidebar-width: 260px;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --purple: #8b5cf6;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: #0c1524;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  color: white;
}

.logo-title {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 1px;
}

.logo-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.nav-list {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent);
  color: white;
}

.nav-item svg {
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-badge {
  background: var(--orange);
  color: #000;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 1px;
}

/* Main Content */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0c1524;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header h1 {
  font-size: 22px;
  font-weight: 600;
}

.header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.data-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--orange);
}

.pulse {
  width: 8px;
  height: 8px;
  background: var(--orange);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

.date-range {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Pages */
.page {
  display: none;
  padding: 28px 32px;
}

.page.active {
  display: block;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stats-grid.four {
  grid-template-columns: repeat(4, 1fr);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.stat-card.accent { border-left: 4px solid var(--red); }
.stat-card.accent2 { border-left: 4px solid var(--orange); }
.stat-card.accent3 { border-left: 4px solid var(--purple); }
.stat-card.accent4 { border-left: 4px solid var(--accent); }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-change {
  font-size: 12px;
  font-weight: 500;
}

.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }
.stat-change.neutral { color: var(--text-dim); }

/* Charts */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.chart-card.wide {
  grid-column: span 1;
}

.charts-row:has(.wide:first-child) {
  grid-template-columns: 2fr 1fr;
}

.charts-row:has(.wide:last-child) {
  grid-template-columns: 1fr 2fr;
}

.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* Tables */
.data-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.data-table-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  color: var(--text);
}

.data-table code {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge.green { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.badge.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent); }
.badge.orange { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.badge.purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.badge.gray { background: rgba(100, 116, 139, 0.15); color: var(--text-dim); }

/* Journey Page */
.journey-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 16px;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  padding: 12px 0;
  outline: none;
  font-family: inherit;
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.search-box svg {
  color: var(--text-dim);
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  white-space: nowrap;
}

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

.offender-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.offender-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.offender-avatar {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
}

.offender-info h2 {
  font-size: 20px;
  font-weight: 600;
}

.offender-info p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.mdm-tag {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.offender-stats-mini {
  display: flex;
  gap: 24px;
}

.offender-stats-mini div {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.offender-stats-mini strong {
  display: block;
  font-size: 24px;
  color: var(--text);
  margin-bottom: 4px;
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 40px;
  margin-bottom: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  left: -33px;
  top: 16px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--bg);
}

.timeline-item.arrest .timeline-dot { background: var(--accent); }
.timeline-item.prosecution .timeline-dot { background: var(--orange); }
.timeline-item.sentencing .timeline-dot { background: var(--purple); }
.timeline-item.incarceration .timeline-dot { background: var(--red); }
.timeline-item.release .timeline-dot { background: var(--green); }
.timeline-item.recidivism .timeline-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.3); }

.timeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}

.timeline-date {
  font-size: 12px;
  color: var(--text-dim);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.timeline-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 4px 0 6px;
}

.timeline-item.arrest .timeline-type { color: var(--accent); }
.timeline-item.prosecution .timeline-type { color: var(--orange); }
.timeline-item.sentencing .timeline-type { color: var(--purple); }
.timeline-item.incarceration .timeline-type { color: var(--red); }
.timeline-item.release .timeline-type { color: var(--green); }
.timeline-item.recidivism .timeline-type { color: var(--red); }

.timeline-card h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.timeline-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.timeline-detail {
  font-style: italic;
  color: var(--text-dim) !important;
  font-size: 12px !important;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}

.empty-state svg {
  margin-bottom: 20px;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Linkage Page */
.linkage-header {
  margin-bottom: 24px;
}

.linkage-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.linkage-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Sankey Visualization */
.sankey-viz {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
  min-height: 320px;
}

.sankey-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sankey-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.sankey-node {
  border-radius: 8px;
  padding: 12px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sankey-node small {
  font-weight: 400;
  opacity: 0.8;
  margin-top: 4px;
}

.sankey-node.ht {
  text-align: center;
  font-size: 16px;
}

.sankey-arrows {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 24px;
  min-width: 60px;
}

.arrow-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* Network Page */
.network-viz-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.network-viz-container h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.network-graph {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
  padding: 16px;
}

.network-svg {
  width: 100%;
  height: auto;
}

/* Sources Page */
.sources-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.source-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.15s;
}

.source-card:hover {
  border-color: var(--text-dim);
}

.source-card.primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), transparent);
}

.source-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.source-icon {
  width: 40px;
  height: 40px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.source-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.source-card > p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.source-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.source-datasets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dataset-tag {
  background: rgba(51, 65, 85, 0.5);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Architecture Diagram */
.integration-diagram {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.integration-diagram h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 24px;
}

.arch-flow {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
}

.arch-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.arch-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-align: center;
}

.arch-box {
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
}

.arch-box.source {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent);
}

.arch-box.process {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--purple);
  padding: 24px 12px;
}

.arch-box.bright {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(59, 130, 246, 0.1));
  border: 2px solid var(--green);
  color: var(--green);
  padding: 24px 12px;
}

.arch-box small {
  font-weight: 400;
  opacity: 0.7;
  display: block;
  margin-top: 4px;
}

.arch-arrow {
  font-size: 24px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .sources-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .sidebar {
    width: 64px;
    overflow: hidden;
  }
  .sidebar-header, .sidebar-footer span { display: none; }
  .nav-item { justify-content: center; padding: 14px; }
  .main { margin-left: 64px; }
  .charts-row {
    grid-template-columns: 1fr;
  }
  .chart-card.wide {
    grid-column: span 1;
  }
  .stats-grid, .stats-grid.four {
    grid-template-columns: repeat(2, 1fr);
  }
  .sources-grid {
    grid-template-columns: 1fr;
  }
}
