:root {
  --bg: #f0f3ef;
  --surface: #f7f9f5;
  --panel: #ffffff;
  --ink: #171a16;
  --muted: #5c6b5a;
  --line: #d3dcd0;
  --accent: #8fb872;
  --accent-strong: #2d5a30;
  --accent-bg: #e8f1e0;
  --warn: #c77620;
  --warn-bg: #fff4e6;
  --danger: #b52d2d;
  --danger-bg: #fde8e8;
  --blue: #3d6b96;
  --blue-bg: #e5edf5;
  --purple: #6b4d96;
  --purple-bg: #ede5f5;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(45,58,42,.07);
  --shadow-lg: 0 4px 24px rgba(45,58,42,.1);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; }
body { background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--accent-strong); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

/* Sidebar */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 260px;
  background: #dce5d8; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 24px 18px;
  overflow-y: auto;
}
.brand {
  display: flex; gap: 12px; align-items: center; margin-bottom: 32px;
}
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 10px; background: var(--ink); color: white;
  font-weight: 800; font-size: 16px;
}
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.03em; }

nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-section { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; padding: 20px 12px 6px; }
nav a, .nav-button {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; color: var(--ink);
  font-weight: 600; font-size: 14px; transition: background .15s;
  border: 0; background: transparent; text-align: left; cursor: pointer; width: 100%;
}
nav a:hover, .nav-button:hover { background: rgba(255,255,255,.65); }
nav a.active { background: rgba(255,255,255,.85); color: var(--accent-strong); }
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.sidebar-bottom { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }

/* Main layout */
.shell { margin-left: 260px; padding: 28px 32px; min-height: 100vh; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 28px; gap: 18px; flex-wrap: wrap;
}

/* Typography */
h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 17px; font-weight: 700; }

/* Metrics */
.metrics, .grid { display: grid; gap: 16px; margin-bottom: 18px; }
.metrics { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: 2fr 1fr 1fr; }

/* Panels */
.panel, .metric {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel { padding: 20px; margin-bottom: 18px; overflow-x: auto; }
.metric { padding: 20px; min-height: 100px; display: flex; flex-direction: column; justify-content: center; }
.metric .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 8px; }
.metric .value { font-size: 32px; font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
.metric .value.small-val { font-size: 14px; font-weight: 600; line-height: 1.4; word-break: break-all; }
.wide { min-width: 0; }

/* Panel header */
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 16px;
}

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; }
tr:hover td { background: var(--surface); }

/* Badges */
.status, .severity, .badge {
  display: inline-flex; min-width: 60px; justify-content: center;
  border-radius: 999px; padding: 4px 10px; font-size: 11px;
  font-weight: 700; letter-spacing: .02em;
}
.queued, .pending { background: var(--blue-bg); color: var(--blue); }
.running { background: var(--purple-bg); color: var(--purple); }
.done, .ok { background: var(--accent-bg); color: var(--accent-strong); }
.failed, .timeout { background: var(--danger-bg); color: var(--danger); }
.canceled, .skipped { background: #e8e8e8; color: #666; }
.critical, .high { background: var(--danger-bg); color: var(--danger); }
.medium { background: var(--warn-bg); color: var(--warn); }
.low, .info { background: var(--blue-bg); color: var(--blue); }
.confirmed { background: var(--accent-bg); color: var(--accent-strong); }
.likely { background: var(--purple-bg); color: var(--purple); }
.candidate { background: var(--warn-bg); color: var(--warn); }
.false_positive { background: #e8e8e8; color: #999; }
.approved { background: var(--accent-bg); color: var(--accent-strong); }
.draft { background: var(--blue-bg); color: var(--blue); }
.submitted { background: var(--accent-bg); color: var(--accent-strong); }
.rejected { background: var(--danger-bg); color: var(--danger); }

/* Buttons */
.button {
  border: 1px solid var(--line); background: #f7f9f5; color: var(--ink);
  border-radius: 8px; padding: 9px 16px; font-weight: 700; font-size: 13px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s;
}
.button:hover { background: #eef2eb; }
.button.primary { background: var(--accent-strong); color: white; border-color: var(--accent-strong); }
.button.primary:hover { background: #1f4a23; }
.button.danger { background: var(--danger-bg); color: var(--danger); border-color: #e8a0a0; }
.button.danger:hover { background: #f5d0d0; }
.button.small { padding: 5px 10px; font-size: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Forms */
.form-panel { max-width: 820px; }
.form-panel label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 4px; color: var(--ink); }
.form-panel p { margin: 0 0 16px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fbfcfa; color: var(--ink); font: inherit; font-size: 14px;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { resize: vertical; min-height: 80px; }
.inline-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.inline-form p { margin: 0; }

/* Code */
pre, .code-block {
  white-space: pre-wrap; overflow-wrap: anywhere;
  background: #f3f5f1; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; max-height: 520px;
  overflow: auto; font-size: 13px; line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.small { font-size: 12px; }
.preline { white-space: pre-line; }

/* Prose */
.prose h2 { margin-top: 24px; margin-bottom: 10px; }
.prose h3 { margin-top: 18px; margin-bottom: 8px; font-size: 15px; }
.prose p, .prose ul, .prose ol { margin-bottom: 10px; }
.prose ul, .prose ol { padding-left: 24px; }
.prose table { margin: 12px 0; }
.prose pre { margin: 12px 0; }

/* Progress */
.progress-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden;
  background: #e8ece6; margin-bottom: 14px; }
.progress-bar .seg-done { background: var(--accent-strong); }
.progress-bar .seg-running { background: var(--purple); }
.progress-bar .seg-failed { background: var(--danger); }

/* Tool health grid */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tool-chip {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  background: var(--surface); transition: border-color .15s;
}
.tool-chip span { display: block; color: var(--muted); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.tool-chip strong { font-size: 14px; }
.tool-chip.missing { border-color: #e8a0a0; }
.tool-chip.missing strong { color: var(--danger); }
.tool-chip.ok strong { color: var(--accent-strong); }

/* Step list */
.step-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.step-row {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 10px;
  align-items: center; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 10px 12px; transition: border-color .15s;
}
.step-row:hover { border-color: var(--accent); }

/* Findings detail */
.finding-section { margin-bottom: 16px; }
.finding-section h3 { font-size: 13px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 6px; }
.finding-section .content {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px;
}

/* Alert */
.alert { border-left: 4px solid var(--danger); background: var(--danger-bg);
  padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; color: var(--danger);
  font-weight: 600; }

/* Login */
.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(135deg, #eef2ed 0%, #dce5d8 100%);
}
.login-card {
  width: min(440px, 100%); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; box-shadow: var(--shadow-lg);
}
.login-brand { margin-bottom: 24px; }
.login-card h1 { font-size: 26px; margin-bottom: 20px; }
.login-card .button { width: 100%; justify-content: center; margin-top: 10px; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { position: static; width: auto; }
  .shell { margin-left: 0; padding: 16px; }
  .topbar, .panel-head { flex-direction: column; align-items: flex-start; }
  .metrics, .grid.two, .grid.three { grid-template-columns: 1fr; }
}

/* Report specific */
.report h1 { font-size: 24px; margin-bottom: 16px; }
.report h2 { font-size: 18px; border-bottom: 2px solid var(--accent); padding-bottom: 4px; margin-top: 28px; }
.report h3 { font-size: 15px; margin-top: 16px; }
.report table { margin: 12px 0; font-size: 13px; }
.report table th { background: var(--surface); }