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

body {
  font-family: system-ui, sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  padding: 24px;
}

/* ── Header ── */
h1 { font-size: 1.4rem; font-weight: 600; color: #f8fafc; }
.subtitle { font-size: 0.85rem; color: #64748b; margin: 4px 0 20px; }

/* ── Nav ── */
nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
nav a {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  background: #1e293b;
  color: #94a3b8;
  text-decoration: none;
  border: 1px solid #334155;
  transition: background 0.15s;
}
nav a:hover, nav a.active { background: #334155; color: #f1f5f9; }

/* ── Filters bar ── */
#filters {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: #94a3b8;
}
.filter-group label { white-space: nowrap; font-weight: 500; }
.filter-group input[type=range] {
  -webkit-appearance: none;
  width: 140px;
  height: 4px;
  border-radius: 2px;
  background: #334155;
  outline: none;
  cursor: pointer;
}
.filter-group input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #60a5fa;
  cursor: pointer;
}
.filter-group .val {
  font-family: monospace;
  font-size: 0.8rem;
  color: #60a5fa;
  min-width: 30px;
}
#visible-count { margin-left: auto; font-size: 0.8rem; color: #475569; }

/* ── Table ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
thead th {
  background: #1e293b;
  color: #94a3b8;
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid #334155;
  white-space: nowrap;
  user-select: none;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: #e2e8f0; }
thead th.asc::after  { content: " ↑"; color: #60a5fa; }
thead th.desc::after { content: " ↓"; color: #60a5fa; }

tbody tr { border-bottom: 1px solid #1e293b; transition: background 0.1s; }
tbody tr:hover { background: #1a2234; }
tbody td { padding: 9px 12px; vertical-align: top; max-width: 380px; }

/* ── Expand button ── */
.expand-btn {
  background: none;
  border: 1px solid #334155;
  border-radius: 4px;
  color: #64748b;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  padding: 1px 5px;
  transition: all 0.1s;
}
.expand-btn:hover { background: #1e293b; color: #94a3b8; }
.expand-btn.open { border-color: #60a5fa; color: #60a5fa; }

/* ── Detail row ── */
tr.detail-row td {
  background: #0d1526;
  border-bottom: 2px solid #1e3a5f;
  padding: 16px 20px;
  max-width: none;
}
.detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  font-size: 0.78rem;
  margin-bottom: 12px;
}
.detail-grid dt { color: #64748b; white-space: nowrap; }
.detail-grid dd { color: #cbd5e1; word-break: break-word; }
.detail-body {
  font-size: 0.75rem;
  color: #94a3b8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 12px;
  background: #080e1a;
  line-height: 1.5;
}

/* ── Utilities ── */
.wrap { white-space: pre-wrap; word-break: break-word; }
.mono { font-family: monospace; font-size: 0.78rem; color: #64748b; }
.muted { color: #475569; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: monospace;
  white-space: nowrap;
}
.hi  { background: #14532d; color: #86efac; }
.med { background: #713f12; color: #fde68a; }
.lo  { background: #1e293b; color: #64748b; }

a { color: #60a5fa; text-decoration: none; }
a:hover { text-decoration: underline; }

.empty { color: #475569; font-style: italic; padding: 20px 0; }

/* ── Add-source form ── */
.usage-card {
  background: #0f1117;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: .88rem;
}
.usage-card summary { cursor: pointer; font-weight: 600; list-style: none; padding: 4px 0; }
.usage-card summary::before { content: "▶ "; font-size: .7em; opacity: .7; }
.usage-card[open] summary::before { content: "▼ "; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: #94a3b8; flex: 1; min-width: 120px; }
.form-row input, .form-row select {
  background: #1e2130;
  border: 1px solid #2a2d3e;
  color: #e2e8f0;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: .88rem;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: #3b82f6; }
.btn-primary {
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 5px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: .88rem;
}
.btn-primary:hover { background: #2563eb; }
