:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #d8e0eb;
  --line-strong: #b9c5d4;
  --primary: #155eef;
  --primary-dark: #0b4bc4;
  --primary-soft: #eaf1ff;
  --success: #067647;
  --success-soft: #ecfdf3;
  --warning: #92400e;
  --warning-soft: #fffaeb;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 20px 50px rgba(23, 32, 51, 0.08);
  --radius: 18px;
  --font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* 字号阶梯：组件只允许这 7 档，配合 --lh-* 使用，禁止写裸字号。 */
  --fs-2xs: 0.75rem;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: clamp(1.75rem, 4vw, 2.5rem);
  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-body: 1.6;
  color: var(--text);
  font-family: var(--font-family);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  background:
    radial-gradient(circle at 8% 12%, rgba(21, 94, 239, 0.08), transparent 28rem),
    linear-gradient(180deg, #f8fafc 0, var(--bg) 30rem);
  line-height: var(--lh-body);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  outline-offset: 3px;
}

:focus-visible {
  outline: 3px solid rgba(21, 94, 239, 0.38);
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.55rem 0.85rem;
  color: #fff;
  background: var(--primary-dark);
  border-radius: 0.5rem;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: none;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 0.8rem clamp(1rem, 4vw, 4rem);
  border-bottom: 1px solid rgba(216, 224, 235, 0.85);
  background: rgba(255, 255, 255, 0.9);
}

.brand {
  display: inline-flex;
  gap: 0.7rem;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, var(--primary), #6b8cff);
  box-shadow: 0 8px 22px rgba(21, 94, 239, 0.22);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.15;
}

.brand strong {
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: var(--fs-2xs);
}

.session-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.user-chip {
  max-width: 16rem;
  padding: 0.35rem 0.7rem;
  overflow: hidden;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  width: min(1180px, calc(100% - 2rem));
  min-height: calc(100vh - 218px);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 5.5rem) 0;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.78fr);
  gap: clamp(2rem, 7vw, 7rem);
  align-items: center;
}

.auth-stack {
  display: grid;
  gap: 1rem;
  align-content: center;
}

.wechat-card .section-heading {
  margin-bottom: 1rem;
}

.wechat-login-body {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
}

.wechat-qr-frame {
  display: grid;
  width: 100%;
  max-width: 210px;
  aspect-ratio: 1;
  padding: 0.65rem;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}

.wechat-qr-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wechat-login-actions {
  display: grid;
  gap: 0.75rem;
}

.wechat-login-state {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.welcome-panel {
  max-width: 620px;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin-top: 0;
  line-height: var(--lh-tight);
}

h1 {
  margin-bottom: 1rem;
  font-size: var(--fs-xl);
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0.45rem;
  font-size: var(--fs-lg);
}

.lead {
  max-width: 44rem;
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-md);
}

.feature-list {
  display: grid;
  gap: 0.85rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.feature-list span {
  display: grid;
  flex: 0 0 2.2rem;
  height: 2.2rem;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 0.7rem;
  font-size: var(--fs-2xs);
  font-weight: 800;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(216, 224, 235, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card,
.onboarding-card {
  padding: clamp(1.25rem, 4vw, 2rem);
}

.section-heading {
  margin-bottom: 1.5rem;
}

.section-heading p:last-child {
  margin: 0;
  color: var(--muted);
}

label:not(.check-row) {
  display: block;
  margin: 1rem 0 0.38rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 0.65rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input,
select {
  min-height: 46px;
  padding: 0.62rem 0.75rem;
}

textarea {
  resize: vertical;
  min-height: 7rem;
  padding: 0.7rem 0.75rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 94, 239, 0.12);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 4rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.65rem;
  transform: translateY(-50%);
}

.field-hint,
.muted {
  color: var(--muted);
}

.field-hint {
  display: block;
  margin-top: 0.32rem;
  font-size: var(--fs-xs);
}

.button,
.text-button,
.icon-button,
.tab {
  cursor: pointer;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.7rem;
  font-weight: 750;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button:disabled,
.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.primary {
  color: #fff;
  background: var(--primary);
}

.button.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.button.secondary,
.button.ghost {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.button.secondary:hover:not(:disabled),
.button.ghost:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.button.compact {
  min-height: 36px;
  padding: 0.4rem 0.7rem;
  font-size: var(--fs-sm);
}

.text-button {
  padding: 0;
  color: var(--primary);
  background: none;
  border: 0;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.22rem;
}

.text-button:hover {
  text-decoration-color: currentColor;
}

.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
}

.form-row.split {
  justify-content: space-between;
}

.form-row.end {
  justify-content: flex-end;
}

.form-message {
  min-height: 1.55rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.form-message.error {
  color: var(--danger);
}

.form-message.success {
  color: var(--success);
}

.notice {
  margin: 1rem 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid;
  border-radius: 0.75rem;
  font-size: var(--fs-sm);
}

.notice.info {
  color: #1849a9;
  background: #eff4ff;
  border-color: #c7d7fe;
}

.notice.warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: #fedf89;
}

.onboarding {
  width: min(820px, 100%);
  margin: 0 auto;
}

.steps li.complete span {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.consent-group {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.consent-item {
  padding: 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
}

.consent-item.emphasized {
  background: #f7f9ff;
  border-color: #b2c5ff;
}

.consent-item p {
  margin: 0.35rem 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.version-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.4rem;
  color: var(--muted);
  background: #eef2f7;
  border-radius: 0.35rem;
  font-size: var(--fs-2xs);
  vertical-align: 0.08rem;
}

.check-row {
  display: flex;
  gap: 0.62rem;
  align-items: flex-start;
  margin-top: 0.75rem;
  cursor: pointer;
}

.check-row input {
  width: 1.1rem;
  min-height: 1.1rem;
  margin: 0.22rem 0 0;
  accent-color: var(--primary);
}

.tab {
  min-width: 8rem;
  padding: 0.55rem 0.9rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 0.6rem;
  font-weight: 750;
}

.tab[aria-selected="true"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 2px 9px rgba(23, 32, 51, 0.08);
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

@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;
  }
}

.site-footer {
  padding: 1.6rem 1rem 2.2rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: var(--fs-xs);
}

.site-footer p {
  margin: 0.25rem 0;
}

dialog {
  width: min(760px, calc(100% - 2rem));
  max-height: min(82vh, 780px);
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 26px 90px rgba(23, 32, 51, 0.25);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.58);
}

.dialog-header,
.dialog-footer {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.25rem;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-header h2,
.dialog-header p {
  margin-bottom: 0;
}

.dialog-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: var(--fs-lg);
}

.legal-content {
  max-height: 56vh;
  padding: 1.5rem;
  overflow-y: auto;
  white-space: pre-wrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .auth-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .welcome-panel {
    max-width: none;
  }
}

@media (max-width: 620px) {
  .site-header {
    align-items: flex-start;
  }

  .wechat-login-body {
    grid-template-columns: 1fr;
  }

  .wechat-qr-frame {
    justify-self: center;
  }

  .session-actions {
    align-items: flex-end;
    flex-direction: column;
  }

  .user-chip {
    max-width: 10rem;
  }

  main {
    width: min(100% - 1.25rem, 1180px);
    padding: 2rem 0;
  }

  .feature-list,
  .welcome-panel .lead {
    display: none;
  }

  .form-row.split {
    align-items: stretch;
    flex-direction: column;
  }

  .form-row.split .button,
  .form-row.end .button {
    width: 100%;
  }

  .tabs .tab {
    min-width: 0;
    flex: 1;
  }
}
.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.workspace-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.workspace-heading {
  max-width: 48rem;
}

.workspace-heading p:last-child {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.workspace-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.55rem;
  align-items: center;
}

.connection-label {
  padding: 0.35rem 0.65rem;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.8fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel {
  padding: clamp(1.1rem, 3vw, 1.65rem);
}

.device-panel,
.quota-panel {
  min-width: 0;
}

.panel-heading {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.panel-heading .eyebrow {
  margin-bottom: 0.25rem;
}

.panel-note {
  color: var(--muted);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.device-state-row {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  color: var(--text);
  font-size: var(--fs-sm);
}

.device-status-dot {
  display: inline-block;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: var(--line-strong);
}

.device-status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 0.24rem rgba(6, 118, 71, 0.12);
}

.device-status-dot.offline {
  background: var(--warning);
  box-shadow: 0 0 0 0.24rem rgba(146, 64, 14, 0.12);
}

.device-meta {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

.device-meta div {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: baseline;
}

.device-meta dt {
  color: var(--muted);
  font-size: var(--fs-xs);
}

.device-meta dd {
  min-width: 0;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}

.quota-value {
  margin: 0.2rem 0 0.65rem;
  color: var(--primary);
  font-size: var(--fs-lg);
  font-weight: 800;
}

.firmware-panel,
.task-panel {
  margin-top: 1rem;
}

.file-input {
  padding: 0.48rem;
  cursor: pointer;
}

.upload-summary {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.task-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.task-card {
  padding: 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
}

.task-card-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
}

.task-title-wrap {
  display: grid;
  gap: 0.2rem;
}

.task-title {
  font-size: var(--fs-base);
}

.task-id {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--fs-2xs);
}

.task-chip {
  flex: 0 0 auto;
  padding: 0.2rem 0.5rem;
  color: var(--muted);
  background: #eef2f7;
  border-radius: 999px;
  font-size: var(--fs-2xs);
  font-weight: 750;
}

.task-chip.status-completed,
.task-chip.status-success {
  color: var(--success);
  background: var(--success-soft);
}

.task-chip.status-failed,
.task-chip.status-canceled {
  color: var(--danger);
  background: var(--danger-soft);
}

.task-chip.status-leased {
  color: #1849a9;
  background: #eff4ff;
}

.task-progress {
  display: block;
  width: 100%;
  height: 0.55rem;
  margin-top: 0.85rem;
  overflow: hidden;
  accent-color: var(--primary);
  border: 0;
  border-radius: 999px;
}

.task-progress-text,
.task-result {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.task-result {
  color: var(--success);
  font-weight: 650;
}

.task-details {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.3rem 0.65rem;
  margin: 0.85rem 0 0;
  font-size: var(--fs-xs);
}

.task-details dt {
  color: var(--muted);
}

.task-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.empty-state {
  display: grid;
  gap: 0.25rem;
  margin-top: 1rem;
  padding: 1rem;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px dashed var(--line-strong);
  border-radius: 0.85rem;
}

.empty-state strong {
  color: var(--text);
}

.empty-state span {
  font-size: var(--fs-xs);
}

@media (max-width: 860px) {
