:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --link: #58a6ff;
  --btn: #238636;
  --btn-hover: #2ea043;
  --critical: #ff7b72;
  --high: #ffa657;
  --medium: #d29922;
  --low: #3fb950;
  --kev: #f85149;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.header {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}

.brand:hover { color: var(--link); }

.header-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.main {
  flex: 1;
  padding: 2rem 0 3rem;
}

.intro {
  margin-bottom: 1.5rem;
}

.intro h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.intro p {
  margin: 0;
  color: var(--text-muted);
  max-width: 36rem;
}

.cache-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.cache-item { display: flex; gap: 0.4rem; }
.cache-label { color: var(--text-muted); }
.cache-value { color: var(--text); }

.card {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 1.25rem;
}

.form-section + .form-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.section-title {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.section-hint {
  margin: -0.25rem 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.field-grid {
  display: grid;
  gap: 0.75rem;
}

.field-grid.two {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.node-os-field {
  margin-bottom: 0.75rem;
  max-width: 320px;
}

.field-grid.three {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

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

.field label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.field input,
.field select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field input:focus,
.field select:focus {
  outline: 1px solid var(--link);
  border-color: var(--link);
}

.form-actions { margin-top: 1.25rem; }

.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--btn);
  color: #fff;
  border-color: rgba(240,246,252,0.1);
}

.btn-primary:hover { background: var(--btn-hover); }

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

.btn-ghost:hover { border-color: var(--text-muted); }

.results-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.results-top h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.results-top p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

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

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.8125rem;
  min-width: 0;
}

.stat-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-right: 0;
}

.stat-value {
  display: block;
  font-weight: 500;
  word-break: break-word;
}

.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }

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

table.findings th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
}

table.findings td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.findings tbody tr:last-child td { border-bottom: none; }

.cve-link {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
}

.cve-link:hover { text-decoration: underline; }

.cve-desc {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

code.ver {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.epss { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }

.tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  white-space: nowrap;
  line-height: 1.25;
}

table.findings td:has(.tag) {
  white-space: nowrap;
  width: 1%;
}

.tag-kev {
  background: rgba(248, 81, 73, 0.1);
  color: var(--kev);
  border-color: rgba(248, 81, 73, 0.3);
}

.tag-remote {
  background: rgba(255, 166, 87, 0.08);
  color: var(--high);
  border-color: rgba(255, 166, 87, 0.25);
}

.sev-critical { color: var(--critical); border-color: rgba(255,123,114,.3); background: rgba(255,123,114,.08); }
.sev-high     { color: var(--high);     border-color: rgba(255,166,87,.3);  background: rgba(255,166,87,.08); }
.sev-medium   { color: var(--medium);   border-color: rgba(210,153,34,.3);  background: rgba(210,153,34,.08); }
.sev-low      { color: var(--low);      border-color: rgba(63,185,80,.3);   background: rgba(63,185,80,.08); }
.sev-unknown  { color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
}

.empty-state h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.empty-state p {
  margin: 0;
  color: var(--text-muted);
}

.error-state {
  max-width: 32rem;
}

.error-state h1 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.error-state p {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
}

.error-hint {
  font-size: 0.8125rem;
}

.error-state .btn {
  margin-top: 0.5rem;
}

.footer {
  padding: 1rem 0 1.5rem;
  border-top: 1px solid var(--border);
}

.footer-row p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Mobile */
@media (max-width: 768px) {
  .container {
    padding: 0;
    max-width: none;
  }

  .header-row,
  .footer-row,
  .intro,
  .results-top,
  .error-state {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .main {
    padding: 1.25rem 0 2rem;
  }

  .intro h1,
  .results-top h1 {
    font-size: 1.25rem;
  }

  .header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .header-sub {
    font-size: 0.8125rem;
  }

  .card {
    padding: 1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .stat-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 1rem;
  }

  .stat {
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .stat + .stat {
    border-top: none;
  }

  .cache-bar {
    flex-direction: column;
    gap: 0.35rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin-left: 0;
    margin-right: 0;
  }

  .field-grid.three,
  .field-grid.two,
  .component-grid {
    grid-template-columns: 1fr;
  }

  .field input,
  .field select {
    font-size: 16px; /* prevent iOS zoom on focus */
  }

  .form-actions .btn-primary {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.65rem 1rem;
  }

  .results-top {
    flex-direction: column;
    align-items: stretch;
  }

  .results-top .btn-ghost {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.55rem 1rem;
  }

  .cache-item {
    flex-wrap: wrap;
  }

  .table-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  /* Match .card inner padding on mobile */
  .table-scroll {
    overflow-x: visible;
    padding: 1rem;
  }

  table.findings thead {
    display: none;
  }

  table.findings tbody tr {
    display: block;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
  }

  table.findings tbody tr:last-child {
    border-bottom: none;
  }

  table.findings td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: none;
    text-align: right;
    width: auto;
  }

  table.findings td:has(.tag) {
    width: auto;
    flex-wrap: nowrap;
  }

  table.findings td:has(.tag) .tag {
    flex-shrink: 0;
  }

  table.findings td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: left;
    min-width: 4.5rem;
  }

  table.findings td.cve-cell {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    padding-top: 0;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
  }

  table.findings td.cve-cell::before {
    display: none;
  }

  table.findings td.cve-cell .cve-link {
    font-size: 0.9375rem;
  }
}
