:root {
  color-scheme: dark;
  --bg: #080c0f;
  --bg-soft: #0d1317;
  --panel: rgba(18, 25, 30, 0.88);
  --panel-solid: #12191e;
  --panel-hover: #172127;
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f7f5;
  --muted: #88969e;
  --muted-bright: #adbac1;
  --green: #72f2a7;
  --green-deep: #35c878;
  --cyan: #67dff2;
  --violet: #a997ff;
  --orange: #ffae66;
  --red: #ff7272;
  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 28% -10%, rgba(62, 181, 116, 0.08), transparent 31rem),
    linear-gradient(180deg, #090e11 0%, var(--bg) 62%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button[hidden] { display: none !important; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(110px);
  opacity: 0.09;
}

.ambient-one {
  top: -20rem;
  left: -10rem;
  background: var(--green);
}

.ambient-two {
  right: -20rem;
  bottom: -18rem;
  background: var(--cyan);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(8, 12, 15, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand > span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand strong {
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.12em;
}

.brand-mark {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  width: 31px;
  height: 31px;
  padding: 7px;
  border: 1px solid rgba(114, 242, 167, 0.2);
  border-radius: 9px;
  background: rgba(114, 242, 167, 0.08);
}

.brand-mark span {
  display: block;
  width: 4px;
  border-radius: 3px;
  background: var(--green);
  box-shadow: 0 0 12px rgba(114, 242, 167, 0.35);
}

.brand-mark span:nth-child(1) { height: 9px; }
.brand-mark span:nth-child(2) { height: 16px; }
.brand-mark span:nth-child(3) { height: 12px; }

.brand-mark.large {
  width: 48px;
  height: 48px;
  gap: 4px;
  padding: 10px;
  border-radius: 14px;
}

.brand-mark.large span { width: 6px; }
.brand-mark.large span:nth-child(1) { height: 14px; }
.brand-mark.large span:nth-child(2) { height: 24px; }
.brand-mark.large span:nth-child(3) { height: 18px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted-bright);
  font-size: 12px;
  font-weight: 650;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.connection[data-state="online"] .connection-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(114, 242, 167, 0.11), 0 0 12px rgba(114, 242, 167, 0.5);
}

.connection[data-state="offline"] .connection-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(255, 114, 114, 0.1);
}

.connection[data-state="loading"] .connection-dot {
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.35; transform: scale(0.8); }
}

.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.icon-button:hover,
.text-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.045);
}

.icon-button:active,
.text-button:active { transform: translateY(1px); }

.icon-button {
  width: 36px;
  padding: 0;
}

.icon-button svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button.is-spinning svg { animation: rotate 650ms linear infinite; }

@keyframes rotate { to { transform: rotate(360deg); } }

.text-button {
  padding: 0 12px;
  color: var(--muted-bright);
  font-size: 12px;
  font-weight: 650;
}

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 calc(34px + env(safe-area-inset-bottom));
}

.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
}

.page-intro h1 {
  margin: 7px 0 0;
  font-size: clamp(27px, 4vw, 42px);
  font-weight: 720;
  letter-spacing: -0.045em;
}

.gpu-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.gpu-tab {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted-bright);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.gpu-tab[aria-selected="true"] {
  border-color: rgba(114, 242, 167, 0.3);
  background: rgba(114, 242, 167, 0.1);
  color: var(--green);
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(20, 28, 33, 0.95), rgba(13, 19, 23, 0.92));
  box-shadow: var(--shadow);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(0, 1.4fr);
  gap: 14px;
}

.utilization-panel {
  display: flex;
  flex-direction: column;
  min-height: 330px;
  padding: 24px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading h2 {
  margin: 7px 0 0;
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.025em;
}

.load-badge,
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 27px;
  padding: 0 10px;
  border: 1px solid rgba(114, 242, 167, 0.2);
  border-radius: 99px;
  background: rgba(114, 242, 167, 0.08);
  color: var(--green);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.load-badge[data-level="busy"] {
  border-color: rgba(255, 174, 102, 0.25);
  background: rgba(255, 174, 102, 0.09);
  color: var(--orange);
}

.load-badge[data-level="saturated"] {
  border-color: rgba(255, 114, 114, 0.26);
  background: rgba(255, 114, 114, 0.1);
  color: var(--red);
}

.utilization-body {
  display: grid;
  grid-template-columns: minmax(160px, 0.85fr) minmax(140px, 1fr);
  align-items: center;
  gap: 20px;
  flex: 1;
  padding-top: 20px;
}

.gauge {
  position: relative;
  width: min(100%, 210px);
  aspect-ratio: 1;
  margin: 0 auto;
}

.gauge svg {
  display: block;
  width: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}

.gauge circle {
  fill: none;
  stroke-width: 8;
}

.gauge-track { stroke: rgba(255, 255, 255, 0.055); }

.gauge-value {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 301.593;
  stroke-dashoffset: 301.593;
  filter: drop-shadow(0 0 7px rgba(114, 242, 167, 0.26));
  transition: stroke-dashoffset 450ms cubic-bezier(.22, .75, .25, 1), stroke 200ms ease;
}

.gauge-value[data-level="busy"] { stroke: var(--orange); }
.gauge-value[data-level="saturated"] { stroke: var(--red); }

.gauge-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.055em;
}

.gauge-label strong {
  font-size: clamp(45px, 6vw, 67px);
  font-weight: 730;
}

.gauge-label span {
  margin: 12px 0 0 3px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 650;
}

.hero-facts {
  display: grid;
  gap: 15px;
}

.hero-facts > div {
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.hero-facts > div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.hero-facts span,
.detail-list dt {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.hero-facts strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
  font-weight: 680;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: start;
  gap: 14px;
  min-height: 158px;
  padding: 20px;
}

.metric-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
}

.metric-icon svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.metric-card[data-tone="violet"] .metric-icon { color: var(--violet); background: rgba(169, 151, 255, 0.1); }
.metric-card[data-tone="orange"] .metric-icon { color: var(--orange); background: rgba(255, 174, 102, 0.1); }
.metric-card[data-tone="cyan"] .metric-icon { color: var(--cyan); background: rgba(103, 223, 242, 0.09); }
.metric-card[data-tone="green"] .metric-icon { color: var(--green); background: rgba(114, 242, 167, 0.09); }

.metric-copy p {
  margin: 1px 0 8px;
  color: var(--muted-bright);
  font-size: 12px;
  font-weight: 650;
}

.metric-copy strong {
  display: block;
  font-size: 25px;
  font-weight: 720;
  letter-spacing: -0.04em;
}

.metric-copy span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.mini-bar {
  grid-column: 1 / -1;
  align-self: end;
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.05);
}

.mini-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
  transition: width 400ms ease;
}

.metric-card[data-tone="violet"] .mini-bar { color: var(--violet); }
.metric-card[data-tone="orange"] .mini-bar { color: var(--orange); }
.metric-card[data-tone="cyan"] .mini-bar { color: var(--cyan); }
.metric-card[data-tone="green"] .mini-bar { color: var(--green); }

.trend-panel {
  margin-top: 14px;
  padding: 24px;
}

.trend-heading { align-items: center; }

.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted-bright);
  font-size: 11px;
  font-weight: 650;
}

.legend span { display: inline-flex; align-items: center; gap: 6px; }

.legend i {
  width: 14px;
  height: 3px;
  border-radius: 9px;
}

.legend-util { background: var(--green); }
.legend-memory { background: var(--violet); }

.chart-wrap {
  position: relative;
  height: 260px;
  margin-top: 19px;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.chart-empty[hidden] { display: none; }

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(270px, 0.75fr);
  gap: 14px;
  margin-top: 14px;
}

.process-panel,
.detail-panel { padding: 24px; }

.count-badge {
  min-width: 28px;
  padding: 0 8px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-bright);
}

.process-list { margin-top: 18px; }

.process-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 20px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.process-row:first-child { border-top: 0; }

.process-name {
  min-width: 0;
}

.process-name strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-name span,
.process-memory span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.process-memory {
  min-width: 84px;
  text-align: right;
}

.process-memory strong { font-size: 13px; }

.process-pill {
  padding: 5px 8px;
  border: 1px solid rgba(114, 242, 167, 0.16);
  border-radius: 7px;
  background: rgba(114, 242, 167, 0.065);
  color: var(--green);
  font-size: 10px;
  font-weight: 750;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 114px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  font-size: 12px;
}

.detail-list {
  display: grid;
  gap: 0;
  margin: 18px 0 0;
}

.detail-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.detail-list > div:first-child { border-top: 0; }

.detail-list dd {
  margin: 0;
  color: var(--muted-bright);
  font-size: 12px;
  font-weight: 680;
  text-align: right;
}

.error-banner {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding: 14px 17px;
  border: 1px solid rgba(255, 114, 114, 0.23);
  border-radius: 13px;
  background: rgba(255, 114, 114, 0.07);
  color: #ffb1b1;
  font-size: 12px;
}

.error-banner[hidden] { display: none; }

footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 24px 0 0;
  color: #5f6b72;
  font-size: 10px;
}

/* Login */
.login-page {
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(100%, 460px);
  padding: 28px 20px;
}

.login-card {
  padding: clamp(26px, 7vw, 42px);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(15, 22, 26, 0.9);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.login-brand h1 {
  margin: 5px 0 0;
  font-size: 31px;
  letter-spacing: -0.04em;
}

.login-lead {
  margin: 28px 0 25px;
  color: var(--muted-bright);
  font-size: 14px;
  line-height: 1.65;
}

.login-card label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-bright);
  font-size: 12px;
  font-weight: 700;
}

.password-field {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.password-field:focus-within {
  border-color: rgba(114, 242, 167, 0.55);
  box-shadow: 0 0 0 3px rgba(114, 242, 167, 0.08);
}

.password-field input {
  min-width: 0;
  flex: 1;
  height: 48px;
  padding: 0 14px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.password-field button {
  width: 60px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.form-error {
  min-height: 18px;
  margin: 8px 0 4px;
  color: #ff9797;
  font-size: 11px;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: #06150c;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: filter 150ms ease, transform 150ms ease;
}

.primary-button:hover { filter: brightness(1.05); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: wait; filter: saturate(0.3); }

.primary-button svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 22px;
  color: #68767d;
  font-size: 10px;
  line-height: 1.5;
}

.privacy-note svg {
  width: 14px;
  min-width: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .utilization-panel { min-height: 310px; }
  .lower-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { min-height: 61px; padding: 0 14px; }
  .brand small { display: none; }
  .connection { padding: 0 9px; }
  .connection #connection-text { max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .text-button { width: 36px; padding: 0; font-size: 0; }
  .text-button::before { content: "退出"; font-size: 10px; }
  .shell { width: min(100% - 24px, 1180px); padding-top: 34px; }
  .page-intro { align-items: flex-start; flex-direction: column; gap: 16px; }
  .gpu-tabs { justify-content: flex-start; }
  .utilization-panel,
  .trend-panel,
  .process-panel,
  .detail-panel { padding: 18px; border-radius: 18px; }
  .utilization-body { grid-template-columns: 1fr 0.8fr; gap: 10px; }
  .gauge { width: min(100%, 174px); }
  .metric-grid { gap: 10px; }
  .metric-card { min-height: 145px; padding: 15px; gap: 11px; border-radius: 18px; }
  .metric-icon { width: 33px; height: 33px; }
  .metric-copy strong { font-size: 21px; }
  .chart-wrap { height: 215px; }
  .process-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .process-pill { display: none; }
}

@media (max-width: 410px) {
  .utilization-body { grid-template-columns: 1fr; }
  .gauge { width: 158px; }
  .hero-facts { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .hero-facts > div { min-width: 0; padding: 9px 0 0; border-top: 1px solid var(--line); border-bottom: 0; }
  .hero-facts strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { grid-template-columns: auto 1fr; min-height: 128px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
