/* CT risk portal.
   Design tokens carried over from portal/portal_prototype.html so the finished
   product still looks like the thing that was approved: teal accent, generous
   whitespace, monospace for anything the reader might quote back to us. */

:root {
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;

  --paper: #ffffff;
  --raised: #fbfcfc;
  --ink: #181c1e;
  --soft: #5c6b6f;
  --faint: #93a1a4;
  --line: #e6eaeb;
  --line-2: #f2f5f5;
  --accent: #0e7a86;
  --accent-soft: #e6f2f3;
  --warn: #a56a12;
  --warn-soft: #fdf4e3;
  --bad: #a33a3a;
  --bad-soft: #fbeded;
  --good: #2f7a52;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 30, 32, .04), 0 8px 24px -12px rgba(16, 30, 32, .12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0c0f10; --raised: #121718; --ink: #e9eeef; --soft: #9aa9ac;
    --faint: #63757a; --line: #1e2628; --line-2: #161c1e;
    --accent: #31bccb; --accent-soft: #0f2b30;
    --warn: #d29a3e; --warn-soft: #2a2116;
    --bad: #e08585; --bad-soft: #2b1a1a; --good: #6cc394;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}
:root[data-theme="light"] {
  --paper: #ffffff; --raised: #fbfcfc; --ink: #181c1e; --soft: #5c6b6f;
  --faint: #93a1a4; --line: #e6eaeb; --line-2: #f2f5f5;
  --accent: #0e7a86; --accent-soft: #e6f2f3; --warn: #a56a12; --warn-soft: #fdf4e3;
  --bad: #a33a3a; --bad-soft: #fbeded; --good: #2f7a52;
}
:root[data-theme="dark"] {
  --paper: #0c0f10; --raised: #121718; --ink: #e9eeef; --soft: #9aa9ac;
  --faint: #63757a; --line: #1e2628; --line-2: #161c1e;
  --accent: #31bccb; --accent-soft: #0f2b30; --warn: #d29a3e; --warn-soft: #2a2116;
  --bad: #e08585; --bad-soft: #2b1a1a; --good: #6cc394;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); line-height: 1.55;
  -webkit-font-smoothing: antialiased; letter-spacing: -.005em;
}
.col { max-width: 640px; margin: 0 auto; padding: 0 24px; }
.col.wide { max-width: 880px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- header -- */
header { padding: 22px 0 0; }
.head { display: flex; align-items: center; gap: 12px; }
.mark { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.mark b { color: var(--accent); font-weight: 600; }
.tag {
  font-size: 11px; color: var(--faint); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 8px; letter-spacing: .02em;
}
.sp { flex: 1; }
.iconbtn {
  width: 32px; height: 32px; border: 1px solid var(--line); background: none;
  border-radius: var(--radius-sm); color: var(--soft); cursor: pointer;
  display: grid; place-items: center; transition: color .15s, border-color .15s;
}
.iconbtn:hover { color: var(--ink); border-color: var(--soft); }
.iconbtn svg { width: 16px; height: 16px; }
.who { font-size: 12.5px; color: var(--faint); }
.linkbtn {
  background: none; border: none; color: var(--soft); font: inherit;
  font-size: 12.5px; cursor: pointer; padding: 0; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: var(--line);
}
.linkbtn:hover { color: var(--ink); }

/* ------------------------------------------------------------------ main -- */
/* Bottom padding has to clear the last action row comfortably; at 64px
   the buttons sat almost on the footer rule. */
main { padding: 56px 0 96px; min-height: 62vh; }
[data-stage] { display: none; }
[data-stage].on { display: block; animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { [data-stage].on { animation: none; } }

.step-lbl {
  font-family: var(--mono); font-size: 12px; color: var(--faint);
  letter-spacing: .04em; margin: 0 0 16px;
}
h1 {
  font-size: 27px; line-height: 1.2; font-weight: 600; letter-spacing: -.02em;
  margin: 0 0 12px; text-wrap: balance;
}
h2 {
  font-size: 15px; font-weight: 600; letter-spacing: -.01em;
  margin: 36px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.sub { color: var(--soft); font-size: 15.5px; margin: 0 0 32px; max-width: 56ch; }

/* ---------------------------------------------------------------- upload -- */
.drop {
  display: block; width: 100%; text-align: left; border: 1px solid var(--line);
  border-radius: var(--radius); background: none; padding: 22px; cursor: pointer;
  transition: border-color .15s, background .15s; font: inherit; color: inherit;
}
.drop:hover, .drop.hot { border-color: var(--accent); background: var(--line-2); }
.drop .dt { display: flex; align-items: center; gap: 14px; }
.drop .ic { width: 22px; height: 22px; color: var(--accent); flex: none; }
.drop .m { font-weight: 500; font-size: 15px; }
.drop .s { font-size: 13px; color: var(--faint); margin-top: 1px; }
.drop.filled .m { font-family: var(--mono); font-weight: 600; color: var(--accent); font-size: 14px; }

.row { display: flex; flex-direction: column; gap: 6px; margin-top: 22px; }
label { font-size: 13px; color: var(--soft); }
input.f {
  border: none; border-bottom: 1px solid var(--line); background: none;
  font: inherit; font-size: 16px; color: var(--ink); padding: 8px 0;
  transition: border-color .15s; width: 100%;
}
input.f:focus { outline: none; border-color: var(--accent); }
input.f::placeholder { color: var(--faint); }

.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 26px; }
.check input { margin-top: 3px; accent-color: var(--accent); flex: none; }
.check span { font-size: 13px; color: var(--soft); }

.btn {
  margin-top: 28px; width: 100%; border: none; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font: inherit; font-weight: 500;
  font-size: 15px; padding: 13px; cursor: pointer; transition: opacity .15s;
}
.btn:hover:not(:disabled) { opacity: .9; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--ink); }
.btn.ghost:hover:not(:disabled) { border-color: var(--soft); opacity: 1; }
.btn.slim { width: auto; padding: 9px 18px; font-size: 14px; margin-top: 0; }

/* -------------------------------------------------------------- progress -- */
.bar { height: 3px; background: var(--line-2); border-radius: 2px; overflow: hidden; margin: 28px 0 12px; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .5s ease; }
.pct { font-family: var(--mono); font-size: 12px; color: var(--faint); }

.steps { list-style: none; padding: 0; margin: 32px 0 0; }
.steps li {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--line-2); font-size: 14px; color: var(--faint);
}
.steps li:last-child { border-bottom: none; }
.steps .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none;
}
.steps li.done { color: var(--soft); }
.steps li.done .dot { background: var(--good); }
.steps li.active { color: var(--ink); font-weight: 500; }
.steps li.active .dot { background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .steps li.active .dot { animation: none; } }

/* --------------------------------------------------------------- results -- */
.score {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 26px;
  background: var(--raised); box-shadow: var(--shadow); margin-bottom: 8px;
}
.score .v { font-size: 46px; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.score .band {
  display: inline-block; margin-left: 10px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; padding: 4px 10px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  vertical-align: middle;
}
.score .interp { color: var(--soft); font-size: 14px; margin-top: 14px; max-width: 54ch; }
.score.pending .v { font-size: 20px; font-weight: 500; color: var(--soft); }

.score .cov { margin-top:10px; font-size:13px; color:var(--faint); }
.score .horizons { display:flex; flex-wrap:wrap; gap:18px; margin-top:14px; }
.score .hz { display:flex; flex-direction:column; }
.score .hz .hk { font-size:12px; color:var(--faint); text-transform:uppercase; letter-spacing:.04em; }
.score .hz .hv { font-size:20px; font-variant-numeric:tabular-nums; }

.row.two { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
@media (max-width:520px){ .row.two { grid-template-columns:1fr; } }

.notice {
  border-left: 2px solid var(--warn); background: var(--warn-soft);
  padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13.5px; color: var(--ink); margin: 10px 0;
}
.notice.bad { border-left-color: var(--bad); background: var(--bad-soft); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice li { margin: 4px 0; }

table.metrics { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.metrics th, table.metrics td {
  text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-2);
}
table.metrics th { color: var(--faint); font-weight: 500; font-size: 12px; letter-spacing: .02em; }
table.metrics td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.metrics td.key { color: var(--soft); font-family: var(--mono); font-size: 12.5px; }
.scrollx { overflow-x: auto; }

.files { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.file {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 14px; font-size: 13.5px; color: var(--ink); transition: border-color .15s;
}
.file:hover { border-color: var(--accent); color: var(--accent); }

details.raw { margin-top: 18px; }
details.raw summary {
  cursor: pointer; font-size: 13px; color: var(--soft); padding: 6px 0;
}
details.raw summary:hover { color: var(--ink); }

/* --------------------------------------------------------------- history -- */
.jobs { list-style: none; padding: 0; margin: 0; }
.jobs li {
  display: flex; align-items: center; gap: 14px; padding: 13px 0;
  border-bottom: 1px solid var(--line-2);
}
.jobs .ref { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent); }
.jobs .lbl { flex: 1; font-size: 14px; color: var(--soft); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobs .when { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.pill {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 9px; border-radius: 999px; background: var(--line-2); color: var(--soft);
}
.pill.done { background: var(--accent-soft); color: var(--accent); }
.pill.run { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

/* ------------------------------------------------------------------ misc -- */
footer {
  border-top: 1px solid var(--line); padding: 34px 0 44px;
  font-size: 12px; color: var(--faint);
}
footer p { margin: 4px 0; }
.err { color: var(--bad); font-size: 13.5px; margin-top: 14px; }
.empty { color: var(--faint); font-size: 14px; padding: 28px 0; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--paper); font-size: 13.5px;
  padding: 11px 20px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 50;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  h1 { font-size: 23px; }
  main { padding: 36px 0 72px; }
  .jobs li { flex-wrap: wrap; gap: 8px; }
}
