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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e2e4ed;
  --muted: #7c7f93;
  --pass: #4ade80;
  --fail: #f87171;
  --accent: #6366f1;
  --radius: 6px;
  font-size: 14px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

select, button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

select:focus, button:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

button:hover { opacity: 0.85; }

main {
  padding: 24px;
}

/* ── Summary section ─────────────────────────────────────────────────────── */

#summary { margin-bottom: 8px; }

.stat-cards {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.charts-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.chart-timeline-box { flex: 2; height: 260px; }
.chart-donut-box    { flex: 1; height: 260px; }

.chart-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.top-lists {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.top-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.top-list-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.top-list table { font-size: 12px; }

.top-list td {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.top-list tr:last-child td { border-bottom: none; }

.top-count {
  color: var(--muted);
  padding-left: 12px;
  white-space: nowrap;
}

.top-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.no-data { font-size: 12px; padding: 8px 0; }

.section-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.status {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.status.error { background: #3b1f1f; border: 1px solid #7f3535; color: var(--fail); }
.status.info  { background: #1f2b3b; border: 1px solid #354060; color: #93c5fd; }
.hidden { display: none; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.num, td.num { text-align: right; }
th.expand-col { width: 32px; }

tbody tr.report-row {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

tbody tr.report-row:hover { background: var(--surface); }

tbody tr.detail-row { background: #13151f; }
tbody tr.detail-row td { padding: 0; }

tbody tr.detail-row.hidden { display: none; }

td {
  padding: 10px 12px;
  vertical-align: top;
}

.loading { color: var(--muted); padding: 24px; text-align: center; }

.pass { color: var(--pass); }
.fail { color: var(--fail); }

.pass-badge, .fail-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.pass-badge { background: #14532d; color: var(--pass); }
.fail-badge { background: #450a0a; color: var(--fail); }

.expand-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
}

.expand-btn:hover { color: var(--text); }

.detail-inner {
  padding: 12px 24px 16px;
}

.detail-inner table {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
}

.detail-inner thead th {
  background: #22253a;
  border-bottom: 2px solid #4a4d65;
  padding: 8px 12px;
}

.detail-inner tbody td {
  padding: 11px 12px;
  vertical-align: middle;
}

.detail-inner th:nth-child(2),
.detail-inner td:nth-child(2) {
  width: 70px;
  min-width: 70px;
  padding-right: 20px;
}

.detail-inner tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.04);
}

.detail-inner tbody tr + tr td {
  border-top: 1px solid #3a3d52;
}

.policy-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.policy-none       { background: #2a2500; color: #facc15; }
.policy-quarantine { background: #2a1800; color: #fb923c; }
.policy-reject     { background: #1a0000; color: var(--fail); }

.auth-cell { vertical-align: top; }

.ip-cell { min-width: 200px; vertical-align: top; }
.ip-addr { font-family: ui-monospace, 'SF Mono', monospace; }
.ip-secondary { font-size: 11px; color: var(--muted); margin-top: 3px; }

.auth-raw {
  font-size: 11px;
  margin-top: 4px;
  color: var(--muted);
}

.auth-raw.pass { color: var(--pass); }
.auth-raw.fail { color: var(--fail); }
.muted-text    { color: var(--muted); }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
  }

  .controls {
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  main { padding: 16px; }

  .stat-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .charts-row { flex-direction: column; }

  .chart-timeline-box,
  .chart-donut-box {
    flex: none;
    width: 100%;
  }

  .chart-donut-box { height: 220px; }

  .top-lists { grid-template-columns: 1fr 1fr; }

  /* hide Reporter and Policy columns */
  thead th:nth-child(2),
  tbody td:nth-child(2),
  thead th:nth-child(4),
  tbody td:nth-child(4) { display: none; }

  .detail-inner { padding: 10px 12px 14px; overflow-x: auto; }
}

@media (max-width: 480px) {
  main { padding: 12px; }

  /* also hide Date range column */
  thead th:nth-child(3),
  tbody td:nth-child(3) { display: none; }

  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 22px; }

  .top-lists { grid-template-columns: 1fr; }
}
