:root {
  color-scheme: light;
  --bg: #eef3f6;
  --panel: #ffffff;
  --panel-soft: #f7fafb;
  --text: #17212b;
  --muted: #687684;
  --line: #dbe4e9;
  --teal: #0f9f9a;
  --teal-dark: #087873;
  --green: #19a35b;
  --amber: #d28411;
  --red: #d84949;
  --blue: #2c75d6;
  --shadow: 0 20px 60px rgba(30, 51, 61, 0.12);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 159, 154, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(44, 117, 214, 0.08), transparent 32%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 252px minmax(560px, 1fr) 340px;
  gap: 12px;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  padding: 12px;
}

.sidebar,
.content,
.detail {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(219, 228, 233, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  border-radius: 18px;
  padding: 16px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--text);
  color: white;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
}

h2 {
  margin-top: 4px;
  font-size: 30px;
  letter-spacing: 0;
}

.brand p,
.detail-empty p,
.empty-state p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.filters {
  display: grid;
  gap: 8px;
}

.filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.filter.active,
.filter:hover {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--text);
}

.filter strong {
  color: inherit;
}

.sidebar-actions {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.primary-action,
.ghost-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary-action {
  background: var(--teal);
  color: #fff;
}

.primary-action:hover {
  background: var(--teal-dark);
}

.ghost-action {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--text);
}

.compact {
  min-height: 38px;
}

.content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 18px;
  padding: 18px;
  overflow: hidden;
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex: 0 0 auto;
}

.eyebrow {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 100%);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0 12px;
  color: var(--muted);
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
  flex: 0 0 auto;
}

.group-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  flex: 0 0 auto;
}

.group-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.group-filter.active,
.group-filter:hover {
  border-color: rgba(15, 159, 154, 0.48);
  background: #e9f7f5;
  color: var(--teal-dark);
}

.group-filter strong {
  min-width: 18px;
  border-radius: 999px;
  background: rgba(15, 159, 154, 0.12);
  color: inherit;
  padding: 2px 6px;
  text-align: center;
  font-size: 12px;
}

.stat {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 12px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 25px;
}

.stat.good strong {
  color: var(--green);
}

.stat.warn strong {
  color: var(--amber);
}

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
  grid-auto-rows: minmax(368px, auto);
  gap: 14px;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 8px 18px 2px;
}

.server-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 368px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  transition: box-shadow 0.16s ease, border-color 0.16s ease;
}

.server-card:hover,
.server-card.selected {
  border-color: rgba(15, 159, 154, 0.45);
  box-shadow: 0 18px 40px rgba(30, 51, 61, 0.12);
}

.card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.server-name {
  font-size: 17px;
  font-weight: 800;
  word-break: break-word;
}

.server-host {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.server-model {
  margin-top: 4px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.level-free,
.status-pill.level-low,
.status-pill.level-warning,
.status-pill.level-critical {
  background: var(--level-color);
}

.status-free {
  background: var(--green);
}

.status-busy {
  background: var(--amber);
}

.status-offline {
  background: var(--red);
}

.status-pending {
  background: var(--blue);
}

.gpu-ring {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.donut {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: conic-gradient(var(--level-color, var(--green)) var(--busy, 0%), #dfe8ec 0);
}

.donut::before {
  content: "";
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
}

.donut span {
  position: relative;
  z-index: 1;
  font-weight: 900;
}

.summary strong {
  display: block;
  font-size: 19px;
  overflow-wrap: anywhere;
}

.summary span {
  color: var(--muted);
  font-size: 12px;
}

.gpu-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  flex: 0 0 auto;
}

.gpu-chip {
  display: grid;
  grid-template-rows: 14px 1fr;
  gap: 3px;
  min-height: 64px;
  border: 1px solid #cfe7dd;
  border-radius: 8px;
  padding: 3px;
  font-size: 10px;
  font-weight: 800;
  background: #e8f5ef;
  color: #0c7040;
  line-height: 1.2;
}

.gpu-chip b {
  color: currentColor;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.gpu-chip.offline,
.gpu-chip.unknown {
  background: #edf2f5;
  border-color: #d7e0e5;
  color: #687684;
}

.gpu-chip.level-free {
  background: #e8f5ef;
  border-color: #bde4cf;
  color: #0c7040;
}

.gpu-chip.level-low {
  background: #f1f7dc;
  border-color: #d8e899;
  color: #617414;
}

.gpu-chip.level-warning {
  background: #fff2da;
  border-color: #f2cf93;
  color: #9b5d08;
}

.gpu-chip.level-critical {
  background: #fde8e8;
  border-color: #f3b2b2;
  color: #9f2f2f;
}

.chip-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(24px, 1fr));
  gap: 4px;
  min-width: 0;
}

.chip-block {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  min-width: 0;
  min-height: 40px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
}

.chip-block i {
  position: absolute;
  inset: auto 0 0 0;
  width: 100%;
  height: var(--level);
  opacity: 0.86;
}

.chip-block.memory i {
  background: var(--level-color, #19a35b);
}

.chip-block.compute i {
  background: var(--level-color, #19a35b);
}

.level-free {
  --level-color: #19a35b;
}

.level-low {
  --level-color: #a9c83d;
}

.level-warning {
  --level-color: #e39a24;
}

.level-critical {
  --level-color: #d84949;
}

.chip-block em,
.chip-block strong {
  position: relative;
  z-index: 1;
  font-style: normal;
}

.chip-block em {
  font-size: 9px;
  color: rgba(23, 33, 43, 0.74);
}

.chip-block strong {
  font-size: 10px;
  color: var(--text);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  margin-top: 12px;
}

.asset-summary {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.asset-summary span {
  border-radius: 999px;
  background: #eef6f6;
  color: var(--teal-dark);
  padding: 3px 7px;
  font-weight: 800;
}

.asset-summary em {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-style: normal;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-summary.failed span {
  background: #fde8e8;
  color: #9f2f2f;
}

.tag {
  max-width: 100%;
  border-radius: 999px;
  background: #eef6f6;
  color: var(--teal-dark);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.edit-card {
  flex: 0 0 auto;
  margin-left: auto;
}

.detail {
  min-height: 0;
  border-radius: 18px;
  padding: 16px;
  overflow-y: auto;
}

.detail-empty {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: calc(100dvh - 56px);
  text-align: center;
}

.detail-pulse,
.empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  margin-bottom: 14px;
  background: #e7f6f4;
  color: var(--teal-dark);
}

.detail-pulse::before {
  content: "";
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--teal);
}

.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-head h3 {
  font-size: 22px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 20px;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.meta-box,
.gpu-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 12px;
}

.meta-box span,
.gpu-row span {
  color: var(--muted);
  font-size: 12px;
}

.meta-box strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.gpu-list {
  display: grid;
  gap: 10px;
}

.asset-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.asset-head,
.asset-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.asset-head h3 {
  margin-top: 2px;
  font-size: 18px;
}

.asset-head span,
.asset-title span,
.asset-item span,
.asset-item em,
.asset-empty,
.asset-error {
  color: var(--muted);
  font-size: 12px;
}

.asset-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.asset-column {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.asset-title {
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.asset-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.asset-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 9px;
}

.asset-item strong,
.asset-item span,
.asset-item em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-item em {
  font-style: normal;
}

.asset-empty,
.asset-error {
  border: 1px dashed var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
  padding: 10px;
}

.asset-error {
  border-color: #f3b2b2;
  background: #fde8e8;
  color: #9f2f2f;
}

.gpu-row {
  background: #fff;
}

.gpu-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.bar {
  height: 9px;
  border-radius: 999px;
  background: #e4edf1;
  overflow: hidden;
}

.bar > i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--level-color, #19a35b);
}

.bar.memory > i {
  background: var(--level-color, #19a35b);
}

.bar.compute > i {
  background: var(--level-color, #19a35b);
}

.bar-stack {
  display: grid;
  gap: 8px;
}

.metric-line {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
}

.metric-line strong {
  color: var(--text);
  font-size: 12px;
  text-align: right;
}

.gpu-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 9px;
  font-size: 12px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 1px dashed #b8c9d1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.empty-state .primary-action {
  margin-top: 14px;
}

.hidden {
  display: none !important;
}

.server-dialog {
  width: min(540px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0;
}

.server-dialog::backdrop {
  background: rgba(23, 33, 43, 0.32);
  backdrop-filter: blur(4px);
}

.server-dialog form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.dialog-head,
.dialog-actions,
.field-row {
  display: flex;
  gap: 12px;
}

.dialog-head,
.dialog-actions {
  align-items: center;
  justify-content: space-between;
}

label {
  display: grid;
  gap: 6px;
  width: 100%;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
}

input:focus,
select:focus {
  border-color: rgba(15, 159, 154, 0.72);
  box-shadow: 0 0 0 3px rgba(15, 159, 154, 0.12);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  border-radius: 12px;
  background: var(--text);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
}

@media (max-width: 1500px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 240px minmax(560px, 1fr);
    height: auto;
    min-height: 100dvh;
  }

  .content {
    min-height: calc(100dvh - 24px);
  }

  .detail {
    grid-column: 1 / -1;
    max-height: none;
  }

  .detail-empty {
    min-height: 220px;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: auto;
    padding: 10px;
  }

  .content {
    min-height: auto;
  }

  .sidebar {
    gap: 14px;
  }

  .filters,
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .server-grid {
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
  }

  .topline,
  .field-row {
    align-items: stretch;
    flex-direction: column;
  }

  h2 {
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  .gpu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .server-card {
    height: auto;
    min-height: 0;
  }
}
