/* Colours, borders and type come from the SjoerdUi theme on <html> (data-sj-style / data-sj-mode).
   The page only adds its own layout and the cluster colours of the charts. */
:root {
  color-scheme: light;
  --edge: #8d8c85; --noise: #a3a29b; --other: #b9b8b0;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
}
:root[data-sj-mode=dark] {
  color-scheme: dark;
  --edge: #77766f; --noise: #6f6e68; --other: #57564f;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 var(--sj-font-family, system-ui, sans-serif); background: var(--sj-page); color: var(--sj-ink); }
header { display: flex; align-items: center; gap: 12px 16px; padding: 14px 20px 6px; flex-wrap: wrap; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 6px; }
h2.spaced { margin-top: 22px; }
#dataset { margin: 0; flex: 1 1 280px; }
.muted { color: var(--sj-muted); }
.small { font-size: 13px; }
code { font-size: .92em; }
.banner { margin: 6px 20px; padding: 8px 12px; border-radius: var(--sj-radius); background: var(--sj-warning-surface); color: var(--sj-warning-ink); }
main > .banner { margin: 0; }
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; padding: 10px 20px 40px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; padding: 10px 12px 40px; } header { padding: 12px 12px 4px; } .banner { margin: 6px 12px; } }

form, .card, .cluster, .tile { background: var(--sj-surface); border: var(--sj-border-width) solid var(--sj-border); border-radius: var(--sj-card-radius); }
form { padding: 12px; display: grid; gap: 14px; position: sticky; top: 10px; max-height: calc(100vh - 20px); overflow: auto; }
@media (max-width: 900px) { form { position: static; max-height: none; } }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
select, input[type=number], input[type=month], input[type=text] { width: 100%; min-height: 44px; padding: 8px 10px; font: inherit; color: var(--sj-ink);
  background: var(--sj-surface); border: var(--sj-border-width) solid var(--sj-border); border-radius: var(--sj-control-radius); }
.description { font-size: 13px; margin: 6px 0; }
.params { display: grid; gap: 10px; margin-top: 8px; }
.param { display: block; min-width: 0; }
.param > span { display: block; font-size: 13px; color: var(--sj-muted); margin-bottom: 2px; }
.param > span b { color: var(--sj-ink); font-variant-numeric: tabular-nums; }
.param small { display: block; color: var(--sj-muted); font-size: 12px; margin-top: 2px; }
.check { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; min-height: 44px; }
.check small { flex-basis: 100%; }
.check input { width: 20px; height: 20px; accent-color: var(--sj-accent); }
.period { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
button { font: inherit; min-height: 44px; padding: 8px 14px; border-radius: var(--sj-control-radius); border: var(--sj-border-width) solid var(--sj-border);
  background: var(--sj-surface); color: var(--sj-ink); cursor: pointer; font-weight: var(--sj-control-weight); }
button.primary { background: var(--sj-accent); border-color: var(--sj-accent); color: var(--sj-surface); font-weight: 600; }
button.quiet, button.small { min-height: 36px; padding: 4px 10px; }
button.danger { color: var(--sj-bad); }
button:disabled { opacity: .6; cursor: progress; }
:focus-visible { outline: 2px solid var(--sj-focus); outline-offset: 2px; }
.error { color: var(--sj-bad); margin: 0; }
[hidden] { display: none !important; }

main { display: grid; gap: 14px; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tile { padding: 10px 12px; }
.tile b { display: block; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile span { font-size: 13px; color: var(--sj-muted); }
.tile small { display: block; font-size: 12px; color: var(--sj-muted); }
.card { padding: 14px; }
.panel { min-width: 0; }
.plot-bar { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.plot-bar h2 { flex: 1 1 200px; margin: 0; }
#plot-wrap { position: relative; margin-top: 6px; }
#plot { display: block; width: 100%; height: min(64vh, 620px); touch-action: none; cursor: grab; border-radius: var(--sj-radius); }
#plot.dragging { cursor: grabbing; }
#plot .edge { stroke: var(--edge); }
#plot .mark { stroke: var(--sj-surface); stroke-width: 2; }
#plot .dim { opacity: .12; }
#plot text { fill: var(--sj-ink); font-size: 12px; paint-order: stroke; stroke: var(--sj-surface); stroke-width: 3px; pointer-events: none; }
#plot text.tag { font-weight: 700; font-size: 14px; }
.tooltip { position: absolute; pointer-events: none; z-index: 2; max-width: 300px; padding: 8px 10px; border-radius: var(--sj-radius);
  background: var(--sj-surface); border: 1px solid var(--sj-border); box-shadow: 0 4px 14px rgb(0 0 0 / .18); font-size: 13px; }
.tooltip b { display: block; }
.tooltip dl { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; margin: 4px 0 0; }
.tooltip dt { color: var(--sj-muted); display: flex; align-items: center; gap: 5px; white-space: nowrap; } .tooltip dd { margin: 0; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 8px; }
.legend button { min-height: 36px; padding: 2px 10px; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 400; }
.legend button[aria-pressed=true] { border-color: var(--sj-ink); box-shadow: inset 0 0 0 1px var(--sj-ink); }
.swatch { width: 16px; height: 16px; flex: none; }

.clusters { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; }
.cluster { padding: 10px 12px; }
.cluster.pinned { border-color: var(--sj-ink); }
.cluster h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 15px; }
.cluster h3 sj-badge { margin-left: auto; font-weight: 400; }
.cluster ul { list-style: none; margin: 0 0 8px; padding: 0; font-size: 13px; }
.cluster li { display: flex; justify-content: space-between; gap: 8px; }
.cluster li span:last-child { color: var(--sj-muted); white-space: nowrap; }
.cluster p { margin: 0; font-size: 13px; color: var(--sj-muted); }
.cluster button { min-height: 32px; padding: 2px 8px; margin: 6px 6px 0 0; font-size: 13px; }

.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 12px; margin: 10px 0; }
.inline-form .param { flex: 1 1 200px; }
.inline-form .param.narrow { flex: 0 1 110px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
sj-data-table { display: block; margin-top: 10px; }
sj-busy { display: block; margin: 8px 0; }

.signin-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.signin-page .card { width: min(420px, 100%); padding: 24px; display: grid; gap: 12px; }
.signin-page p { margin: 0; }
sign-in-kit { display: grid; gap: 10px; justify-items: start; }

/* Charts: recessive grid and axes, text in text colours, marks in the cluster colours. */
.chart { position: relative; margin-top: 8px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid { stroke: var(--sj-line); stroke-width: 1; }
.chart .axis { fill: var(--sj-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--s1); stroke: var(--sj-surface); stroke-width: 2; }
.chart .cross { stroke: var(--sj-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .band { fill: var(--sj-ink); opacity: .06; }
.chart .seg { stroke: var(--sj-surface); stroke-width: 1.5; }
.chart .seg.dim { opacity: .15; }
.chart .value { fill: var(--sj-ink); font-size: 12px; font-weight: 600; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.charts h3 { font-size: 14px; margin: 0; }
.charts p { margin: 0; }
