/* CVE Patcher. One stylesheet, no build step. Tokens first; light and dark themes. */

:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #101828;
  --muted: #667085;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #ffffff;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(16 24 40 / 5%);
  --shadow-hover: 0 4px 12px rgb(16 24 40 / 10%);
  /* Severity: text on a tint for chips, solid for bars. */
  --sev-critical: #b42318;
  --sev-critical-bg: #fee4e2;
  --sev-critical-bar: #d92d20;
  --sev-high: #c4320a;
  --sev-high-bg: #ffead5;
  --sev-high-bar: #f97316;
  --sev-medium: #93370d;
  --sev-medium-bg: #fef0c7;
  --sev-medium-bar: #eab308;
  --sev-low: #344054;
  --sev-low-bg: #eaecf0;
  --sev-low-bar: #98a2b3;
  --sev-unscored: #475467;
  --sev-unscored-bg: #f2f4f7;
  --sev-unscored-bar: #d0d5dd;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c111d;
    --surface: #161b26;
    --surface-2: #1b2130;
    --text: #f5f5f6;
    --muted: #94969c;
    --border: #2b3240;
    --border-strong: #3b4354;
    --accent: #8098f9;
    --accent-hover: #a4bcfd;
    --accent-soft: #1f2347;
    --accent-text: #0c111d;
    --ok: #47cd89;
    --ok-bg: #0b2a1c;
    --warn: #fdb022;
    --warn-bg: #2d1f08;
    --danger: #f97066;
    --danger-bg: #331414;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-hover: 0 4px 16px rgb(0 0 0 / 45%);
    --sev-critical: #fda29b;
    --sev-critical-bg: #3b1513;
    --sev-critical-bar: #f04438;
    --sev-high: #feb273;
    --sev-high-bg: #3a1d0b;
    --sev-high-bar: #fb6514;
    --sev-medium: #fde272;
    --sev-medium-bg: #332a0b;
    --sev-medium-bar: #eaaa08;
    --sev-low: #cecfd2;
    --sev-low-bg: #262c38;
    --sev-low-bar: #85888e;
    --sev-unscored: #a8acb4;
    --sev-unscored-bg: #222733;
    --sev-unscored-bar: #4a5263;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px / 1.5 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

code {
  font:
    0.86em / 1.4 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
}

h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.6rem;
  margin: 0;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
}

h3 {
  font-size: 0.95rem;
  margin: 20px 0 8px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
  padding: 10px max(16px, calc((100vw - 1180px) / 2));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.brand svg {
  color: var(--accent);
}

.topbar nav {
  display: flex;
  gap: 4px;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 500;
}

.topbar nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.topbar nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.signout {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

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

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 16px 64px;
}

/* Page head and sections */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 20px;
}

.page-head p {
  margin: 4px 0 0;
}

.crumb {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.crumb a {
  color: var(--muted);
  text-decoration: none;
}

.crumb a:hover {
  color: var(--accent);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 8px 0 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 32px 0 12px;
  font-size: 1rem;
}

/* Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}

.card + .card {
  margin-top: 16px;
}

.card.narrow {
  max-width: 460px;
  margin: 56px auto;
}

.card.empty {
  text-align: center;
  padding: 40px 24px;
}

.card.empty p {
  margin: 0 auto;
  max-width: 560px;
  color: var(--muted);
}

.card.empty p.actions,
p.actions {
  margin-top: 16px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 8px;
}

.card-head h2 {
  margin: 0;
}

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

.grid .card,
.grid .card + .card {
  margin: 0;
}

.health-grid {
  align-items: start;
}

details.images summary {
  cursor: pointer;
}

/* Stat tiles */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.stat.danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  background: var(--danger-bg);
}

.stat.danger .stat-value {
  color: var(--danger);
}

.stat.warn .stat-value {
  color: var(--warn);
}

.stat.ok .stat-value {
  color: var(--ok);
}

/* Repo grid */

.installation + .installation {
  margin-top: 8px;
}

.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.repo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  transition:
    box-shadow 0.15s,
    border-color 0.15s;
}

.repo-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}

.repo-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--border);
}

.repo-card.urgent::before {
  background: var(--sev-critical-bar);
}

.repo-card.needs::before {
  background: var(--sev-high-bar);
}

.repo-card.clear::before {
  background: var(--ok);
}

.repo-card header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.repo-card header a {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
  margin-right: auto;
}

.repo-card header a:hover {
  color: var(--accent);
}

/* The whole card is a link target for pointer users; the name link stays the real one. */
.repo-card header a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.repo-card form,
.repo-card .badge {
  position: relative;
  z-index: 1;
}

.headline {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.headline .figure {
  font-size: 2rem;
  font-weight: 750;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.headline .figure.danger {
  color: var(--sev-critical);
}

.headline .figure.warn {
  color: var(--sev-high);
}

.headline .figure.ok {
  color: var(--ok);
}

.headline .label {
  font-weight: 600;
}

.repo-card .status {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.repo-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.repo-foot strong {
  color: var(--text);
  font-weight: 600;
}

.repo-foot .when {
  margin-left: auto;
}

/* Severity: bar, chips, legend */

.sevbar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.sevbar span {
  display: block;
  min-width: 4px;
}

.sevbar .critical {
  background: var(--sev-critical-bar);
}

.sevbar .high {
  background: var(--sev-high-bar);
}

.sevbar .medium {
  background: var(--sev-medium-bar);
}

.sevbar .low {
  background: var(--sev-low-bar);
}

.sevbar .unscored {
  background: var(--sev-unscored-bar);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sev {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.5;
  padding: 0 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.sev-critical {
  color: var(--sev-critical);
  background: var(--sev-critical-bg);
}

.sev-high {
  color: var(--sev-high);
  background: var(--sev-high-bg);
}

.sev-medium {
  color: var(--sev-medium);
  background: var(--sev-medium-bg);
}

.sev-low {
  color: var(--sev-low);
  background: var(--sev-low-bg);
}

.sev-unscored {
  color: var(--sev-unscored);
  background: var(--sev-unscored-bg);
}

/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.6;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
  vertical-align: middle;
}

.badge.ok {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: transparent;
}

.badge.warn,
.badge.nofix {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: transparent;
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: transparent;
}

.badge.qualifies {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.badge.state-open {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: transparent;
}

.badge.state-merged {
  color: #6941c6;
  background: #f4ebff;
  border-color: transparent;
}

@media (prefers-color-scheme: dark) {
  .badge.state-merged {
    color: #d6bbfb;
    background: #2c1c5f;
  }
}

/* Buttons */

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.button:hover,
button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.button:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button.primary,
button.primary {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.button.primary:hover,
button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.repo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.repo-actions form {
  margin: 0;
}

/* Notices */

.banner {
  background: var(--warn-bg);
  color: var(--warn);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  text-align: center;
  font-weight: 600;
}

.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 0 16px;
}

.notice.error {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.notice.warn {
  border-left-color: var(--warn);
  background: var(--warn-bg);
}

/* Tables */

.table-wrap {
  overflow-x: auto;
  margin: 0 -24px;
  padding: 0 24px;
}

table.findings,
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.findings th,
.findings td,
.data th,
.data td {
  text-align: left;
  vertical-align: top;
  padding: 10px 12px 10px 0;
  border-top: 1px solid var(--border);
}

.findings th,
.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-top: 0;
  padding-top: 4px;
}

.findings tbody tr:hover,
.data tbody tr:hover {
  background: var(--surface-2);
}

.findings .title {
  max-width: 44ch;
  margin-top: 2px;
}

table.findings a {
  font-weight: 600;
}

.findings td:nth-child(3) {
  min-width: 15ch;
}

/* Directory cards on the repo page */

.set-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 4px;
}

.set-head h2 {
  margin: 0;
}

.set-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.qualifying {
  margin: 8px 0 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: 0.9rem;
}

details.ignore {
  margin-top: 6px;
}

details.ignore summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
}

details.ignore form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-top: 8px;
}

details.ignore label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

input[name="reason"],
form.settings input[type="url"] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

input[name="reason"] {
  min-width: 260px;
}

.reason {
  margin-top: 4px;
  font-style: italic;
  color: var(--muted);
}

/* Fix PR rows */

.pr-number {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Timeline (activity) */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 4px 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.timeline li:first-child {
  border-top: 0;
}

.timeline .when {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.timeline .what {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline .what .line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

@media (max-width: 640px) {
  .timeline li {
    grid-template-columns: 1fr;
  }
}

/* Forms (settings) */

form.settings label {
  display: block;
  margin: 12px 0;
  font-weight: 600;
}

form.settings input[type="url"] {
  display: block;
  width: 100%;
  max-width: 640px;
  margin-top: 6px;
  font-weight: normal;
}

label.check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: normal !important;
}

/* Sign-in */

.signin {
  max-width: 440px;
  margin: 72px auto;
  text-align: center;
}

.signin .logo {
  display: inline-flex;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 16px;
}

.signin h1 {
  margin-bottom: 8px;
}

.signin p {
  color: var(--muted);
}

.signin .button {
  margin-top: 12px;
  width: 100%;
  padding: 12px;
}

/* Health page: CPU and memory meters */

.resource-row + .resource-row {
  margin-top: 12px;
}

.meter {
  display: block;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* Work in progress: the home page panel and per-repo chips */

.card.progress {
  border-left: 4px solid var(--accent);
  margin-bottom: 24px;
}

.card.progress h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.worklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.worklist li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 0.9rem;
}

.worklist a {
  overflow-wrap: anywhere;
}

.chips.work .badge {
  white-space: normal;
}

/* Rescan spinner */

.spinner {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -0.1em;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }

  .repo-card {
    transition: none;
  }
}

@media (max-width: 640px) {
  .card {
    padding: 16px;
  }

  .table-wrap {
    margin: 0 -16px;
    padding: 0 16px;
  }

  .signout .who {
    display: none;
  }
}

/* The repo's fix PR (D-107) and its AI-written description (D-108). */
.fix-pr-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 12px;
}

.ai-summary {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 14px;
}

.ai-summary p {
  margin: 0 0 6px;
}

.ai-summary .ai-label {
  font-weight: 600;
}

.ai-summary .ai-text {
  white-space: pre-line;
}

.build {
  border-top: 1px solid var(--border);
  margin-top: 16px;
  padding-top: 14px;
}

.build h3 {
  margin: 0 0 8px;
}

.build-progress {
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
  margin-bottom: 10px;
}

.build-items {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.build-items li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.build-items li:last-child {
  border-bottom: 0;
}

details.earlier {
  margin-top: 14px;
}

details.earlier summary {
  cursor: pointer;
  color: var(--muted);
}
