@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=JetBrains+Mono:wght@400;500;700&family=Inter:wght@400;500&display=swap");

:root {
  /* --- color tokens --- */
  --bg: #0c1415;
  --panel: #142123;
  --panel-dim: #101b1d;
  --border: #2c3e40;
  --text: #e6edf3;
  --text-dim: #8b97a6;
  --text-faint: #96a8ab;

  --tier-low: #4fd1c5;    /* cool / idle */
  --tier-mid: #f2c14e;    /* warming up */
  --tier-high: #e5533d;   /* hot / saturated */
  --accent: #70d5ac;      /* identity accent, used sparingly */
  --offline: #e5533d;

  --radius: 14px;
  --font-display: "Space Grotesk", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(108, 123, 255, 0.07), transparent),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(79, 209, 197, 0.05), transparent);
  background-attachment: fixed;
  min-height: 100vh;
}

.wrap {
  max-width: 1920px;
  margin: 0 auto;
  padding: 30px 28px 48px;
}

/* ---------- header ---------- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 6px;
}

.title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(24px, 4vw, 32px);
  margin: 0;
  letter-spacing: -0.01em;
}

.title .dim { color: var(--text-dim); font-weight: 500; }

.header-right {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tier-low);
  margin-right: 7px;
  box-shadow: 0 0 0 0 rgba(79, 209, 197, 0.6);
}

@media (prefers-reduced-motion: no-preference) {
  .live-dot.pulsing {
    animation: pulse 2s ease-out infinite;
  }
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(79, 209, 197, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(79, 209, 197, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 209, 197, 0); }
}

/* ---------- summary strip ---------- */
.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.summary-cell {
  background: var(--panel);
  padding: 20px;
}

.summary-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.summary-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 28px;
}

.summary-value .unit {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 3px;
}

/* ---------- grid of host cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr));
  gap: 12px;
}

/* fall back to wrapping on narrower screens so cards stay readable */
@media (max-width: 1500px) {
  .grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
  opacity: 0;
  transform: translateY(6px);
}

@media (prefers-reduced-motion: no-preference) {
  .card.in {
    animation: card-in 0.45s ease forwards;
  }
}
.card.in:not(.animatable) { opacity: 1; transform: none; }

@keyframes card-in {
  to { opacity: 1; transform: none; }
}

.card.offline { opacity: 0.55; }
.card.offline.in { opacity: 0.55; transform: none; }

.card-head {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.card-host {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online { background: var(--tier-low); }
.status-dot.offline { background: var(--offline); }

.card-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  text-align: right;
}

.card-error {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--tier-high);
  background: rgba(229, 83, 61, 0.08);
  border: 1px solid rgba(229, 83, 61, 0.25);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 4px;
}

/* ---------- metric rows ---------- */
.metric {
  margin-bottom: 8px;
}

.metric-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.metric-label .sub {
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0;
}

.metric-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
}

.metric-value .unit {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
}

.metric-body {
  display: grid;
  grid-template-columns: 1fr 64px;
  align-items: center;
  gap: 10px;
}

.bar-track {
  height: 5px;
  border-radius: 3px;
  background: var(--panel-dim);
  border: 1px solid var(--border);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background-color 0.5s ease;
}

canvas.spark {
  display: block;
  width: 64px;
  height: 22px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.gpu-block {
  background: var(--panel-dim);
  border: 1px solid #3d4757;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 9px;
}

.gpu-block:last-child { margin-bottom: 0; }

.gpu-name {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gpu-stats-row {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

.gpu-stats-row b { color: var(--text); font-weight: 600; }

/* ---------- per-GPU user / process panel ---------- */
.gpu-users {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.gpu-users.idle { cursor: default; color: var(--text-faint); }
.gpu-users .who { color: var(--text); font-weight: 600; }
.gpu-users.idle .who { color: var(--text-faint); font-weight: 400; }
.gpu-users .count { color: var(--text-faint); }
.gpu-users .chev { margin-left: auto; color: var(--text-faint); font-size: 9px; }

.gpu-procs {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.gpu-procs.open { display: block; }

.proc-row {
  display: grid;
  grid-template-columns: minmax(60px, auto) 1fr auto auto;
  gap: 10px;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 0;
}
.proc-row .proc-user { color: var(--text); font-weight: 600; }
.proc-row .proc-cmd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proc-row .proc-mem { color: var(--tier-mid); }
.proc-row .proc-pid { color: var(--text-faint); }

.empty-note {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  padding: 10px 0;
}

.loading {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 13px;
  padding: 40px 0;
  text-align: center;
}

@media (max-width: 560px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- server selection ---------- */
[hidden] { display: none !important; }
.server-selector {
  margin-bottom: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.selector-heading, .server-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
#selection-count { color: var(--text-dim); margin-right: auto; }
.selector-heading button {
  background: var(--panel-dim);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}
.selector-heading button:disabled { opacity: .5; cursor: default; }
.server-options { margin-top: 12px; }
.server-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  background: var(--panel-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.server-option:has(input:checked) { border-color: var(--accent); }
.server-option input { accent-color: var(--accent); }
.selector-note { color: var(--text-dim); font-size: 12px; margin: 12px 0 0; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.brand-campus { color: var(--accent); font-weight: 500; }
.subtitle { margin: 9px 0 0; color: var(--text-dim); font-size: 14px; }
.header-right { line-height: 1.8; }
.connection-status { color: var(--tier-low); font-weight: 600; margin-bottom: 4px; }
.summary { gap: 12px; background: transparent; border: 0; border-radius: 0; }
.summary-cell { border: 1px solid var(--border); border-radius: var(--radius); }
.summary-cell:first-child { border-top: 2px solid var(--accent); }
.section-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin: 26px 0 14px; }
.section-heading h2 { font-family: var(--font-display); font-size: 18px; margin: 0; }
.section-heading > span { color: var(--text-dim); font-size: 12px; }
.card-meta { text-align: left; overflow-wrap: anywhere; max-width: 100%; }
.card-error { overflow-wrap: anywhere; line-height: 1.6; }
.card.offline.in { opacity: 1; border-color: #65423c; }
.card-state { font-family: var(--font-body); font-size: 10px; font-weight: 500; padding: 3px 7px; border-radius: 20px; background: var(--panel-dim); color: var(--tier-low); white-space: nowrap; }
.offline .card-state { color: var(--tier-high); }
.gpu-name { color: var(--text-dim); font-size: 12px; }
.gpu-stats-row { flex-wrap: wrap; gap: 5px 12px; }
.server-option { transition: border-color .15s, background .15s; }
.server-option:hover, .selector-heading button:hover:not(:disabled) { border-color: var(--accent); }
.server-option:has(input:checked) { background: rgba(112, 213, 172, .09); }
.loading { grid-column: 1 / -1; border: 1px dashed var(--border); border-radius: var(--radius); padding: 42px 16px; }
@media (max-width: 560px) {
  .wrap { padding: 20px 14px 32px; }
  .title { font-size: 26px; overflow-wrap: anywhere; }
  .eyebrow { font-size: 9px; line-height: 1.6; }
  .header-right { text-align: left; }
  .summary { gap: 8px; }
  .summary-cell { padding: 14px 12px; }
  .summary-value { font-size: 24px; }
  .summary-label { font-size: 9px; }
  #selection-count { width: 100%; order: 2; }
  .server-option { flex: 1 1 auto; }
  .proc-row { grid-template-columns: minmax(45px, auto) 1fr auto; gap: 6px; }
  .proc-pid { grid-column: 2 / -1; }
}

/* Account controls and the administration workspace */
.account-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: -8px 0 24px; font-size: 12px; }
.account-bar > span { margin-right: auto; color: var(--text-dim); }
a { color: var(--accent); text-underline-offset: 3px; }
button, input { font: inherit; }
button { cursor: pointer; background: var(--panel-dim); border: 1px solid var(--border); border-radius: 7px; color: var(--text); padding: 9px 12px; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .6; cursor: default; }
.primary-button { background: var(--accent); color: #0c2420; border-color: var(--accent); font-weight: 700; padding: 13px 18px; }
.quiet-button { background: transparent; }
form label:not(.checkbox-label) { display: block; font-size: 13px; color: var(--text); margin: 16px 0; }
form input:not([type="checkbox"]) { width: 100%; min-width: 0; display: block; margin-top: 7px; padding: 12px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; }
form input[readonly] { opacity: .7; }
.form-hint { font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.checkbox-label { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; margin: 16px 0; }
input[type="checkbox"] { accent-color: var(--accent); }
.admin-panel { position: fixed; top: 0; right: 0; width: 400px; height: 100dvh; padding: 24px; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--border); box-shadow: -12px 0 48px #0005; z-index: 10; }
.admin-heading { display: flex; align-items: center; justify-content: space-between; }
.admin-heading h2 { margin: 0; font-family: var(--font-display); }
.admin-users { display: grid; gap: 8px; margin: 20px 0 12px; }
.admin-users button { display: flex; flex-direction: column; text-align: left; gap: 5px; }
.admin-users button span { color: var(--text-dim); font-size: 11px; }
.admin-panel h3 { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 24px; }
.admin-panel h4 { font-size: 13px; }
.permission-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 11px; }
.permission-row > span { overflow-wrap: anywhere; }
.permission-row label { display: inline-flex !important; gap: 3px; margin: 0 !important; font-size: 10px !important; }
.generated-password { overflow-wrap: anywhere; font: 12px var(--font-mono); color: var(--accent); padding: 12px; background: var(--bg); user-select: all; }
.danger-button { color: #ffaaa0; margin-top: 12px; }
#admin-message, #auth-message { font-size: 13px; line-height: 1.6; color: var(--tier-mid); }
.admin-open .wrap { margin-right: 400px; }
@media (max-width: 800px) { .admin-panel { width: min(100%, 400px); } .admin-open .wrap { margin-right: 0; } }
/* Login */
.login-body { display: grid; min-height: 100dvh; align-items: center; }
.login-layout { display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; gap: 80px; max-width: 1120px; width: 100%; margin: 0 auto; padding: 64px 28px; }
.login-intro h1 { font-family: var(--font-display); font-size: clamp(28px, 3.3vw, 42px); line-height: 1.2; letter-spacing: -.04em; overflow-wrap: anywhere; }
.login-lead { font-size: 24px; line-height: 1.4; margin: 28px 0 14px; }
.login-description { color: var(--text-dim); line-height: 1.8; max-width: 390px; font-size: 15px; }
.login-card { border: 1px solid var(--border); background: var(--panel); border-radius: 20px; padding: 36px; box-shadow: 0 28px 90px #0003; }
.login-card h2 { font-family: var(--font-display); margin: 12px 0; font-size: 27px; }
#form-description { color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.login-card .primary-button { width: 100%; margin-top: 10px; display: flex; justify-content: space-between; }
.login-footnote { color: var(--text-dim); font-size: 12px; }
.login-illustration { display: flex; gap: 10px; align-items: flex-end; height: 90px; margin: 36px 0 24px; }
.login-illustration span { width: 36px; height: 60%; border: 1px solid #70d5ac66; border-radius: 6px; background: linear-gradient(0deg, #70d5ac33, #70d5ac08); }
.login-illustration span:nth-child(2n) { height: 90%; }
.login-illustration span:nth-child(3n) { height: 45%; }
@media (max-width: 800px) {
  .login-layout { grid-template-columns: 1fr; max-width: 520px; gap: 28px; padding: 32px 20px; }
  .login-lead, .login-description, .login-illustration, .login-footnote { display: none; }
  .login-card { padding: 26px; }
}
