/* apogy remote compute: the apogy.de palette (violet-tinted dark neutrals, one accent), Plex type. */
@font-face { font-family: "Plex Sans"; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: oklch(0.155 0.018 280);
  --surface: oklch(0.195 0.02 280);
  --surface-2: oklch(0.235 0.022 280);
  --surface-3: oklch(0.28 0.024 280);
  --line: oklch(1 0 0 / 0.09);
  --line-strong: oklch(1 0 0 / 0.16);
  --text: oklch(0.93 0.012 280);
  --text-muted: oklch(0.72 0.02 280);
  --text-faint: oklch(0.60 0.02 280);
  --accent: oklch(0.70 0.17 292);
  --accent-text: oklch(0.80 0.12 292);
  --accent-tint: oklch(0.70 0.17 292 / 0.16);
  --on-accent: oklch(0.16 0.02 280);
  --good: oklch(0.78 0.13 160);
  --bad: oklch(0.72 0.15 25);
  --warn: oklch(0.84 0.13 85);
  --good-tint: oklch(0.78 0.13 160 / 0.14);
  --bad-tint: oklch(0.72 0.15 25 / 0.14);
  --warn-tint: oklch(0.84 0.13 85 / 0.14);
  --sans: "Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "Plex Mono", ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --radius: 8px;
  --radius-sm: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 16px / 1.5 var(--sans); -webkit-font-smoothing: antialiased;
}
button, select, input, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent-text); text-underline-offset: 3px; }

/* --- frame -------------------------------------------------------------------------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: 1120px; margin: 0 auto; padding: 20px 16px 8px;
}
/* the apogy wordmark + "gpu", like "apogy chess"; the o of apogy carries the brand gradient */
.brand { display: flex; align-items: center; gap: 12px; color: #e7e9ff; text-decoration: none; }
.brand-mark { display: block; border-radius: 7px; }
.wordmark { display: block; height: 24px; width: auto; margin-top: 7px; /* x-height on the mark's centre */ }
.brand .sub { font: 400 15px / 1 var(--mono); white-space: nowrap; color: var(--text-muted); letter-spacing: 0.02em; margin-left: -2px; }
.tailnet { font: 400 13px var(--mono); color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
main { max-width: 1120px; margin: 0 auto; padding: 8px 16px 64px; display: grid; gap: 28px; }
.label { font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin: 0 0 10px; }
.module { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.module.flush { padding: 0; overflow: hidden; }
.hint { color: var(--text-faint); font-size: 13px; font-weight: 400; }
.empty { color: var(--text-muted); padding: 20px 16px; margin: 0; }

/* --- status dots and chips -------------------------------------------------------------- */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.dot.good { background: var(--good); box-shadow: 0 0 0 3px var(--good-tint); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-tint); }
.dot.bad { background: var(--bad); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 13px; font-weight: 500; background: var(--surface-2); color: var(--text-muted); white-space: nowrap;
}
.chip.running { background: var(--accent-tint); color: var(--accent-text); }
.chip.running::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }
.chip.succeeded, .chip.idle { background: var(--good-tint); color: var(--good); }
.chip.failed, .chip.offline { background: var(--bad-tint); color: var(--bad); }
.chip.paused, .chip.busy, .chip.yielding, .chip.held { background: var(--warn-tint); color: var(--warn); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* --- hosts ------------------------------------------------------------------------------ */
.hosts { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); }
.host { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 16px; }
.host.off { opacity: 0.7; }
.host-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.host-name { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.host-sub { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.gauges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gauges.sys { grid-template-columns: repeat(2, 1fr); margin-top: -4px; }
.gauge { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; }
.gauge .k { font-size: 12px; color: var(--text-faint); letter-spacing: 0.04em; }
.gauge .v { font: 500 22px / 1.2 var(--mono); font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; }
.gauge .v small { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.bar { height: 4px; border-radius: 2px; background: var(--surface-3); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width 400ms ease; }
.bar.hot > i { background: var(--warn); }
.host-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--text-muted); font-size: 14px; }
.host-foot a { cursor: pointer; }
@media (max-width: 560px) { .gauges { grid-template-columns: repeat(2, 1fr); } }

/* --- buttons and forms ----------------------------------------------------------------- */
button {
  border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 6px 14px; cursor: pointer; font-size: 14px; font-weight: 500;
}
button:hover { background: var(--surface-3); }
button.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button:disabled { opacity: 0.5; cursor: default; }

details > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px; }
details > summary::-webkit-details-marker { display: none; }
details > summary h2 { font-size: 16px; font-weight: 600; margin: 0; }
details > summary::before { content: "+"; font: 500 16px var(--mono); color: var(--accent-text); width: 12px; }
details[open] > summary::before { content: "–"; }
form { display: grid; gap: 14px; margin-top: 16px; }
label { display: grid; gap: 5px; font-size: 14px; color: var(--text-muted); font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; align-self: end; padding-bottom: 8px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > label { flex: 1 1 120px; }
.row > .grow { flex: 2 1 180px; }
.row > .grow-2 { flex: 4 1 260px; }
input, select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 14px; color: var(--text); font-weight: 400;
}
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
textarea { resize: vertical; line-height: 1.45; }
.actions { display: flex; align-items: center; gap: 14px; }
.msg { font-size: 14px; color: var(--text-muted); }
.msg.bad { color: var(--bad); }
.files { margin: 0; font-size: 13px; color: var(--text-muted); }

/* --- jobs table ------------------------------------------------------------------------- */
table.jobs { width: 100%; border-collapse: collapse; font-size: 14px; }
.jobs th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-faint); letter-spacing: 0.04em; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.jobs td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.jobs tbody tr { cursor: pointer; }
.jobs tbody tr:hover { background: var(--surface-2); }
.jobs tbody tr.sel { background: var(--accent-tint); }
.jobs tbody tr:last-child td { border-bottom: 0; }
.jobs .id { color: var(--text-faint); font-family: var(--mono); }
.jobs .nm { font-weight: 500; }
.jobs .img { display: block; color: var(--text-faint); font: 400 12px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.jobs-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.jobs-head .label { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: none; border: 0; padding: 5px 12px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { background: var(--surface-2); color: var(--text); }
.seg button.on { background: var(--accent-tint); color: var(--accent-text); }
.seg .n { font: 400 12px var(--mono); color: var(--text-faint); margin-left: 2px; }
.seg button.on .n { color: inherit; }
.jobs-more { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-faint); }
.jobs-more button { background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 12px; color: var(--text-muted); cursor: pointer; }
.jobs-more button:hover { background: var(--surface-2); color: var(--text); }
@media (max-width: 640px) { .hide-sm { display: none; } .jobs .img { max-width: 160px; } }

/* --- job detail ------------------------------------------------------------------------- */
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.detail-head h3 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.detail-head .btns { display: flex; gap: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 14px; margin: 14px 0; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.err { color: var(--bad); }
pre.log {
  background: oklch(0.12 0.015 280); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; margin: 0; max-height: 460px; overflow: auto; font: 400 12.5px / 1.5 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere; color: oklch(0.86 0.012 280);
}
.arts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.arts a { font: 400 13px var(--mono); background: var(--surface-2); padding: 4px 10px; border-radius: var(--radius-sm); text-decoration: none; }
.arts a:hover { background: var(--surface-3); }
.sub-h { font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin: 18px 0 8px; }

/* --- a job's live status (status.json): title, label/value grid, age -------------------------- */
.live { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; transition: opacity 400ms ease; }
.live.stale { opacity: 0.55; }
.live-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 500; }
.live-head > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.live-head .age { font: 400 12px var(--mono); color: var(--text-faint); white-space: nowrap; }
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 16px; margin-top: 8px; }
.live-grid > div { min-width: 0; }
.live-grid .k { font-size: 12px; color: var(--text-faint); letter-spacing: 0.04em; }
.live-grid .v { font: 400 13px / 1.4 var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* --- sign-in (public mode) ------------------------------------------------------------ */
.login { background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 20px; width: min(420px, calc(100vw - 32px)); }
.login::backdrop { background: oklch(0 0 0 / 0.6); }
.login h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.login input { width: 100%; box-sizing: border-box; margin-top: 12px; }
.login .msg:empty { display: none; }
.login .err { color: var(--bad); }
button.link { background: none; border: 0; padding: 0; color: var(--accent-text); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font: inherit; }
.tokens { width: min(720px, calc(100vw - 32px)); }
.tokens .row { display: flex; gap: 8px; margin: 12px 0 4px; }
.tokens .row input { flex: 1; margin: 0; }
.tokens table { width: 100%; font-size: 14px; }
.newtoken { background: var(--good-tint); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; }
.newtoken .k { font-size: 13px; color: var(--text-muted); }
.newtoken input { width: 100%; box-sizing: border-box; margin: 8px 0; }
.noaccess { max-width: 520px; margin: 15vh auto; }

/* --- all GPUs of a shared machine --------------------------------------------------------- */
table.gpus { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
table.gpus th { text-align: left; font-weight: 500; color: var(--text-faint); padding: 4px 6px; }
table.gpus td { padding: 4px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
table.gpus tr.ours td { background: var(--accent-tint); }
table.gpus .chip { font-size: 11px; padding: 0 6px; }
.mini { display: flex; align-items: center; gap: 8px; }
.mini .bar { flex: 1; min-width: 50px; }
.mini .num { white-space: nowrap; }
