/* The look of every page this Worker serves. One dark instrument panel:
   a black shell, a narrow rail, and rounded panels that each hold one job.
   Lexend Exa is the wide face throughout; keys and addresses are monospace. */

@font-face {
  font-family: "Lexend Exa";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/lexend-exa-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Lexend Exa";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/lexend-exa-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --shell: #070709;
  --rail: #0c0c0f;
  --panel: #19191d;
  --raised: #25252b;
  --raised-hover: #303037;
  --well: #0f0f12;
  --line: #2b2b32;
  --ink: #f4f4f6;
  --muted: #9b9ba5;
  --yellow: #f0d84f;
  --red: #ff5a4a;
  --green: #62d48c;
  --blue: #86c8f6;
  --sans: "Lexend Exa", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 28px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--shell); }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 6.25rem minmax(0, 1fr);
  background: var(--shell);
  color: var(--ink);
  font: 400 0.8125rem/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
  accent-color: var(--yellow);
  caret-color: var(--yellow);
  scrollbar-color: var(--raised) var(--shell);
}
body.bare { display: block; }
::selection { background: var(--yellow); color: #111; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; border-radius: 6px; }
a { color: var(--ink); text-decoration-color: var(--muted); text-underline-offset: 0.22em; }
a:hover { text-decoration-color: var(--ink); }

/* ---------------------------------------------------------------- rail */

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; align-items: center; gap: 2rem;
  padding: 1.75rem 0 1.5rem;
  background: var(--rail);
}
.rail .mark { font-weight: 700; font-size: 0.8125rem; letter-spacing: 0.04em; color: var(--ink); text-decoration: none; }
.rail nav { display: flex; flex-direction: column; gap: 0.75rem; }
.rail-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  color: var(--muted); text-decoration: none;
  font-size: 0.625rem; font-weight: 500; letter-spacing: 0.02em;
}
.rail-item .glyph {
  display: grid; place-items: center; width: 2.875rem; height: 2.875rem;
  border-radius: 14px; transition: background-color 160ms ease-out, color 160ms ease-out;
}
.rail-item svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.rail-item:hover { color: var(--ink); }
.rail-item:hover .glyph { background: var(--panel); }
.rail-item[aria-current="page"] { color: var(--ink); }
.rail-item[aria-current="page"] .glyph { background: var(--raised); }
.rail .who { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 0.45rem; max-width: 100%; padding: 0 0.5rem; }
.rail .avatar {
  display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%;
  background: var(--raised); color: var(--ink); font-weight: 600; font-size: 0.875rem; text-transform: uppercase;
}
.rail .who .email { font-size: 0.5625rem; color: var(--muted); max-width: 5.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- panels */

main { padding: 1.25rem 1.25rem 3rem 0.25rem; min-width: 0; }
.board { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; max-width: 88rem; }
.panel { grid-column: span 12; background: var(--panel); border-radius: var(--radius); padding: 1.75rem 2rem 2rem; min-width: 0; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.board.single { max-width: 40rem; margin: 0 auto; }

h1 { font-size: 1.625rem; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
h2 { font-size: 1rem; line-height: 1.3; font-weight: 600; margin: 0 0 1.25rem; }
p { margin: 0 0 0.85rem; max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: 0.75rem; }

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; }
.head h1 { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.head .sub { margin: 0.5rem 0 0; color: var(--muted); }
.back { display: inline-block; margin-bottom: 1.1rem; font-size: 0.6875rem; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--ink); }

/* A small label over a strong value, as on an instrument. */
.stats { display: flex; flex-wrap: wrap; gap: 1.5rem 3rem; margin: 1.75rem 0 0; padding: 0; }
.stat { margin: 0; min-width: 0; }
.label, th {
  display: block; font-size: 0.625rem; font-weight: 500; line-height: 1.3;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted);
}
.stat .value { display: block; margin: 0.4rem 0 0; font-size: 1.0625rem; font-weight: 600; line-height: 1.25; }
.stat .value.big { font-size: 1.5rem; }
.accent { color: var(--yellow); }

.flash { display: flex; align-items: center; gap: 0.6rem; margin: 1.5rem 0 0; font-weight: 500; }
.flash::before { content: ""; flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--green); }
.flash.bad::before { background: var(--red); }

/* ---------------------------------------------------------------- tables */

.scroll { overflow-x: auto; margin: 0 -0.5rem; padding: 0 0.5rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.85rem 0.9rem 0.85rem 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { padding-top: 0; padding-bottom: 0.75rem; white-space: nowrap; display: table-cell; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
td { font-weight: 500; }
td .sub { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.6875rem; font-weight: 400; }
td.nowrap, .sub.nowrap { white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 0.4rem; }
td a.name { font-weight: 600; font-size: 0.875rem; text-decoration: none; }
td a.name:hover { text-decoration: underline; }
code, .key { font-family: var(--mono); font-size: 0.8125rem; letter-spacing: 0; }
.key { white-space: nowrap; color: var(--ink); }

.chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.7rem 0.3rem 0.6rem; border-radius: 999px;
  background: var(--well); color: var(--ink);
  font-size: 0.6875rem; font-weight: 600; line-height: 1.2; letter-spacing: 0; white-space: nowrap;
}
.chip::before { content: ""; width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: var(--muted); }
.chip.ok::before { background: var(--green); }
.chip.warn::before { background: var(--yellow); }
.chip.off::before { background: var(--red); }

/* ---------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.7rem 1.25rem; border: 0; border-radius: 999px;
  background: var(--ink); color: #0b0b0d;
  font: 600 0.75rem/1.2 var(--sans); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 160ms ease-out, color 160ms ease-out;
}
.btn:hover { background: #fff; }
.btn:active { background: #d9d9dd; }
.btn.quiet { background: var(--raised); color: var(--ink); }
.btn.quiet:hover { background: var(--raised-hover); }
.btn.danger { background: var(--red); color: #1a0502; }
.btn.danger:hover { background: #ff7566; }
.btn.mini { padding: 0.45rem 0.85rem; font-size: 0.6875rem; }
.buttons { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 1.75rem; }

form.stack { display: grid; gap: 1.35rem; }
form.stack.two { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.5rem; }
form.stack.two > .wide { grid-column: 1 / -1; }
.field label, fieldset legend { display: block; margin-bottom: 0.5rem; padding: 0; font-size: 0.625rem; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.field .hint { display: block; margin-top: 0.5rem; color: var(--muted); font-size: 0.6875rem; line-height: 1.5; max-width: 58ch; }
.field .error { display: block; margin-top: 0.5rem; color: var(--red); font-size: 0.6875rem; font-weight: 600; }
input[type="text"], input[type="email"], input[type="number"], textarea {
  width: 100%; padding: 0.75rem 0.95rem;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--well); color: var(--ink);
  font: 500 0.8125rem/1.4 var(--sans);
  transition: border-color 160ms ease-out;
}
input:hover, textarea:hover { border-color: #44444d; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--red); }
textarea { min-height: 6rem; resize: vertical; }
fieldset { border: 0; margin: 0; padding: 0; }
.choice { display: grid; grid-template-columns: auto 1fr; gap: 0 0.65rem; align-items: start; margin-top: 0.65rem; }
.choice input { margin: 0.25rem 0 0; width: 1rem; height: 1rem; }
.choice label { margin: 0; font-size: 0.8125rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink); }
.choice .hint { grid-column: 2; color: var(--muted); font-size: 0.6875rem; line-height: 1.5; }
form.inline { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
form.inline .field { flex: 0 1 19rem; }
.after-inline { margin: 0.6rem 0 0; }
.after-inline.error { color: var(--red); font-size: 0.6875rem; font-weight: 600; }

/* A key shown once: the one panel that asks to be acted on now. */
.panel.fresh { border: 1px solid var(--yellow); }
.secret {
  display: block; margin: 1rem 0; padding: 0.95rem 1.1rem;
  border-radius: 14px; background: var(--well);
  font-family: var(--mono); font-size: 0.9375rem; color: var(--yellow);
  overflow-wrap: anywhere; user-select: all;
}

/* ---------------------------------------------------------------- usage */

.meter-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.meter-row .name { font-weight: 600; font-size: 0.875rem; }
.meter-row .figure { font-weight: 700; font-size: 1.125rem; }
.gauge { display: block; width: 100%; height: 14px; margin: 0.9rem 0 0; overflow: visible; }
.gauge line { vector-effect: non-scaling-stroke; stroke-linecap: round; fill: none; }
.gauge .track { stroke: #3a3a42; stroke-width: 2; }
.gauge .fill { stroke: var(--ink); stroke-width: 2; }
.gauge .knob { stroke: var(--ink); stroke-width: 12; }
.gauge.full .fill, .gauge.full .knob { stroke: var(--red); }
td .gauge { width: 9rem; height: 10px; margin: 0.45rem 0 0; }
td .gauge .knob { stroke-width: 8; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
.pairs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 1.5rem; margin: 0; }
.chart { display: block; width: 100%; height: auto; margin: 0.9rem 0 0; }
.chart .bar { fill: var(--ink); transition: fill 120ms ease-out; }
.chart .bar:hover { fill: var(--yellow); }
.chart .base { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-foot { display: flex; justify-content: space-between; gap: 0.75rem; color: var(--muted); font-size: 0.625rem; margin-top: 0.5rem; }

.empty { margin-top: 1.75rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.empty p { color: var(--muted); }

/* ---------------------------------------------------------------- front page */

.front { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.front .panel { max-width: 36rem; padding: 2.75rem 2.75rem 3rem; }
.front .mark { display: block; margin-bottom: 2.5rem; font-weight: 700; font-size: 0.8125rem; letter-spacing: 0.04em; }
.front h1 { font-size: 2rem; }
.front p { margin-top: 1rem; color: var(--muted); font-size: 0.875rem; }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 76rem) {
  .span-8, .span-7, .span-5, .span-4 { grid-column: span 12; }
}
@media (max-width: 46rem) {
  body { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; gap: 1.25rem; padding: 0.75rem 1rem; }
  .rail nav { flex-direction: row; gap: 0.5rem; }
  .rail-item .glyph { width: 2.5rem; height: 2.5rem; }
  .rail .who { margin: 0 0 0 auto; padding: 0; }
  .rail .who .email { display: none; }
  main { padding: 0.75rem 0.75rem 2.5rem; }
  .panel { padding: 1.35rem 1.25rem 1.5rem; border-radius: 22px; }
  form.stack.two { grid-template-columns: minmax(0, 1fr); }
  td.actions { text-align: left; }
  h1 { font-size: 1.375rem; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .rail-item .glyph, input, textarea, .chart .bar { transition: none; }
}
