/* Colour carries one meaning here: a brand. The interface itself stays in ink and paper, so the
   only hues on a page are the tracked brands (--series-*, from a validated categorical palette
   in fixed order) and the reserved status colours. */
:root {
  color-scheme: light;
  --page: #f1f3f0;
  --panel: #fcfcfb;
  --ink: #16211e;
  --ink-2: #4e5a55;
  --ink-3: #6f7a75;
  --line: #dde2de;
  --line-strong: #bfc8c2;
  --link: #1c5cab;
  --button: #16211e;
  --button-ink: #fcfcfb;
  --focus: #2a78d6;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --series-0: #8b9590;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #121413;
    --panel: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #96958c;
    --line: #2e302e;
    --line-strong: #474a47;
    --link: #86b6ef;
    --button: #f0efec;
    --button-ink: #121413;
    --focus: #6da7ec;
    --series-0: #7d827f;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #0ca30c;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
h1, h2, p, ul, ol, figure, table { margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
h1.quote { font-weight: 500; max-width: 34ch; }
h1.quote::before { content: "“"; }
h1.quote::after { content: "”"; }
h2 { font-size: 1rem; line-height: 1.3; font-weight: 600; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
code { font-size: 0.9em; background: var(--page); border: 1px solid var(--line); border-radius: 3px; padding: 0 0.3em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--panel); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }
.muted { color: var(--ink-3); }
.strong { font-weight: 600; }

/* Shell: navigation on the paper, content beside it. */
.shell { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
.side { padding: 1.5rem 1rem 1rem 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; border-right: 1px solid var(--line); }
main { padding: 2rem 2.5rem 4rem; display: flex; flex-direction: column; gap: 1.5rem; max-width: 78rem; width: 100%; }
.wordmark { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }

.switch { position: relative; }
.switch summary { list-style: none; display: flex; align-items: center; gap: 0.6rem; cursor: pointer; padding: 0.4rem 0.5rem; margin: 0 -0.5rem; border-radius: 6px; }
.switch summary::-webkit-details-marker { display: none; }
.switch summary::after { content: ""; margin-left: auto; width: 0.45rem; height: 0.45rem; border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3); transform: rotate(45deg) translateY(-2px); }
.switch summary:hover { background: var(--line); }
.switch-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; width: 1.6rem; height: 1.6rem; border-radius: 5px; background: var(--ink); color: var(--panel); display: grid; place-items: center; font-size: 0.8rem; font-weight: 700; }
.switch ul { list-style: none; padding: 0.35rem; margin-top: 0.25rem; position: absolute; left: -0.5rem; right: -0.5rem; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; z-index: 5; box-shadow: 0 6px 20px rgb(22 33 30 / 0.12); }
.switch li a { display: block; padding: 0.35rem 0.5rem; border-radius: 5px; color: var(--ink); text-decoration: none; }
.switch li a:hover { background: var(--page); }
.switch li a[aria-current] { font-weight: 600; }
.switch-new { border-top: 1px solid var(--line); margin-top: 0.35rem; padding-top: 0.35rem; }

.side nav { display: flex; flex-direction: column; gap: 0.25rem; }
.side nav a { color: var(--ink-2); text-decoration: none; display: block; padding: 0.3rem 0.5rem; margin: 0 -0.5rem; border-radius: 5px; }
.side nav a:hover { background: var(--line); color: var(--ink); }
.nav-head { font-size: 0.85rem; color: var(--ink-3); }
.projects, .subnav { list-style: none; padding: 0; }
.projects > li > a { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projects > li > a.open { font-weight: 700; }
.subnav { margin: 0.1rem 0 0.6rem 0.5rem; padding-left: 0.75rem; border-left: 1px solid var(--line-strong); }
.side nav a[aria-current="page"] { color: var(--ink); font-weight: 600; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.side-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; }
.side-foot a { color: var(--ink-2); text-decoration: none; }
.side-foot a:hover { color: var(--ink); text-decoration: underline; }

/* Page furniture */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.sub { color: var(--ink-2); max-width: 70ch; margin-top: 0.35rem; }
.lead { color: var(--ink-2); max-width: 62ch; font-size: 1.05rem; }
.crumb { color: var(--ink-3); font-size: 0.9rem; margin-bottom: -0.75rem; }
.footnote { color: var(--ink-3); font-size: 0.87rem; max-width: 80ch; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem 1.4rem; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.narrow { max-width: 34rem; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.callout { border-color: var(--ink); }

.alert { padding: 0.7rem 1rem; border-radius: 6px; border: 1px solid var(--line-strong); border-left-width: 4px; background: var(--panel); max-width: 80ch; }
.alert-error { border-left-color: var(--critical); }
.alert-ok { border-left-color: var(--good); }
.alert-info { border-left-color: var(--ink-3); }

.tag { display: inline-block; font-size: 0.78rem; line-height: 1.5; padding: 0 0.45rem; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--ink-2); text-decoration: none; white-space: nowrap; vertical-align: 0.08em; }
a.tag:hover { border-color: var(--ink-2); color: var(--ink); }

/* Forms */
label, .field { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 500; font-size: 0.92rem; }
.field-label { font-weight: 500; }
label small, .field small { font-weight: 400; color: var(--ink-3); font-size: 0.85rem; }
label.check { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 400; font-size: 1rem; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type="text"], input[type="email"], input[type="password"], select, textarea {
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 0.45rem 0.6rem; width: 100%; min-width: 0;
}
input:disabled { color: var(--ink-3); background: var(--page); }
input[size] { width: auto; }
textarea { resize: vertical; line-height: 1.45; }
fieldset { border: 0; padding: 0; margin: 0; display: contents; }
.stack { display: flex; flex-direction: column; gap: 0.9rem; align-items: stretch; }
.stack > button { align-self: flex-start; }
.row { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: flex-end; }
.stack > .row { align-items: flex-start; }
.row > label { flex: 1 1 11rem; }
.row > label:has(input[size]) { flex: 0 1 auto; }
.inline { display: inline-flex; gap: 0.5rem; }
.inline select { width: auto; padding: 0.2rem 0.4rem; }
.copyrow { display: flex; gap: 0.6rem; }
button { cursor: pointer; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 0.45rem 0.9rem; font-weight: 600; white-space: nowrap; }
button:hover { border-color: var(--ink-2); }
button.primary { background: var(--button); color: var(--button-ink); border-color: var(--button); }
button.primary:hover { opacity: 0.88; }
button.danger { color: var(--critical); border-color: var(--critical); align-self: flex-start; }
button.link { background: none; border: 0; padding: 0; color: var(--link); font-weight: 400; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
button.danger-link { color: var(--critical); align-self: flex-start; }
.side-foot button.link { color: var(--ink-2); text-decoration: none; }
.side-foot button.link:hover { color: var(--ink); text-decoration: underline; }

.filters { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: flex-end; }
.filters label { flex-direction: row; align-items: center; gap: 0.5rem; color: var(--ink-2); font-weight: 400; }
.filters select { width: auto; padding: 0.3rem 0.5rem; color: var(--ink); }
.filters .export { margin-left: auto; color: var(--ink-2); font-size: 0.9rem; padding-bottom: 0.35rem; }

.tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: 0.4rem 0; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

/* Tables */
table.data { border-collapse: collapse; width: 100%; }
table.data caption { text-align: left; font-weight: 600; padding-bottom: 0.4rem; }
main > table.data, #run > table.data { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
main > table.data th:first-child, main > table.data td:first-child, #run > table.data th:first-child, #run > table.data td:first-child { padding-left: 1.4rem; }
main > table.data th:last-child, main > table.data td:last-child, #run > table.data th:last-child, #run > table.data td:last-child { padding-right: 1.4rem; }
#run { display: flex; flex-direction: column; gap: 1.5rem; }
.data th { text-align: left; font-weight: 500; font-size: 0.85rem; color: var(--ink-3); padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.data td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data tbody tr:last-child td { border-bottom: 0; }
.data.compact th, .data.compact td { padding: 0.42rem 0.4rem; }
.data.compact th { white-space: normal; vertical-align: bottom; line-height: 1.25; }
.data .name { white-space: nowrap; }
.panel:has(> table.data) { overflow-x: auto; }
.data.compact th:first-child, .data.compact td:first-child { padding-left: 0; }
.data.compact th:last-child, .data.compact td:last-child { padding-right: 0; }
.data .num { text-align: right; white-space: nowrap; }
.data .wide { min-width: 16rem; width: 46%; }
.data .actions { text-align: right; white-space: nowrap; }
.data .barcol { width: 16%; min-width: 4rem; vertical-align: middle; padding-left: 0; }
.data tr.own td { font-weight: 600; }
.data tr.off td { color: var(--ink-3); }
.data tr.off a { color: inherit; }
.data a.strong { color: var(--ink); }
.url { color: var(--ink-3); font-size: 0.87rem; word-break: break-all; }

/* Admin: tables you edit in place. Each row's fields belong to the form in its last cell. */
.data.keys td, .data.models td { vertical-align: middle; }
.data.models input[type="text"], .data.models select, .keyform input { padding: 0.35rem 0.5rem; }
.data.models input[type="text"] { min-width: 9rem; }
.data.models select { min-width: 6.5rem; }
.data.models .actions form { display: inline-block; margin-left: 0.75rem; }
.keyform { display: flex; gap: 0.5rem; }
.keyform input { min-width: 11rem; }
.warn { display: block; margin-top: 0.35rem; padding-left: 0.6rem; border-left: 3px solid var(--warning); color: var(--ink-2); font-size: 0.87rem; max-width: 34ch; }

.bar { display: block; width: 100%; height: 4px; border-radius: 2px; overflow: hidden; }
.bar-track { fill: var(--line); }
.bar-fill { fill: var(--ink-2); }

.swatch { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 2px; margin-right: 0.5rem; background: var(--series-0); }
.s1 { --c: var(--series-1); } .s2 { --c: var(--series-2); } .s3 { --c: var(--series-3); } .s4 { --c: var(--series-4); }
.s5 { --c: var(--series-5); } .s6 { --c: var(--series-6); } .s7 { --c: var(--series-7); } .s8 { --c: var(--series-8); }
.s0 { --c: var(--series-0); }
.swatch[class*=" s"] { background: var(--c); }

.state { white-space: nowrap; text-decoration: none; color: var(--ink); }
a.state:hover { text-decoration: underline; }
.state::before { content: ""; display: inline-block; width: 0.55rem; height: 0.55rem; margin-right: 0.45rem; border-radius: 50%; }
.state-yes::before { background: var(--good); }
.state-no { color: var(--ink-3); }
.state-warn::before { background: var(--warning); border-radius: 1px; }
.state-no::before { border: 1.5px solid var(--ink-3); }
.state-failed::before { background: var(--critical); border-radius: 1px; transform: rotate(45deg); }
.mentions .state { font-weight: 400; font-size: 0.87rem; color: var(--ink-2); margin-left: 0.35rem; }
.sentiment-positive::before { background: var(--good); }
.sentiment-neutral::before { border: 1.5px solid var(--ink-3); }
.sentiment-negative::before { background: var(--critical); border-radius: 1px; transform: rotate(45deg); }
.state-running::before { border: 1.5px solid var(--ink-2); border-top-color: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Dashboard */
/* The dividers are the grid gap showing the line colour, so any number of stats wraps cleanly. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stat { padding: 1.1rem 1.4rem 1.2rem; background: var(--panel); display: flex; flex-direction: column; gap: 0.15rem; }
.stat h2 { font-size: 0.9rem; font-weight: 500; color: var(--ink-2); }
.figure { font-size: 2.5rem; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; }
.delta { font-size: 0.87rem; color: var(--ink-2); }
.arrow { display: inline-block; width: 0; height: 0; margin-right: 0.35rem; border-left: 0.3rem solid transparent; border-right: 0.3rem solid transparent; }
.delta.up .arrow { border-bottom: 0.45rem solid var(--good); }
.delta.down .arrow { border-top: 0.45rem solid var(--critical); }
.delta.flat .arrow { width: 0.55rem; border: 0; border-top: 2px solid var(--ink-3); vertical-align: 0.25em; }
.note { font-size: 0.85rem; color: var(--ink-3); }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--ink-3); font-size: 12px; }
.chart .series path { fill: none; stroke: var(--c, var(--series-0)); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series circle { fill: var(--c, var(--series-0)); stroke: var(--panel); stroke-width: 2; }
.chart .series.own path { stroke-width: 3; }
.chart .direct { fill: var(--ink-2); font-size: 12.5px; }
.chart .series.own .direct { fill: var(--ink); font-weight: 600; }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; margin-top: 0.6rem; font-size: 0.87rem; color: var(--ink-2); }
.legend .swatch { width: 0.9rem; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 0.4rem; }
.tip { position: absolute; top: 0; pointer-events: none; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 0.5rem 0.7rem; font-size: 0.87rem; box-shadow: 0 6px 20px rgb(22 33 30 / 0.14); min-width: 9rem; z-index: 2; }
.tip-day { color: var(--ink-3); margin-bottom: 0.25rem; }
.tip-row { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.tip-row b { min-width: 2.6rem; text-align: right; }
.tip-row i { width: 0.8rem; height: 2px; background: var(--c, var(--series-0)); flex: none; }
.tip-row span { color: var(--ink-2); }

.checklist { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.checklist li { padding-left: 1.6rem; position: relative; }
.checklist li::before { content: ""; position: absolute; left: 0; top: 0.3rem; width: 0.85rem; height: 0.85rem; border: 1.5px solid var(--line-strong); border-radius: 50%; }
.checklist li.done::before { background: var(--good); border-color: var(--good); }

/* Answer */
.reading { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem; align-items: start; }
.reading aside { display: flex; flex-direction: column; gap: 1.5rem; }
.prose { max-width: 68ch; overflow-wrap: anywhere; }
.prose > * + * { margin-top: 0.8em; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-size: 1.05rem; font-weight: 600; margin-top: 1.4em; letter-spacing: 0; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.3em; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 0.3rem 0.6rem; text-align: left; }
.prose blockquote { margin: 0; padding-left: 1rem; border-left: 3px solid var(--line-strong); color: var(--ink-2); }
.mentions { padding-left: 1.4rem; display: flex; flex-direction: column; gap: 0.3rem; }
.mentions li.own { font-weight: 600; }
.mentions li.other { color: var(--ink-2); }
.mentions li.other .muted { font-size: 0.87rem; margin-left: 0.35rem; }
.queries { padding-left: 1.4rem; display: flex; flex-direction: column; gap: 0.3rem; overflow-wrap: anywhere; }
.sourcelist { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.sourcelist a { display: block; overflow-wrap: anywhere; }
.sourcelist .muted { font-size: 0.87rem; }
.brand h2 .swatch { display: none; }

/* Pages without navigation */
.bare-main { max-width: 26rem; margin: 0 auto; padding: 4rem 1.5rem; gap: 1.25rem; }
.bare-main .wordmark { margin-bottom: 1.5rem; }
.aside { color: var(--ink-2); }

@media (max-width: 62rem) {
  .split, .reading { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 48rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 1rem; gap: 0.75rem; }
  .side-foot { flex-direction: row; flex-wrap: wrap; gap: 1rem; margin-top: 0; }
  .subnav { display: flex; flex-wrap: wrap; gap: 0 0.25rem; margin: 0.1rem 0 0.4rem; padding-left: 0; border-left: 0; }
  .subnav a { margin: 0; }
  main { padding: 1.25rem 1rem 3rem; }
  main > table.data, #run > table.data, .panel > table.data { display: block; overflow-x: auto; }
  .figure { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .state-running::before { animation: none; }
}
