/* Look follows the SART app (../sart/DESIGN.md): institution blue, Atkinson Hyperlegible, light only. */
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-400-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-weight: 700;
  font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-700-normal.woff2) format('woff2');
}

:root {
  --blue: #093697;
  --yellow: #f6d106;
  --ink: #1d2433;
  --ink-soft: #4a5162;
  --paper: #fbf8f1;
  --surface: #ffffff;
  --edge: #8a8f9c;
  --rule: #e4e1d8;
  --error: #a3261b;
  /* Group colours, validated for colour-blind separation on white; shapes repeat the difference. */
  --g1: #2a5fc4;
  --g2: #c2570c;
  /* Video set colours: a different pair from the groups, so a set is never mistaken for a group. */
  --s1: #1a8a62;
  --s2: #7a4fc7;
  --radius-control: 6px;
  --radius-panel: 12px;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 'Atkinson Hyperlegible', system-ui, sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-1); }
h2 { color: var(--blue); font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 var(--space-2); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

button {
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  padding: 0.55rem 1.3rem;
  border-radius: var(--radius-control);
  cursor: pointer;
}
.btn-primary { background: var(--blue); color: #fff; border: 2px solid var(--blue); }
.btn-ghost { background: transparent; color: #fff; border: 2px solid #fff; }
@media (hover: hover) {
  .btn-primary:hover { background: var(--ink); border-color: var(--ink); }
  .btn-ghost:hover { background: rgb(255 255 255 / 0.12); }
}
button:disabled { opacity: 0.6; cursor: progress; }

label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.7rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--edge);
  border-radius: var(--radius-control);
}
.hint { color: var(--ink-soft); font-size: 0.95rem; }
.error { color: var(--error); font-weight: 700; }

/* Login */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-3) var(--space-2);
  background:
    linear-gradient(var(--blue), var(--blue)) top / 100% 38vh no-repeat,
    var(--paper);
}
.login-card {
  width: 100%;
  max-width: 24rem;
  background: var(--surface);
  border-radius: var(--radius-panel);
  box-shadow: 0 8px 28px rgb(29 36 51 / 0.18);
  padding: var(--space-4) var(--space-3) var(--space-3);
}
.brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: var(--space-3); }
.brand img { width: 44px; height: 44px; }
.brand h1 { font-size: 1.4rem; margin: 0; }
.brand p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }
.brand-mark { border-bottom: 4px solid var(--yellow); }
.field { margin-bottom: var(--space-2); }
.password-row { position: relative; }
.password-row input { padding-right: 5.5rem; }
.reveal {
  position: absolute;
  top: 2px;
  right: 2px;
  min-height: 40px;
  padding: 0 0.8rem;
  background: var(--surface);
  color: var(--blue);
  border: 0;
  font-size: 0.9rem;
}
.login-card .btn-primary { width: 100%; margin-top: var(--space-1); }
.login-card .error { margin: var(--space-2) 0 0; min-height: 1.5em; }

/* Dashboard */
.top {
  background: var(--blue);
  color: #fff;
  padding: var(--space-3) var(--space-2);
}
.top > div {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.top h1 { font-size: 1.5rem; margin: 0; }
.top p { margin: 0; opacity: 0.9; }
.top .spacer { flex: 1; }
main:not(.login) { max-width: 72rem; margin: 0 auto; padding: var(--space-3) var(--space-2) var(--space-4); }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: end;
  margin-bottom: var(--space-3);
}
.controls > div { min-width: 14rem; flex: 1; max-width: 22rem; }
.segmented { display: flex; border: 1.5px solid var(--edge); border-radius: var(--radius-control); overflow: hidden; }
.segmented button {
  flex: 1;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font-weight: 400;
  padding: 0.5rem 0.8rem;
}
.segmented button[aria-pressed="true"] { background: var(--blue); color: #fff; font-weight: 700; }

.block {
  background: var(--surface);
  border-radius: var(--radius-panel);
  padding: var(--space-3) clamp(var(--space-2), 3vw, var(--space-3));
  margin-bottom: var(--space-3);
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--space-2); margin-bottom: var(--space-3); }
.tile { border: 1px solid var(--rule); border-radius: var(--radius-control); padding: var(--space-2); }
.tile .label { color: var(--ink-soft); font-size: 0.9rem; }
.tile .value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.tile .sub { color: var(--ink-soft); font-size: 0.9rem; }

.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: var(--space-3); }

.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: minmax(0, 15rem) 1fr 2.5rem; gap: 0.75rem; align-items: center; margin-bottom: 0.45rem; }
.bars code { font-size: 0.88rem; overflow-wrap: anywhere; }
.bars .track { height: 12px; background: var(--paper); border-radius: 4px; }
.bars .fill { height: 100%; background: var(--blue); border-radius: 4px; }
.bars .n { text-align: right; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
tbody th { font-size: 1rem; color: var(--ink); font-weight: 400; }
tr.kind th { color: var(--blue); font-weight: 700; padding-top: 1rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 0.9rem; color: var(--ink-soft); }
td.num, th.num { text-align: right; white-space: nowrap; }
td code { font-size: 0.85rem; }

.legend { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-1); padding: 0; list-style: none; font-size: 0.95rem; }
.legend li { display: flex; align-items: center; gap: 0.4rem; }
.legend svg { flex: none; }

.chart { width: 100%; max-width: 760px; height: auto; display: block; overflow: visible; }
.chart text { font: 12px 'Atkinson Hyperlegible', system-ui, sans-serif; fill: var(--ink-soft); }
.chart .axis { stroke: var(--edge); stroke-width: 1; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .ref { stroke: var(--edge); stroke-dasharray: 4 4; }
svg .g1 { stroke: var(--g1); fill: var(--g1); }
svg .g2 { stroke: var(--g2); fill: var(--g2); }
svg .s1 { stroke: var(--s1); fill: var(--s1); }
svg .s2 { stroke: var(--s2); fill: var(--s2); }
svg .neutral { stroke: var(--blue); fill: var(--blue); }
svg .mean { stroke: var(--ink); stroke-width: 2; }
svg .line { fill: none; stroke-width: 2; }
svg .point { stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; stroke: none; cursor: default; }
.chart .label-strong { fill: var(--ink); font-weight: 700; }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  font-size: 0.88rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-control);
  max-width: 16rem;
  z-index: 10;
}
.empty-state { text-align: center; padding: var(--space-4) var(--space-2); }
