:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #dde1e8;
  --text: #161a22;
  --text-2: #4a5263;
  --muted: #6b7385;
  --accent: #2f6fdb;
  --accent-soft: #e4ecfb;
  --accent-ink: #1d4fa8;
  --db: #0f7c6e;
  --db-soft: #dcf2ee;
  --crit: #c4314b;
  --high: #c76a12;
  --mid: #8a7a10;
  --key: #a86b00;
  --key-soft: #fff1cc;
  --crit-soft: #fdecef;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #171b23; --surface-2: #1f2430; --border: #2b3240;
    --text: #e8ebf1; --text-2: #b4bccb; --muted: #8a93a5;
    --accent: #6b9cf0; --accent-soft: #1f2b44; --accent-ink: #a9c4f7;
    --db: #4cc3b0; --db-soft: #15312d;
    --crit: #f06a80; --high: #f0a050; --mid: #d6c450; --key: #f3c14b; --key-soft: #3a2f12; --crit-soft: #3a1b22;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #171b23; --surface-2: #1f2430; --border: #2b3240;
  --text: #e8ebf1; --text-2: #b4bccb; --muted: #8a93a5;
  --accent: #6b9cf0; --accent-soft: #1f2b44; --accent-ink: #a9c4f7;
  --db: #4cc3b0; --db-soft: #15312d;
  --crit: #f06a80; --high: #f0a050; --mid: #d6c450; --key: #f3c14b; --key-soft: #3a2f12; --crit-soft: #3a1b22;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.top__inner { max-width: 1480px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand svg { width: 30px; height: 30px; fill: var(--accent); flex: none; }
.brand h1 { font-size: 19px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.top__actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--accent); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
.badge:not(:empty) { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }

/* layout */
.layout { max-width: 1480px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.filters {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto;
}
.filters__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.filters__head h2 { font-size: 16px; }
.field { display: block; margin-bottom: 12px; }
.field__label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.field input, .years select, .sort select {
  width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 10px;
}
.field input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.years { display: flex; align-items: center; gap: 6px; color: var(--muted); }

.facet { border-top: 1px solid var(--border); padding: 8px 0; }
.facet > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 14px; padding: 4px 0; }
.facet > summary::-webkit-details-marker { display: none; }
.facet__sel { color: var(--accent); font-weight: 500; font-size: 12px; margin-left: auto; margin-right: 6px; }
.facet__search { width: 100%; margin: 4px 0 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.opts { display: flex; flex-direction: column; gap: 1px; }
.opt { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.opt:hover { background: var(--surface-2); }
.opt input { accent-color: var(--accent); margin: 0; flex: none; }
.opt__name { flex: 1; min-width: 0; }
.opt__n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.opt.is-zero { opacity: .45; }
.more { margin-top: 4px; font-size: 13px; }

/* presets */
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.preset {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 14px;
  cursor: pointer; font-size: 14px; display: inline-flex; gap: 6px; align-items: center;
}
.preset:hover { border-color: var(--accent); }
.preset.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.stat__num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat__lbl { color: var(--muted); font-size: 13px; }
.stat--chart { grid-column: 1 / -1; }
.chart { display: flex; align-items: flex-end; gap: 2px; height: 64px; margin-top: 8px; }
.bar { flex: 1; min-width: 2px; background: var(--accent); border-radius: 4px 4px 0 0; position: relative; cursor: pointer; }
.bar:hover, .bar.is-sel { background: var(--accent-ink); }
.bar.is-zero { background: var(--border); height: 2px !important; border-radius: 0; }
.chart__axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.toolbar__right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sort { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sort select { width: auto; color: var(--text); padding: 5px 8px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 10px; cursor: pointer; }
.seg button.is-on { background: var(--accent); color: #fff; }
.export { display: flex; gap: 6px; }
.chips-active { display: flex; flex-wrap: wrap; gap: 6px; }
.achip { background: var(--accent-soft); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 3px 10px; font-size: 13px; cursor: pointer; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; position: relative; overflow: hidden;
  text-align: left; width: 100%;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--sevc, var(--mid)); }
.card:hover { border-color: var(--accent); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card__meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.sev { font-weight: 600; color: var(--sevc); }
.card h3 { font-size: 16px; }
.card__org { color: var(--text-2); font-size: 13px; }
.card__sum { color: var(--text-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 0; }
.tag--type { background: var(--accent-soft); color: var(--accent-ink); }
button.tag { cursor: pointer; }
button.tag:hover { outline: 1px solid currentColor; }
.card__foot { margin-top: auto; font-size: 13px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 8px; }
.ru-flag { font-size: 11px; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }

/* table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; position: sticky; top: 0; background: var(--surface); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.foot { color: var(--muted); font-size: 12px; margin-top: 28px; border-top: 1px solid var(--border); padding-top: 12px; }

/* modal */
.modal { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(860px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); }
.modal::backdrop { background: rgba(10, 14, 22, .55); }
.modal__bar { display: flex; gap: 6px; justify-content: flex-end; padding: 10px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal article { padding: 16px 22px 24px; }
.modal h2 { font-size: 22px; margin: 6px 0 4px; }
.modal h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; }
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 6px 14px; margin-top: 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.modal p { margin: 0; }
.modal ul { margin: 0; padding-left: 20px; }
.modal li { margin: 3px 0; }
.src a { color: var(--accent); }
.mitre a { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; text-decoration: none; }

.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }

.only-mobile { display: none !important; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .only-mobile { display: inline-flex !important; }
  .filters {
    position: fixed; inset: 0; top: 0; max-height: none; z-index: 40; border-radius: 0; transform: translateX(-100%);
    transition: transform .2s; width: min(380px, 100vw);
  }
  .filters.is-open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
  .kv dt { margin-top: 8px; }
  .sub { display: none; }
  .presets { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .preset { flex: none; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat__lbl { font-size: 12px; }
  .stat--loss { grid-column: 1 / -1; }
  .stat__num { font-size: 22px; }
}

/* importance highlighting */
.key-badge { background: var(--key-soft); color: var(--key); font-weight: 700; border-radius: 999px; padding: 0 8px; font-size: 12px; white-space: nowrap; }
.card--crit { background: linear-gradient(180deg, var(--crit-soft), var(--surface) 70px); border-color: color-mix(in srgb, var(--crit) 35%, var(--border)); }
.card--crit::before { width: 6px; }
.card--key { box-shadow: 0 0 0 1px var(--key), var(--shadow); border-color: var(--key); }
.stat--crit .stat__num { color: var(--crit); }
.stat--key .stat__num { color: var(--key); }
.preset--key { border-color: var(--key); color: var(--key); font-weight: 700; }
.preset--key.is-on { background: var(--key); color: #fff; border-color: var(--key); }
.preset--crit { border-color: var(--crit); color: var(--crit); font-weight: 600; }
.preset--crit.is-on { background: var(--crit); color: #fff; border-color: var(--crit); }
.preset.is-on .opt__n { color: inherit; opacity: .85; }
.stat--loss .stat__num { color: var(--accent-ink); }
.loss { font-weight: 600; color: var(--text); white-space: nowrap; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- icons ---------- */
.ico { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.ico--xs { width: 12px; height: 12px; margin-left: 4px; vertical-align: -1px; opacity: .7; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: border-color .15s, background .15s, color .15s; }
.btn--square { width: 36px; height: 36px; padding: 0; }
.btn--square .ico { width: 18px; height: 18px; }
.link--icon { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; }
.link--icon .ico { width: 14px; height: 14px; }
.filters__head h2 { display: inline-flex; align-items: center; gap: 8px; }
.filters__head h2 .ico { color: var(--accent); }
.field__label { display: flex; align-items: center; gap: 5px; }
.field__label .ico { width: 13px; height: 13px; }
.field--search { position: relative; }
.field--search .input-ico { position: absolute; left: 10px; bottom: 9px; color: var(--muted); pointer-events: none; display: flex; }
.field--search input { padding-left: 34px; }

/* theme toggle: show the icon of the theme you would switch to */
.theme-ico { display: none; }
.theme-ico--moon { display: flex; }
:root[data-theme="dark"] .theme-ico--moon { display: none; }
:root[data-theme="dark"] .theme-ico--sun { display: flex; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-ico--moon { display: none; }
  :root:not([data-theme="light"]) .theme-ico--sun { display: flex; }
}

/* facets */
.facet > summary { gap: 8px; justify-content: flex-start; }
.facet__ico { color: var(--muted); width: 16px; height: 16px; }
.facet[open] .facet__ico, .facet:hover .facet__ico { color: var(--accent); }
.facet__title { flex: 1; }
.facet__sel { margin: 0; background: var(--accent); color: #fff; border-radius: 999px; min-width: 18px; height: 18px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.facet__chev { color: var(--muted); transition: transform .15s; }
.facet:not([open]) .facet__chev { transform: rotate(-90deg); }
.facet__search { padding-left: 8px; }

/* presets */
.preset .ico { color: var(--muted); width: 15px; height: 15px; }
.preset:hover .ico { color: var(--accent); }
.preset--key .ico, .preset--key:hover .ico { color: var(--key); }
.preset--crit .ico, .preset--crit:hover .ico { color: var(--crit); }
.preset.is-on .ico { color: inherit; }

/* stats */
.stat { position: relative; }
.stat__ico { position: absolute; top: 12px; right: 12px; width: 20px; height: 20px; color: var(--muted); opacity: .7; }
.stat--crit .stat__ico { color: var(--crit); opacity: 1; }
.stat--key .stat__ico { color: var(--key); opacity: 1; }
.stat--loss .stat__ico { color: var(--accent); opacity: 1; }
.stat--chart .stat__lbl { display: flex; align-items: center; gap: 6px; }

/* toolbar */
.sort .ico { color: var(--muted); }
.seg button { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 32px; padding: 0; color: var(--text-2); }
.seg button .ico { width: 17px; height: 17px; }
.seg button.is-on { color: #fff; }
.achip { display: inline-flex; align-items: center; gap: 5px; }
.achip .ico { width: 13px; height: 13px; }
.achip__x { opacity: .6; }
.achip:hover .achip__x { opacity: 1; }

/* cards & modal */
.card__meta .ico { width: 13px; height: 13px; vertical-align: -2px; }
.meta-i { display: inline-flex; align-items: center; gap: 3px; }
.sev { display: inline-flex; align-items: center; gap: 3px; }
.key-badge { display: inline-flex; align-items: center; gap: 3px; }
.key-badge .ico { width: 12px; height: 12px; fill: currentColor; }
.key-badge--only { padding: 2px 5px; }
.loss { display: inline-flex; align-items: center; gap: 4px; }
.loss .ico { width: 14px; height: 14px; color: var(--accent); }
.modal h3 { display: flex; align-items: center; gap: 7px; }
.modal h3 .ico { color: var(--accent); width: 15px; height: 15px; }
.src a { display: inline-flex; align-items: center; }
.empty__ico { width: 40px; height: 40px; color: var(--border); display: block; margin: 0 auto 8px; }
@media (max-width: 520px) { .sort__lbl { display: none; } }

/* option icons */
.opt__ico { display: inline-flex; color: var(--muted); }
.opt__ico .ico { width: 15px; height: 15px; }
.opt:hover .opt__ico { color: var(--text-2); }
.opt:has(input:checked) .opt__ico { color: var(--accent); }
.opt:has(input:checked) .opt__name { font-weight: 600; }
.opt.is-zero .opt__ico { opacity: .6; }
.achip .opt__ico { color: inherit; }
.achip .opt__ico .ico { width: 13px; height: 13px; }
