:root {
  --brand: #284bba;
  --brand-dark: #17306e;
  --ink: #1a1a1a;
  --muted: #4b5563;
  --line: #d7dce6;
  --wash: #f2f5fb;
  --green: #0a6b3d;
  --green-wash: #e9f6ef;
  --red: #ba1a1a;
  --red-wash: #fdf0ef;
  --amber: #8a5a00;
  --amber-wash: #fdf6e3;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  color: var(--ink); background: #fafbfd; line-height: 1.45; font-size: 16px;
}
a { color: var(--brand); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #0f62fe; outline-offset: 2px;
}

.demo-banner {
  background: var(--brand-dark); color: #fff; padding: 8px 20px;
  font-size: 13.5px; text-align: center;
}
.demo-banner strong { color: #ffd166; }

header.site {
  background: #fff; border-bottom: 3px solid var(--brand);
  padding: 14px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.wordmark {
  background: var(--brand); color: #fff; font-weight: 800; letter-spacing: -0.5px;
  padding: 5px 13px; border-radius: 7px; font-size: 19px; text-decoration: none;
}
header.site .title { font-size: 17px; font-weight: 700; color: var(--brand-dark); }
header.site .subtitle { font-size: 13px; color: var(--muted); }
header.site nav { margin-left: auto; display: flex; gap: 14px; font-size: 14.5px; }

main { max-width: 1080px; margin: 0 auto; padding: 26px 24px 60px; }

h1 { font-size: 27px; color: var(--brand-dark); letter-spacing: -0.3px; margin-bottom: 6px; }
h2 { font-size: 20px; color: var(--brand-dark); margin: 26px 0 10px; }
h3 { font-size: 16px; color: var(--brand-dark); margin: 16px 0 6px; }
p.lede { font-size: 17px; color: var(--muted); max-width: 62ch; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 20px 0; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.metric .value { font-size: 26px; font-weight: 800; color: var(--brand-dark); }
.metric .label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line);
        border-radius: 10px; overflow: hidden; font-size: 14.5px; margin: 10px 0 18px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--wash); color: var(--brand-dark); font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.chip.high { background: var(--red-wash); color: var(--red); }
.chip.medium { background: var(--amber-wash); color: var(--amber); }
.chip.low { background: var(--green-wash); color: var(--green); }
.chip.pending { background: var(--wash); color: var(--brand-dark); }
.chip.approved { background: var(--green-wash); color: var(--green); }
.chip.rejected { background: #eee; color: #555; }
.chip.fail { background: var(--red-wash); color: var(--red); }
.chip.pass { background: var(--green-wash); color: var(--green); }

.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin: 14px 0; }
.callout { background: var(--wash); border-left: 4px solid var(--brand); border-radius: 0 8px 8px 0;
           padding: 12px 16px; margin: 14px 0; font-size: 14.5px; }

.finding { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin: 14px 0; overflow: hidden; }
.finding-head { display: flex; align-items: center; gap: 12px; padding: 13px 18px; flex-wrap: wrap; }
.finding-head .fid { font-weight: 800; color: var(--brand-dark); font-size: 15px; }
.finding-head .ftitle { font-weight: 600; flex: 1; min-width: 240px; }
.finding-body { border-top: 1px solid var(--line); padding: 14px 18px; display: grid; gap: 10px; }
.trace { display: grid; grid-template-columns: 130px 1fr; gap: 4px 14px; font-size: 14px; }
.trace dt { font-weight: 700; color: var(--brand-dark); }
.trace dd { margin: 0; }
.clause { background: var(--wash); border: 1px dashed var(--line); border-radius: 6px;
          padding: 9px 12px; font-family: Georgia, serif; font-size: 14px; font-style: italic; }
.actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
button {
  font: inherit; font-size: 14px; font-weight: 600; border-radius: 7px; cursor: pointer;
  padding: 7px 15px; border: 1.5px solid var(--line); background: #fff; color: var(--ink);
}
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.approve { background: var(--green); border-color: var(--green); color: #fff; }
button.reject { background: #fff; border-color: var(--red); color: var(--red); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 22px 0 4px; flex-wrap: wrap; }
.tabs button { border: none; border-radius: 8px 8px 0 0; background: transparent; padding: 10px 16px;
               font-size: 15px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: #fff; color: var(--brand-dark); font-weight: 700;
               border: 2px solid var(--line); border-bottom: 2px solid #fff; margin-bottom: -2px; }
[role="tabpanel"] { padding-top: 10px; }
[hidden] { display: none !important; }

.workline { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
            background: #0f172a; color: #d7e3ff; border-radius: 8px; padding: 12px 15px;
            overflow-x: auto; white-space: pre; line-height: 1.55; }
details.work { margin: 8px 0 16px; }
details.work summary { cursor: pointer; font-weight: 600; color: var(--brand); font-size: 14px; padding: 4px 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } .trace { grid-template-columns: 1fr; } }

.audit { font-size: 14px; }
.audit li { margin-bottom: 6px; list-style: none; padding-left: 18px; position: relative; }
.audit li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 8px; height: 8px;
                    border-radius: 50%; background: var(--brand); }
.audit time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }

footer.site { border-top: 1px solid var(--line); background: #fff; margin-top: 40px;
              padding: 20px 24px; font-size: 13px; color: var(--muted); }
footer.site .inner { max-width: 1080px; margin: 0 auto; }
.eng-tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
           color: var(--muted); background: var(--wash); border: 1px solid var(--line);
           border-radius: 6px; padding: 2px 8px; }
.skip-link { position: absolute; left: -9999px; top: 0; background: #fff; color: var(--brand-dark);
             padding: 8px 14px; z-index: 10; }
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- app chrome (v2) ---------- */
header.site .product { font-size: 17px; font-weight: 800; color: var(--brand-dark); letter-spacing: -0.2px; }
.persona { display: flex; align-items: center; gap: 8px; }
.persona select { font: inherit; font-size: 13.5px; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex;
          align-items: center; justify-content: center; font-size: 12.5px; font-weight: 800; flex: none; }
nav.app { display: flex; gap: 2px; margin-left: 18px; }
nav.app a { text-decoration: none; color: var(--muted); font-size: 14.5px; padding: 7px 13px; border-radius: 8px; }
nav.app a[aria-current="page"] { background: var(--wash); color: var(--brand-dark); font-weight: 700; }

/* queue */
.queue-filters { display: flex; gap: 8px; margin: 14px 0 4px; }
.pill { font: inherit; font-size: 13.5px; font-weight: 600; border: 1.5px solid var(--line); background: #fff;
        border-radius: 999px; padding: 5px 14px; cursor: pointer; color: var(--muted); }
.pill[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
tr.me { background: #f6f8ff; }
tr.me td:first-child { border-left: 3px solid var(--brand); }
a.caselink { font-weight: 700; }
.muted { color: var(--muted); }

/* case header + stepper */
.case-head { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; margin: 16px 0; }
.case-head .row { display: flex; gap: 26px; flex-wrap: wrap; font-size: 14px; }
.case-head .kv b { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 700; }
.stepper { display: flex; flex-wrap: wrap; gap: 0; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.step { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); padding-right: 18px; margin-right: 4px; position: relative; }
.step .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); background: #fff;
             display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: var(--muted); flex: none; }
.step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.step.current { color: var(--brand-dark); font-weight: 700; }
.step.current .dot { border-color: var(--brand); color: var(--brand); }
.step:not(:last-child)::after { content: "›"; margin-left: 14px; color: var(--line); font-size: 15px; }

/* documents tab */
.docviewer { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 12px; }
@media (max-width: 860px) { .docviewer { grid-template-columns: 1fr; } }
.docpage { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 22px 26px;
           font-family: Georgia, 'Times New Roman', serif; font-size: 14.5px; line-height: 1.6; }
.docpage h4 { font-family: inherit; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: #444; margin: 14px 0 6px; }
.docpage .pageno { text-align: center; color: #999; font-size: 12px; margin-top: 16px; }
mark.flag { background: #fff1b8; border-bottom: 2px solid var(--amber); padding: 1px 2px; }
.extract-rail .item { border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 0 8px 8px 0;
                      background: #fff; padding: 10px 13px; margin-bottom: 10px; font-size: 13.5px; }
.extract-rail .item b { color: var(--brand-dark); }

/* workpaper */
.workpaper { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 30px 36px; margin-top: 12px;
             font-family: 'Times New Roman', Georgia, serif; font-size: 15px; line-height: 1.5; }
.workpaper .wp-head { text-align: center; margin-bottom: 14px; }
.workpaper .wp-head .form { font-size: 12.5px; color: #555; display: flex; justify-content: space-between; }
.workpaper h4 { font-size: 15px; margin: 16px 0 4px; text-decoration: underline; }
.workpaper table.wp-meta { font-family: inherit; font-size: 14px; border: 1.5px solid #333; margin: 10px 0 16px; }
.workpaper table.wp-meta td { border: 1px solid #333; padding: 4px 8px; }
.workpaper .draft-stamp { color: #b23; border: 2px solid #b23; display: inline-block; padding: 2px 12px;
                          font-weight: 700; transform: rotate(-2deg); letter-spacing: 2px; margin-bottom: 8px; }
.wp-issue { border-top: 1px dashed #999; padding-top: 12px; margin-top: 14px; }
.wp-flag { font-size: 12.5px; font-family: -apple-system, Arial, sans-serif; }

/* review queue (manager) */
.rq-empty { border: 1.5px dashed var(--line); border-radius: 10px; padding: 26px; text-align: center; color: var(--muted); background: #fff; }
.bars { display: grid; gap: 7px; margin: 12px 0 4px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 40px; align-items: center; gap: 10px; font-size: 13.5px; }
.bar-track { background: var(--wash); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { background: var(--brand); height: 100%; border-radius: 6px; }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
