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

:root {
  --bg:         #f4f5f7;
  --surface:    #ffffff;
  --border:     #dfe1e6;
  --text:       #172b4d;
  --text-muted: #6b778c;
  --radius:     8px;
  --font:       system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:       "Cascadia Code", "Fira Code", Consolas, monospace;

  --crit:       #c0392b;  --crit-bg:   #fdecea;  --crit-border: #e57373;
  --high:       #d35400;  --high-bg:   #fef3e2;  --high-border: #ffb74d;
  --med:        #9a6700;  --med-bg:    #fffde7;
  --low:        #2e7d32;  --low-bg:    #f1f8e9;
  --clean:      #1b6b3a;  --clean-dot: #36b37e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #1a1b1e;
    --surface:    #25262b;
    --border:     #373a40;
    --text:       #c1c2c5;
    --text-muted: #909296;
    --crit-bg:    #2c1212;  --crit-border: #7b2020;
    --high-bg:    #2c1f08;  --high-border: #7b4c10;
    --med-bg:     #252206;
    --low-bg:     #0d2010;
  }
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ───────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }

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

#status { font-size: 12px; color: var(--text-muted); }

button {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.1s;
}
button:hover  { background: var(--bg); }
button:active { opacity: 0.7; }

/* ── Main ─────────────────────────────── */
main {
  padding: 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.error-banner {
  background: var(--crit-bg);
  color: var(--crit);
  border: 1px solid var(--crit-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
}

/* ── Tabs ─────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 8px 18px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.1s;
}

.tab:hover { color: var(--text); background: none; }

.tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
  background: none;
}

.tab-panel { display: flex; flex-direction: column; gap: 16px; }

/* ── Cluster card ─────────────────────── */
.cluster-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cluster-card.severity-critical { border-color: var(--crit-border); }
.cluster-card.severity-high     { border-color: var(--high-border); }

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

.cluster-card.severity-critical .cluster-header { background: var(--crit-bg); border-bottom-color: var(--crit-border); }
.cluster-card.severity-high     .cluster-header { background: var(--high-bg); border-bottom-color: var(--high-border); }

.cluster-title { display: flex; align-items: center; gap: 8px; }

.cluster-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--clean-dot);
  flex-shrink: 0;
}

.cluster-card.severity-critical .cluster-dot { background: var(--crit); }
.cluster-card.severity-high     .cluster-dot { background: var(--high); }

.cluster-name  { font-weight: 600; font-size: 14px; }
.cluster-count { font-size: 12px; color: var(--text-muted); }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Table ────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

.mono  { font-family: var(--mono); font-size: 12px; }
.kind  { font-size: 12px; color: var(--text-muted); }
.image { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sev-col { text-align: center; width: 52px; }

/* ── Severity counts ──────────────────── */
.sev {
  display: inline-block;
  min-width: 28px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.sev-critical { background: var(--crit-bg); color: var(--crit); }
.sev-high     { background: var(--high-bg); color: var(--high); }
.sev-medium   { background: var(--med-bg);  color: var(--med);  }
.sev-low      { background: var(--low-bg);  color: var(--low);  }
.sev-zero     { color: var(--text-muted); font-size: 12px; }

tbody tr.clickable-row { cursor: pointer; }

/* ── Detail Drawer ─────────────────────── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
}

.drawer-overlay.open { display: block; }

.detail-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(580px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  overflow: hidden;
}

.detail-drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.drawer-meta  { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.drawer-title { font-weight: 700; font-size: 14px; }

.drawer-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-close {
  border: none;
  background: none;
  font-size: 16px;
  color: var(--text-muted);
  padding: 0 4px;
  flex-shrink: 0;
  line-height: 1;
}

.drawer-close:hover { color: var(--text); background: none; }

.drawer-content {
  overflow-y: auto;
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-loading {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── CVE items ────────────────────────── */
.cve-item {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
}

.cve-item.sev-critical { border-left-color: var(--crit); }
.cve-item.sev-high     { border-left-color: var(--high); }
.cve-item.sev-medium   { border-left-color: var(--med);  }
.cve-item.sev-low      { border-left-color: var(--low);  }

.cve-row1  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cve-id    { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.cve-score { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.cve-title { color: var(--text-muted); }

.cve-versions { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.cve-versions .arrow { margin: 0 4px; }
.cve-versions .fixed { color: var(--low); font-weight: 600; }

.cve-description {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.cve-action {
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
}

.cve-link a {
  font-size: 11px;
  color: #0052cc;
  text-decoration: none;
  overflow-wrap: break-word;
  word-break: break-all;
}

.cve-link a:hover { text-decoration: underline; }

@media (prefers-color-scheme: dark) {
  .cve-link a { color: #4c9aff; }
}
