:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --line: #d8dee9;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --secondary: #2563eb;
  --danger: #b91c1c;
  --warning: #b45309;
  --success: #15803d;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.admin-shell {
  max-width: 1180px;
}

.hero-panel,
.panel,
.stat-tile,
.device-card,
.admin-user {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 460px);
  gap: 24px;
  align-items: end;
  padding: 28px;
}

.hero-title {
  display: grid;
  align-content: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 6px;
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: 0;
}

label {
  display: grid;
  gap: 8px;
  color: #273449;
  font-size: 14px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.phone-form,
.stack-form,
.reauth-form {
  display: grid;
  gap: 16px;
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 44px;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 700;
  white-space: nowrap;
}

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

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

.secondary-button {
  color: #fff;
  background: var(--secondary);
}

.ghost-button {
  color: var(--text);
  border: 1px solid var(--line);
  background: #fff;
}

.danger-button {
  color: #fff;
  background: var(--danger);
}

.full-button {
  width: 100%;
}

.notice {
  margin: 16px 0 0;
  border-radius: 8px;
  padding: 12px 14px;
  color: #14342f;
  border: 1px solid rgba(15, 118, 110, 0.28);
  background: #e6f5f3;
}

.notice.is-error {
  color: #5f1717;
  border-color: rgba(185, 28, 28, 0.25);
  background: #fdecec;
}

.workspace {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.section-head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.section-head.tight {
  margin-bottom: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-tile {
  padding: 16px;
}

.stat-tile span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 22px;
}

.empty-state {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.device-list,
.admin-list {
  display: grid;
  gap: 12px;
}

.device-card {
  padding: 16px;
  box-shadow: none;
}

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

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

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-item {
  min-width: 0;
  border-radius: 6px;
  padding: 10px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
}

.meta-item strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-ok {
  color: var(--success);
  background: #eaf8ef;
}

.status-soon {
  color: var(--warning);
  background: #fff4df;
}

.status-expired {
  color: var(--danger);
  background: #fdecec;
}

.status-hidden {
  color: #475569;
  background: #eef2f7;
}

.captcha-row {
  display: grid;
  grid-template-columns: 1fr 164px;
  gap: 12px;
  align-items: end;
}

.captcha-button {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.captcha-button img {
  width: 140px;
  height: 44px;
  object-fit: contain;
}

.reauth-panel {
  border-color: rgba(37, 99, 235, 0.28);
}

.login-panel {
  width: min(420px, 100%);
  margin: 18px auto 0;
}

.search-field {
  max-width: 560px;
}

.admin-user {
  overflow: hidden;
  box-shadow: none;
}

.admin-user-head {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.admin-device {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.2fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.admin-device:last-child {
  border-bottom: 0;
}

.code-text {
  overflow-wrap: anywhere;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.account-phone {
  margin: 8px 0 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.46);
}

.success-modal {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .hero-panel,
  .content-grid {
    grid-template-columns: 1fr;
  }

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

  .admin-device {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 12px;
  }

  .hero-panel,
  .panel {
    padding: 16px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 20px;
  }

  .inline-field,
  .captcha-row,
  .device-meta {
    grid-template-columns: 1fr;
  }

  .section-head,
  .device-top,
  .admin-user-head {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row {
    justify-content: stretch;
  }

  .button-row button,
  .ghost-button,
  .primary-button,
  .secondary-button,
  .danger-button {
    width: 100%;
  }

  .captcha-button img {
    width: 150px;
  }
}
