:root {
  color-scheme: dark;
  --bg: #141018;
  --bg-2: #1c1824;
  --bg-3: #2a2434;
  --fg: #e8e4ef;
  --fg-2: #a39caf;
  --accent: #cba6ff;
  --ok: #74e0a3;
  --warn: #ffd36b;
  --bad: #ff6b8b;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.5 system-ui, -apple-system, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg-3);
}

header h1 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.05em;
}

#status {
  font-size: 12px;
  color: var(--fg-2);
  flex: 1;
}

button {
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }

button:disabled { opacity: 0.5; cursor: default; }
button:disabled:hover { border-color: transparent; }

#update-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--accent);
  font-size: 12px;
}

#update-banner[hidden] { display: none; }

#update-text {
  flex: 1;
  color: var(--fg);
}

#update-install { border-color: var(--accent); }

main {
  display: grid;
  grid-template-columns: 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

main:has(#detail-panel:not([hidden])) {
  grid-template-columns: 1fr 420px;
}

#list-panel { overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--bg-2);
  text-align: left;
  padding: 6px 10px;
  font-weight: 600;
  color: var(--fg-2);
  border-bottom: 1px solid var(--bg-3);
  z-index: 1;
}

/* Header filter controls. `position: sticky` already establishes a containing
   block, so the per-column popover anchors to its th. */
.th-inner {
  display: flex;
  align-items: center;
  gap: 4px;
}
.th-label { flex: 1; }

.th-filter-btn,
.th-clear-btn {
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--fg-2);
  padding: 0 3px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.th-filter-btn:hover,
.th-clear-btn:hover {
  border: none;
  color: var(--accent);
}

thead th.filtered { color: var(--accent); }
thead th.filtered .th-filter-btn { color: var(--accent); }

/* Floated above the trigger button; coordinates are set by positionPopover()
   in main.js so it can escape the scroll container's clipping. */
.th-popover {
  position: fixed;
  padding: 6px;
  background: var(--bg-3);
  border: 1px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  z-index: 10;
}
.th-popover[hidden] { display: none; }

.th-popover input,
.th-popover select {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--bg-3);
  border-radius: 3px;
  padding: 3px 6px;
  font-family: var(--mono);
  font-size: 12px;
}

tbody td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--bg-2);
}

/* Inset the last column so its filter trigger isn't overlapped by the
   vertical scrollbar of #list-panel. */
#apps thead th:last-child,
#apps tbody td:last-child {
  padding-right: 20px;
}

tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg-2); }
tbody tr.selected { background: var(--bg-3); }

td.name {
  font-family: system-ui, sans-serif;
  color: var(--fg);
}

td.version.stale { color: var(--warn); }
td.version.very-stale { color: var(--bad); }

.framework-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 11px;
  background: var(--bg-3);
}
/* settings dialog */
dialog {
  padding: 0;
  border: 1px solid var(--bg-3);
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--fg);
  max-width: 520px;
  width: 90vw;
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
#settings-form {
  display: flex;
  flex-direction: column;
}
#settings-form > header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg-3);
  display: flex;
  align-items: center;
  gap: 10px;
}
#settings-form h2 {
  margin: 0;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.05em;
  flex: 1;
}
#settings-close {
  background: transparent;
  border: none;
  color: var(--fg-2);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
#settings-form .source {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bg-3);
}
#settings-form .source--primary {
  background: linear-gradient(
    180deg,
    rgba(203, 166, 255, 0.08),
    rgba(203, 166, 255, 0.02)
  );
  border-left: 2px solid var(--accent);
}
#settings-form .source label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
#settings-form .source label.field {
  margin-top: 8px;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px;
  align-items: center;
}
#settings-form .source label.field span {
  color: var(--fg-2);
  font-size: 12px;
}
#settings-form input[type="text"],
#settings-form input[type="password"] {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--bg-3);
  border-radius: 3px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 12px;
  width: 100%;
}
#settings-form p.muted {
  color: var(--fg-2);
  font-size: 11px;
  margin: 4px 0 0;
}
#settings-path {
  padding: 10px 14px 0;
  font-size: 11px;
  font-family: var(--mono);
  word-break: break-all;
}
#settings-form > footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--bg-3);
}
.muted { color: var(--fg-2); }

.framework-tag.electron { background: #2a3a60; color: #9dc9ff; }
.framework-tag.tauri { background: #2a4030; color: #9dffc9; }
.framework-tag.cef { background: #4a2a3d; color: #ffc9e0; }
.framework-tag.chromiumbrowser { background: #2a3a55; color: #b5d3ff; }
.framework-tag.nwjs { background: #603820; color: #ffc79d; }
.framework-tag.flutter { background: #184a60; color: #9de0ff; }
.framework-tag.qt { background: #204a2a; color: #b5ffaa; }
.framework-tag.reactnative { background: #204a55; color: #9deff5; }
.framework-tag.wails { background: #60282a; color: #ffaab0; }
.framework-tag.sciter { background: #3a2060; color: #d5aaff; }
.framework-tag.java { background: #5a4018; color: #ffd69d; }
.framework-tag.safari { background: #18425a; color: #9ddbff; }
.framework-tag.native { background: var(--bg-3); color: var(--fg-2); }
.framework-tag.unknown { background: var(--bg-3); color: var(--fg-2); }

.risk {
  display: inline-block;
  min-width: 4em;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  text-align: center;
  font-weight: 600;
}
.risk.ok { background: #1a3a28; color: var(--ok); }
.risk.warn { background: #3d321a; color: var(--warn); }
.risk.bad { background: #3a1a28; color: var(--bad); }
.risk.unknown { background: var(--bg-3); color: var(--fg-2); }

#detail-panel {
  background: var(--bg-2);
  border-left: 1px solid var(--bg-3);
  overflow: auto;
  display: flex;
  flex-direction: column;
}

/* `display: flex` above would silently override the [hidden] attribute's
   default. Restore correct hiding so a closed panel is fully removed from
   layout (no reserved column, no residual flex box). */
#detail-panel[hidden] {
  display: none !important;
}

#detail-panel header {
  border-bottom: 1px solid var(--bg-3);
}

#detail-panel h2 {
  flex: 1;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

#detail-body {
  padding: 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

#detail-body h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin: 16px 0 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
#detail-body h3:first-child { margin-top: 0; }

#detail-body dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 12px;
  row-gap: 3px;
  margin: 0;
}

#detail-body dt {
  color: var(--fg-2);
}
#detail-body dd {
  margin: 0;
  word-break: break-all;
}

#detail-body .ok { color: var(--ok); }
#detail-body .warn { color: var(--warn); }
#detail-body .bad { color: var(--bad); }

#detail-body ul {
  margin: 4px 0;
  padding-left: 18px;
}

#detail-body .advisory {
  margin: 4px 0;
  padding: 6px 8px;
  background: var(--bg-3);
  border-radius: 3px;
  border-left: 2px solid var(--fg-2);
  /* Rule ids, asar file paths and code samples are long unbroken tokens; wrap
     them so a finding can't push the detail panel into horizontal scroll. */
  overflow-wrap: anywhere;
}
#detail-body .advisory.high { border-left-color: var(--bad); }
#detail-body .advisory.critical { border-left-color: var(--bad); }
#detail-body .advisory.medium { border-left-color: var(--warn); }

/* Collapsible advisories: the CVE id shows in the summary; the description
   reveals on expand. */
#detail-body details.advisory > summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}
#detail-body details.advisory > summary::-webkit-details-marker { display: none; }
#detail-body details.advisory > summary::before {
  content: "▸ ";
  color: var(--fg-2);
}
#detail-body details.advisory[open] > summary::before { content: "▾ "; }
#detail-body .advisory-body {
  margin-top: 6px;
  color: var(--fg-2);
  white-space: pre-wrap;
}

/* Runtime / dependency CVE tabs. The list can run to hundreds of entries, so
   only the active panel is shown at a time. */
#detail-body .cve-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 8px;
  border-bottom: 1px solid var(--bg-3);
}
#detail-body .cve-tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 5px 8px;
  margin-bottom: -1px;
  color: var(--fg-2);
  font-family: var(--mono);
}
#detail-body .cve-tab:hover {
  border-color: transparent;
  color: var(--fg);
}
#detail-body .cve-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
#detail-body .cve-panel { display: none; }
#detail-body .cve-panel.active { display: block; }

/* Briefly highlight an advisory a background EUVD update just added to the open
   app, so a newly-published vulnerability is noticeable without the pane
   jumping. */
@keyframes achilles-flash-new {
  from { background: color-mix(in srgb, var(--accent) 38%, transparent); }
  to { background: transparent; }
}
#detail-body .advisory.flash-new { animation: achilles-flash-new 2.4s ease-out; }

/* Web-only EUVD snapshot controls, nested under the EUVD source entry in the
   settings dialog and collapsed (hidden) when EUVD is unchecked. */
#euvd-snapshot-settings {
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid var(--bg-3);
}
#euvd-snapshot-settings[hidden] { display: none; }
#euvd-snapshot-settings label { display: block; margin: 6px 0; }
#euvd-snapshot-settings p { margin: 6px 0; }
