:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --muted: #98a2b3;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --on-accent: #ffffff;
  --green: #067647; --green-soft: #ecfdf3;
  --amber: #b54708; --amber-soft: #fffaeb;
  --red: #b42318;   --red-soft: #fef3f2;
  --violet: #6941c6; --violet-soft: #f4f3ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06);
  --shadow-md: 0 6px 20px rgba(16,24,40,.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1,h2,h3 { color: var(--text); font-weight: 600; margin: 0; }
.muted { color: var(--text-2); }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }
.ti { font-size: 18px; line-height: 1; }

/* Buttons */
button, .btn {
  font-family: inherit; font-size: 14px; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 9px 15px; font-weight: 500;
  background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
button.secondary:hover { background: var(--surface-2); }
button.ghost { background: transparent; color: var(--text-2); border-color: transparent; padding: 6px 10px; }
button.ghost:hover { background: var(--surface-2); }
button.danger { background: transparent; color: var(--red); border-color: var(--border-strong); }
button.danger:hover { background: var(--red-soft); border-color: var(--red); }
button.sm { padding: 6px 11px; font-size: 13px; }
button:disabled { opacity: .55; cursor: not-allowed; }

/* Forms */
input, select, textarea {
  font-family: inherit; font-size: 14px; width: 100%;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 74px; resize: vertical; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin: 12px 0 5px; }

/* Layout */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 58px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 9px; letter-spacing: -.01em; }
.brand .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); }
.brand .ai { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav .navlink { background: transparent; color: var(--text-2); border: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.nav .navlink:hover { background: var(--surface-2); color: var(--text); }
.nav .navlink.active { background: var(--accent-soft); color: var(--accent); }
.nav .who { color: var(--text-2); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.container { max-width: 1000px; margin: 0 auto; padding: 28px 24px 90px; }

/* Auth */
.auth-bg { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-wrap { width: 100%; max-width: 420px; background: var(--surface); padding: 30px; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-md); }
.auth-wrap .brand { justify-content: center; margin-bottom: 6px; font-size: 20px; }
.auth-wrap p.sub { color: var(--text-2); text-align: center; margin: 0 0 22px; }
.auth-tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; background: transparent; color: var(--text-2); box-shadow: none; }
.auth-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Cards & headings */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section-head h2 { font-size: 22px; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 16px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 13px; background: none; border: none; padding: 4px 0; margin-bottom: 10px; }
.back:hover { color: var(--text); background: none; }
.empty { text-align: center; color: var(--text-2); padding: 46px 20px; }
.empty .ti { font-size: 30px; color: var(--muted); display: block; margin-bottom: 10px; }
.error { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 16px; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.type1, .pill.violet { background: var(--violet-soft); color: var(--violet); }
.pill.type2, .pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.success { background: var(--green-soft); color: var(--green); }
.pill.warning { background: var(--amber-soft); color: var(--amber); }
.pill.danger  { background: var(--red-soft); color: var(--red); }
.pill.muted   { background: var(--surface-2); color: var(--text-2); }
.cat-badge { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-weight: 500; }

/* Progress */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.progress.green > span { background: var(--green); }

/* Dashboard audit cards */
.audit-card { cursor: pointer; transition: box-shadow .15s, transform .15s, border-color .15s; }
.audit-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

/* Stepper */
.stepper { display: flex; align-items: flex-start; }
.step { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 0 0 auto; width: 104px; text-align: center; cursor: pointer; }
.step .circle {
  width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 21px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  transition: box-shadow .12s;
}
.step.done .circle { background: var(--green-soft); color: var(--green); border-color: transparent; }
.step.current .circle { background: var(--accent); color: var(--on-accent); border-color: transparent; box-shadow: 0 0 0 4px var(--accent-soft); }
.step .s-name { font-size: 13px; font-weight: 600; color: var(--text); }
.step.todo .s-name { color: var(--text-2); }
.step .s-cap { font-size: 11px; color: var(--muted); }
.step-line { flex: 1 1 auto; min-width: 8px; height: 2px; background: var(--border); margin-top: 22px; }
.step-line.done { background: var(--green); }

.phase-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 22px 2px 14px; }
.phase-head h2 { font-size: 19px; }
.phase-head .ph-sub { font-size: 13px; color: var(--text-2); margin-top: 3px; }

/* Controls (Prove) */
.control { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.control-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; cursor: pointer; }
.control-head:hover { background: var(--surface-2); }
.control-head .cid { font-weight: 600; min-width: 54px; font-variant-numeric: tabular-nums; }
.control-head .ctitle { flex: 1; }
.control-body { padding: 6px 18px 18px; border-top: 1px solid var(--border); }
.control-body h4 { margin: 16px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.examples { margin: 6px 0; padding-left: 20px; }
.examples li { margin: 3px 0; color: var(--text-2); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.st-not_started { background: var(--muted); }
.st-in_progress { background: var(--amber); }
.st-ready_for_review { background: var(--accent); }
.st-accepted { background: var(--green); }
.st-exception { background: var(--red); }
.st-not_applicable { background: var(--border-strong); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.tabs .navlink { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; font-weight: 500; }
.tabs .navlink.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.ev-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; margin: 7px 0; }
.ev-item .meta { flex: 1; font-size: 12px; }
.policy-link { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 11px; margin: 4px 6px 4px 0; color: var(--text); font-size: 13px; }
.policy-link:hover { border-color: var(--accent); color: var(--accent); }

/* Assess walkthrough */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--surface); color: var(--text-2); border: none; border-radius: 0; padding: 6px 13px; font-weight: 500; box-shadow: none; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: none; }
.seg button:hover { background: var(--surface-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.seg button.on.pos { background: var(--green-soft); color: var(--green); }
.seg button.on.neg { background: var(--red-soft); color: var(--red); }
.seg button.on.warn { background: var(--amber-soft); color: var(--amber); }
.seg button.on.neutral { background: var(--surface-2); color: var(--text-2); }
.q-row { padding: 15px 0; border-top: 1px solid var(--border); }
.q-row:first-child { border-top: none; }
.q-row .q-text { font-size: 14px; }
.q-review { margin-top: 10px; }
.q-note { font-size: 12px; margin-top: 9px; display: flex; align-items: center; gap: 5px; }
.sec-head { padding: 16px 18px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.sec-head:hover { background: var(--surface-2); }

/* Gap / Fix cards */
.gap-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--surface); box-shadow: var(--shadow); }
.gap-card .gc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gap-card .gc-body { font-size: 14px; color: var(--text-2); line-height: 1.6; margin: 8px 0 12px; }
.gap-card .gc-fix { font-size: 14px; color: var(--text); line-height: 1.6; margin: 8px 0 12px; }
.gap-card .gc-fix b { font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 600; }

/* Service cards (Add) */
.service-card { display: flex; flex-direction: column; }
.service-card .sc-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.service-card h3 { font-size: 16px; margin-bottom: 6px; }
.service-card p { color: var(--text-2); font-size: 13px; flex: 1; margin: 0 0 14px; }

/* Metric chips */
.metrics { display: flex; gap: 10px; flex-wrap: wrap; }
.metric { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; }
.metric .dot { width: 9px; height: 9px; border-radius: 50%; }

/* Modal */
#modal-root .overlay { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
#modal-root .modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; padding: 24px; box-shadow: var(--shadow-md); }
#modal-root .modal.wide { max-width: 820px; }
.modal h3 { font-size: 18px; }
.policy-body { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; white-space: pre-wrap; font-size: 13px; line-height: 1.6; max-height: 52vh; overflow: auto; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.checkbox-row input { width: auto; }

.toast { position: fixed; bottom: 22px; right: 22px; background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow-md); font-size: 14px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin .8s linear infinite; }
.gen-progress { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--accent); font-weight: 500; padding: 6px 10px; background: var(--accent-soft); border-radius: 8px; }
.gen-progress .bar { flex: 0 0 auto; }
