:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #5f6b7a;
  --border: #dde2e8;
  --accent: #1f4fd1;
  --accent-soft: #e8eefc;
  --cra: #0f766e;
  --ai: #7c3aed;
  --critical: #b42318;
  --high: #c2410c;
  --medium: #a16207;
  --low: #4b5563;
  --ok: #15803d;
  --progress: #2563eb;
  --na: #9ca3af;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --surface: #1a2029;
    --text: #e6e9ee;
    --muted: #9aa5b4;
    --border: #2c3542;
    --accent: #7aa2ff;
    --accent-soft: #1f2a44;
    --cra: #2dd4bf;
    --ai: #a78bfa;
    --critical: #f87171;
    --high: #fb923c;
    --medium: #facc15;
    --low: #9ca3af;
    --ok: #4ade80;
    --progress: #60a5fa;
    --na: #6b7280;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; margin: 0.4em 0; }
h2 { font-size: 1.25rem; margin: 1.6em 0 0.6em; }
h3 { font-size: 1.05rem; margin: 0 0 0.4em; }
h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 1.1em 0 0.3em; }
code { background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.d-block { display: block; }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: #fff; margin-right: 4px;
}
.topbar nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.container { max-width: 1180px; margin: 0 auto; padding: 16px 24px 48px; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 24px; border-top: 1px solid var(--border); }

.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-small { padding: 6px 12px; font-size: 0.88rem; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--critical); border: 1px solid var(--critical); }

.flash { padding: 10px 14px; border-radius: 8px; margin: 8px 0; border: 1px solid var(--border); background: var(--surface); }
.flash-success { border-color: var(--ok); }
.flash-error { border-color: var(--critical); }
.flash-warning { border-color: var(--medium); }

.hero {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; margin: 12px 0 8px;
}
.hero p { max-width: 640px; color: var(--muted); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card-link { color: inherit; }
.card-link:hover { text-decoration: none; border-color: var(--accent); }
.empty { padding: 24px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.note { background: var(--accent-soft); border-radius: var(--radius); padding: 4px 16px; font-size: 0.9rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { margin-bottom: 6px; }
.crumbs { margin: 8px 0 0; font-size: 0.9rem; }

.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  border: 1px solid currentColor; white-space: nowrap; vertical-align: middle;
}
.badge-reg { color: var(--accent); }
.badge-reg-cra { color: var(--cra); }
.badge-reg-ai_act { color: var(--ai); }
.badge-critical { color: var(--critical); }
.badge-high { color: var(--high); }
.badge-medium { color: var(--medium); }
.badge-low { color: var(--low); }
.tag { display: inline-block; font-size: 0.78rem; background: var(--accent-soft); border-radius: 6px; padding: 1px 7px; margin: 0 4px 4px 0; }

/* Forms */
.form { max-width: 720px; display: grid; gap: 14px; }
.form-wide { max-width: none; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 0.9rem; }
input, select, textarea {
  font: inherit; font-weight: 400; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; margin-bottom: 4px; }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.choice-card, .role {
  display: flex; gap: 10px; align-items: flex-start; font-weight: 400; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
}
.choice-card:has(input:checked), .role:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice-card input, .role input { margin-top: 4px; }
.role-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.scope-section h3 { margin-top: 1.2em; }
.question { padding: 10px 0; border-top: 1px solid var(--border); }
.question-text { margin: 0 0 4px; font-weight: 600; }
.question select { max-width: 520px; width: 100%; }
.inline-options { display: flex; gap: 18px; }
.inline-options label { display: flex; gap: 6px; align-items: center; font-weight: 400; }

/* Assessment */
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.actions form { margin: 0; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 16px 0; }
.stat { font-size: 2rem; font-weight: 700; line-height: 1.1; margin-bottom: 6px; }
.progress { display: flex; align-items: center; gap: 8px; }
.progress-track { flex: 1; height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; background: var(--ok); transition: width .3s; }
.progress-label { font-size: 0.8rem; color: var(--muted); min-width: 38px; text-align: right; }
.status-counts { list-style: none; padding: 0; margin: 10px 0 0; font-size: 0.85rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot-not_started { background: var(--border); }
.dot-in_progress { background: var(--progress); }
.dot-implemented { background: var(--ok); }
.dot-not_applicable { background: var(--na); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; }
.timeline li { display: grid; grid-template-columns: 96px 1fr; gap: 8px; padding: 3px 0; }
.timeline li.past { color: var(--muted); }
.timeline-date { font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 22px 0 6px; }
.filters input[type=search] { min-width: 200px; }

.group-title { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.req {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: var(--radius); margin-bottom: 8px;
}
.req summary {
  display: flex; gap: 12px; align-items: center; padding: 12px 16px; cursor: pointer; list-style: none;
}
.req summary::-webkit-details-marker { display: none; }
.req summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.req[open] summary::before { transform: rotate(90deg); }
.req-id { font-family: ui-monospace, monospace; font-size: 0.8rem; color: var(--muted); min-width: 84px; }
.req-title { flex: 1; font-weight: 600; }
.req-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.status-pill { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: var(--border); white-space: nowrap; }
.status-in_progress { background: var(--progress); color: #fff; }
.status-implemented { background: var(--ok); color: #fff; }
.status-not_applicable { background: var(--na); color: #fff; }
.task-count { font-size: 0.75rem; color: var(--muted); min-width: 30px; text-align: right; }
.req-body { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; padding: 0 16px 16px 40px; }
.req-side { border-left: 1px solid var(--border); padding-left: 18px; font-size: 0.9rem; }
.article { color: var(--muted); font-size: 0.85rem; margin: 0; }
.applies-now { color: var(--critical); font-weight: 600; }
.applies-later { color: var(--muted); }
.tasks { list-style: none; padding: 0; margin: 0; }
.tasks li { margin-bottom: 4px; }
.tasks label { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 0.95rem; }
.tasks input { margin-top: 5px; }
.tasks label:has(input:checked) { color: var(--muted); text-decoration: line-through; }
.reasons, .related, .evidence { padding-left: 18px; margin: 0; }
.tracking { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0 10px; }
.tracking .grow { grid-column: 1 / -1; }

@media (max-width: 760px) {
  .container { padding: 12px 16px 40px; }
  .topbar { padding: 10px 16px; }
  .req-body { grid-template-columns: 1fr; padding-left: 16px; }
  .req-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); }
  .tracking, .two-col { grid-template-columns: 1fr; }
  .req summary { flex-wrap: wrap; }
}

/* Sign-in and user management */
.devbar { background: #fff4cc; color: #5c4400; text-align: center; padding: 6px 12px; font-size: 0.85rem; border-bottom: 1px solid #e8d48a; }
.auth-box { max-width: 420px; margin: 24px auto; }
.auth-box .form { max-width: none; }
.nav-menu { position: relative; }
.nav-menu summary { cursor: pointer; list-style: none; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; display: grid; gap: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.15);
}
.nav-menu-list p { margin: 0; word-break: break-all; }
.nav-menu-list form { margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }
.admin-card { margin-bottom: 14px; }
.admin-card summary { cursor: pointer; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 12px; }
.form-row label { min-width: 180px; }
form.inline-action { display: inline; margin: 0; }
.temp-password code, .invite-link code { user-select: all; word-break: break-all; }
.table-scroll { overflow-x: auto; margin: 12px 0; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Projects: tabs, work items, gap analysis, export */
:root {
  --st-in_place: #15803d; --st-in_progress: #2563eb; --st-partial: #d97706;
  --st-missing: #dc2626; --st-not_assessed: #cbd5e1; --st-not_applicable: #94a3b8;
}
@media (prefers-color-scheme: dark) {
  :root { --st-in_place: #22c55e; --st-in_progress: #60a5fa; --st-partial: #f59e0b;
          --st-missing: #f87171; --st-not_assessed: #475569; --st-not_applicable: #64748b; }
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 12px 0 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.stat-label { font-size: 0.9rem; font-weight: 400; color: var(--muted); }
.howto { font-size: 0.9rem; margin: 12px 0; }

.state-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--border); gap: 1px; margin: 6px 0; }
.seg { display: block; min-width: 3px; }
.seg-in_place { background: var(--st-in_place); }
.seg-in_progress { background: var(--st-in_progress); }
.seg-partial { background: var(--st-partial); }
.seg-missing { background: var(--st-missing); }
.seg-not_assessed { background: var(--st-not_assessed); }
.seg-not_applicable { background: var(--st-not_applicable); }
.seg-empty { background: var(--border); }
.legend { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.78rem; color: var(--muted); }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 5px; }

.req-not_assessed { border-left-color: var(--st-not_assessed); }
.req-gap { border-left-color: var(--st-missing); }
.req-in_progress { border-left-color: var(--st-in_progress); }
.req-in_place { border-left-color: var(--st-in_place); }
.req-not_applicable { border-left-color: var(--st-not_applicable); opacity: 0.75; }
.rstate-not_assessed { background: var(--border); }
.rstate-gap { background: var(--st-missing); color: #fff; }
.rstate-in_progress { background: var(--st-in_progress); color: #fff; }
.rstate-in_place { background: var(--st-in_place); color: #fff; }
.rstate-not_applicable { background: var(--st-not_applicable); color: #fff; }
.wstate-pill-missing { background: var(--st-missing); color: #fff; }
.wstate-pill-partial { background: var(--st-partial); color: #fff; }

.obligation summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; margin-top: 8px; }
.obligation p { margin: 6px 0 0; }
.work-items { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.work-item {
  display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 12px; align-items: start;
  padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--st-not_assessed); border-radius: 8px;
}
.wstate-missing { border-left-color: var(--st-missing); }
.wstate-partial { border-left-color: var(--st-partial); }
.wstate-in_progress { border-left-color: var(--st-in_progress); }
.wstate-in_place { border-left-color: var(--st-in_place); }
.wstate-not_applicable { border-left-color: var(--st-not_applicable); opacity: .7; }
.wi-key { font-family: ui-monospace, monospace; font-size: 0.75rem; color: var(--muted); margin-right: 6px; }
.wi-done { margin: 4px 0 0; font-size: 0.88rem; }
.wi-done span { color: var(--muted); font-weight: 600; }
.wi-tags { margin: 6px 0 0; }
.tag-size { font-weight: 700; }
.tag-cond { font-style: italic; }
.wi-actions { margin: 6px 0 0; padding-left: 1.2rem; font-size: 0.88rem; list-style: lower-alpha; }
.wi-actions li { margin: 2px 0; }
.wi-form { display: grid; gap: 6px; margin: 0; }
.wi-form select, .wi-form input { font-size: 0.85rem; padding: 6px 8px; }
.wi-form.saving { opacity: .6; }
.set-all { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin: 10px 0 0; font-size: 0.85rem; }
.set-all label { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.set-all select { font-size: 0.85rem; padding: 4px 8px; }
.req-form { display: grid; gap: 8px; margin-bottom: 8px; }
.req-form label { font-size: 0.8rem; }

.inline-filter { margin-top: 1.4em; }
.inline-filter label { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.gap-table .wide { width: 34%; }
.gap-table .num, .table .num { text-align: right; white-space: nowrap; }
.gap-table tr.top-gap td:first-child { font-weight: 700; }

.export-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.export-form fieldset { display: grid; gap: 6px; }
.radio { display: flex; gap: 8px; align-items: baseline; font-weight: 400; }
.export-help { font-size: 0.9rem; }
.export-help ol { padding-left: 20px; }
.export-help li { margin-bottom: 6px; }

@media (max-width: 760px) {
  .work-item { grid-template-columns: 1fr; }
  .export-layout { grid-template-columns: 1fr; }
}

/* MCP access on the account page */
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 12px; }
.inline-form label { flex: 1 1 200px; }
.snippet { background: var(--surface-2, var(--surface)); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 0.8rem; white-space: pre-wrap; word-break: break-all; }
.token-value { word-break: break-all; font-size: 0.9rem; }
.token-new { border-color: var(--accent, var(--border)); }
.consent-actions { display: flex; gap: 12px; margin-top: 16px; }
