:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1a2332;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #1d4ed8;
  --accent-soft: #dbeafe;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --gray-soft: #f1f5f9;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }

/* App shell: fixed left sidebar + scrolling work view */
#layout { display: flex; min-height: 100vh; }
#sidebar { width: 240px; min-width: 240px; background: #101828; color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
#content { flex: 1; min-width: 0; }
.brand { display: flex; gap: 10px; align-items: center; cursor: pointer; padding: 16px 16px 12px; color: #fff; font-size: 14px; }
.logo { background: var(--accent); color: #fff; font-weight: 700; border-radius: 8px; padding: 7px 9px; font-size: 14px; }
.brand .sub { color: #64748b; font-size: 10.5px; }
#side-nav { flex: 1; padding: 6px 10px; }
.side-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: #cbd5e1; margin-bottom: 2px; }
.side-item:hover { background: #1c2a44; color: #fff; }
.side-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.side-item .count { margin-left: auto; font-size: 11px; background: #1e293b; border-radius: 999px; padding: 1px 8px; color: #94a3b8; }
.side-item.active .count { background: rgba(255,255,255,.25); color: #fff; }
.side-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 12px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-step { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; color: #cbd5e1; margin-bottom: 1px; }
.side-step:hover { background: #1c2a44; color: #fff; }
.side-step.active { background: var(--accent); color: #fff; font-weight: 600; }
.step-dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #475569; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; flex: none; }
.step-dot.done { background: #16a34a; border-color: #16a34a; color: #fff; }
.side-step.active .step-dot { border-color: #fff; }
.side-job { margin: 4px 12px 8px; padding: 8px 10px; background: #1c2a44; border-radius: 8px; cursor: pointer; }
.sj-label { font-size: 11.5px; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sj-bar { height: 4px; background: #0f172a; border-radius: 2px; margin: 5px 0 3px; overflow: hidden; }
.sj-bar span { display: block; height: 100%; background: #3b82f6; transition: width .5s; }
.sj-msg { font-size: 10px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-bar { height: 8px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.job-bar span { display: block; height: 100%; background: var(--accent); transition: width .5s; }
#side-user { padding: 12px 16px; border-top: 1px solid #1e293b; font-size: 13px; color: #e2e8f0; }
#side-user .row-btns { display: flex; gap: 6px; margin-top: 8px; }
#side-user button { background: #1e293b; color: #cbd5e1; border: none; border-radius: 7px; padding: 6px 10px; cursor: pointer; font-size: 12px; }
#side-user button:hover { background: #334155; color: #fff; }
h1 { font-size: 17px; margin: 0; }
.sub { color: var(--muted); font-size: 12px; }
#user-chip { font-size: 13px; color: var(--muted); padding: 0 4px; }
.auth-card { max-width: 380px; margin: 80px auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.auth-card h2 { margin: 0 0 6px; }
.auth-card input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-top: 10px; box-sizing: border-box; }
.auth-card button.primary { width: 100%; margin-top: 16px; padding: 11px; font-size: 14px; }
.auth-err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
.pill.role-admin { background: #fde68a; color: #92400e; }
.pill.role-editor { background: var(--accent-soft); color: var(--accent); }
.pill.role-viewer { background: var(--gray-soft); color: var(--muted); }
.subtabs { display: flex; gap: 6px; margin: 12px 0; border-bottom: 1px solid var(--line); }
.subtabs button { background: none; border: none; padding: 8px 14px; cursor: pointer; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; }
.subtabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.nav-btn { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 13px; color: var(--ink); }
.nav-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
main { width: 100%; max-width: none; margin: 0; padding: 20px 28px 80px; }

#deadline-banner .banner { margin: 16px 28px 0; padding: 10px 16px; border-radius: var(--radius); font-size: 13px; }
.banner.warn { background: var(--amber-soft); color: var(--amber); border: 1px solid #fcd34d; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.card.clickable:hover { border-color: var(--accent); cursor: pointer; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

button.primary { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-size: 13px; font-weight: 600; }
button.primary:disabled { opacity: .5; cursor: default; }
button.ghost { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--ink); }
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.danger { border-color: var(--red); color: var(--red); }

.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 11.5px; font-weight: 600; }
.pill.MR { background: #ede9fe; color: #6d28d9; }
.pill.CRA { background: #cffafe; color: #0e7490; }
.pill.st-not_started { background: var(--gray-soft); color: var(--muted); }
.pill.st-in_progress { background: var(--amber-soft); color: var(--amber); }
.pill.st-evidence_attached { background: var(--accent-soft); color: var(--accent); }
.pill.st-verified { background: var(--green-soft); color: var(--green); }
.pill.st-not_applicable { background: var(--gray-soft); color: var(--muted); text-decoration: line-through; }
.pill.scope-company { background: #fef9c3; color: #854d0e; }
.pill.scope-product { background: var(--gray-soft); color: var(--muted); }
.pill.v-adequate { background: var(--green-soft); color: var(--green); }
.pill.v-partial { background: var(--amber-soft); color: var(--amber); }
.pill.v-inadequate, .pill.v-no_evidence { background: var(--red-soft); color: var(--red); }

.deadline-chip { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-size: 12.5px; }
.deadline-chip.urgent { border-color: #fcd34d; background: var(--amber-soft); color: var(--amber); }
.readiness { font-weight: 700; font-size: 15px; color: var(--muted); }
.readiness.mid { color: var(--amber); }
.readiness.good { color: var(--green); }
.actions-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.action-chip { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 12px; font-size: 12px; cursor: pointer; font-weight: 600; }
.action-chip:hover { background: var(--accent); color: #fff; }
.progress-bar { height: 8px; border-radius: 4px; background: var(--gray-soft); overflow: hidden; display: flex; margin-top: 8px; }
.progress-bar span { height: 100%; }
.seg-verified { background: #22c55e; }
.seg-evidence { background: #3b82f6; }
.seg-progress { background: #f59e0b; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.filters select, .filters input[type=text] { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px; background: var(--card); }
.filters input[type=text] { flex: 1; min-width: 180px; }

/* requirements tab: chips, view toggle, split layout, table */
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 12.5px; cursor: pointer; color: var(--muted); background: var(--card); white-space: nowrap; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.view-toggle { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-toggle button { border: none; background: var(--card); padding: 6px 12px; cursor: pointer; font-size: 14px; color: var(--muted); }
.view-toggle button.on { background: var(--accent-soft); color: var(--accent); }
.split-wrap { display: grid; grid-template-columns: clamp(260px, 22vw, 380px) minmax(0, 1fr); gap: 10px; align-items: start; }
.rl { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); max-height: 72vh; overflow-y: auto; }
.rl-item { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.rl-item:hover { background: var(--gray-soft); }
.rl-item.selected { background: var(--accent-soft); }
.rl-item .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.rl-text { min-width: 0; }
.rl-id { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-item.selected .rl-id { color: var(--accent); }
.rl-title { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-warn { color: var(--amber); }
.detail-pane { position: sticky; top: 12px; max-height: 86vh; overflow-y: auto; }
.req-table { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; font-size: 13px; overflow: hidden; }
.req-table th { text-align: left; padding: 8px 10px; background: var(--gray-soft); font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.req-table th.sortable { cursor: pointer; }
.req-table th.sortable:hover { color: var(--accent); }
.req-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.req-table tbody tr { cursor: pointer; }
.req-table tbody tr:hover { background: var(--gray-soft); }
.req-table tbody tr.selected { background: var(--accent-soft); }
.req-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.req-head { display: flex; gap: 10px; align-items: center; padding: 12px 16px; cursor: pointer; flex-wrap: wrap; }
.req-head:hover { background: #fafbfd; }
.req-title { font-weight: 600; flex: 1; min-width: 200px; }
.req-body { border-top: 1px solid var(--line); padding: 14px 16px; }
.req-body textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 13px; font-family: inherit; resize: vertical; min-height: 72px; }
textarea.justif { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit; resize: vertical; min-height: 100px; field-sizing: content; max-height: 320px; }
.req-body select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.field { margin: 10px 0; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }

.ev-item { display: flex; gap: 8px; align-items: center; padding: 6px 10px; background: var(--gray-soft); border-radius: 8px; margin: 4px 0; font-size: 13px; }
.ev-item .x { margin-left: auto; cursor: pointer; color: var(--muted); font-weight: 700; }
.ev-item .x:hover { color: var(--red); }

.ai-box { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; margin-top: 10px; background: #f8faff; }
.ai-box.stale { border-left-color: var(--amber); background: #fffdf5; }
.pill.v-partial { background: var(--amber-soft); color: var(--amber); }
.presumption-box { border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 8px; padding: 9px 14px; margin-bottom: 10px; background: #fffdf5; font-size: 13px; }
.presumption-box.ok { border-left-color: #16a34a; background: #f4fdf6; }
.sugg-box { border: 1px dashed var(--accent); border-radius: 8px; padding: 10px 14px; margin: 10px 0; background: #f8faff; }
.sugg-item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sugg-item:last-child { border-bottom: none; }
.sugg-score { font-weight: 700; color: var(--accent); font-size: 13px; min-width: 38px; }
.ai-box ul { margin: 6px 0; padding-left: 20px; }
.ai-box li { margin-bottom: 8px; }
.gap-quote { border-left: 3px solid var(--line); padding: 3px 10px; margin: 4px 0; font-style: italic; color: #475569; font-size: 12.5px; background: var(--gray-soft); border-radius: 0 6px 6px 0; }

.details { background: var(--gray-soft); border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.55; margin-bottom: 10px; color: #334155; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.links a { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 12px; font-size: 12px; text-decoration: none; font-weight: 600; }
.links a:hover { background: var(--accent); color: #fff; }

.xmap { margin-top: 10px; font-size: 12.5px; }
.xmap a { color: var(--accent); cursor: pointer; text-decoration: none; }
.xmap a:hover { text-decoration: underline; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 60px 16px; overflow: auto; }
.modal { background: var(--card); border-radius: 12px; padding: 22px; width: 560px; max-width: 100%; }
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal input[type=text], .modal textarea, .modal select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-size: 13.5px; font-family: inherit; }
.modal .checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.modal .checks label { font-size: 13px; display: flex; gap: 6px; align-items: center; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.attach-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.attach-list label { display: flex; gap: 8px; padding: 6px 8px; font-size: 13px; align-items: flex-start; border-radius: 6px; }
.attach-list label:hover { background: var(--gray-soft); }

/* Help center */
.help-layout { display: flex; gap: 16px; align-items: flex-start; }
.help-nav { width: 230px; min-width: 230px; }
.help-nav input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.help-topic { padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; margin-bottom: 2px; }
.help-topic:hover { background: var(--accent-soft); }
.help-topic.active { background: var(--accent); color: #fff; font-weight: 600; }
.help-body { flex: 1; line-height: 1.6; max-width: 900px; }
.help-body p, .help-body li { font-size: 13.5px; }
.help-body code { background: var(--gray-soft); border-radius: 4px; padding: 1px 5px; font-size: 12px; }

/* Guided tour */
#tour-ring { position: fixed; border: 2px solid var(--accent); border-radius: 10px; box-shadow: 0 0 0 9999px rgba(15,23,42,.55); z-index: 300; pointer-events: none; transition: all .3s ease; }
#tour-pop { position: fixed; background: var(--card); border-radius: 12px; padding: 16px 18px; z-index: 301; box-shadow: 0 10px 40px rgba(0,0,0,.3); font-size: 13.5px; transition: all .3s ease; }
#tour-pop p { margin: 8px 0 12px; line-height: 1.5; }

/* Context help button */
#help-fab { position: fixed; bottom: 22px; right: 22px; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; border: none; font-size: 18px; font-weight: 700; cursor: pointer; box-shadow: 0 4px 14px rgba(29,78,216,.4); z-index: 90; }
#help-fab:hover { background: #1e40af; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 100; }
#toast.show { opacity: 1; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
