:root {
  --page: #f4efeb;
  --card: #fffdfb;
  --text: #393939;
  --muted: #77716d;
  --border: #3d3d3d;
  --soft: #ddd6d0;

  --blue: #63b7ea;
  --yellow: #ffe11b;
  --green: #20a987;
  --red: #c94425;

  --shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--page);
  color: var(--text);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    Inter,
    Arial,
    sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  color: inherit;
}

button {
  cursor: pointer;
}

.page {
  width: min(calc(100% - 28px), 1180px);
  margin: 0 auto;
  padding:
    max(14px, env(safe-area-inset-top))
    0
    max(40px, env(safe-area-inset-bottom));
}

/* 顶部 */

.topbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
}

.vps-heading {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 0 16px;
  border: 2px solid var(--border);
  background: var(--blue);
  font-size: 14px;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.vps-count {
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  background: #3e4144;
  color: #fff;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.language-select,
.settings-button {
  min-height: 48px;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.language-select {
  min-width: 110px;
  padding: 0 11px;
}

.settings-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
}

.settings-button:hover {
  background: var(--yellow);
}

.settings-button svg {
  width: 17px;
  height: 17px;
}

/* 机器列表 */

.machine-grid {
  display: grid;
  grid-template-columns:
    repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  align-items: start;
  gap: 20px;
  margin-top: 22px;
}

.machine-card {
  min-width: 0;
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--card);
}

.machine-hero {
  position: relative;
  height: 155px;
  background: var(--hero, #e95420);
  border-bottom: 6px solid var(--green);
}

.provider-badge,
.status-badge {
  position: absolute;
  top: 15px;
  z-index: 2;
  min-height: 31px;
  display: flex;
  align-items: center;
  border: 2px solid var(--border);
  font-size: 12px;
  font-weight: 900;
}

.provider-badge {
  left: 15px;
  max-width: calc(100% - 125px);
  padding: 5px 10px;
  overflow: hidden;
  background: var(--yellow);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status-badge {
  right: 15px;
  gap: 7px;
  padding: 0 10px;
  background: #fff;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aaa39e;
}

.status-badge.online .status-dot {
  background: #24cfa2;
  box-shadow: 0 0 5px rgba(36, 207, 162, 0.7);
}

.os-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 82px;
  transform: translate(-50%, -42%);
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.15);
  box-shadow:
    0 8px 13px rgba(0, 0, 0, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.os-logo img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.machine-body {
  padding: 19px 22px 22px;
}

.machine-name {
  margin: 0 0 5px;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 21px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.os-name {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

/* ISP */

.network-row {
  min-height: 43px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 2px solid var(--soft);
  background: #f5f0ec;
  font-size: 11px;
}

.network-main {
  min-width: 0;
}

.network-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.network-name {
  display: block;
  min-width: 0;
  font-family: Consolas, monospace;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.network-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.network-tag {
  padding: 3px 6px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: Consolas, monospace;
  font-size: 9px;
  font-weight: 900;
}

.network-tag.idc {
  background: #ffe0d2;
}

.network-tag.isp {
  background: #dffff5;
}

.network-tag.business {
  background: #e7e5ff;
}

.network-tag.danger {
  background: #ffe4ea;
}

/* 使用率 */

.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.usage-heading {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-family: Consolas, monospace;
  font-size: 10px;
}

.usage-heading strong {
  font-size: 12px;
}

.progress {
  height: 9px;
  padding: 2px;
  border: 2px solid var(--border);
  background: #fff;
}

.progress-fill {
  display: block;
  height: 100%;
  background: var(--green);
}

.offline .progress-fill {
  background: #aaa39e;
}

/* 配置 */

.spec-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 15px;
}

.spec-item {
  min-width: 0;
  min-height: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7px;
  border: 2px solid var(--soft);
  background: #f7f2ee;
  text-align: center;
}

.spec-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 9px;
}

.spec-value {
  font-family: Consolas, monospace;
  font-size: 15px;
  font-weight: 900;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.meta-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border: 2px solid var(--soft);
  background: #fff;
  font-family: Consolas, monospace;
  font-size: 10px;
  font-weight: 900;
}

.meta-badge.bandwidth {
  border-color: var(--border);
  background: var(--blue);
}

.last-seen {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}

/* 空状态 */

.empty-state {
  grid-column: 1 / -1;
  min-height: 300px;
  display: grid;
  place-items: center;
  padding: 25px;
  border: 2px dashed #9c9590;
  background: rgba(255, 255, 255, 0.35);
  text-align: center;
}

.empty-icon {
  font-size: 42px;
}

.empty-title {
  margin: 12px 0 6px;
  font-size: 21px;
  font-weight: 900;
}

.empty-description {
  margin: 0 0 17px;
  color: var(--muted);
  font-size: 12px;
}

/* 按钮 */

.normal-button {
  min-height: 39px;
  padding: 0 13px;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.09);
}

.normal-button.primary {
  background: var(--yellow);
}

.normal-button.danger {
  color: var(--red);
}

/* 设置弹窗 */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 12px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.modal.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 23, 22, 0.7);
  backdrop-filter: blur(2px);
}

.dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  border: 2px solid var(--border);
  background: #fff;
  box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.2);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 2px solid var(--border);
  background: var(--blue);
}

.dialog-title {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
}

.dialog-description {
  margin: 4px 0 0;
  font-size: 10px;
  font-weight: 700;
}

.close-button {
  width: 35px;
  height: 35px;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 22px;
}

.settings-form {
  padding: 17px 16px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 900;
}

.field-help {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.isp-help {
  margin: 0 0 16px;
  padding: 10px;
  border-left: 5px solid var(--blue);
  background: #f7f2ee;
}

.input,
.select {
  width: 100%;
  height: 41px;
  padding: 0 10px;
  border: 2px solid var(--border);
  border-radius: 0;
  outline: none;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.input:focus,
.select:focus {
  border-color: #329bd2;
  box-shadow: 3px 3px 0 rgba(50, 155, 210, 0.2);
}

.bandwidth-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 105px;
  gap: 8px;
}

.admin-box {
  padding: 11px;
  border: 2px solid var(--soft);
  background: #f7f2ee;
}

.token-box {
  margin-bottom: 16px;
  padding: 11px;
  border: 2px solid #d4a81a;
  background: #fff9d7;
}

.token-value {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 8px;
  border: 1px solid #8e7d36;
  background: #fff;
  font-family: Consolas, monospace;
  font-size: 10px;
  overflow-wrap: anywhere;
  user-select: all;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 15px;
  border-top: 2px solid var(--soft);
}

.dialog-actions .spacer {
  flex: 1;
}

.toast {
  position: fixed;
  z-index: 1200;
  left: 50%;
  bottom: 24px;
  max-width: calc(100% - 30px);
  padding: 10px 15px;
  border: 2px solid var(--border);
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  box-shadow: var(--shadow);
  transform: translate(-50%, 20px);
  visibility: hidden;
  opacity: 0;
}

.toast.show {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 520px) {
  .page {
    width: calc(100% - 22px);
  }

  .settings-button {
    width: 48px;
    padding: 0;
  }

  .settings-button span {
    display: none;
  }

  .language-select {
    min-width: 95px;
  }

  .machine-body {
    padding: 17px;
  }

  .dialog-actions .spacer {
    display: none;
  }

  .dialog-actions button {
    flex: 1;
  }
}

@media (max-width: 340px) {
  .vps-heading {
    padding: 0 10px;
  }

  .usage-grid,
  .spec-grid {
    grid-template-columns: 1fr;
  }

  .spec-item {
    min-height: 54px;
    flex-direction: row;
    gap: 10px;
  }

  .spec-label {
    margin: 0;
  }
}