/* Diglet — CodeHurdle ops console.
   One loud thing: the strata strip (a journey as bands sized by time, the
   failing band in pink). Everything else stays quiet: white sheets on a cool
   grey-green ground, hairline rules, tabular figures. */

:root {
  --ground: #F2F3EF;
  --surface: #FFFFFF;
  --sunk: #F7F8F5;
  --ink: #1C2220;
  --muted: #5D6662;
  --faint: #8A928E;
  --rule: #D6DAD3;
  --rule-soft: #E6E9E3;
  --pink: #C93D72;
  --pink-soft: #F8E4EC;
  --green: #1F7A52;
  --green-soft: #E1F0E8;
  --amber: #A86B12;
  --amber-soft: #F6EBD8;
  --blue: #2E6286;
  --blue-soft: #E2ECF3;
  --band-1: #C9CFC6;
  --band-2: #B3BBB0;
  --band-wait: #E3E6DF;
  --focus: #2E6286;
  --ui: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --gutter: 24px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #121614;
    --surface: #1A1F1D;
    --sunk: #161B19;
    --ink: #E4E8E2;
    --muted: #9AA39E;
    --faint: #6F7873;
    --rule: #2E3532;
    --rule-soft: #242A27;
    --pink: #E8679A;
    --pink-soft: #3A1F2A;
    --green: #52B788;
    --green-soft: #18302A;
    --amber: #D9A04A;
    --amber-soft: #352A18;
    --blue: #7DB0D4;
    --blue-soft: #1C2B36;
    --band-1: #3A423E;
    --band-2: #4A544F;
    --band-wait: #262D2A;
    --focus: #7DB0D4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #121614; --surface: #1A1F1D; --sunk: #161B19; --ink: #E4E8E2; --muted: #9AA39E; --faint: #6F7873;
  --rule: #2E3532; --rule-soft: #242A27; --pink: #E8679A; --pink-soft: #3A1F2A; --green: #52B788; --green-soft: #18302A;
  --amber: #D9A04A; --amber-soft: #352A18; --blue: #7DB0D4; --blue-soft: #1C2B36; --band-1: #3A423E; --band-2: #4A544F;
  --band-wait: #262D2A; --focus: #7DB0D4; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 14px/1.45 var(--ui);
  font-variant-numeric: tabular-nums;
  font-variation-settings: "wdth" 100;
}
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
code, .mono, pre, kbd { font-family: var(--mono); font-size: 12.5px; font-variant-ligatures: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: stretch; gap: 28px;
  height: 46px; padding: 0 var(--gutter);
  background: var(--surface); border-bottom: 1px solid var(--rule);
}
.mark {
  display: flex; align-items: center; gap: 8px;
  font-weight: 750; font-size: 17px; letter-spacing: -0.02em; text-decoration: none;
  font-variation-settings: "wdth" 125;
}
.mark svg { width: 18px; height: 18px; }
.mark-hole { fill: var(--ink); }
.mark-mound { fill: var(--pink); }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: flex; align-items: center; padding: 0 10px; white-space: nowrap;
  color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--pink); font-weight: 600; }
.bar-end { display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.who { color: var(--muted); font-size: 13px; }
.signout { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.signout:hover { color: var(--ink); }
.badge { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; text-decoration: none; }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.badge-warn .badge-dot { background: var(--amber); }
.badge-error .badge-dot { background: var(--pink); }
.badge-error { color: var(--pink); font-weight: 600; }

/* Page */
main { padding: 22px var(--gutter) 64px; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; margin-bottom: 18px; }
.head h1 { font-size: 22px; font-variation-settings: "wdth" 112; }
.head .sub { color: var(--muted); }
.head .push { margin-left: auto; }
.crumb { color: var(--muted); text-decoration: none; }
.crumb:hover { color: var(--ink); }
h2 { font-size: 15px; font-variation-settings: "wdth" 108; }
.section { margin-top: 28px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 10px; }
.section-head .sub, .note { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); }
.grid > .section, .stack > .section:first-child { margin-top: 0; }
.cols-2 { display: grid; gap: 28px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .cols-2 { grid-template-columns: minmax(0, 1fr); } }

.sheet { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
.pad { padding: 14px 16px; }

/* Ledger: the row of key figures, read left to right. */
.ledger {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
}
.ledger > div { padding: 12px 16px 14px; border-left: 1px solid var(--rule-soft); min-width: 0; }
.ledger > div:first-child { border-left: 0; }
.figure { display: block; font-size: 28px; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; font-variation-settings: "wdth" 90; }
.figure small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.figure-label { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.figure-alarm { color: var(--pink); }
.figure-warn { color: var(--amber); }
.figure-good { color: var(--green); }
@media (max-width: 640px) {
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger > div { border-left: 0; border-top: 1px solid var(--rule-soft); }
  .ledger > div:nth-child(-n+2) { border-top: 0; }
  .ledger > div:nth-child(even) { border-left: 1px solid var(--rule-soft); }
}

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule-soft); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--sunk); color: var(--muted); font-weight: 500; font-size: 12.5px; border-bottom-color: var(--rule); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--sunk); }
td.num, th.num { text-align: right; }
td.wrap { white-space: normal; min-width: 240px; max-width: 640px; overflow-wrap: anywhere; }
td.dim, .dim { color: var(--muted); }
.row-link { text-decoration: none; }
tr.row-fault td:first-child { box-shadow: inset 2px 0 0 var(--pink); }
tr.row-warn td:first-child { box-shadow: inset 2px 0 0 var(--amber); }
.empty { padding: 22px 16px; color: var(--muted); }
.more td { text-align: center; padding: 0; }
.more button { width: 100%; padding: 10px; }
table.kv th { position: static; width: 1%; background: none; border: 0; padding: 4px 18px 4px 0; font-size: 13px; }
table.kv td { border: 0; padding: 4px 0; white-space: normal; }
table.kv tr:hover td { background: none; }

/* Verdicts: a small square and a word. Colour never carries meaning alone. */
.v { display: inline-flex; align-items: center; gap: 7px; }
.v::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--faint); flex: none; }
.v-good::before { background: var(--green); }
.v-bad::before { background: var(--amber); }
.v-fault { color: var(--pink); font-weight: 600; }
.v-fault::before { background: var(--pink); }
.v-open::before { background: var(--blue); border-radius: 50%; }
.lvl { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.lvl-error { color: var(--pink); font-weight: 600; }
.lvl-warn { color: var(--amber); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border: 1px solid var(--rule);
  border-radius: 999px; background: var(--surface); color: var(--ink); text-decoration: none; font-size: 13px;
}
.chip b { font-weight: 600; }
.chip span { color: var(--muted); }
.chip:hover { border-color: var(--muted); }
.chip[aria-current="true"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.chip[aria-current="true"] span { color: var(--surface); opacity: .75; }

/* Notices */
.notice { padding: 10px 14px; border-radius: 6px; border: 1px solid var(--rule); background: var(--surface); margin-bottom: 14px; }
.notice-error { border-color: var(--pink); background: var(--pink-soft); }
.notice-warn { border-color: var(--amber); background: var(--amber-soft); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

/* Failure callout on a submission or package */
.failure {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 18px; align-items: baseline;
  padding: 14px 16px; border: 1px solid var(--pink); border-left-width: 4px; border-radius: 6px; background: var(--surface);
}
.failure-id { font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--pink); }
.failure-what { font-weight: 600; }
.failure p { grid-column: 1 / -1; color: var(--muted); }
.failure pre { grid-column: 1 / -1; margin: 6px 0 0; }
.copy { border: 1px solid var(--rule); background: var(--surface); color: var(--muted); border-radius: 4px; padding: 1px 7px; font: 500 12px var(--ui); cursor: pointer; }
.copy:hover { color: var(--ink); border-color: var(--muted); }

/* The strata strip */
.strata-block { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 16px 16px 12px; }
.strata { display: block; width: 100%; height: 22px; border-radius: 3px; overflow: hidden; }
.band { stroke: var(--surface); stroke-width: .25; vector-effect: non-scaling-stroke; }
.band-step { fill: var(--band-1); }
.band-step.band-alt { fill: var(--band-2); }
.band-wait { fill: var(--band-wait); }
.band-retry { fill: var(--amber); }
.band-fail { fill: var(--pink); }
.band-done { fill: var(--green); }
.band-open { fill: var(--blue); }
.strata-legend { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 10px 0 0; padding: 0; list-style: none; counter-reset: step; font-size: 13px; }
.strata-legend li { counter-increment: step; display: flex; align-items: baseline; gap: 6px; padding-right: 16px; }
.strata-legend li::before { content: counter(step); font-family: var(--mono); font-size: 11px; color: var(--faint); }
.strata-legend .t { color: var(--muted); }
.strata-legend .fail { color: var(--pink); font-weight: 600; }
.strata-legend .retry { color: var(--amber); }
.strata-legend .done { color: var(--green); }
.strata-total { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--muted); }

/* Charts */
.spark { display: block; width: 100%; height: 56px; }
.spark-lg { height: 120px; }
.spark-area { fill: var(--blue-soft); }
.spark-line { fill: none; stroke: var(--blue); stroke-width: 1.5; }
.spark-empty line { stroke: var(--rule); }
.chart { min-width: 0; }
.chart-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 4px; }
.chart-head span:last-child { color: var(--muted); }
.chart-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.charts { display: grid; gap: 18px 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.meter { display: block; width: 100%; height: 4px; margin-top: 6px; border-radius: 2px; overflow: hidden; }
.meter-track { fill: var(--rule-soft); }
.meter-ok { fill: var(--blue); }
.meter-warn { fill: var(--amber); }
.meter-alarm { fill: var(--pink); }

/* Machines */
.machines { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.machine { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 14px 16px 16px; min-width: 0; }
.machine-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.machine-head h2 { font-size: 17px; }
.machine-head .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.machine-head .push { margin-left: auto; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stats b { display: block; font-size: 20px; font-weight: 600; font-variation-settings: "wdth" 90; }
.stats span { color: var(--muted); font-size: 12.5px; }
@media (max-width: 480px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.config { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 20px; font-size: 13px; }
.config dt { color: var(--muted); }
.config dd { margin: 0; }

/* Forms */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 12px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field label, .field .label { font-size: 12.5px; color: var(--muted); }
input, select, button { font: inherit; color: inherit; }
input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="datetime-local"], select {
  height: 32px; padding: 0 9px; border: 1px solid var(--rule); border-radius: 5px; background: var(--surface); min-width: 0;
}
input[type="text"], input[type="search"] { width: 15em; }
input.id { width: 21em; font-family: var(--mono); font-size: 12.5px; }
input:hover, select:hover { border-color: var(--faint); }
.btn {
  height: 32px; padding: 0 14px; border: 1px solid var(--ink); border-radius: 5px; background: var(--ink); color: var(--surface);
  font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.btn-quiet { background: var(--surface); color: var(--ink); border-color: var(--rule); font-weight: 500; }
.btn-quiet:hover { border-color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 5px; overflow: hidden; background: var(--surface); height: 32px; }
.seg a { display: flex; align-items: center; padding: 0 10px; text-decoration: none; color: var(--muted); border-left: 1px solid var(--rule-soft); font-size: 13px; }
.seg a:first-child { border-left: 0; }
.seg a[aria-current="true"] { background: var(--ink); color: var(--surface); }
.toggle { display: inline-flex; align-items: center; gap: 8px; height: 32px; cursor: pointer; }
.toggle input { accent-color: var(--pink); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live .live-dot { background: var(--pink); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live .live-dot { animation: none; } }

/* Code and logs */
pre { margin: 0; padding: 12px 14px; overflow: auto; background: var(--sunk); border: 1px solid var(--rule-soft); border-radius: 5px; line-height: 1.55; max-height: 560px; }
pre.code { counter-reset: line; }
.log td { font-family: var(--mono); font-size: 12px; padding-top: 5px; padding-bottom: 5px; }
.log td.msg { white-space: normal; min-width: 280px; overflow-wrap: anywhere; }
.log .kv { color: var(--muted); }
.log .kv b { color: var(--ink); font-weight: 500; }
.fields { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 2px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.fields b { color: var(--ink); font-weight: 500; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details[open] summary { margin-bottom: 8px; }
.htmx-request .loading, .loading.htmx-request { opacity: 1; }
.loading { opacity: 0; transition: opacity .2s; color: var(--muted); font-size: 13px; }
.refresh-note { color: var(--faint); font-size: 12.5px; }

/* Login */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); }
.login-art { position: relative; overflow: hidden; background: var(--ink); color: var(--ground); padding: 40px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art .mark { color: var(--ground); font-size: 22px; }
.login-art .mark-hole { fill: var(--ground); }
.login-art p { max-width: 30em; color: #B8C0BB; font-size: 15px; }
.login-strata { display: flex; height: 26px; gap: 2px; margin-top: 18px; }
.login-strata i { display: block; background: #3A423E; border-radius: 2px; }
.login-strata i:nth-child(odd) { background: #4A544F; }
.login-strata i.f { background: var(--pink); }
.login-form { background: var(--surface); padding: 56px 40px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.login-form h1 { font-size: 22px; font-variation-settings: "wdth" 112; }
.login-form .field input { width: 100%; height: 38px; }
.login-form .btn { height: 40px; justify-content: center; }
.login-form .hint { color: var(--muted); font-size: 13px; }
@media (max-width: 760px) {
  .login-page { grid-template-columns: 1fr; }
  .login-art { padding: 24px 16px; min-height: 0; }
  .login-art p { display: none; }
  .login-form { padding: 32px 16px; justify-content: start; }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  /* Two rows: brand and account on top, every section on the second row. */
  .bar { flex-wrap: wrap; height: auto; gap: 0 14px; }
  .bar .mark { height: 42px; }
  .bar-end { margin-left: auto; height: 42px; }
  .nav { order: 3; flex: 1 0 100%; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); border-top: 1px solid var(--rule); }
  .nav a { height: 38px; }
  .who { display: none; }
  main { padding-top: 16px; }
  .head h1 { font-size: 19px; }
  .figure { font-size: 24px; }
  input[type="text"], input[type="search"], input.id { width: 100%; }
  .filters .field { flex: 1 1 140px; }
  .filters .field.wide { flex-basis: 100%; }
}
