:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: rgba(255, 255, 255, 0.94);
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f1f5f9;
  --primary: #0a84ff;
  --primary-dark: #0067d6;
  --accent: #0f9f6e;
  --warn: #c77900;
  --danger: #d92d20;
  --ok: #079455;
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.08);
  --shadow-hover: 0 24px 70px rgba(17, 24, 39, 0.12);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(246, 247, 249, 0.92) 42%),
    repeating-linear-gradient(90deg, rgba(17, 24, 39, 0.025) 0, rgba(17, 24, 39, 0.025) 1px, transparent 1px, transparent 72px);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
  animation: pageIn 460ms var(--ease) both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 10px;
  z-index: 10;
  min-height: 62px;
  margin-bottom: 28px;
  padding: 10px 12px;
  border: 1px solid rgba(229, 231, 235, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 36px rgba(17, 24, 39, 0.06);
}

.brand,
.nav,
.actions,
.form-actions,
.panel-title,
.hero-row,
.detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 760;
  font-size: 18px;
  transition: transform 180ms var(--ease);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.08), 0 10px 24px rgba(10, 132, 255, 0.16);
}

.brand:hover {
  transform: translateY(-1px);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
  display: block;
}

.nav a,
.ghost {
  color: var(--muted);
  border: 0;
  background: transparent;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 160ms var(--ease), background-color 160ms var(--ease), transform 160ms var(--ease);
}

.nav a.active,
.nav a:hover,
.ghost:hover {
  color: var(--text);
  background: #fff;
  transform: translateY(-1px);
}

.hero-row,
.detail-head,
.section-head {
  justify-content: space-between;
  margin-bottom: 22px;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.06;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

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

.mono {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 13px;
}

.panel,
.stat {
  background: var(--panel);
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease), border-color 220ms var(--ease);
}

.panel {
  padding: 22px;
  margin-bottom: 18px;
  animation: liftIn 420ms var(--ease) both;
}

.panel:hover,
.stat:hover {
  border-color: rgba(10, 132, 255, 0.18);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

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

.stats-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-self: stretch;
  margin-bottom: 0;
}

.stat {
  padding: 18px;
  overflow: hidden;
  position: relative;
}

.stat::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.62;
}

.stat span,
.label,
.hint {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 7px;
  font-size: 26px;
  line-height: 1.1;
}

.stat small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.primary,
.button,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease), background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}

.primary {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(10, 132, 255, 0.25);
}

.primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(10, 132, 255, 0.3);
}

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

.button:hover {
  border-color: #c7d2fe;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.06);
}

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

.danger:hover {
  border-color: #f97066;
  transform: translateY(-1px);
}

.primary:active,
.button:active,
.danger:active,
.ghost:active {
  transform: translateY(0) scale(0.98);
}

.is-busy {
  pointer-events: none;
  opacity: 0.78;
}

.is-busy::after {
  content: "";
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  font-size: 14px;
}

tbody tr {
  transition: background-color 160ms var(--ease);
}

tbody tr:hover {
  background: rgba(10, 132, 255, 0.035);
}

.strong {
  font-weight: 720;
}

.empty {
  padding: 36px 12px;
  color: var(--muted);
  text-align: center;
}

.actions {
  flex-wrap: wrap;
}

td.actions {
  display: flex;
}

.login-panel {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 420px);
  gap: 28px;
  align-items: center;
  min-height: calc(100vh - 180px);
}

.form {
  display: grid;
  gap: 16px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  resize: vertical;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease), transform 160ms var(--ease);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.12);
  transform: translateY(-1px);
}

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

.narrow {
  max-width: 820px;
  margin: 0 auto;
}

.back {
  display: inline-flex;
  margin-bottom: 12px;
  color: var(--muted);
  transition: color 160ms var(--ease), transform 160ms var(--ease);
}

.back:hover {
  color: var(--primary);
  transform: translateX(-2px);
}

.alert {
  padding: 12px 14px;
  border: 1px solid #fedf89;
  border-radius: 8px;
  background: #fffaeb;
  color: #93370d;
}

.switch {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}

.switch input {
  width: 18px;
  height: 18px;
}

.qr-panel {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 22px;
  align-items: center;
}

.qr {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.09);
}

.link {
  display: block;
  margin: 6px 0 14px;
  color: var(--primary);
  word-break: break-all;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--ok);
  background: #ecfdf3;
  font-size: 12px;
  font-weight: 700;
}

.pill.off {
  color: var(--muted);
  background: var(--soft);
}

.danger-zone {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.public-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.public-card {
  width: min(680px, 100%);
}

.longpress-body {
  min-height: 100vh;
  background: #fff;
}

.wecom-topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: calc(64px + env(safe-area-inset-top));
  padding: calc(10px + env(safe-area-inset-top)) 56px 10px;
  border-bottom: 1px solid #eef0f3;
  background: rgba(247, 248, 250, 0.96);
  backdrop-filter: blur(16px);
  text-align: center;
}

.wecom-title {
  color: #111827;
  font-size: 20px;
  font-weight: 720;
  line-height: 1.15;
}

.wecom-subtitle {
  margin-top: 3px;
  color: #7a7f87;
  font-size: 12px;
  line-height: 1.2;
}

.wecom-guide {
  display: grid;
  min-height: calc(100vh - 76px - env(safe-area-inset-top));
  place-items: center;
  padding: 34px 18px max(34px, env(safe-area-inset-bottom));
}

.wecom-card {
  width: min(440px, 100%);
  text-align: center;
}

.wecom-info {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #66b1ff, #2388f2);
  color: #fff;
  font-family: Georgia, serif;
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 16px 38px rgba(35, 136, 242, 0.24);
}

.wecom-card h1 {
  margin: 0 0 10px;
  color: #111827;
  font-size: 24px;
  line-height: 1.25;
  word-break: break-word;
}

.wecom-text {
  margin-bottom: 22px;
  color: #111827;
  font-size: 22px;
  font-weight: 760;
  line-height: 1.35;
}

.wecom-qr-wrap {
  width: min(82vw, 292px);
  margin: 0 auto;
  padding: 14px;
  border: 1px solid #edf0f5;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 58px rgba(17, 24, 39, 0.11);
}

.public-qr {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 4px;
  -webkit-touch-callout: default;
  user-select: auto;
}

.wecom-tip {
  margin: 18px auto 0;
  color: #6b7280;
  font-size: 15px;
  line-height: 1.55;
}

.wecom-note {
  margin: 12px auto 0;
  color: #9aa0aa;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  padding: 10px 14px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.22);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

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

.is-soft-disabled {
  opacity: 0.5;
}

pre {
  margin: 0 0 16px;
  padding: 16px;
  overflow: auto;
  border-radius: 8px;
  background: var(--soft);
  white-space: pre-wrap;
  word-break: break-word;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 1200px);
    padding-top: 12px;
  }

  .topbar,
  .hero-row,
  .detail-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  .login-panel,
  .field-grid,
  .detail-grid,
  .stats-grid,
  .stats-grid.compact,
  .qr-panel {
    grid-template-columns: 1fr;
  }

  .qr {
    width: 160px;
    height: 160px;
  }

  h1 {
    font-size: 34px;
  }
}
