:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #697586;
  --line: #e2e7ee;
  --brand: #1f3b5c;
  --brand-soft: #eef3f8;
  --red: #b42318;
  --red-bg: #fff1f0;
  --amber: #9a6700;
  --amber-bg: #fff7df;
  --green: #157347;
  --green-bg: #edf8f2;
  --blue: #245b89;
  --blue-bg: #eef5fb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .03);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 70px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display:grid; place-items:center;
  background: var(--brand); color:white; font-weight:800;
}
.brand-name { font-weight: 800; letter-spacing: .08em; font-size: 14px; }
.brand-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.project-switcher {
  display:flex; align-items:center; gap:10px; padding:8px 14px; border:1px solid var(--line);
  border-radius:10px; background:white;
}
.project-switcher strong { display:block; font-size:13px; }
.project-switcher span { display:block; color:var(--muted); font-size:11px; margin-top:2px; }
.project-dot { width:8px; height:8px; border-radius:50%; background:#d12727; }
.profile { justify-self:end; border:0; width:34px; height:34px; border-radius:50%; background:#eef2f6; font-weight:700; }

.shell { max-width: 1500px; margin: 0 auto; padding: 34px 30px 60px; }
.hero { display:flex; align-items:flex-end; justify-content:space-between; gap:24px; margin-bottom:24px; }
.hero h1 { margin:5px 0 6px; font-size:30px; letter-spacing:-.03em; }
.hero p { margin:0; color:var(--muted); }
.hero-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.eyebrow { text-transform:uppercase; letter-spacing:.1em; color:var(--muted); font-size:11px; font-weight:800; }

.card {
  background:var(--panel); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow);
  padding:22px; margin-bottom:18px;
}
.card h2 { margin:4px 0 0; font-size:18px; letter-spacing:-.015em; }
.section-head { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:18px; }
.subtle { color:var(--muted); font-size:12px; }

.koa { display:grid; grid-template-columns:44px 1fr; gap:16px; border-color:#d7e1eb; }
.koa-icon { width:44px; height:44px; border-radius:12px; display:grid; place-items:center; background:var(--brand-soft); color:var(--brand); font-weight:800; }
.koa-copy h2 { margin:3px 0 5px; }
.koa-copy p { color:var(--muted); margin:0; line-height:1.5; }
.prompt-row { display:flex; gap:8px; margin-top:15px; }
.prompt-row input { flex:1; min-width:0; border:1px solid var(--line); border-radius:9px; padding:11px 12px; outline:none; }
.prompt-row input:focus { border-color:#8fa9c0; box-shadow:0 0 0 3px #eef4f8; }
.primary-button, .secondary-button { border-radius:9px; padding:10px 13px; font-weight:700; }
.primary-button { border:1px solid var(--brand); color:white; background:var(--brand); }
.secondary-button { border:1px solid var(--line); color:var(--text); background:white; }
.koa-response { margin-top:14px; padding:12px 14px; border-radius:9px; background:#f7f9fb; color:#334155; line-height:1.55; }

.lifecycle { display:grid; grid-template-columns:repeat(9,1fr); gap:8px; }
.life-step { position:relative; color:#929eac; font-size:11px; min-width:0; }
.life-step::before { content:""; position:absolute; top:5px; left:7px; right:-12px; height:1px; background:#dfe5eb; z-index:0; }
.life-step:last-child::before { display:none; }
.life-dot { position:relative; z-index:1; display:block; width:11px; height:11px; border-radius:50%; background:#d6dde5; margin-bottom:8px; }
.life-step.active { color:#344256; font-weight:700; }
.life-step.active .life-dot { background:var(--brand); }

.main-grid { display:grid; grid-template-columns:minmax(0,1fr) 330px; gap:18px; align-items:start; }
.side-column { position:sticky; top:88px; }

.battle-list { display:grid; gap:10px; }
.battle-item { display:grid; grid-template-columns:minmax(0,1.4fr) minmax(180px,.8fr) minmax(180px,.8fr); gap:16px; padding:15px 0; border-top:1px solid var(--line); }
.battle-item:first-child { border-top:0; padding-top:0; }
.battle-title { display:flex; align-items:center; gap:7px; flex-wrap:wrap; }
.battle-title h3 { margin:0 5px 0 0; font-size:15px; }
.battle-main p, .battle-action span { color:var(--muted); font-size:12px; line-height:1.5; }
.battle-main p { margin:7px 0 0; }
.battle-action { display:flex; flex-direction:column; gap:5px; font-size:12px; }

.alignment-list { display:grid; }
.alignment-row { display:flex; justify-content:space-between; gap:20px; padding:14px 0; border-top:1px solid var(--line); }
.alignment-row:first-child { border-top:0; padding-top:0; }
.alignment-row p { color:var(--muted); margin:4px 0 0; font-size:12px; }
.alignment-meta { min-width:190px; display:flex; align-items:center; justify-content:flex-end; gap:10px; color:var(--muted); font-size:11px; }

.cap-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
.cap-card { border:1px solid var(--line); border-radius:11px; padding:15px; }
.cap-card h3 { margin:0 0 12px; font-size:14px; }
.cap-row { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:29px; border-top:1px solid #f0f2f5; font-size:12px; }
.cap-row:first-of-type { border-top:0; }
.text-button { background:none; border:0; padding:8px 0 0; color:var(--blue); font-weight:700; font-size:12px; }

.compact-card h2 { font-size:17px; }
.check-list { display:grid; gap:9px; }
.check-row { display:grid; grid-template-columns:22px 1fr auto; align-items:center; gap:8px; font-size:12px; }
.check-icon { width:20px; height:20px; border-radius:50%; background:#f1f3f6; display:grid; place-items:center; color:#929eac; }
.check-icon.ok { background:var(--green-bg); color:var(--green); }
.output-list { display:grid; margin-top:12px; }
.output-list button { display:flex; justify-content:space-between; align-items:center; padding:11px 0; border:0; border-top:1px solid var(--line); background:none; text-align:left; font-size:12px; }
.output-list button:first-child { border-top:0; }
.metric { display:flex; justify-content:space-between; border-top:1px solid var(--line); padding:11px 0; font-size:12px; }
.metric:first-of-type { margin-top:10px; }
.metric span { color:var(--muted); }

.badge { display:inline-flex; align-items:center; min-height:22px; padding:3px 8px; border-radius:999px; font-size:10px; font-weight:800; white-space:nowrap; }
.badge-neutral { background:#f2f4f6; color:#5c6674; }
.badge-red { background:var(--red-bg); color:var(--red); }
.badge-red-outline { background:white; color:var(--red); border:1px solid #f0b6b1; }
.badge-amber { background:var(--amber-bg); color:var(--amber); }
.badge-green { background:var(--green-bg); color:var(--green); }
.badge-blue { background:var(--blue-bg); color:var(--blue); }

.drawer-backdrop { position:fixed; inset:0; background:rgba(15,23,42,.22); z-index:40; }
.drawer { position:fixed; top:0; right:0; bottom:0; width:min(460px,92vw); background:white; z-index:50; padding:24px; box-shadow:-18px 0 50px rgba(15,23,42,.15); }
.drawer-head { display:flex; justify-content:space-between; align-items:center; border-bottom:1px solid var(--line); padding-bottom:18px; }
.drawer-head h2 { margin:4px 0 0; }
.icon-button { border:1px solid var(--line); background:white; width:34px; height:34px; border-radius:8px; font-size:20px; }
.drawer-body { margin-top:12px; }
.drawer-row { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:13px 0; border-top:1px solid var(--line); font-size:13px; }
.drawer-row:first-child { border-top:0; }

@media (max-width: 1080px) {
  .main-grid { grid-template-columns:1fr; }
  .side-column { position:static; display:grid; grid-template-columns:repeat(2,1fr); gap:18px; }
  .side-column .card { margin-bottom:0; }
  .cap-grid { grid-template-columns:repeat(2,1fr); }
  .battle-item { grid-template-columns:1fr; gap:8px; }
  .lifecycle { grid-template-columns:repeat(3,1fr); row-gap:18px; }
  .life-step::before { display:none; }
}
@media (max-width: 700px) {
  .topbar { grid-template-columns:1fr auto; padding:0 16px; }
  .project-switcher { display:none; }
  .shell { padding:22px 14px 40px; }
  .hero { align-items:flex-start; flex-direction:column; }
  .hero h1 { font-size:25px; }
  .prompt-row { flex-direction:column; }
  .cap-grid, .side-column { grid-template-columns:1fr; }
  .alignment-row { flex-direction:column; }
  .alignment-meta { justify-content:flex-start; min-width:0; }
  .lifecycle { grid-template-columns:repeat(2,1fr); }
}

.top-actions { justify-self:end; display:flex; align-items:center; gap:10px; }
.lang-switch { display:flex; align-items:center; border:1px solid var(--line); border-radius:9px; overflow:hidden; background:white; }
.lang-switch button { border:0; background:white; color:var(--muted); padding:7px 9px; font-size:11px; font-weight:800; }
.lang-switch button + button { border-left:1px solid var(--line); }
.lang-switch button.active { background:var(--brand); color:white; }
@media (max-width:700px) {
  .top-actions { gap:6px; }
  .lang-switch button { padding:6px 8px; }
}

.source-chip{font-size:11px;font-weight:800;color:var(--brand);background:var(--brand-soft);padding:7px 10px;border-radius:999px}
.finding-box{display:flex;gap:12px;align-items:flex-start;background:#f8fafc;border:1px solid var(--line);border-radius:10px;padding:13px 14px;margin-bottom:16px;font-size:12px;line-height:1.5}
.finding-box strong{white-space:nowrap}.baseline-grid{display:grid;grid-template-columns:1.3fr .8fr .9fr;gap:12px}
.baseline-column{border:1px solid var(--line);border-radius:11px;padding:14px;min-width:0}
.baseline-column-head{display:flex;gap:9px;align-items:flex-start;margin-bottom:10px}.baseline-column-head strong{display:block;font-size:13px}.baseline-column-head small{display:block;color:var(--muted);font-size:10.5px;line-height:1.4;margin-top:3px}
.dot{width:8px;height:8px;border-radius:50%;margin-top:5px;flex:0 0 auto}.dot-green{background:var(--green)}.dot-amber{background:var(--amber)}.dot-red{background:var(--red)}
.tab-list{display:grid}.tab-list button{display:flex;justify-content:space-between;gap:10px;border:0;border-top:1px solid #eef1f4;background:none;padding:8px 0;text-align:left;font-size:11px;color:var(--text)}.tab-list button:first-child{border-top:0}.tab-list button:hover{color:var(--blue)}.tab-stats{color:var(--muted);white-space:nowrap;font-size:10px}
.simple-list{display:flex;flex-wrap:wrap;gap:6px}.simple-list span{padding:5px 7px;border-radius:6px;background:#f5f7f9;color:#465466;font-size:10.5px}
.exceptions-head{margin:20px 0 8px}.exceptions-head h3{margin:4px 0 0;font-size:15px}.exception-list{border-top:1px solid var(--line)}
.exception-row{display:grid;grid-template-columns:150px minmax(0,1.2fr) minmax(0,1fr) minmax(0,1fr);gap:14px;padding:12px 0;border-bottom:1px solid var(--line);font-size:11px}.exception-row p{margin:4px 0 0;color:var(--muted);line-height:1.45}.exception-id span{display:block;color:var(--muted);margin-top:3px}.mini-label{text-transform:uppercase;letter-spacing:.08em;font-size:9px;font-weight:800;color:var(--muted)}
.baseline-detail{background:white;border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow);padding:20px;margin-bottom:18px}.baseline-detail-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}.baseline-detail-head h3{margin:3px 0 0}.detail-row{display:grid;grid-template-columns:1.2fr 1fr 1fr 1fr;gap:14px;border-top:1px solid var(--line);padding:13px 0;font-size:11px}.detail-row p{margin:4px 0 0;color:var(--muted);line-height:1.45}
@media(max-width:1080px){.baseline-grid{grid-template-columns:1fr}.exception-row,.detail-row{grid-template-columns:1fr 1fr}}@media(max-width:700px){.exception-row,.detail-row{grid-template-columns:1fr}.finding-box{flex-direction:column;gap:4px}}

.loading-card{color:var(--muted);min-height:100px;display:flex;align-items:center}.error-text{color:var(--red)}
.workflow-card{margin-top:2px}.spec-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.spec-field{display:flex;flex-direction:column;gap:6px}.spec-field span{font-size:10px;text-transform:uppercase;letter-spacing:.08em;font-weight:800;color:var(--muted)}
.spec-field input,.spec-field select,.gap-toolbar input,.gap-toolbar select{width:100%;border:1px solid var(--line);border-radius:8px;background:white;padding:9px 10px;color:var(--text);outline:none}
.spec-field input:focus,.spec-field select:focus,.gap-toolbar input:focus,.gap-toolbar select:focus{border-color:#8fa9c0;box-shadow:0 0 0 3px #eef4f8}
.input-note{margin:14px 0 0;color:var(--muted);font-size:11px;line-height:1.5}
.reference-strip{display:grid;grid-template-columns:1fr 60px 1fr;align-items:center;gap:18px}.reference-strip h2{font-size:16px}.reference-strip p{margin:6px 0 0;color:var(--muted);font-size:11px;line-height:1.5}.reference-arrow{text-align:center;font-size:26px;color:#9aa6b2}
.scope-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.scope-item{display:flex;align-items:flex-start;gap:8px;border:1px solid var(--line);border-radius:9px;padding:9px;background:#fafbfc;cursor:pointer}.scope-item.active{background:#f5f9fc;border-color:#bfcfdd}.scope-item input{margin-top:2px}.scope-item strong{display:block;font-size:11px}.scope-item small{display:block;margin-top:3px;color:var(--muted);font-size:9.5px}
.matrix-kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:18px}.matrix-kpi{background:white;border:1px solid var(--line);border-radius:12px;padding:16px;box-shadow:var(--shadow)}.matrix-kpi span{display:block;color:var(--muted);font-size:10px;text-transform:uppercase;letter-spacing:.06em}.matrix-kpi strong{display:block;font-size:25px;margin-top:6px}.matrix-kpi.green strong{color:var(--green)}.matrix-kpi.red strong{color:var(--red)}
.gap-toolbar{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:10px;margin-bottom:12px}.gap-table-wrap{overflow:auto;border:1px solid var(--line);border-radius:10px}.gap-table{width:100%;border-collapse:collapse;min-width:1120px}.gap-table th{position:sticky;top:0;background:#f7f9fb;text-align:left;font-size:10px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);padding:10px;border-bottom:1px solid var(--line)}.gap-table td{vertical-align:top;padding:11px 10px;border-bottom:1px solid #eef1f4;font-size:11px;line-height:1.45}.gap-table tr:last-child td{border-bottom:0}.gap-table th:nth-child(1){width:180px}.gap-table th:nth-child(3){width:130px}.gap-table th:nth-child(4){width:210px}.gap-table th:nth-child(5){width:240px}
.gap-id{display:block;color:var(--muted);margin-top:3px}.confidence{display:inline-block;margin-top:6px;padding:2px 6px;border-radius:999px;background:#f1f4f7;color:#667085;font-size:9px}.req-text{font-weight:600}.historical-comment{margin-top:6px;padding:6px 7px;border-left:2px solid #d7dee7;background:#fafbfc;color:#667085;font-size:10px}.empty-cell{text-align:center;color:var(--muted);padding:30px!important}.load-more{margin-top:12px}.source-foot p{margin:6px 0;color:var(--muted);font-size:11px;line-height:1.5}
@media(max-width:1000px){.spec-grid,.scope-grid{grid-template-columns:repeat(2,1fr)}.matrix-kpis{grid-template-columns:repeat(2,1fr)}.reference-strip{grid-template-columns:1fr}.reference-arrow{transform:rotate(90deg)}}
@media(max-width:650px){.spec-grid,.scope-grid,.matrix-kpis{grid-template-columns:1fr}.gap-toolbar{grid-template-columns:1fr}.reference-strip{gap:8px}}

.export-card{border-color:#cbd8e4}.export-explain{margin:-4px 0 16px;color:var(--muted);font-size:11px;line-height:1.55}
.export-source-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.source-file{border:1px solid var(--line);border-radius:10px;padding:12px;background:#fafbfc;display:flex;flex-direction:column;gap:4px}
.source-file span{font-size:9px;text-transform:uppercase;letter-spacing:.08em;font-weight:800;color:var(--muted)}
.source-file strong{font-size:12px;margin-bottom:5px}.source-file input{font-size:10px;color:var(--muted)}
.export-actions{display:flex;align-items:center;gap:14px;margin-top:14px}.export-status{color:var(--muted);font-size:10.5px;line-height:1.45}
.primary-button:disabled{opacity:.55;cursor:not-allowed}
@media(max-width:650px){.export-source-grid{grid-template-columns:1fr}.export-actions{align-items:flex-start;flex-direction:column}}

.scope-item.out-of-scope{
  background:#f4f5f7;
  border-color:#d9dee5;
  opacity:.78;
  cursor:default;
}
.scope-item.out-of-scope strong{color:#667085}
.scope-item.out-of-scope small{color:#7a8492}
.scope-item.out-of-scope input{accent-color:#98a2b3}
