:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --ink-primary: #0b0b0b;
  --ink-secondary: #52514e;
  --ink-muted: #898781;
  --grid-line: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);

  --series-1: #2a78d6; /* GPU 0 / primary line */
  --series-2: #eb6834; /* GPU 1 */
  --series-3: #1baf7a; /* GPU 2 */

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --surface: #1a1a19;
    --page: #0d0d0d;
    --ink-primary: #ffffff;
    --ink-secondary: #c3c2b7;
    --ink-muted: #898781;
    --grid-line: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;

    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-critical: #d03b3b;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink-primary);
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
  padding: 16px;
}

a {
  color: var(--series-1);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto 20px;
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
}

.topbar .sub {
  color: var(--ink-muted);
  font-size: 13px;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-primary);
  border-radius: 6px;
  padding: 7px 12px;
}
button:hover {
  border-color: var(--series-1);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button.primary {
  background: var(--series-1);
  color: #fff;
  border-color: transparent;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

.machine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.machine-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.machine-card h2 {
  font-size: 15px;
  margin: 0 0 2px;
}
.machine-card h2 a {
  color: var(--ink-primary);
}

.machine-card .location {
  color: var(--ink-muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.machine-card .offline-banner {
  color: var(--status-critical);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-tile {
  padding: 4px 0;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-secondary);
  font-size: 12px;
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  margin-top: 2px;
}

.stat-sub {
  color: var(--ink-muted);
  font-size: 11px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-good {
  background: var(--status-good);
}
.status-warning {
  background: var(--status-warning);
}
.status-critical {
  background: var(--status-critical);
}
.status-unknown {
  background: var(--ink-muted);
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.chart-card h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink-secondary);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-header h3 {
  margin: 0;
}

button.small {
  padding: 4px 10px;
  font-size: 12px;
}

.last-check {
  color: var(--ink-muted);
  font-size: 11px;
  margin-top: 8px;
}

.progress-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--grid-line);
  overflow: hidden;
  margin: 10px 0;
}
.progress-bar-fill {
  height: 100%;
  width: 40%;
  border-radius: 2px;
  background: var(--series-1);
  animation: progress-sweep 1.1s ease-in-out infinite;
}
@keyframes progress-sweep {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

.chart-container {
  position: relative;
}

.chart-empty {
  color: var(--ink-muted);
  font-size: 13px;
  padding: 40px 0;
  text-align: center;
}

.chart-svg {
  display: block;
}

.grid-line {
  stroke: var(--grid-line);
  stroke-width: 1;
}
.baseline {
  stroke: var(--baseline);
  stroke-width: 1;
}
.axis-label {
  fill: var(--ink-muted);
  font-size: 10px;
}
.series-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.series-dot {
  stroke: var(--surface);
  stroke-width: 2;
}
.end-label {
  fill: var(--ink-primary);
  font-size: 11px;
  font-weight: 600;
}
.crosshair {
  stroke: var(--baseline);
  stroke-width: 1;
}

.chart-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  min-width: 140px;
  z-index: 10;
}
.tooltip-time {
  color: var(--ink-muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.tooltip-key {
  width: 10px;
  height: 2px;
  display: inline-block;
}
.tooltip-name {
  color: var(--ink-secondary);
  flex: 1;
}
.tooltip-value {
  color: var(--ink-primary);
}

.chart-legend {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-secondary);
}
.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--grid-line);
}
th {
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
}
th:hover,
th:focus-visible {
  color: var(--ink-primary);
}
th:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: -2px;
}
th[aria-sort="ascending"],
th[aria-sort="descending"] {
  color: var(--ink-primary);
}
.sort-arrow {
  color: var(--series-1);
}

/* Pastel staleness flags for "last login" - deliberately soft/muted, distinct
   from the vivid good/warning/critical status dots used for live metrics. */
:root {
  --pastel-orange-bg: #fde8cc;
  --pastel-orange-ink: #8a5a1f;
  --pastel-red-bg: #fbdada;
  --pastel-red-ink: #8f3a3a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --pastel-orange-bg: rgba(250, 178, 25, 0.16);
    --pastel-orange-ink: #e8b872;
    --pastel-red-bg: rgba(208, 59, 59, 0.18);
    --pastel-red-ink: #e39a9a;
  }
}
.login-stale-warning {
  background: var(--pastel-orange-bg);
  color: var(--pastel-orange-ink);
  border-radius: 4px;
}
.login-stale-critical {
  background: var(--pastel-red-bg);
  color: var(--pastel-red-ink);
  border-radius: 4px;
}
td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
th.num {
  text-align: right;
}

.install-event {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--grid-line);
  font-size: 13px;
}
.install-event:last-child {
  border-bottom: none;
}
.install-event .what {
  color: var(--ink-primary);
}
.install-event .when {
  color: var(--ink-muted);
  font-size: 12px;
  white-space: nowrap;
}
.action-installed { color: var(--status-good); }
.action-upgraded { color: var(--series-1); }
.action-removed { color: var(--status-critical); }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 100;
}
