:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --sunken: #e3e8ee;
  --ink: #1a2230;
  --muted: #5b6676;
  --line: #d3dae3;
  --action: #2f4b9a;
  --action-ink: #ffffff;
  --buy: #1f7a5a;
  --hold: #b7791f;
  --sell: #b4413a;
  --review: #6b7280;
  --focus: #6d8eea;
  --radius-s: 4px;
  --radius-m: 8px;
  --ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --memo: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a22;
    --surface: #1c2430;
    --sunken: #111720;
    --ink: #e3e8ef;
    --muted: #97a3b4;
    --line: #2e3a4a;
    --action: #7f9cf0;
    --action-ink: #0f1622;
    --buy: #4cc49a;
    --hold: #e3b04b;
    --sell: #ec7a72;
    --review: #9aa3b2;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--ui); font-variant-numeric: tabular-nums;
}
a { color: var(--action); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .25rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---- chrome ---- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a { padding: .35rem .65rem; border-radius: var(--radius-s); color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--sunken); font-weight: 600; }
.who { margin-left: auto; display: flex; gap: .75rem; align-items: center; color: var(--muted); font-size: .9rem; }
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
main:focus, main:focus-visible { outline: none; }
.narrow + .small, .panel + .small { margin-top: .75rem; }
.disclaimer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

/* ---- controls ---- */
button, .button {
  font: inherit; cursor: pointer; border-radius: var(--radius-s); padding: .5rem .95rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--muted); }
button.primary { background: var(--action); border-color: var(--action); color: var(--action-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--sell); }
button.link { border: 0; background: none; padding: 0; color: var(--action); }
button:disabled { opacity: .55; cursor: not-allowed; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input, select {
  font: inherit; width: 100%; padding: .5rem .6rem; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
input:focus, select:focus { border-color: var(--action); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--action) 25%, transparent); }
.field { margin-bottom: 1.1rem; position: relative; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem; }
.check {
  display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; margin: 0;
  padding: .4rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); cursor: pointer;
}
.check input { width: auto; margin: 0; accent-color: var(--action); }
.check:has(input:checked) { border-color: var(--action); }
.error-text { color: var(--sell); font-size: .9rem; min-height: 1.3em; }

/* ---- surfaces ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.25rem; }
.stack > * + * { margin-top: 1.25rem; }
.narrow { max-width: 640px; }
.login { max-width: 360px; margin: 8vh auto 0; }

.suggest {
  position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: .25rem 0; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); box-shadow: 0 6px 18px rgb(0 0 0 / .12);
}
.suggest li { padding: .4rem .7rem; cursor: pointer; display: flex; gap: .6rem; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--sunken); }
.suggest b { min-width: 6.5rem; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--sunken); }
td.num, th.num { text-align: right; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }

/* ---- status + rating ---- */
.status { display: inline-flex; align-items: center; gap: .4rem; }
.status::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--review); }
.status.running::before { background: var(--action); animation: pulse 1.4s ease-in-out infinite; }
.status.succeeded::before { background: var(--buy); }
.status.failed::before { background: var(--sell); }
.status.queued::before { background: transparent; border: 1.5px solid var(--muted); }
.rating { font-weight: 700; }
.rating.buy, .rating.overweight { color: var(--buy); }
.rating.hold { color: var(--hold); }
.rating.sell, .rating.underweight { color: var(--sell); }
.rating.review { color: var(--review); }

/* ---- the docket: five stages of the committee ---- */
.job-grid { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 1.25rem; align-items: start; }
.docket { list-style: none; margin: 0; padding: 0; counter-reset: stage; }
.stage { position: relative; padding: 0 0 1.1rem 2.6rem; }
.stage::before {
  counter-increment: stage; content: counter(stage, upper-roman);
  position: absolute; left: 0; top: 0; width: 1.9rem; height: 1.9rem; display: grid; place-items: center;
  border-radius: 50%; border: 1.5px solid var(--line); color: var(--muted); font: 600 .8rem/1 var(--memo); background: var(--surface);
}
.stage::after { content: ""; position: absolute; left: .93rem; top: 2rem; bottom: .15rem; width: 1.5px; background: var(--line); }
.stage:last-child::after { display: none; }
.stage.active::before { border-color: var(--action); color: var(--action); }
.stage.done::before { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.stage.done::after { background: var(--action); }
.stage h3 { margin: .2rem 0 .4rem; font-size: .95rem; font-weight: 650; }
.seats { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.seat { display: flex; justify-content: space-between; gap: .5rem; font-size: .88rem; color: var(--muted); }
.seat[data-status="in_progress"] { color: var(--ink); font-weight: 600; }
.seat[data-status="in_progress"] .state::before { content: ""; display: inline-block; width: .45rem; height: .45rem; margin-right: .35rem; border-radius: 50%; background: var(--action); animation: pulse 1.4s ease-in-out infinite; }
.seat[data-status="completed"] { color: var(--ink); }
.seat[data-status="completed"] .state { color: var(--buy); }

.meters { display: flex; gap: 1.5rem; flex-wrap: wrap; font-size: .9rem; margin-bottom: 1rem; }
.meters b { display: block; font-size: 1.15rem; }
.log { max-height: 60vh; overflow-y: auto; font-size: .88rem; }
.log-item { padding: .45rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.log-item:last-child { border-bottom: 0; }
.log-item .speaker { font-weight: 600; color: var(--ink); }
.log-item.tool { color: var(--muted); }
.log-item.warning { color: var(--hold); }
.log-item p { margin: .15rem 0 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- verdict + report ---- */
.verdict { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: center; }
.verdict .rating { font: 700 2.4rem/1 var(--memo); letter-spacing: -.01em; padding-right: 1.5rem; border-right: 1px solid var(--line); }
.verdict p { font: 1.05rem/1.55 var(--memo); margin: 0; max-width: 68ch; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: .6rem .8rem; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--action); font-weight: 600; }
.memo { font: 1.02rem/1.65 var(--memo); max-width: 72ch; overflow-wrap: anywhere; }
.memo h1, .memo h2, .memo h3 { font-family: var(--ui); margin: 1.5em 0 .5em; }
.memo h1 { font-size: 1.3rem; } .memo h2 { font-size: 1.15rem; } .memo h3 { font-size: 1rem; }
.memo table { font: .9rem/1.4 var(--ui); margin: 1rem 0; display: block; overflow-x: auto; }
.memo th, .memo td { white-space: normal; border: 1px solid var(--line); }
.memo code { font-size: .88em; background: var(--sunken); padding: .1em .3em; border-radius: 3px; }
.memo blockquote { margin: 1rem 0; padding-left: 1rem; border-left: 3px solid var(--line); color: var(--muted); }

.keybox { display: flex; gap: .5rem; align-items: center; background: var(--sunken); padding: .75rem; border-radius: var(--radius-s); }
.keybox code { flex: 1; overflow-wrap: anywhere; font-size: .9rem; }
.bar { height: .5rem; background: var(--sunken); border-radius: 99px; overflow: hidden; margin: .5rem 0; }
.bar span { display: block; height: 100%; background: var(--action); }

#toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 20; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--ink); color: var(--bg); padding: .7rem 1rem; border-radius: var(--radius-s); box-shadow: 0 6px 18px rgb(0 0 0 / .2); }
.toast.error { background: var(--sell); color: #fff; }

@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

@media (max-width: 760px) {
  .job-grid, .verdict { grid-template-columns: 1fr; }
  .verdict .rating { border-right: 0; padding: 0; }
  .topbar { gap: .5rem 1rem; padding: .6rem 1rem; }
  .who { margin-left: 0; }
  main { padding: 1.25rem 1rem 2rem; }
  th, td { padding: .5rem .6rem; }
}
