/* APS dashboard — broadcast styling for a 1920x1080 wall display.
   Pure neutral ground: colour is reserved for data (model, money, power,
   temperature, rank). Fonts are self-hosted, so nothing here needs the
   internet once the page is served. Square corners throughout — the flat
   colour bars carry the structure that rounded cards used to. */
@import url("/static/fonts.css");

:root {
  /* neutrals — no hue at all */
  --bg: #000000;
  --bg-head: #070707;
  --bg-panel: #0d0d0d;
  --bg-tile: #121212;
  --bg-track: #1c1c1c;
  --line: #262626;
  --fg: #f5f5f5;
  --fg-dim: #9a9a9a;
  --fg-label: #7a7a7a;
  --fg-mute: #5c5c5c;

  /* data colours */
  --deepseek: #4da3ff;
  --qwen: #a97cff;
  --gold: #ffc95c;
  --silver: #c8c8c8;
  --bronze: #cd8a5a;
  --green: #35d6a4;
  --yellow: #ffd35c;
  --orange: #ff9f43;
  --power: #ffb347;
  --red: #ff5d5d;
  --accent: var(--deepseek);

  --sans: "IBM Plex Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: var(--sans); font-size: 18px; overflow: hidden;
}
body { display: flex; flex-direction: column; }

.num, .clock, .hvalue, .estat .v, .tile-temp, .metric b, .lb-rank, .lb-delta,
.lb-speed, .lb-value, .user-name, .user-model, .user-total, .ev .t, .hsub b {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}

/* section headings read as broadcast labels, not prose */
h2 {
  margin: 0 0 12px; font-size: 15px; font-weight: 600; letter-spacing: .2em;
  color: var(--fg-dim); display: flex; align-items: center; gap: 14px;
}
.hint { font-size: 12px; font-weight: 600; letter-spacing: .12em; color: var(--fg-mute); }
.hint.stale { color: var(--orange); }
.muted { color: var(--fg-dim); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 32px;
  height: 132px; padding: 0 40px;
  background: var(--bg-head); border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 24px; cursor: pointer; }
.logos { display: flex; align-items: center; gap: 24px; }
.logos img { display: block; width: auto; }
.logo-thunder { height: 62px; }
/* The ManyCore mark ships as black artwork; invert it for the dark canvas,
   and nudge it up — its dot sits above the cap line. */
.logo-manycore { height: 40px; filter: invert(1); opacity: .93; position: relative; top: -4px; }
.rule-v { width: 2px; height: 62px; background: var(--line); }

.brand-text { display: flex; flex-direction: column; gap: 7px; }
.title { display: flex; }
.title span { font-size: 40px; font-weight: 700; letter-spacing: -.015em; line-height: 1.05; white-space: nowrap; }
.brand .sub {
  font-size: 13px; font-weight: 600; letter-spacing: .14em; color: var(--fg-label);
}

.headline-stats { display: flex; flex: 1; justify-content: flex-end; align-items: stretch; }
/* Fixed rows: label / figure / footnote. Every block reserves all three even
   when one is empty, which is what keeps the row aligned across blocks. */
.hstat {
  display: grid; grid-template-rows: 16px 56px 20px; row-gap: 9px;
  align-content: center; justify-items: end; align-items: center;
  padding: 0 36px; border-left: 2px solid var(--line);
}
.hstat:last-child { padding-right: 0; }
.hlabel {
  font-size: 13px; font-weight: 600; letter-spacing: .2em; color: var(--fg-label);
}
.hvalue { font-size: 56px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.hvalue.bump { animation: bump .45s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.05); color: var(--deepseek); } 100% { transform: scale(1); } }
/* Cost rides under the token count: it is a footnote, not a headline. */
.hsub { display: flex; align-items: center; gap: 9px; min-height: 20px; }
.hsub span { font-size: 11px; font-weight: 600; letter-spacing: .16em; color: var(--fg-mute); }
.hsub b { font-size: 16px; font-weight: 700; color: var(--gold); }

.clock { font-weight: 600; letter-spacing: -.01em; }
.conn {
  display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px;
  background: var(--bg-panel); border: 1px solid var(--line);
  font-size: 12px; font-weight: 600; letter-spacing: .2em; color: var(--fg-mute);
}
.conn .dot { width: 8px; height: 8px; background: var(--fg-mute); display: block; }
.conn.live { border-color: #2e6b4d; color: var(--green); }
.conn.live .dot { background: var(--green); }
.conn.down { border-color: #6b2e2e; color: var(--red); }
.conn.down .dot { background: var(--red); }

.mock-badge {
  align-self: flex-start; padding: 2px 9px;
  font-size: 11px; font-weight: 700; letter-spacing: .18em;
  background: rgba(255, 179, 71, .14); color: var(--power); border: 1px solid rgba(255, 179, 71, .45);
}
.mock-badge[hidden] { display: none; }

/* ---------- layout ---------- */
.grid {
  flex: 1; display: grid; gap: 24px; padding: 24px 40px 26px; min-height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "gpu side" "users side";
}
.panel { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.gpu-panel { grid-area: gpu; flex: none; }
.side-panel { grid-area: side; }
.users-panel { grid-area: users; }
.users-panel h2, .gpu-panel h2 { flex: none; }
.placeholder { color: var(--fg-mute); font-size: 15px; padding: 8px 0; }

/* ---------- engine bands + GPU tiles ---------- */
.engine-groups { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.engine-summaries { display: flex; flex-direction: column; gap: 7px; flex: none; }
.esum {
  display: flex; align-items: center; gap: 13px; flex-wrap: wrap;
  background: var(--bg-panel); border-left: 6px solid var(--line); padding: 9px 20px;
}
.engine-name { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.engine-sub {
  font-size: 11px; font-weight: 600; letter-spacing: .16em; color: var(--fg-label);
}
.engine-stats { margin-left: auto; display: flex; gap: 26px; align-items: baseline; }
.estat { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.estat .v { font-size: 26px; font-weight: 700; line-height: 1; }
.estat .l { font-size: 10px; font-weight: 600; letter-spacing: .2em; color: var(--fg-label); }
/* Money is a footnote here as well: same figure, a quarter of the weight. */
.estat.cost { min-width: 76px; }
.estat.cost .v { font-size: 16px; color: var(--gold); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; flex: none; }
.tile {
  background: var(--bg-panel); border-top: 5px solid var(--line); padding: 11px 15px 13px;
  display: flex; flex-direction: column; gap: 4px; overflow: hidden;
}
.tile-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 3px; }
.tile-id { font-size: 14px; font-weight: 600; letter-spacing: .14em; color: var(--fg-dim); }
.tile-temp { font-size: 29px; font-weight: 700; line-height: 1; }
.temp-cool { color: var(--green); }
.temp-warm { color: var(--yellow); }
.temp-hot { color: var(--orange); }
.temp-critical { color: var(--red); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

.metric { display: grid; grid-template-columns: 40px 1fr 52px; gap: 9px; align-items: center; }
.metric .ml { font-size: 10px; font-weight: 600; letter-spacing: .16em; color: var(--fg-label); }
.metric b { font-size: 13px; font-weight: 600; text-align: right; }
.bar { height: 8px; background: var(--bg-track); overflow: hidden; }
.bar > i { display: block; height: 100%; transition: width .5s ease; }
.bar.util > i { background: var(--accent); }
.bar.vram > i { background: #6e6e6e; }
.bar.power > i { background: var(--power); }

/* ---------- leaderboards (one per class track) ---------- */
.boards { display: flex; flex-direction: column; gap: 18px; flex: 1 1 auto; min-height: 0; }
.board { display: flex; flex-direction: column; min-height: 0; flex: 1 1 0; }
.board h2 { flex: none; }
.board h2 .hint b { color: var(--fg-dim); font-weight: 600; }


.leaderboard { display: flex; flex-direction: column; gap: 5px; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.lb-row { flex: none; }
.lb-row {
  display: grid; grid-template-columns: 52px 30px 1fr auto 82px 74px;
  align-items: center; gap: 13px;
  background: var(--bg-panel); border-left: 5px solid var(--line); padding: 11px 16px 11px 13px;
}
.lb-row.top1 { background: #161616; border-left-color: var(--gold); }
.lb-row.top2 { border-left-color: var(--silver); }
.lb-row.top3 { border-left-color: var(--bronze); }
.lb-row.flash { animation: flash 2.6s ease-out; }
@keyframes flash { 0% { background: #2a2a2a; } 100% { } }
.lb-rank { font-size: 29px; font-weight: 700; line-height: 1; text-align: center; color: var(--fg-label); }
.lb-row.top1 .lb-rank { color: var(--gold); }
.lb-row.top2 .lb-rank { color: var(--silver); }
.lb-row.top3 .lb-rank { color: var(--bronze); }
.lb-delta { font-size: 14px; font-weight: 600; text-align: center; }
.lb-delta.up { color: var(--green); }
.lb-delta.down { color: var(--red); }
.lb-delta.same { color: #4a4a4a; }
.lb-name {
  font-family: var(--mono); font-size: 21px; font-weight: 600; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-name small {
  font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: .12em;
  color: var(--fg-mute); margin-left: 10px;
}
.lb-speed { font-size: 27px; font-weight: 700; color: var(--accent); text-align: right; }
.lb-row.top1 .lb-speed { color: var(--gold); }
.lb-value { font-size: 16px; color: var(--fg-dim); text-align: right; }
.lb-spark { display: flex; justify-content: flex-end; align-items: center; height: 22px; }
.spark { display: block; }
.more-line {
  font-size: 12px; font-weight: 600; letter-spacing: .12em; color: var(--fg-mute);
  padding: 5px 0 0 13px; flex: none;
}
.users .more-line { grid-column: 1 / -1; padding-left: 0; }

/* Empty slots keep the panel's shape when the room is still warming up —
   and on a leaderboard they read as places waiting to be taken. */
.lb-row.is-ph { background: #080808; border-left-color: #151515; }
.lb-row.is-ph .lb-rank,
.lb-row.is-ph .lb-name,
.lb-row.is-ph .lb-speed,
.lb-row.is-ph .lb-delta { color: #2b2b2b; }

/* ---------- events ---------- */
.events { display: flex; flex-direction: column; gap: 4px; flex: none; }
.ev { flex: none; }
.ev {
  display: flex; gap: 16px; align-items: baseline; font-size: 17px;
  padding: 9px 16px; border-left: 5px solid var(--line); color: var(--fg-dim);
}
.ev .t { font-size: 14px; color: var(--fg-mute); }
.ev.admin { color: var(--qwen); }

/* ---------- users ---------- */
/* The roster is fixed and every aps## keeps its slot, so the compact view
   trades the per-model numbers for enough columns to show everyone at once —
   the stacked bar still carries the model split, and the rotation view below
   spells the numbers out. */
.users {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px 22px; align-content: stretch; grid-auto-rows: minmax(22px, 1fr);
  flex: 1 1 auto; min-height: 0; overflow: hidden;
}
.user-row {
  display: grid; grid-template-columns: 48px 1fr 58px;
  align-items: center; gap: 8px; font-size: 13px; min-height: 22px;
}
.user-row .user-model { display: none; }
.user-name { font-size: 13px; font-weight: 600; color: #cfcfcf; }
.user-bar { height: 9px; background: var(--bg-track); display: flex; }
.user-bar > i { display: block; height: 100%; transition: width .6s ease; }
.user-model { font-size: 13px; text-align: right; }
.user-total { font-size: 13px; font-weight: 700; text-align: right; color: var(--fg); }
.legend { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-size: 12px; font-weight: 600; letter-spacing: .12em; color: var(--fg-label); }
.legend i { width: 10px; height: 10px; display: inline-block; }
.legend-count { font-size: 12px; font-weight: 600; letter-spacing: .12em; color: var(--fg-mute); }

/* ---------- banner + toast ---------- */
.banner {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  height: 62px; background: var(--gold); color: #0a0a0a;
  font-size: 23px; font-weight: 700; letter-spacing: -.01em;
}
.banner[hidden] { display: none; }
.banner.warn { background: var(--power); }
.banner.celebrate { background: var(--green); }
#toasts {
  position: fixed; top: 150px; left: 50%; transform: translateX(-50%); z-index: 50;
  display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none;
}
.toast {
  background: #111111; border: 2px solid var(--gold); color: var(--gold);
  font-size: 30px; font-weight: 700; padding: 18px 38px; text-align: center;
  animation: toast-in .35s ease-out;
}
.toast .sub {
  display: block; margin-top: 6px; font-family: var(--mono); font-size: 17px;
  font-weight: 600; color: var(--fg);
}
@keyframes toast-in { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- view modes (wall-display rotation) ---------- */
body.view-gpu .grid { grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "gpu"; }
body.view-gpu .side-panel, body.view-gpu .users-panel { display: none; }
body.view-gpu .gpu-panel { flex: 1; }
body.view-gpu .engine-groups { flex: 1; min-height: 0; }
body.view-gpu .engine-summaries { flex-direction: row; flex: none; }
body.view-gpu .esum { flex: 1; flex-direction: column; align-items: flex-start; gap: 9px; padding: 14px 20px; }
body.view-gpu .engine-stats { margin-left: 0; gap: 32px; }
body.view-gpu .estat { align-items: flex-start; }
body.view-gpu .estat .v { font-size: 33px; }
body.view-gpu .estat.cost .v { font-size: 19px; }
body.view-gpu .tiles { grid-auto-rows: 1fr; gap: 13px; flex: 1; min-height: 0; }
body.view-gpu .tile { padding: 20px 26px; gap: 12px; justify-content: center; }
body.view-gpu .tile-id { font-size: 20px; }
body.view-gpu .tile-temp { font-size: 54px; }
body.view-gpu .bar { height: 13px; }
body.view-gpu .metric { grid-template-columns: 56px 1fr 74px; gap: 14px; }
body.view-gpu .metric .ml { font-size: 13px; }
body.view-gpu .metric b { font-size: 19px; }

body.view-board .grid { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); grid-template-areas: "side"; }
body.view-board .gpu-panel, body.view-board .users-panel { display: none; }
body.view-board .boards { flex-direction: row; gap: 34px; }
body.view-board .board { flex: 1 1 0; }
body.view-board .lb-row { grid-template-columns: 62px 34px 1fr auto 104px 84px; padding: 13px 18px 13px 15px; }
body.view-board .lb-rank { font-size: 34px; }
body.view-board .lb-name { font-size: 25px; }
body.view-board .lb-speed { font-size: 31px; }
body.view-board .lb-value { font-size: 17px; }


body.view-users .grid { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); grid-template-areas: "users"; }
body.view-users .gpu-panel, body.view-users .side-panel { display: none; }
body.view-users .users { grid-template-columns: repeat(auto-fill, minmax(540px, 1fr)); gap: 8px 34px; grid-auto-rows: minmax(26px, 1fr); }
body.view-users .user-row { font-size: 19px; min-height: 26px; gap: 12px;
                            grid-template-columns: 110px 1fr 96px 96px 104px; }
body.view-users .user-row .user-model { display: block; }
body.view-users .user-name { font-size: 19px; }
body.view-users .user-model { font-size: 18px; }
body.view-users .user-total { font-size: 19px; }
body.view-users .user-bar { height: 15px; }

/* ---------- admin overlay ---------- */
#admin-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .86); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#admin-overlay[hidden] { display: none; }
.adm-card {
  background: var(--bg-panel); border: 1px solid var(--line);
  padding: 26px 28px; width: 420px;
}
.adm-card.wide { width: min(1100px, 96vw); max-height: 92vh; overflow-y: auto; }
.adm-card h3 { margin: 0 0 14px; font-size: 21px; font-weight: 700; display: flex; align-items: center; }
.adm-card h4 {
  margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .2em; color: var(--fg-label);
}
.adm-card p { margin: 0 0 14px; font-size: 14px; color: var(--fg-dim); }
.adm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 26px; }
.adm-grid .span { grid-column: 1 / -1; }
.adm-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
#admin-overlay input, #admin-overlay select, #admin-overlay textarea {
  padding: 9px 12px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); background: #000; color: var(--fg);
  outline: none; flex: 1; min-width: 90px;
}
#admin-overlay textarea { width: 100%; resize: vertical; }
#admin-overlay input:focus, #admin-overlay textarea:focus { border-color: var(--accent); }
#admin-overlay button, .btnlink {
  padding: 9px 16px; font-size: 15px; font-weight: 700; border: 0;
  background: var(--accent); color: #05070c; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-block; font-family: inherit;
}
#admin-overlay button.ghost, .btnlink {
  background: transparent; color: var(--accent); border: 1px solid var(--line);
}
#admin-overlay button.right { margin-left: auto; }
#admin-overlay button.mini { padding: 4px 10px; font-size: 13px; }
#admin-overlay button.danger { background: transparent; color: var(--red); border: 1px solid var(--line); }
.chk { display: flex; gap: 6px; align-items: center; font-size: 15px; color: var(--fg-dim); }
.chk input { flex: none; min-width: 0; }
.adm-err { margin-top: 12px; color: var(--red); font-size: 14px; min-height: 18px; }
.small { font-size: 13px; }
.adm-subs { max-height: 240px; overflow-y: auto; margin-top: 8px; }
.sub-row {
  display: grid; grid-template-columns: 70px 110px 96px 1fr 72px 60px;
  gap: 8px; align-items: center; padding: 5px 8px; font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.sub-row.invalid { opacity: .45; text-decoration: line-through; }
.sub-row .t { font-family: var(--mono); color: var(--fg-mute); }
