:root {
  color-scheme: dark;
  --bg: #090b12;
  --panel: rgba(16, 20, 34, 0.92);
  --panel-2: rgba(23, 30, 48, 0.94);
  --line: rgba(156, 163, 175, 0.22);
  --text: #f8fafc;
  --muted: #aeb8ca;
  --soft: #7dd3fc;
  --brand: #a78bfa;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(167, 139, 250, 0.18), transparent 34rem),
    radial-gradient(circle at top right, rgba(125, 211, 252, 0.16), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button, input, select, textarea, .button {
  font: inherit;
}

button, .button {
  border: 1px solid rgba(167, 139, 250, 0.42);
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  padding: 0.72rem 1rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

button.secondary, .button.secondary {
  background: rgba(15, 23, 42, 0.72);
  color: var(--text);
}

button:hover, .button:hover { filter: brightness(1.08); }

input, select, textarea {
  width: 100%;
  margin-top: 0.38rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.72);
  color: var(--text);
  padding: 0.7rem 0.8rem;
}

textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
label { color: var(--muted); font-size: 0.84rem; font-weight: 700; }
a { color: #93c5fd; }

.hero {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: stretch;
  padding: 2rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.6rem;
  color: var(--soft);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0.5rem; font-size: clamp(2rem, 5vw, 4.5rem); line-height: 0.95; letter-spacing: -0.06em; }
h2 { margin-bottom: 0.7rem; }
h3 { margin-bottom: 0.5rem; }
.subcopy { max-width: 920px; color: var(--muted); font-size: 1.05rem; line-height: 1.55; margin-bottom: 0; }

.hero-card {
  min-width: 220px;
  display: grid;
  align-content: center;
  gap: 0.2rem;
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.hero-card strong { font-size: 3rem; line-height: 1; }
.hero-card span, .hero-card small { color: var(--muted); }

.shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 380px;
  gap: 1rem;
  padding: 1rem;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.sidebar, .workspace, .detail { display: grid; gap: 1rem; }
.sidebar { position: sticky; top: 1rem; }
.detail { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }

.view-list { display: grid; gap: 0.5rem; }
.view-btn {
  justify-content: flex-start;
  text-align: left;
  background: rgba(15, 23, 42, 0.72);
  border-color: var(--line);
}
.view-btn.active {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.24), rgba(124, 58, 237, 0.38));
  border-color: rgba(52, 211, 153, 0.55);
}

.muted { color: var(--muted); }
.mini { font-size: 0.88rem; }
.run-summary { display: grid; gap: 0.45rem; line-height: 1.35; }

.controls { display: grid; gap: 1rem; }
.control-grid, .research-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; }
.full { display: block; margin-top: 0.85rem; }
summary { cursor: pointer; font-weight: 900; color: var(--text); margin-bottom: 0.8rem; }

.table-panel { min-width: 0; }
.table-head { display: flex; justify-content: space-between; gap: 1rem; align-items: end; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; max-height: 64vh; }
table { width: 100%; min-width: 1080px; border-collapse: collapse; }
th, td { padding: 0.75rem; border-bottom: 1px solid rgba(148, 163, 184, 0.16); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: #111827; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; z-index: 1; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: rgba(125, 211, 252, 0.08); }
td small { display: block; color: var(--muted); margin-top: 0.25rem; }

.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.28rem 0.56rem;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, 0.12);
  font-size: 0.8rem;
  font-weight: 900;
}
.pill.high { color: #bbf7d0; border-color: rgba(52, 211, 153, 0.5); background: rgba(52, 211, 153, 0.12); }
.pill.medium { color: #fde68a; border-color: rgba(251, 191, 36, 0.5); background: rgba(251, 191, 36, 0.12); }
.pill.low-needs-review { color: #bfdbfe; border-color: rgba(96, 165, 250, 0.5); background: rgba(96, 165, 250, 0.12); }
.pill.excluded { color: #fecdd3; border-color: rgba(251, 113, 133, 0.55); background: rgba(251, 113, 133, 0.12); }

.detail-fields { display: grid; gap: 0.55rem; margin-bottom: 1rem; }
.detail-row { border: 1px solid rgba(148, 163, 184, 0.16); border-radius: 12px; padding: 0.65rem; background: rgba(2, 6, 23, 0.38); }
.detail-row span { display: block; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.25rem; }
.detail-row strong { white-space: pre-wrap; overflow-wrap: anywhere; }
.detail form { display: grid; gap: 0.75rem; }
.empty { color: var(--muted); padding: 1.6rem; text-align: center; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  max-width: 520px;
  border: 1px solid rgba(52, 211, 153, 0.42);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  background: #0f172a;
  box-shadow: var(--shadow);
}
.toast.warn { border-color: rgba(251, 191, 36, 0.5); }
.toast.error { border-color: rgba(251, 113, 133, 0.6); }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar, .detail { position: static; max-height: none; }
  .hero { flex-direction: column; }
}

@media (max-width: 760px) {
  .hero { padding: 1rem; }
  .shell { padding: 0.6rem; }
  .control-grid, .research-grid { grid-template-columns: 1fr; }
  .table-head { display: block; }
}
