@cclabsnz/sf-audit 1.24.1 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,36 +1,38 @@
1
- import { esc, firaFontFaceCss, INTERACTIVE_CSP_META } from '@cclabsnz/sf-core';
1
+ import { esc, DEFAULT_BRANDING, INTERACTIVE_CSP_META } from '@cclabsnz/sf-core';
2
+ import { deckFontFaceCss } from './deckFonts.js';
2
3
  import { renderAttackChainDagSvg } from './AttackChainDagRenderer.js';
3
4
  import { coverageSummary, coverageAdvice } from '../findings/coverage.js';
4
5
  import { techniqueLabel } from '../threats/attack.js';
5
6
  import { unknownMetrics } from '../findings/unknownMetrics.js';
7
+ import { buildActionPlan, planHeadline, EFFORT_LABEL, WAVE_LABEL, WAVE_WHY } from '../report/ActionPlan.js';
8
+ import { DOMAINS, domainOf } from '../checks/domains.js';
9
+ // The report is printed on white, in the executive report's palette. Every severity colour holds
10
+ // at least 4.5:1 on white and under white text, so badges and counts stay legible when printed.
6
11
  const RISK_COLORS = {
7
- CRITICAL: '#dc2626',
8
- HIGH: '#ea580c',
9
- MEDIUM: '#d97706',
10
- LOW: '#2563eb',
11
- INFO: '#64748b',
12
+ CRITICAL: '#b91c1c',
13
+ HIGH: '#c2410c',
14
+ MEDIUM: '#a16207',
15
+ LOW: '#1d4ed8',
16
+ INFO: '#475569',
12
17
  };
13
- const RISK_BG = {
14
- CRITICAL: 'rgba(220,38,38,0.12)',
15
- HIGH: 'rgba(234,88,12,0.12)',
16
- MEDIUM: 'rgba(217,119,6,0.12)',
17
- LOW: 'rgba(37,99,235,0.12)',
18
- INFO: 'rgba(100,116,139,0.12)',
19
- };
20
- const PASS_COLOR = '#22c55e';
21
- const PASS_BG = 'rgba(34,197,94,0.10)';
18
+ const GOOD = '#15803d';
19
+ const WARN = '#a16207';
20
+ const BAD = '#b91c1c';
21
+ const PASS_COLOR = GOOD;
22
+ /** Severities drawn as solid tags; the rest are outlined, as in the executive report. */
23
+ const SOLID = new Set(['CRITICAL', 'HIGH']);
22
24
  const GRADE_COLOR = {
23
- A: '#22c55e', B: '#84cc16', C: '#eab308', D: '#f97316', F: '#ef4444',
25
+ A: GOOD, B: '#4d7c0f', C: WARN, D: '#c2410c', F: BAD,
24
26
  };
25
27
  // ── Dashboard helpers ────────────────────────────────────────────────────────
26
- /** The grey used for inconclusive findings. */
27
- const UNKNOWN_COLOR = '#8b949e';
28
+ /** The grey used for inconclusive findings and counts the audit could not read. */
29
+ const UNKNOWN_COLOR = DEFAULT_BRANDING.muted;
28
30
  function statusColor(value, warnThreshold, dangerThreshold) {
29
31
  if (value <= warnThreshold)
30
- return '#22c55e';
32
+ return GOOD;
31
33
  if (value <= dangerThreshold)
32
- return '#d97706';
33
- return '#dc2626';
34
+ return WARN;
35
+ return BAD;
34
36
  }
35
37
  function progressBar(value, max, color) {
36
38
  if (max === 0)
@@ -47,43 +49,6 @@ function metricRow(label, value, color, bar) {
47
49
  function inventoryCard(title, rows) {
48
50
  return `<div class="inv-card"><div class="inv-card-title">${esc(title)}</div>${rows.join('')}</div>`;
49
51
  }
50
- function buildScoreRing(score, grade, color) {
51
- return `
52
- <div class="score-ring" style="background:conic-gradient(from -90deg, ${color} ${score}%, #2d3748 ${score}%)" aria-label="Health score ${score} out of 100, grade ${grade}">
53
- <div class="score-inner">
54
- <div class="score-num" style="color:${color}">${score}<span>/100</span></div>
55
- <div class="score-grade" style="background:${color}">${esc(grade)}</div>
56
- </div>
57
- </div>`;
58
- }
59
- function buildDonutSvg(counts) {
60
- const levels = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'];
61
- const total = levels.reduce((s, l) => s + (counts[l] ?? 0), 0);
62
- const cx = 60, cy = 60, R = 44;
63
- const CIRC = 2 * Math.PI * R;
64
- if (total === 0) {
65
- return `<svg width="120" height="120" viewBox="0 0 120 120" aria-hidden="true">
66
- <circle cx="${cx}" cy="${cy}" r="${R}" fill="none" stroke="#21262d" stroke-width="14" />
67
- <text x="${cx}" y="${cy + 5}" text-anchor="middle" fill="#22c55e" font-size="12" font-family="system-ui,sans-serif">Clean</text>
68
- </svg>`;
69
- }
70
- let offset = CIRC / 4; // Start from 12 o'clock
71
- const arcs = levels.map(l => {
72
- const count = counts[l] ?? 0;
73
- if (count === 0)
74
- return '';
75
- const dash = (count / total) * CIRC;
76
- const arc = `<circle cx="${cx}" cy="${cy}" r="${R}" fill="none" stroke="${RISK_COLORS[l]}" stroke-width="14" stroke-dasharray="${dash.toFixed(2)} ${CIRC.toFixed(2)}" stroke-dashoffset="${offset.toFixed(2)}" />`;
77
- offset -= dash;
78
- return arc;
79
- });
80
- return `<svg width="120" height="120" viewBox="0 0 120 120" aria-hidden="true">
81
- <circle cx="${cx}" cy="${cy}" r="${R}" fill="none" stroke="#21262d" stroke-width="14" />
82
- ${arcs.join('')}
83
- <text x="${cx}" y="${cy - 5}" text-anchor="middle" fill="#f0f6fc" font-size="20" font-weight="700" font-family="system-ui,sans-serif">${total}</text>
84
- <text x="${cx}" y="${cy + 14}" text-anchor="middle" fill="#8b949e" font-size="10" font-family="system-ui,sans-serif">open findings</text>
85
- </svg>`;
86
- }
87
52
  /** Open findings per severity: what the score and the executive report count (RULE-079). */
88
53
  function openCounts(result) {
89
54
  const open = result.findings.filter((f) => !f.passed && !f.inconclusive && !f.notAssessed && !f.waived);
@@ -91,10 +56,14 @@ function openCounts(result) {
91
56
  }
92
57
  function buildDashboard(result, counts) {
93
58
  const m = result.metrics;
94
- const gradeColor = GRADE_COLOR[result.grade] ?? '#64748b';
95
- const gauge = buildScoreRing(result.healthScore, result.grade, gradeColor);
96
- const donut = buildDonutSvg(counts);
97
- const kpiCards = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'].map(l => `<div class="kpi-card" style="border-top:3px solid ${RISK_COLORS[l]}">
59
+ const gradeColor = GRADE_COLOR[result.grade] ?? UNKNOWN_COLOR;
60
+ const openTotal = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'].reduce((n, l) => n + (counts[l] ?? 0), 0);
61
+ const sevBar = openTotal
62
+ ? ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW']
63
+ .map((l) => (counts[l] ? `<i style="width:${((counts[l] / openTotal) * 100).toFixed(2)}%;background:${RISK_COLORS[l]}"></i>` : ''))
64
+ .join('')
65
+ : '';
66
+ const kpiCards = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'].map(l => `<div class="kpi-card" style="--sev:${RISK_COLORS[l]}">
98
67
  <div class="kpi-value" style="color:${RISK_COLORS[l]}">${counts[l] ?? 0}</div>
99
68
  <div class="kpi-label">${l}</div>
100
69
  </div>`).join('');
@@ -116,64 +85,59 @@ function buildDashboard(result, counts) {
116
85
  metricRow('Permission Sets', m.permissionSetCount),
117
86
  ]);
118
87
  // Code Quality
119
- const covColor = m.codeCoveragePercent >= 75 ? '#22c55e' : m.codeCoveragePercent >= 50 ? '#d97706' : '#dc2626';
88
+ const covColor = m.codeCoveragePercent >= 75 ? GOOD : m.codeCoveragePercent >= 50 ? WARN : BAD;
120
89
  const codeCard = inventoryCard('Code Quality', [
121
90
  metricRow('Apex Classes', m.apexClassCount),
122
91
  metricRow('Apex Triggers', m.apexTriggerCount),
123
92
  metricRow('Code Coverage', `${m.codeCoveragePercent}%`, covColor, progressBar(m.codeCoveragePercent, 100, covColor)),
124
93
  ]);
125
94
  // Integrations
126
- const insecureColor = m.insecureRemoteSitesCount > 0 ? '#dc2626' : '#22c55e';
95
+ const insecureColor = m.insecureRemoteSitesCount > 0 ? BAD : GOOD;
127
96
  const unusedCredColor = statusColor(m.unusedNamedCredentialsCount, 0, 2);
128
97
  const integrationsCard = inventoryCard('Integrations', [
129
98
  metricRow('Connected Apps', m.connectedAppsCount),
130
99
  metricRow('Remote Sites', m.remoteSitesCount),
131
100
  metricRow('↳ Insecure', m.insecureRemoteSitesCount, insecureColor, m.remoteSitesCount > 0 ? progressBar(m.insecureRemoteSitesCount, m.remoteSitesCount, insecureColor) : ''),
132
101
  metricRow('Named Credentials', m.namedCredentialsCount),
133
- metricRow('↳ Unused', m.unusedNamedCredentialsCount, m.unusedNamedCredentialsCount > 0 ? '#d97706' : '#22c55e', m.namedCredentialsCount > 0 ? progressBar(m.unusedNamedCredentialsCount, m.namedCredentialsCount, unusedCredColor) : ''),
102
+ metricRow('↳ Unused', m.unusedNamedCredentialsCount, m.unusedNamedCredentialsCount > 0 ? WARN : GOOD, m.namedCredentialsCount > 0 ? progressBar(m.unusedNamedCredentialsCount, m.namedCredentialsCount, unusedCredColor) : ''),
134
103
  ]);
135
104
  // Governance & Events
136
105
  const failedColor = statusColor(m.failedLogins30d, 10, 100);
137
- const healthChkColor = m.healthCheckScore >= 75 ? '#22c55e' : m.healthCheckScore >= 50 ? '#d97706' : '#dc2626';
106
+ const healthChkColor = m.healthCheckScore >= 75 ? GOOD : m.healthCheckScore >= 50 ? WARN : BAD;
138
107
  const governanceCard = inventoryCard('Governance & Events', [
139
108
  metricRow('Failed Logins (30d)', m.failedLogins30d, failedColor),
140
109
  metricRow('SF Health Check', `${m.healthCheckScore}%`, healthChkColor, progressBar(m.healthCheckScore, 100, healthChkColor)),
141
110
  ]);
142
111
  const waivedBanner = result.waivedFindings?.length
143
- ? `<div class="waived-banner" style="background:#0f291e;border:1px solid #16a34a;border-radius:8px;padding:12px 16px;margin-bottom:20px;color:#dcfce7;font-size:13px;"><strong>Accepted risks:</strong> ${result.waivedFindings.length} finding(s) waived under an approved waiver and excluded from the score.</div>`
112
+ ? `<div class="waived-banner"><strong>Accepted risks:</strong> ${result.waivedFindings.length} finding(s) waived under an approved waiver and excluded from the score.</div>`
144
113
  : '';
145
114
  const gradeReasonLine = result.gradeReason
146
- ? `<div class="grade-reason" style="margin-top:10px;font-size:12px;color:#94a3b8">Why ${esc(result.grade)}: ${esc(result.gradeReason.replace(/^[A-F]: /, ''))}</div>`
115
+ ? `<div class="grade-reason">Why ${esc(result.grade)}: ${esc(result.gradeReason.replace(/^[A-F]: /, ''))}</div>`
147
116
  : '';
148
117
  const cov = result.coverage;
149
118
  const coverageLine = cov
150
- ? `<div class="coverage${cov.gradeCapped ? ' is-capped' : ''}" style="margin-top:10px;font-size:12px;color:${cov.gradeCapped ? '#fbbf24' : '#94a3b8'}">${esc(coverageSummary(cov))}${cov.notAssessed.length ? `<br>Not assessed: ${cov.notAssessed.map((id) => `<code>${esc(id)}</code>`).join(', ')}<br>${esc(coverageAdvice(cov))}` : ''}</div>`
119
+ ? `<div class="coverage${cov.gradeCapped ? ' is-capped' : ''}">${esc(coverageSummary(cov))}${cov.notAssessed.length
120
+ ? `<details class="cov-more"><summary>Why ${cov.notAssessed.length} ${cov.notAssessed.length === 1 ? 'was' : 'were'} not assessed</summary><p>${cov.notAssessed.map((id) => `<code>${esc(id)}</code>`).join(', ')}</p><p>${esc(coverageAdvice(cov))}</p></details>`
121
+ : ''}</div>`
151
122
  : '';
152
123
  return `
153
124
  ${waivedBanner}
154
125
  <div class="dashboard">
155
- <div class="dash-top">
156
- <div class="dash-score-panel">
157
- <div class="gauge-wrap">
158
- ${gauge}
126
+ <div class="verdict">
127
+ <div class="verdict-grade" role="group" aria-label="Health score ${result.healthScore} out of 100, grade ${esc(result.grade)}">
128
+ <div class="grade-mark" style="--g:${gradeColor}">${esc(result.grade)}</div>
129
+ <div class="grade-text">
130
+ <div class="score-line"><span class="score-num" style="color:${gradeColor}">${result.healthScore}</span><span class="score-of">/100 health score</span></div>
131
+ ${gradeReasonLine}
132
+ ${coverageLine}
159
133
  </div>
160
- ${gradeReasonLine}
161
- ${coverageLine}
162
134
  </div>
163
- <div class="dash-risk-panel">
164
- <div class="donut-wrap">
165
- ${donut}
166
- <div class="donut-legend">
167
- ${['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'].map(l => `<div class="legend-row">
168
- <span class="legend-dot" style="background:${RISK_COLORS[l]}"></span>
169
- <span>${l}</span>
170
- <span class="legend-count">${counts[l] ?? 0}</span>
171
- </div>`).join('')}
172
- </div>
173
- </div>
135
+ <div class="verdict-sev">
136
+ <div class="open-total"><b class="open-n">${openTotal}</b> open findings</div>
137
+ <div class="sev-bar" role="img" aria-label="${openTotal} open findings by severity">${sevBar}</div>
138
+ <div class="kpi-strip">${kpiCards}</div>
174
139
  </div>
175
140
  </div>
176
- <div class="kpi-strip">${kpiCards}</div>
177
141
  <div class="inv-grid">
178
142
  ${usersCard}
179
143
  ${codeCard}
@@ -182,27 +146,84 @@ function buildDashboard(result, counts) {
182
146
  </div>
183
147
  </div>`;
184
148
  }
149
+ // ── Report structure helpers ─────────────────────────────────────────────────
150
+ const SEV_ORDER = { CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3, INFO: 4 };
151
+ const OTHER_DOMAIN = 'Other checks';
152
+ function statusOf(f) {
153
+ if (f.passed)
154
+ return 'passed';
155
+ if (f.inconclusive || f.notAssessed)
156
+ return 'inconclusive';
157
+ if (f.waived)
158
+ return 'waived';
159
+ return f.riskLevel === 'INFO' ? 'info' : 'open';
160
+ }
161
+ /** Open findings first, worst first; then informational, waived, inconclusive and passed results. */
162
+ const STATUS_ORDER = { open: 0, info: 1, waived: 2, inconclusive: 3, passed: 4 };
163
+ function byPriority(a, b) {
164
+ return STATUS_ORDER[statusOf(a)] - STATUS_ORDER[statusOf(b)] || (SEV_ORDER[a.riskLevel] ?? 9) - (SEV_ORDER[b.riskLevel] ?? 9);
165
+ }
166
+ /** A stable, unique anchor per finding, so a ticket can link straight to it. */
167
+ function findingAnchors(findings) {
168
+ const used = new Set();
169
+ const out = new Map();
170
+ for (const f of findings) {
171
+ const base = `f-${String(f.id ?? 'finding').toLowerCase().replace(/[^a-z0-9_-]+/g, '-')}`;
172
+ let a = base;
173
+ for (let n = 2; used.has(a); n++)
174
+ a = `${base}-${n}`;
175
+ used.add(a);
176
+ out.set(f, a);
177
+ }
178
+ return out;
179
+ }
180
+ /** Chain labels as the executive report prints them: C1… for named chains, P1… for potential ones. */
181
+ function chainLabels(chains) {
182
+ let c = 0, p = 0;
183
+ return chains.map((ch) => (ch.abuseCase ? `C${++c}` : `P${++p}`));
184
+ }
185
+ const slug = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
186
+ /** The framework a compliance tag belongs to: 'SOC2-CC6.1' is SOC2; OWASP LLM tags ('LLM02') are one framework. */
187
+ const frameworkOf = (tag) => (/^LLM\d/.test(tag) ? 'OWASP-LLM' : tag.split(/[-.]/)[0]);
188
+ const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
189
+ function severityBadge(f) {
190
+ const st = statusOf(f);
191
+ if (st === 'inconclusive')
192
+ return '<span class="inconclusive-badge">? INCONCLUSIVE</span>';
193
+ if (st === 'passed')
194
+ return `<span class="risk-badge" style="--sev:${PASS_COLOR}">✓ PASS</span>`;
195
+ const sev = `<span class="risk-badge${SOLID.has(f.riskLevel) ? ' solid' : ''}" style="--sev:${RISK_COLORS[f.riskLevel] ?? UNKNOWN_COLOR}">${esc(f.riskLevel)}</span>`;
196
+ return st === 'waived' ? `${sev}<span class="waived-mark">waived</span>` : sev;
197
+ }
185
198
  // ── Main renderer ────────────────────────────────────────────────────────────
186
199
  export class HtmlRenderer {
187
200
  format = 'html';
188
201
  fileExtension = '.html';
189
- renderAttackPaths(result) {
202
+ renderAttackPaths(result, labels, anchorOfId) {
190
203
  if (!result.attackChains || result.attackChains.length === 0)
191
204
  return '';
192
205
  const cards = result.attackChains
193
- .map((c) => {
206
+ .map((c, ci) => {
194
207
  const conf = c.confidence === 'named' ? '' : ' (potential)';
195
- const dagSvg = renderAttackChainDagSvg(c, { theme: 'dark' });
208
+ const dagSvg = renderAttackChainDagSvg(c, { theme: 'light' });
196
209
  const steps = c.steps
197
210
  .map((s) => {
198
211
  const technique = s.techniques?.length ? ` → ${esc(s.techniques.map(techniqueLabel).join(' · '))}` : '';
199
212
  const grants = s.capabilityInferred ? '' : `: grants <code>${esc(s.capability)}</code>${technique}`;
200
213
  const cut = s.breaksChain ? ' <strong>✂ break point</strong>' : '';
201
- return `<li><strong>${esc(s.title ?? s.findingId)}</strong> (${esc(s.severity ?? '—')})${grants}${cut}</li>`;
214
+ const anchor = anchorOfId.get(s.findingId);
215
+ const name = `<strong>${esc(s.title ?? s.findingId)}</strong>`;
216
+ return `<li>${anchor ? `<a href="#${anchor}">${name}</a>` : name} (${esc(s.severity ?? '—')})${grants}${cut}</li>`;
202
217
  })
203
218
  .join('');
204
- return `<div class="attack-chain severity-${c.severity.toLowerCase()}">
205
- <h3>[${esc(c.severity)}] ${esc(c.title)}${conf}</h3>
219
+ const gist = c.abuseCase ? `Break it: ${esc(c.abuseCase.breakPoint)}` : `${c.steps.length} steps; possible but unproven`;
220
+ return `<details class="attack-chain severity-${esc(c.severity.toLowerCase())}" id="chain-${ci + 1}">
221
+ <summary class="chain-sum">
222
+ <span class="risk-badge solid" style="--sev:${RISK_COLORS[c.severity] ?? UNKNOWN_COLOR}">${esc(c.severity)}</span>
223
+ <span class="chain-text"><h3><span class="chain-label">${labels[ci]}</span> ${esc(c.title)}${conf}</h3><span class="chain-gist">${gist}</span></span>
224
+ <span class="chevron">›</span>
225
+ </summary>
226
+ <div class="chain-body">
206
227
  ${c.abuseCase ? `<p><strong>Abuse case:</strong> ${esc(c.abuseCase.actor)} wants to ${esc(c.abuseCase.goal)}.</p>` : ''}
207
228
  <p>${esc(c.narrative)}</p>
208
229
  ${dagSvg}
@@ -211,39 +232,191 @@ export class HtmlRenderer {
211
232
  ? `<p class="remediation"><strong>Breaks the chain:</strong> ${esc(c.abuseCase.breakPoint)}</p>
212
233
  <p class="remediation"><strong>Remediation:</strong> ${esc(c.remediation)}</p>`
213
234
  : `<p class="remediation"><strong>Recommended fixes:</strong> ${esc(c.remediation)}</p>`}
214
- </div>`;
235
+ </div>
236
+ </details>`;
215
237
  })
216
238
  .join('\n');
217
- return `<section class="attack-paths">
239
+ return `<section class="attack-paths" id="attack-paths">
218
240
  <h2>Attack Paths (${result.attackChains.length})</h2>
219
- <p class="subtitle">Combinations of findings that together enable an exploit more severe than any single finding.</p>
241
+ <p class="subtitle">Combinations of findings that together enable an exploit more severe than any single finding. Open a path for its steps, diagram and fix.</p>
220
242
  ${cards}
243
+ </section>`;
244
+ }
245
+ /** Option A: the fixes, in the order to do them, each with the findings it closes. */
246
+ renderPlan(plan, headline, labels, chainSev, anchorOf) {
247
+ if (plan.length === 0) {
248
+ return `<section class="fix-first" id="fix-first">
249
+ <div class="kicker">Fix first</div>
250
+ <h2 class="sec-h">${esc(headline)}</h2>
251
+ </section>`;
252
+ }
253
+ const chip = (i, kind) => `<a class="chip ${kind ? 'part' : chainSev[i]}" href="#chain-${i + 1}">${kind ? 'part of ' : ''}${labels[i]}</a>`;
254
+ let last = 0;
255
+ const rows = plan.map((a, i) => {
256
+ const head = a.wave !== last
257
+ ? `<tr class="wave-h"><td colspan="5">${WAVE_LABEL[a.wave]} <span class="why">· ${WAVE_WHY[a.wave]}</span></td></tr>`
258
+ : '';
259
+ last = a.wave;
260
+ const partOf = [...new Set([...a.weakens, ...a.inChains])].filter((c) => !a.breaks.includes(c));
261
+ const breaks = [...a.breaks.map((c) => chip(c, '')), ...partOf.map((c) => chip(c, 'part'))].join('') || '<span class="none">—</span>';
262
+ const closes = a.fixes
263
+ .map((f) => `<li>${severityBadge(f)}<a href="#${anchorOf.get(f)}">${esc(f.title)}</a></li>`)
264
+ .join('');
265
+ return `${head}<tr>
266
+ <td class="n">${i + 1}</td>
267
+ <td class="act"><b>${esc(a.title)}</b><span class="why-line">${esc(a.detail ?? a.why)}</span><ul class="closes">${closes}</ul></td>
268
+ <td><div class="chips">${breaks}</div></td>
269
+ <td class="num">${a.fixes.length}</td>
270
+ <td class="effort">${EFFORT_LABEL[a.effort]}</td>
271
+ </tr>`;
272
+ }).join('');
273
+ return `<section class="fix-first" id="fix-first">
274
+ <div class="kicker">Fix first</div>
275
+ <h2 class="sec-h">${esc(headline)}</h2>
276
+ <p class="subtitle">Each action lists the findings it closes and the attack chains it breaks. Effort is an estimate for planning, not a quote.</p>
277
+ <div class="tbl"><table class="plan">
278
+ <thead><tr><th></th><th>Action</th><th>Breaks</th><th class="num">Closes</th><th>Effort</th></tr></thead>
279
+ <tbody>${rows}</tbody>
280
+ </table></div>
281
+ </section>`;
282
+ }
283
+ /** Option C: one scorecard row per domain, then each domain's findings, with passed checks folded away. */
284
+ renderDomains(result, card) {
285
+ const groups = new Map();
286
+ for (const d of DOMAINS)
287
+ groups.set(d, []);
288
+ for (const f of result.findings) {
289
+ const d = domainOf(f.checkId) ?? OTHER_DOMAIN;
290
+ if (!groups.has(d))
291
+ groups.set(d, []);
292
+ groups.get(d).push(f);
293
+ }
294
+ const domains = [...groups.entries()]
295
+ .filter(([, fs]) => fs.length > 0)
296
+ .map(([name, fs]) => {
297
+ const open = fs.filter((f) => statusOf(f) === 'open').sort(byPriority);
298
+ const n = (l) => open.filter((f) => f.riskLevel === l).length;
299
+ return { name, fs: [...fs].sort(byPriority), open, worst: open[0]?.riskLevel, counts: { c: n('CRITICAL'), h: n('HIGH'), m: n('MEDIUM'), l: n('LOW') } };
300
+ })
301
+ .sort((a, b) => (SEV_ORDER[a.worst ?? 'INFO'] - SEV_ORDER[b.worst ?? 'INFO']) || b.open.length - a.open.length);
302
+ /** The domain's headline, and its worst open finding when there is one. */
303
+ const claim = (d) => {
304
+ if (d.open.length) {
305
+ const parts = ['c', 'h', 'm', 'l']
306
+ .filter((k) => d.counts[k])
307
+ .map((k) => `${d.counts[k]} ${{ c: 'critical', h: 'high', m: 'medium', l: 'low' }[k]}`);
308
+ return { head: `${parts.join(', ')} open`, worst: `Worst: ${d.open[0].title}` };
309
+ }
310
+ const n = (st) => d.fs.filter((f) => statusOf(f) === st).length;
311
+ const rest = [
312
+ n('inconclusive') ? `${plural(n('inconclusive'), 'result')} could not be assessed` : '',
313
+ n('waived') ? `${n('waived')} waived` : '',
314
+ n('info') ? `${n('info')} informational` : '',
315
+ n('passed') ? `${n('passed')} passed` : '',
316
+ ].filter(Boolean);
317
+ return { head: `No open findings; ${rest.join(', ')}` };
318
+ };
319
+ const unassessed = (d) => d.fs.some((f) => statusOf(f) === 'inconclusive');
320
+ const mark = (d) => d.worst
321
+ ? `<span class="risk-badge${SOLID.has(d.worst) ? ' solid' : ''}" style="--sev:${RISK_COLORS[d.worst]}">${esc(d.worst)}</span>`
322
+ : unassessed(d)
323
+ ? '<span class="inconclusive-badge">? PARTLY UNSEEN</span>'
324
+ : `<span class="risk-badge" style="--sev:${PASS_COLOR}">✓ CLEAR</span>`;
325
+ const bar = (d) => {
326
+ const total = d.fs.length;
327
+ const seg = (k, count) => (count ? `<i class="b-${k}" style="width:${((count / total) * 100).toFixed(2)}%"></i>` : '');
328
+ const st = (s) => d.fs.filter((f) => statusOf(f) === s).length;
329
+ return `<div class="bar" role="img" aria-label="${esc(d.name)}: ${d.open.length} open of ${total} results">${seg('c', d.counts.c)}${seg('h', d.counts.h)}${seg('m', d.counts.m)}${seg('l', d.counts.l)}${seg('u', st('info') + st('waived') + st('inconclusive'))}${seg('p', st('passed'))}</div>`;
330
+ };
331
+ const withIssues = domains.filter((d) => d.counts.c + d.counts.h > 0).length;
332
+ const scorecard = domains.map((d) => `<a class="dom-row" href="#d-${slug(d.name)}">
333
+ <span class="dom-name">${esc(d.name)}</span>
334
+ <span class="dom-claim">${mark(d)}<span>${(() => { const { head, worst } = claim(d); return `<b>${esc(head)}</b>${worst ? `<span class="worst">${esc(worst)}</span>` : ''}`; })()}</span></span>
335
+ ${bar(d)}
336
+ <span class="dom-counts"><b>${d.open.length}</b> open · ${d.fs.filter((f) => statusOf(f) === 'passed').length} passed</span>
337
+ </a>`).join('');
338
+ const sections = domains.map((d) => {
339
+ const shown = d.fs.filter((f) => statusOf(f) !== 'passed');
340
+ const passed = d.fs.filter((f) => statusOf(f) === 'passed');
341
+ return `<section class="domain" id="d-${slug(d.name)}">
342
+ <h3 class="dom-h">${esc(d.name)}</h3>
343
+ <p class="dom-sub">${(() => { const { head, worst } = claim(d); return esc(worst ? `${head}. ${worst}` : head); })()}</p>
344
+ ${shown.map(card).join('')}
345
+ ${passed.length ? `<details class="passed-fold"><summary>${plural(passed.length, 'check')} passed</summary>${passed.map(card).join('')}</details>` : ''}
346
+ </section>`;
347
+ }).join('\n');
348
+ return `<section class="by-domain" id="by-domain">
349
+ <div class="kicker">By domain</div>
350
+ <h2 class="sec-h">${withIssues ? `${withIssues} of ${domains.length} domains have critical or high findings` : `No domain has a critical or high finding`}</h2>
351
+ <div class="scorecard">${scorecard}</div>
352
+ <div class="bar-key" aria-hidden="true"><span><i class="b-c"></i>Critical</span><span><i class="b-h"></i>High</span><span><i class="b-m"></i>Medium</span><span><i class="b-l"></i>Low</span><span><i class="b-u"></i>Info, waived or inconclusive</span><span><i class="b-p"></i>Passed</span></div>
353
+ ${sections}
354
+ </section>`;
355
+ }
356
+ /** Option D: every result in one table that can be regrouped and searched; links to the full finding. */
357
+ renderTable(result, labels, chainSev, anchorOf) {
358
+ const chainsOf = new Map();
359
+ (result.attackChains ?? []).forEach((c, i) => {
360
+ for (const s of c.steps) {
361
+ const list = chainsOf.get(s.findingId) ?? [];
362
+ if (!list.includes(`${labels[i]}|${chainSev[i]}`))
363
+ list.push(`${labels[i]}|${chainSev[i]}`);
364
+ chainsOf.set(s.findingId, list);
365
+ }
366
+ });
367
+ const rows = [...result.findings].sort(byPriority).map((f) => {
368
+ const st = statusOf(f);
369
+ const dom = domainOf(f.checkId) ?? OTHER_DOMAIN;
370
+ const chains = chainsOf.get(f.id) ?? [];
371
+ const fws = [...new Set((f.complianceTags ?? []).map(frameworkOf))];
372
+ const sevKey = st === 'open' ? f.riskLevel : st === 'info' ? 'INFO' : st.toUpperCase();
373
+ return `<tr data-sev="${esc(sevKey)}" data-dom="${esc(dom)}" data-ch="${esc(chains.map((c) => c.split('|')[0]).join(' '))}" data-fw="${esc(fws.join(' '))}" data-st="${st}"${st === 'passed' ? ' hidden' : ''}>
374
+ <td>${severityBadge(f)}</td>
375
+ <td><a href="#${anchorOf.get(f)}">${esc(f.title)}</a><span class="row-dom">${esc(dom)}</span></td>
376
+ <td class="num">${f.affectedItems?.length ?? '—'}</td>
377
+ <td><div class="chips">${chains.map((c) => { const [l, sev] = c.split('|'); return `<a class="chip ${sev}" href="#chain-${labels.indexOf(l) + 1}">${l}</a>`; }).join('') || '<span class="none">—</span>'}</div></td>
378
+ </tr>`;
379
+ }).join('');
380
+ const passed = result.findings.filter((f) => f.passed).length;
381
+ return `<section class="all-results" id="all-results">
382
+ <div class="kicker">Appendix</div>
383
+ <h2 class="sec-h">All ${plural(result.findings.length, 'result')}, in one table</h2>
384
+ <div class="tools">
385
+ <div class="seg" role="group" aria-label="Group by">
386
+ <button type="button" data-group="sev" aria-pressed="true">Severity</button><button type="button" data-group="dom" aria-pressed="false">Domain</button><button type="button" data-group="ch" aria-pressed="false">Attack chain</button><button type="button" data-group="fw" aria-pressed="false">Framework</button>
387
+ </div>
388
+ <label class="tool-check"><input type="checkbox" id="show-passed"> Include ${plural(passed, 'passed check')}</label>
389
+ <label class="tool-search" for="result-search">Search <input type="search" id="result-search" placeholder="guest, apex, SOC2…" autocomplete="off"></label>
390
+ </div>
391
+ <div class="tbl"><table class="results">
392
+ <thead><tr><th>Status</th><th>Finding</th><th class="num">Affected</th><th>Chains</th></tr></thead>
393
+ <tbody id="results-body">${rows}</tbody>
394
+ </table></div>
395
+ <p class="no-match" id="no-match" hidden>No result matches that search.</p>
221
396
  </section>`;
222
397
  }
223
398
  render(result) {
224
- const levels = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'];
225
- const counts = Object.fromEntries(levels.map((l) => [l, result.findings.filter((f) => f.riskLevel === l).length]));
226
- const filterButtons = [
227
- `<button class="filter-btn active" data-filter="all">All (${result.findings.length})</button>`,
228
- ...levels.map((l) => `<button class="filter-btn" data-filter="${l}" style="--accent:${RISK_COLORS[l]}">${l} (${counts[l]})</button>`),
229
- ].join('\n ');
230
- const attackPathsHtml = this.renderAttackPaths(result);
231
- const findingsHtml = result.findings.length === 0
232
- ? '<p class="no-findings">No findings.</p>'
233
- : result.findings.map((f) => {
234
- const isInconclusive = !!f.inconclusive;
235
- const cardAccent = isInconclusive ? '#8b949e' : (f.passed ? PASS_COLOR : (RISK_COLORS[f.riskLevel] ?? '#64748b'));
236
- const cardBg = isInconclusive ? 'rgba(139,148,158,0.06)' : (f.passed ? PASS_BG : (RISK_BG[f.riskLevel] ?? 'rgba(100,116,139,0.12)'));
237
- const badgeHtml = isInconclusive
238
- ? `<span class="inconclusive-badge">? INCONCLUSIVE</span>`
239
- : f.passed
240
- ? `<span class="risk-badge" style="background:${PASS_COLOR}">✓ PASS</span>`
241
- : `<span class="risk-badge" style="background:${RISK_COLORS[f.riskLevel] ?? '#64748b'}">${esc(f.riskLevel)}</span>`;
242
- const tagsHtml = f.complianceTags?.length
243
- ? `<div class="compliance-tags">${f.complianceTags.map((t) => `<span class="compliance-tag">${esc(t)}</span>`).join('')}</div>`
244
- : '';
245
- return `
246
- <details class="finding-card${isInconclusive ? ' is-inconclusive' : ''}" data-risk="${esc(f.riskLevel)}" style="--card-accent:${cardAccent};--card-bg:${cardBg}">
399
+ const chains = result.attackChains ?? [];
400
+ const labels = chainLabels(chains);
401
+ const anchorOf = findingAnchors(result.findings);
402
+ const anchorOfId = new Map();
403
+ for (const [f, a] of anchorOf)
404
+ if (!anchorOfId.has(f.id))
405
+ anchorOfId.set(f.id, a);
406
+ const plan = buildActionPlan(result.findings, chains);
407
+ const chainSev = chains.map((c) => `sev-${esc(c.severity.toLowerCase())}`);
408
+ const openHigh = result.findings.filter((f) => statusOf(f) === 'open' && f.riskLevel === 'HIGH').length;
409
+ const headline = planHeadline(plan, chains, openHigh);
410
+ const attackPathsHtml = this.renderAttackPaths(result, labels, anchorOfId);
411
+ const card = (f) => {
412
+ const isInconclusive = statusOf(f) === 'inconclusive';
413
+ const cardAccent = isInconclusive ? UNKNOWN_COLOR : (f.passed ? 'var(--hair)' : (RISK_COLORS[f.riskLevel] ?? UNKNOWN_COLOR));
414
+ const badgeHtml = severityBadge(f);
415
+ const tagsHtml = f.complianceTags?.length
416
+ ? `<div class="compliance-tags">${f.complianceTags.map((t) => `<span class="compliance-tag">${esc(t)}</span>`).join('')}</div>`
417
+ : '';
418
+ return `
419
+ <details class="finding-card${isInconclusive ? ' is-inconclusive' : ''}" id="${anchorOf.get(f)}" data-risk="${esc(f.riskLevel)}" style="--card-accent:${cardAccent}">
247
420
  <summary class="finding-summary">
248
421
  ${badgeHtml}
249
422
  <span class="finding-title">${esc(f.title)}</span>
@@ -257,24 +430,31 @@ export class HtmlRenderer {
257
430
  <p>${esc(f.remediation)}</p>
258
431
  </div>
259
432
  ${f.affectedItems?.length ? (() => {
260
- const hasUrls = f.affectedItems.some((i) => i.url);
261
- const hasNotes = f.affectedItems.some((i) => i.note);
262
- const headers = ['Item', ...(hasUrls ? ['Setup Link'] : []), ...(hasNotes ? ['Notes'] : [])];
263
- const thead = `<tr>${headers.map((h) => `<th>${esc(h)}</th>`).join('')}</tr>`;
264
- const tbody = f.affectedItems.map((item) => {
265
- const cells = [
266
- `<td>${esc(item.label)}</td>`,
267
- ...(hasUrls ? [`<td>${item.url ? `<a href="${esc(item.url)}" target="_blank" rel="noopener">Open ↗</a>` : '—'}</td>`] : []),
268
- ...(hasNotes ? [`<td>${esc(item.note ?? '')}</td>`] : []),
269
- ];
270
- return `<tr>${cells.join('')}</tr>`;
271
- }).join('');
272
- return `<div class="affected-items"><strong>Affected items (${f.affectedItems.length})</strong><table class="affected-table"><thead>${thead}</thead><tbody>${tbody}</tbody></table></div>`;
273
- })() : ''}
433
+ const hasUrls = f.affectedItems.some((i) => i.url);
434
+ const hasNotes = f.affectedItems.some((i) => i.note);
435
+ const headers = ['Item', ...(hasUrls ? ['Setup Link'] : []), ...(hasNotes ? ['Notes'] : [])];
436
+ const thead = `<tr>${headers.map((h) => `<th>${esc(h)}</th>`).join('')}</tr>`;
437
+ const tbody = f.affectedItems.map((item) => {
438
+ const cells = [
439
+ `<td>${esc(item.label)}</td>`,
440
+ ...(hasUrls ? [`<td>${item.url ? `<a href="${esc(item.url)}" target="_blank" rel="noopener">Open ↗</a>` : '—'}</td>`] : []),
441
+ ...(hasNotes ? [`<td>${esc(item.note ?? '')}</td>`] : []),
442
+ ];
443
+ return `<tr>${cells.join('')}</tr>`;
444
+ }).join('');
445
+ return `<div class="affected-items"><strong>Affected items (${f.affectedItems.length})</strong><table class="affected-table"><thead>${thead}</thead><tbody>${tbody}</tbody></table></div>`;
446
+ })() : ''}
274
447
  ${tagsHtml}
275
448
  </div>
276
449
  </details>`;
277
- }).join('\n');
450
+ };
451
+ const bodyHtml = result.findings.length === 0
452
+ ? `<p class="no-findings">No findings.</p>
453
+ ${attackPathsHtml}`
454
+ : `${this.renderPlan(plan, headline, labels, chainSev, anchorOf)}
455
+ ${attackPathsHtml}
456
+ ${this.renderDomains(result, card)}
457
+ ${this.renderTable(result, labels, chainSev, anchorOf)}`;
278
458
  return `<!DOCTYPE html>
279
459
  <html lang="en">
280
460
  <head>
@@ -283,292 +463,352 @@ ${INTERACTIVE_CSP_META}
283
463
  <meta name="viewport" content="width=device-width,initial-scale=1">
284
464
  <title>SF Security Audit: ${esc(result.orgName)}</title>
285
465
  <style>
286
- ${firaFontFaceCss()}
466
+ ${deckFontFaceCss()}
467
+ :root {
468
+ --ink: ${DEFAULT_BRANDING.ink};
469
+ --accent: ${DEFAULT_BRANDING.primary};
470
+ --muted: ${DEFAULT_BRANDING.muted};
471
+ --paper: #ffffff;
472
+ --desk: #eef0f1;
473
+ --hair: #e3e6e9;
474
+ --body: #3a434d;
475
+ --serif: 'Source Serif 4', Georgia, serif;
476
+ --sans: 'Source Sans 3', system-ui, sans-serif;
477
+ --mono: ui-monospace, Menlo, Consolas, monospace;
478
+ --ease: cubic-bezier(0.16, 1, 0.3, 1);
479
+ --shadow: 0 1px 2px rgba(20,30,40,0.06), 0 14px 34px -24px rgba(20,30,40,0.35);
480
+ }
287
481
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
482
+ html { -webkit-print-color-adjust: exact; print-color-adjust: exact; background: var(--desk); }
288
483
  body {
289
- font-family: 'Fira Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
290
- background: #0d1117;
291
- color: #c9d1d9;
484
+ font-family: var(--sans);
485
+ font-size: 15px;
486
+ background: var(--desk);
487
+ color: var(--ink);
292
488
  max-width: 1100px;
293
- margin: 2rem auto;
294
- padding: 0 1.25rem 4rem;
295
- line-height: 1.6;
489
+ margin: 0 auto;
490
+ padding: 2.5rem 1.25rem 4rem;
491
+ line-height: 1.5;
492
+ font-variant-numeric: tabular-nums;
296
493
  }
494
+ a { color: var(--accent); text-underline-offset: 2px; transition: color 150ms var(--ease); }
495
+ a:hover { color: ${BAD}; }
496
+ code { font-family: var(--mono); font-size: 0.86em; background: color-mix(in srgb, var(--accent) 7%, var(--paper)); padding: 0 3px; }
497
+ strong { font-weight: 650; }
297
498
 
298
499
  /* ── Header ── */
299
- .header { margin-bottom: 1.5rem; }
300
- .header h1 { color: #f0f6fc; font-size: 1.5rem; font-weight: 700; margin-bottom: 0.4rem; }
301
- .meta { font-size: 0.8rem; color: #8b949e; display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }
500
+ .header { margin-bottom: 1.75rem; }
501
+ .kicker { font-size: 13px; font-weight: 650; color: var(--accent); letter-spacing: 0.01em; }
502
+ .header h1 { font-family: var(--serif); font-size: 2.25rem; font-weight: 600; line-height: 1.12; letter-spacing: -0.012em; margin: 0.35rem 0 0.6rem; }
503
+ .meta { font-size: 0.8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem; }
504
+ .meta strong { color: var(--ink); }
302
505
 
303
- /* ── Dashboard ── */
304
- .dashboard { margin-bottom: 2rem; }
305
-
306
- .dash-top {
307
- display: grid;
308
- grid-template-columns: 1fr 1fr;
309
- gap: 0.75rem;
310
- margin-bottom: 0.75rem;
311
- }
312
- .dash-score-panel, .dash-risk-panel {
313
- background: #161b22;
314
- border: 1px solid #30363d;
315
- border-radius: 12px;
316
- padding: 1.5rem;
317
- display: flex;
318
- align-items: center;
319
- justify-content: center;
506
+ /* ── Panels: white paper on the grey desk, as in the executive report ── */
507
+ .inv-card, .attack-chain {
508
+ background: var(--paper);
509
+ box-shadow: var(--shadow);
320
510
  }
321
- /* The grade reason and coverage note sit under the gauge, not squeezed beside it. */
322
- .dash-score-panel { flex-direction: column; text-align: center; }
323
511
 
324
- /* Score ring */
325
- .gauge-wrap { display: flex; align-items: center; justify-content: center; }
326
- .score-ring {
327
- width: 152px;
328
- height: 152px;
329
- border-radius: 50%;
330
- padding: 11px;
331
- display: flex;
332
- align-items: center;
333
- justify-content: center;
512
+ /* ── Dashboard: one verdict band, then the org inventory ── */
513
+ .dashboard { margin-bottom: 2.75rem; }
514
+ .verdict {
515
+ display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); background: var(--paper); box-shadow: var(--shadow);
516
+ margin-bottom: 1rem;
334
517
  }
335
- .score-inner {
336
- width: 100%;
337
- height: 100%;
338
- border-radius: 50%;
339
- background: #161b22;
340
- display: flex;
341
- flex-direction: column;
342
- align-items: center;
343
- justify-content: center;
344
- gap: 0.4rem;
518
+ .verdict-grade { display: flex; gap: 1.25rem; align-items: flex-start; padding: 1.4rem 1.6rem; }
519
+ .grade-mark {
520
+ flex: none; width: 76px; height: 76px; display: grid; place-items: center; border: 1px solid var(--hair);
521
+ border-top: 4px solid var(--g); font-family: var(--serif); font-size: 46px; font-weight: 600; line-height: 1; color: var(--g);
345
522
  }
346
- .score-num {
347
- font-size: 2rem;
348
- font-weight: 700;
349
- line-height: 1;
350
- font-family: 'Fira Code', monospace;
351
- }
352
- .score-num span { font-size: 0.75rem; color: #8b949e; font-weight: 400; }
353
- .score-grade {
354
- display: inline-flex;
355
- align-items: center;
356
- justify-content: center;
357
- width: 1.75rem;
358
- height: 1.75rem;
359
- border-radius: 50%;
360
- font-size: 0.9rem;
361
- font-weight: 800;
362
- color: #fff;
363
- }
364
-
365
- /* Donut */
366
- .donut-wrap { display: flex; align-items: center; gap: 1.5rem; }
367
- .donut-legend { display: flex; flex-direction: column; gap: 0.45rem; }
368
- .legend-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: #c9d1d9; }
369
- .legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
370
- .legend-count { margin-left: auto; font-weight: 700; color: #f0f6fc; padding-left: 1rem; }
523
+ .grade-text { min-width: 0; }
524
+ .score-line { display: flex; align-items: baseline; gap: 0.3rem; }
525
+ .score-num { font-family: var(--serif); font-size: 2rem; font-weight: 600; line-height: 1; }
526
+ .score-of { font-size: 0.85rem; color: var(--muted); }
527
+ .grade-reason { margin-top: 0.35rem; font-size: 0.9rem; font-weight: 600; color: var(--ink); }
528
+ .coverage { margin-top: 0.35rem; font-size: 0.8rem; color: var(--muted); }
529
+ .coverage.is-capped { color: ${WARN}; }
530
+ .cov-more { display: inline; }
531
+ .cov-more summary { display: inline; cursor: pointer; color: var(--accent); margin-left: 0.4rem; list-style: none; }
532
+ .cov-more summary::-webkit-details-marker { display: none; }
533
+ .cov-more summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
534
+ .cov-more p { margin-top: 0.3rem; overflow-wrap: anywhere; }
535
+ .verdict-sev { padding: 1.4rem 1.6rem; border-left: 1px solid var(--hair); display: flex; flex-direction: column; gap: 0.65rem; }
536
+ .open-total { font-size: 0.9rem; color: var(--muted); }
537
+ .open-total b { font-family: var(--serif); font-size: 2rem; font-weight: 600; color: var(--ink); margin-right: 0.3rem; line-height: 1; }
538
+ .sev-bar { display: flex; height: 10px; background: var(--hair); }
539
+ .sev-bar i { display: block; height: 100%; }
540
+ .kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
541
+ .kpi-card { border-left: 3px solid var(--sev); padding: 0.1rem 0.75rem; }
542
+ .kpi-value { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; line-height: 1.1; color: var(--sev); }
543
+ .kpi-label { font-size: 0.68rem; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; }
371
544
 
372
- /* KPI strip */
373
- .kpi-strip {
374
- display: grid;
375
- grid-template-columns: repeat(4, 1fr);
376
- gap: 0.75rem;
377
- margin-bottom: 0.75rem;
378
- }
379
- .kpi-card {
380
- background: #161b22;
381
- border: 1px solid #30363d;
382
- border-radius: 10px;
383
- padding: 1rem 1.25rem;
545
+ /* Inventory grid */
546
+ .inv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
547
+ .inv-card { padding: 1.1rem 1.35rem 1.2rem; }
548
+ .inv-card-title {
549
+ font-size: 0.72rem; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase;
550
+ margin-bottom: 0.5rem; padding-bottom: 0.5rem; border-bottom: 1.5px solid var(--ink);
384
551
  }
385
- .kpi-value { font-size: 2rem; font-weight: 800; line-height: 1; margin-bottom: 0.25rem; }
386
- .kpi-label { font-size: 0.7rem; font-weight: 700; color: #8b949e; letter-spacing: 0.06em; }
552
+ .metric-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.32rem 0; border-bottom: 1px solid var(--hair); }
553
+ .metric-row:last-child { border-bottom: 0; }
554
+ .metric-label { flex: 1; font-size: 0.86rem; color: var(--body); }
555
+ .metric-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; min-width: 72px; }
556
+ .metric-value { font-size: 0.92rem; font-weight: 700; color: var(--ink); }
557
+ .prog-bar { width: 72px; height: 4px; background: var(--hair); overflow: hidden; }
558
+ .prog-fill { height: 100%; }
387
559
 
388
- /* Inventory grid */
389
- .inv-grid {
390
- display: grid;
391
- grid-template-columns: repeat(2, 1fr);
392
- gap: 0.75rem;
560
+ /* ── Section headings ── */
561
+ .attack-paths h2, .sec-h {
562
+ font-family: var(--serif); font-size: 1.75rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.005em; text-wrap: balance; max-width: 34em;
393
563
  }
394
- .inv-card {
395
- background: #161b22;
396
- border: 1px solid #30363d;
397
- border-radius: 10px;
398
- padding: 1rem 1.25rem;
564
+ .sec-h { margin-top: 0.35rem; }
565
+ .attack-paths h2::after, .sec-h::after { content: ''; display: block; width: 72px; height: 2px; background: var(--accent); margin: 0.9rem 0 0; }
566
+ .fix-first, .by-domain, .all-results { margin-bottom: 3rem; scroll-margin-top: 1rem; }
567
+ .sec-h + .subtitle, .sec-h + .scorecard, .sec-h + .tools, .sec-h + .tbl { margin-top: 1.1rem; }
568
+ .tbl { overflow-x: auto; }
569
+ .num { text-align: right; }
570
+ .none { color: var(--muted); }
571
+ .chips { display: flex; flex-wrap: wrap; gap: 4px; }
572
+ .chip { font-size: 0.72rem; font-weight: 700; padding: 0 5px; border: 1.25px solid #c9ced3; color: var(--body); white-space: nowrap; text-decoration: none; background: var(--paper); }
573
+ .chip.sev-critical { border-color: ${RISK_COLORS.CRITICAL}; color: ${RISK_COLORS.CRITICAL}; }
574
+ .chip.sev-high { border-color: ${RISK_COLORS.HIGH}; color: ${RISK_COLORS.HIGH}; }
575
+ .chip.part { font-weight: 600; color: var(--muted); }
576
+ a.chip:hover { background: #f6f7f8; }
577
+
578
+ /* ── Fix first (A) ── */
579
+ table.plan, table.results { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--paper); box-shadow: var(--shadow); }
580
+ table.plan th, table.results th {
581
+ text-align: left; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
582
+ padding: 0.85rem 0.75rem 0.5rem; border-bottom: 1.5px solid var(--ink); white-space: nowrap; background: var(--paper);
583
+ position: sticky; top: 0; z-index: 1;
399
584
  }
400
- .inv-card-title {
401
- font-size: 0.7rem;
402
- font-weight: 700;
403
- color: #8b949e;
404
- letter-spacing: 0.06em;
405
- text-transform: uppercase;
406
- margin-bottom: 0.6rem;
407
- padding-bottom: 0.5rem;
408
- border-bottom: 1px solid #21262d;
585
+ table.plan td, table.results td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--hair); vertical-align: top; }
586
+ table.plan tr.wave-h td { border-bottom: 0; padding: 1rem 0.75rem 0.2rem; font-size: 0.8rem; font-weight: 700; color: var(--accent); }
587
+ table.plan .why { font-weight: 400; color: var(--muted); }
588
+ table.plan .n { width: 2rem; color: var(--muted); font-weight: 700; }
589
+ table.plan .act b { display: block; color: var(--ink); font-weight: 650; }
590
+ table.plan .why-line { display: block; font-size: 0.82rem; color: var(--muted); margin-top: 0.1rem; max-width: 80ch; }
591
+ table.plan .effort { white-space: nowrap; color: var(--body); }
592
+ ul.closes { list-style: none; margin: 0.45rem 0 0; padding: 0; display: grid; gap: 0.25rem; }
593
+ ul.closes li { display: flex; gap: 0.5rem; align-items: baseline; font-size: 0.84rem; }
594
+ ul.closes .risk-badge { min-width: 4.4rem; font-size: 0.6rem; padding: 0 0.35rem; }
595
+ ul.closes .risk-badge.solid { background: var(--paper); color: var(--sev); }
596
+ ul.closes a { color: var(--body); text-decoration: none; }
597
+ ul.closes a:hover { color: var(--accent); text-decoration: underline; }
598
+ .chain-label { font-family: var(--sans); font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-right: 0.15rem; }
599
+ .attack-chain { scroll-margin-top: 1rem; padding: 0; }
600
+ .chain-sum { display: flex; gap: 0.9rem; align-items: flex-start; padding: 1rem 1.4rem; cursor: pointer; list-style: none; transition: background-color 150ms var(--ease); }
601
+ .chain-sum::-webkit-details-marker { display: none; }
602
+ .chain-sum:hover { background: #f6f7f8; }
603
+ .chain-sum:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
604
+ .chain-sum .risk-badge { margin-top: 0.2rem; }
605
+ .chain-text { flex: 1; min-width: 0; }
606
+ .chain-text h3 { margin-bottom: 0.15rem; }
607
+ .chain-gist { display: block; font-size: 0.86rem; color: var(--muted); max-width: 95ch; }
608
+ .attack-chain[open] .chevron { transform: rotate(90deg); }
609
+ .chain-body { padding: 0.2rem 1.6rem 1.4rem; border-top: 1px solid var(--hair); }
610
+ .chain-body > p:first-child { margin-top: 0.9rem; }
611
+ .attack-chain li a { color: inherit; }
612
+
613
+ /* ── By domain (C) ── */
614
+ .scorecard { background: var(--paper); box-shadow: var(--shadow); padding: 0.4rem 1.4rem; }
615
+ .dom-row {
616
+ display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 8.5rem; grid-template-areas: 'name bar counts' 'claim bar counts';
617
+ gap: 0.15rem 1.5rem; align-items: center; padding: 0.8rem 0; border-bottom: 1px solid var(--hair); color: inherit; text-decoration: none;
618
+ transition: background-color 150ms var(--ease);
409
619
  }
410
- .metric-row {
411
- display: flex;
412
- align-items: center;
413
- gap: 0.5rem;
414
- padding: 0.28rem 0;
620
+ .dom-row:last-child { border-bottom: 0; }
621
+ .dom-row:hover { background: #f6f7f8; }
622
+ .dom-row:hover .dom-claim span { color: var(--accent); }
623
+ .dom-name { grid-area: name; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
624
+ .dom-claim { grid-area: claim; display: flex; gap: 0.6rem; align-items: baseline; color: var(--ink); font-size: 0.92rem; min-width: 0; }
625
+ .dom-claim b { font-weight: 650; margin-right: 0.4rem; }
626
+ .dom-claim .worst { color: var(--muted); font-size: 0.86rem; }
627
+ .dom-claim > span:last-child { min-width: 0; overflow-wrap: anywhere; }
628
+ .dom-claim .risk-badge { min-width: 4.9rem; }
629
+ .bar { grid-area: bar; display: flex; height: 12px; background: var(--hair); }
630
+ .bar i, .bar-key i { display: block; height: 100%; }
631
+ .b-c { background: ${RISK_COLORS.CRITICAL}; } .b-h { background: ${RISK_COLORS.HIGH}; } .b-m { background: ${RISK_COLORS.MEDIUM}; } .b-l { background: ${RISK_COLORS.LOW}; }
632
+ .b-u { background: #d4d8dc; } .b-p { background: repeating-linear-gradient(135deg, #b8dcc4 0 3px, #d7ece0 3px 6px); }
633
+ .dom-counts { grid-area: counts; text-align: right; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
634
+ .dom-counts b { color: var(--ink); }
635
+ .bar-key { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin: 0.7rem 0 2rem; font-size: 0.75rem; color: var(--muted); }
636
+ .bar-key span { display: inline-flex; align-items: center; gap: 0.35rem; }
637
+ .bar-key i { width: 12px; height: 9px; }
638
+ .domain { margin-top: 2rem; scroll-margin-top: 1rem; }
639
+ .dom-h { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
640
+ .dom-sub { color: var(--muted); font-size: 0.88rem; margin: 0.2rem 0 0.8rem; max-width: 90ch; }
641
+ .passed-fold { margin-top: 0.6rem; }
642
+ .passed-fold > summary {
643
+ cursor: pointer; list-style: none; font-size: 0.82rem; font-weight: 700; color: ${GOOD}; padding: 0.4rem 0;
415
644
  }
416
- .metric-label { flex: 1; font-size: 0.82rem; color: #c9d1d9; }
417
- .metric-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; min-width: 72px; }
418
- .metric-value { font-size: 0.9rem; font-weight: 700; color: #f0f6fc; }
419
- .prog-bar { width: 72px; height: 4px; background: #21262d; border-radius: 2px; overflow: hidden; }
420
- .prog-fill { height: 100%; border-radius: 2px; }
645
+ .passed-fold > summary::-webkit-details-marker { display: none; }
646
+ .passed-fold > summary::before { content: '+ '; }
647
+ .passed-fold[open] > summary::before { content: '− '; }
648
+ .passed-fold > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
649
+ .waived-mark { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); border: 1px dashed var(--muted); padding: 0.05rem 0.35rem; margin-left: 0.35rem; }
421
650
 
422
- /* ── Filters ── */
423
- .filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
424
- .filter-btn {
425
- padding: 0.35rem 0.9rem;
426
- border-radius: 20px;
427
- border: 1px solid #30363d;
428
- background: #161b22;
429
- color: #8b949e;
430
- cursor: pointer;
431
- font-size: 0.8rem;
432
- font-weight: 600;
433
- transition: all 0.15s;
434
- }
435
- .filter-btn:hover { border-color: #58a6ff; color: #58a6ff; }
436
- .filter-btn.active {
437
- background: var(--accent, #238636);
438
- border-color: var(--accent, #238636);
439
- color: #fff;
651
+ /* ── All results (D) ── */
652
+ .tools { display: flex; flex-wrap: wrap; gap: 0.6rem 1.25rem; align-items: center; margin-bottom: 0.8rem; }
653
+ .seg { display: inline-flex; border: 1.25px solid #cfd4d9; background: var(--paper); }
654
+ .seg button {
655
+ font: 700 0.78rem var(--sans); color: var(--body); background: transparent; border: 0; border-left: 1px solid #cfd4d9;
656
+ padding: 0.35rem 0.75rem; cursor: pointer; transition: background-color 150ms var(--ease), color 150ms var(--ease);
440
657
  }
658
+ .seg button:first-child { border-left: 0; }
659
+ .seg button:hover { color: var(--accent); }
660
+ .seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
661
+ .seg button:focus-visible, .tools input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
662
+ .tool-check, .tool-search { font-size: 0.82rem; color: var(--body); display: inline-flex; gap: 0.4rem; align-items: center; }
663
+ .tool-search input { font: 0.88rem var(--sans); border: 1.25px solid #cfd4d9; padding: 0.3rem 0.55rem; width: 15rem; max-width: 60vw; color: var(--ink); background: var(--paper); }
664
+ table.results tr.grp td { font-size: 0.78rem; font-weight: 700; color: var(--accent); padding-top: 1rem; border-bottom: 1px solid var(--accent); }
665
+ table.results td:nth-child(2) a { color: var(--ink); font-weight: 600; text-decoration: none; }
666
+ table.results td:nth-child(2) a:hover { color: var(--accent); text-decoration: underline; }
667
+ .row-dom { display: block; font-size: 0.76rem; color: var(--muted); }
668
+ .no-match { color: var(--muted); padding: 1rem 0; }
669
+ .finding-card { scroll-margin-top: 1rem; }
670
+ .finding-card:target { box-shadow: 0 0 0 2px var(--accent); }
671
+ .subtitle { color: var(--muted); font-size: 0.9rem; margin: 0.9rem 0 1.25rem; max-width: 70ch; }
672
+
673
+ /* ── Attack paths ── */
674
+ .attack-paths { margin-bottom: 2.75rem; }
675
+ .attack-chain { border-left: 3px solid var(--chain); margin-bottom: 0.6rem; color: var(--body); font-size: 0.92rem; }
676
+ .attack-chain.severity-critical { --chain: ${RISK_COLORS.CRITICAL}; }
677
+ .attack-chain.severity-high { --chain: ${RISK_COLORS.HIGH}; }
678
+ .attack-chain.severity-medium { --chain: ${RISK_COLORS.MEDIUM}; }
679
+ .attack-chain.severity-low { --chain: ${RISK_COLORS.LOW}; }
680
+ .attack-chain h3 { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; color: var(--ink); line-height: 1.3; }
681
+ .attack-chain p { margin-bottom: 0.6rem; max-width: 95ch; }
682
+ .attack-chain svg { max-width: 100%; height: auto; margin: 0.5rem 0 0.75rem; }
683
+ .attack-chain ol { padding-left: 1.3rem; margin-bottom: 0.75rem; }
684
+ .attack-chain li { margin-bottom: 0.3rem; }
685
+ .attack-chain .remediation { border-left: 2px solid var(--accent); padding-left: 0.85rem; }
441
686
 
442
- /* ── Finding cards ── */
443
687
  .finding-card {
444
- background: var(--card-bg);
445
- border: 1px solid #30363d;
688
+ background: var(--paper);
689
+ border: 1px solid var(--hair);
446
690
  border-left: 3px solid var(--card-accent);
447
- border-radius: 8px;
448
- margin-bottom: 0.6rem;
691
+ margin-bottom: 0.5rem;
449
692
  overflow: hidden;
693
+ transition: box-shadow 200ms var(--ease);
450
694
  }
451
- .finding-card[open] { border-color: var(--card-accent); }
695
+ .finding-card:hover, .finding-card[open] { box-shadow: var(--shadow); }
452
696
  .finding-summary {
453
- display: flex;
454
- align-items: center;
455
- gap: 0.75rem;
456
- padding: 0.75rem 1rem;
457
- cursor: pointer;
458
- list-style: none;
459
- user-select: none;
697
+ display: flex; align-items: center; gap: 0.8rem; padding: 0.75rem 1rem;
698
+ cursor: pointer; list-style: none; user-select: none;
699
+ transition: background-color 150ms var(--ease);
460
700
  }
461
701
  .finding-summary::-webkit-details-marker { display: none; }
462
- .finding-summary:hover { background: rgba(255,255,255,0.03); }
702
+ .finding-summary:hover { background: #f6f7f8; }
703
+ .finding-summary:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
463
704
  .risk-badge {
464
- flex-shrink: 0;
465
- padding: 0.15rem 0.6rem;
466
- border-radius: 4px;
467
- font-size: 0.7rem;
468
- font-weight: 800;
469
- color: #fff;
470
- letter-spacing: 0.04em;
705
+ display: inline-block; flex-shrink: 0; min-width: 4.9rem; text-align: center; vertical-align: 0.15em;
706
+ padding: 0.05rem 0.45rem; font-family: var(--sans); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em;
707
+ color: var(--sev); border: 1.25px solid var(--sev); background: var(--paper);
471
708
  }
472
- .finding-title { flex: 1; font-weight: 600; color: #e6edf3; font-size: 0.9rem; }
473
- .finding-category { font-size: 0.75rem; color: #8b949e; white-space: nowrap; }
474
- .chevron { color: #8b949e; font-size: 1.2rem; transition: transform 0.2s; }
709
+ .risk-badge.solid { background: var(--sev); color: #fff; }
710
+ .attack-chain h3 .risk-badge { min-width: 0; margin-right: 0.35rem; }
711
+ .finding-title { flex: 1; font-weight: 600; color: var(--ink); font-size: 0.93rem; }
712
+ .finding-category { font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
713
+ .chevron { color: var(--muted); font-size: 1.2rem; transition: transform 200ms var(--ease); }
475
714
  .finding-card[open] .chevron { transform: rotate(90deg); }
476
- .finding-body { padding: 0 1rem 1rem; border-top: 1px solid #30363d; }
477
- .finding-detail { color: #c9d1d9; font-size: 0.875rem; padding: 0.75rem 0 0.5rem; }
715
+ .finding-body { padding: 0 1rem 1.1rem; border-top: 1px solid var(--hair); }
716
+ .finding-detail { color: var(--body); font-size: 0.9rem; padding: 0.8rem 0 0.5rem; max-width: 95ch; }
478
717
  .remediation-box {
479
- background: rgba(35,134,54,0.1);
480
- border: 1px solid rgba(35,134,54,0.3);
481
- border-radius: 6px;
482
- padding: 0.75rem;
718
+ background: color-mix(in srgb, var(--accent) 6%, var(--paper));
719
+ border-left: 2px solid var(--accent);
720
+ padding: 0.7rem 0.9rem;
483
721
  margin-top: 0.5rem;
484
- font-size: 0.85rem;
485
- }
486
- .remediation-box strong { color: #3fb950; display: block; margin-bottom: 0.25rem; }
487
- .affected-items { margin-top: 0.75rem; font-size: 0.82rem; }
488
- .affected-items strong { color: #c9d1d9; display: block; margin-bottom: 0.5rem; }
489
- .affected-table {
490
- width: 100%;
491
- border-collapse: collapse;
492
- font-size: 0.8rem;
493
- font-family: 'Menlo', 'Consolas', monospace;
722
+ font-size: 0.88rem;
723
+ color: var(--body);
494
724
  }
725
+ .remediation-box strong { color: var(--accent); display: block; margin-bottom: 0.2rem; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; }
726
+ .affected-items { margin-top: 0.85rem; font-size: 0.84rem; }
727
+ .affected-items strong { color: var(--ink); display: block; margin-bottom: 0.45rem; }
728
+ .affected-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-family: var(--mono); }
495
729
  .affected-table th {
496
- background: #1c2128;
497
- color: #8b949e;
498
- text-align: left;
499
- padding: 0.4rem 0.6rem;
500
- border-bottom: 1px solid #30363d;
501
- font-weight: 600;
502
- white-space: nowrap;
503
- }
504
- .affected-table td {
505
- padding: 0.35rem 0.6rem;
506
- border-bottom: 1px solid #21262d;
507
- color: #c9d1d9;
508
- vertical-align: top;
509
- word-break: break-word;
730
+ font-family: var(--sans); color: var(--muted); text-align: left; padding: 0 0.6rem 0.4rem 0;
731
+ border-bottom: 1.5px solid var(--ink); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap;
510
732
  }
733
+ .affected-table td { padding: 0.4rem 0.6rem 0.4rem 0; border-bottom: 1px solid var(--hair); color: var(--body); vertical-align: top; word-break: break-word; }
511
734
  .affected-table tr:last-child td { border-bottom: none; }
512
- .affected-table a { color: #58a6ff; text-decoration: none; white-space: nowrap; }
513
- .affected-table a:hover { text-decoration: underline; }
735
+ .affected-table a { white-space: nowrap; }
514
736
 
515
- .no-findings { color: #8b949e; text-align: center; padding: 3rem 0; }
737
+ .no-findings { color: var(--muted); text-align: center; padding: 3rem 0; }
516
738
 
517
739
  /* ── Compliance tags ── */
518
- .compliance-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem; }
740
+ .compliance-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.7rem; }
519
741
  .compliance-tag {
520
- font-size: 0.65rem;
521
- font-weight: 700;
522
- padding: 0.1rem 0.45rem;
523
- border-radius: 3px;
524
- background: rgba(88,166,255,0.12);
525
- border: 1px solid rgba(88,166,255,0.25);
526
- color: #58a6ff;
527
- letter-spacing: 0.03em;
528
- white-space: nowrap;
742
+ font-size: 0.66rem; font-weight: 700; padding: 0.05rem 0.4rem;
743
+ border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--paper));
744
+ color: var(--accent); letter-spacing: 0.03em; white-space: nowrap;
529
745
  }
530
746
  /* ── Inconclusive findings ── */
531
- .finding-card.is-inconclusive {
532
- border-left-color: #8b949e !important;
533
- opacity: 0.8;
534
- }
535
- .finding-card.is-inconclusive .finding-summary { background: rgba(139,148,158,0.05); }
747
+ .finding-card.is-inconclusive { border-left-style: dashed; }
748
+ .finding-card.is-inconclusive .finding-title { color: var(--body); }
536
749
  .inconclusive-badge {
537
- flex-shrink: 0;
538
- padding: 0.15rem 0.6rem;
539
- border-radius: 4px;
540
- font-size: 0.7rem;
541
- font-weight: 800;
542
- color: #8b949e;
543
- border: 1px dashed #8b949e;
544
- letter-spacing: 0.04em;
750
+ flex-shrink: 0; min-width: 4.9rem; text-align: center;
751
+ padding: 0.08rem 0.45rem; font-size: 0.68rem; font-weight: 700;
752
+ color: var(--muted); border: 1px dashed var(--muted); letter-spacing: 0.05em;
753
+ }
754
+ /* ── Accepted risks ── */
755
+ .waived-banner {
756
+ background: #f0f7f2; border-left: 3px solid ${GOOD}; padding: 0.75rem 1rem; margin-bottom: 1.25rem;
757
+ color: #14532d; font-size: 0.86rem;
545
758
  }
546
759
  /* ── Offline footer ── */
547
760
  .offline-footer {
548
- margin-top: 3rem;
549
- padding: 0.75rem 1rem;
550
- border-radius: 8px;
551
- background: rgba(34,197,94,0.05);
552
- border: 1px solid rgba(34,197,94,0.15);
553
- font-size: 0.78rem;
554
- color: #8b949e;
555
- text-align: center;
761
+ margin-top: 3rem; padding-top: 0.85rem; border-top: 1px solid #cfd4d9;
762
+ font-size: 0.78rem; color: var(--muted);
556
763
  }
557
- .offline-footer strong { color: #3fb950; }
764
+ .offline-footer strong { color: var(--ink); }
558
765
 
766
+ @media (prefers-reduced-motion: reduce) {
767
+ *, *::before, *::after { transition: none !important; }
768
+ }
769
+ @media print {
770
+ html, body { background: #fff; }
771
+ .verdict, .inv-card, .attack-chain { box-shadow: none; border: 1px solid var(--hair); }
772
+ .tools, .chevron { display: none; }
773
+ table.plan th, table.results th { position: static; }
774
+ .passed-fold > .finding-card { break-inside: avoid; }
775
+ }
559
776
  /* ── Responsive ── */
560
777
  @media (max-width: 680px) {
561
- .dash-top { grid-template-columns: 1fr; }
562
- .kpi-strip { grid-template-columns: repeat(2, 1fr); }
778
+ body { padding-top: 1.5rem; }
779
+ .header h1 { font-size: 1.75rem; }
780
+ .verdict { grid-template-columns: 1fr; }
781
+ .verdict-sev { border-left: 0; border-top: 1px solid var(--hair); }
782
+ .verdict-grade { padding: 1.1rem; gap: 0.9rem; }
783
+ .grade-mark { width: 60px; height: 60px; font-size: 36px; }
563
784
  .inv-grid { grid-template-columns: 1fr; }
785
+ .finding-summary { flex-wrap: wrap; }
786
+ .dom-row { grid-template-columns: 1fr; grid-template-areas: 'name' 'claim' 'bar' 'counts'; }
787
+ .dom-counts { text-align: left; }
788
+ .scorecard { padding: 0.4rem 1rem; }
789
+ .finding-category { display: none; }
790
+ .dom-claim { flex-direction: column; gap: 0.3rem; }
791
+ table.plan thead { display: none; }
792
+ table.plan, table.plan tbody, table.plan tr, table.plan td { display: block; width: 100%; }
793
+ table.plan tr { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--hair); }
794
+ table.plan td { border: 0; padding: 0.15rem 0; }
795
+ table.plan tr.wave-h td { padding: 0.6rem 0 0; }
796
+ table.plan .n { display: inline; }
797
+ table.plan td.num::before { content: 'Closes '; color: var(--muted); }
798
+ table.plan td.num { text-align: left; }
799
+ table.plan td.effort::before { content: 'Effort '; color: var(--muted); }
800
+ }
801
+ @media (min-width: 681px) and (max-width: 1000px) {
802
+ .inv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
564
803
  }
565
804
  </style>
566
805
  </head>
567
806
  <body>
568
807
  <div class="header">
808
+ <div class="kicker">Technical findings</div>
569
809
  <h1>Salesforce Security Audit</h1>
570
810
  <div class="meta">
571
- <span>Org: <strong style="color:#c9d1d9">${esc(result.orgName)}</strong></span>
811
+ <span>Org: <strong>${esc(result.orgName)}</strong></span>
572
812
  <span>ID: ${esc(result.orgId)}</span>
573
813
  <span>Instance: ${esc(result.instance)}</span>
574
814
  <span>Type: ${esc(result.orgType)}${result.isSandbox ? ' (Sandbox)' : ''}</span>
@@ -578,33 +818,81 @@ ${firaFontFaceCss()}
578
818
 
579
819
  ${buildDashboard(result, openCounts(result))}
580
820
 
581
- ${attackPathsHtml}
582
-
583
- <div class="filters">
584
- ${filterButtons}
585
- </div>
586
-
587
- <div id="findings-list">
588
- ${findingsHtml}
589
- </div>
821
+ ${bodyHtml}
590
822
 
591
823
  <script>
592
- const buttons = document.querySelectorAll('.filter-btn');
593
- const cards = document.querySelectorAll('.finding-card');
594
-
595
- buttons.forEach(btn => {
596
- btn.addEventListener('click', () => {
597
- buttons.forEach(b => b.classList.remove('active'));
598
- btn.classList.add('active');
599
- const filter = btn.dataset.filter;
600
- cards.forEach(card => {
601
- card.style.display = (filter === 'all' || card.dataset.risk === filter) ? '' : 'none';
602
- });
824
+ (function () {
825
+ function reveal() {
826
+ var id;
827
+ try { id = decodeURIComponent(location.hash.slice(1)); } catch (e) { return; }
828
+ var el = id && document.getElementById(id);
829
+ for (var n = el; n; n = n.parentElement) if (n.tagName === 'DETAILS') n.open = true;
830
+ if (el) el.scrollIntoView();
831
+ }
832
+ window.addEventListener('hashchange', reveal);
833
+ // Following the same link twice fires no hashchange, so reopen on every in-page link click too.
834
+ document.addEventListener('click', function (e) {
835
+ var a = e.target.closest && e.target.closest('a[href^="#"]');
836
+ if (a && a.getAttribute('href') === location.hash) setTimeout(reveal, 0);
837
+ });
838
+ if (location.hash) reveal();
839
+ })();
840
+ (function () {
841
+ var body = document.getElementById('results-body');
842
+ if (!body) return;
843
+ var rows = Array.prototype.slice.call(body.querySelectorAll('tr[data-st]'));
844
+ var buttons = Array.prototype.slice.call(document.querySelectorAll('.seg button'));
845
+ var search = document.getElementById('result-search');
846
+ var showPassed = document.getElementById('show-passed');
847
+ var noMatch = document.getElementById('no-match');
848
+ var group = 'sev';
849
+ var SEV = ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW', 'INFO', 'WAIVED', 'INCONCLUSIVE', 'PASSED'];
850
+ function keys(row) {
851
+ var v = row.dataset[group] || '';
852
+ if (group === 'sev' || group === 'dom') return [v];
853
+ var list = v.split(' ').filter(Boolean);
854
+ return list.length ? list : [group === 'ch' ? 'Not on an attack chain' : 'No framework tag'];
855
+ }
856
+ function render() {
857
+ var term = search.value.trim().toLowerCase();
858
+ var groups = {}, order = [];
859
+ rows.forEach(function (row) {
860
+ var visible = (showPassed.checked || row.dataset.st !== 'passed') &&
861
+ (!term || row.textContent.toLowerCase().indexOf(term) >= 0 || (row.dataset.fw + ' ' + row.dataset.ch).toLowerCase().indexOf(term) >= 0);
862
+ if (!visible) return;
863
+ keys(row).forEach(function (k) { if (!groups[k]) { groups[k] = []; order.push(k); } groups[k].push(row); });
864
+ });
865
+ if (group === 'sev') order.sort(function (a, b) { return SEV.indexOf(a) - SEV.indexOf(b); });
866
+ else order.sort(function (a, b) { return groups[b].length - groups[a].length || a.localeCompare(b, undefined, { numeric: true }); });
867
+ var frag = document.createDocumentFragment();
868
+ order.forEach(function (k) {
869
+ var head = document.createElement('tr');
870
+ head.className = 'grp';
871
+ var cell = document.createElement('td');
872
+ cell.colSpan = 4;
873
+ cell.textContent = k + ' · ' + groups[k].length;
874
+ head.appendChild(cell);
875
+ frag.appendChild(head);
876
+ groups[k].forEach(function (row) { var r = row.cloneNode(true); r.hidden = false; frag.appendChild(r); });
877
+ });
878
+ body.textContent = '';
879
+ body.appendChild(frag);
880
+ noMatch.hidden = order.length > 0;
881
+ }
882
+ buttons.forEach(function (b) {
883
+ b.addEventListener('click', function () {
884
+ group = b.dataset.group;
885
+ buttons.forEach(function (x) { x.setAttribute('aria-pressed', String(x === b)); });
886
+ render();
603
887
  });
604
888
  });
889
+ search.addEventListener('input', render);
890
+ showPassed.addEventListener('change', render);
891
+ render();
892
+ })();
605
893
  </script>
606
894
  <div class="offline-footer">
607
- <strong>Offline-first audit:</strong> all analysis performed locally; no data is transmitted outside your Salesforce org. Generated by <a href="https://github.com/cclabsnz/sf-audit-plugin" style="color:inherit">sf-audit</a>, built by <a href="https://cloudcounsel.co.nz" style="color:inherit">CloudCounsel</a>.
895
+ <strong>Offline-first audit:</strong> all analysis performed locally; no data is transmitted outside your Salesforce org. Generated by <a href="https://github.com/cclabsnz/sf-audit-plugin">sf-audit</a>, built by <a href="https://cloudcounsel.co.nz">CloudCounsel</a>.
608
896
  </div>
609
897
  </body>
610
898
  </html>`;