:root {
  color-scheme: dark;
  --bg: #070b14;
  --surface: #0f172a;
  --surface-alt: #162033;
  --border: #26354d;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #10b981;
  --scrollbar-thumb: #475569;
  --scrollbar-track: #0f172a;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  accent-color: var(--accent);
}

@supports not (scrollbar-color: auto) {
  :root {
    scrollbar-width: auto;
  }
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }
  ::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
  }
  ::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
}

label.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

input,
select,
textarea {
  background: #090f1d;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  min-height: 38px;
}

button,
a.btn-secondary {
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
}

.btn-primary {
  background: #0284c7;
  color: #ffffff;
}

.btn-danger {
  background: #b91c1c;
  border-color: #ef4444;
  color: #ffffff;
}

.btn-secondary {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--text);
}

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 800;
}

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.topbar h1,
.auth-card h1 {
  margin: 0.2rem 0;
  font-size: 1.45rem;
}

.brand-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.soc-badge {
  background: #7f1d1d;
  border: 1px solid #ef4444;
  color: #fecaca;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.pulse-pill {
  background: #064e3b;
  border: 1px solid #10b981;
  color: #a7f3d0;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inline-date {
  font-size: 0.78rem;
}

.tab-bar {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.tab-bar [role="tab"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.tab-bar [role="tab"][aria-selected="true"] {
  background: #0c4a6e;
  border-color: var(--accent);
  color: #ffffff;
}

.banner {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.banner.error {
  background: #450a0a;
  border-color: #dc2626;
  color: #fecaca;
}

.banner.ok {
  background: #052e16;
  border-color: #10b981;
  color: #bbf7d0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.kpi-card.danger {
  border-color: #dc2626;
  background: #1c0b10;
}

.kpi-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.kpi-val {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0.25rem 0;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.card.alert-border {
  border-color: #dc2626;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-head.wrap {
  flex-wrap: wrap;
}

.card h2 {
  margin: 0;
  font-size: 1.08rem;
}

.filter-row,
.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 1rem;
}

.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(620px, 72vh);
  container-type: inline-size;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: #111c32;
}

th,
td {
  padding: 0.58rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

thead th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #93c5fd;
  white-space: nowrap;
}

tbody tr {
  background: var(--surface);
}

tbody tr:hover {
  background: #17233b;
}

tbody tr.clickable {
  cursor: pointer;
}

tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: inherit;
  font-weight: 700;
}

@container (width < 640px) {
  .stack-cards,
  .stack-cards thead,
  .stack-cards tbody,
  .stack-cards tr,
  .stack-cards th,
  .stack-cards td {
    display: block;
  }

  .stack-cards thead {
    display: none;
  }

  .stack-cards tr {
    margin-block-end: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem;
  }

  .stack-cards tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--surface-alt);
  }

  .stack-cards td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: var(--muted);
  }
}

.sev-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sev-critical {
  background: #7f1d1d;
  color: #fecaca;
  border: 1px solid #ef4444;
}

.sev-high {
  background: #78350f;
  color: #fde68a;
  border: 1px solid #f59e0b;
}

.sev-medium {
  background: #1e3a8a;
  color: #bfdbfe;
  border: 1px solid #3b82f6;
}

.sev-low {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #475569;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
}

.diag-box {
  background: #090f1d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  font-family: Consolas, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 360px;
}

dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 1.25rem;
  width: min(760px, calc(100vw - 2rem));
  max-height: 88dvh;
}

dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(2, 6, 23, 0.78);
  overflow: hidden;
  overscroll-behavior: contain;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}

.modal-head h1 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.evidence-pre {
  background: #090f1d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font-family: Consolas, monospace;
  font-size: 0.78rem;
  overflow: auto;
  max-height: 220px;
  margin: 0;
}

.auth-install-row {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.install-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.85rem;
}

.install-card {
  background: #0b1324;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.install-card h2 {
  margin: 0;
  font-size: 0.98rem;
  color: #f8fafc;
}

.install-card a.btn-primary {
  text-decoration: none;
  text-align: center;
}

.small {
  font-size: 0.76rem;
}
