/* =========================================================
   Audit Report — Scope, Delivery & Traceability Assessment
   Enterprise audit-report styling. Light default, dark via
   [data-theme="dark"]. No external fonts (offline-safe).
   ========================================================= */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --text: #1a1f2e;
  --text-soft: #4b5563;
  --muted: #6b7280;
  --line: #e3e7ee;
  --line-strong: #c9d0db;
  --navy: #1f3a5f;
  --navy-soft: #eaeff6;
  --green: #2e7d4f;
  --green-bg: #e9f4ee;
  --amber: #9a6700;
  --amber-bg: #fbf0d9;
  --red: #b3362c;
  --red-bg: #faeae8;
  --gray: #5f6b7a;
  --gray-bg: #eef0f3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 6px;
  --sidenav-w: 248px;
}

html[data-theme="dark"] {
  --bg: #11151c;
  --bg-soft: #161b24;
  --surface: #1a2029;
  --surface-2: #1e242f;
  --text: #e6e9ef;
  --text-soft: #b6bdc9;
  --muted: #8a93a3;
  --line: #2a3240;
  --line-strong: #3a4456;
  --navy: #8fb0d9;
  --navy-soft: #1d2735;
  --green: #6fbf92;
  --green-bg: #16281f;
  --amber: #d9a93f;
  --amber-bg: #2b2310;
  --red: #e08077;
  --red-bg: #2e1a18;
  --gray: #9aa4b2;
  --gray-bg: #232a35;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}

code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 2px solid var(--navy);
}
.topbar-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.topbar-mark {
  font-weight: 800; letter-spacing: .14em; font-size: 13px;
  color: #fff; background: var(--navy); padding: 3px 8px; border-radius: 3px;
}
html[data-theme="dark"] .topbar-mark { color: #11151c; }
.topbar-name { font-weight: 600; font-size: 14px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.search-wrap { position: relative; }
#searchBox {
  width: 270px; max-width: 38vw;
  padding: 7px 64px 7px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg-soft); color: var(--text); font-size: 13px;
}
#searchBox:focus { outline: 2px solid var(--navy); outline-offset: 1px; }
.search-count {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--muted); background: var(--surface); padding: 1px 6px;
  border: 1px solid var(--line); border-radius: 10px;
}
.tool-btn {
  padding: 7px 12px; font-size: 13px; font-weight: 600;
  color: var(--text-soft); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer;
}
.tool-btn:hover { border-color: var(--navy); color: var(--navy); }

/* ---------- Layout ---------- */
.layout { display: flex; align-items: flex-start; max-width: 1380px; margin: 0 auto; }

.sidenav {
  position: sticky; top: 56px;
  width: var(--sidenav-w); flex: 0 0 var(--sidenav-w);
  max-height: calc(100vh - 56px); overflow-y: auto;
  padding: 22px 14px 22px 20px;
  border-right: 1px solid var(--line);
}
.sidenav ol { list-style: none; margin: 0; padding: 0; counter-reset: nav; }
.sidenav li { counter-increment: nav; }
.sidenav a {
  display: flex; gap: 10px; align-items: baseline;
  padding: 7px 10px; margin: 1px 0;
  font-size: 13px; font-weight: 500; color: var(--text-soft);
  text-decoration: none; border-left: 3px solid transparent; border-radius: 0 4px 4px 0;
}
.sidenav a::before {
  content: counter(nav, decimal-leading-zero);
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.sidenav a:hover { background: var(--bg-soft); color: var(--text); }
.sidenav a.active { border-left-color: var(--navy); color: var(--navy); font-weight: 700; background: var(--navy-soft); }
.sidenav-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.sidenav-foot p { margin: 0; }

.content { flex: 1; min-width: 0; padding: 0 36px 80px; }

/* ---------- Sections ---------- */
.section { padding: 44px 0 18px; border-bottom: 1px solid var(--line); scroll-margin-top: 64px; }
.section:last-of-type { border-bottom: 0; }
.section h2 { font-size: 24px; margin: 0 0 14px; letter-spacing: -.01em; display: flex; align-items: center; gap: 12px; }
.secnum { font-size: 12px; font-weight: 700; color: var(--navy); border: 1px solid var(--navy); border-radius: 3px; padding: 2px 7px; letter-spacing: .08em; }
.section h3 { font-size: 16.5px; margin: 26px 0 10px; }
.section h4 { font-size: 14px; margin: 0 0 6px; }
.lede { color: var(--text-soft); max-width: 880px; margin: 0 0 18px; }
.prose { max-width: 880px; color: var(--text); }
.prose p { margin: 8px 0; }
.source { font-size: 11.5px; color: var(--muted); margin: 10px 0 0; }
.src { font-size: 11px; color: var(--muted); white-space: nowrap; }
.src::before { content: "— "; }

/* ---------- Cover ---------- */
.cover { padding-top: 56px; }
.cover-kicker { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.cover h1 { font-size: 44px; margin: 0; letter-spacing: -.02em; line-height: 1.1; }
.cover-subtitle { font-size: 21px; color: var(--navy); font-weight: 600; margin: 6px 0 4px; }
.cover-product { color: var(--text-soft); margin: 4px 0 22px; }
.cover-meta { display: grid; gap: 8px; margin: 0 0 26px; max-width: 880px; }
.cover-meta > div { display: grid; grid-template-columns: 220px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.meta-label { font-weight: 700; color: var(--text-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

.exec-card {
  background: var(--surface-2); border: 1px solid var(--line); border-top: 3px solid var(--navy);
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); max-width: 980px;
}
.exec-card-title { font-size: 14px; text-transform: uppercase; letter-spacing: .1em; color: var(--navy); margin: 0 0 10px; }
.exec-card > p { margin: 0 0 16px; max-width: 880px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-num { display: block; font-size: 30px; font-weight: 800; color: var(--navy); letter-spacing: -.02em; }
.stat-label { display: block; font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

/* ---------- Scorecard ---------- */
.scorecard { max-width: 880px; display: grid; gap: 16px; margin-bottom: 8px; }
.score-row { }
.score-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
.score-val { color: var(--navy); font-weight: 800; }
.bar { height: 12px; background: var(--gray-bg); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; width: var(--w); border-radius: 6px 0 0 6px; }
.fill-green { background: var(--green); }
.fill-amber { background: var(--amber); }
.fill-red   { background: var(--red); }
.fill-navy  { background: var(--navy); }
.score-note { font-size: 11.5px; color: var(--muted); margin: 4px 0 0; }

.findings { max-width: 920px; padding-left: 20px; }
.findings li { margin: 7px 0; }

/* ---------- Flow diagram ---------- */
.flow { display: flex; flex-direction: column; align-items: stretch; max-width: 620px; margin: 18px 0; }
.flow-step {
  display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto; column-gap: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--navy);
  border-radius: var(--radius); padding: 12px 16px;
}
.flow-step strong { grid-column: 2; font-size: 14.5px; }
.flow-step span:last-child { grid-column: 2; font-size: 12.5px; color: var(--muted); }
.flow-pct { grid-row: 1 / span 2; align-self: center; font-size: 19px; font-weight: 800; color: var(--navy); }
.flow-arrow { text-align: center; color: var(--muted); font-size: 16px; padding: 2px 0; }

.chart-block { max-width: 880px; margin: 22px 0; }
.chart-wrap { position: relative; height: 300px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.chart-short { height: 170px; }
.chart-fallback { font-size: 13px; color: var(--text-soft); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 880px; margin: 18px 0; }
.callout { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.callout-wide { max-width: 880px; border-left: 4px solid var(--navy); margin-top: 18px; }
.callout ul.tight { margin: 6px 0 0; padding-left: 18px; }
.callout ul.tight li { margin: 4px 0; font-size: 13.5px; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; margin: 18px 0; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
}
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15px; flex: 1 1 auto; }
.card p { margin: 0; font-size: 13.5px; color: var(--text-soft); }
.card details { font-size: 13px; border-top: 1px dashed var(--line); padding-top: 8px; }
.card details summary { cursor: pointer; font-weight: 600; color: var(--navy); font-size: 12.5px; }
.card details p { margin: 6px 0 0; }
.card .source { margin-top: auto; }

/* chips */
.chip {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.chip-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.chip-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber); }
.chip-red   { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red); }
.chip-gray  { background: var(--gray-bg);  color: var(--gray);  border: 1px solid var(--gray); }
.chip-outline { background: transparent; color: var(--muted); border: 1px dashed var(--line-strong); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; background: var(--surface); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  background: var(--navy-soft); color: var(--navy); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .06em; position: sticky; top: 0;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-soft); }

.os-table td:first-child { font-weight: 700; white-space: nowrap; }
.row-green td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.row-amber td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.row-red td:first-child   { box-shadow: inset 3px 0 0 var(--red); }
.row-gray td:first-child  { box-shadow: inset 3px 0 0 var(--gray); }

.mini {
  display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px;
  border-radius: 3px; margin-right: 4px; white-space: nowrap;
  background: var(--gray-bg); color: var(--gray);
}
.mini-green { background: var(--green-bg); color: var(--green); }
.mini-amber { background: var(--amber-bg); color: var(--amber); }
.mini-red   { background: var(--red-bg); color: var(--red); }

.count-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.count { font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 4px; border: 1px solid; }
.count-green { color: var(--green); background: var(--green-bg); border-color: var(--green); }
.count-amber { color: var(--amber); background: var(--amber-bg); border-color: var(--amber); }
.count-red   { color: var(--red); background: var(--red-bg); border-color: var(--red); }
.count-gray  { color: var(--gray); background: var(--gray-bg); border-color: var(--gray); }
.count-navy  { color: var(--navy); background: var(--navy-soft); border-color: var(--navy); }
.chip-navy   { background: var(--navy-soft); color: var(--navy); border: 1px solid var(--navy); }
.extra-table td:nth-child(1) { font-weight: 700; color: var(--muted); }
.extra-table td:nth-child(3), .extra-table td:nth-child(4) { white-space: nowrap; }

/* ---------- Tier cards ---------- */
.tier-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 18px 0; }
.tier-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.tier-card h3 { margin: 0 0 10px; font-size: 14.5px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tier-n { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tier-card ul { list-style: none; margin: 0; padding: 0; }
.tier-card li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13.5px; }
.tier-card li em { color: var(--muted); font-style: normal; margin-left: auto; font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.dot-green { background: var(--green); } .dot-amber { background: var(--amber); }
.dot-red { background: var(--red); } .dot-gray { background: var(--gray); }
.tier-note { font-size: 12px; color: var(--muted); margin: 10px 0 0; border-top: 1px dashed var(--line); padding-top: 8px; }

/* ---------- Gap cards ---------- */
.gap-cards { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.gap-card {
  background: var(--surface); border: 1px solid var(--red); border-top: 4px solid var(--red);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.gap-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.gap-head h3 { margin: 0; font-size: 15px; color: var(--red); }
.gap-ids { font-size: 11px; color: var(--muted); white-space: nowrap; }
.gap-card dl { margin: 0; font-size: 13px; }
.gap-card dt { font-weight: 800; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 8px; }
.gap-card dd { margin: 2px 0 0; color: var(--text); }

/* ---------- Documentation grid ---------- */
.doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 18px 0; }
.doc-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--surface); }
.doc-card h3 { margin: 0 0 10px; font-size: 14px; }
.doc-card ul { margin: 0; padding-left: 18px; font-size: 13px; }
.doc-card li { margin: 6px 0; }
.doc-over     { border-top: 4px solid var(--red); }
.doc-over h3  { color: var(--red); }
.doc-under    { border-top: 4px solid var(--amber); }
.doc-under h3 { color: var(--amber); }
.doc-conflict { border-top: 4px solid var(--navy); }
.doc-conflict h3 { color: var(--navy); }
.doc-format   { border-top: 4px solid var(--gray); }
.doc-format h3 { color: var(--gray); }

/* ---------- Risk table ---------- */
.risk-table td:first-child { max-width: 520px; }
.risk-table td:nth-child(2), .risk-table td:nth-child(3) { white-space: nowrap; }
.risk-table td:nth-child(4) { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* ---------- Verdict ---------- */
.verdict-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 18px 0; }
.verdict-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.verdict-card h3 { margin: 0 0 6px; font-size: 14.5px; }
.verdict-card p { margin: 6px 0 0; font-size: 13.5px; color: var(--text-soft); }
.verdict-answer { font-size: 19px !important; font-weight: 800; margin: 2px 0 6px !important; }
.answer-yes { color: var(--green) !important; }
.answer-no { color: var(--red) !important; }
.answer-neutral { color: var(--navy) !important; }

.final-card {
  background: var(--navy-soft); border: 1px solid var(--navy); border-radius: var(--radius);
  padding: 22px 26px; margin-top: 18px;
}
.final-card h3 { margin: 0 0 8px; color: var(--navy); font-size: 16px; }
.final-card p { margin: 6px 0; max-width: 980px; }

/* ---------- Footer ---------- */
.report-foot { padding: 30px 0 10px; font-size: 12px; color: var(--muted); border-top: 2px solid var(--navy); margin-top: 30px; }
.report-foot p { max-width: 980px; margin: 6px 0; }

/* ---------- Search filtering ---------- */
.search-hidden { display: none !important; }
.section.section-dim > :not(h2) { opacity: .25; }
mark.hl { background: #ffe79c; color: inherit; padding: 0; }
html[data-theme="dark"] mark.hl { background: #6b5618; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .sidenav { display: none; }
  .content { padding: 0 20px 60px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .tier-grid, .doc-grid, .verdict-grid, .two-col { grid-template-columns: 1fr; }
  .cover h1 { font-size: 34px; }
  #searchBox { width: 170px; }
  .topbar-name { display: none; }
}

/* ---------- Print ---------- */
@media print {
  :root { --bg:#fff; --surface:#fff; --surface-2:#fff; --text:#000; --text-soft:#222; --muted:#444; --line:#bbb; --line-strong:#999; --shadow:none; }
  .topbar, .sidenav, .tool-btn, .search-wrap { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  .section { page-break-inside: avoid; border-bottom: 1px solid #ccc; padding: 24px 0; }
  .cards, .gap-cards { grid-template-columns: 1fr 1fr; }
  .chart-wrap { height: auto; min-height: 200px; }
  a { color: inherit; text-decoration: none; }
  details > *:not(summary) { display: block; }
}
