:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #607089;
  --line: #dce3ee;
  --accent: #2563eb;
  --accent-soft: #e8f0ff;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
  --ui-zoom: 1;
  --sev-high: #dc3545;
  --sev-high-bg: #fde8ea;
  --sev-medium: #f97316;
  --sev-medium-bg: #fff7ed;
  --sev-low: #eab308;
  --sev-low-bg: #fefce8;
  --sev-info: #3b82f6;
  --sev-info-bg: #eff6ff;
  --archive-badge: #8b5cf6;
  --archive-badge-bg: #f3e8ff;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b23;
  --text: #e6edf3;
  --muted: #8b949e;
  --line: #30363d;
  --accent: #58a6ff;
  --accent-soft: #102a44;
  --shadow: none;
  --sev-high-bg: #2d1518;
  --sev-medium-bg: #2d1f10;
  --sev-low-bg: #2d2a10;
  --sev-info-bg: #101c2d;
  --archive-badge-bg: #1e1430;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
  zoom: var(--ui-zoom);
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 32px clamp(20px, 4vw, 56px) 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.header-actions .status { margin-left: auto; }

.header-btn {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.header-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.zoom-control { display: inline-flex; gap: 6px; }
.zoom-control button { min-width: 34px; padding-inline: 8px; }

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 11px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
}

.disclaimer {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.disclaimer a { color: var(--accent); font-weight: 800; text-decoration: none; }
.disclaimer a:hover { text-decoration: underline; }

.status {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(20px, 4vw, 56px) 48px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) minmax(260px, 1.7fr);
  gap: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

select, input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  padding: 9px 11px;
}
select:focus, input:focus {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.summary > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.summary span { display: block; font-size: 28px; font-weight: 800; }
.summary small { color: var(--muted); }
.summary .api-link a {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
}

.list-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.list-head, .record {
  display: grid;
  grid-template-columns: 40px 84px minmax(150px, 220px) minmax(200px, 0.8fr) minmax(180px, 1fr) minmax(260px, 1.4fr) minmax(180px, 0.9fr);
  align-items: center;
  gap: 10px;
}

.list-head {
  min-height: 36px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, var(--accent-soft));
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.record {
  min-height: 44px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.record:last-child { border-bottom: 0; }
.record:nth-child(even) { background: color-mix(in srgb, var(--bg) 50%, var(--panel) 50%); }
.record:hover { background: color-mix(in srgb, var(--panel) 80%, var(--accent) 20%); }

.indicator {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 15px;
}
.indicator.sev-High { background: var(--sev-high-bg); }
.indicator.sev-Medium { background: var(--sev-medium-bg); }
.indicator.sev-Low { background: var(--sev-low-bg); }
.indicator.sev-Informational { background: var(--sev-info-bg); }

.cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell.severity {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.cell.severity.sev-High { color: var(--sev-high); }
.cell.severity.sev-Medium { color: var(--sev-medium); }
.cell.severity.sev-Low { color: var(--sev-low); }
.cell.severity.sev-Informational { color: var(--sev-info); }

.cell.alert-id {
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 12px;
  color: var(--muted);
}

.cell.alert-name {
  font-size: 14px;
  font-weight: 600;
}

.cell.mitre-tactics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mitre-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.cell.description {
  color: var(--muted);
  font-size: 13px;
}

.cell.source-type {
  font-size: 11px;
  white-space: nowrap;
}
.source-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.source-type-badge.ms-learn {
  background: var(--accent-soft);
  color: var(--accent);
}
.source-type-badge.archive {
  background: var(--archive-badge-bg);
  color: var(--archive-badge);
}
.source-type-badge.deprecated {
  background: var(--danger-soft);
  color: var(--danger);
}
.source-type-badge.observed {
  background: #e0f2fe;
  color: #0369a1;
}

[data-theme="dark"] .source-type-badge.observed {
  background: #0c2d3f;
  color: #7dd3fc;
}

[data-density="expanded"] .record {
  align-items: start;
  min-height: 72px;
  padding-block: 11px;
}
[data-density="expanded"] .cell {
  overflow: visible;
  text-overflow: initial;
  white-space: normal;
}
[data-density="expanded"] .description { line-height: 1.45; }

.empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.markdown-output {
  padding: 16px;
  margin: 0;
  overflow-x: auto;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.disclaimer-dialog {
  width: min(640px, 92vw);
  max-height: 85vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
.disclaimer-dialog::backdrop { background: rgba(13, 17, 23, 0.55); }
.disclaimer-dialog .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.disclaimer-dialog h2 { margin: 0; font-size: 20px; }
.disclaimer-dialog .dialog-body { padding: 20px 22px 24px; overflow-y: auto; }
.disclaimer-dialog .dialog-body p { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.disclaimer-dialog h3 { margin: 0 0 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; color: var(--accent); }

.source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 18px;
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
}
.source-list a { color: var(--accent); text-decoration: none; }
.source-list a:hover { text-decoration: underline; }

@media (max-width: 520px) { .source-list { grid-template-columns: 1fr; } }

@media (max-width: 920px) {
  :root { --ui-zoom: 0.92; }
  .app-header { display: block; }
  .header-actions { margin-top: 12px; }
  .status { text-align: left; }
  .filters, .summary { grid-template-columns: 1fr; }
  .list-shell { overflow-x: auto; }
  .list-head, .record { min-width: 960px; }
}
