filegrc 0.4.0 → 0.5.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.
package/src/web.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  utcCalendarDate,
9
9
  validCalendarRecurrence
10
10
  } from "./recurrence.js";
11
- import { PROGRAM_PATH, RESOURCE_INSTRUCTIONS } from "./program-path.js";
11
+ import { PROGRAM_PATH, RESOURCE_INSTRUCTIONS, RESOURCE_PAGE_SUMMARIES } from "./program-path.js";
12
12
  import { formatCalendarDate, formatLocalDateTime } from "./time.js";
13
13
 
14
14
  export function renderIndex(state = null) {
@@ -50,9 +50,10 @@ const READINESS_STAGES = SHARED_PROGRAM_STAGES.map((stage) => ({
50
50
  ...stage,
51
51
  number: String(stage.number)
52
52
  }));
53
+ const RESOURCE_GUIDE_INSTRUCTIONS = ${JSON.stringify(RESOURCE_INSTRUCTIONS)};
53
54
  const STAGE_PAGE_SUMMARIES = ${JSON.stringify({
54
- ...RESOURCE_INSTRUCTIONS,
55
- "utility:audit-packet": "Review filegrc Evidence and External Evidence for the formal period, complete engagement preparation, and build the indexed audit packet."
55
+ ...RESOURCE_PAGE_SUMMARIES,
56
+ "utility:audit-packet": "Review fieldwork readiness and build the indexed evidence packet."
56
57
  })};
57
58
  const RECORD_TEXT_FIELDS = new Set(["description", "statement", "activity", "purpose", "scope", "objective", "applicabilityRationale", "summary", "rationale", "businessPurpose", "changeSummary", "decisionSummary", "decisionRationale", "recommendation", "remediationPlan", "auditorNotes", "notPerformedReason"]);
58
59
  const FINDING_SOURCE_TYPES = new Set(["control-test", "policy-review", "meeting", "risk", "risk-assessment", "vendor-review", "access-review", "incident", "exercise", "backup-test", "penetration-test", "audit"]);
@@ -253,7 +254,7 @@ function renderHome(main) {
253
254
  : "";
254
255
  main.innerHTML = '<div class="page home-page"><section class="hero overview-hero"><div><p class="kicker">Current program state</p><h2>' + esc(titleCase(state.workspace.title)) + '</h2><p>' + esc(state.workspace.description || "Governance, risk, controls, evidence, and audit work maintained as plain files in Git.") + '</p></div></section>' + setupBanner + readinessOverview() +
255
256
  '<div class="overview-grid"><section class="panel obligation-panel"><div class="panel-head"><div><p class="kicker">Policy obligations</p><h3>' + obligationHeading + '</h3></div><a href="#/stage/run">Open board</a></div>' + obligationPreview(previewObligations) + '</section>' +
256
- '<section class="panel event-reminder-panel"><div class="panel-head"><div><p class="kicker">Event reminders</p><h3>Did Something Change?</h3></div><a href="#/stage/run?section=events">' + (acceptedEventTriggers.length ? "Trigger work" : "Review proposals") + '</a></div>' + eventReminderPreview(state.obligations.triggers.slice(0, 4)) + '</section>' +
257
+ '<section class="panel event-reminder-panel"><div class="panel-head"><div><p class="kicker">Event reminders</p><h3>Did Something Change?</h3></div><a href="#/stage/run?section=events">' + (acceptedEventTriggers.length ? "Trigger work" : "Review proposals") + '</a></div>' + eventReminderPreview(orderedPolicyEventTriggers(state.obligations.triggers).slice(0, 4)) + '</section>' +
257
258
  auditPanel + '</div></div>';
258
259
  main.querySelector("#resume-setup")?.addEventListener("click", requestOnboarding);
259
260
  }
@@ -273,29 +274,29 @@ function initialSetupBanner() {
273
274
  ? "Choose the program goal."
274
275
  : "Confirm the saved program goal: " + goalLabels[goal] + ".";
275
276
  const completion = system.status === "planned"
276
- ? "Complete setup to activate the planned service and continue to Step 1."
277
- : "Complete setup to close onboarding and continue to Step 1.";
278
- return '<section class="setup-banner"><div><p class="kicker">Setup draft saved</p><h3>Review and complete initial setup</h3><p>' + esc(system.title) + ' already has a saved service boundary.</p></div><ol><li>Review the saved service boundary.</li><li>' + esc(goalStep) + '</li><li>' + esc(completion) + '</li><li><button class="text-button" type="button" id="resume-setup">Resume setup</button></li></ol></section>';
277
+ ? "Confirm the service scope to activate the planned service and continue to Step 1."
278
+ : "Confirm the service scope to close onboarding and continue to Step 1.";
279
+ return '<section class="setup-banner"><div><p class="kicker">Setup draft saved</p><h3>Review the initial service scope</h3><p>' + esc(system.title) + ' already has a saved service boundary.</p></div><ol><li>Review the saved service boundary.</li><li>' + esc(goalStep) + '</li><li>' + esc(completion) + '</li><li><button class="text-button" type="button" id="resume-setup">Resume setup</button></li></ol></section>';
279
280
  }
280
281
 
281
282
  function readinessOverview() {
282
283
  const progress = programPathProgress();
283
284
  const nextHref = nextProgramStageHref();
284
- const programStage = (id, body, href) => {
285
+ const programStage = (id, href) => {
285
286
  const stage = READINESS_STAGES.find((candidate) => candidate.id === id);
286
287
  const current = stageProgress(stage);
287
288
  const remaining = current.total - current.complete;
288
- const status = !remaining ? "Review complete" : current.complete ? remaining + " pages to review" : "Review not marked";
289
- return [stage.title, body, href, status, !remaining ? "good" : current.complete ? "warn" : "neutral"];
289
+ const status = !remaining ? "Ready" : current.complete ? remaining + " pages need work" : "Needs work";
290
+ return [stage.title, stage.summary, href, status, !remaining ? "good" : current.complete ? "warn" : "neutral"];
290
291
  };
291
292
  const stages = [
292
- programStage("scope", "Confirm program ownership, criteria, and commitments, then describe the service, supporting systems, and dependencies.", "#/stage/scope"),
293
- programStage("policies", "Tailor the policy set, obtain independent management approval, and establish effective dates.", "#/stage/policies"),
294
- programStage("controls", "Finish the internal control set and every authoritative evidence source, then record any complementary controls.", "#/stage/controls"),
295
- programStage("run", "Begin the candidate period, maintain risk assessments, work the filegrc queue, run the remaining controls, and retain dated evidence.", "#/stage/run"),
296
- programStage("audit", "Engage the CPA firm, confirm the formal period, complete fieldwork, and generate the final evidence packet.", "#/stage/audit")
293
+ programStage("scope", "#/stage/scope"),
294
+ programStage("policies", "#/stage/policies"),
295
+ programStage("controls", "#/stage/controls"),
296
+ programStage("run", "#/stage/run"),
297
+ programStage("audit", "#/stage/audit")
297
298
  ];
298
- return '<section class="readiness-map"><div class="readiness-map-head"><div><p class="kicker">SOC 2 program path</p><h3>Prepare, Operate, Then Audit</h3></div><div class="readiness-progress-summary"><div><span>Page Review Progress</span><strong>' + progress.percent + '%</strong><div class="progress"><span style="width:' + progress.percent + '%"></span></div><small>' + esc(progress.complete + " of " + progress.total + " program pages marked reviewed") + '</small></div><a class="button primary" href="' + nextHref + '">Continue</a></div></div><div class="readiness-flow">' + stages.map(([title, body, href, status, tone], index) => '<a href="' + href + '"><span>' + (index + 1) + '</span><strong>' + esc(title) + '</strong><small>' + esc(body) + '</small><b class="readiness-state ' + esc(tone) + '">' + esc(status) + '</b></a>').join("") + '</div></section>';
299
+ return '<section class="readiness-map"><div class="readiness-map-head"><div><p class="kicker">SOC 2 program path</p><h3>Prepare, Operate, Then Audit</h3></div><div class="readiness-progress-summary"><div><span>Program readiness</span><strong>' + progress.percent + '%</strong><div class="progress"><span style="width:' + progress.percent + '%"></span></div><small>' + esc(progress.complete + " of " + progress.total + " program pages " + (progress.complete === 1 ? "is" : "are") + " ready") + '</small></div><a class="button primary" href="' + nextHref + '">Continue</a></div></div><div class="readiness-flow">' + stages.map(([title, body, href, status, tone], index) => '<a href="' + href + '"><span>' + (index + 1) + '</span><strong>' + esc(title) + '</strong><small>' + esc(body) + '</small><b class="readiness-state ' + esc(tone) + '">' + esc(status) + '</b></a>').join("") + '</div></section>';
299
300
  }
300
301
 
301
302
  function nextProgramStageHref() {
@@ -317,6 +318,249 @@ function renderStageOverview(main, stageId, params = new URLSearchParams()) {
317
318
  renderStagePageIndex(stage) + (stage.id === "controls" ? renderEvidenceReadiness() : "") + '</div>';
318
319
  }
319
320
 
321
+ function workflowGuidance(options = {}) {
322
+ const workflow = state.workflow;
323
+ if (!workflow) return "";
324
+ const matches = (item) => {
325
+ if (options.stageId && item.stage !== options.stageId) return false;
326
+ if (options.type && item.subject?.type !== options.type && item.source?.type !== options.type) return false;
327
+ if (options.id && item.subject?.id !== options.id && item.source?.id !== options.id) return false;
328
+ return true;
329
+ };
330
+ const activeStates = new Set(["blocked", "due", "open", "overdue", "ready", "scheduled", "upcoming", "waiting-external"]);
331
+ const findings = workflow.findings.filter(matches);
332
+ const workItems = workflow.workItems.filter((item) => matches(item) && activeStates.has(item.state));
333
+ const items = [...findings, ...workItems].sort((left, right) => (
334
+ workflowItemStatePriority(left) - workflowItemStatePriority(right)
335
+ || (left.priority ?? workflowItemPriority(left)) - (right.priority ?? workflowItemPriority(right))
336
+ || left.key.localeCompare(right.key)
337
+ ));
338
+ if (!items.length) return "";
339
+ const blocking = items.filter((item) => ["blocked", "due", "open", "overdue", "ready"].includes(item.state));
340
+ const status = blocking.length
341
+ ? blocking.length + " " + pluralize("item", blocking.length) + (blocking.length === 1 ? " needs work" : " need work")
342
+ : items.length + " scheduled or external";
343
+ const visible = items.slice(0, 6);
344
+ const rows = visible.map((item) => {
345
+ const href = workflowItemHref(item);
346
+ const body = '<span class="workflow-finding-status ' + esc(item.state) + '">' + esc(properCase(item.state)) + '</span><span><strong>' + esc(item.title) + '</strong><small>' + esc(item.message || workflowItemDetail(item)) + '</small></span>';
347
+ return href ? '<a href="' + href + '">' + body + '</a>' : '<div>' + body + '</div>';
348
+ }).join("");
349
+ return '<section class="workflow-guidance panel"><div class="panel-head"><div><p class="kicker">To-do</p><h3>' + esc(options.title || "Checklist") + '</h3><p>' + esc(status) + '</p></div><span class="badge ' + (blocking.length ? "warn" : "good") + '">' + (blocking.length ? "Needs work" : "Current") + '</span></div><div class="workflow-findings">' + rows + '</div>' + (items.length > visible.length ? '<p class="workflow-guidance-more">Showing ' + visible.length + ' of ' + items.length + ' items. Use <code>filegrc workflow --json</code> for the complete reproducible result.</p>' : "") + '</section>';
350
+ }
351
+
352
+ function collectionReviewPanel(type) {
353
+ const assessment = state.collectionReviews?.[type];
354
+ if (!assessment) return "";
355
+ const configuration = assessment.configuration;
356
+ const current = assessment.status === "current";
357
+ const reviewerNames = (assessment.review?.reviewedByIds || [])
358
+ .map((id) => state.resources.find(({ record }) => record.id === id)?.record.title || id);
359
+ const reviewSummary = current
360
+ ? '<p class="collection-review-result"><strong>' + esc(properCase(assessment.review.decision)) + '</strong><span>Reviewed ' + esc(formatCalendarDate(assessment.review.reviewedOn)) + (reviewerNames.length ? " by " + esc(reviewerNames.join(", ")) : "") + '.</span></p>'
361
+ : '<p class="collection-review-result"><strong>' + (assessment.status === "stale" ? "Review again" : "Review required") + '</strong><span>' + esc(assessment.message) + '</span></p>';
362
+ return '<section class="collection-review-panel panel ' + (current ? "current" : "required") + '"><div class="collection-review-head"><div><p class="kicker">Scope confirmation</p><h3>' + esc(configuration.title) + '</h3><p>' + esc(configuration.description) + '</p></div><span class="badge ' + (current ? "good" : "warn") + '">' + (current ? "Reviewed" : assessment.status === "stale" ? "Stale" : "Review required") + '</span></div>' +
363
+ '<details ' + (current ? "" : "open") + '><summary>What to review</summary><ul>' + configuration.reviewPoints.map((point) => '<li>' + esc(point) + '</li>').join("") + '</ul></details>' +
364
+ '<div class="collection-review-foot">' + reviewSummary + (!state.readOnly ? '<button class="button ' + (current ? "" : "primary") + '" type="button" data-review-collection="' + esc(type) + '">' + (current ? "Review again" : "Review and confirm") + '</button>' : "") + '</div></section>';
365
+ }
366
+
367
+ function resourceReviewCriteria(type) {
368
+ const reviewPoints = state.model.resources[type]?.guidance?.reviewPoints || [];
369
+ if (!reviewPoints.length) return "";
370
+ return '<section class="resource-review-criteria"><strong>What the reviewer should check</strong><ul>' + reviewPoints.map((point) => '<li>' + esc(point) + '</li>').join("") + '</ul></section>';
371
+ }
372
+
373
+ function recordWorkflowItems(type, id) {
374
+ const activeStates = new Set(["blocked", "due", "open", "overdue", "ready", "scheduled", "upcoming", "waiting-external"]);
375
+ return [
376
+ ...(state.workflow?.findings || []),
377
+ ...(state.workflow?.workItems || [])
378
+ ].filter((item) => (
379
+ activeStates.has(item.state)
380
+ && (
381
+ item.subject?.type === type && item.subject?.id === id
382
+ || item.source?.type === type && item.source?.id === id
383
+ )
384
+ )).sort((left, right) => (
385
+ workflowItemStatePriority(left) - workflowItemStatePriority(right)
386
+ || (left.priority ?? workflowItemPriority(left)) - (right.priority ?? workflowItemPriority(right))
387
+ || left.key.localeCompare(right.key)
388
+ ));
389
+ }
390
+
391
+ function recordWorkflowCell(type, entry) {
392
+ const items = recordWorkflowItems(type, entry.record.id);
393
+ if (!items.length) return '<span class="record-workflow-clear">No calculated action</span>';
394
+ const item = items[0];
395
+ const href = workflowItemHref(item) || "#/resource/" + encodeURIComponent(type) + "/" + encodeURIComponent(entry.record.id);
396
+ return '<a class="record-workflow-action" href="' + href + '"><span class="workflow-finding-status ' + esc(item.state) + '">' + esc(properCase(item.state)) + '</span><span><strong>' + esc(item.title) + '</strong><small>' + esc(item.message || workflowItemDetail(item)) + (items.length > 1 ? " +" + (items.length - 1) + " more" : "") + '</small></span></a>';
397
+ }
398
+
399
+ function openCollectionReviewDialog(type) {
400
+ const assessment = state.collectionReviews?.[type];
401
+ if (!assessment) return;
402
+ const configuration = assessment.configuration;
403
+ const people = resourcesOfType("person").filter(({ record }) => record.status === "active");
404
+ const systems = resourcesOfType("system").filter(({ record }) => record.status === "active");
405
+ const allowedDecisions = configuration.decisions || ["complete"];
406
+ const defaultDecision = assessment.review?.decision
407
+ || (!assessment.recordCount && allowedDecisions.includes("zero-population") ? "zero-population" : allowedDecisions[0]);
408
+ const decisions = allowedDecisions.map((decision) => (
409
+ '<option value="' + esc(decision) + '" ' + (defaultDecision === decision ? "selected" : "") + '>' + esc(properCase(decision)) + '</option>'
410
+ )).join("");
411
+ const dialog = document.createElement("dialog");
412
+ dialog.className = "commit-dialog event-dialog collection-review-dialog";
413
+ dialog.setAttribute("aria-labelledby", "collection-review-dialog-title");
414
+ dialog.innerHTML = '<form><div class="dialog-head"><div><p class="kicker">Scope confirmation</p><h2 id="collection-review-dialog-title">Confirm ' + esc(configuration.title.toLowerCase()) + '</h2></div><button type="button" class="icon-button" aria-label="Close">×</button></div><p>' + esc(configuration.description) + '</p><section class="event-dialog-steps collection-review-checks"><strong>Before confirming</strong><ul>' + configuration.reviewPoints.map((point) => '<li>' + esc(point) + '</li>').join("") + '</ul></section><div class="form-grid"><label><span>Conclusion</span><select name="decision" required>' + decisions + '</select></label><label><span>Reviewer</span><select name="reviewerId" required><option value="">Select</option>' + people.map(({ record }) => '<option value="' + esc(record.id) + '" ' + ((assessment.review?.reviewedByIds || []).includes(record.id) ? "selected" : "") + '>' + esc(record.title) + '</option>').join("") + '</select></label><label><span>Reviewed on</span><input name="reviewedOn" type="date" required value="' + esc(assessment.review?.reviewedOn || currentDate()) + '"></label><label data-authoritative-system><span>Authoritative System</span><select name="authoritativeSystemId"><option value="">Select</option>' + systems.map(({ record }) => '<option value="' + esc(record.id) + '" ' + (assessment.review?.authoritativeSystemId === record.id ? "selected" : "") + '>' + esc(record.title) + '</option>').join("") + '</select></label><label class="full"><span>Review notes</span><textarea name="rationale" rows="3" required placeholder="Note what you confirmed and any scope decision that needs context.">' + esc(assessment.review?.rationale || "") + '</textarea></label></div><div class="workflow-preview" role="status"></div><div class="dialog-error" role="alert"></div><div class="dialog-actions"><button type="button" class="button" data-event="cancel">Cancel</button><button type="submit" class="button primary" data-preview-collection-review>Preview confirmation</button></div></form>';
415
+ document.body.append(dialog);
416
+ dialog.showModal();
417
+ const form = dialog.querySelector("form");
418
+ const systemField = dialog.querySelector("[data-authoritative-system]");
419
+ const syncDecision = () => {
420
+ const external = form.elements.decision.value === "externally-managed";
421
+ systemField.hidden = !external;
422
+ form.elements.authoritativeSystemId.required = external;
423
+ };
424
+ syncDecision();
425
+ dialog.querySelector(".icon-button").addEventListener("click", () => dialog.close());
426
+ dialog.querySelector('[data-event="cancel"]').addEventListener("click", () => dialog.close());
427
+ dialog.addEventListener("close", () => dialog.remove());
428
+ let previewedPayload = null;
429
+ form.addEventListener("input", () => {
430
+ previewedPayload = null;
431
+ syncDecision();
432
+ dialog.querySelector(".workflow-preview").innerHTML = "";
433
+ dialog.querySelector("[data-preview-collection-review]").textContent = "Preview confirmation";
434
+ });
435
+ form.addEventListener("submit", async (event) => {
436
+ event.preventDefault();
437
+ if (!form.reportValidity()) return;
438
+ const error = dialog.querySelector(".dialog-error");
439
+ error.textContent = "";
440
+ const payload = {
441
+ resourceType: type,
442
+ decision: form.elements.decision.value,
443
+ rationale: form.elements.rationale.value.trim(),
444
+ reviewedByIds: [form.elements.reviewerId.value],
445
+ reviewedOn: form.elements.reviewedOn.value,
446
+ authoritativeSystemId: form.elements.authoritativeSystemId.value || undefined,
447
+ expectedRevision: assessment.reviewRevision || undefined
448
+ };
449
+ form.querySelectorAll("button,input,select,textarea").forEach((control) => { control.disabled = true; });
450
+ try {
451
+ if (!previewedPayload) {
452
+ const response = await localFetch("/api/collection-review/preview", {
453
+ method: "POST",
454
+ headers: { "content-type": "application/json" },
455
+ body: JSON.stringify(payload)
456
+ });
457
+ if (!response.ok) throw new Error(await responseMessage(response));
458
+ const preview = await response.json();
459
+ previewedPayload = payload;
460
+ dialog.querySelector(".workflow-preview").innerHTML = '<strong>Review before saving</strong><p>Save this confirmation for ' + preview.assessment.recordCount + ' current ' + esc(pluralize("record", preview.assessment.recordCount)) + '. If the collection or material scope changes, FileGRC will ask for another review.</p>';
461
+ dialog.querySelector("[data-preview-collection-review]").textContent = "Confirm and save";
462
+ } else {
463
+ const response = await localFetch("/api/collection-review", {
464
+ method: "POST",
465
+ headers: { "content-type": "application/json" },
466
+ body: JSON.stringify({ ...previewedPayload, confirmed: true })
467
+ });
468
+ if (!response.ok) throw new Error(await responseMessage(response));
469
+ applyMutationState(await response.json());
470
+ dialog.close();
471
+ render();
472
+ }
473
+ } catch (requestError) {
474
+ error.textContent = requestError.message;
475
+ } finally {
476
+ form.querySelectorAll("button,input,select,textarea").forEach((control) => { control.disabled = false; });
477
+ }
478
+ });
479
+ }
480
+
481
+ function workflowItemHref(item) {
482
+ const source = item.source?.id && item.source?.type && item.source.type !== "unknown"
483
+ ? item.source
484
+ : null;
485
+ if (source && ["assigned-work", "obligation-occurrence"].includes(item.kind)) {
486
+ return "#/stage/run?work=" + encodeURIComponent(source.type + ":" + source.id);
487
+ }
488
+ const commands = [
489
+ ...(item.actions || []).map((action) => action.command),
490
+ item.nextAction?.command
491
+ ].filter(Boolean);
492
+ const applicabilityCommand = commands.find((command) => command.includes(" review-applicability "));
493
+ const applicabilityType = applicabilityCommand?.match(/--type\s+([a-z0-9-]+)/)?.[1];
494
+ if (applicabilityType && state.model.resources[applicabilityType]) {
495
+ return "#/resources/" + encodeURIComponent(applicabilityType) + "?review=1";
496
+ }
497
+ const collectionReviewCommand = commands.find((command) => command.includes(" review-collection "));
498
+ const collectionReviewType = collectionReviewCommand?.match(/review-collection\s+([a-z0-9-]+)/)?.[1];
499
+ if (collectionReviewType && state.model.collectionReviews?.[collectionReviewType]) {
500
+ return "#/resources/" + encodeURIComponent(collectionReviewType) + "?review-collection=1";
501
+ }
502
+ if (commands.some((command) => command.includes(" external-reviewer-setup"))) {
503
+ const reviewer = resourcesOfType("appointment")
504
+ .find(({ record }) => record.appointmentKind === "independent-policy-reviewer");
505
+ if (reviewer) return "#/resource/appointment/" + encodeURIComponent(reviewer.record.id);
506
+ }
507
+ if (commands.some((command) => command.includes(" evidence-map"))) return "#/stage/controls";
508
+ const reference = item.subject?.id && item.subject?.type
509
+ ? item.subject
510
+ : source;
511
+ if (reference && reference.type !== "unknown") {
512
+ return "#/resource/" + encodeURIComponent(reference.type) + "/" + encodeURIComponent(reference.id);
513
+ }
514
+ const missingType = item.subject?.type && state.model.resources[item.subject.type]
515
+ ? item.subject.type
516
+ : null;
517
+ if (missingType) {
518
+ return "#/resources/" + encodeURIComponent(missingType) + (state.readOnly ? "" : "?new=1");
519
+ }
520
+ if (item.auditId) return "#/audit-packet?auditId=" + encodeURIComponent(item.auditId);
521
+ const stage = {
522
+ scope: "scope",
523
+ policies: "policies",
524
+ controls: "controls",
525
+ operate: "run",
526
+ operation: "run",
527
+ audit: "audit",
528
+ setup: "audit",
529
+ fieldwork: "audit",
530
+ deliver: "audit",
531
+ auditor: "audit"
532
+ }[item.stage];
533
+ return stage ? "#/stage/" + stage : "";
534
+ }
535
+
536
+ function workflowItemDetail(item) {
537
+ if (item.dueOn) return "Due " + item.dueOn;
538
+ if (item.availableOn) return "Available " + item.availableOn;
539
+ return item.nextAction?.command || "Review the related source facts.";
540
+ }
541
+
542
+ function workflowItemPriority(item) {
543
+ if (item.state === "overdue") return 0;
544
+ if (["due", "open", "ready"].includes(item.state)) return 20;
545
+ if (item.state === "blocked") return 30;
546
+ if (item.severity === "error") return 10;
547
+ if (item.state === "waiting-external") return 40;
548
+ return 50;
549
+ }
550
+
551
+ function workflowItemStatePriority(item) {
552
+ return {
553
+ overdue: 0,
554
+ due: 10,
555
+ open: 20,
556
+ ready: 30,
557
+ blocked: 40,
558
+ upcoming: 50,
559
+ scheduled: 60,
560
+ "waiting-external": 70
561
+ }[item.state] ?? 80;
562
+ }
563
+
320
564
  function renderEvidenceReadiness() {
321
565
  const items = state.programReadiness?.stages
322
566
  ?.find((stage) => stage.id === "controls")
@@ -350,7 +594,7 @@ function renderEvidenceReadiness() {
350
594
  '<div class="evidence-map-links"><div><small>Controls</small><div class="evidence-map-references">' + (item.controlIds || []).map((id) => formatReference(id)).join("") + '</div></div><div><small>Authoritative sources</small><div class="evidence-map-sources">' + sourceAction + '</div></div></div><p class="evidence-map-status">' + esc(item.message) + '</p></article>';
351
595
  }).join("");
352
596
  const empty = '<section class="evidence-map-empty"><p class="kicker">Evidence readiness</p><h3>Select the program controls first</h3><p>Control implementation checks are generated from the selected Controls and their authoritative evidence sources.</p><a class="button primary" href="#/resources/control">Review Controls</a></section>';
353
- return '<section class="evidence-map"><div class="evidence-map-head"><div><p class="kicker">Control implementation</p><h2>' + completeCount + ' of ' + items.length + ' evidence ' + (items.length === 1 ? "family" : "families") + ' ready</h2><p>Before marking Controls implemented, connect them to the Systems where their evidence originates. Each source must be active, have the required source role and current access owners, and include repeatable retrieval instructions in Record Markdown.</p></div><div class="evidence-map-actions"><a class="button" href="#/resources/system">Review Systems</a><a class="button primary" href="#/resources/control">Review Controls</a></div></div>' + (cards || empty) + '</section>';
597
+ return '<section class="evidence-map"><div class="evidence-map-head"><div><p class="kicker">Control implementation</p><h2>' + completeCount + ' of ' + items.length + ' evidence ' + (items.length === 1 ? "family" : "families") + ' ready</h2><p>Connect each Control to the Systems that produce its evidence. The cards below show what each source still needs.</p></div><div class="evidence-map-actions"><a class="button" href="#/resources/system">Review Systems</a><a class="button primary" href="#/resources/control">Review Controls</a></div></div>' + (cards || empty) + '</section>';
354
598
  }
355
599
 
356
600
  function evidenceSourceCheckLabel(name) {
@@ -374,15 +618,6 @@ function stagePageDestinations(stage) {
374
618
  .map((destination) => ({ ...destination, section })));
375
619
  }
376
620
 
377
- function stagePageId(stage, destination) {
378
- return stage.id + ":" + (destination.type || "utility:" + destination.utility);
379
- }
380
-
381
- function stagePageComplete(pageId) {
382
- const completedPageIds = rendererSettingsEntry()?.record.completedStagePageIds || [];
383
- return completedPageIds.includes(pageId);
384
- }
385
-
386
621
  function stagePageSummary(destination) {
387
622
  const summaryKey = destination.type || "utility:" + destination.utility;
388
623
  const section = destination.section || (destination.type
@@ -392,24 +627,117 @@ function stagePageSummary(destination) {
392
627
  }
393
628
 
394
629
  function stagePageCard(stage, destination, index) {
395
- const details = destination.type ? resourceRollup(destination.type) : utilityRollup(destination.utility);
396
630
  const summary = stagePageSummary(destination);
397
631
  const stepLabel = "Step " + stage.number + "." + String.fromCharCode(97 + index);
398
- const pageId = stagePageId(stage, destination);
399
- const complete = stagePageComplete(pageId);
400
- const completionControl = state.readOnly
401
- ? '<span class="stage-page-completion-state ' + (complete ? "complete" : "") + '">' + (complete ? "Complete" : "Not marked complete") + '</span>'
402
- : '<button class="button stage-page-completion ' + (complete ? "complete" : "") + '" type="button" data-stage-page-completion="' + esc(pageId) + '" data-complete="' + complete + '">' + (complete ? "Mark incomplete" : "Mark complete") + '</button>';
403
- return '<article class="stage-page-card ' + (complete ? "complete" : "") + '"><a class="stage-page-card-link" href="' + destination.href + '" aria-label="Open ' + esc(destination.label) + '"></a><div class="stage-page-card-head"><div><small>' + esc(stepLabel) + '</small><h3>' + esc(destination.label) + '</h3></div><span class="stage-page-rollup"><strong>' + esc(details.value) + '</strong><small>' + esc(details.label) + '</small></span></div><p>' + esc(summary) + '</p><div class="stage-page-card-foot"><span class="stage-page-open" aria-hidden="true">Open ›</span>' + completionControl + '</div></article>';
632
+ const derived = derivedStagePageState(stage, destination);
633
+ const complete = derived.complete;
634
+ const items = stagePageItems(stage, destination);
635
+ const completionState = '<span class="stage-page-completion-state ' + (complete ? "complete" : "") + '">' + esc(derived.label) + '</span>';
636
+ const taskPreview = items.length
637
+ ? '<div class="stage-page-tasks">' + items.slice(0, 3).map((item) => {
638
+ const href = workflowItemHref(item) || destination.href;
639
+ return '<a href="' + href + '"><span class="workflow-finding-status ' + esc(item.state) + '">' + esc(properCase(item.state)) + '</span><span><strong>' + esc(item.title) + '</strong><small>' + esc(stagePageItemDetail(item)) + '</small></span></a>';
640
+ }).join("") + (items.length > 3 ? '<small class="stage-page-tasks-more">+' + (items.length - 3) + ' more on this page</small>' : "") + '</div>'
641
+ : "";
642
+ return '<article class="stage-page-card ' + (complete ? "complete" : "") + '"><a class="stage-page-card-link" href="' + destination.href + '" aria-label="Open ' + esc(destination.label) + '"></a><div class="stage-page-card-head"><div><small>' + esc(stepLabel) + '</small><h3>' + esc(destination.label) + '</h3></div>' + completionState + '</div><p>' + esc(summary) + '</p>' + taskPreview + '<div class="stage-page-card-foot"><span class="stage-page-open" aria-hidden="true">Open ›</span></div></article>';
643
+ }
644
+
645
+ function stagePageItemDetail(item) {
646
+ const controlChecks = item.subject?.type === "control"
647
+ ? String(item.message || "").match(/^Complete (\d+) checks before implementation:/)
648
+ : null;
649
+ if (controlChecks) return controlChecks[1] + " implementation checks remain. Open the Control to review them.";
650
+ return item.message || workflowItemDetail(item);
404
651
  }
405
652
 
406
653
  function stageProgress(stage) {
407
654
  if (stage.id === "run") return operationProgress();
408
655
  const pages = stagePageDestinations(stage);
409
- const complete = pages.filter((destination) => stagePageComplete(stagePageId(stage, destination))).length;
656
+ if (stage.id === "audit" && state.workflow?.assessments?.auditReadiness?.status === "not-started") {
657
+ return {
658
+ percent: 0,
659
+ complete: 0,
660
+ total: pages.length,
661
+ status: "Not started",
662
+ tone: "neutral",
663
+ detail: "Create an Audit only after a real engagement or customer deadline exists."
664
+ };
665
+ }
666
+ const complete = pages.filter((destination) => derivedStagePageState(stage, destination).complete).length;
410
667
  return progressFromCounts(complete, pages.length, "page");
411
668
  }
412
669
 
670
+ function derivedStagePageState(stage, destination) {
671
+ if (
672
+ stage.id === "audit"
673
+ && state.workflow?.assessments?.auditReadiness?.status === "not-started"
674
+ && (destination.type === "audit" || destination.utility === "audit-packet")
675
+ ) {
676
+ return { complete: false, label: "No engagement" };
677
+ }
678
+ const blocking = stagePageItems(stage, destination);
679
+ if (blocking.length) {
680
+ return { complete: false, label: blocking.length + " " + pluralize("item", blocking.length) + (blocking.length === 1 ? " needs work" : " need work") };
681
+ }
682
+ if (destination.type && resourcesOfType(destination.type).length === 0) {
683
+ const collectionReview = state.collectionReviews?.[destination.type];
684
+ if (collectionReview) {
685
+ return collectionReview.status === "current"
686
+ ? { complete: true, label: "Reviewed" }
687
+ : { complete: false, label: "Review scope" };
688
+ }
689
+ return { complete: true, label: "Conditional" };
690
+ }
691
+ return { complete: true, label: "Ready" };
692
+ }
693
+
694
+ function stagePageItems(stage, destination) {
695
+ const activeStates = new Set(["blocked", "due", "open", "overdue", "ready"]);
696
+ const items = [
697
+ ...(state.workflow?.findings || []),
698
+ ...(state.workflow?.workItems || [])
699
+ ].filter((item) => (
700
+ activeStates.has(item.state)
701
+ && (
702
+ item.stage === stage.id
703
+ || stage.id === "scope"
704
+ && destination.type === "appointment"
705
+ && item.code === "governance.appointment.independent-policy-reviewer"
706
+ )
707
+ ));
708
+ return items.filter((item) => {
709
+ if (
710
+ destination.type === "requirement"
711
+ && item.subject?.type === "requirement"
712
+ && item.fieldPath === "applicabilityReview"
713
+ ) return false;
714
+ if (
715
+ stage.id === "controls"
716
+ && ["source-coverage", "system"].includes(item.subject?.type)
717
+ && item.key?.startsWith("evidence-source.")
718
+ ) return false;
719
+ if (
720
+ stage.id === "policies"
721
+ && destination.type === "policy"
722
+ && item.code === "governance.appointment.independent-policy-reviewer"
723
+ ) return true;
724
+ if (
725
+ destination.type
726
+ && (item.subject?.type === destination.type || item.source?.type === destination.type)
727
+ ) return true;
728
+ const href = workflowItemHref(item);
729
+ if (!href) return false;
730
+ const destinationHref = destination.href.split("?")[0];
731
+ return href === destinationHref
732
+ || href.startsWith(destinationHref + "?")
733
+ || Boolean(destination.type && href.startsWith("#/resource/" + destination.type + "/"));
734
+ }).sort((left, right) => (
735
+ workflowItemStatePriority(left) - workflowItemStatePriority(right)
736
+ || (left.priority ?? workflowItemPriority(left)) - (right.priority ?? workflowItemPriority(right))
737
+ || left.key.localeCompare(right.key)
738
+ ));
739
+ }
740
+
413
741
  function operationProgress() {
414
742
  const program = state.programReadiness;
415
743
  const goal = program?.target?.goal || state.workspace.assuranceGoal || "none";
@@ -420,7 +748,8 @@ function operationProgress() {
420
748
  ? Boolean(program?.target?.candidateCoverage?.kind === "as-of")
421
749
  : Boolean(program?.evidenceReady);
422
750
  const overdue = state.obligations.counts.overdue || 0;
423
- const complete = Boolean(program?.evidenceReady && candidateStarted && overdue === 0);
751
+ const blocked = state.obligations.counts.blocked || 0;
752
+ const complete = Boolean(program?.evidenceReady && candidateStarted && overdue === 0 && blocked === 0);
424
753
  if (complete) {
425
754
  return {
426
755
  percent: 100,
@@ -428,7 +757,7 @@ function operationProgress() {
428
757
  total: 1,
429
758
  status: "Operating",
430
759
  tone: "good",
431
- detail: "Evidence collection is running and the Work Queue has no overdue work."
760
+ detail: "Evidence collection is running and the Work Queue has no overdue or blocked work."
432
761
  };
433
762
  }
434
763
  if (overdue) {
@@ -441,6 +770,16 @@ function operationProgress() {
441
770
  detail: overdue + " overdue Work Queue " + pluralize("item", overdue) + " must be resolved."
442
771
  };
443
772
  }
773
+ if (blocked) {
774
+ return {
775
+ percent: 0,
776
+ complete: 0,
777
+ total: 1,
778
+ status: "Blocked",
779
+ tone: "bad",
780
+ detail: blocked + " blocked Work Queue " + pluralize("item", blocked) + " must be resolved."
781
+ };
782
+ }
444
783
  if (program?.evidenceReady && goal === "soc-2-type-2" && !candidateStarted) {
445
784
  return {
446
785
  percent: 0,
@@ -473,10 +812,10 @@ function programPathProgress() {
473
812
  function progressFromCounts(complete, total, noun) {
474
813
  if (!total) return { percent: 0, complete: 0, total: 0, status: "Nothing to review", tone: "neutral", detail: "No " + pluralize(noun, 2) + " are configured yet." };
475
814
  const percent = Math.round((complete / total) * 100);
476
- const detail = complete + " of " + total + " " + pluralize(noun, total) + " marked reviewed. This tracks page review, while readiness checks the records themselves.";
477
- if (complete === total) return { percent: 100, complete, total, status: "Review complete", tone: "good", detail };
478
- if (!complete) return { percent: 0, complete, total, status: "No pages marked", tone: "warn", detail };
479
- return { percent, complete, total, status: "Review in progress", tone: "warn", detail };
815
+ const detail = complete + " of " + total + " " + pluralize(noun, total) + (complete === 1 ? " is" : " are") + " ready.";
816
+ if (complete === total) return { percent: 100, complete, total, status: "Ready", tone: "good", detail };
817
+ if (!complete) return { percent: 0, complete, total, status: "Needs work", tone: "warn", detail };
818
+ return { percent, complete, total, status: "In progress", tone: "warn", detail };
480
819
  }
481
820
 
482
821
  function stageProgressCard(progress) {
@@ -495,30 +834,6 @@ function sectionDestinations(section) {
495
834
  return destinations;
496
835
  }
497
836
 
498
- function resourceRollup(type) {
499
- const records = resourcesOfType(type).map(({ record }) => record);
500
- if (!records.length) return { value: "0", label: "No records yet" };
501
- const statuses = new Map();
502
- records.forEach((record) => {
503
- const status = displayStatus(record);
504
- if (status) statuses.set(status, (statuses.get(status) || 0) + 1);
505
- });
506
- const statusText = [...statuses.entries()].sort((a, b) => b[1] - a[1]).slice(0, 2).map(([status, count]) => count + " " + humanize(status).toLowerCase()).join(" · ");
507
- return { value: String(records.length), label: statusText || pluralize("record", records.length) };
508
- }
509
-
510
- function utilityRollup(utility) {
511
- if (utility === "obligation-board") {
512
- const open = state.obligations.items.filter((item) => item.status !== "complete");
513
- return { value: String(open.length), label: open.length ? "Open work items" : "No work due" };
514
- }
515
- if (utility === "audit-packet") {
516
- const audits = resourcesOfType("audit");
517
- return { value: String(audits.length), label: audits.length ? pluralize("engagement", audits.length) : "No engagement yet" };
518
- }
519
- return { value: "0", label: "Not started" };
520
- }
521
-
522
837
  function auditEngagementPrompt(audit = null) {
523
838
  const hasAuditor = audit?.auditorVendorId;
524
839
  if (hasAuditor) return "";
@@ -536,7 +851,7 @@ function renderExternalEvidenceSection() {
536
851
  const createButton = state.readOnly
537
852
  ? ""
538
853
  : '<button class="button primary" type="button" data-new-external-evidence>New external evidence</button>';
539
- return '<section class="workflow-section external-evidence-section"><div class="section-head"><div><p class="kicker">Fixed artifacts and approved references</p><h2>External Evidence</h2><p>Create a record when a real export, report, screenshot, signed file, or approved external reference exists. Select its authoritative source System, link the Controls and operating record it supports, then record collection and verification facts.</p></div><div class="page-actions">' +
854
+ return '<section class="workflow-section external-evidence-section"><div class="section-head"><div><p class="kicker">Fixed artifacts and approved references</p><h2>External Evidence</h2><p>Add fixed artifacts only when they exist. Link each one to its source System and the work it supports.</p></div><div class="page-actions">' +
540
855
  createButton + '<a class="button" href="#/resources/evidence">View all</a></div></div><div class="external-evidence-list">' +
541
856
  (recent || empty("No External Evidence has been collected yet. Create it during operation only when a real artifact or approved external reference exists.")) +
542
857
  '</div></section>';
@@ -545,34 +860,42 @@ function renderExternalEvidenceSection() {
545
860
  function renderObligations(main, params = new URLSearchParams()) {
546
861
  const stage = READINESS_STAGES.find((candidate) => candidate.id === "run");
547
862
  const plan = state.obligations;
548
- const controls = resourcesOfType("control");
549
- const linkedControlIds = new Set(resourcesOfType("obligation").flatMap(({ record }) => record.controlIds || []));
550
- const scheduledControls = controls.filter(({ record }) => linkedControlIds.has(record.id)).length;
551
- const assignedFollowUp = plan.standaloneItems.length;
552
863
  const visibleCardLimit = 6;
553
- const sections = ["proposed", "upcoming", "due", "overdue"].map((status) => {
554
- const items = plan.items.filter((item) => item.status === status);
864
+ const sections = ["proposed", "upcoming", "blocked", "due", "overdue"].map((status) => {
865
+ const items = obligationBoardItems(plan.items, status);
555
866
  const cards = items.map((item, index) => obligationCard(item, index >= visibleCardLimit)).join("");
556
867
  const more = items.length > visibleCardLimit
557
868
  ? '<button class="button obligation-more" type="button" data-expand-obligations="' + status + '" data-total="' + items.length + '" aria-expanded="false">Show ' + (items.length - visibleCardLimit) + ' more</button>'
558
869
  : "";
559
870
  return '<section class="obligation-column" data-obligation-column="' + status + '"><div class="obligation-column-head"><span class="badge status-' + status + '">' + esc(properCase(status)) + '</span><strong>' + items.length + '</strong></div><div class="obligation-cards">' + (items.length ? cards : empty("Nothing " + status + ".")) + '</div>' + more + '</section>';
560
871
  }).join("");
561
- const triggers = plan.triggers.map((trigger, index) => policyEventTrigger(trigger, index)).join("");
872
+ const eventTriggerLimit = 6;
873
+ const orderedTriggers = orderedPolicyEventTriggers(plan.triggers);
874
+ const triggers = orderedTriggers.map((trigger, index) => policyEventTrigger(trigger, index, index >= eventTriggerLimit)).join("");
875
+ const eventMore = orderedTriggers.length > eventTriggerLimit
876
+ ? '<button class="button policy-event-more" type="button" data-expand-policy-events aria-expanded="false">Show ' + (orderedTriggers.length - eventTriggerLimit) + ' more events</button>'
877
+ : "";
562
878
  const feedback = policyEventFeedback
563
879
  ? '<section class="policy-event-feedback" role="status" aria-live="polite"><span class="status-dot good"></span><div><strong>Work added to the Work Queue</strong><p>' + esc(policyEventFeedback.name + " created " + policyEventFeedback.taskCount + " " + pluralize("task", policyEventFeedback.taskCount) + ".") + '</p></div><button class="button" type="button" data-view-added-work>View Work Queue</button><button class="icon-button" type="button" data-dismiss-policy-event-feedback aria-label="Dismiss confirmation">×</button></section>'
564
880
  : "";
565
881
  main.innerHTML = '<div class="page obligation-board-page stage-overview-page"><nav class="breadcrumbs"><a href="#/">Overview</a><span>/</span><span>' + esc(stage.title) + '</span></nav>' +
566
882
  '<section class="stage-overview-hero"><div><p class="kicker">Step ' + esc(stage.number) + ' of 5</p><h2>' + esc(stage.title) + '</h2><p>' + esc(stage.summary) + '</p></div>' + stageProgressCard(stageProgress(stage)) + '</section>' +
567
883
  feedback +
568
- '<section class="workflow-section event-reminders"><div class="section-head"><div><p class="kicker">Changes that create work</p><h2>Policy Events</h2><p>Trigger the matching workflow when an event occurs. filegrc adds every required action to the Work Queue with its owner and deadline.</p></div></div><div class="policy-event-list">' + (triggers || empty("No event-driven obligations are configured.")) + '</div></section>' +
569
- '<section class="workflow-section work-queue-section"><div class="section-head"><div><p class="kicker">Recurring, event, and assigned work</p><h2>Work Queue</h2><p>This board schedules work linked to ' + scheduledControls + ' of ' + controls.length + ' controls and includes ' + assignedFollowUp + ' open ' + pluralize("Action Item", assignedFollowUp) + '. Triggered Policy Event actions appear here as individual tasks in Upcoming, Due, or Overdue. Other controls operate continuously or per transaction in their source systems and are documented through evidence records. Starter work remains a proposal until its governing policies are effective and at least one linked control is implemented.</p></div><div class="page-actions">' + (!state.readOnly ? '<button class="button" type="button" data-new-action-item>New task</button>' : "") + '<a class="button" href="#/resources/obligation">Edit schedules</a></div></div>' +
884
+ '<section class="workflow-section event-reminders"><div class="section-head"><div><p class="kicker">Changes that create work</p><h2>Policy Events</h2><p>Trigger the matching workflow when an event occurs. filegrc adds every required action to the Work Queue with its owner and deadline.</p></div></div><div class="policy-event-list">' + (triggers || empty("No event-driven obligations are configured.")) + '</div>' + eventMore + '</section>' +
885
+ '<section class="workflow-section work-queue-section"><div class="section-head"><div><p class="kicker">Recurring, event, and assigned work</p><h2>Work Queue</h2><p>Complete scheduled work and assigned follow-up here. Each card shows its due window, source, and next action.</p></div><div class="page-actions">' + (!state.readOnly ? '<button class="button" type="button" data-new-action-item>New task</button>' : "") + '<a class="button" href="#/resources/obligation">Edit schedules</a></div></div>' +
570
886
  '<div class="obligation-board">' + sections + '</div>' +
571
887
  '</section>' + renderExternalEvidenceSection() + '</div>';
572
888
  main.querySelectorAll("[data-start-event]").forEach((button) => button.addEventListener("click", () => {
573
889
  const trigger = plan.triggers.find((item) => item.eventType === button.dataset.startEvent);
574
890
  if (trigger) openObligationEventDialog(trigger);
575
891
  }));
892
+ main.querySelector("[data-expand-policy-events]")?.addEventListener("click", (event) => {
893
+ const button = event.currentTarget;
894
+ const expanded = button.getAttribute("aria-expanded") === "true";
895
+ main.querySelectorAll(".policy-event-row[data-collapsed]").forEach((row) => { row.hidden = expanded; });
896
+ button.setAttribute("aria-expanded", String(!expanded));
897
+ button.textContent = expanded ? "Show " + (orderedTriggers.length - eventTriggerLimit) + " more events" : "Show fewer events";
898
+ });
576
899
  main.querySelector("[data-view-added-work]")?.addEventListener("click", () => main.querySelector(".work-queue-section")?.scrollIntoView({ behavior: "smooth", block: "start" }));
577
900
  main.querySelector("[data-dismiss-policy-event-feedback]")?.addEventListener("click", (event) => {
578
901
  policyEventFeedback = null;
@@ -591,6 +914,10 @@ function renderObligations(main, params = new URLSearchParams()) {
591
914
  const item = plan.items.find((candidate) => candidate.key === button.dataset.recordObligation);
592
915
  if (item) openObligationCompletion(item);
593
916
  }));
917
+ main.querySelectorAll("[data-complete-action]").forEach((button) => button.addEventListener("click", () => {
918
+ const item = plan.items.find((candidate) => candidate.key === button.dataset.completeAction);
919
+ if (item) openActionCompletion(item);
920
+ }));
594
921
  main.querySelector("[data-new-action-item]")?.addEventListener("click", () => openEditor("action-item", null, {
595
922
  description: "Create a task only when follow-up from another record needs its own assignee, deadline, and completion proof. Point it to that source record; it will remain in Work Queue until done or canceled."
596
923
  }));
@@ -601,9 +928,52 @@ function renderObligations(main, params = new URLSearchParams()) {
601
928
  if (requestedEvent) main.querySelector('[data-start-event="' + CSS.escape(requestedEvent) + '"]')?.click();
602
929
  });
603
930
  }
931
+ const requestedWork = params.get("work");
932
+ if (requestedWork) {
933
+ queueMicrotask(() => {
934
+ const card = [...main.querySelectorAll("[data-work-source]")]
935
+ .find((candidate) => candidate.dataset.workSource === requestedWork);
936
+ if (!card) return;
937
+ card.hidden = false;
938
+ card.classList.add("workflow-target");
939
+ card.scrollIntoView({ block: "center" });
940
+ });
941
+ }
604
942
  }
605
943
 
606
- function policyEventTrigger(trigger, index) {
944
+ function obligationBoardItems(items, status) {
945
+ const matching = items.filter((item) => item.status === status);
946
+ if (status !== "proposed") return matching;
947
+ const seen = new Set();
948
+ return matching.filter((item) => {
949
+ const source = item.actionItemId ? "action:" + item.actionItemId : "obligation:" + item.obligationId;
950
+ if (seen.has(source)) return false;
951
+ seen.add(source);
952
+ return true;
953
+ });
954
+ }
955
+
956
+ function policyEventDisplayRank(eventType) {
957
+ const featured = [
958
+ "person-started",
959
+ "person-role-changed",
960
+ "person-ended",
961
+ "material-incident",
962
+ "system-material-change",
963
+ "vendor-activated"
964
+ ];
965
+ const index = featured.indexOf(eventType);
966
+ return index === -1 ? featured.length : index;
967
+ }
968
+
969
+ function orderedPolicyEventTriggers(triggers) {
970
+ return [...triggers].sort((left, right) => (
971
+ policyEventDisplayRank(left.eventType) - policyEventDisplayRank(right.eventType)
972
+ || policyEventName(left.eventType).localeCompare(policyEventName(right.eventType))
973
+ ));
974
+ }
975
+
976
+ function policyEventTrigger(trigger, index, collapsed = false) {
607
977
  const tooltipId = "policy-event-tooltip-" + index;
608
978
  const proposed = trigger.programStatus === "proposed";
609
979
  const unavailable = state.readOnly || proposed;
@@ -612,7 +982,7 @@ function policyEventTrigger(trigger, index) {
612
982
  : state.readOnly
613
983
  ? "Open this workspace in writable mode to trigger the workflow."
614
984
  : trigger.steps.length + " " + pluralize("task", trigger.steps.length) + " will be added to the Work Queue.";
615
- return '<article class="policy-event-row"><div class="policy-event-name"><div class="policy-event-title"><strong>' + esc(policyEventName(trigger.eventType)) + '</strong><span class="policy-event-guide"><button class="guide-trigger policy-event-guide-trigger" type="button" aria-label="Show ' + esc(policyEventName(trigger.eventType)) + ' workflow steps" aria-describedby="' + tooltipId + '"><svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8"></circle><path d="M7.8 7.5a2.4 2.4 0 1 1 3.25 2.25c-.7.31-1.05.72-1.05 1.5v.25M10 14.5v.1"></path></svg></button><div class="policy-event-tooltip" id="' + tooltipId + '" role="tooltip"><strong>' + esc(proposed ? "Proposed workflow" : "Adds " + trigger.steps.length + " " + pluralize("task", trigger.steps.length) + " to the Work Queue") + '</strong><ol>' + trigger.steps.map((step) => '<li><span>' + esc(step.title) + '</span><small>' + esc(eventStepSummary(step)) + '</small></li>').join("") + '</ol></div></span></div><small>' + esc(availability) + '</small></div><button class="button primary" type="button" data-start-event="' + esc(trigger.eventType) + '"' + (unavailable ? " disabled" : "") + '>Trigger Work</button></article>';
985
+ return '<article class="policy-event-row"' + (collapsed ? " data-collapsed hidden" : "") + '><div class="policy-event-name"><div class="policy-event-title"><strong>' + esc(policyEventName(trigger.eventType)) + '</strong><span class="policy-event-guide"><button class="guide-trigger policy-event-guide-trigger" type="button" aria-label="Show ' + esc(policyEventName(trigger.eventType)) + ' workflow steps" aria-describedby="' + tooltipId + '"><svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8"></circle><path d="M7.8 7.5a2.4 2.4 0 1 1 3.25 2.25c-.7.31-1.05.72-1.05 1.5v.25M10 14.5v.1"></path></svg></button><div class="policy-event-tooltip" id="' + tooltipId + '" role="tooltip"><strong>' + esc(proposed ? "Proposed workflow" : "Adds " + trigger.steps.length + " " + pluralize("task", trigger.steps.length) + " to the Work Queue") + '</strong><ol>' + trigger.steps.map((step) => '<li><span>' + esc(step.title) + '</span><small>' + esc(eventStepSummary(step)) + '</small></li>').join("") + '</ol></div></span></div><small>' + esc(availability) + '</small></div><button class="button primary" type="button" data-start-event="' + esc(trigger.eventType) + '"' + (unavailable ? " disabled" : "") + '>Trigger Work</button></article>';
616
986
  }
617
987
 
618
988
  function policyEventName(eventType) {
@@ -639,16 +1009,54 @@ function defaultClassificationId() {
639
1009
  function obligationCard(item, collapsed = false) {
640
1010
  const type = item.actionItemId ? "action-item" : "obligation";
641
1011
  const id = item.actionItemId || item.obligationId;
642
- const completion = !item.actionItemId ? obligationCompletionPlan(item) : null;
1012
+ const completion = item.actionItemId ? actionCompletionPlan(item) : obligationCompletionPlan(item);
643
1013
  const canAct = completion?.blocked === "Assign current owner"
644
1014
  || !["upcoming", "proposed"].includes(item.status);
645
1015
  const action = !state.readOnly && canAct && completion
646
1016
  ? completion.blocked
647
1017
  ? '<a class="obligation-action blocked" href="' + completion.href + '">' + esc(completion.blocked) + '</a>'
648
- : '<button class="obligation-action" type="button" data-record-obligation="' + esc(item.key) + '">Record work</button>'
1018
+ : item.actionItemId
1019
+ ? '<button class="obligation-action" type="button" data-complete-action="' + esc(item.key) + '">Complete task</button>'
1020
+ : '<button class="obligation-action" type="button" data-record-obligation="' + esc(item.key) + '">Record work</button>'
649
1021
  : "";
650
1022
  const kind = item.kind === "event" ? "Policy Event Task" : item.kind === "action" ? "Assigned Follow-up" : properCase(item.activityType || "Recurring");
651
- return '<article class="obligation-card status-' + esc(item.status) + '"' + (collapsed ? ' data-collapsed hidden' : "") + '><div class="obligation-card-head"><span>' + esc(kind) + '</span><strong>' + esc(timingText(item)) + '</strong></div><h3><a href="#/resource/' + type + '/' + encodeURIComponent(id) + '">' + esc(titleCase(item.title)) + '</a></h3><p>' + esc(windowText(item)) + '</p><div class="obligation-card-foot"><div class="obligation-links">' + (item.policyIds || []).map(formatReference).join("") + '</div>' + action + '</div></article>';
1023
+ return '<article class="obligation-card status-' + esc(item.status) + '" data-work-source="' + esc(type + ":" + id) + '"' + (collapsed ? ' data-collapsed hidden' : "") + '><div class="obligation-card-head"><span>' + esc(kind) + '</span><strong>' + esc(timingText(item)) + '</strong></div><h3><a href="#/resource/' + type + '/' + encodeURIComponent(id) + '">' + esc(titleCase(item.title)) + '</a></h3><p>' + esc(windowText(item)) + '</p><div class="obligation-card-foot"><div class="obligation-links">' + (item.policyIds || []).map(formatReference).join("") + '</div>' + action + '</div></article>';
1024
+ }
1025
+
1026
+ function actionCompletionPlan(item) {
1027
+ const action = state.resources.find(({ record }) => (
1028
+ record.type === "action-item" && record.id === item.actionItemId
1029
+ ));
1030
+ if (!action) return null;
1031
+ if (action.record.status === "blocked") {
1032
+ return {
1033
+ blocked: "Resolve blockers",
1034
+ href: "#/resource/action-item/" + encodeURIComponent(action.record.id)
1035
+ };
1036
+ }
1037
+ if (!action.record.obligationId) {
1038
+ return {
1039
+ blocked: "Open task",
1040
+ href: "#/resource/action-item/" + encodeURIComponent(action.record.id)
1041
+ };
1042
+ }
1043
+ const obligation = state.resources.find(({ record }) => (
1044
+ record.type === "obligation" && record.id === action.record.obligationId
1045
+ ));
1046
+ if (!obligation) {
1047
+ return {
1048
+ blocked: "Repair obligation link",
1049
+ href: "#/resource/action-item/" + encodeURIComponent(action.record.id)
1050
+ };
1051
+ }
1052
+ const type = state.model.obligationActivities?.[obligation.record.activityType]?.completionType;
1053
+ if (!type) {
1054
+ return {
1055
+ blocked: "Review completion type",
1056
+ href: "#/resource/obligation/" + encodeURIComponent(obligation.record.id)
1057
+ };
1058
+ }
1059
+ return { type, action, obligation };
652
1060
  }
653
1061
 
654
1062
  function obligationCompletionPlan(item) {
@@ -668,6 +1076,21 @@ function obligationCompletionPlan(item) {
668
1076
  return { type };
669
1077
  }
670
1078
 
1079
+ function openActionCompletion(item) {
1080
+ const completion = actionCompletionPlan(item);
1081
+ if (!completion || completion.blocked) return;
1082
+ openEditor(completion.type, null, {
1083
+ seed: obligationCompletionSeed(completion.type, item, completion.obligation.record),
1084
+ actionCompletion: {
1085
+ actionItemId: completion.action.record.id,
1086
+ revision: completion.action.revision,
1087
+ completedOn: currentDate()
1088
+ },
1089
+ description: "Record the work that completed this assigned task. Saving creates and links the required operating record, then marks the Action Item done in the same validated write.",
1090
+ saveLabel: "Save and complete task"
1091
+ });
1092
+ }
1093
+
671
1094
  function openObligationCompletion(item) {
672
1095
  const obligation = state.resources.find(({ record }) => record.type === "obligation" && record.id === item.obligationId);
673
1096
  if (!obligation) return showError("The obligation template could not be found.");
@@ -688,6 +1111,11 @@ function obligationCompletionSeed(type, item, obligation) {
688
1111
  const date = currentDate();
689
1112
  const timestamp = new Date().toISOString();
690
1113
  const responsiblePeople = currentPeopleForParties(item.ownerIds || []);
1114
+ const independentPeople = resourcesOfType("person")
1115
+ .map(({ record }) => record)
1116
+ .filter((record) => record.status === "active" && !responsiblePeople.includes(record.id))
1117
+ .map(({ id }) => id);
1118
+ const reviewerPeople = independentPeople.length ? [independentPeople[0]] : [];
691
1119
  const inScopeSystems = resourcesOfType("system").filter(({ record }) => (state.workspace.systemIds || []).includes(record.id) && record.status !== "retired").map(({ record }) => record.id);
692
1120
  const activeVendors = resourcesOfType("vendor").filter(({ record }) => record.status !== "terminated").map(({ record }) => record.id);
693
1121
  const title = item.title + " · " + formatCalendarDate(item.dueWindowStart);
@@ -697,35 +1125,54 @@ function obligationCompletionSeed(type, item, obligation) {
697
1125
  return { ...common, status: "complete", teamId: team.id, chairIds: currentPeopleForParties(team.chairIds || []), scheduledFor: date, startedAt: timestamp, endedAt: timestamp, attendeeIds: responsiblePeople };
698
1126
  }
699
1127
  if (type === "policy-review") {
700
- return { ...common, status: "complete", scopeResourceIds: obligation.scopeResourceIds || [], reviewerIds: responsiblePeople, completedOn: date, outcome: "passed", changesRequired: false, coverage: rangeCoverage(item.dueWindowStart, item.dueWindowEnd) };
1128
+ return { ...common, status: "complete", scopeResourceIds: obligation.scopeResourceIds || [], reviewerIds: reviewerPeople, completedOn: date, outcome: "passed", changesRequired: false, evidenceIds: [], coverage: rangeCoverage(item.dueWindowStart, item.dueWindowEnd) };
701
1129
  }
702
1130
  if (type === "risk-assessment") {
703
- return { ...common, status: "complete", completedOn: date, assessmentKind: "enterprise-risk", scope: "In-scope SOC 2 systems and dependencies", assessorIds: responsiblePeople, reviewerIds: responsiblePeople, methodology: state.workspace.riskMethodology?.method || "Documented risk methodology", summary: "Assessment completed; link the supporting evidence and resulting risks.", approvedOn: date };
1131
+ return { ...common, status: "complete", completedOn: date, assessmentKind: "enterprise-risk", scope: "In-scope SOC 2 systems and dependencies", assessorIds: responsiblePeople, reviewerIds: reviewerPeople, methodology: state.workspace.riskMethodology?.method || "Documented risk methodology", summary: "Assessment completed; link the supporting evidence and resulting risks.", evidenceIds: [], approvedOn: date };
704
1132
  }
705
1133
  if (type === "attestation") {
706
- return { ...common, status: "completed", subjectResourceIds: [obligation.templateResourceId, ...(obligation.scopeResourceIds || [])].filter(Boolean), personId: responsiblePeople[0], attestationKind: item.activityType || "completion", assignedOn: item.dueWindowStart, dueOn: item.dueWindowEnd, completedOn: date, attestationMethod: "git-approval" };
1134
+ return { ...common, status: "completed", subjectResourceIds: [...new Set([obligation.templateResourceId, ...(obligation.scopeResourceIds || [])].filter(Boolean))], personId: responsiblePeople[0], attestationKind: item.activityType || "completion", assignedOn: item.dueWindowStart, dueOn: item.dueWindowEnd, completedOn: date, attestationMethod: "git-approval" };
707
1135
  }
708
1136
  if (type === "access-review") {
709
- return { ...common, status: "complete", completedOn: date, reviewerIds: responsiblePeople, systemIds: inScopeSystems, scope: "Privileged, production, and important-system access", outcome: "passed", approvedByIds: responsiblePeople, approvedOn: date, coverage: rangeCoverage(item.dueWindowStart, item.dueWindowEnd) };
1137
+ return { ...common, status: "complete", completedOn: date, reviewerIds: responsiblePeople, systemIds: inScopeSystems, scope: "Privileged, production, and important-system access", outcome: "passed", evidenceIds: [], approvedByIds: reviewerPeople, approvedOn: date, coverage: rangeCoverage(item.dueWindowStart, item.dueWindowEnd) };
710
1138
  }
711
1139
  if (type === "vulnerability-scan") {
712
- return { ...common, status: "complete", scanKind: "vulnerability", scope: "In-scope systems", operatorIds: responsiblePeople, scheduledFor: date, completedAt: timestamp, systemIds: inScopeSystems, resultSummary: "Document the scan result and link findings or evidence." };
1140
+ return { ...common, status: "complete", scanKind: "vulnerability", scope: "In-scope systems", operatorIds: responsiblePeople, scheduledFor: date, completedAt: timestamp, systemIds: inScopeSystems, resultSummary: "Document the scan result and link findings or evidence.", evidenceIds: [], reviewerIds: reviewerPeople, reviewedOn: date };
713
1141
  }
714
1142
  if (type === "penetration-test") {
715
- return { ...common, status: "complete", testKind: "independent", scope: "In-scope systems and service boundary", coverage: rangeCoverage(date, date), ownerIds: responsiblePeople, outcome: "passed", systemIds: inScopeSystems, completedOn: date, reviewerIds: responsiblePeople, reviewedOn: date };
1143
+ return { ...common, status: "complete", testKind: "independent", scope: "In-scope systems and service boundary", coverage: rangeCoverage(date, date), ownerIds: responsiblePeople, outcome: "passed", evidenceIds: [], systemIds: inScopeSystems, completedOn: date, reviewerIds: reviewerPeople, reviewedOn: date };
716
1144
  }
717
1145
  if (type === "control-test") {
718
- return { ...common, status: "complete", controlId: obligation.controlIds?.[0] || "", testKinds: [item.activityType || "control-operation"], performedBy: "management", testerIds: responsiblePeople, reviewerIds: responsiblePeople, completedOn: date, reviewedOn: date, outcome: "passed", coverage: rangeCoverage(item.dueWindowStart, item.dueWindowEnd) };
1146
+ return { ...common, status: "complete", controlId: obligation.controlIds?.[0] || "", testKinds: [item.activityType || "control-operation"], performedBy: "management", testerIds: responsiblePeople, reviewerIds: reviewerPeople, completedOn: date, reviewedOn: date, outcome: "passed", evidenceIds: [], coverage: rangeCoverage(item.dueWindowStart, item.dueWindowEnd) };
1147
+ }
1148
+ if (type === "control-activity") {
1149
+ return {
1150
+ ...common,
1151
+ status: "complete",
1152
+ profileId: item.completionProfile || item.activityType,
1153
+ obligationId: item.obligationId,
1154
+ controlIds: item.controlIds || obligation.controlIds || [],
1155
+ scopeResourceIds: (item.subjectResourceIds || item.scopeResourceIds || obligation.scopeResourceIds || []).length
1156
+ ? (item.subjectResourceIds || item.scopeResourceIds || obligation.scopeResourceIds)
1157
+ : [state.workspace.id],
1158
+ performerIds: responsiblePeople,
1159
+ completedAt: timestamp,
1160
+ method: "",
1161
+ result: "",
1162
+ reviewerIds: reviewerPeople,
1163
+ reviewedOn: date,
1164
+ ownerIds: item.ownerIds || obligation.ownerIds || []
1165
+ };
719
1166
  }
720
1167
  if (type === "exercise") {
721
- return { ...common, status: "complete", exerciseKind: item.title.toLowerCase().includes("continuity") ? "business-continuity" : "incident-response", scheduledFor: date, facilitatorIds: responsiblePeople, objective: item.title, outcome: "passed", systemIds: inScopeSystems, completedAt: timestamp };
1168
+ return { ...common, status: "complete", exerciseKind: item.title.toLowerCase().includes("continuity") ? "business-continuity" : "incident-response", scheduledFor: date, facilitatorIds: responsiblePeople, objective: item.title, outcome: "passed", evidenceIds: [], systemIds: inScopeSystems, completedAt: timestamp };
722
1169
  }
723
1170
  if (type === "backup-test") {
724
- return { ...common, status: "complete", systemIds: inScopeSystems, scheduledFor: date, operatorIds: responsiblePeople, reviewerIds: responsiblePeople, outcome: "passed", completedAt: timestamp };
1171
+ return { ...common, status: "complete", systemIds: inScopeSystems, scheduledFor: date, operatorIds: responsiblePeople, reviewerIds: reviewerPeople, outcome: "passed", evidenceIds: [], completedAt: timestamp };
725
1172
  }
726
1173
  if (type === "vendor-review") {
727
1174
  const eventVendorId = (item.subjectResourceIds || []).find((id) => state.resources.some(({ record }) => record.id === id && record.type === "vendor"));
728
- return { ...common, status: "complete", vendorId: eventVendorId || activeVendors[0] || "", reviewerIds: responsiblePeople, completedOn: date, decision: "approved", coverage: rangeCoverage(item.dueWindowStart, item.dueWindowEnd) };
1175
+ return { ...common, status: "complete", vendorId: eventVendorId || activeVendors[0] || "", reviewerIds: responsiblePeople, completedOn: date, decision: "approved", evidenceIds: [], coverage: rangeCoverage(item.dueWindowStart, item.dueWindowEnd) };
729
1176
  }
730
1177
  return {
731
1178
  ...common,
@@ -749,17 +1196,29 @@ function openObligationEventDialog(trigger) {
749
1196
  const eventField = needsTimestamp
750
1197
  ? '<label><span>Event time <small>your local time</small></span><input name="occurredAt" type="datetime-local" required value="' + esc(currentLocalDateTime()) + '"></label>'
751
1198
  : '<label><span>Event date</span><input name="occurredOn" type="date" required value="' + esc(currentDate()) + '"></label>';
1199
+ const riskField = trigger.eventType === "person-ended"
1200
+ ? '<label><span>Departure risk</span><select name="riskLevel" required><option value="normal">Normal</option><option value="high">High or involuntary</option></select></label>'
1201
+ : "";
752
1202
  const dialog = document.createElement("dialog");
753
1203
  dialog.className = "commit-dialog event-dialog";
754
1204
  dialog.setAttribute("aria-labelledby", "event-dialog-title");
755
- dialog.innerHTML = '<form><div class="dialog-head"><div><p class="kicker">Policy event</p><h2 id="event-dialog-title">' + esc(policyEventName(trigger.eventType)) + '</h2></div><button type="button" class="icon-button" aria-label="Close">×</button></div><p>This creates one event record and adds ' + trigger.steps.length + ' linked tasks to the Work Queue.</p>' + eventField +
1205
+ dialog.innerHTML = '<form><div class="dialog-head"><div><p class="kicker">Policy event</p><h2 id="event-dialog-title">' + esc(policyEventName(trigger.eventType)) + '</h2></div><button type="button" class="icon-button" aria-label="Close">×</button></div><p>This creates one event record and adds the matching linked tasks to the Work Queue.</p>' + eventField + riskField +
756
1206
  (subjects.length ? '<label><span>Subject <small>required</small></span><select name="subject" required><option value="">Select</option>' + subjects.map(({ record }) => '<option value="' + esc(record.id) + '">' + esc(record.title) + ' · ' + esc(state.model.resources[record.type].title) + '</option>').join("") + '</select></label>' : "") +
757
- '<label><span>Workflow name <small>optional</small></span><input name="title" maxlength="200" placeholder="' + esc(policyEventName(trigger.eventType)) + '"></label><div class="event-dialog-steps">' + trigger.steps.map((step) => '<div><strong>' + esc(step.title) + '</strong><small>' + esc(eventStepSummary(step)) + '</small></div>').join("") + '</div><div class="dialog-error" role="alert"></div><div class="dialog-actions"><button type="button" class="button" data-event="cancel">Cancel</button><button type="submit" class="button primary">Add Tasks to Work Queue</button></div></form>';
1207
+ '<label><span>Workflow name <small>optional</small></span><input name="title" maxlength="200" placeholder="' + esc(policyEventName(trigger.eventType)) + '"></label><div class="event-dialog-steps">' + trigger.steps.map((step) => '<div data-risk-levels="' + esc((step.eventRiskLevels || []).join(",")) + '" ' + ((step.eventRiskLevels || []).length ? "hidden" : "") + '><strong>' + esc(step.title) + '</strong><small>' + esc(eventStepSummary(step)) + '</small></div>').join("") + '</div><div class="dialog-error" role="alert"></div><div class="dialog-actions"><button type="button" class="button" data-event="cancel">Cancel</button><button type="submit" class="button primary">Add Tasks to Work Queue</button></div></form>';
758
1208
  document.body.append(dialog);
759
1209
  dialog.showModal();
760
1210
  dialog.querySelector(".icon-button").addEventListener("click", () => dialog.close());
761
1211
  dialog.querySelector('[data-event="cancel"]').addEventListener("click", () => dialog.close());
762
1212
  dialog.addEventListener("close", () => dialog.remove());
1213
+ const syncRiskSteps = () => {
1214
+ const selectedRisk = dialog.querySelector('[name="riskLevel"]')?.value || "";
1215
+ dialog.querySelectorAll("[data-risk-levels]").forEach((step) => {
1216
+ const levels = step.dataset.riskLevels.split(",").filter(Boolean);
1217
+ step.hidden = levels.length > 0 && !levels.includes(selectedRisk);
1218
+ });
1219
+ };
1220
+ dialog.querySelector('[name="riskLevel"]')?.addEventListener("change", syncRiskSteps);
1221
+ syncRiskSteps();
763
1222
  dialog.querySelector("form").addEventListener("submit", async (event) => {
764
1223
  event.preventDefault();
765
1224
  const form = event.currentTarget;
@@ -773,6 +1232,7 @@ function openObligationEventDialog(trigger) {
773
1232
  eventType: trigger.eventType,
774
1233
  occurredOn: form.elements.occurredOn?.value || undefined,
775
1234
  occurredAt: form.elements.occurredAt?.value ? new Date(form.elements.occurredAt.value).toISOString() : undefined,
1235
+ riskLevel: form.elements.riskLevel?.value || undefined,
776
1236
  subjectResourceIds: form.elements.subject?.value ? [form.elements.subject.value] : [],
777
1237
  title: form.elements.title.value
778
1238
  })
@@ -795,6 +1255,220 @@ function openObligationEventDialog(trigger) {
795
1255
  dialog.querySelector('input[name="occurredOn"], input[name="occurredAt"]').focus();
796
1256
  }
797
1257
 
1258
+ function openExternalReviewerGovernanceDialog() {
1259
+ const dialog = document.createElement("dialog");
1260
+ dialog.className = "commit-dialog event-dialog";
1261
+ dialog.setAttribute("aria-labelledby", "external-reviewer-dialog-title");
1262
+ dialog.innerHTML = '<form><div class="dialog-head"><div><p class="kicker">Independent review</p><h2 id="external-reviewer-dialog-title">Set up an external reviewer</h2></div><button type="button" class="icon-button" aria-label="Close">×</button></div><p>Use this flow when no suitable internal reviewer is available. It adds the external reviewer, activates the Independent Policy Reviewer and Oversight Chair Appointments, adds the reviewer to the oversight team, and routes draft policy approvals to that person.</p><div class="form-grid"><label><span>Reviewer name</span><input name="reviewerName" required maxlength="200"></label><label><span>Email <small>optional</small></span><input name="email" type="email"></label><label><span>Organization <small>optional</small></span><input name="organization" maxlength="200"></label><label><span>Organizational job title</span><input name="jobTitle" required maxlength="200" placeholder="Principal Consultant"></label><label><span>Appointment starts</span><input name="startsOn" type="date" required value="' + esc(currentDate()) + '"></label><label class="full"><span>Why this reviewer is independent</span><textarea name="independenceRationale" required rows="4" placeholder="Describe their separation from policy ownership and control operation."></textarea></label></div><div class="workflow-preview" role="status"></div><div class="dialog-error" role="alert"></div><div class="dialog-actions"><button type="button" class="button" data-event="cancel">Cancel</button><button type="submit" class="button primary" data-preview-governance>Preview bundle</button></div></form>';
1263
+ document.body.append(dialog);
1264
+ dialog.showModal();
1265
+ const form = dialog.querySelector("form");
1266
+ const close = () => dialog.close();
1267
+ dialog.querySelector(".icon-button").addEventListener("click", close);
1268
+ dialog.querySelector('[data-event="cancel"]').addEventListener("click", close);
1269
+ dialog.addEventListener("close", () => dialog.remove());
1270
+ let previewedPayload = null;
1271
+ form.addEventListener("input", () => {
1272
+ previewedPayload = null;
1273
+ dialog.querySelector(".workflow-preview").innerHTML = "";
1274
+ dialog.querySelector("[data-preview-governance]").textContent = "Preview bundle";
1275
+ });
1276
+ form.addEventListener("submit", async (event) => {
1277
+ event.preventDefault();
1278
+ if (!form.reportValidity()) return;
1279
+ const payload = Object.fromEntries(new FormData(form).entries());
1280
+ const error = dialog.querySelector(".dialog-error");
1281
+ error.textContent = "";
1282
+ form.querySelectorAll("button,input,textarea").forEach((control) => { control.disabled = true; });
1283
+ try {
1284
+ if (!previewedPayload) {
1285
+ const response = await localFetch("/api/external-reviewer-governance/preview", {
1286
+ method: "POST",
1287
+ headers: { "content-type": "application/json" },
1288
+ body: JSON.stringify(payload)
1289
+ });
1290
+ if (!response.ok) throw new Error(await responseMessage(response));
1291
+ const preview = await response.json();
1292
+ previewedPayload = payload;
1293
+ dialog.querySelector(".workflow-preview").innerHTML = '<strong>Review this bundle</strong><p>Create ' + preview.changes.create.length + ' records and update ' + preview.changes.update.length + '. No approval or historical date is inferred beyond the facts entered above.</p>';
1294
+ dialog.querySelector("[data-preview-governance]").textContent = "Confirm and apply";
1295
+ } else {
1296
+ const response = await localFetch("/api/external-reviewer-governance", {
1297
+ method: "POST",
1298
+ headers: { "content-type": "application/json" },
1299
+ body: JSON.stringify({ ...previewedPayload, confirmed: true })
1300
+ });
1301
+ if (!response.ok) throw new Error(await responseMessage(response));
1302
+ applyMutationState(await response.json());
1303
+ dialog.close();
1304
+ render();
1305
+ }
1306
+ } catch (requestError) {
1307
+ error.textContent = requestError.message;
1308
+ } finally {
1309
+ form.querySelectorAll("button,input,textarea").forEach((control) => { control.disabled = false; });
1310
+ }
1311
+ });
1312
+ form.elements.reviewerName.focus();
1313
+ }
1314
+
1315
+ function openNextAuditCycleDialog(prior) {
1316
+ const priorEnd = coverageEnd(prior.coverage) || currentDate();
1317
+ const start = dateAfter(priorEnd);
1318
+ const end = start.slice(0, 4) + "-12-31";
1319
+ const dialog = document.createElement("dialog");
1320
+ dialog.className = "commit-dialog event-dialog";
1321
+ dialog.setAttribute("aria-labelledby", "audit-cycle-dialog-title");
1322
+ dialog.innerHTML = '<form><div class="dialog-head"><div><p class="kicker">Audit lifecycle</p><h2 id="audit-cycle-dialog-title">' + (prior.auditKind === "soc-2-type-1" ? "Start the Type 2 operating period" : "Start the next audit cycle") + '</h2></div><button type="button" class="icon-button" aria-label="Close">×</button></div><p>Carry forward the approved scope and control selections as a new planning record. FileGRC leaves report, evidence, delivery, and closure facts behind and requires review of every later change.</p><div class="form-grid"><label><span>Period start</span><input name="startsOn" type="date" required value="' + esc(start) + '"></label><label><span>Period end</span><input name="endsOn" type="date" required value="' + esc(end) + '"></label><label class="full"><span>Audit name <small>optional</small></span><input name="title" maxlength="200" placeholder="Next SOC 2 Type 2 audit"></label></div><div class="workflow-preview" role="status"></div><div class="dialog-error" role="alert"></div><div class="dialog-actions"><button type="button" class="button" data-event="cancel">Cancel</button><button type="submit" class="button primary" data-preview-cycle>Preview carry-forward</button></div></form>';
1323
+ document.body.append(dialog);
1324
+ dialog.showModal();
1325
+ const form = dialog.querySelector("form");
1326
+ dialog.querySelector(".icon-button").addEventListener("click", () => dialog.close());
1327
+ dialog.querySelector('[data-event="cancel"]').addEventListener("click", () => dialog.close());
1328
+ dialog.addEventListener("close", () => dialog.remove());
1329
+ let previewedPayload = null;
1330
+ form.addEventListener("input", () => {
1331
+ previewedPayload = null;
1332
+ dialog.querySelector(".workflow-preview").innerHTML = "";
1333
+ dialog.querySelector("[data-preview-cycle]").textContent = "Preview carry-forward";
1334
+ });
1335
+ form.addEventListener("submit", async (event) => {
1336
+ event.preventDefault();
1337
+ if (!form.reportValidity()) return;
1338
+ const payload = {
1339
+ ...Object.fromEntries(new FormData(form).entries()),
1340
+ priorAuditId: prior.id
1341
+ };
1342
+ const error = dialog.querySelector(".dialog-error");
1343
+ error.textContent = "";
1344
+ form.querySelectorAll("button,input").forEach((control) => { control.disabled = true; });
1345
+ try {
1346
+ if (!previewedPayload) {
1347
+ const response = await localFetch("/api/audit-cycle/preview", {
1348
+ method: "POST",
1349
+ headers: { "content-type": "application/json" },
1350
+ body: JSON.stringify(payload)
1351
+ });
1352
+ if (!response.ok) throw new Error(await responseMessage(response));
1353
+ const preview = await response.json();
1354
+ previewedPayload = payload;
1355
+ dialog.querySelector(".workflow-preview").innerHTML = '<strong>Review the carried-forward scope</strong><p>' + preview.audit.controlIds.length + ' controls, ' + preview.audit.systemIds.length + ' systems, and ' + preview.audit.requirementIds.length + ' requirements will start in Planning. The new record still requires scope, continuity, and source review.</p>';
1356
+ dialog.querySelector("[data-preview-cycle]").textContent = "Confirm and create";
1357
+ } else {
1358
+ const response = await localFetch("/api/audit-cycle", {
1359
+ method: "POST",
1360
+ headers: { "content-type": "application/json" },
1361
+ body: JSON.stringify({ ...previewedPayload, confirmed: true })
1362
+ });
1363
+ if (!response.ok) throw new Error(await responseMessage(response));
1364
+ const result = await response.json();
1365
+ applyMutationState(result);
1366
+ dialog.close();
1367
+ history.replaceState(null, "", "#/resources/audit/" + encodeURIComponent(result.audit.id));
1368
+ render();
1369
+ }
1370
+ } catch (requestError) {
1371
+ error.textContent = requestError.message;
1372
+ } finally {
1373
+ form.querySelectorAll("button,input").forEach((control) => { control.disabled = false; });
1374
+ }
1375
+ });
1376
+ }
1377
+
1378
+ function openApplicabilityReviewDialog(type, entries) {
1379
+ const definition = state.model.resources[type];
1380
+ const reviewPoints = definition?.guidance?.reviewPoints || [];
1381
+ const people = resourcesOfType("person").filter(({ record }) => record.status === "active");
1382
+ const pending = entries.filter(({ record }) => (
1383
+ !record.applicabilityReview
1384
+ || type === "requirement" && record.applicability === "undetermined"
1385
+ ));
1386
+ const dialog = document.createElement("dialog");
1387
+ dialog.className = "commit-dialog applicability-dialog";
1388
+ dialog.setAttribute("aria-labelledby", "applicability-dialog-title");
1389
+ const options = type === "requirement"
1390
+ ? '<option value="applicable">Applicable</option><option value="not-applicable">Not applicable</option>'
1391
+ : '<option value="applicable">Applicable</option><option value="not-applicable">Not applicable</option><option value="externally-managed">Externally managed</option><option value="zero-population">Zero population</option>';
1392
+ const rows = pending.map((entry) => '<div class="applicability-row" data-review-id="' + esc(entry.record.id) + '"><div><strong>' + esc(entry.record.title) + '</strong><small>' + esc(entry.record.code || entry.record.id) + '</small></div><select name="decision"><option value="">Review later</option>' + options + '</select><input name="rationale" placeholder="Decision rationale"></div>').join("");
1393
+ const reviewChecks = reviewPoints.length
1394
+ ? '<section class="collection-review-checks"><strong>Before deciding</strong><ul>' + reviewPoints.map((point) => '<li>' + esc(point) + '</li>').join("") + '</ul></section>'
1395
+ : "";
1396
+ dialog.innerHTML = '<form><div class="dialog-head"><div><p class="kicker">Batch review</p><h2 id="applicability-dialog-title">Review ' + esc(definition.pluralTitle) + '</h2></div><button type="button" class="icon-button" aria-label="Close">×</button></div><p>Record only decisions reviewed against the current service scope. Leave an item at Review later when management has not decided it.</p>' + reviewChecks + '<div class="form-grid review-context"><label><span>Reviewer</span><select name="reviewerId" required><option value="">Select</option>' + people.map(({ record }) => '<option value="' + esc(record.id) + '">' + esc(record.title) + '</option>').join("") + '</select></label><label><span>Reviewed on</span><input name="reviewedOn" type="date" required value="' + esc(currentDate()) + '"></label></div><div class="applicability-rows">' + (rows || empty("Every record already has a reviewed applicability decision.")) + '</div><div class="workflow-preview" role="status"></div><div class="dialog-error" role="alert"></div><div class="dialog-actions"><button type="button" class="button" data-event="cancel">Cancel</button><button type="submit" class="button primary" data-preview-review ' + (pending.length ? "" : "disabled") + '>Preview decisions</button></div></form>';
1397
+ document.body.append(dialog);
1398
+ dialog.showModal();
1399
+ const form = dialog.querySelector("form");
1400
+ dialog.querySelector(".icon-button").addEventListener("click", () => dialog.close());
1401
+ dialog.querySelector('[data-event="cancel"]').addEventListener("click", () => dialog.close());
1402
+ dialog.addEventListener("close", () => dialog.remove());
1403
+ let previewedPayload = null;
1404
+ form.addEventListener("input", () => {
1405
+ previewedPayload = null;
1406
+ dialog.querySelector(".workflow-preview").innerHTML = "";
1407
+ dialog.querySelector("[data-preview-review]").textContent = "Preview decisions";
1408
+ });
1409
+ form.addEventListener("submit", async (event) => {
1410
+ event.preventDefault();
1411
+ if (!form.reportValidity()) return;
1412
+ const error = dialog.querySelector(".dialog-error");
1413
+ error.textContent = "";
1414
+ let missingRationale = false;
1415
+ const decisions = [...dialog.querySelectorAll("[data-review-id]")].flatMap((row) => {
1416
+ const decision = row.querySelector('[name="decision"]').value;
1417
+ if (!decision) return [];
1418
+ const rationale = row.querySelector('[name="rationale"]').value.trim();
1419
+ if (!rationale) missingRationale = true;
1420
+ return [{
1421
+ id: row.dataset.reviewId,
1422
+ decision,
1423
+ rationale
1424
+ }];
1425
+ });
1426
+ if (missingRationale) {
1427
+ error.textContent = "Add a rationale for every selected decision.";
1428
+ return;
1429
+ }
1430
+ if (!decisions.length) {
1431
+ error.textContent = "Select at least one decision.";
1432
+ return;
1433
+ }
1434
+ const payload = {
1435
+ decisions,
1436
+ reviewedByIds: [form.elements.reviewerId.value],
1437
+ reviewedOn: form.elements.reviewedOn.value,
1438
+ expectedRevisions: Object.fromEntries(entries.map((entry) => [entry.record.id, entry.revision]))
1439
+ };
1440
+ form.querySelectorAll("button,input,select").forEach((control) => { control.disabled = true; });
1441
+ try {
1442
+ if (!previewedPayload) {
1443
+ const response = await localFetch("/api/applicability-review/preview", {
1444
+ method: "POST",
1445
+ headers: { "content-type": "application/json" },
1446
+ body: JSON.stringify(payload)
1447
+ });
1448
+ if (!response.ok) throw new Error(await responseMessage(response));
1449
+ const preview = await response.json();
1450
+ previewedPayload = payload;
1451
+ dialog.querySelector(".workflow-preview").innerHTML = '<strong>Review before saving</strong><p>' + preview.reviewedIds.length + ' decisions will be saved with the reviewer, review date, and current scope recorded automatically.</p>';
1452
+ dialog.querySelector("[data-preview-review]").textContent = "Confirm and save";
1453
+ } else {
1454
+ const response = await localFetch("/api/applicability-review", {
1455
+ method: "POST",
1456
+ headers: { "content-type": "application/json" },
1457
+ body: JSON.stringify({ ...previewedPayload, confirmed: true })
1458
+ });
1459
+ if (!response.ok) throw new Error(await responseMessage(response));
1460
+ applyMutationState(await response.json());
1461
+ dialog.close();
1462
+ render();
1463
+ }
1464
+ } catch (requestError) {
1465
+ error.textContent = requestError.message;
1466
+ } finally {
1467
+ form.querySelectorAll("button,input,select").forEach((control) => { control.disabled = false; });
1468
+ }
1469
+ });
1470
+ }
1471
+
798
1472
  function renderAuditPacket(main, params = new URLSearchParams()) {
799
1473
  const audits = resourcesOfType("audit");
800
1474
  const evidence = resourcesOfType("evidence");
@@ -803,7 +1477,10 @@ function renderAuditPacket(main, params = new URLSearchParams()) {
803
1477
  .flatMap((family) => family.operationRecordTypes || []));
804
1478
  const filegrcRecords = state.resources.filter(({ record }) => filegrcRecordTypes.has(record.type));
805
1479
  const requestedAudit = params.get("auditId");
806
- const selected = audits.find(({ record }) => record.id === requestedAudit)?.record || audits.find(({ record }) => record.status !== "complete")?.record || null;
1480
+ const requestedEntry = audits.find(({ record }) => record.id === requestedAudit);
1481
+ const openEntry = audits.find(({ record }) => record.status !== "complete");
1482
+ const soleEntry = audits.length === 1 ? audits[0] : null;
1483
+ const selected = (requestedEntry || openEntry || soleEntry)?.record || null;
807
1484
  const today = currentDate();
808
1485
  const start = coverageStart(selected?.coverage) || today.slice(0, 4) + "-01-01";
809
1486
  const end = coverageEnd(selected?.coverage) || today;
@@ -815,13 +1492,13 @@ function renderAuditPacket(main, params = new URLSearchParams()) {
815
1492
  ["Engagement", selected ? selected.title : "No audit record", "#/resources/audit", selected ? "good" : "warn"],
816
1493
  ["filegrc Evidence", filegrcRecords.length + " operating " + pluralize("record", filegrcRecords.length), "#/stage/run", "neutral"],
817
1494
  ["External Evidence", evidence.length + " " + pluralize("record", evidence.length), "#/resources/evidence", evidence.length ? "good" : "neutral"],
818
- ["Policy work", state.obligations.counts.overdue ? state.obligations.counts.overdue + " overdue" : state.obligations.counts.due ? state.obligations.counts.due + " due" : state.obligations.counts.proposed ? state.obligations.counts.proposed + " proposals" : "No work due", "#/stage/run", state.obligations.counts.overdue ? "bad" : state.obligations.counts.due ? "warn" : state.obligations.counts.proposed ? "neutral" : "good"]
1495
+ ["Policy work", state.obligations.counts.overdue ? state.obligations.counts.overdue + " overdue" : state.obligations.counts.blocked ? state.obligations.counts.blocked + " blocked" : state.obligations.counts.due ? state.obligations.counts.due + " due" : state.obligations.counts.proposed ? state.obligations.counts.proposed + " proposals" : "No work due", "#/stage/run", state.obligations.counts.overdue || state.obligations.counts.blocked ? "bad" : state.obligations.counts.due ? "warn" : state.obligations.counts.proposed ? "neutral" : "good"]
819
1496
  ];
820
- const evidencePaths = '<section class="panel audit-evidence-paths"><div class="panel-head"><div><p class="kicker">Evidence workflow</p><h3>Review both evidence paths</h3><p>Use the formal audit date or period. Each selected control may need one or both paths.</p></div></div><div class="audit-evidence-path-grid"><a href="#/stage/run"><span class="step-label">filegrc Evidence</span><h4>Review operating records</h4><p>Complete the applicable Step 4 records, link them to their Controls, and record results in their fields or Markdown. Link any external artifact needed to support the result. The packet includes the records, Markdown, Git history, and linked artifacts.</p></a><a href="#/resources/evidence"><span class="step-label">External Evidence</span><h4>Review imported or referenced proof</h4><p>Verify the source System, audit date or period, Control links, collector, verifier, and fixed attachment or approved external reference. The packet includes the records, retained files, delivery index, and checksums.</p></a></div></section>';
1497
+ const evidencePaths = '<section class="panel audit-evidence-paths"><div class="panel-head"><div><p class="kicker">Evidence workflow</p><h3>Review both evidence paths</h3><p>Use the formal audit date or period. Each selected control may need one or both paths.</p></div></div><div class="audit-evidence-path-grid"><a href="#/stage/run"><span class="step-label">filegrc Evidence</span><h4>Review operating records</h4><p>Confirm the applicable Step 4 records are complete and linked to their Controls.</p></a><a href="#/resources/evidence"><span class="step-label">External Evidence</span><h4>Review imported or referenced proof</h4><p>Confirm each artifact is fixed, verified, and linked to its source System and Controls.</p></a></div></section>';
821
1498
  const dateFields = typeOne
822
1499
  ? '<label><span>As-of date</span><input type="date" name="start" required value="' + esc(start) + '"></label>'
823
1500
  : '<label><span>Period start</span><input type="date" name="start" required value="' + esc(start) + '"></label><label><span>Period end</span><input type="date" name="end" required value="' + esc(end) + '"></label>';
824
- main.innerHTML = '<div class="page audit-packet-page"><div class="page-intro"><div><p class="kicker">Audit evidence and packet</p><h2>Prepare Fieldwork</h2><p>Confirm the firm-agreed date or period, review filegrc Evidence and External Evidence, complete management documents and Type 2 populations, then build the indexed packet. filegrc compiles both evidence paths with their links, control matrix, history, attachments, indexes, and checksums.</p></div></div><section class="packet-preflight" aria-label="Packet readiness">' + preflight.map(([label, value, href, tone]) => '<a href="' + href + '"><span class="status-dot ' + tone + '"></span><span><small>' + esc(label) + '</small><strong>' + esc(value) + '</strong></span></a>').join("") + '</section>' + evidencePaths + renderAuditPreparation(preparation) + '<section class="panel packet-builder"><div class="panel-head"><div><p class="kicker">Evidence delivery</p><h3>' + (typeOne ? "Build the As-of Packet" : "Build the Period Packet") + '</h3></div></div><form id="packet-form">' + dateFields + '<label><span>Audit <small>required for delivery</small></span><select name="auditId"><option value="">Draft Without Audit Scope</option>' + audits.map(({ record }) => '<option value="' + esc(record.id) + '" ' + (record.id === selected?.id ? "selected" : "") + '>' + esc(record.title) + '</option>').join("") + '</select></label><button class="button primary" type="submit" ' + (state.readOnly ? "disabled" : "") + '>' + (draft ? "Generate draft" : "Generate packet") + '</button></form><p class="packet-note">' + (state.readOnly ? "Packet generation requires the local writable renderer or the CLI." : draft ? "Drafts expose coverage gaps now. Commit a clean revision and select an audit record before delivery." : "The packet is derived under .filegrc/ and bound to the selected audit and current Git revision. filegrc checks preparation and integrity; the engagement team determines evidence sufficiency.") + '</p><div class="dialog-error" role="alert"></div></section><div id="packet-results"></div></div>';
1501
+ main.innerHTML = '<div class="page audit-packet-page"><div class="page-intro"><div><p class="kicker">Audit evidence and packet</p><h2>Prepare Fieldwork</h2><p>Review fieldwork readiness, then build the evidence packet for the agreed audit date or period.</p></div></div><section class="packet-preflight" aria-label="Packet readiness">' + preflight.map(([label, value, href, tone]) => '<a href="' + href + '"><span class="status-dot ' + tone + '"></span><span><small>' + esc(label) + '</small><strong>' + esc(value) + '</strong></span></a>').join("") + '</section>' + evidencePaths + renderAuditPreparation(preparation) + '<section class="panel packet-builder"><div class="panel-head"><div><p class="kicker">Evidence delivery</p><h3>' + (typeOne ? "Build the As-of Packet" : "Build the Period Packet") + '</h3></div></div><form id="packet-form">' + dateFields + '<label><span>Audit <small>required for delivery</small></span><select name="auditId"><option value="">Draft Without Audit Scope</option>' + audits.map(({ record }) => '<option value="' + esc(record.id) + '" ' + (record.id === selected?.id ? "selected" : "") + '>' + esc(record.title) + '</option>').join("") + '</select></label><button class="button primary" type="submit" ' + (state.readOnly ? "disabled" : "") + '>' + (draft ? "Generate draft" : "Generate packet") + '</button></form><p class="packet-note">' + (state.readOnly ? "Packet generation requires the local writable renderer or the CLI." : draft ? "Drafts expose coverage gaps now. Commit a clean revision and select an audit record before delivery." : "The packet is derived under .filegrc/ and bound to the selected audit and current Git revision. filegrc checks preparation and integrity; the engagement team determines evidence sufficiency.") + '</p><div class="dialog-error" role="alert"></div></section><div id="packet-results"></div></div>';
825
1502
  main.querySelector('select[name="auditId"]').addEventListener("change", (event) => {
826
1503
  const next = event.currentTarget.value;
827
1504
  location.hash = "#/audit-packet" + (next ? "?auditId=" + encodeURIComponent(next) : "");
@@ -925,7 +1602,7 @@ function renderPacketResults(container, result) {
925
1602
  }
926
1603
 
927
1604
  function obligationPreview(items) {
928
- return items.length ? '<div class="obligation-preview">' + items.map((item) => '<a href="#/stage/run"><span class="status-dot ' + (item.status === "overdue" ? "bad" : item.status === "due" ? "warn" : "neutral") + '"></span><span><strong>' + esc(item.title) + '</strong><small>' + esc(timingText(item)) + '</small></span></a>').join("") + '</div>' : empty("No open obligations.");
1605
+ return items.length ? '<div class="obligation-preview">' + items.map((item) => '<a href="#/stage/run"><span class="status-dot ' + (["blocked", "overdue"].includes(item.status) ? "bad" : item.status === "due" ? "warn" : "neutral") + '"></span><span><strong>' + esc(item.title) + '</strong><small>' + esc(timingText(item)) + '</small></span></a>').join("") + '</div>' : empty("No open obligations.");
929
1606
  }
930
1607
 
931
1608
  function distinctObligationPreviews(items, limit) {
@@ -961,6 +1638,7 @@ function windowText(item) {
961
1638
  function timingText(item) {
962
1639
  if (item.canceledAction) return "Action canceled; resolve or cancel the event";
963
1640
  if (item.missingCompletion) return "Link required completion proof";
1641
+ if (item.status === "blocked") return item.blockingReason || "Blocked";
964
1642
  if (item.status === "proposed") return "Starter proposal";
965
1643
  if (item.status === "overdue" && Number.isInteger(item.hoursOverdue)) {
966
1644
  return item.hoursOverdue === 0 ? "Overdue less than 1 hour" : item.hoursOverdue + " hour" + (item.hoursOverdue === 1 ? "" : "s") + " overdue";
@@ -1015,11 +1693,21 @@ function renderList(main, type, params = new URLSearchParams()) {
1015
1693
  return { name, label: field.label || humanize(name), values };
1016
1694
  }).filter(({ values }) => values.length > 1);
1017
1695
  const createButton = !state.readOnly && !definition.singleton ? '<button class="button primary" id="new-resource">New ' + esc(definition.title.toLowerCase()) + '</button>' : "";
1696
+ const hasPendingApplicability = entries.some(({ record }) => (
1697
+ !record.applicabilityReview
1698
+ || type === "requirement" && record.applicability === "undetermined"
1699
+ ));
1700
+ const applicabilityButton = !state.readOnly
1701
+ && ["requirement", "control", "commitment", "complementary-control"].includes(type)
1702
+ && hasPendingApplicability
1703
+ ? '<button class="button" id="review-applicability">Review applicability</button>'
1704
+ : "";
1018
1705
  const guideTrigger = '<button class="guide-trigger" id="resource-guide-trigger" type="button" aria-label="About ' + esc(definition.pluralTitle) + '" aria-haspopup="dialog" aria-controls="resource-guide" aria-expanded="false"><svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="8"></circle><path d="M7.8 7.5a2.4 2.4 0 1 1 3.25 2.25c-.7.31-1.05.72-1.05 1.5v.25M10 14.5v.1"></path></svg></button>';
1019
1706
  const listTools = '<div class="list-tools list-header-tools"><label><span class="sr-only">Filter list</span><input id="list-search" type="search" placeholder="Filter ' + esc(definition.pluralTitle.toLowerCase()) + '"></label>' +
1020
- filters.map(({ name, label, values }) => '<select class="field-filter" data-field="' + esc(name) + '" aria-label="Filter by ' + esc(label.toLowerCase()) + '"><option value="">Any ' + esc(properCase(label)) + '</option>' + values.map((value) => '<option value="' + esc(value) + '">' + esc(filterOptionLabel(value)) + '</option>').join("") + '</select>').join("") + '<span id="result-count" aria-live="polite">' + entries.length + ' records</span>' + createButton + '</div>';
1707
+ filters.map(({ name, label, values }) => '<select class="field-filter" data-field="' + esc(name) + '" aria-label="Filter by ' + esc(label.toLowerCase()) + '"><option value="">Any ' + esc(properCase(label)) + '</option>' + values.map((value) => '<option value="' + esc(value) + '">' + esc(filterOptionLabel(value)) + '</option>').join("") + '</select>').join("") + '<span id="result-count" aria-live="polite">' + entries.length + ' records</span>' + applicabilityButton + createButton + '</div>';
1021
1708
  main.innerHTML = '<div class="page"><div class="page-intro"><div><p class="kicker">' + esc(listStage?.title || groupTitle(definition.group)) + '</p><div class="page-title-line"><h2>' + esc(titleCase(definition.pluralTitle)) + '</h2>' + guideTrigger + '</div></div>' + listTools + '</div>' + resourceGuide(type) +
1022
- '<section class="record-table-wrap"><table class="record-table"><thead><tr><th>' + esc(fieldLabel(type, "title")) + '</th>' + fields.map((name) => '<th>' + esc(fieldLabel(type, name)) + '</th>').join("") + '<th>Git file</th></tr></thead><tbody id="record-rows"></tbody></table></section>' +
1709
+ collectionReviewPanel(type) +
1710
+ '<section class="record-table-wrap"><table class="record-table"><thead><tr><th>' + esc(fieldLabel(type, "title")) + '</th>' + fields.map((name) => '<th>' + esc(fieldLabel(type, name)) + '</th>').join("") + '<th>Next action</th><th>Git file</th></tr></thead><tbody id="record-rows"></tbody></table></section>' +
1023
1711
  '<nav class="pagination list-pagination" aria-label="' + esc(definition.pluralTitle) + ' pages" hidden><button class="button" type="button" data-page="previous">Previous</button><span class="page-status" aria-live="polite"></span><button class="button" type="button" data-page="next">Next</button></nav></div>';
1024
1712
  resourceGuideCleanup = setupResourceGuide(main);
1025
1713
  const pagination = main.querySelector(".list-pagination");
@@ -1035,7 +1723,7 @@ function renderList(main, type, params = new URLSearchParams()) {
1035
1723
  const start = (pageNumber - 1) * LIST_PAGE_SIZE;
1036
1724
  const visible = filtered.slice(start, start + LIST_PAGE_SIZE);
1037
1725
  main.querySelector("#result-count").textContent = filtered.length + (filtered.length === 1 ? " record" : " records");
1038
- main.querySelector("#record-rows").innerHTML = filtered.length ? visible.map((entry) => '<tr><td data-label="' + esc(fieldLabel(type, "title")) + '" data-primary-field><a class="record-title" href="#/resource/' + encodeURIComponent(type) + '/' + encodeURIComponent(entry.record.id) + '">' + esc(entry.record.title) + '</a></td>' + fields.map((name) => '<td data-label="' + esc(fieldLabel(type, name)) + '">' + (name === "$operationTracking" ? controlOperationTracking(entry.record) : name === "$workQueueStatus" ? obligationWorkQueueStatus(entry.record) : formatValue(name === "status" ? displayStatus(entry.record) : entry.record[name], name, type)) + '</td>').join("") + '<td data-label="Git file"><code>' + esc(entry.relativePath.replace(/^data\//, "")) + '</code></td></tr>').join("") : '<tr><td colspan="' + (fields.length + 2) + '">' + empty("No records match this filter.") + '</td></tr>';
1726
+ main.querySelector("#record-rows").innerHTML = filtered.length ? visible.map((entry) => '<tr><td data-label="' + esc(fieldLabel(type, "title")) + '" data-primary-field><a class="record-title" href="#/resource/' + encodeURIComponent(type) + '/' + encodeURIComponent(entry.record.id) + '">' + esc(entry.record.title) + '</a></td>' + fields.map((name) => '<td data-label="' + esc(fieldLabel(type, name)) + '">' + (name === "$operationTracking" ? controlOperationTracking(entry.record) : name === "$workQueueStatus" ? obligationWorkQueueStatus(entry.record) : formatValue(name === "status" ? displayStatus(entry.record) : entry.record[name], name, type)) + '</td>').join("") + '<td data-label="Next action">' + recordWorkflowCell(type, entry) + '</td><td data-label="Git file"><code>' + esc(entry.relativePath.replace(/^data\//, "")) + '</code></td></tr>').join("") : '<tr><td colspan="' + (fields.length + 3) + '">' + empty(entries.length ? "No records match this filter." : state.collectionReviews?.[type] ? "No records exist. Use the scope confirmation above to record an allowed zero population or add the records management identified." : definition.guidance?.emptyState || "No records exist. Use the page guidance to decide whether a record is required, then add only real program facts.") + '</td></tr>';
1039
1727
  pagination.hidden = totalPages === 1;
1040
1728
  previous.disabled = pageNumber === 1;
1041
1729
  next.disabled = pageNumber === totalPages;
@@ -1075,7 +1763,15 @@ function renderList(main, type, params = new URLSearchParams()) {
1075
1763
  renderRows();
1076
1764
  syncRoute();
1077
1765
  main.querySelector("#new-resource")?.addEventListener("click", () => openEditor(type));
1766
+ main.querySelector("#review-applicability")?.addEventListener("click", () => openApplicabilityReviewDialog(type, entries));
1767
+ main.querySelector("[data-review-collection]")?.addEventListener("click", () => openCollectionReviewDialog(type));
1078
1768
  if (params.get("new") === "1" && !state.readOnly && !definition.singleton) queueMicrotask(() => openEditor(type));
1769
+ if (params.get("review") === "1" && !state.readOnly) {
1770
+ queueMicrotask(() => main.querySelector("#review-applicability")?.click());
1771
+ }
1772
+ if (params.get("review-collection") === "1" && !state.readOnly) {
1773
+ queueMicrotask(() => main.querySelector("[data-review-collection]")?.click());
1774
+ }
1079
1775
  }
1080
1776
 
1081
1777
  function renderDetail(main, type, id) {
@@ -1113,12 +1809,33 @@ function renderDetail(main, type, id) {
1113
1809
  ? ""
1114
1810
  : (FINDING_SOURCE_TYPES.has(type) ? '<button class="button" type="button" data-record-finding>Record finding</button>' : "")
1115
1811
  + (ACTION_ITEM_SOURCE_TYPES.has(type) ? '<button class="button" type="button" data-add-action-item>Add task</button>' : "");
1812
+ const lifecycleActions = state.readOnly
1813
+ ? ""
1814
+ : type === "action-item" && !["done", "canceled"].includes(entry.record.status) && entry.record.obligationId
1815
+ ? '<button class="button primary" type="button" data-complete-action-detail>Complete task</button>'
1816
+ : type === "obligation-event" && entry.record.status !== "complete"
1817
+ ? '<button class="button primary" type="button" data-complete-event>Complete event</button>'
1818
+ : "";
1819
+ const governanceActions = !state.readOnly
1820
+ && type === "appointment"
1821
+ && entry.record.appointmentKind === "independent-policy-reviewer"
1822
+ && entry.record.status === "planned"
1823
+ ? '<button class="button" type="button" data-external-reviewer-governance>Use external reviewer</button>'
1824
+ : "";
1825
+ const auditCycleAction = !state.readOnly
1826
+ && type === "audit"
1827
+ && entry.record.status === "complete"
1828
+ ? '<button class="button primary" type="button" data-next-audit-cycle>' + (entry.record.auditKind === "soc-2-type-1" ? "Start Type 2 period" : "Start next cycle") + '</button>'
1829
+ : "";
1116
1830
  const detailMain = hasRecordBody
1117
1831
  ? '<section class="panel detail-main">' + narrativeContent + markdownContent + addRecordContent + '</section>'
1118
1832
  : "";
1119
- main.innerHTML = '<div class="page"><div class="detail-head"><div><div class="breadcrumbs header-breadcrumbs"><a href="#/resources/' + encodeURIComponent(type) + '">' + esc(titleCase(definition.pluralTitle)) + '</a><span>/</span><span>' + esc(entry.record.title) + '</span></div><h2>' + esc(titleCase(entry.record.title)) + '</h2></div><div class="actions">' + (type === "audit" ? '<a class="button primary" href="#/audit-packet?auditId=' + encodeURIComponent(entry.record.id) + '">Audit Evidence &amp; Packet</a>' : "") + issueActions + addRecordContentAction + (!state.readOnly ? '<button class="button" id="edit-resource">Edit</button>' + (!definition.singleton ? '<button class="button danger" id="delete-resource">Delete</button>' : "") : "") + '</div></div><div class="detail-grid ' + (hasRecordBody ? "" : "detail-grid-structured") + '">' + detailMain +
1120
- '<aside><section class="panel"><div class="panel-head"><h3>Metadata</h3></div><dl class="metadata">' + sourceMetadata + visible.map(([name, value]) => '<div><dt>' + esc(fields[name]?.label || humanize(name)) + '</dt><dd>' + formatValue(name === "status" ? displayStatus(entry.record) : value, name, type) + '</dd></div>').join("") + '</dl></section>' + personParticipation(entry) + resourceConnections(entry) + '<section class="panel"><div class="panel-head"><h3>File History</h3></div>' + (entry.history?.length ? '<div class="history">' + entry.history.map((commit) => '<div><code>' + esc(commit.shortCommit) + '</code><span><strong>' + esc(commit.subject) + '</strong><small>' + esc(commit.author) + ' · ' + esc(formatLocalDateTime(commit.timestamp)) + '</small></span></div>').join("") + '</div>' : empty("No committed history for this file.")) + '</section></aside></div></div>';
1833
+ const attachmentPanel = type === "evidence" ? evidenceAttachmentPanel(entry) : "";
1834
+ main.innerHTML = '<div class="page"><div class="detail-head"><div><div class="breadcrumbs header-breadcrumbs"><a href="#/resources/' + encodeURIComponent(type) + '">' + esc(titleCase(definition.pluralTitle)) + '</a><span>/</span><span>' + esc(entry.record.title) + '</span></div><h2>' + esc(titleCase(entry.record.title)) + '</h2></div><div class="actions">' + auditCycleAction + (type === "audit" ? '<a class="button primary" href="#/audit-packet?auditId=' + encodeURIComponent(entry.record.id) + '">Audit Evidence &amp; Packet</a>' : "") + governanceActions + lifecycleActions + issueActions + addRecordContentAction + (!state.readOnly ? '<button class="button" id="edit-resource">Edit</button>' + (!definition.singleton ? '<button class="button danger" id="delete-resource">Delete</button>' : "") : "") + '</div></div>' + workflowGuidance({ type, id, title: "Finalization checklist" }) + resourceReviewCriteria(type) + '<div class="detail-grid ' + (hasRecordBody ? "" : "detail-grid-structured") + '">' + detailMain +
1835
+ '<aside><section class="panel"><div class="panel-head"><h3>Metadata</h3></div><dl class="metadata">' + sourceMetadata + visible.map(([name, value]) => '<div><dt>' + esc(fields[name]?.label || humanize(name)) + '</dt><dd>' + formatValue(name === "status" ? displayStatus(entry.record) : value, name, type) + '</dd></div>').join("") + '</dl></section>' + attachmentPanel + personParticipation(entry) + resourceConnections(entry) + '<section class="panel"><div class="panel-head"><h3>File History</h3></div>' + (entry.history?.length ? '<div class="history">' + entry.history.map((commit) => '<div><code>' + esc(commit.shortCommit) + '</code><span><strong>' + esc(commit.subject) + '</strong><small>' + esc(commit.author) + ' · ' + esc(formatLocalDateTime(commit.timestamp)) + '</small></span></div>').join("") + '</div>' : empty("No committed history for this file.")) + '</section></aside></div></div>';
1121
1836
  main.querySelector("#edit-resource")?.addEventListener("click", () => openEditor(type, entry));
1837
+ main.querySelector("[data-external-reviewer-governance]")?.addEventListener("click", openExternalReviewerGovernanceDialog);
1838
+ main.querySelector("[data-next-audit-cycle]")?.addEventListener("click", () => openNextAuditCycleDialog(entry.record));
1122
1839
  main.querySelector("[data-record-finding]")?.addEventListener("click", () => openEditor("finding", null, {
1123
1840
  seed: issueSeed("finding", entry.record),
1124
1841
  description: "Record only a confirmed gap that needs separate remediation tracking. Keep the report details in this source record’s Markdown."
@@ -1127,6 +1844,68 @@ function renderDetail(main, type, id) {
1127
1844
  seed: issueSeed("action-item", entry.record),
1128
1845
  description: "Create a separate task only when this follow-up needs its own assignee, deadline, and completion proof. It will appear in Work Queue."
1129
1846
  }));
1847
+ main.querySelector("[data-complete-action-detail]")?.addEventListener("click", () => {
1848
+ const item = state.obligations.items.find(({ actionItemId }) => actionItemId === entry.record.id);
1849
+ if (item) openActionCompletion(item);
1850
+ else showError("This Action Item is not available in the current Work Queue calculation.");
1851
+ });
1852
+ main.querySelector("[data-complete-event]")?.addEventListener("click", async () => {
1853
+ try {
1854
+ const response = await localFetch("/api/obligation-event-completions", {
1855
+ method: "POST",
1856
+ headers: { "content-type": "application/json" },
1857
+ body: JSON.stringify({
1858
+ eventId: entry.record.id,
1859
+ completedOn: currentDate(),
1860
+ revision: entry.revision
1861
+ })
1862
+ });
1863
+ if (!response.ok) throw new Error(await responseMessage(response));
1864
+ applyMutationState(await response.json());
1865
+ render();
1866
+ } catch (error) {
1867
+ showError(error.message);
1868
+ }
1869
+ });
1870
+ main.querySelector("[data-attach-evidence]")?.addEventListener("click", () => {
1871
+ main.querySelector("[data-evidence-file]")?.click();
1872
+ });
1873
+ main.querySelector("[data-evidence-file]")?.addEventListener("change", async (event) => {
1874
+ const file = event.currentTarget.files?.[0];
1875
+ if (!file) return;
1876
+ if (!confirm('Attach "' + file.name + '" to this Evidence record? Confirm that its classification, retention, and repository access are appropriate.')) {
1877
+ event.currentTarget.value = "";
1878
+ return;
1879
+ }
1880
+ try {
1881
+ const response = await localFetch(
1882
+ "/api/evidence-attachments/" + encodeURIComponent(entry.record.id) + "/" + encodeURIComponent(file.name)
1883
+ + "?revision=" + encodeURIComponent(entry.revision),
1884
+ { method: "POST", body: file }
1885
+ );
1886
+ if (!response.ok) throw new Error(await responseMessage(response));
1887
+ applyMutationState(await response.json());
1888
+ render();
1889
+ } catch (error) {
1890
+ showError(error.message);
1891
+ }
1892
+ });
1893
+ main.querySelectorAll("[data-detach-evidence]").forEach((button) => button.addEventListener("click", async () => {
1894
+ const attachment = button.dataset.detachEvidence;
1895
+ if (!confirm('Remove "' + attachment + '" from this Evidence record and delete its local file?')) return;
1896
+ try {
1897
+ const response = await localFetch(
1898
+ "/api/evidence-attachments/" + encodeURIComponent(entry.record.id) + "/" + encodeURIComponent(attachment)
1899
+ + "?revision=" + encodeURIComponent(entry.revision),
1900
+ { method: "DELETE" }
1901
+ );
1902
+ if (!response.ok) throw new Error(await responseMessage(response));
1903
+ applyMutationState(await response.json());
1904
+ render();
1905
+ } catch (error) {
1906
+ showError(error.message);
1907
+ }
1908
+ }));
1130
1909
  main.querySelector("#add-record-content")?.addEventListener("click", () => openEditor(type, entry, { addRecordContent: true }));
1131
1910
  main.querySelectorAll("[data-edit-content]").forEach((button) => button.addEventListener("click", () => openContentEditor(entry, button.dataset.editContent)));
1132
1911
  main.querySelector("#delete-resource")?.addEventListener("click", async () => {
@@ -1142,6 +1921,23 @@ function renderDetail(main, type, id) {
1142
1921
  });
1143
1922
  }
1144
1923
 
1924
+ function evidenceAttachmentPanel(entry) {
1925
+ const attachments = (entry.record.filePaths || []).map((path) => ({
1926
+ path,
1927
+ name: path.split("/").at(-1)
1928
+ }));
1929
+ const rows = attachments.length
1930
+ ? attachments.map(({ path, name }) => (
1931
+ '<li><span><strong>' + esc(name) + '</strong><small>' + esc(path) + '</small></span>'
1932
+ + (!state.readOnly ? '<button class="text-button danger-text" type="button" data-detach-evidence="' + esc(name) + '">Remove</button>' : "")
1933
+ + '</li>'
1934
+ )).join("")
1935
+ : '<li class="attachment-empty">No local attachments. An approved external reference may be used when the source cannot be stored here.</li>';
1936
+ return '<section class="panel evidence-attachments"><div class="panel-head"><div><h3>Attachments</h3><p>Fixed source files retained with this Evidence record.</p></div>'
1937
+ + (!state.readOnly ? '<button class="button" type="button" data-attach-evidence>Attach file</button><input type="file" data-evidence-file hidden>' : "")
1938
+ + '</div><ul>' + rows + '</ul></section>';
1939
+ }
1940
+
1145
1941
  async function loadResourceDetail(type, id) {
1146
1942
  const key = type + "\0" + id;
1147
1943
  if (resourceDetailRequests.has(key)) return resourceDetailRequests.get(key);
@@ -1479,14 +2275,18 @@ function resourceGuide(type) {
1479
2275
  const definition = state.model.resources[type];
1480
2276
  const guidance = definition?.guidance;
1481
2277
  if (!definition || !guidance) return "";
1482
- const instructions = stagePageSummary({ type });
2278
+ const instructions = RESOURCE_GUIDE_INSTRUCTIONS[type] || definition.description;
1483
2279
  const sources = (guidance.sourceResourceIds || [])
1484
2280
  .map((id) => state.resources.find(({ record }) => record.id === id))
1485
2281
  .filter(Boolean);
1486
2282
  const sourceLinks = sources.length
1487
2283
  ? '<div class="guide-links">' + sources.map(({ record }) => '<a href="#/resource/' + encodeURIComponent(record.type) + '/' + encodeURIComponent(record.id) + '">' + esc(record.title) + '</a>').join("") + '</div>'
1488
2284
  : "";
1489
- return '<section class="page-guide resource-guide-popover" id="resource-guide" role="dialog" aria-label="How to use ' + esc(definition.pluralTitle) + '" hidden><div><span>Instructions</span><p>' + esc(instructions) + '</p></div><div><span>Use</span><p>' + esc(definition.description) + '</p></div><div><span>Policy basis</span><p>' + esc(guidance.policyBasis) + '</p>' + sourceLinks + '</div></section>';
2285
+ const reviewPoints = guidance.reviewPoints || [];
2286
+ const reviewGuide = reviewPoints.length
2287
+ ? '<div class="guide-review"><span>When reviewing</span><ul>' + reviewPoints.map((point) => '<li>' + esc(point) + '</li>').join("") + '</ul></div>'
2288
+ : "";
2289
+ return '<section class="page-guide resource-guide-popover" id="resource-guide" role="dialog" aria-label="How to use ' + esc(definition.pluralTitle) + '" hidden><div><span>Instructions</span><p>' + esc(instructions) + '</p></div><div><span>Use</span><p>' + esc(definition.description) + '</p></div><div><span>Policy basis</span><p>' + esc(guidance.policyBasis) + '</p>' + sourceLinks + '</div>' + reviewGuide + '</section>';
1490
2290
  }
1491
2291
 
1492
2292
  function setupResourceGuide(main) {
@@ -1629,91 +2429,62 @@ function onboardingSteps() {
1629
2429
  points: [
1630
2430
  "Use the UI, an editor, the CLI, or an agent; every path changes the same files.",
1631
2431
  "JSON holds structured records. Markdown holds policies, plans, minutes, and other long-form work.",
1632
- "In trunk mode, each browser save fast-forwards, validates, creates one focused local commit, then pushes it in the background. The workspace stays read-only until sync finishes.",
1633
- "Record status represents approval. Draft, proposed, approved, and retired records all stay on the authoritative branch.",
1634
- "Agents and terminal users continue to manage Git explicitly.",
1635
- "The dashboard derives program status from the current repository state."
2432
+ "Record status represents approval. In trunk mode, the browser validates, commits, and pushes each save; agents and terminal users manage Git explicitly."
1636
2433
  ]
1637
2434
  };
1638
2435
  const path = {
1639
2436
  target: ".readiness-map",
1640
2437
  kicker: "Program model",
1641
2438
  title: "Follow the audit chain",
1642
- body: "The shortest dependable path is to define scope, approve policies, implement controls, prepare the evidence process, and operate the program before audit fieldwork begins.",
2439
+ body: "Follow the five program steps in order. Each step reveals the records and decisions needed next.",
1643
2440
  points: [
1644
- "Scope starts with people, dated appointments, oversight teams, applicable criteria, commitments, material vendors, and in-scope systems.",
1645
- "Program operation includes current risk assessments and risks, which may add or change controls as conditions change.",
1646
- "Evidence preparation means cataloging authoritative systems, documenting extraction, and testing captures before the candidate period.",
1647
- "The CPA firm, formal report period, fieldwork, and final report are the last stage. Engage earlier only when timing or scope needs outside input."
2441
+ "Define the people, criteria, service, Systems, and providers in scope.",
2442
+ "Approve the policies, implement the controls, then operate them and retain dated proof.",
2443
+ "Create the audit engagement when a CPA firm is involved or a real customer deadline requires it."
1648
2444
  ]
1649
2445
  };
1650
- const obligations = {
2446
+ const operation = {
1651
2447
  target: ".obligation-panel",
1652
- kicker: "Obligations",
1653
- title: "Work the policy queue",
1654
- body: "Recurring policy work appears as upcoming, due, or overdue. Each item shows the full allowed completion range, the first overdue date, and a live countdown to that cutoff.",
1655
- points: [
1656
- "Quarterly means any date in that cycle is valid unless the policy sets a narrower window.",
1657
- "Link a dated completion record and its evidence to satisfy one occurrence.",
1658
- "The UI and filegrc CLI use the same calculation."
1659
- ]
1660
- };
1661
- const events = {
1662
- target: ".event-reminder-panel",
1663
- kicker: "Triggered work",
1664
- title: "Complete a checklist when key events occur",
1665
- body: "Use an event reminder for a new worker, job or responsibility change, departure, personal device, vendor change or incident, material system or data-use change, or security incident. One action item is created for every policy requirement, with its own owner, evidence, due range, and cutoff.",
2448
+ kicker: "Program operation",
2449
+ title: "Work the queue and trigger policy events",
2450
+ body: "Recurring work and assigned follow-up appear in the Work Queue with owners, allowed completion dates, and overdue cutoffs. When a listed event happens, start its Policy Event to create the applicable tasks and deadlines.",
1666
2451
  points: [
1667
- "The checklist stays open until every action is done and has the requested completion record or evidence.",
1668
- "Hour-based rules keep the event time and exact cutoff; day-based rules keep the policy date range.",
1669
- "Every action has a policy-based cutoff or a reasonable default deadline for the event.",
1670
- "Agents start the identical workflow with the filegrc CLI."
2452
+ "Complete each occurrence with the requested dated operating record and supporting evidence.",
2453
+ "Start Policy Events only after the real event occurs. FileGRC creates one owned Action Item for each applicable policy step.",
2454
+ "The browser and CLI use the same schedules, event rules, and completion checks."
1671
2455
  ]
1672
2456
  };
1673
- const reportTypes = {
2457
+ const auditPath = {
1674
2458
  target: null,
1675
- kicker: "SOC 2 report types",
1676
- title: "Choose the report goal",
2459
+ kicker: "Report goal and audit",
2460
+ title: "Choose the report goal and plan fieldwork",
1677
2461
  body: [
1678
2462
  "SOC 2 is an independent CPA report on controls relevant to the selected Trust Services Criteria.",
1679
- "Most customer requests focus on Security. Add Availability, Processing Integrity, Confidentiality, or Privacy only when the service and customer need call for them."
2463
+ "Most customer requests focus on Security. Add another category only when the service and customer need call for it. Choose a management goal now, then create an Audit record only after a real CPA engagement or customer deadline exists."
1680
2464
  ],
1681
2465
  sections: [
1682
2466
  {
1683
2467
  title: "Type 1",
1684
- body: "A CPA evaluates whether the controls are suitably designed and implemented at a point in time. Type 1 is optional before Type 2, but it can help with an urgent customer request."
2468
+ body: "The CPA evaluates control design and implementation at a point in time. Type 1 is optional before Type 2."
1685
2469
  },
1686
2470
  {
1687
2471
  title: "Type 2",
1688
- body: "A CPA evaluates whether the controls operated consistently throughout an agreed review period, often six months. Dated evidence must cover that period."
2472
+ body: "The CPA evaluates operation across an agreed period. Dated evidence and complete populations must cover that period."
1689
2473
  }
1690
2474
  ],
1691
- afterSections: "Most evidence comes from production, identity, monitoring, and business systems. filegrc records where it comes from and how it was collected."
1692
- };
1693
- const audit = {
1694
- target: ".audit-panel",
1695
- kicker: "Final stage",
1696
- title: "Engage the firm and prepare fieldwork",
1697
- body: "Once the program is ready and evidence collection is running, record the CPA firm and the agreed scope and period. Then reconcile populations, answer requests, and generate the delivery packet.",
1698
- points: [
1699
- "The audit record holds the firm-agreed date or period; the workspace keeps management's earlier candidate dates.",
1700
- "Audit Readiness identifies missing management documents, populations, exact-period evidence, and request work.",
1701
- "The CPA firm selects samples, tests controls, evaluates exceptions, and issues the report."
1702
- ]
2475
+ afterSections: "FileGRC prepares the records and packet. The CPA firm selects samples, tests controls, evaluates exceptions, and issues the report."
1703
2476
  };
1704
2477
  const setup = {
1705
2478
  target: null,
1706
2479
  kicker: "Initial scope",
1707
2480
  title: "Describe the service you plan to audit",
1708
- body: "This records the management goal and creates the first in-scope system. It does not create an audit engagement. Next, finish Step 1 by adding the real reviewers and operators, finishing the oversight team, and confirming the criteria, commitments, vendors, and systems."
2481
+ body: "Create the first in-scope System and record management’s goal. Step 1 will guide the rest of the scope."
1709
2482
  };
1710
2483
  return [
1711
2484
  files,
1712
2485
  path,
1713
- obligations,
1714
- events,
1715
- reportTypes,
1716
- audit,
2486
+ operation,
2487
+ auditPath,
1717
2488
  setup
1718
2489
  ];
1719
2490
  }
@@ -1734,7 +2505,7 @@ function renderOnboardingStep() {
1734
2505
  ? onboardingSetupForm()
1735
2506
  : description + explanation + afterSections;
1736
2507
  const finalActions = onboardingStep === steps.length - 1
1737
- ? '<span class="onboarding-save-status" role="status" aria-live="polite"></span><button class="button" type="button" data-onboarding="draft">Save draft</button><button class="button primary" type="button" data-onboarding="next">Complete setup</button>'
2508
+ ? '<span class="onboarding-save-status" role="status" aria-live="polite"></span><button class="button" type="button" data-onboarding="draft">Save as planned</button><button class="button primary" type="button" data-onboarding="next">Confirm service scope</button>'
1738
2509
  : '<button class="button primary" type="button" data-onboarding="next">Next</button>';
1739
2510
  onboardingDialog.innerHTML = '<div class="onboarding-progress" style="--onboarding-step-count:' + steps.length + '" aria-label="Onboarding step ' + (onboardingStep + 1) + ' of ' + steps.length + '">' + progress + '</div><div class="onboarding-scroll"><div class="onboarding-head"><p class="kicker">' + esc(step.kicker) + ' · ' + (onboardingStep + 1) + ' of ' + steps.length + '</p><h2 id="onboarding-title">' + esc(titleCase(step.title)) + '</h2></div>' + body + '<div class="dialog-error" role="alert"></div></div><div class="dialog-actions onboarding-actions"><button class="button text-button onboarding-skip" type="button" data-onboarding="skip">Skip onboarding</button>' + (onboardingStep ? '<button class="button" type="button" data-onboarding="back">Back</button>' : "") + finalActions + '</div>';
1740
2511
  onboardingDialog.querySelector('[data-onboarding="skip"]').addEventListener("click", cancelOnboarding);
@@ -1774,17 +2545,12 @@ function onboardingSetupForm() {
1774
2545
  if (onboardingDraft.classificationId && !classifications.includes(onboardingDraft.classificationId)) {
1775
2546
  classifications.push(onboardingDraft.classificationId);
1776
2547
  }
1777
- const currentSystem = onboardingDraft.systemId ? state.resources.find(({ record }) => record.id === onboardingDraft.systemId)?.record : null;
1778
- const existing = [
1779
- currentSystem ? "Updates system " + currentSystem.title + "." : "Creates a new in-scope system.",
1780
- "Records a management program goal without creating an audit engagement."
1781
- ].filter(Boolean).join(" ");
1782
2548
  const gitStatus = state.repository?.mode === "trunk"
1783
2549
  ? '<div class="onboarding-git-status ' + (state.repository.status === "synced" ? "" : "warning") + '"><span class="status-dot ' + repositoryStatusTone(state.repository.status) + '"></span><span><strong>' + esc(state.repository.label) + '</strong><small>' + esc(state.repository.status === "synced" ? "Completing onboarding will save its related workspace, system, and renderer changes in one local commit, then push it in the background." : state.repository.message) + '</small></span></div>'
1784
2550
  : state.git.available && state.git.branch
1785
2551
  ? '<div class="onboarding-git-status"><span class="status-dot good"></span><span><strong>Manual repository mode</strong><small>Setup changes will stay local until you commit and synchronize them.</small></span></div>'
1786
2552
  : '<div class="onboarding-git-status warning"><span class="status-dot warn"></span><span><strong>Git setup needed</strong><small>Manual-mode writes still work, but Git history is unavailable until the repository is configured.</small></span></div>';
1787
- return '<p class="onboarding-body">' + esc(onboardingSteps().at(-1).body) + '</p>' + gitStatus + '<form id="onboarding-setup" class="onboarding-form"><label class="wide"><span>Service name</span><input name="serviceName" required maxlength="200" value="' + esc(onboardingDraft.serviceName) + '" placeholder="Customer-facing application"></label><label class="wide"><span>Scope description</span><textarea name="scope" required maxlength="2000" placeholder="What the service does and which production boundary is in scope">' + esc(onboardingDraft.scope) + '</textarea></label><label><span>Accountable owner</span><select name="ownerId" required><option value="">Select</option>' + people.map(({ record }) => '<option value="' + esc(record.id) + '" ' + (record.id === onboardingDraft.ownerId ? "selected" : "") + '>' + esc(record.title) + '</option>').join("") + '</select></label><label><span>Business criticality</span><select name="criticality" required>' + ["low", "medium", "high", "critical"].map((value) => '<option value="' + value + '" ' + (value === onboardingDraft.criticality ? "selected" : "") + '>' + esc(properCase(value)) + '</option>').join("") + '</select></label><label><span>Highest data classification</span><select name="classificationId" required>' + classifications.map((value) => '<option value="' + esc(value) + '" ' + (value === onboardingDraft.classificationId ? "selected" : "") + '>' + esc(properCase(value)) + '</option>').join("") + '</select></label><label><span>Internet exposed</span><select name="internetExposed" required><option value="true" ' + (onboardingDraft.internetExposed === "true" ? "selected" : "") + '>Yes</option><option value="false" ' + (onboardingDraft.internetExposed === "false" ? "selected" : "") + '>No</option></select></label><label class="wide"><span>Program goal</span><select name="programGoal" required><option value="none" ' + (onboardingDraft.programGoal === "none" ? "selected" : "") + '>No Assurance Goal Yet</option><option value="readiness" ' + (onboardingDraft.programGoal === "readiness" ? "selected" : "") + '>Program Readiness</option><option value="type-1" ' + (onboardingDraft.programGoal === "type-1" ? "selected" : "") + '>SOC 2 Type 1</option><option value="type-2" ' + (onboardingDraft.programGoal === "type-2" ? "selected" : "") + '>SOC 2 Type 2</option></select><small>This records management intent only. It does not create an engagement or establish the formal report period.</small></label></form><p class="onboarding-write-note">' + esc(existing) + ' Save draft marks the service Planned and selects it in Workspace program scope. It is ready for scope review, but it is not approved or active. ' + (state.repository?.mode === "trunk" ? "The browser saves and synchronizes the related files together." : "Manual mode leaves the files for you to commit.") + ' Complete the remaining Step 1 pages next.</p>';
2553
+ return '<p class="onboarding-body">' + esc(onboardingSteps().at(-1).body) + '</p>' + gitStatus + '<form id="onboarding-setup" class="onboarding-form"><label class="wide"><span>Service name</span><input name="serviceName" required maxlength="200" value="' + esc(onboardingDraft.serviceName) + '" placeholder="Customer-facing application"></label><label class="wide"><span>Scope description</span><textarea name="scope" required maxlength="2000" placeholder="What the service does and which production boundary is in scope">' + esc(onboardingDraft.scope) + '</textarea></label><label><span>Accountable owner</span><select name="ownerId" required><option value="">Select</option>' + people.map(({ record }) => '<option value="' + esc(record.id) + '" ' + (record.id === onboardingDraft.ownerId ? "selected" : "") + '>' + esc(record.title) + '</option>').join("") + '</select></label><label><span>Business criticality</span><select name="criticality" required>' + ["low", "medium", "high", "critical"].map((value) => '<option value="' + value + '" ' + (value === onboardingDraft.criticality ? "selected" : "") + '>' + esc(properCase(value)) + '</option>').join("") + '</select></label><label><span>Highest data classification</span><select name="classificationId" required>' + classifications.map((value) => '<option value="' + esc(value) + '" ' + (value === onboardingDraft.classificationId ? "selected" : "") + '>' + esc(properCase(value)) + '</option>').join("") + '</select></label><label><span>Internet exposed</span><select name="internetExposed" required><option value="true" ' + (onboardingDraft.internetExposed === "true" ? "selected" : "") + '>Yes</option><option value="false" ' + (onboardingDraft.internetExposed === "false" ? "selected" : "") + '>No</option></select></label><label class="wide"><span>Program goal</span><select name="programGoal" required><option value="none" ' + (onboardingDraft.programGoal === "none" ? "selected" : "") + '>No Assurance Goal Yet</option><option value="readiness" ' + (onboardingDraft.programGoal === "readiness" ? "selected" : "") + '>Program Readiness</option><option value="type-1" ' + (onboardingDraft.programGoal === "type-1" ? "selected" : "") + '>SOC 2 Type 1</option><option value="type-2" ' + (onboardingDraft.programGoal === "type-2" ? "selected" : "") + '>SOC 2 Type 2</option></select><small>This records management intent only. It does not create an engagement or establish the formal report period.</small></label></form><p class="onboarding-write-note">Save as planned keeps the System planned. Confirm service scope makes it active. Both add it to the Workspace scope.</p>';
1788
2554
  }
1789
2555
 
1790
2556
  function captureOnboardingForm() {
@@ -1904,22 +2670,6 @@ async function writeRendererSettingsResource(record, entry) {
1904
2670
  return response.json();
1905
2671
  }
1906
2672
 
1907
- async function toggleStagePageCompletion(button) {
1908
- const entry = rendererSettingsEntry();
1909
- if (!entry) throw new Error("Renderer settings are unavailable.");
1910
- const completed = new Set(entry.record.completedStagePageIds || []);
1911
- const pageId = button.dataset.stagePageCompletion;
1912
- if (button.dataset.complete === "true") {
1913
- completed.delete(pageId);
1914
- } else {
1915
- completed.add(pageId);
1916
- }
1917
- applyMutationState(await writeRendererSettingsResource({
1918
- ...entry.record,
1919
- completedStagePageIds: [...completed].sort()
1920
- }, entry));
1921
- }
1922
-
1923
2673
  function setOnboardingBusy(busy, label = "") {
1924
2674
  if (!onboardingDialog) return;
1925
2675
  clearTimeout(onboardingStillWorkingTimer);
@@ -2081,7 +2831,7 @@ function openEditor(type, entry = null, options = {}) {
2081
2831
  const editorDescription = options.description
2082
2832
  || implementationEditorDescription(type)
2083
2833
  || "Fill the core fields below. Git will record the author, time, reason, and diff when you commit this file.";
2084
- dialog.innerHTML = '<form><div class="dialog-head"><div><p class="kicker">' + (entry ? "Edit record" : options.obligationCompletion ? "Record obligation work" : "Create record") + '</p><h2 id="resource-editor-title">' + esc(titleCase(entry?.record.title || record.title || definition.title)) + '</h2></div><button type="button" class="icon-button" data-editor-dismiss aria-label="Close">×</button></div><p>' + esc(editorDescription) + '</p><div class="form-grid">' + names.map((name) => editorField(type, name, fields[name], record[name], required.has(name) || conditionMatches(record, fields[name].requiredWhen), Boolean(entry), oneOf.has(name), activeOneOf.has(name))).join("") + '</div>' +
2834
+ dialog.innerHTML = '<form><div class="dialog-head"><div><p class="kicker">' + (entry ? "Edit record" : options.actionCompletion ? "Complete assigned work" : options.obligationCompletion ? "Record obligation work" : "Create record") + '</p><h2 id="resource-editor-title">' + esc(titleCase(entry?.record.title || record.title || definition.title)) + '</h2></div><button type="button" class="icon-button" data-editor-dismiss aria-label="Close">×</button></div><p>' + esc(editorDescription) + '</p>' + resourceReviewCriteria(type) + '<div class="form-grid">' + names.map((name) => editorField(type, name, fields[name], record[name], required.has(name) || conditionMatches(record, fields[name].requiredWhen), Boolean(entry), oneOf.has(name), activeOneOf.has(name))).join("") + '</div>' +
2085
2835
  activeMarkdown.map((markdown) => {
2086
2836
  const generated = !entry?.content?.[markdown.name];
2087
2837
  const source = entry?.content?.[markdown.name]?.source
@@ -2151,7 +2901,9 @@ function openEditor(type, entry = null, options = {}) {
2151
2901
  }
2152
2902
  const url = entry
2153
2903
  ? "/api/resource/" + encodeURIComponent(type) + "/" + encodeURIComponent(entry.record.id)
2154
- : options.obligationCompletion ? "/api/obligation-completions" : "/api/resources";
2904
+ : options.actionCompletion
2905
+ ? "/api/action-completions"
2906
+ : options.obligationCompletion ? "/api/obligation-completions" : "/api/resources";
2155
2907
  const contentRevisions = Object.fromEntries([
2156
2908
  ...activeMarkdown.map(({ name }) => [entry?.content?.[name]?.path, entry?.content?.[name]?.revision]),
2157
2909
  [recordContentItem?.path, recordContentItem?.revision]
@@ -2163,9 +2915,11 @@ function openEditor(type, entry = null, options = {}) {
2163
2915
  body: JSON.stringify({
2164
2916
  record: updated,
2165
2917
  content,
2166
- revision: entry?.revision || options.obligationCompletion?.revision,
2918
+ revision: entry?.revision || options.actionCompletion?.revision || options.obligationCompletion?.revision,
2167
2919
  contentRevisions,
2168
- obligationId: options.obligationCompletion?.obligationId
2920
+ obligationId: options.obligationCompletion?.obligationId,
2921
+ actionItemId: options.actionCompletion?.actionItemId,
2922
+ completedOn: options.actionCompletion?.completedOn
2169
2923
  })
2170
2924
  });
2171
2925
  if (!response.ok) throw new Error(await responseMessage(response));
@@ -2506,21 +3260,6 @@ function openContentEditor(entry, name) {
2506
3260
  }
2507
3261
 
2508
3262
  function bindCommon() {
2509
- root.querySelectorAll("[data-stage-page-completion]").forEach((button) => button.addEventListener("click", async (event) => {
2510
- event.preventDefault();
2511
- event.stopPropagation();
2512
- const label = button.textContent;
2513
- button.disabled = true;
2514
- button.textContent = "Saving…";
2515
- try {
2516
- await toggleStagePageCompletion(button);
2517
- render();
2518
- } catch (error) {
2519
- button.disabled = false;
2520
- button.textContent = label;
2521
- button.title = error.message;
2522
- }
2523
- }));
2524
3263
  root.querySelectorAll(".nav-toggle, .nav-subgroup-toggle").forEach((button) => button.addEventListener("click", () => {
2525
3264
  const group = button.closest(".nav-group");
2526
3265
  const open = group.classList.toggle("open");
@@ -2656,6 +3395,11 @@ function currentDate() {
2656
3395
  return new Date().toISOString().slice(0, 10);
2657
3396
  }
2658
3397
  }
3398
+ function dateAfter(value) {
3399
+ const date = new Date(value + "T00:00:00Z");
3400
+ date.setUTCDate(date.getUTCDate() + 1);
3401
+ return date.toISOString().slice(0, 10);
3402
+ }
2659
3403
  function currentLocalDateTime() {
2660
3404
  const now = new Date();
2661
3405
  const local = new Date(now.getTime() - now.getTimezoneOffset() * 60000);
@@ -3026,7 +3770,9 @@ html,body{height:100%;overflow:hidden}.shell{grid-template-columns:248px minmax(
3026
3770
  .nav-stage>.nav-items>a.nav-direct{display:grid;grid-template-columns:minmax(0,1fr) var(--nav-control-width);gap:6px;align-items:center;width:100%;padding:6px 6px 6px 7px;font-size:13.2px}
3027
3771
  .nav-heading-row{display:grid;grid-template-columns:minmax(0,1fr) 24px;gap:2px;align-items:stretch}.nav-heading-row>.nav-heading{display:grid;grid-template-columns:24px minmax(0,1fr);gap:6px;align-items:center;width:100%;padding:7px 6px;border-radius:7px;color:#d5d9ed;text-align:left;text-transform:none;letter-spacing:0;text-decoration:none}.nav-heading-row>.nav-heading:hover,.nav-heading-row>.nav-heading.current{background:rgba(255,255,255,.1);color:#fff}.nav-toggle{display:grid;place-items:center;width:24px;height:auto;min-height:100%;padding:0;border:0;border-radius:6px;background:none;color:#aeb6d8;cursor:pointer}.nav-toggle:hover{background:rgba(255,255,255,.1);color:#fff}.nav-chevron{display:block;width:12px;height:12px;place-self:center;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;transition:transform .15s}.nav-subheading-row{display:grid;grid-template-columns:minmax(0,1fr) 22px;gap:2px;align-items:center;width:100%;padding:0;border:0;border-radius:6px;background:none;color:#919bc4;cursor:pointer}.nav-subheading-row:hover{background:rgba(255,255,255,.1);color:#fff}.nav-subheading-row>.nav-subheading{display:flex;align-items:center;min-width:0;padding:7px;color:inherit;text-align:left;text-transform:uppercase;letter-spacing:.09em;font-size:9.6px;font-weight:780}.nav-group.open>.nav-heading-row .nav-chevron,.nav-group.open>.nav-subheading-row .nav-chevron{transform:rotate(90deg)}
3028
3772
  .stage-overview-hero{display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:28px;align-items:center;padding:26px 28px;background:var(--panel);border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow)}.stage-overview-hero h2,.group-overview-head h2{font:500 37.2px Georgia,serif;margin:7px 0}.stage-overview-hero>div>p:not(.kicker),.group-overview-head>div>p:not(.kicker){max-width:760px;color:var(--muted);font-size:14.4px;line-height:1.55;margin:0}.stage-progress-card{padding:15px 17px;background:var(--paper);border:1px solid var(--line);border-radius:9px}.stage-progress-card>div:first-child{display:flex;align-items:center;justify-content:space-between;margin-bottom:11px}.stage-progress-card>div:first-child>strong{font:500 33.6px Georgia,serif}.stage-progress-card p{color:var(--muted);font-size:10.8px;line-height:1.45;margin:9px 0 0}.badge.neutral{background:#e5e8f2;color:#555e73}.stage-overview-layout{display:grid;grid-template-columns:320px minmax(0,1fr);gap:15px;margin-top:15px;align-items:start}.stage-plan ol,.group-plan ol{display:grid;gap:12px;padding-left:20px;margin:0}.stage-plan li,.group-plan li{padding-left:4px;color:var(--ink);font-size:13.2px;line-height:1.5}.stage-groups{min-width:0}.stage-groups>.section-head{margin:4px 0 13px}.stage-group-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.stage-group-card{position:relative;display:block;min-height:138px;padding:18px 38px 17px 18px;background:var(--panel);border:1px solid var(--line);border-radius:10px;text-decoration:none;box-shadow:0 2px 8px rgba(21,40,33,.025)}.stage-group-card:hover{border-color:var(--accent-light)}.stage-group-card h3{font-size:15.6px;margin:0 0 7px}.stage-group-card p{color:var(--muted);font-size:12px;line-height:1.5;margin:0}.stage-group-card small{display:block;color:var(--accent);font-size:9.6px;font-weight:700;margin-top:12px}.stage-group-arrow{position:absolute;right:16px;top:16px;color:var(--accent);font-size:24px}.group-overview-head{display:flex;justify-content:space-between;align-items:end;gap:25px;margin-bottom:15px}.stage-status-link{display:grid;grid-template-columns:auto auto;align-items:center;gap:4px 12px;min-width:155px;padding:12px 14px;background:var(--panel);border:1px solid var(--line);border-radius:9px;text-decoration:none}.stage-status-link>strong{font:500 28.8px Georgia,serif;text-align:right}.stage-status-link>small{grid-column:1/-1;color:var(--muted);font-size:9.6px;text-align:right}.relationship-note{display:grid;grid-template-columns:250px minmax(0,1fr);gap:20px;align-items:center;margin-bottom:15px;padding:17px 20px;background:var(--accent-soft);border:1px solid #cbd3ff;border-radius:10px}.relationship-note h3{font-size:15.6px;margin:5px 0 0}.relationship-note>p{color:var(--muted);font-size:12px;line-height:1.55;margin:0}.relationship-note code{font-size:10.8px}.group-plan{margin-bottom:24px}.group-related-links{display:flex;align-items:center;gap:8px;margin-top:18px;padding-top:14px;border-top:1px solid var(--line)}.group-related-links>span{color:var(--muted);font-size:10.8px;margin-right:auto}.group-destinations>.section-head{margin-bottom:12px}.group-destination-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:11px}.group-destination-card{display:grid;grid-template-columns:minmax(0,1fr) 100px;gap:16px;min-height:150px;padding:18px;background:var(--panel);border:1px solid var(--line);border-radius:10px;text-decoration:none;box-shadow:0 2px 8px rgba(21,40,33,.025)}.group-destination-card:hover{border-color:var(--accent-light)}.group-destination-card h3{font-size:15.6px;margin:5px 0 7px}.group-destination-card p:not(.kicker){color:var(--muted);font-size:10.8px;line-height:1.5;margin:0}.destination-rollup{align-self:center;text-align:right}.destination-rollup strong,.destination-rollup small{display:block}.destination-rollup strong{font:500 32.4px Georgia,serif}.destination-rollup small{color:var(--muted);font-size:9.6px;line-height:1.35;margin-top:3px}
3029
- .context-workflow{display:flex;align-items:center;justify-content:space-between;gap:24px;margin:-8px 0 18px;padding:17px 19px;background:var(--accent-soft);border:1px solid #cbd3ff;border-radius:10px}.context-workflow h3{font-size:16px;margin:4px 0 5px}.context-workflow p:not(.kicker){color:var(--muted);font-size:12px;line-height:1.5;margin:0;max-width:850px}.context-workflow .button{white-space:nowrap}.evidence-map{display:grid;gap:12px;margin-top:18px}.evidence-map-head{display:flex;align-items:center;justify-content:space-between;gap:24px;padding:20px 22px;background:var(--accent-soft);border:1px solid #cbd3ff;border-radius:11px}.evidence-map-head>div:first-child{max-width:760px}.evidence-map-head h2{font:500 24px Georgia,serif;margin:5px 0 7px}.evidence-map-head p:not(.kicker){color:var(--muted);font-size:12px;line-height:1.55;margin:0}.evidence-map-actions{display:flex;gap:8px}.evidence-map-card{padding:18px 20px;background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 2px 8px rgba(21,40,33,.025)}.evidence-map-card.complete{border-color:#b9dac6}.evidence-map-card-head{display:flex;align-items:start;justify-content:space-between;gap:20px}.evidence-map-card-head h3{font-size:16px;margin:7px 0 0}.evidence-map-card-head>small{color:var(--muted);font-size:10px;text-align:right}.evidence-map-card>p{color:var(--muted);font-size:12px;line-height:1.55;margin:12px 0}.evidence-map-expectation{display:grid;grid-template-columns:120px minmax(0,1fr);gap:12px;padding:8px 0;border-top:1px solid var(--line);font-size:11px;line-height:1.5}.evidence-map-expectation strong{color:var(--muted);font-size:9.6px;text-transform:uppercase;letter-spacing:.06em}.evidence-map-expectation code{background:var(--paper);border-radius:4px;padding:2px 5px}.evidence-map-links{display:grid;grid-template-columns:minmax(220px,1fr) minmax(280px,1.2fr);gap:20px;margin-top:13px;padding-top:13px;border-top:1px solid var(--line)}.evidence-map-links>div>small{display:block;color:var(--muted);font-size:9.6px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;margin-bottom:7px}.evidence-map-references,.evidence-map-sources{display:flex;flex-wrap:wrap;gap:5px}.evidence-map-source{display:flex;align-items:center;gap:7px;padding:7px 9px;background:var(--paper);border:1px solid var(--line);border-radius:7px;font-size:11px;text-decoration:none}.evidence-map-source.complete{border-color:#b9dac6;background:#edf7f1}.evidence-map-source small{color:var(--muted);font-size:9px}.evidence-map-status{padding:9px 11px;background:var(--paper);border-radius:7px}.evidence-map-empty{padding:24px;background:var(--panel);border:1px solid var(--line);border-radius:10px}.evidence-map-empty h3{margin:6px 0}.evidence-map-empty p:not(.kicker){color:var(--muted);font-size:12px;margin:0 0 14px}.stage-pages{margin-top:24px}.stage-page-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.stage-page-card{position:relative;display:flex;flex-direction:column;min-width:0;padding:18px;background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 2px 8px rgba(21,40,33,.025);transition:border-color .15s,box-shadow .15s}.stage-page-card:hover{border-color:var(--accent-light);box-shadow:0 5px 16px rgba(21,40,33,.07)}.stage-page-card.complete{border-color:#b9dac6}.stage-page-card-link{position:absolute;inset:0;z-index:1;border-radius:10px}.stage-page-card-link:focus-visible{outline:2px solid var(--focus);outline-offset:2px}.stage-page-card-head{display:flex;align-items:center;justify-content:space-between;gap:18px}.stage-page-card-head h3{font-size:15.6px;line-height:1.35;margin:4px 0 0}.stage-page-card-head>div>small{display:block;color:var(--accent);font-size:9.6px;font-weight:700}.stage-page-card>p{color:var(--muted);font-size:12px;line-height:1.5;margin:13px 0 0}.stage-page-rollup{display:flex;flex:0 0 104px;flex-direction:column;justify-content:center;text-align:right}.stage-page-rollup strong,.stage-page-rollup small{display:block}.stage-page-rollup strong{font:500 24px Georgia,serif}.stage-page-rollup small{color:var(--muted);font-size:9.6px;line-height:1.35;margin-top:2px}.stage-page-card-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:auto;padding-top:15px}.stage-page-completion{position:relative;z-index:2;color:var(--accent)}.stage-page-completion.complete{color:#176143;border-color:#b9dac6;background:#edf7f1}.stage-page-completion-state{color:var(--muted);font-size:10.8px}.stage-page-completion-state.complete{color:#176143;font-weight:700}.stage-page-open{color:var(--accent);font-size:12px;font-weight:700}.work-queue-section{margin-top:28px}.work-queue-section>.section-head{align-items:end}
3773
+ .collection-review-panel{margin:16px 0 22px}.collection-review-panel.required{border-color:#d8bd78}.collection-review-panel.current{border-color:#b9dac6}.collection-review-head{display:flex;align-items:flex-start;justify-content:space-between;gap:24px}.collection-review-head h3{margin:4px 0 6px}.collection-review-head p:not(.kicker){max-width:900px;margin:0;color:var(--muted);font-size:11px;line-height:1.5}.collection-review-panel details{margin-top:13px;padding:10px 12px;border:1px solid var(--line);border-radius:7px;background:var(--surface-soft)}.collection-review-panel summary{cursor:pointer;font-size:11px;font-weight:750}.collection-review-panel ul,.collection-review-checks ul{margin:9px 0 0;padding-left:20px;color:var(--muted);font-size:10.4px;line-height:1.55}.collection-review-foot{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-top:13px}.collection-review-result{display:flex;align-items:baseline;gap:8px;margin:0}.collection-review-result strong{font-size:11px}.collection-review-result span{color:var(--muted);font-size:10.4px}.collection-review-checks{margin:13px 0;padding:11px 13px;border:1px solid var(--line);border-radius:7px;background:var(--surface-soft)}.collection-review-checks>strong{font-size:11px}.event-dialog-steps.collection-review-checks{margin:15px 0 0;padding:10px;border:0}.collection-review-dialog textarea{box-sizing:border-box;width:100%;resize:vertical}.resource-review-criteria{margin:16px 0 22px;padding:13px 15px;border:1px solid var(--line);border-radius:8px;background:var(--panel)}.resource-review-criteria>strong{font-size:11px}.resource-review-criteria ul{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px 28px;margin:9px 0 0;padding-left:20px;color:var(--muted);font-size:10.4px;line-height:1.5}.commit-dialog .resource-review-criteria{margin:12px 0;background:var(--surface-soft)}.record-workflow-action{display:grid;grid-template-columns:auto minmax(140px,1fr);gap:7px;align-items:start;min-width:240px;text-decoration:none}.record-workflow-action strong,.record-workflow-action small{display:block}.record-workflow-action strong{font-size:10.4px}.record-workflow-action small{margin-top:2px;color:var(--muted);font-size:9.2px;line-height:1.35}.record-workflow-clear{color:var(--muted);font-size:10px;white-space:nowrap}.workflow-guidance{margin:16px 0 22px}.workflow-guidance .panel-head{align-items:flex-start;margin-bottom:12px}.workflow-guidance .panel-head h3{margin:4px 0}.workflow-guidance .panel-head p:not(.kicker){margin:4px 0 0;color:var(--muted);font-size:11px}.workflow-findings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.workflow-findings>a,.workflow-findings>div{display:grid;grid-template-columns:auto minmax(0,1fr);gap:9px;align-items:start;padding:10px 11px;border:1px solid var(--line);border-radius:7px;background:var(--surface-soft);text-decoration:none}.workflow-findings strong,.workflow-findings small{display:block}.workflow-findings strong{font-size:11px}.workflow-findings small{margin-top:3px;color:var(--muted);font-size:9.6px;line-height:1.4}.workflow-finding-status{min-width:62px;padding:3px 5px;border-radius:99px;background:var(--accent-soft);color:var(--accent);font-size:8.4px;font-weight:750;text-align:center;text-transform:uppercase;letter-spacing:.04em}.workflow-finding-status.overdue,.workflow-finding-status.blocked{background:#f5ded9;color:#8d352c}.workflow-finding-status.ready,.workflow-finding-status.due,.workflow-finding-status.open{background:#f7e9cf;color:#855717}.workflow-finding-status.complete{background:#ddefe5;color:#176143}.workflow-guidance-more{margin:10px 0 0;color:var(--muted);font-size:9.6px}.context-workflow{display:flex;align-items:center;justify-content:space-between;gap:24px;margin:-8px 0 18px;padding:17px 19px;background:var(--accent-soft);border:1px solid #cbd3ff;border-radius:10px}.context-workflow h3{font-size:16px;margin:4px 0 5px}.context-workflow p:not(.kicker){color:var(--muted);font-size:12px;line-height:1.5;margin:0;max-width:850px}.context-workflow .button{white-space:nowrap}.evidence-map{display:grid;gap:12px;margin-top:18px}.evidence-map-head{display:flex;align-items:center;justify-content:space-between;gap:24px;padding:20px 22px;background:var(--accent-soft);border:1px solid #cbd3ff;border-radius:11px}.evidence-map-head>div:first-child{max-width:760px}.evidence-map-head h2{font:500 24px Georgia,serif;margin:5px 0 7px}.evidence-map-head p:not(.kicker){color:var(--muted);font-size:12px;line-height:1.55;margin:0}.evidence-map-actions{display:flex;gap:8px}.evidence-map-card{padding:18px 20px;background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 2px 8px rgba(21,40,33,.025)}.evidence-map-card.complete{border-color:#b9dac6}.evidence-map-card-head{display:flex;align-items:start;justify-content:space-between;gap:20px}.evidence-map-card-head h3{font-size:16px;margin:7px 0 0}.evidence-map-card-head>small{color:var(--muted);font-size:10px;text-align:right}.evidence-map-card>p{color:var(--muted);font-size:12px;line-height:1.55;margin:12px 0}.evidence-map-expectation{display:grid;grid-template-columns:120px minmax(0,1fr);gap:12px;padding:8px 0;border-top:1px solid var(--line);font-size:11px;line-height:1.5}.evidence-map-expectation strong{color:var(--muted);font-size:9.6px;text-transform:uppercase;letter-spacing:.06em}.evidence-map-expectation code{background:var(--paper);border-radius:4px;padding:2px 5px}.evidence-map-links{display:grid;grid-template-columns:minmax(220px,1fr) minmax(280px,1.2fr);gap:20px;margin-top:13px;padding-top:13px;border-top:1px solid var(--line)}.evidence-map-links>div>small{display:block;color:var(--muted);font-size:9.6px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;margin-bottom:7px}.evidence-map-references,.evidence-map-sources{display:flex;flex-wrap:wrap;gap:5px}.evidence-map-source{display:flex;align-items:center;gap:7px;padding:7px 9px;background:var(--paper);border:1px solid var(--line);border-radius:7px;font-size:11px;text-decoration:none}.evidence-map-source.complete{border-color:#b9dac6;background:#edf7f1}.evidence-map-source small{color:var(--muted);font-size:9px}.evidence-map-status{padding:9px 11px;background:var(--paper);border-radius:7px}.evidence-map-empty{padding:24px;background:var(--panel);border:1px solid var(--line);border-radius:10px}.evidence-map-empty h3{margin:6px 0}.evidence-map-empty p:not(.kicker){color:var(--muted);font-size:12px;margin:0 0 14px}.stage-pages{margin-top:24px}.stage-page-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.stage-page-card{position:relative;display:flex;flex-direction:column;min-width:0;padding:18px;background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 2px 8px rgba(21,40,33,.025);transition:border-color .15s,box-shadow .15s}.stage-page-card:hover{border-color:var(--accent-light);box-shadow:0 5px 16px rgba(21,40,33,.07)}.stage-page-card.complete{border-color:#b9dac6}.stage-page-card-link{position:absolute;inset:0;z-index:1;border-radius:10px}.stage-page-card-link:focus-visible{outline:2px solid var(--focus);outline-offset:2px}.stage-page-card-head{display:flex;align-items:center;justify-content:space-between;gap:18px}.stage-page-card-head h3{font-size:15.6px;line-height:1.35;margin:4px 0 0}.stage-page-card-head>div>small{display:block;color:var(--accent);font-size:9.6px;font-weight:700}.stage-page-card>p{color:var(--muted);font-size:12px;line-height:1.5;margin:13px 0 0}.stage-page-tasks{position:relative;z-index:2;display:grid;gap:6px;margin-top:13px}.stage-page-tasks>a{display:grid;grid-template-columns:auto minmax(0,1fr);gap:8px;align-items:start;padding:9px;border:1px solid var(--line);border-radius:7px;background:var(--surface-soft);text-decoration:none}.stage-page-tasks>a:hover{border-color:var(--accent-light)}.stage-page-tasks strong,.stage-page-tasks small{display:block}.stage-page-tasks strong{font-size:10.8px}.stage-page-tasks small{margin-top:2px;color:var(--muted);font-size:9.4px;line-height:1.35}.stage-page-tasks-more{color:var(--muted);font-size:9.4px}.stage-page-rollup{display:flex;flex:0 0 104px;flex-direction:column;justify-content:center;text-align:right}.stage-page-rollup strong,.stage-page-rollup small{display:block}.stage-page-rollup strong{font:500 24px Georgia,serif}.stage-page-rollup small{color:var(--muted);font-size:9.6px;line-height:1.35;margin-top:2px}.stage-page-card-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:auto;padding-top:15px}.stage-page-completion-state{color:var(--muted);font-size:10.8px}.stage-page-completion-state.complete{color:#176143;font-weight:700}.stage-page-open{color:var(--accent);font-size:12px;font-weight:700}.work-queue-section{margin-top:28px}.work-queue-section>.section-head{align-items:end}
3774
+ .workflow-findings>a:hover{border-color:var(--accent-light);box-shadow:0 3px 9px rgba(21,40,33,.05)}.workflow-findings>a:focus-visible{outline:2px solid var(--focus);outline-offset:2px}.stage-page-card-head{align-items:flex-start}.stage-page-completion-state{flex:0 0 auto;max-width:150px;padding:5px 8px;border-radius:99px;background:#f7e9cf;color:#855717;font-size:9.6px;font-weight:750;line-height:1.25;text-align:right}.stage-page-completion-state.complete{background:#ddefe5;color:#176143}.obligation-card.workflow-target{outline:2px solid var(--focus);outline-offset:3px}.obligation-card-foot{flex-wrap:wrap}.obligation-card-foot .obligation-links{flex:1 1 120px}
3775
+ .evidence-attachments .panel-head{align-items:flex-start}.evidence-attachments .panel-head h3{margin:0}.evidence-attachments .panel-head p{margin:4px 0 0;color:var(--muted);font-size:10px}.evidence-attachments ul{list-style:none;margin:0;padding:0}.evidence-attachments li{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 0;border-top:1px solid var(--line)}.evidence-attachments li:first-child{border-top:0}.evidence-attachments strong,.evidence-attachments small{display:block}.evidence-attachments strong{font-size:11px}.evidence-attachments small{margin-top:2px;color:var(--muted);font-size:9px;overflow-wrap:anywhere}.evidence-attachments .attachment-empty{display:block;color:var(--muted);font-size:10px;line-height:1.45}.danger-text{color:var(--red)}
3030
3776
  .button{text-decoration:none}
3031
3777
  .external-evidence-section{margin-top:28px}.external-evidence-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.external-evidence-list>.empty{grid-column:1/-1}.external-evidence-list>a{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:13px 15px;background:var(--panel);border:1px solid var(--line);border-radius:8px;text-decoration:none}.external-evidence-list>a:hover{border-color:var(--accent-light)}.external-evidence-list>a>span:first-child{min-width:0}.external-evidence-list strong,.external-evidence-list small{display:block}.external-evidence-list strong{font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.external-evidence-list small{color:var(--muted);font-size:9.6px;margin-top:4px}
3032
3778
  .home-page{padding-top:16px;padding-bottom:16px}.overview-hero{min-height:72px;padding:10px 20px;align-items:center}.overview-hero h2{font-size:26.4px;margin:3px 0 2px}.overview-hero p:not(.kicker){font-size:12px}.home-page .readiness-map{padding:12px 15px}.home-page .readiness-map-head{margin-bottom:8px}.home-page .readiness-flow a{padding:7px}
@@ -3038,7 +3784,7 @@ html,body{height:100%;overflow:hidden}.shell{grid-template-columns:248px minmax(
3038
3784
  .record-content-action{display:flex;justify-content:flex-start;margin-top:20px}.record-content-details{border-top:1px solid var(--line);margin-top:18px;padding-top:13px}.record-content-details summary{cursor:pointer;color:var(--accent);font-size:13.2px;font-weight:750}.record-content-details>p{color:var(--muted);font-size:12px}.record-content-editor>span small{color:var(--muted);font-size:10.8px;font-weight:500}
3039
3785
  .program-setup{grid-template-columns:minmax(250px,.75fr) minmax(440px,1.4fr)}.setup-steps{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.setup-steps a{display:grid;grid-template-columns:24px minmax(0,1fr);gap:9px;align-items:start;padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--panel);color:var(--ink);text-decoration:none}.setup-steps a:hover{border-color:var(--accent-light)}.setup-steps a>span:first-child{display:grid;place-items:center;width:24px;height:24px;border-radius:50%;background:var(--accent-soft);color:var(--accent);font-size:12px}.setup-steps a.done>span:first-child{background:#dcefe4;color:#125733}.setup-steps strong,.setup-steps small{display:block}.setup-steps strong{font-size:12px}.setup-steps small{margin-top:3px;color:var(--muted);font-size:9.6px;line-height:1.4;font-weight:500}
3040
3786
  .readiness-map{margin:14px 0;background:var(--panel);border:1px solid var(--line);border-radius:11px;padding:20px 22px;box-shadow:0 2px 8px rgba(21,40,33,.025)}.readiness-map-head{display:grid;grid-template-columns:minmax(220px,1fr) minmax(320px,420px);gap:28px;align-items:center;margin-bottom:17px}.readiness-map-head h3{font-size:18px;margin:5px 0 0}.readiness-progress-summary{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px 14px;align-items:center}.readiness-progress-summary>div{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:3px 12px;align-items:baseline}.readiness-progress-summary>div>span{color:var(--muted);font-size:9.6px;font-weight:700;text-transform:uppercase;letter-spacing:.08em}.readiness-progress-summary>div>strong{font-size:9.6px;font-weight:700;line-height:1.2}.readiness-progress-summary .progress,.readiness-progress-summary small{grid-column:1/-1}.readiness-progress-summary small{color:var(--muted);font-size:9.6px}.readiness-progress-summary>.button{white-space:nowrap}.readiness-flow{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}.readiness-flow a{display:grid;grid-template-columns:23px minmax(0,1fr);column-gap:8px;align-content:start;min-width:0;padding:11px;border:1px solid var(--line);border-radius:8px;background:var(--surface-soft);text-decoration:none}.readiness-flow a:hover{border-color:var(--accent-light);background:var(--accent-soft)}.readiness-flow a>span{grid-row:1/4;display:grid;place-items:center;width:23px;height:23px;border-radius:50%;background:var(--primary-gradient);color:#fff;font-size:9.6px;font-weight:800}.readiness-flow strong{font-size:12px;line-height:1.25}.readiness-flow small{grid-column:2;color:var(--muted);font-size:9.6px;line-height:1.4;margin-top:3px}.readiness-state{grid-column:2;justify-self:start;margin-top:8px;padding:3px 6px;border-radius:99px;background:var(--surface-muted);color:var(--muted);font-size:8.4px;line-height:1.2}.readiness-state.good{background:#dcefe4;color:#125733}.readiness-state.warn{background:#f6e8c9;color:#79500f}.readiness-state.bad{background:#f7dfdc;color:#873027}.audit-engagement{display:grid;grid-template-columns:minmax(210px,1fr) minmax(260px,1.25fr) auto;gap:20px;align-items:center;padding:14px 15px;border-radius:8px;background:var(--surface-soft)}.audit-engagement strong{font-size:13.2px}.audit-engagement p,.audit-engagement li{color:var(--muted);font-size:10.8px;line-height:1.5}.audit-engagement p{margin:5px 0 0}.audit-engagement ul{margin:0;padding-left:18px}.audit-engagement .button{white-space:nowrap;text-decoration:none}.resource-directory{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.resource-directory>section{min-width:0;padding:12px;border-radius:8px;background:var(--surface-soft)}.resource-directory h4{margin:0 0 7px;color:var(--muted);font-size:10.8px;text-transform:uppercase;letter-spacing:.08em}.resource-directory a{display:flex;justify-content:space-between;gap:10px;padding:5px 0;border-top:1px solid var(--line);font-size:10.8px;text-decoration:none}.resource-directory a:first-of-type{border-top:0}.resource-directory a:hover span{color:var(--accent)}.resource-directory a strong{color:var(--muted);font-size:9.6px}.record-prose{max-width:790px}.record-prose section{padding:0 0 20px}.record-prose section+section{padding-top:20px;border-top:1px solid var(--line)}.record-prose h3{margin:0 0 7px;color:var(--muted);font-size:10.8px;text-transform:uppercase;letter-spacing:.08em}.record-prose p{margin:0;font-size:16.8px;line-height:1.65;white-space:pre-wrap}.connections-panel .panel-head>span{display:grid;place-items:center;min-width:22px;height:22px;border-radius:99px;background:var(--surface-muted);color:var(--muted);font-size:9.6px}.connections{display:grid}.connections a{display:block;padding:9px 0;border-top:1px solid var(--line);text-decoration:none}.connections a:first-child{padding-top:0;border-top:0}.connections strong,.connections small{display:block}.connections strong{font-size:12px}.connections small{margin-top:3px;color:var(--muted);font-size:9.6px;line-height:1.4}.connections a:hover strong{color:var(--accent)}.connections-more{margin:9px 0 0;color:var(--muted);font-size:9.6px;line-height:1.4}.external-source{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;color:var(--accent);text-decoration:none}.external-source span,.external-source strong,.external-source small{display:block}.external-source strong{font-size:12px;line-height:1.35}.external-source small{margin-top:3px;color:var(--muted);font-size:9.6px;line-height:1.35;overflow-wrap:anywhere}.external-source b{font-size:13.2px}.external-source:hover strong{text-decoration:underline}
3041
- .page-title-line{display:flex;align-items:center;gap:8px}.guide-trigger{display:grid;place-items:center;width:24px;height:24px;flex:0 0 auto;padding:0;border:1px solid var(--line);border-radius:50%;background:var(--panel);color:var(--muted);cursor:pointer}.guide-trigger svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round}.guide-trigger:hover{border-color:var(--accent-light);color:var(--accent)}.guide-trigger:focus-visible{outline:2px solid var(--focus);outline-offset:2px}.page-guide{display:grid;grid-template-columns:1.05fr 1.25fr 1fr;gap:0;margin:0;background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 2px 8px rgba(21,40,33,.025)}.resource-guide-popover{position:fixed;z-index:40;overflow:auto;box-shadow:0 18px 50px rgba(0,0,24,.24)}.resource-guide-popover[hidden]{display:none}.page-guide>div{padding:14px 16px;border-left:1px solid var(--line);min-width:0}.page-guide>div:first-child{border-left:0}.page-guide>div>span{display:block;color:var(--accent);text-transform:uppercase;letter-spacing:.09em;font-size:9.6px;font-weight:780;margin-bottom:6px}.page-guide p{color:var(--muted);font-size:12px;line-height:1.5;margin:0}.guide-links{display:flex;flex-wrap:wrap;gap:5px;margin-top:8px}.guide-links a{color:var(--accent);background:var(--accent-soft);border-radius:99px;padding:4px 7px;text-decoration:none;font-size:9.6px;font-weight:700}
3787
+ .page-title-line{display:flex;align-items:center;gap:8px}.guide-trigger{display:grid;place-items:center;width:24px;height:24px;flex:0 0 auto;padding:0;border:1px solid var(--line);border-radius:50%;background:var(--panel);color:var(--muted);cursor:pointer}.guide-trigger svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round}.guide-trigger:hover{border-color:var(--accent-light);color:var(--accent)}.guide-trigger:focus-visible{outline:2px solid var(--focus);outline-offset:2px}.page-guide{display:grid;grid-template-columns:1.05fr 1.25fr 1fr;gap:0;margin:0;background:var(--panel);border:1px solid var(--line);border-radius:10px;box-shadow:0 2px 8px rgba(21,40,33,.025)}.resource-guide-popover{position:fixed;z-index:40;overflow:auto;box-shadow:0 18px 50px rgba(0,0,24,.24)}.resource-guide-popover[hidden]{display:none}.page-guide>div{padding:14px 16px;border-left:1px solid var(--line);min-width:0}.page-guide>div:first-child{border-left:0}.page-guide>div>span{display:block;color:var(--accent);text-transform:uppercase;letter-spacing:.09em;font-size:9.6px;font-weight:780;margin-bottom:6px}.page-guide p{color:var(--muted);font-size:12px;line-height:1.5;margin:0}.page-guide>.guide-review{grid-column:1/-1;border-top:1px solid var(--line);border-left:0}.guide-review ul{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px 28px;margin:0;padding-left:18px;color:var(--muted);font-size:11px;line-height:1.45}.guide-links{display:flex;flex-wrap:wrap;gap:5px;margin-top:8px}.guide-links a{color:var(--accent);background:var(--accent-soft);border-radius:99px;padding:4px 7px;text-decoration:none;font-size:9.6px;font-weight:700}
3042
3788
  .operation-tracking{display:grid;gap:2px;min-width:0;text-decoration:none}.operation-tracking strong,.operation-tracking small{display:block;overflow-wrap:anywhere}.operation-tracking small{color:var(--muted);line-height:1.35}.operation-tracking.running strong{color:#176143}.operation-tracking.waiting strong,.operation-tracking.mixed strong{color:var(--amber)}.operation-tracking.paused strong{color:var(--red)}a.operation-tracking:hover strong{text-decoration:underline}
3043
3789
  .page-actions{display:flex;align-items:center;justify-content:flex-end;gap:7px;flex-wrap:wrap}.repository-sync-status{min-height:18px;margin:7px 0 0;color:var(--muted);font-size:13.2px}.repository-sync-status.error{color:var(--red)}.repository-sync-alert{display:flex;align-items:flex-start;gap:9px;padding:10px 22px;border-bottom:1px solid #e9c888;background:#fff8e8;color:var(--ink);font-size:12px;line-height:1.45}.repository-sync-alert.syncing{border-color:var(--line);background:var(--surface-soft)}.repository-sync-alert .status-dot{flex:0 0 auto;margin-top:4px}.repository-sync-alert a{margin-left:auto;white-space:nowrap}.repository-state-banner,.repository-override{display:flex;align-items:flex-start;gap:13px;margin-bottom:14px}.repository-state-banner>.status-dot,.repository-override>.status-dot{margin-top:5px}.repository-state-banner h3{margin:3px 0 5px}.repository-state-banner p:last-child,.repository-override p{margin:0;color:var(--muted);line-height:1.5}.repository-override{padding:14px 17px;border:1px solid #e9c888;border-radius:9px;background:#fff8e8;font-size:13.2px}.repository-override strong{display:block;margin-bottom:4px}.onboarding-dialog{width:min(470px,calc(100vw - 30px));max-height:calc(100vh - 32px);margin:0;border:1px solid var(--line);border-radius:13px;padding:0;background:var(--panel);color:var(--ink);box-shadow:0 28px 90px rgba(0,0,24,.38);overflow:hidden}.onboarding-dialog[open]{display:flex;flex-direction:column}.onboarding-dialog::backdrop{background:transparent;backdrop-filter:none}.onboarding-shade{position:fixed;inset:0;z-index:60;pointer-events:none}.onboarding-shade span{position:absolute;background:rgba(0,0,24,.58)}.onboarding-progress{display:grid;flex:0 0 auto;grid-template-columns:repeat(var(--onboarding-step-count),1fr);gap:5px;padding:18px 24px 0}.onboarding-progress span{height:3px;border-radius:3px;background:var(--surface-muted)}.onboarding-progress span.active{background:var(--accent-light)}.onboarding-scroll{min-height:0;overflow-y:auto}.onboarding-head{padding:22px 25px 0}.onboarding-head h2{font-family:Georgia,serif;font-size:30px;font-weight:500;letter-spacing:-.015em;margin:8px 0 0}.onboarding-body{color:var(--muted);font-size:14.4px;line-height:1.6;margin:13px 25px 0}.onboarding-body+.onboarding-body{margin-top:8px}.onboarding-points{display:grid;gap:9px;margin:18px 25px 4px;padding-left:19px}.onboarding-points li{font-size:13.2px;line-height:1.5;padding-left:3px}.onboarding-sections{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:16px 25px 4px}.onboarding-sections section{padding:13px;border:1px solid var(--line);border-radius:8px;background:var(--surface-soft)}.onboarding-sections strong{font-size:13.2px}.onboarding-sections p{margin:6px 0 0;color:var(--muted);font-size:12px;line-height:1.5}.onboarding-actions{flex:0 0 auto;flex-wrap:wrap;padding:12px 25px 23px;border-top:1px solid var(--line);background:var(--panel)}.onboarding-skip{margin-right:auto;color:var(--muted);text-transform:none;letter-spacing:0;font-size:13.2px}.onboarding-form{display:grid;grid-template-columns:1fr 1fr;gap:13px;margin:18px 25px 0}.onboarding-form label{display:block;min-width:0}.onboarding-form label.wide{grid-column:1/-1}.onboarding-form label>span{display:block;color:var(--ink);font-size:12px;font-weight:720;margin-bottom:6px}.onboarding-form input,.onboarding-form select,.onboarding-form textarea{width:100%;min-height:40px;border:1px solid var(--line);border-radius:7px;background:var(--field);color:var(--ink);padding:9px 10px;font-size:14.4px}.onboarding-form textarea{min-height:78px;resize:vertical}.onboarding-form small{display:block;color:var(--muted);font-size:10.8px;line-height:1.45;margin-top:5px}.onboarding-write-note{color:var(--muted);font-size:10.8px;line-height:1.5;margin:12px 25px 16px}.onboarding-scroll>.dialog-error{margin:8px 25px 0}.onboarding-focus{outline:4px solid var(--accent-light)!important;outline-offset:5px;scroll-margin-top:102px}
3044
3790
  .onboarding-save-status{color:var(--muted);font-size:10.8px;line-height:1.35}.onboarding-save-status:empty{display:none}.onboarding-save-status:not(:empty){order:-1;flex-basis:100%;margin-bottom:4px}.onboarding-retry-sync{margin-top:9px}.detail-loading{color:var(--muted)}
@@ -3048,6 +3794,7 @@ html,body{height:100%;overflow:hidden}.shell{grid-template-columns:248px minmax(
3048
3794
  @media(max-width:1100px){.search{display:none}.topbar-status{margin-left:auto}.metrics{grid-template-columns:repeat(2,1fr)}.dashboard-grid,.organization-grid{grid-template-columns:repeat(2,1fr)}.catalog{grid-template-columns:repeat(3,1fr)}.span-2{grid-column:span 2}.resource-directory{grid-template-columns:repeat(2,minmax(0,1fr))}}
3049
3795
  @media(max-width:760px){.shell{display:block}.sidebar{transform:translateX(-100%);transition:.2s;box-shadow:8px 0 30px rgba(0,0,0,.2)}.sidebar.shown{transform:translateX(0)}.workspace{min-width:0}.mobile-nav{display:block;border:0;background:none;font-size:24px}.topbar{height:72px;padding:0 16px}.topbar>div:first-of-type{min-width:0}.topbar-status{display:none}.search{display:flex;max-width:none}.search kbd,.topbar .eyebrow{display:none}.page{padding:20px 15px 60px}.hero{display:block;padding:23px}.hero-meta{margin-top:22px;flex-wrap:wrap}.metrics,.dashboard-grid,.organization-grid{grid-template-columns:1fr}.span-2{grid-column:auto}.catalog{grid-template-columns:repeat(2,1fr)}.detail-grid{grid-template-columns:1fr}.page-intro,.detail-head{display:block}.page-intro>.button,.actions{margin-top:15px}.page-intro>.list-header-tools{justify-content:flex-start;margin:15px 0 0}.list-header-tools label{max-width:none}.record-table{min-width:720px}.readiness-map{padding:17px}.readiness-map-head{grid-template-columns:1fr;gap:8px}.readiness-flow{grid-template-columns:repeat(2,minmax(0,1fr))}.audit-engagement{grid-template-columns:1fr}.audit-engagement .button{grid-column:auto}.resource-directory{grid-template-columns:1fr}}
3050
3796
  @media(max-width:760px){.setup-banner,.page-guide,.stage-overview-hero,.relationship-note,.group-destination-card,.stage-page-grid,.evidence-map-expectation,.evidence-map-links,.external-evidence-list{grid-template-columns:1fr}.context-workflow,.evidence-map-head{align-items:stretch;flex-direction:column}.evidence-map-actions{flex-wrap:wrap}.page-guide>div{border-left:0;border-top:1px solid var(--line)}.page-guide>div:first-child{border-top:0}.group-overview-head{display:block}.stage-progress-card,.stage-status-link{margin-top:15px}.destination-rollup{text-align:left}.form-grid{grid-template-columns:1fr}.record-table{min-width:0}.record-table thead{display:none}.record-table,.record-table tbody,.record-table tr{display:block}.record-table tr{padding:8px 12px;border-bottom:1px solid var(--line)}.record-table tr:last-child{border-bottom:0}.record-table td:not([data-label]){display:block}.record-table td[data-label]{display:grid;grid-template-columns:105px minmax(0,1fr);gap:10px;border:0;padding:7px 0;align-items:start}.record-table td[data-label]::before{content:attr(data-label);color:#75817b;text-transform:uppercase;letter-spacing:.07em;font-size:9.6px;font-weight:700}.record-table td[data-primary-field]{display:block;padding:8px 0 10px}.record-table td[data-primary-field]::before{display:none}.content-label{align-items:flex-start}.editor form{padding:18px}.diagnostics>div{grid-template-columns:58px minmax(0,1fr)}.diagnostics p{grid-column:1/-1}.changes code{overflow-wrap:anywhere}.onboarding-dialog{max-height:56vh}}
3797
+ @media(max-width:760px){.guide-review ul,.resource-review-criteria ul{grid-template-columns:1fr}.collection-review-head,.collection-review-foot{align-items:stretch;flex-direction:column}.record-workflow-action{min-width:0}}
3051
3798
  @media(max-width:520px){.onboarding-form,.onboarding-sections,.setup-steps{grid-template-columns:1fr}.onboarding-form label.wide{grid-column:auto}.onboarding-actions{flex-wrap:wrap}.onboarding-skip{width:100%;order:3;margin:3px 0 0}.readiness-flow{grid-template-columns:1fr}.obligation-card-foot{align-items:flex-start;flex-direction:column}.obligation-action{align-self:flex-start}}
3052
3799
  @media(min-width:761px){.detail-grid{grid-template-columns:minmax(270px,1fr) minmax(0,2fr)}.detail-grid aside{grid-column:1;grid-row:1}.detail-main{grid-column:2;grid-row:1}}
3053
3800
  @media(min-width:761px){.detail-grid.detail-grid-structured{grid-template-columns:1fr}.detail-grid-structured aside{grid-column:1;grid-row:1;grid-template-columns:repeat(auto-fit,minmax(320px,1fr))}.detail-grid-structured aside>.panel{align-self:start}}
@@ -3121,11 +3868,12 @@ dialog::backdrop{background:rgba(0,0,24,.62)}
3121
3868
  .commit-files code{font-size:10.8px;overflow-wrap:anywhere}
3122
3869
  .onboarding-progress{grid-template-columns:repeat(var(--onboarding-step-count),1fr)}
3123
3870
  .onboarding-git-status{display:flex;align-items:flex-start;gap:9px;margin:14px 25px 0;padding:10px 12px;border:1px solid var(--line);border-radius:7px;background:var(--surface-soft)}.onboarding-git-status .status-dot{margin-top:4px}.onboarding-git-status strong,.onboarding-git-status small{display:block}.onboarding-git-status strong{font-size:12px}.onboarding-git-status small{color:var(--muted);font-size:10.8px;line-height:1.45;margin-top:3px}.onboarding-git-status code{font-size:10.8px}
3124
- .badge.status-overdue{background:#f7dfdc;color:#873027}.badge.status-due{background:#f6e8c9;color:#79500f}.badge.status-upcoming,.badge.status-proposed{background:var(--accent-soft);color:var(--accent)}.badge.status-complete{background:#dcefe4;color:#125733}
3871
+ .badge.status-overdue,.badge.status-blocked{background:#f7dfdc;color:#873027}.badge.status-due{background:#f6e8c9;color:#79500f}.badge.status-upcoming,.badge.status-proposed{background:var(--accent-soft);color:var(--accent)}.badge.status-complete{background:#dcefe4;color:#125733}
3125
3872
  .obligation-preview,.event-reminder-preview{display:grid;gap:8px}.obligation-preview a{display:flex;align-items:flex-start;gap:9px;text-decoration:none;padding:7px 0;border-top:1px solid var(--line)}.obligation-preview a:first-child{border-top:0;padding-top:0}.obligation-preview strong,.obligation-preview small,.event-reminder-preview strong,.event-reminder-preview small{display:block}.obligation-preview strong,.event-reminder-preview strong{font-size:12px}.obligation-preview small,.event-reminder-preview small{font-size:10.8px;color:var(--muted);margin-top:2px}.event-reminder-preview{grid-template-columns:repeat(2,minmax(0,1fr))}.event-reminder-preview a{padding:10px;border-radius:7px;background:var(--surface-soft);text-decoration:none}
3126
- .obligation-board{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;align-items:start}.obligation-column{min-width:0}.obligation-column-head{display:flex;align-items:center;justify-content:space-between;margin:5px 1px 10px}.obligation-column-head>strong{font:500 26.4px Georgia,serif}.obligation-cards{display:grid;gap:9px}.obligation-card{background:var(--panel);border:1px solid var(--line);border-left:4px solid var(--accent-light);border-radius:9px;padding:14px;box-shadow:0 2px 8px rgba(21,40,33,.025)}.obligation-card.status-overdue{border-left-color:var(--red)}.obligation-card.status-due{border-left-color:#d89021}.obligation-card-head{display:flex;justify-content:space-between;gap:8px;text-transform:uppercase;letter-spacing:.06em;font-size:9.6px;color:var(--muted)}.obligation-card-head strong{color:var(--ink);text-align:right}.obligation-card h3{font-size:14.4px;margin:9px 0 7px}.obligation-card h3 a{text-decoration:none}.obligation-card p{font-size:10.8px;line-height:1.5;color:var(--muted);margin:0}.obligation-links{margin-top:10px}.workflow-section{margin-top:30px}.section-head{display:flex;justify-content:space-between;margin-bottom:13px}.section-head h2{font:500 28.8px Georgia,serif;margin:6px 0}.section-head p:not(.kicker){font-size:13.2px;color:var(--muted);margin:0;max-width:720px}.policy-event-feedback{display:grid;grid-template-columns:auto minmax(0,1fr) auto auto;gap:10px;align-items:center;margin-top:14px;padding:12px 14px;border:1px solid #9ccfb2;border-radius:8px;background:#e7f5ec}.policy-event-feedback .status-dot{align-self:start;margin-top:4px}.policy-event-feedback strong,.policy-event-feedback p{display:block}.policy-event-feedback strong{font-size:12px}.policy-event-feedback p{margin:3px 0 0;color:#315d44;font-size:10.8px}.policy-event-feedback .icon-button{width:30px;height:30px}.policy-event-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.policy-event-row{position:relative;display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0;padding:9px 10px;border:1px solid var(--line);border-radius:8px;background:var(--panel)}.policy-event-name{min-width:0}.policy-event-title{display:flex;align-items:center;gap:6px;min-width:0}.policy-event-title>strong{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.policy-event-guide{display:inline-flex;flex:0 0 auto}.policy-event-guide .guide-trigger{width:20px;height:20px}.policy-event-guide .guide-trigger svg{width:14px;height:14px}.policy-event-name strong,.policy-event-name>small{display:block}.policy-event-name strong{font-size:12px}.policy-event-name>small{margin-top:2px;color:var(--muted);font-size:9.6px;line-height:1.35;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.policy-event-row>.button{flex:none;padding:7px 9px;font-size:10.8px}.policy-event-tooltip{position:absolute;z-index:8;top:calc(100% + 7px);left:0;width:min(420px,calc(100vw - 48px));padding:12px 14px;border:1px solid var(--line);border-radius:8px;background:var(--panel);box-shadow:var(--shadow);opacity:0;visibility:hidden;transform:translateY(-3px);transition:opacity .12s,transform .12s,visibility 0s .12s;pointer-events:none}.policy-event-row:nth-child(3n) .policy-event-tooltip{right:0;left:auto}.policy-event-row:hover,.policy-event-row:focus-within{z-index:9}.policy-event-guide:hover .policy-event-tooltip,.policy-event-guide:focus-within .policy-event-tooltip{opacity:1;visibility:visible;transform:none;transition-delay:0s}.policy-event-tooltip>strong{font-size:12px}.policy-event-tooltip ol{display:grid;gap:7px;margin:9px 0 0;padding-left:20px}.policy-event-tooltip li span,.policy-event-tooltip li small{display:block}.policy-event-tooltip li span{font-size:10.8px}.policy-event-tooltip li small{margin-top:2px;color:var(--muted);font-size:9.6px;line-height:1.4}
3873
+ .obligation-board{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:14px;align-items:start}.obligation-column{min-width:0}.obligation-column-head{display:flex;align-items:center;justify-content:space-between;margin:5px 1px 10px}.obligation-column-head>strong{font:500 26.4px Georgia,serif}.obligation-cards{display:grid;gap:9px}.obligation-card{background:var(--panel);border:1px solid var(--line);border-left:4px solid var(--accent-light);border-radius:9px;padding:14px;box-shadow:0 2px 8px rgba(21,40,33,.025)}.obligation-card.status-overdue,.obligation-card.status-blocked{border-left-color:var(--red)}.obligation-card.status-due{border-left-color:#d89021}.obligation-card-head{display:flex;justify-content:space-between;gap:8px;text-transform:uppercase;letter-spacing:.06em;font-size:9.6px;color:var(--muted)}.obligation-card-head strong{color:var(--ink);text-align:right}.obligation-card h3{font-size:14.4px;margin:9px 0 7px}.obligation-card h3 a{text-decoration:none}.obligation-card p{font-size:10.8px;line-height:1.5;color:var(--muted);margin:0}.obligation-links{margin-top:10px}.workflow-section{margin-top:30px}.section-head{display:flex;justify-content:space-between;margin-bottom:13px}.section-head h2{font:500 28.8px Georgia,serif;margin:6px 0}.section-head p:not(.kicker){font-size:13.2px;color:var(--muted);margin:0;max-width:720px}.policy-event-feedback{display:grid;grid-template-columns:auto minmax(0,1fr) auto auto;gap:10px;align-items:center;margin-top:14px;padding:12px 14px;border:1px solid #9ccfb2;border-radius:8px;background:#e7f5ec}.policy-event-feedback .status-dot{align-self:start;margin-top:4px}.policy-event-feedback strong,.policy-event-feedback p{display:block}.policy-event-feedback strong{font-size:12px}.policy-event-feedback p{margin:3px 0 0;color:#315d44;font-size:10.8px}.policy-event-feedback .icon-button{width:30px;height:30px}.policy-event-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.policy-event-more{margin-top:10px}.policy-event-row{position:relative;display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0;padding:9px 10px;border:1px solid var(--line);border-radius:8px;background:var(--panel)}.policy-event-row[hidden]{display:none}.policy-event-name{min-width:0}.policy-event-title{display:flex;align-items:center;gap:6px;min-width:0}.policy-event-title>strong{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.policy-event-guide{display:inline-flex;flex:0 0 auto}.policy-event-guide .guide-trigger{width:20px;height:20px}.policy-event-guide .guide-trigger svg{width:14px;height:14px}.policy-event-name strong,.policy-event-name>small{display:block}.policy-event-name strong{font-size:12px}.policy-event-name>small{margin-top:2px;color:var(--muted);font-size:9.6px;line-height:1.35;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.policy-event-row>.button{flex:none;padding:7px 9px;font-size:10.8px}.policy-event-tooltip{position:absolute;z-index:8;top:calc(100% + 7px);left:0;width:min(420px,calc(100vw - 48px));padding:12px 14px;border:1px solid var(--line);border-radius:8px;background:var(--panel);box-shadow:var(--shadow);opacity:0;visibility:hidden;transform:translateY(-3px);transition:opacity .12s,transform .12s,visibility 0s .12s;pointer-events:none}.policy-event-row:nth-child(3n) .policy-event-tooltip{right:0;left:auto}.policy-event-row:hover,.policy-event-row:focus-within{z-index:9}.policy-event-guide:hover .policy-event-tooltip,.policy-event-guide:focus-within .policy-event-tooltip{opacity:1;visibility:visible;transform:none;transition-delay:0s}.policy-event-tooltip>strong{font-size:12px}.policy-event-tooltip ol{display:grid;gap:7px;margin:9px 0 0;padding-left:20px}.policy-event-tooltip li span,.policy-event-tooltip li small{display:block}.policy-event-tooltip li span{font-size:10.8px}.policy-event-tooltip li small{margin-top:2px;color:var(--muted);font-size:9.6px;line-height:1.4}
3127
3874
  .obligation-card-foot{display:flex;align-items:flex-end;justify-content:space-between;gap:9px;margin-top:10px}.obligation-card-foot .obligation-links{margin-top:0;min-width:0}.obligation-action{flex:0 0 auto;border:0;border-radius:6px;background:var(--accent-soft);color:var(--accent);padding:7px 9px;font-family:inherit;font-size:10.8px;font-weight:700;line-height:1;text-decoration:none;cursor:pointer}.obligation-action:hover{filter:brightness(1.08)}.obligation-action.blocked{background:var(--surface-muted);color:var(--muted)}.obligation-more{width:100%;margin-top:9px}.workflow-section{scroll-margin-top:92px}
3128
- .event-dialog label{display:block;margin-top:13px}.event-dialog label>span{display:block;font-size:12px;font-weight:720;margin-bottom:6px}.event-dialog input,.event-dialog select{width:100%;min-height:40px;border:1px solid var(--line);border-radius:7px;background:var(--field);color:var(--ink);padding:9px 10px;font-size:14.4px}.event-dialog-steps{display:grid;gap:6px;margin-top:15px;padding:10px;background:var(--surface-soft);border-radius:7px}.event-dialog-steps strong,.event-dialog-steps small{display:block}.event-dialog-steps strong{font-size:12px}.event-dialog-steps small{font-size:9.6px;color:var(--muted);margin-top:2px}
3875
+ .event-dialog label{display:block;margin-top:13px}.event-dialog label[hidden]{display:none}.event-dialog label>span{display:block;font-size:12px;font-weight:720;margin-bottom:6px}.event-dialog input,.event-dialog select,.event-dialog textarea{width:100%;min-height:40px;border:1px solid var(--line);border-radius:7px;background:var(--field);color:var(--ink);padding:9px 10px;font-size:14.4px}.event-dialog textarea{resize:vertical}.commit-dialog .form-grid label.full{grid-column:1/-1}.workflow-preview{margin-top:14px;padding:0 12px;border-radius:7px;background:var(--surface-soft)}.workflow-preview:not(:empty){padding-top:10px;padding-bottom:10px}.workflow-preview strong,.workflow-preview p{display:block;margin:0}.workflow-preview p{margin-top:5px;color:var(--muted);font-size:12px;line-height:1.5}.event-dialog-steps{display:grid;gap:6px;margin-top:15px;padding:10px;background:var(--surface-soft);border-radius:7px}.event-dialog-steps strong,.event-dialog-steps small{display:block}.event-dialog-steps strong{font-size:12px}.event-dialog-steps small{font-size:9.6px;color:var(--muted);margin-top:2px}
3876
+ .applicability-dialog{width:min(980px,calc(100vw - 30px));max-height:calc(100vh - 32px);border:0;border-radius:12px;padding:0;background:var(--panel);color:var(--ink);box-shadow:0 25px 80px rgba(0,0,24,.28)}.applicability-dialog form{padding:23px}.applicability-dialog form>p{color:var(--muted);font-size:13.2px}.review-context label>span{display:block;font-size:12px;font-weight:720;margin-bottom:6px}.review-context input,.review-context select,.applicability-row input,.applicability-row select{width:100%;min-height:38px;border:1px solid var(--line);border-radius:7px;background:var(--field);color:var(--ink);padding:8px 9px;font-size:13.2px}.review-context label.full{grid-column:1/-1}.applicability-rows{display:grid;gap:7px;max-height:46vh;overflow:auto;margin-top:16px;padding-right:4px}.applicability-row{display:grid;grid-template-columns:minmax(210px,1fr) 180px minmax(240px,1.3fr);gap:9px;align-items:center;padding:9px;border:1px solid var(--line);border-radius:8px}.applicability-row strong,.applicability-row small{display:block}.applicability-row small{margin-top:3px;color:var(--muted);font-size:10.8px}
3129
3877
  .packet-builder form{display:grid;grid-template-columns:repeat(3,minmax(0,1fr)) auto;gap:12px;align-items:end}.packet-builder label>span{display:block;font-size:10.8px;font-weight:720;margin-bottom:6px}.packet-builder input,.packet-builder select{width:100%;min-height:40px;border:1px solid var(--line);border-radius:7px;background:var(--field);color:var(--ink);padding:9px 10px;font-size:13.2px}.packet-note,.packet-output>p{font-size:12px;color:var(--muted);margin:12px 0 0}.packet-output{margin:14px 0}.packet-output h3{overflow-wrap:anywhere}.packet-gaps{display:grid}.packet-gaps>div{display:grid;grid-template-columns:58px 1fr;gap:10px;border-top:1px solid var(--line);padding:10px 0}.packet-gaps>div:first-child{border-top:0}.packet-gaps p{font-size:12px;margin:0}.packet-list{display:grid}.packet-list a{display:block;text-decoration:none;border-top:1px solid var(--line);padding:9px 0}.packet-list a:first-child{border-top:0}.packet-list strong,.packet-list small{display:block}.packet-list strong{font-size:12px}.packet-list small{font-size:9.6px;color:var(--muted);margin-top:2px}
3130
3878
  .packet-preflight{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;margin-bottom:12px}.packet-preflight a{display:flex;align-items:flex-start;gap:9px;padding:10px 12px;border:1px solid var(--line);border-radius:8px;background:var(--panel);text-decoration:none}.packet-preflight .status-dot{margin-top:4px}.packet-preflight small,.packet-preflight strong{display:block}.packet-preflight small{color:var(--muted);font-size:9.6px;text-transform:uppercase;letter-spacing:.07em}.packet-preflight strong{margin-top:3px;font-size:12px}.audit-evidence-paths{margin-bottom:12px}.audit-evidence-paths .panel-head p:not(.kicker){margin:4px 0 0;color:var(--muted);font-size:10.8px}.audit-evidence-path-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:12px}.audit-evidence-path-grid>a{display:block;padding:14px;border:1px solid var(--line);border-radius:8px;background:var(--surface-soft);text-decoration:none}.audit-evidence-path-grid h4{margin:7px 0 5px;font-size:13.2px}.audit-evidence-path-grid p{margin:0;color:var(--muted);font-size:10.8px;line-height:1.55}
3131
3879
  .audit-preparation{margin-bottom:12px}.audit-preparation .panel-head{align-items:flex-start}.audit-preparation .panel-head h3{margin:3px 0}.audit-preparation .panel-head p:not(.kicker){margin:4px 0 0;color:var(--muted);font-size:10.8px}.preparation-progress{height:5px;margin:12px 0 0;border-radius:99px;background:var(--surface-muted);overflow:hidden}.preparation-progress span{display:block;height:100%;border-radius:inherit;background:var(--primary-gradient)}.audit-preparation-note{margin:9px 0 0;color:var(--muted);font-size:10.8px;line-height:1.5}.preparation-stages{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:12px}.preparation-stage{border:1px solid var(--line);border-radius:8px;background:var(--surface-soft);overflow:hidden}.preparation-stage summary{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:11px 12px;cursor:pointer;list-style:none}.preparation-stage summary::-webkit-details-marker{display:none}.preparation-stage summary span,.preparation-stage summary strong,.preparation-stage summary small{display:block}.preparation-stage summary strong{font-size:12px}.preparation-stage summary small{margin-top:3px;color:var(--muted);font-size:9.6px;line-height:1.4}.preparation-stage summary b{flex:none;color:var(--muted);font-size:9.6px;font-weight:650}.preparation-items{border-top:1px solid var(--line);background:var(--panel)}.preparation-items>a,.preparation-items>div{display:grid;grid-template-columns:22px minmax(0,1fr);gap:9px;padding:10px 12px;border-top:1px solid var(--line);text-decoration:none}.preparation-items>:first-child{border-top:0}.preparation-items strong,.preparation-items small{display:block}.preparation-items strong{font-size:10.8px}.preparation-items small{margin-top:3px;color:var(--muted);font-size:9.6px;line-height:1.45}.preparation-status{display:grid;place-items:center;width:20px;height:20px;border-radius:50%;background:var(--surface-muted);color:var(--muted);font-size:10.8px;font-weight:800}.preparation-status.complete{background:#dcefe4;color:#125733}.preparation-status.action{background:#f7dfdc;color:#873027}.preparation-status.later{background:#f6e8c9;color:#79500f}.preparation-status.external,.preparation-status.info{background:var(--accent-soft);color:var(--accent)}.audit-preparation-error:empty{display:none}
@@ -3135,6 +3883,7 @@ dialog::backdrop{background:rgba(0,0,24,.62)}
3135
3883
  @media(max-width:900px){.overview-grid{grid-template-columns:1fr}.overview-grid>.audit-panel{grid-column:auto}}
3136
3884
  @media(max-width:520px){.event-reminder-preview,.policy-event-list,.packet-builder form,.packet-preflight,.audit-evidence-path-grid{grid-template-columns:1fr}.policy-event-row:nth-child(n) .policy-event-tooltip{right:auto;left:0}.packet-metrics{grid-template-columns:1fr}.obligation-card-head{display:block}.obligation-card-head strong{display:block;text-align:left;margin-top:3px}}
3137
3885
  @media(max-width:520px){.policy-event-feedback{grid-template-columns:auto minmax(0,1fr) auto}.policy-event-feedback>.button{grid-column:2}.policy-event-feedback>.icon-button{grid-column:3;grid-row:1}}
3886
+ @media(max-width:760px){.workflow-findings{grid-template-columns:1fr}}
3138
3887
 
3139
3888
  @media(prefers-color-scheme:dark){
3140
3889
  :root{--ink:#f4f5ff;--muted:#b8bfd3;--line:#343d5c;--paper:#000;--panel:#141a2e;--accent:#aab7ff;--accent-soft:#252e52;--accent-light:#9aabff;--focus:#bdc7ff;--amber:#ffd08a;--red:#ffaaa0;--surface-soft:#1b2238;--surface-muted:#252d48;--field:#11172a;--field-readonly:#1c2338;--shadow:0 12px 34px rgba(0,0,0,.3)}
@@ -3146,9 +3895,19 @@ dialog::backdrop{background:rgba(0,0,24,.62)}
3146
3895
  .badge.status-active,.badge.status-approved,.badge.status-complete,.badge.status-passed,.badge.status-accepted{background:#173b2b;color:#a8edc4}
3147
3896
  .badge.status-open,.badge.status-high,.badge.status-critical,.badge.status-failed{background:#4a252a;color:#ffb5ad}
3148
3897
  .badge.status-draft,.badge.status-planned,.badge.status-in-progress,.badge.status-medium{background:#483714;color:#ffd991}
3149
- .badge.status-overdue{background:#4a252a;color:#ffb5ad}
3898
+ .badge.status-overdue,.badge.status-blocked{background:#4a252a;color:#ffb5ad}
3150
3899
  .badge.status-due{background:#483714;color:#ffd991}
3151
3900
  .badge.status-complete{background:#173b2b;color:#a8edc4}
3901
+ .repository-override,.repository-sync-alert{border-color:#77612f;background:#382f19}
3902
+ .repository-override code{color:#ffe2a3}
3903
+ .workflow-finding-status.ready,.workflow-finding-status.due,.workflow-finding-status.open,.stage-page-completion-state,.readiness-state.warn,.preparation-status.later{background:#483714;color:#ffd991}
3904
+ .workflow-finding-status.overdue,.workflow-finding-status.blocked,.readiness-state.bad,.preparation-status.action{background:#4a252a;color:#ffb5ad}
3905
+ .workflow-finding-status.complete,.stage-page-completion-state.complete,.readiness-state.good,.preparation-status.complete{background:#173b2b;color:#a8edc4}
3906
+ .stage-page-card.complete,.evidence-map-card.complete{border-color:#315f48}
3907
+ .collection-review-panel.required{border-color:#77612f}
3908
+ .collection-review-panel.current{border-color:#315f48}
3909
+ .evidence-map-source.complete{border-color:#315f48;background:#183426}
3910
+ .operation-tracking.running strong{color:#a8edc4}
3152
3911
  .policy-event-feedback{border-color:#315f48;background:#183426}.policy-event-feedback p{color:#b7d8c3}
3153
3912
  .missing-options{border-color:#77612f;background:#382f19;color:#ffdc92}
3154
3913
  .status-dot.neutral{background:#9aabff}