:root {
  --bg: #0f1115;
  --card: #171a21;
  --border: #2a2e38;
  --text: #e6e8eb;
  --muted: #8a93a3;
  --accent: #5b8def;
  --green: #3ec97c;
  --red: #f0616d;
  --amber: #e8b339;
  --orange: #ff8a4c;
  --teal: #3ecfcf;
  --surface-2: #0f1115;
  --surface-3: #1c2029;
}

* { box-sizing: border-box; }

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

.topbar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
}

.brand span {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
  margin-left: 8px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

h1 { margin-top: 0; font-size: 20px; }
h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 0; }

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="file"], input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  background: #0f1115;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover { opacity: .9; }

table.tasks {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.tasks th, table.tasks td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

table.tasks th { color: var(--muted); font-weight: 500; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-queued { background: #2a2e38; color: var(--muted); }
.badge-running { background: rgba(91,141,239,.15); color: var(--accent); }
.badge-success { background: rgba(62,201,124,.15); color: var(--green); }
.badge-failed { background: rgba(240,97,109,.15); color: var(--red); }

.empty { color: var(--muted); font-size: 14px; }

.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.meta {
  display: flex;
  gap: 16px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.log {
  height: 420px;
  overflow-y: auto;
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.entry { padding: 4px 0; border-bottom: 1px solid #1c1f26; }
.entry-assistant { color: var(--text); }
.entry-tool_result { color: var(--muted); }
.entry-system { color: var(--amber); }
.entry-result { color: var(--green); font-weight: 600; }
.entry-raw { color: var(--muted); }

.report {
  font-size: 14px;
  line-height: 1.6;
}

.report pre {
  background: #0b0d11;
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
}

.report code {
  background: #0b0d11;
  padding: 1px 5px;
  border-radius: 4px;
}

.report table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
}

.report th, .report td {
  border: 1px solid var(--border);
  padding: 6px 8px;
}

/* ---------------------------------------------------------------------
   Shared card-header row (title + right-aligned pill/link)
--------------------------------------------------------------------- */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.card-head h2 { margin: 0; }

.dl-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.dl-link:hover { text-decoration: underline; }

.report-downloads {
  display: flex;
  align-items: center;
  gap: 6px;
}
.report-downloads .dl-link {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
}
.report-downloads .dl-link:hover {
  text-decoration: none;
  border-color: var(--accent);
}

/* ---------------------------------------------------------------------
   Manual refresh button — small, secondary, sits in a card-head row.
   Logs/pipeline no longer auto-poll, so this is the only way to update them.
--------------------------------------------------------------------- */
.btn-refresh {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-refresh:hover { opacity: 1; color: var(--text); border-color: var(--accent); }

/* ---------------------------------------------------------------------
   Task list: clickable rows + relative time
--------------------------------------------------------------------- */
table.tasks tbody tr { cursor: pointer; transition: background .12s; }
table.tasks tbody tr:hover { background: rgba(91,141,239,.06); }
.row-link { color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 600; }
.row-link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------
   Generic small status pill — reused for pipeline stages, session
   summary, and per-row "current stage" in the scan list.
--------------------------------------------------------------------- */
.stage-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #2a2e38;
  color: var(--muted);
  white-space: nowrap;
}
.stage-pill-active { background: rgba(91,141,239,.15); color: var(--accent); }
.stage-pill-done { background: rgba(62,201,124,.15); color: var(--green); }
.stage-pill-error { background: rgba(240,97,109,.15); color: var(--red); }
.stage-pill-pending { background: #2a2e38; color: var(--muted); }
.stage-pill-skipped { background: #2a2e38; color: var(--muted); text-decoration: line-through; }

/* ---------------------------------------------------------------------
   Pipeline stage stepper
--------------------------------------------------------------------- */
.stage-stepper {
  display: flex;
  align-items: flex-start;
  margin-top: 18px;
  padding-top: 4px;
}

.step {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 13px;
  left: calc(50% + 16px);
  right: calc(-50% + 16px);
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step-done:not(:last-child)::after { background: var(--green); }

.step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  z-index: 1;
  flex-shrink: 0;
}
.step-done .step-dot { background: var(--green); color: #04140b; }
.step-error .step-dot { background: var(--red); color: #fff; }
.step-active .step-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(91,141,239,.22);
  animation: step-pulse 1.6s ease-in-out infinite;
}
@keyframes step-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(91,141,239,.45); }
  70%  { box-shadow: 0 0 0 9px rgba(91,141,239,0); }
  100% { box-shadow: 0 0 0 0 rgba(91,141,239,0); }
}

.step-label {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
  padding: 0 4px;
}
.step-done .step-label, .step-active .step-label, .step-error .step-label { color: var(--text); font-weight: 600; }

@media (max-width: 700px) {
  .step-label { display: none; }
}

/* ---------------------------------------------------------------------
   Claude session log — chat-style rendering
--------------------------------------------------------------------- */
.session-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  white-space: normal;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
/* Flex items with overflow != visible get an automatic min-height of 0, so
   without this the column flex layout shrinks .sess-tool (overflow:hidden)
   entries down toward 0px to force everything into the fixed-height
   container instead of scrolling it. */
.session-log > * {
  flex-shrink: 0;
}

.sess-pill {
  align-self: flex-start;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
}
.sess-pill-system { color: var(--amber); border-color: rgba(232,179,57,.3); }
.sess-pill-bg { color: var(--muted); }
.sess-pill-bg-failed { color: var(--red); border-color: rgba(240,97,109,.3); }
.sess-pill-result { align-self: center; color: var(--green); border-color: rgba(62,201,124,.3); font-weight: 600; }
.sess-pill-raw { font-family: "SF Mono", Consolas, monospace; font-size: 11px; }

.sess-turn {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 8px 12px;
}
.sess-turn-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.sess-turn-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.sess-turn-body code {
  background: #0b0d11;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.sess-tool {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.sess-tool summary {
  list-style: none;
  cursor: pointer;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.sess-tool summary::-webkit-details-marker { display: none; }
.sess-tool summary::before {
  content: '▸';
  color: var(--muted);
  font-size: 10px;
  transition: transform .1s;
}
.sess-tool[open] summary::before { transform: rotate(90deg); }

.sess-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
}
.sess-tag-tool { background: rgba(91,141,239,.15); color: var(--accent); }
.sess-tag-result { background: rgba(138,147,163,.15); color: var(--muted); }
.sess-tag-error { background: rgba(240,97,109,.15); color: var(--red); }
.sess-tool-name { color: var(--text); font-weight: 600; font-family: "SF Mono", Consolas, monospace; font-size: 12px; }

.sess-result-error { border-color: rgba(240,97,109,.35); }

.sess-tool-input {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #0b0d11;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  max-height: 320px;
  overflow-y: auto;
}

/* ---------------------------------------------------------------------
   Report — direct JSON schema rendering
--------------------------------------------------------------------- */
.report-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.report-nav a {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  text-decoration: none;
}
.report-nav a:hover { color: var(--text); border-color: var(--accent); }

.report-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.report-app-info { flex: 1 1 320px; min-width: 0; }
.report-app-name { margin: 0 0 8px; font-size: 22px; }
.report-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  font-size: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 999px;
}
.report-method, .report-scope-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 68ch;
  margin: 6px 0;
}
.report-scope-note strong { color: var(--text); }

.report-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-content: flex-start;
}
.stat {
  min-width: 84px;
  text-align: center;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
.stat-num { display: block; font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-label { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.stat-critical .stat-num { color: var(--red); }
.stat-high .stat-num { color: var(--orange); }
.stat-medium .stat-num { color: var(--amber); }
.stat-low .stat-num { color: var(--accent); }
.stat-informational .stat-num { color: var(--muted); }

.report-hook {
  background: linear-gradient(135deg, rgba(91,141,239,.12), rgba(91,141,239,.03));
  border: 1px solid rgba(91,141,239,.3);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.report-hook-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
  margin-bottom: 6px;
}
.report-hook-text { font-size: 14.5px; line-height: 1.65; }
.report-hook-text p:first-child { margin-top: 0; }
.report-hook-text p:last-child { margin-bottom: 0; }

.report-section { margin-bottom: 26px; }
.report-section h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 0 0 12px;
  scroll-margin-top: 16px;
}
.section-count {
  display: inline-block;
  background: var(--surface-3);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  margin-left: 4px;
}
.report-prose { font-size: 14px; line-height: 1.7; }

.findings-list { display: flex; flex-direction: column; gap: 10px; }
.finding {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  background: var(--surface-3);
  overflow: hidden;
}
.finding.sev-critical { border-left-color: var(--red); }
.finding.sev-high { border-left-color: var(--orange); }
.finding.sev-medium { border-left-color: var(--amber); }
.finding.sev-low { border-left-color: var(--accent); }
.finding.sev-informational { border-left-color: var(--muted); }

.finding summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.finding summary::-webkit-details-marker { display: none; }
.finding-id { font-family: "SF Mono", Consolas, monospace; font-size: 12px; color: var(--muted); }
.finding-title { font-size: 14px; font-weight: 600; flex: 1; min-width: 160px; }
.cvss-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
}

.sev-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 3px 9px;
  border-radius: 4px;
  white-space: nowrap;
}
.sev-badge-critical { background: rgba(240,97,109,.18); color: var(--red); }
.sev-badge-high { background: rgba(255,138,76,.18); color: var(--orange); }
.sev-badge-medium { background: rgba(232,179,57,.18); color: var(--amber); }
.sev-badge-low { background: rgba(91,141,239,.18); color: var(--accent); }
.sev-badge-informational { background: rgba(138,147,163,.18); color: var(--muted); }

.finding-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.finding-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.tag {
  font-size: 11px;
  color: var(--muted);
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
}
.tag-mono { font-family: "SF Mono", Consolas, monospace; }
.tag-confidence { color: var(--teal); border-color: rgba(62,207,207,.3); }
.tag-live { color: var(--green); border-color: rgba(62,201,124,.3); }
.tag-small { font-size: 10px; padding: 1px 7px; }

.finding-block, .finding-fix { margin-top: 14px; }
.finding-block h5, .finding-fix h5 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.finding-block { font-size: 13.5px; line-height: 1.65; }
.finding-fix {
  background: rgba(62,201,124,.06);
  border: 1px solid rgba(62,201,124,.25);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.65;
}
.finding-fix h5 { color: var(--green); }
.finding-block pre, .finding-fix pre {
  background: #0b0d11;
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
}
.finding-block code, .finding-fix code {
  background: #0b0d11;
  padding: 1px 5px;
  border-radius: 4px;
}
.finding-block p:first-child, .finding-fix p:first-child { margin-top: 0; }
.finding-block p:last-child, .finding-fix p:last-child { margin-bottom: 0; }

.notes-list { display: flex; flex-direction: column; gap: 8px; }
.note-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
}
.note-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  margin-top: 1px;
}
.note-positive .note-icon { background: rgba(62,201,124,.18); color: var(--green); }
.note-neutral .note-icon { background: rgba(138,147,163,.18); color: var(--muted); }
.note-item-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.note-item-result { font-size: 13px; color: var(--muted); line-height: 1.55; }
.note-item-result p { margin: 0; }

.table-scroll { overflow-x: auto; }
.api-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.api-table th, .api-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.api-table th { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.route-cell { font-family: "SF Mono", Consolas, monospace; font-size: 12px; word-break: break-all; }
.params-cell { color: var(--muted); font-size: 12px; }
.method-badge {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--muted);
}
.method-get { color: var(--accent); }
.method-post { color: var(--green); }
.method-put, .method-patch { color: var(--amber); }
.method-delete { color: var(--red); }
.auth-yes { color: var(--green); font-size: 12px; }
.auth-no { color: var(--muted); font-size: 12px; }

.owasp-list { display: flex; flex-direction: column; gap: 8px; }
.owasp-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
}
.owasp-cat { font-size: 13px; font-weight: 600; }
.owasp-result { font-size: 13px; color: var(--muted); line-height: 1.6; }
.owasp-result p { margin: 0 0 6px; }
.owasp-result p:last-child { margin-bottom: 0; }
@media (max-width: 700px) {
  .owasp-row { grid-template-columns: 1fr; }
}

.recs-list { font-size: 13.5px; line-height: 1.8; padding-left: 20px; margin: 0; }
