:root {
  --paper: #f3efe6;
  --ink: #1f1b16;
  --muted: #6b6258;
  --line: #d7cfc3;
  --card: #fffaf2;
  --input: #ffffff;
  --accent: #0f6e62;
  --accent-2: #c45c26;
  --pass: #1f7a3a;
  --fail: #b42318;
  --warn: #9a6700;
  --info: #175cd3;
  --shadow: 0 10px 30px rgba(31, 27, 22, 0.08);
  --bubble: #efe8db;
  --bubble-ai: #e7f5f2;
  --header: rgba(255,250,242,0.92);
  --glow: #fff8e8;
}
html[data-theme="dark"] {
  --paper: #141210;
  --ink: #f3efe6;
  --muted: #b4a99c;
  --line: #3d372f;
  --card: #1e1a16;
  --input: #2a251f;
  --accent: #2dd4bf;
  --accent-2: #fb923c;
  --pass: #4ade80;
  --fail: #f87171;
  --warn: #fbbf24;
  --info: #60a5fa;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --bubble: #2a241e;
  --bubble-ai: #16332e;
  --header: rgba(30, 26, 22, 0.94);
  --glow: #2a241e;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Source Sans 3", system-ui, sans-serif;
  background:
    radial-gradient(circle at 10% -10%, var(--glow) 0, transparent 40%),
    var(--paper);
  color: var(--ink);
  min-height: 100vh;
}
body.layout {
  display: grid;
  grid-template-columns: 228px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #1f1b16;
  color: #f3efe6;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { color: #f3efe6; margin-bottom: 22px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a {
  color: #f3efe6;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
}
.sidebar nav a:hover { background: rgba(255,250,242,0.08); text-decoration: none; }
.sidebar nav a.active { background: var(--accent); }
.shell { min-width: 0; }
.title-link { font-weight: 600; color: var(--ink); }
.title-link:hover { color: var(--accent); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono, textarea.scenario, .log {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--header);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.mark {
  background: var(--ink);
  color: var(--paper);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  padding: 4px 7px;
  border-radius: 4px;
}
.top nav { display: flex; gap: 16px; }

.wrap { width: min(1100px, calc(100% - 40px)); margin: 28px auto 64px; }
h1, h2, h3 { margin: 0 0 12px; }
h1 { font-size: 32px; letter-spacing: -0.03em; }
.lede { color: var(--muted); margin-bottom: 22px; max-width: 70ch; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.space { justify-content: space-between; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 20px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 18px; }

.btn, button, input[type=submit] {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}
.btn.secondary, button.secondary, input.secondary {
  background: transparent;
  color: var(--ink);
}
.btn.danger { background: var(--fail); border-color: var(--fail); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.small, button.small { padding: 5px 10px; font-size: 14px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid currentColor;
}
.badge.PASS, .badge.pass { color: var(--pass); background: #e8f6ec; }
.badge.FAIL, .badge.fail { color: var(--fail); background: #fdecea; }
.badge.ERROR, .badge.TIMEOUT, .badge.NOT_COVERED { color: var(--fail); background: #fdecea; }
.badge.PARTIAL, .badge.NOT_RUN, .badge.RUNNING { color: var(--warn); background: #fff6dd; }
.badge.Draft { color: var(--muted); background: #f3efe6; }
.badge.Active { color: var(--accent); background: #e7f5f2; }
.badge.Critical { color: var(--fail); }
.badge.High { color: var(--accent-2); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.table tr:hover td { background: rgba(15, 110, 98, 0.04); }

label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
input[type=text], input[type=number], textarea, select {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
textarea.scenario { min-height: 220px; font-size: 13px; }

.crumbs { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.meta { color: var(--muted); font-size: 14px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; }
.kv b { color: var(--muted); font-weight: 600; }

.log {
  background: #1f1b16;
  color: #f3efe6;
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
  max-height: 360px;
  white-space: pre-wrap;
  font-size: 12.5px;
}

.flashes { width: min(1100px, calc(100% - 40px)); margin: 12px auto 0; }
@media (max-width: 860px) {
  body.layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
}
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 8px; }
.flash-ok { background: #e8f6ec; color: var(--pass); }
.flash-error { background: #fdecea; color: var(--fail); }

.project-card h2 { margin-bottom: 4px; }
.stat { color: var(--muted); }

.ai-box textarea { min-height: 64px; }
.chat { display: grid; gap: 10px; max-height: 360px; overflow: auto; }
.bubble { padding: 10px 12px; border-radius: 10px; background: var(--bubble); white-space: pre-wrap; }
.bubble.assistant { background: var(--bubble-ai); }
.ai-dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  width: min(720px, calc(100% - 32px));
  padding: 18px;
  box-shadow: var(--shadow);
}
.ai-dialog::backdrop { background: rgba(20, 16, 12, 0.55); }
.ai-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.top nav { align-items: center; }

.suggestion { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; }
.busy {
  position: fixed; inset: 0; background: rgba(31,27,22,0.45);
  place-items: center; z-index: 20;
}
.busy[hidden] { display: none !important; }
.busy:not([hidden]) { display: grid; }
.busy-card {
  background: var(--card); padding: 24px; border-radius: 14px; text-align: center;
  box-shadow: var(--shadow);
  max-width: 420px;
}
.busy-card .meta { margin: 0 0 12px; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; margin: 0 auto 12px; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--muted); padding: 20px 0; }
.inline { display: inline; }
.checkboxes { display: grid; gap: 6px; margin: 8px 0 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=text] { width: 240px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
pre.prose { white-space: pre-wrap; font-family: inherit; margin: 0; }
