/* Gary's dashboard.
 *
 * Light is the base declaration; dark is redefined twice — once for the OS
 * setting and once for an explicit toggle — so the toggle wins in both
 * directions. Every colour is a token: nothing below this block names a hex.
 *
 * The lane palette (--s1…--s6) is the validated categorical set. Slots are
 * assigned in lane order and never cycled, so no two lanes on screen share a
 * colour, and the ordering is the one that clears colour-blind separation on
 * adjacent pairs — which is exactly how lanes are stacked.
 */

:root {
  color-scheme: light;

  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --rule: #e1e0d9;
  --rule-2: rgba(11, 11, 11, 0.1);

  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;

  --good: #0ca30c;
  --good-text: #006300;
  --warn: #fab219;
  --serious: #ec835a;
  --bad: #d03b3b;
  --info: #2a78d6;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --rule: #2c2c2a;
    --rule-2: rgba(255, 255, 255, 0.1);

    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;

    --good-text: #0ca30c;
    --info: #3987e5;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --rule: #2c2c2a;
  --rule-2: rgba(255, 255, 255, 0.1);

  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #008300;

  --good-text: #0ca30c;
  --info: #3987e5;
}

/* Each lane sets --lane once; every mark inside it reads that. */
.s1 { --lane: var(--s1); }
.s2 { --lane: var(--s2); }
.s3 { --lane: var(--s3); }
.s4 { --lane: var(--s4); }
.s5 { --lane: var(--s5); }
.s6 { --lane: var(--s6); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
.m { font-family: var(--mono); }
.dim { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.empty { color: var(--ink-3); font-style: italic; padding: 22px 26px; }

/* ---- top bar ---- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 26px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.01em; }
.brand-mark { display: flex; flex-direction: column; gap: 2px; }
.brand-mark i { display: block; width: 14px; height: 2.5px; border-radius: 2px; }
.brand-mark i:nth-child(1) { background: var(--s1); width: 14px; }
.brand-mark i:nth-child(2) { background: var(--s3); width: 10px; }
.brand-mark i:nth-child(3) { background: var(--s4); width: 12px; }

.crumbs { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs .sep { color: var(--ink-3); }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }

.theme { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.theme-btn {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.6;
}
.theme-btn:hover { color: var(--ink); background: var(--surface-2); }
.theme-btn[aria-pressed="true"] { color: var(--ink); background: var(--surface-2); }

.live { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px color-mix(in srgb, var(--good) 60%, transparent); }
.live.stale .live-dot { background: var(--ink-3); box-shadow: none; }
body.polling .live-dot { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 0 0 70px; }

/* ---- totals: the one hero row ---- */

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 0 44px;
  padding: 22px 26px 20px;
}

.total-v { font-size: 27px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.total-k { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3); margin-top: 3px; display: flex; gap: 8px; }
.total-live { color: var(--info); }

/* ---- cards ---- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 16px;
  padding: 4px 26px 30px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 17px 19px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 13px;
  transition: border-color 120ms, transform 120ms, box-shadow 120ms;
}

.card:hover { border-color: var(--rule-2); transform: translateY(-1px); box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 7%, transparent); }
.card.running { border-color: color-mix(in srgb, var(--info) 55%, var(--rule)); }
.card.failed { border-color: color-mix(in srgb, var(--bad) 45%, var(--rule)); }

.card-id { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.card-flow { font-family: var(--mono); font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; margin-top: -6px; }
.card-req { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- the card's mini strip ---- */

.strip { margin-top: 2px; }
.strip-empty { color: var(--ink-3); font-style: italic; font-size: 12.5px; padding: 10px 0; }

.strip-axis { position: relative; height: 15px; border-bottom: 1px solid var(--rule); margin-left: 94px; }
.strip-axis .tick { position: absolute; bottom: 2px; transform: translateX(-50%); font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.strip-axis .tick.edge { transform: none; }

.strip-row { display: flex; align-items: center; height: 26px; }
.strip-name {
  width: 94px;
  flex: 0 0 94px;
  padding-right: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--lane, var(--ink-2));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.strip-track { position: relative; flex: 1; height: 100%; border-bottom: 1px solid var(--rule); }

.dot {
  position: absolute;
  top: 50%;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  /* A ring in the surface colour keeps overlapping dots legible without
     drawing a border, which would add ink that isn't data. */
  box-shadow: 0 0 0 1.5px var(--surface);
}
.dot.start { background: var(--lane); }
.dot.tool { background: color-mix(in srgb, var(--lane) 55%, var(--surface)); }
.dot.handoff { background: var(--ink-2); }
.dot.finish { background: var(--good); }
.dot.error { background: var(--bad); }
.dot.latest { width: 10px; height: 10px; animation: pulse 1.4s ease-in-out infinite; }

.strip-more { padding-left: 94px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); height: 20px; line-height: 20px; }

/* ---- card foot ---- */

.card-foot { margin-top: auto; padding-top: 4px; display: flex; align-items: center; gap: 12px; }
.foot-left { display: flex; align-items: center; gap: 11px; }
.card-foot .dim { margin-left: auto; font-family: var(--mono); font-size: 11px; }

.marks { display: inline-flex; gap: 4px; }
.mark { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.mark.succeeded { background: var(--good); }
.mark.failed { background: var(--bad); }
.mark.running { background: var(--info); animation: pulse 1.2s ease-in-out infinite; }
.mark.pending { background: transparent; box-shadow: inset 0 0 0 1px var(--ink-3); }

.card-stats { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- chips ---- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  font-size: 11.5px;
  white-space: nowrap;
}
.chip-i { font-size: 11px; }
.chip.ok { color: var(--good-text); border-color: color-mix(in srgb, var(--good) 40%, var(--rule)); }
.chip.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--rule)); }
.chip.unproven { color: var(--serious); border-color: color-mix(in srgb, var(--serious) 45%, var(--rule)); }
.chip.running { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, var(--rule)); }
.chip.running .chip-i { display: inline-block; animation: spin 1.4s linear infinite; }
.chip.idle { color: var(--ink-3); border-style: dashed; }

.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 2px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 11.5px;
  white-space: nowrap;
}
.stat-i { color: var(--ink-3); font-size: 10.5px; }
.stat-v { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stat.compact { border: 0; padding: 0; color: var(--ink-2); }

.tag { display: inline-flex; align-items: baseline; gap: 5px; font-family: var(--mono); font-size: 10.5px; }
.tag-k { color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.07em; }
.tag-v { color: var(--ink-2); }

/* ---- run head ---- */

.run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 20px 26px 18px; border-bottom: 1px solid var(--rule); }
.run-title { font-size: 16px; font-weight: 600; max-width: 56ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-meta { display: flex; align-items: center; gap: 12px; }
.run-meta .dim { font-family: var(--mono); font-size: 11.5px; }
.run-stats { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }

.bar { margin: 14px 26px 0; padding: 9px 13px; border-radius: 8px; font-size: 13px; }
.bar.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); }
.bar.warn { color: var(--ink-2); background: color-mix(in srgb, var(--serious) 9%, transparent); border: 1px solid color-mix(in srgb, var(--serious) 32%, transparent); }

/* ---- the waterfall ---- */

.fall { margin: 18px 26px; border: 1px solid var(--rule); border-radius: 13px; background: var(--surface); overflow: hidden; }

.fall-axis { display: flex; background: var(--surface-2); border-bottom: 1px solid var(--rule); }
.zone-head {
  flex: 0 0 auto;
  padding: 7px 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--s4);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  border-right: 1px solid var(--rule);
  /* The label sits over the request zone, whose width the lanes below match. */
  margin-left: 216px;
}
.axis-track { position: relative; flex: 1; height: 30px; }
.axis-track .tick { position: absolute; bottom: 6px; transform: translateX(-50%); font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }

.lane { display: grid; grid-template-columns: 216px 1fr; border-bottom: 1px solid var(--rule); }
.lane:last-child { border-bottom: 0; }

.lane-head { padding: 11px 14px; border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lane-name { font-weight: 700; font-size: 13.5px; color: var(--lane); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ctx { margin-top: 5px; max-width: 172px; }
.ctx-head { display: flex; justify-content: space-between; align-items: baseline; }
.ctx-k { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-3); }
.ctx-v { font-family: var(--mono); font-size: 10px; color: var(--ink-2); }
.ctx-bar { height: 4px; margin-top: 3px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--lane) 16%, var(--surface-2)); }
.ctx-fill { height: 100%; background: var(--lane); transition: width 300ms ease; }

.lane-track { position: relative; height: 92px; }
.grid { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--rule); opacity: 0.6; }
.zone-line { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--rule); }

.block {
  position: absolute;
  top: 11px;
  height: 70px;
  padding: 7px 9px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--lane) 45%, transparent);
  background: color-mix(in srgb, var(--lane) 12%, var(--surface));
  overflow: hidden;
  white-space: nowrap;
  transition: box-shadow 120ms, transform 120ms;
}
.block:hover { box-shadow: 0 0 0 1px var(--lane), 0 6px 18px color-mix(in srgb, var(--lane) 22%, transparent); }
.block.failed { border-color: color-mix(in srgb, var(--bad) 70%, transparent); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.block.running { animation: pulse 1.8s ease-in-out infinite; }
.block.selected { box-shadow: 0 0 0 2px var(--info); }

.b-top { display: flex; align-items: baseline; gap: 7px; }
.b-i { font-size: 11px; color: var(--lane); }
.block.failed .b-i { color: var(--bad); }
.block.succeeded .b-i { color: var(--good-text); }
.b-name { font-weight: 700; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.b-time { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.b-desc { margin-top: 3px; font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }

.ttick { position: absolute; bottom: 4px; width: 2px; height: 7px; border-radius: 1px; background: var(--lane); opacity: 0.55; }
.ttick.err { background: var(--bad); opacity: 1; }

/* ---- phase detail ---- */

.detail { margin: 0 26px 26px; border: 1px solid var(--rule); border-radius: 13px; background: var(--surface); overflow: hidden; }
.d-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 13px 17px; background: var(--surface-2); border-bottom: 1px solid var(--rule); }
.d-name { font-size: 15px; font-weight: 700; }
.d-tags { margin-left: auto; display: flex; gap: 14px; }
.d-close { color: var(--ink-3); font-size: 14px; padding: 0 4px; }
.d-close:hover { color: var(--ink); }

.d-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 24px; padding: 6px 17px 18px; }
@media (max-width: 1100px) { .d-grid { grid-template-columns: 1fr; } }

.sect { border-bottom: 1px solid var(--rule); }
.sect:last-child { border-bottom: 0; }
.sect > summary { cursor: pointer; padding: 10px 0; display: flex; align-items: baseline; gap: 8px; list-style: none; }
.sect > summary::-webkit-details-marker { display: none; }
.sect > summary::before { content: "▸"; color: var(--ink-3); font-size: 9px; }
.sect[open] > summary::before { content: "▾"; }
.sect-t { font-family: var(--mono); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
.sect-body { padding: 0 0 14px; }

.d-desc { margin: 0; color: var(--ink-2); }

.usage { width: 100%; max-width: 380px; border-collapse: collapse; font-size: 12.5px; }
.usage th { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 400; text-align: left; padding: 0 0 5px; }
.usage td { padding: 3px 0; }
.usage td.num { font-family: var(--mono); }
.u-total td { border-top: 1px solid var(--rule); font-weight: 700; padding-top: 6px; }
.u-note { margin: 9px 0 0; font-size: 11.5px; color: var(--ink-3); max-width: 46ch; }

/* The recorded-values table carries paths and urls, not the four short numbers
   the cost table was sized for, so it gets the width and is allowed to wrap. */
.usage.kv { max-width: none; }
.usage.kv td:first-child { color: var(--ink-3); white-space: nowrap; padding-right: 14px; vertical-align: top; }
.usage.kv td:last-child { word-break: break-all; }

/* A link that has to sit among plain metadata without turning the row into a
   navigation bar: it reads as text until you go near it. */
.tick-link { border-bottom: 1px solid var(--rule); }
.tick-link:hover { color: var(--ink); border-bottom-color: currentColor; }

/* The run id keeps its lowercase inside .card-flow, which is uppercased. An
   uppercased ADW-20260812-A869 is not the string you would paste anywhere. */
.card-flow .dim { text-transform: none; letter-spacing: 0; margin-left: 8px; }

.gate { margin-bottom: 11px; padding-left: 9px; border-left: 2px solid var(--rule); }
.gate.ok { border-left-color: var(--good); }
.gate.bad { border-left-color: var(--bad); }
.gate-head { display: flex; align-items: baseline; gap: 7px; }
.gate-i { font-size: 11px; }
.gate.ok .gate-i { color: var(--good-text); }
.gate.bad .gate-i { color: var(--bad); }
.gate-n { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.checks { list-style: none; margin: 4px 0 0; padding: 0; }
.checks li { display: flex; gap: 6px; font-family: var(--mono); font-size: 11px; color: var(--ink-2); padding: 1px 0; }
.checks li.bad { color: var(--bad); }
.check-i { color: var(--ink-3); }
.checks li.bad .check-i { color: var(--bad); }
.check-k { flex: 0 0 auto; }
.check-n { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }
.checks li.bad .check-n { color: var(--bad); }

.prompt > summary { cursor: pointer; display: flex; gap: 9px; align-items: baseline; font-family: var(--mono); font-size: 11.5px; padding: 4px 0; }
.prompt > summary .dim { margin-left: auto; }
.out { margin-bottom: 11px; }
.out-head { display: flex; align-items: baseline; gap: 10px; }
.out-t { font-family: var(--mono); font-size: 11.5px; font-weight: 700; }
.ok-t { color: var(--good-text); font-size: 11px; }
.bad-t { color: var(--bad); font-size: 11px; }

pre {
  margin: 5px 0 0;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  max-height: 40vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.d-right h3 { margin: 12px 0 8px; font-family: var(--mono); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; display: flex; gap: 7px; align-items: baseline; }

.events { max-height: 62vh; overflow-y: auto; border: 1px solid var(--rule); border-radius: 8px; }
.ev { display: flex; align-items: baseline; gap: 11px; padding: 5px 10px; font-family: var(--mono); font-size: 11px; border-bottom: 1px solid var(--rule); }
.ev:last-child { border-bottom: 0; }
.ev-t { color: var(--ink-3); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.ev-k { flex: 0 0 112px; color: var(--ink-2); }
.ev-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-x { flex: 0 0 auto; display: flex; gap: 10px; }
.ev.bad .ev-k { color: var(--bad); }
.ev.ok .ev-k { color: var(--good-text); }
.ev.tool .ev-k { color: var(--s1); }
.ev.handoff .ev-k { color: var(--s5); }
.ev.start .ev-k { color: var(--s2); }

/* --- breaks in the axis ---------------------------------------------------
 *
 * A run contains waiting: a human gate can take days, and drawn to scale that
 * leaves the actual work as a hairline at each end of an empty page. Idle
 * stretches collapse to a fixed narrow band carrying their real duration — the
 * same trick a bar chart uses rather than drawing eight blank ninths of itself.
 *
 * Hatched rather than solid so it reads as "removed", not as "something ran here".
 */
.gap-head {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px dashed var(--rule-strong);
  border-right: 1px dashed var(--rule-strong);
}

.gap-t {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  white-space: nowrap;
  /* The band is deliberately narrow, so the label is allowed out of it. */
  transform: translateY(-1px);
}

.gap-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0 3px,
    color-mix(in srgb, var(--ink) 7%, transparent) 3px 4px
  );
  border-left: 1px dashed var(--rule);
  border-right: 1px dashed var(--rule);
  pointer-events: none;
}
