:root {
  color-scheme: dark;
  --bg: #071018;
  --surface: #0d1923;
  --surface-2: #122431;
  --line: #213746;
  --text: #edf4f7;
  --muted: #8da5b3;
  --gold: #e8b65d;
  --cyan: #4fd2d8;
  --green: #61d59a;
  --red: #ff7a7a;
  --blue: #74a8ff;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
[hidden] { display: none !important; }

.topbar {
  min-height: 78px; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
  gap: 20px; border-bottom: 1px solid var(--line); background: rgba(7, 16, 24, .96); position: sticky;
  top: 0; z-index: 10;
}
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid #396170;
  border-radius: 12px; color: var(--gold); background: #10212d; font: 700 15px ui-monospace, monospace;
  letter-spacing: .08em;
}
.eyebrow { margin: 0 0 5px; color: var(--cyan); font: 700 11px ui-monospace, monospace; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 10px; }

button {
  min-height: 40px; border: 0; border-radius: 10px; padding: 0 15px; cursor: pointer; color: #061218;
  background: var(--gold); font-weight: 700;
}
button:hover { filter: brightness(1.07); }
.button-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.button-quiet { background: transparent; color: var(--muted); border: 1px solid transparent; }
.status-pill, .badge {
  display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 999px;
  font: 700 11px ui-monospace, monospace; letter-spacing: .04em; border: 1px solid var(--line);
}
.status-pending { color: var(--gold); }
.status-ready, .badge-pass { color: var(--green); border-color: #286249; background: #0d2b20; }
.status-error, .badge-fail { color: var(--red); border-color: #633636; background: #2d1719; }
.badge-neutral { color: var(--blue); background: #132440; border-color: #28466d; }

.workspace { display: grid; grid-template-columns: 310px minmax(0, 1fr); min-height: calc(100vh - 78px); }
.sidebar { border-right: 1px solid var(--line); padding: 22px 18px; background: #09141d; }
.content { padding: 28px; min-width: 0; }
.search-form label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
input {
  width: 100%; min-height: 42px; color: var(--text); background: #08121a; border: 1px solid var(--line);
  border-radius: 10px; padding: 0 12px;
}
.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 28px 2px 10px; }
.section-heading h2 { margin: 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.section-heading span { color: var(--muted); font: 12px ui-monospace, monospace; }
.campaign-list { display: grid; gap: 8px; }
.campaign-item {
  width: 100%; height: auto; min-height: 72px; text-align: left; color: var(--text); background: transparent;
  border: 1px solid transparent; display: grid; gap: 7px; padding: 12px;
}
.campaign-item:hover, .campaign-item.is-active { background: var(--surface); border-color: var(--line); filter: none; }
.campaign-item strong { font: 600 12px ui-monospace, monospace; overflow-wrap: anywhere; }
.campaign-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 500; }

.empty-state, .loading-state, .error-state {
  min-height: 440px; display: grid; align-content: center; justify-items: center; text-align: center;
  border: 1px dashed #294353; border-radius: var(--radius); color: var(--muted); padding: 40px;
}
.empty-state h2, .error-state h2 { color: var(--text); max-width: 580px; }
.empty-state p, .error-state p { max-width: 620px; line-height: 1.7; }
.loader { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--cyan); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.report-head h2 { margin-bottom: 7px; font: 700 26px ui-monospace, monospace; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.classification-badge { color: var(--gold); border: 1px solid #6d5330; border-radius: 999px; padding: 8px 12px; font-size: 12px; white-space: nowrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi {
  padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, #0d1c27, #0b1720);
}
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { margin-top: 7px; font: 700 22px ui-monospace, monospace; }
.kpi-note { margin-top: 5px; color: var(--muted); font-size: 11px; }
.report-nav { display: flex; gap: 8px; overflow-x: auto; padding: 20px 0 2px; }
.report-nav a { color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; white-space: nowrap; font-size: 12px; }
.report-nav a:hover { color: var(--text); border-color: #3e6578; }
.panel { margin-top: 18px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel > h2 { font-size: 17px; margin-bottom: 18px; }
.panel h3 { font-size: 14px; color: var(--gold); margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.subpanel { padding: 15px; background: #09151e; border: 1px solid #1d3341; border-radius: 11px; min-width: 0; }
.research-copy { color: #cfdae0; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.key-value { display: grid; grid-template-columns: 155px minmax(0, 1fr); gap: 8px 14px; margin: 0; }
.key-value dt { color: var(--muted); }
.key-value dd { margin: 0; overflow-wrap: anywhere; }
.code-pill { display: inline-block; max-width: 100%; margin: 3px 5px 3px 0; padding: 4px 7px; border-radius: 6px; background: #081219; border: 1px solid #243d4c; color: #b8d9e8; font: 11px ui-monospace, monospace; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; border: 1px solid #1d3341; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #1d3341; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: #0a1720; white-space: nowrap; }
td { overflow-wrap: anywhere; }
tr:last-child td { border-bottom: 0; }
.round-card { margin-top: 12px; padding: 17px; border-left: 3px solid var(--cyan); background: #09151e; border-radius: 0 11px 11px 0; }
.round-card:first-of-type { margin-top: 0; }
.round-title { display: flex; justify-content: space-between; gap: 12px; }
.selection-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid #1d3341; }

.metric-list { display: grid; gap: 12px; }
.metric-row { display: grid; grid-template-columns: 210px minmax(120px, 1fr) 88px; align-items: center; gap: 12px; }
.metric-row label { color: var(--muted); font-size: 12px; }
.metric-row output { font: 12px ui-monospace, monospace; text-align: right; }
progress { width: 100%; height: 8px; appearance: none; border: 0; }
progress::-webkit-progress-bar { background: #172a36; border-radius: 99px; }
progress::-webkit-progress-value { background: var(--cyan); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--cyan); border-radius: 99px; }

.source-head { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 12px; }
.source-code { max-height: 620px; overflow: auto; margin: 0; padding: 18px; border: 1px solid #233d4d; border-radius: 10px; background: #050c12; color: #cce2ed; font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; }
.notice { padding: 12px 14px; border: 1px solid #5e4a2a; border-radius: 10px; background: #251d10; color: #e8cc96; line-height: 1.55; }
.chart-card { margin: 14px 0; padding: 15px; background: #09151e; border: 1px solid #1d3341; border-radius: 11px; overflow: hidden; }
.chart-card h3 { margin-bottom: 8px; }
.evidence-chart { display: block; width: 100%; height: auto; max-height: 520px; }

.login-body { display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 10%, #173245, var(--bg) 56%); }
.login-shell { width: min(100%, 460px); }
.login-card { padding: 34px; border-radius: 20px; border: 1px solid #315064; background: rgba(9, 21, 30, .96); box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.login-card .brand-mark { margin-bottom: 24px; }
.login-card h1 { font-size: 30px; margin-bottom: 12px; }
.login-copy { color: var(--muted); line-height: 1.6; }
.login-form { display: grid; gap: 10px; margin-top: 26px; }
.login-form label { color: var(--muted); font-size: 12px; }
.login-form button { margin-top: 6px; }
.form-message { color: var(--red); margin: 15px 0 0; }
.security-note { margin: 18px 0 0; color: #688391; font-size: 11px; line-height: 1.55; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .campaign-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar { align-items: flex-start; padding: 13px 15px; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .status-pill { width: 100%; justify-content: center; order: 3; }
  .content { padding: 18px 14px; }
  .sidebar { padding: 18px 14px; }
  .campaign-list, .grid-2, .kpi-grid { grid-template-columns: 1fr; }
  .report-head { display: grid; }
  .classification-badge { justify-self: start; }
  .metric-row { grid-template-columns: 1fr; gap: 5px; }
  .metric-row output { text-align: left; }
  .key-value { grid-template-columns: 1fr; }
  .key-value dd { margin-bottom: 8px; }
}
