:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #15181d;
  --muted: #5b6472;
  --border: #dde1e7;
  --accent: #d9381e;
  --accent-text: #ffffff;
  --link: #1f5fbf;
  --focus: #2b6de0;

  --t-critical: #b3122b;
  --t-critical-bg: #fde7ea;
  --t-high: #c2410c;
  --t-high-bg: #ffedd5;
  --t-medium: #a16207;
  --t-medium-bg: #fef6d8;
  --t-low: #1d6b45;
  --t-low-bg: #dcf5e7;
  --t-info: #4b5563;
  --t-info-bg: #eceff3;

  --exploit: #b3122b;
  --ransom: #6d28d9;
  --ransom-bg: #ede4ff;
  --ok: #1d7a46;
  --warn: #a16207;
  --bad: #b3122b;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1d222b;
    --text: #e7eaee;
    --muted: #98a2b3;
    --border: #2a303b;
    --link: #7fb0ff;
    --focus: #7fb0ff;
    --t-critical: #ff8a9a;
    --t-critical-bg: #45121c;
    --t-high: #ffae7a;
    --t-high-bg: #43230f;
    --t-medium: #f5cf62;
    --t-medium-bg: #3b2f0b;
    --t-low: #7fd8a6;
    --t-low-bg: #10331f;
    --t-info: #b4bcc8;
    --t-info-bg: #262c36;
    --exploit: #ff8a9a;
    --ransom: #c4a6ff;
    --ransom-bg: #2c1f4d;
    --ok: #7fd8a6;
    --warn: #f5cf62;
    --bad: #ff8a9a;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161a21;
  --surface-2: #1d222b;
  --text: #e7eaee;
  --muted: #98a2b3;
  --border: #2a303b;
  --link: #7fb0ff;
  --focus: #7fb0ff;
  --t-critical: #ff8a9a;
  --t-critical-bg: #45121c;
  --t-high: #ffae7a;
  --t-high-bg: #43230f;
  --t-medium: #f5cf62;
  --t-medium-bg: #3b2f0b;
  --t-low: #7fd8a6;
  --t-low-bg: #10331f;
  --t-info: #b4bcc8;
  --t-info-bg: #262c36;
  --exploit: #ff8a9a;
  --ransom: #c4a6ff;
  --ransom-bg: #2c1f4d;
  --ok: #7fd8a6;
  --warn: #f5cf62;
  --bad: #ff8a9a;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, select, input { font: inherit; color: inherit; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.logo:hover { text-decoration: none; }
.logo-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: var(--accent-text); font: 700 12px var(--mono);
}
.stats { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.stats::-webkit-scrollbar { display: none; }
.stat {
  display: flex; align-items: baseline; gap: 6px; white-space: nowrap;
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; color: var(--muted); cursor: pointer;
}
.stat b { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.stat.crit b { color: var(--t-critical); }
.stat.expl b { color: var(--exploit); }
.stat.plain { cursor: default; }
.top-actions { display: flex; align-items: center; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.ghost { background: transparent; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.search { flex: 1 1 280px; min-width: 0; }
.search input {
  width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface);
}
.tier-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 12px; font-weight: 600; text-transform: capitalize;
}
.chip[aria-pressed="true"] { border-color: currentColor; }
.chip.t-critical[aria-pressed="true"] { background: var(--t-critical-bg); color: var(--t-critical); }
.chip.t-high[aria-pressed="true"] { background: var(--t-high-bg); color: var(--t-high); }
.chip.t-medium[aria-pressed="true"] { background: var(--t-medium-bg); color: var(--t-medium); }
.chip.t-low[aria-pressed="true"] { background: var(--t-low-bg); color: var(--t-low); }
.chip.t-info[aria-pressed="true"] { background: var(--t-info-bg); color: var(--t-info); }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.toggles { display: flex; gap: 12px; flex-wrap: wrap; }
.toggle { display: inline-flex; gap: 5px; align-items: center; font-size: 13px; cursor: pointer; user-select: none; }
.sort-row { display: flex; gap: 8px; margin-left: auto; }
select {
  padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
}

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; padding: 16px 20px; max-width: 1400px; margin: 0 auto; }
.sidebar { position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 80px); overflow-y: auto; padding-right: 4px; }
.facet { margin-bottom: 16px; }
.facet h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.facet ul { list-style: none; margin: 0; padding: 0; }
.facet li button {
  display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 8px;
  padding: 3px 8px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; text-align: left;
}
.facet li button:hover { background: var(--surface-2); }
.facet li button[aria-pressed="true"] { background: var(--surface-2); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.facet .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.facet .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet .more-btn { margin-top: 2px; border: 0; background: none; color: var(--link); cursor: pointer; padding: 2px 8px; font-size: 12px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.active-filters:empty { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; cursor: pointer;
}
.pill::after { content: "✕"; font-size: 10px; color: var(--muted); }
.pill.clear { background: transparent; color: var(--link); }
.pill.clear::after { content: ""; }

.result-bar { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* ---------- items ---------- */
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); overflow: hidden;
}
.card-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 5px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
}
.badge.tier-critical { background: var(--t-critical-bg); color: var(--t-critical); }
.badge.tier-high { background: var(--t-high-bg); color: var(--t-high); }
.badge.tier-medium { background: var(--t-medium-bg); color: var(--t-medium); }
.badge.tier-low { background: var(--t-low-bg); color: var(--t-low); }
.badge.tier-info { background: var(--t-info-bg); color: var(--t-info); }
.badge.cat { background: var(--surface-2); color: var(--muted); font-weight: 600; }
.badge.exploited { background: var(--exploit); color: #fff; }
.badge.ransom { background: var(--ransom-bg); color: var(--ransom); }
.badge.poc { background: var(--surface-2); color: var(--exploit); border: 1px solid var(--border); }
.badge.patch { background: var(--surface-2); color: var(--ok); border: 1px solid var(--border); }
.badge.kev { background: var(--t-critical-bg); color: var(--t-critical); }
.card h2 { margin: 0; font-size: 15px; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
.card h2 button { all: unset; cursor: pointer; }
.card h2 button:hover { text-decoration: underline; }
.card h2 button:focus-visible { outline: 2px solid var(--focus); }
.summary { margin: 4px 0 6px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12px; color: var(--muted); }
.score { font-family: var(--mono); font-size: 12px; color: var(--text); }
.score small { color: var(--muted); font-family: var(--font); }
.cves { display: flex; gap: 4px; flex-wrap: wrap; }
.cve { font-family: var(--mono); font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag {
  padding: 0 7px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 11.5px; cursor: pointer; color: var(--text); line-height: 20px;
}
.tag:hover { border-color: var(--muted); }
.tag.weak { background: transparent; color: var(--muted); }
.ext { margin-left: auto; }

.more { display: flex; justify-content: center; padding: 16px 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.skeleton { height: 92px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border: 1px solid var(--border); }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- dialogs ---------- */
.dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text);
  width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
}
.dialog.wide { width: min(1100px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(10, 12, 16, 0.55); }
.dialog-inner { position: relative; padding: 20px 22px; overflow-wrap: anywhere; }
.dialog-close { position: absolute; top: 12px; right: 12px; }
.dialog h2 { margin: 0 32px 8px 0; font-size: 18px; line-height: 1.35; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; margin: 14px 0; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; }
.detail-summary { white-space: pre-wrap; margin: 10px 0; }
.links { padding-left: 18px; margin: 6px 0; }
.links li { margin: 2px 0; }
.mono { font-family: var(--mono); font-size: 12px; }
.related { margin-top: 12px; }

.table-wrap { overflow-x: auto; }
table.src { width: 100%; border-collapse: collapse; font-size: 13px; }
table.src th, table.src td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.src th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
table.src td.num { text-align: right; font-variant-numeric: tabular-nums; }
.health { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-transform: capitalize; }
.health::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.health.ok::before { background: var(--ok); }
.health.failing::before { background: var(--bad); }
.health.stale::before { background: var(--warn); }
.err { color: var(--bad); font-size: 12px; }
.src-summary { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; color: var(--muted); }
.src-summary b { color: var(--text); }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 20px 40px; max-width: 900px; margin: 0 auto; }

.only-mobile { display: none; }
.scrim { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; }
  .only-mobile { display: inline-grid; }
  .sidebar-head.only-mobile { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(320px, 86vw); max-height: none; height: 100%;
    background: var(--surface); padding: 16px; border-right: 1px solid var(--border);
    transform: translateX(-105%); transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(10, 12, 16, 0.45); }
  .scrim[hidden] { display: none; }
  .top { padding: 8px 16px; gap: 10px; flex-wrap: wrap; }
  .stats { order: 3; flex-basis: 100%; }
  .top-actions { margin-left: auto; }
  .toolbar { padding: 10px 16px; }
  .sort-row { margin-left: 0; width: 100%; }
  .sort-row select { flex: 1; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dt { margin-top: 6px; }
  .logo-text { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
