:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #14181f; --muted: #5d6673; --line: #e2e5ea;
  --accent: #1f6feb; --accent-ink: #ffffff; --soft: #eef3fd;
  --high: #c62f2f; --medium: #b86e00; --low: #5d6673; --ok: #1d7f4e;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --panel: #161b22; --ink: #e6e9ee; --muted: #9aa4b2; --line: #262d37;
    --accent: #4c8dff; --accent-ink: #0b0f15; --soft: #172235;
    --high: #ff6b6b; --medium: #f0a640; --low: #9aa4b2; --ok: #46c38a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: 0.9em; }
pre { background: var(--soft); padding: 12px; border-radius: 8px; overflow-x: auto; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-weight: 650; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.topbar nav { display: flex; gap: 16px; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { color: var(--ink); }
main { flex: 1; min-height: 0; }

.layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; padding: 16px; height: 100%; }
.side { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
select, input, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.stats div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.bad { color: var(--high); } .warn { color: var(--medium); }
.fine { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.findings { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.findings li { font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--bg); border-left: 3px solid var(--low); }
.findings li.sev-high { border-left-color: var(--high); }
.findings li.sev-medium { border-left-color: var(--medium); }
.findings .badge { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: 4px; }
.findings .when { display: block; color: var(--muted); font-family: var(--mono); font-size: 11px; }

.chat-panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.chat { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.intro h1 { margin: 0 0 6px; font-size: 22px; }
.intro p { color: var(--muted); max-width: 62ch; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { font: inherit; font-size: 13px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; text-align: left; }
.chip:hover { border-color: var(--accent); }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); width: 85%; }
.msg.error { align-self: center; color: var(--high); font-size: 13px; }
.steps { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.steps li { font-family: var(--mono); font-size: 11.5px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }
.steps li.pending { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.content.streaming { white-space: pre-wrap; }
.content h3 { font-size: 15px; margin: 16px 0 4px; }
.content table { border-collapse: collapse; } .content td, .content th { border: 1px solid var(--line); padding: 4px 8px; }
.meta { font-size: 12px; color: var(--muted); margin-top: 6px; }

.composer { border-top: 1px solid var(--line); padding: 12px 16px; }
.composer textarea { resize: vertical; min-height: 52px; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
button { font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px; border: 1px solid transparent; }
button:disabled { opacity: .5; cursor: progress; }
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary { background: var(--soft); color: var(--accent); border-color: var(--line); }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); text-decoration: none; font-size: 14px; padding: 8px 12px; border-radius: 8px; }
.small { padding: 3px 8px; font-size: 12px; }

.page { max-width: 920px; margin: 0 auto; padding: 24px 16px 48px; }
.prose { line-height: 1.65; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0 20px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.inline { flex: 1; min-width: 260px; }
.narrow { max-width: 360px; }
.empty { padding: 20px; color: var(--muted); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .chat-panel { min-height: 75vh; }
  .msg, .msg.assistant { max-width: 100%; width: auto; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
