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

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #0f0f23;
  --bg-card: #16213e;
  --bg-card-hover: #1a2744;
  --border: #222;
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --text-muted: #555;
  --accent-blue: #60a5fa;
  --accent-green: #4ade80;
  --accent-purple: #c084fc;
  --accent-yellow: #fbbf24;
  --accent-red: #f87171;
  --accent-orange: #fb923c;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#topbar {
  background: #12122a;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
}

.logo {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.tabs { display: flex; gap: 4px; }

.tab {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.15s;
}
.tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.tab.active { color: var(--accent-blue); background: rgba(96,165,250,0.1); }

.status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.status .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
  transition: background 0.3s;
}
.status.connected .dot { background: var(--accent-green); }
.status.connected .label { color: var(--accent-green); }
.status.disconnected .label { color: var(--text-muted); }

#content {
  flex: 1;
  overflow: hidden;
}

.view { display: none; height: 100%; }
.view.active { display: flex; }

#view-live { display: none; flex-direction: row; }
#view-live.active { display: flex; }

.sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-section { margin-bottom: 20px; }

.sidebar-title {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.peer-card {
  background: var(--bg-card);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  transition: background 0.15s;
}
.peer-card:hover { background: var(--bg-card-hover); }

.peer-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.peer-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.peer-dot.active { background: var(--accent-green); }
.peer-dot.idle { background: var(--accent-yellow); }

.peer-name {
  font-size: 11px;
  color: #fff;
  font-weight: 600;
}

.peer-meta {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
  margin-left: 14px;
}

.claim-item {
  background: var(--bg-card);
  padding: 5px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
}
.claim-file { color: var(--accent-blue); }
.claim-owner { color: var(--text-muted); }

.timeline {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.timeline-title {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.filters { display: flex; gap: 4px; }

.filter-pill {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  transition: all 0.15s;
}
.filter-pill:hover { color: var(--text-primary); }
.filter-pill.active {
  color: var(--accent-blue);
  background: rgba(96,165,250,0.15);
}

.timeline-entries {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entry {
  background: var(--bg-card);
  padding: 10px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--text-muted);
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.entry-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.entry-agent { font-size: 11px; font-weight: 600; }
.entry-time { font-size: 10px; color: var(--text-muted); }
.entry-body { font-size: 11px; color: #ccc; word-break: break-word; }
.entry-type { font-size: 9px; color: var(--text-muted); margin-top: 4px; }

.color-0 { color: var(--accent-green); }
.color-1 { color: var(--accent-purple); }
.color-2 { color: var(--accent-yellow); }
.color-3 { color: var(--accent-blue); }
.color-4 { color: var(--accent-orange); }
.color-5 { color: var(--accent-red); }

.border-0 { border-left-color: var(--accent-green); }
.border-1 { border-left-color: var(--accent-purple); }
.border-2 { border-left-color: var(--accent-yellow); }
.border-3 { border-left-color: var(--accent-blue); }
.border-4 { border-left-color: var(--accent-orange); }
.border-5 { border-left-color: var(--accent-red); }

#view-sessions {
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}

.sessions-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.date-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.session-card {
  background: var(--bg-card);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.session-card:hover { background: var(--bg-card-hover); }

.session-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.session-agent { font-weight: 600; font-size: 12px; }
.session-detail { font-size: 10px; color: var(--text-secondary); }
.session-duration { font-size: 11px; color: var(--accent-blue); }

.session-activity {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: none;
}
.session-card.expanded .session-activity { display: block; }

#view-analytics {
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  gap: 16px;
}

.analytics-header {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.range-btn {
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  transition: all 0.15s;
}
.range-btn:hover { color: var(--text-primary); }
.range-btn.active { color: var(--accent-blue); background: rgba(96,165,250,0.15); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 16px;
}
.stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 4px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.chart-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 16px;
}
.chart-title {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
}
.bar {
  flex: 1;
  background: var(--accent-blue);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  opacity: 0.7;
  transition: opacity 0.15s;
  position: relative;
}
.bar:hover { opacity: 1; }

.h-bar-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.h-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.h-bar-label {
  font-size: 10px;
  color: var(--text-secondary);
  min-width: 120px;
  text-align: right;
}
.h-bar-track {
  flex: 1;
  height: 18px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}
.h-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.h-bar-value {
  font-size: 10px;
  color: var(--text-muted);
  min-width: 30px;
}

@media (max-width: 768px) {
  .sidebar { width: 180px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}
