:root, [data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-subtle: #111;
  --bg-hover: #151515;
  --border: #222;
  --border-subtle: #252525;
  --border-focus: #333;
  --text: #ccc;
  --text-bright: #fff;
  --text-secondary: #888;
  --text-dim: #555;
  --text-muted: #444;
  --row-border: #1a1a1a;
  --tooltip-bg: rgba(17, 17, 17, 0.9);
}

[data-theme="light"] {
  --bg: #f5f5f0;
  --bg-subtle: #eee;
  --bg-hover: #e4e4e0;
  --border: #ddd;
  --border-subtle: #ccc;
  --border-focus: #bbb;
  --text: #333;
  --text-bright: #111;
  --text-secondary: #555;
  --text-dim: #888;
  --text-muted: #999;
  --row-border: #e0e0e0;
  --tooltip-bg: rgba(238, 238, 238, 0.9);
}

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

body {
  font-family: monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 1rem;
  font-size: 14px;
  line-height: 1.6;
}

.container { max-width: 600px; margin: 0 auto; }

a { color: #1B7340; text-decoration: none; }
a:hover { color: #2a9d5c; }

h1 {
  font-size: 12px;
  font-weight: normal;
  margin-bottom: 1.5rem;
}
h1 a.title { color: var(--text-secondary); }
h1 a.title:hover { color: var(--text-bright); }
h1 .dim { color: var(--text-dim); }

section { margin-bottom: 2rem; }

.section-title {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.metrics {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.metric-value {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: normal;
}

.metric-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 1rem;
  margin-bottom: 1rem;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.timeline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 60px;
}

.bar-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 2px;
}
.bar-stack:hover .bar-normal { background: #2a9d5c; }
.bar-normal { background: #1B7340; flex-shrink: 0; }

.doc-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--row-border);
}
.doc-row:last-child { border-bottom: none; }
.doc-type { color: var(--text-secondary); }
.doc-count { color: var(--text); }

.pub-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--row-border);
}
.pub-row:last-child { border-bottom: none; }
.pub-name { color: var(--text-secondary); }
a.pub-name { color: #1B7340; }
a.pub-name:hover { color: #2a9d5c; }
.pub-count { color: var(--text-dim); }

.timing-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--row-border);
}
.timing-row:last-child { border-bottom: none; }
.timing-name { color: var(--text-secondary); }
.timing-value { color: var(--text); }
.timing-value .dim { color: var(--text-dim); }

.traffic-section {
  position: relative;
  margin-bottom: 3rem;
}
.traffic-sparkline {
  position: relative;
  height: 60px;
}
.traffic-tooltip {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 9px;
  color: var(--text-dim);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  background: var(--tooltip-bg);
  padding: 1px 4px;
}
.traffic-range-btns {
  position: absolute;
  top: 0;
  right: 0;
}
.traffic-range-btns button {
  font-family: monospace;
  font-size: 10px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 1px 6px;
  cursor: pointer;
  margin-left: 2px;
}
.traffic-range-btns button:hover {
  border-color: var(--border-focus);
  color: var(--text-secondary);
}
.traffic-range-btns button.active {
  border-color: #1B7340;
  color: #1B7340;
}

.latency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}
.latency-cell {
  display: flex;
  flex-direction: column;
}
.latency-canvas-wrap {
  position: relative;
  height: 40px;
}
.latency-canvas-wrap canvas {
  width: 100%;
  height: 100%;
}
.latency-cell-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.latency-cell-label .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.latency-cell-max {
  margin-left: auto;
  color: var(--text-muted);
}
.latency-cell-empty {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
}
.latency-tooltip {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 9px;
  color: var(--text-dim);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  background: var(--tooltip-bg);
  padding: 1px 4px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  color: var(--text-dim);
}
.tag:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
  color: var(--text);
}
.tag .n { color: var(--text-muted); margin-left: 4px; }

.live { font-size: 11px; color: var(--text-dim); }
.live span { color: #4ade80; }

.theme-toggle {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 16px;
  user-select: none;
}
.theme-toggle:hover { color: var(--text); }

footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}
footer a { color: var(--text-dim); }
footer a:hover { color: var(--text-secondary); }
