:root {
  --bg: #10151d;
  --panel: #1a2230;
  --panel-2: #212b3d;
  --text: #e8edf4;
  --muted: #8b98ab;
  --accent: #4da3ff;
  --accent-2: #7fd1b9;
  --danger: #ff6b6b;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
}
main { max-width: 900px; margin: 0 auto; padding: 24px 16px 64px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid #2b3648;
}
.brand { font-weight: 700; font-size: 18px; color: #fff; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.logout-form { margin: 0; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.muted { color: var(--muted); font-weight: normal; font-size: 0.92em; }

.card {
  background: var(--panel); border: 1px solid #2b3648;
  border-radius: var(--radius); padding: 20px 22px; margin: 14px 0;
}
.form-stack label, .run-form label { display: block; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.form-stack button[type="submit"], .run-form button[type="submit"] { margin-top: 6px; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 9px 11px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid #34415a; border-radius: 6px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }

.btn {
  display: inline-block; padding: 8px 14px; border-radius: 6px;
  border: 1px solid #34415a; background: var(--panel-2); color: var(--text);
  font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0a1017; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 4px 8px; }
.btn-ghost:hover { color: var(--text); border-color: #34415a; }
.btn-ghost.danger:hover { color: var(--danger); }

.table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.table th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid #26303f; }

.status { padding: 3px 11px; border-radius: 999px; font-size: 12px; display: inline-block; }
.status-running { background: #2b3a55; color: var(--accent); }
.status-done { background: #1f3b33; color: var(--accent-2); }
.status-error { background: #46242a; color: var(--danger); }

.stats-strip { display: flex; gap: 18px; color: var(--muted); font-size: 13px; }
.notice.warn { background: #3d3320; border: 1px solid #6b5a2e; padding: 12px 16px; border-radius: 6px; margin: 0 0 16px; }
.notice.good { background: #1f3b33; border: 1px solid #2e6b52; padding: 12px 16px; border-radius: 6px; margin: 0 0 16px; color: var(--accent-2); }
.tabs { display: flex; gap: 8px; margin-bottom: 4px; border-bottom: 1px solid #2b3648; padding-bottom: 10px; }
.tab {
  padding: 8px 16px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font: inherit; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel-2); border-color: #34415a; color: var(--text); }
.check-label { display: flex !important; gap: 10px; align-items: center; color: var(--text) !important; }
.check-label input[type="checkbox"] { width: auto; margin: 0; }

.candidate-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.candidate {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid #34415a; border-radius: 8px;
  cursor: pointer;
}
.candidate:has(input:checked) { border-color: var(--accent); background: #1d2a3f; }
.candidate input[type="radio"] { width: auto; margin-top: 4px; }
.candidate-body { display: flex; flex-direction: column; gap: 2px; }
.candidate-custom { margin-top: 4px; }
.capture-actions { display: flex; gap: 12px; align-items: center; }

.settings-row { display: flex; gap: 14px; }
.settings-row label { flex: 1; }
.provider-block h2 { margin-top: 18px; }
.error { color: var(--danger); margin: 0 0 14px; }
#sections > .btn { margin-top: 12px; }

.running { display: flex; align-items: center; gap: 14px; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid #34415a; border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.section-card { padding-top: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.section-head h2 { margin: 8px 0; }
.section-body :first-child { margin-top: 0; }
.section-body :last-child { margin-bottom: 0; }
.study-meta { margin-bottom: 6px; }
.study-actions { margin: 12px 0 16px; }
.context-details { margin: 10px 0; }
.context-details summary { cursor: pointer; }
.context-details p { margin: 8px 0 0; }

.section-edit .heading-input { font-weight: 600; font-size: 16px; }
.section-edit-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.section-edit-tools { display: flex; gap: 4px; }
.section-edit label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.section-edit-row { display: flex; gap: 14px; align-items: flex-end; margin-top: 4px; }
.section-edit-row label { flex: 1; margin-bottom: 0; }
.section-edit-row .btn { margin-bottom: 1px; }

.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; }
.filter-bar select, .filter-bar input { width: auto; flex: 1; margin-top: 0; }

.login-wrap { display: flex; justify-content: center; padding-top: 10vh; }
.login-wrap .card { width: 360px; text-align: center; padding: 32px 28px; }
.login-wrap h1 { margin: 0 0 6px; }
.login-wrap .tagline { color: var(--muted); margin: 0 0 24px; }
.login-wrap input { margin: 0 0 16px; padding: 10px 12px; }
.login-wrap .btn { padding: 10px 22px; min-width: 120px; }
.login-wrap .error { margin: 0 0 14px; }
