
:root {
  color-scheme: dark;
  --canvas: #0a0e13;
  --panel: #10161d;
  --panel-raised: #151d26;
  --panel-deep: #080c11;
  --line: #27313c;
  --line-strong: #394654;
  --ink: #edf2f5;
  --muted: #91a0ae;
  --quiet: #657482;
  --signal: #72d1aa;
  --signal-dim: #173b31;
  --warn: #e3b76d;
  --danger: #ef8989;
  --focus: #9ee6c8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .52; }
button:focus-visible, input:focus-visible, summary:focus-visible, pre:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

main { width: min(1540px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 64px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(18px, 2vw, 23px); font-weight: 680; letter-spacing: -.025em; }
h2 { font-size: 17px; font-weight: 680; letter-spacing: -.015em; }
h3 { font-size: 12px; font-weight: 650; }
p { color: var(--muted); line-height: 1.55; }
.mono, input, pre, td, dd, .run-row strong, .count, .priority-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.panel { border: 1px solid var(--line); background: var(--panel); }
.login { min-height: 92vh; display: grid; place-items: center; }
.login-card { width: min(440px, 100%); padding: 30px; border-radius: 12px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid #3e8c70;
  border-radius: 8px;
  color: var(--signal);
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: -.06em;
}
.brand-caption { margin-top: 2px; color: var(--muted); font-size: 12px; }
.login-card > h1 { margin-top: 32px; font-size: 30px; }
.login-card > p { margin-top: 8px; max-width: 42ch; }
.login-card form { display: grid; gap: 14px; margin-top: 28px; }

label { display: grid; gap: 7px; color: #bdc7cf; font-size: 12px; font-weight: 600; }
input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--panel-deep);
  color: var(--ink);
}
input::placeholder { color: #586673; }
input:hover { border-color: #4a5968; }

.primary, #login-button, #create-button {
  min-height: 44px;
  border: 1px solid #86dbb8;
  border-radius: 6px;
  padding: 9px 16px;
  background: var(--signal);
  color: #07120d;
  font-weight: 750;
}
.login-card button { width: 100%; }
.secondary {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 7px 11px;
  background: transparent;
  color: #d4dce2;
  font-size: 12px;
  font-weight: 650;
}
.secondary:hover { border-color: #607181; background: var(--panel-raised); }
.secondary[data-success="true"] { border-color: var(--signal); color: var(--signal); }
.error { min-height: 20px; margin-top: 11px; color: var(--danger); font: 12px/1.5 ui-monospace, monospace; white-space: pre-wrap; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.service-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.service-state::before { width: 7px; height: 7px; border-radius: 50%; background: var(--signal); content: ""; box-shadow: 0 0 0 3px var(--signal-dim); }

.create { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 22px; align-items: center; padding: 16px 18px; border-radius: 8px; }
.command-label { color: var(--ink); font-size: 13px; font-weight: 680; }
.command-help { margin-top: 3px; color: var(--quiet); font-size: 11px; }
.create form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.create .error { grid-column: 1 / -1; margin: -2px 0 0; }

.workspace-grid { display: grid; grid-template-columns: minmax(300px, 350px) minmax(0, 1fr); gap: 14px; align-items: start; margin-top: 14px; }
.runs { position: sticky; top: 14px; min-height: 510px; overflow: hidden; border-radius: 8px; }
.detail { min-width: 0; overflow: hidden; border-radius: 8px; }
.section-head { display: flex; min-height: 56px; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.section-head > span { color: var(--quiet); font-size: 11px; }
.list-tabs, .actions { display: flex; align-items: center; gap: 6px; }
.list-tabs button {
  min-height: 30px;
  border: 0;
  border-radius: 4px;
  padding: 5px 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}
.list-tabs button:hover { background: var(--panel-raised); color: var(--ink); }
.list-tabs button[data-active="true"] { background: #1b2b27; color: var(--signal); }
.domain-filter { width: calc(100% - 24px); min-height: 36px; margin: 12px; }
.run-list { display: grid; max-height: calc(100vh - 250px); min-height: 450px; overflow: auto; align-content: start; }
.run-row {
  display: grid;
  width: 100%;
  min-height: 0;
  gap: 8px;
  border: 0;
  border-bottom: 1px solid #202a34;
  border-left: 2px solid transparent;
  border-radius: 0;
  padding: 13px 15px 13px 13px;
  background: transparent;
  color: inherit;
  text-align: left;
  font-weight: 400;
}
.run-row:hover { background: #131b23; }
.run-row[data-selected="true"] { border-left-color: var(--signal); background: #182129; }
.run-primary { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; }
.run-primary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.run-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--quiet); font-size: 10px; }
.status, .score-badge, .coverage-chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 2px 6px;
  color: #b8c3cb;
  font: 650 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}
.score-badge { border-color: #386f5d; color: var(--signal); }
.status[data-status="scored"] { border-color: #386f5d; color: var(--signal); }
.status[data-status="failed"], .status[data-status="expired"] { border-color: #814949; color: var(--danger); }
.status[data-status="incomplete"] { border-color: #755f3d; color: var(--warn); }
.empty { padding: 24px 16px; color: var(--quiet); font-size: 12px; }

.detail-title { display: flex; min-width: 0; align-items: center; gap: 10px; }
.record-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--signal); }
.detail-title h2 { overflow-wrap: anywhere; }
.detail-body { padding: 0 18px 20px; }
.job-meta {
  display: grid;
  grid-template-columns: 1.4fr 1fr .7fr .9fr .7fr 1fr;
  margin: 0 -18px 18px;
  border-bottom: 1px solid var(--line);
  background: #0d1319;
}
.job-meta div { min-width: 0; padding: 11px 14px; border-right: 1px solid var(--line); }
.job-meta div:last-child { border-right: 0; }
.job-meta dt { color: var(--quiet); font-size: 9px; font-weight: 650; letter-spacing: .04em; }
.job-meta dd { margin: 5px 0 0; overflow: hidden; color: #cbd4db; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.job-meta dd[data-status="scored"] { color: var(--signal); }
.job-meta dd[data-status="failed"], .job-meta dd[data-status="expired"] { color: var(--danger); }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 11px; }
pre {
  min-height: 280px;
  max-height: 68vh;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 17px;
  background: var(--panel-deep);
  color: #d2dae0;
  font-size: 11px;
  line-height: 1.62;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.domain-overview { display: grid; grid-template-columns: 210px minmax(0, 1fr); margin-bottom: 24px; border: 1px solid var(--line); background: #0d1319; }
.priority-readout { display: flex; min-height: 174px; flex-direction: column; justify-content: space-between; padding: 17px; border-right: 1px solid var(--line); }
.priority-label { color: var(--muted); font-size: 11px; }
.priority-number { display: flex; align-items: baseline; gap: 6px; }
.priority-value { color: var(--signal); font-size: 54px; font-weight: 620; letter-spacing: -.08em; line-height: 1; }
.priority-denominator { color: var(--quiet); font-size: 12px; }
.priority-note { color: var(--quiet); font-size: 10px; line-height: 1.45; }
.priority-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.surface-ledger { display: grid; align-content: stretch; }
.ledger-row { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 14px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.ledger-row:last-child { border-bottom: 0; }
.ledger-label { color: var(--quiet); font-size: 10px; font-weight: 650; }
.ledger-values { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.ledger-stat { min-width: 0; }
.ledger-stat strong { display: block; color: var(--ink); font: 600 18px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.ledger-stat span { display: block; margin-top: 3px; overflow: hidden; color: var(--quiet); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.coverage-values { display: flex; flex-wrap: wrap; gap: 6px; }
.coverage-chip { color: #afbbc4; }
.coverage-chip[data-value="confirmed"], .coverage-chip[data-value="fetched"], .coverage-chip[data-value="typed"] { border-color: #386f5d; color: var(--signal); }

.domain-groups { display: grid; gap: 24px; }
.section-group { display: grid; gap: 8px; }
.group-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 0 2px 2px; }
.group-heading h3 { color: #c9d2d9; }
.group-heading span { color: var(--quiet); font-size: 10px; }
.data-section { overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: #0e141a; }
.data-section[open] { border-color: #33404c; }
.data-section summary { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px; background: #121a22; cursor: pointer; list-style: none; }
.data-section summary::-webkit-details-marker { display: none; }
.data-section summary::before { width: 12px; flex: 0 0 12px; color: var(--quiet); content: "+"; font: 13px/1 ui-monospace, monospace; }
.data-section[open] summary::before { content: "−"; color: var(--signal); }
.section-title { display: flex; min-width: 0; flex: 1; align-items: baseline; gap: 8px; }
.section-title strong { color: #d8e0e5; font-size: 11px; }
.section-title em { overflow: hidden; color: var(--quiet); font-size: 10px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.data-section summary > .count { color: var(--muted); font-size: 10px; }
.section-tools { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--panel-deep); }
.section-filter { min-height: 32px; padding: 6px 9px; font-size: 10px; }
.section-result-count { flex: 0 0 auto; color: var(--quiet); font: 10px/1 ui-monospace, monospace; }
.table-wrap { max-height: 440px; overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th { position: sticky; top: 0; z-index: 1; background: #111820; color: var(--quiet); text-align: left; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-weight: 650; }
th, td { max-width: 520px; padding: 8px 10px; border-bottom: 1px solid #202a34; vertical-align: top; overflow-wrap: anywhere; }
tbody tr:nth-child(even) { background: #0b1117; }
tbody tr:hover { background: #162029; }
.tag { display: inline-block; margin: 0 4px 3px 0; border: 1px solid var(--line-strong); border-radius: 3px; padding: 2px 5px; color: #aebac3; font-size: 9px; }
.section-empty { padding: 14px 12px; border-top: 1px solid var(--line); color: var(--quiet); font-size: 10px; }
.group-empty { border-left: 2px solid var(--line-strong); padding: 10px 12px; color: var(--quiet); font-size: 11px; }
footer { margin-top: 16px; color: var(--quiet); font-size: 10px; }

@media (max-width: 1080px) {
  .workspace-grid { grid-template-columns: 290px minmax(0, 1fr); }
  .job-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .job-meta div:nth-child(3) { border-right: 0; }
  .job-meta div:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .domain-overview { grid-template-columns: 180px minmax(0, 1fr); }
  .ledger-values { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px; }
}

@media (max-width: 820px) {
  main { width: min(100% - 24px, 720px); padding-top: 18px; }
  .create { grid-template-columns: 1fr; gap: 12px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .runs { position: static; min-height: 0; }
  .run-list { min-height: 0; max-height: 330px; }
  .domain-overview { grid-template-columns: 170px minmax(0, 1fr); }
}

@media (max-width: 560px) {
  main { width: min(100% - 16px, 520px); padding-bottom: 36px; }
  .topbar { align-items: flex-start; }
  .service-state { display: none; }
  .create form { grid-template-columns: 1fr; }
  .create form button { width: 100%; }
  .job-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-meta div, .job-meta div:nth-child(3) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .job-meta div:nth-child(even) { border-right: 0; }
  .domain-overview { grid-template-columns: 1fr; }
  .priority-readout { min-height: 150px; border-right: 0; border-bottom: 1px solid var(--line); }
  .ledger-row { grid-template-columns: 1fr; gap: 8px; }
  .report-head { align-items: flex-start; flex-direction: column; }
  .actions { width: 100%; }
  .actions button { flex: 1; }
  th, td { min-width: 110px; }
}

@media (prefers-reduced-motion: no-preference) {
  button, input, .run-row { transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease; }
}
