/* ── Design tokens ─────────────────────────────────────────────── */
:root {
  --bg: #09090b;
  --bg-surface: #121215;
  --bg-card: #18181c;
  --bg-card-hover: #1e1e23;
  --bg-raised: #1f1f25;
  --border: #25252b;
  --border-strong: #33333c;
  --text: #f1f1f3;
  --text-secondary: #9898a0;
  --text-tertiary: #6b6b75;
  --accent: #8896f0;
  --accent-hover: #a5aff7;
  --accent-bg: rgba(136, 150, 240, 0.08);
  --accent-border: rgba(136, 150, 240, 0.22);

  --ok: #5edb8a;
  --ok-bg: rgba(94, 219, 138, 0.07);
  --ok-border: rgba(94, 219, 138, 0.25);
  --warn: #f0b848;
  --warn-bg: rgba(240, 184, 72, 0.07);
  --warn-border: rgba(240, 184, 72, 0.28);
  --bad: #f2545b;
  --bad-bg: rgba(242, 84, 91, 0.07);
  --bad-border: rgba(242, 84, 91, 0.30);

  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-sm: 5px;

  --transition: 160ms ease;
}

/* ── Reset & base ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code,
pre,
.mono {
  font-family: var(--font-mono);
}

/* ── Layout shell ─────────────────────────────────────────────── */
.page-shell {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 40px;
}

/* ── Header ───────────────────────────────────────────────────── */
.site-header {
  margin-bottom: 36px;
}

.site-header .eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  padding: 3px 10px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
}

.site-header h1 {
  margin: 0 0 14px;
  font-size: clamp(1.8rem, 4.5vw, 2.4rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}

.site-header .lead {
  max-width: 620px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.65;
}

/* ── Controls ─────────────────────────────────────────────────── */
.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 20px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 550;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-primary {
  color: #111;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: #44444e;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* ── Status messages ──────────────────────────────────────────── */
.status-bar {
  margin-bottom: 28px;
}

.status-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.status-msg[hidden] {
  display: none;
}

.status-loading {
  color: #c5cbf8;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
}

.status-error {
  color: #fcc;
  background: var(--bad-bg);
  border: 1px solid var(--bad-border);
}

.status-error p {
  margin: 0;
}

.status-error p + p {
  margin-top: 8px;
}

/* spinner */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border: 2px solid rgba(197, 203, 248, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

/* ── Card grid ────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.card-grid.triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  min-width: 0;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.card-header {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: 0;
  color: var(--text);
}

/* ── Key-value lists ──────────────────────────────────────────── */
.kv-grid {
  display: grid;
  gap: 0;
  margin: 0;
}

.kv-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.44fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.kv-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.kv-row dt {
  color: var(--text-tertiary);
  font-size: 0.83rem;
  font-weight: 480;
  padding-top: 1px;
}

.kv-row dd {
  min-width: 0;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--text);
  overflow-wrap: anywhere;
}

.kv-row dd .muted {
  font-family: var(--font);
}

.muted {
  color: var(--text-tertiary);
}

/* ── IP groups ────────────────────────────────────────────────── */
.ip-groups {
  display: grid;
  gap: 12px;
}

.ip-group {
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
}

.ip-group h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
}

.ip-group .muted {
  margin: 0;
  color: var(--text-tertiary);
  font-family: var(--font);
  font-size: 0.84rem;
}

.ip-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.ip-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: rgba(0, 0, 0, 0.22);
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}

.ip-list li .item-meta {
  color: var(--text-tertiary);
  font-family: var(--font);
  font-size: 0.76rem;
  font-weight: 480;
}

/* ── Pills / tags ─────────────────────────────────────────────── */
.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  font-family: var(--font);
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 0.71rem;
  font-weight: 550;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
}

/* ── Risk card ────────────────────────────────────────────────── */
.risk-card {
  border-width: 2px;
}

.risk-card .card-header {
  margin-bottom: 10px;
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#riskDescription {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.risk-card h3 {
  margin: 16px 0 8px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.plain-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.plain-list li {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.55;
}

.plain-list li.muted {
  list-style: none;
  margin-left: -18px;
  color: var(--text-tertiary);
  font-style: italic;
}

/* Risk levels — JS sets risk-{level} on card + badge */
.risk-card.risk-low {
  border-color: var(--ok-border);
}
.risk-card.risk-low .risk-badge {
  color: var(--ok);
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
}

.risk-card.risk-medium-low {
  border-color: var(--warn-border);
}
.risk-card.risk-medium-low .risk-badge {
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
}

.risk-card.risk-medium {
  border-color: var(--bad-border);
}
.risk-card.risk-medium .risk-badge {
  color: var(--bad);
  background: var(--bad-bg);
  border: 1px solid var(--bad-border);
}

.risk-card.risk-high {
  border-color: var(--bad-border);
}
.risk-card.risk-high .risk-badge {
  color: #fff;
  background: var(--bad);
  border: 1px solid var(--bad);
}

/* ── Detail accordions ────────────────────────────────────────── */
.detail-card {
  margin-bottom: 16px;
  padding: 0;
  overflow: hidden;
}

.detail-card summary {
  padding: 18px 20px;
  font-weight: 650;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.detail-card summary:hover {
  color: var(--text);
}

.detail-card[open] summary {
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

/* Candidate items */
.candidate-list {
  display: grid;
  gap: 10px;
  padding: 20px;
}

.candidate-item {
  min-width: 0;
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
}

.candidate-item h3 {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.candidate-raw {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

/* JSON block */
.json-block {
  max-height: 520px;
  margin: 0;
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.28);
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

/* ── Footer ───────────────────────────────────────────────────── */
.footer-note {
  margin-top: 16px;
  padding: 14px 0;
  color: var(--text-tertiary);
  font-size: 0.82rem;
  line-height: 1.65;
  border-top: 1px solid var(--border);
}

.footer-note code {
  font-size: 0.8rem;
}

/* ── Privacy note (inline, subtle) ────────────────────────────── */
.privacy-note {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.privacy-note li {
  position: relative;
  padding-left: 14px;
  color: var(--text-tertiary);
  font-size: 0.78rem;
  line-height: 1.5;
}

.privacy-note li::before {
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 4px;
  height: 4px;
  content: "";
  background: var(--text-tertiary);
  border-radius: 50%;
  opacity: 0.5;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 780px) {
  .page-shell {
    width: min(100% - 28px, 1040px);
    padding: 32px 0 28px;
  }

  .card-grid,
  .card-grid.triple {
    grid-template-columns: 1fr;
  }

  .site-header h1 {
    font-size: 1.7rem;
  }

  .control-bar {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .kv-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .kv-row dt {
    font-size: 0.78rem;
  }

  .privacy-note {
    gap: 8px;
  }
}
