/* RIVA Dark Theme */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2129;
  --border: #30363d;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --orange: #d18616;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji';
  font-size: 14px;
  line-height: 1.5;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
header h1 { font-size: 20px; font-weight: 600; color: var(--accent); }
header h1 span { color: var(--text-dim); font-weight: 400; font-size: 14px; }

.connection-status { display: flex; align-items: center; color: var(--text-dim); font-size: 13px; }
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.live { background: var(--green); }
.status-dot.offline { background: var(--red); }

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Sections */
section { margin-bottom: 32px; }
section h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
th:hover { color: var(--text); }
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-running { background: rgba(63,185,80,0.15); color: var(--green); }
.badge-installed { background: rgba(88,166,255,0.15); color: var(--accent); }
.badge-not_found { background: rgba(139,148,158,0.15); color: var(--text-dim); }

/* Severity badges */
.severity-critical { background: rgba(248,81,73,0.2); color: var(--red); font-weight: 700; }
.severity-high { background: rgba(248,81,73,0.15); color: var(--red); }
.severity-medium { background: rgba(210,153,34,0.15); color: var(--yellow); }
.severity-low { background: rgba(88,166,255,0.15); color: var(--accent); }
.severity-info { background: rgba(139,148,158,0.1); color: var(--text-dim); }

/* Status colors for network */
.conn-established { color: var(--green); }
.conn-close-wait { color: var(--yellow); }
.conn-time-wait { color: var(--red); }

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 13px;
}
.card-row .label { color: var(--text-dim); }
.card-row .value { color: var(--text); font-family: monospace; }

.sparkline-container { margin-top: 10px; }
.sparkline-label { font-size: 11px; color: var(--text-dim); margin-bottom: 2px; }
svg.sparkline { display: block; }

/* Bar chart */
.bar-chart { margin-top: 8px; }
.bar-row {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  font-size: 12px;
}
.bar-label { width: 120px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 16px; background: var(--bg); border-radius: 3px; margin: 0 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.3s ease; }
.bar-count { width: 40px; text-align: right; color: var(--text-dim); font-family: monospace; }

/* Accordion */
.accordion { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--bg-card); }
.accordion + .accordion { margin-top: 8px; }
.accordion-header {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 13px;
  user-select: none;
}
.accordion-header:hover { background: var(--bg-hover); }
.accordion-arrow { transition: transform 0.2s; font-size: 12px; color: var(--text-dim); }
.accordion.open .accordion-arrow { transform: rotate(90deg); }
.accordion-body { display: none; padding: 0 14px 14px; }
.accordion.open .accordion-body { display: block; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-dim); }
.btn-primary { background: rgba(88,166,255,0.15); border-color: var(--accent); color: var(--accent); }
.btn-primary:hover { background: rgba(88,166,255,0.25); }

/* Empty state */
.empty-msg { color: var(--text-dim); font-style: italic; padding: 20px; text-align: center; }

/* Stat summary cards */
.stat-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.stat-card {
  flex: 1;
  min-width: 150px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
}
.stat-card .stat-value { font-size: 24px; font-weight: 700; color: var(--accent); }
.stat-card .stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* Footer */
footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* Timeline Bar */
.timeline-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.timeline-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.timeline-live-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
}
.timeline-live-btn.active {
  background: rgba(63,185,80,0.2);
  border-color: var(--green);
  color: var(--green);
}
.timeline-play-btn {
  font-size: 11px;
  padding: 3px 8px;
  min-width: 28px;
  text-align: center;
}
.timeline-label {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 140px;
  white-space: nowrap;
}
.timeline-track {
  flex: 1;
  position: relative;
  height: 32px;
}
.timeline-buckets {
  display: flex;
  align-items: flex-end;
  height: 20px;
  gap: 1px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
}
.timeline-bucket {
  flex: 1;
  background: rgba(88,166,255,0.3);
  border-radius: 1px;
  min-height: 2px;
  transition: background 0.15s;
}
.timeline-bucket.has-orphan {
  background: rgba(210,153,34,0.5);
}
.timeline-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  position: absolute;
  bottom: 0;
  left: 0;
}
.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 4px rgba(88,166,255,0.4);
}
.timeline-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
}

/* Launch type colors */
.launch-user_terminal { color: var(--green); }
.launch-ide { color: var(--accent); }
.launch-script { color: var(--yellow); }
.launch-system { color: var(--orange); }
.launch-unknown { color: var(--text-dim); }

/* Forensic Timeline */
.forensic-timeline {
  max-height: 600px;
  overflow-y: auto;
  padding: 4px 0;
}
.forensic-event {
  padding: 4px 8px;
  border-left: 2px solid var(--border);
  margin-left: 8px;
  margin-bottom: 2px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}
.forensic-event.fail {
  border-left-color: var(--red);
  background: rgba(248,81,73,0.05);
}
.forensic-event.dead-end {
  border-left-color: var(--yellow);
  background: rgba(210,153,34,0.05);
}
.forensic-event-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.forensic-event-time {
  color: var(--text-dim);
  font-size: 11px;
  min-width: 60px;
}
.forensic-event-label {
  font-weight: 600;
  color: var(--accent);
}
.forensic-event-prompt {
  color: var(--text);
  padding-left: 68px;
  font-family: inherit;
  font-size: 12px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.forensic-action {
  padding-left: 68px;
  margin-left: 0;
  border-left: none;
}
.forensic-tool-name {
  color: var(--purple);
  font-weight: 600;
}
.forensic-back-btn {
  margin-bottom: 8px;
}
.forensic-session-row:hover td {
  background: var(--bg-hover);
}

/* Efficiency bar */
.efficiency-bar {
  width: 100px;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}
.efficiency-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
  body { padding: 12px; }
  .card-grid { grid-template-columns: 1fr; }
  .stat-row { flex-direction: column; }
  .tab-btn { padding: 8px 12px; font-size: 12px; }
  .timeline-bar { flex-direction: column; align-items: stretch; }
  .timeline-label { min-width: auto; }
}
