:root {
  --bg: #eef2f9;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #e5e9f2;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eef4ff;
  --success: #15803d;
  --warn-bg: #fff8e8;
  --warn-border: #f0c36d;
  --warn-text: #7a4b00;
  --error-bg: #fef3f2;
  --error-border: #f2b8b5;
  --error-text: #912018;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 5vw, 40px);
  background:
    radial-gradient(1100px 520px at 12% -8%, #dfe9ff 0%, rgba(223, 233, 255, 0) 62%),
    radial-gradient(900px 480px at 108% 8%, #ece5ff 0%, rgba(236, 229, 255, 0) 58%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.5;
}

.card {
  width: 100%;
  max-width: 520px;
  padding: clamp(22px, 6vw, 36px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 24px;
  background: var(--card);
  box-shadow:
    0 24px 60px rgba(23, 32, 51, 0.12),
    0 2px 8px rgba(23, 32, 51, 0.05);
}

.card-header {
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(20px, 5.4vw, 24px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.notice {
  margin: 18px 0 0;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.notice-warning {
  border-color: var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-text);
}

.notice-error {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
  font-weight: 600;
}

.panel {
  min-height: 292px;
  display: flex;
  align-items: center;
  margin-top: 26px;
}

.view {
  width: 100%;
  text-align: center;
}

.view-loading {
  display: flex;
  min-height: 260px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 28px;
  height: 28px;
  margin-bottom: 18px;
  border: 3px solid #dbe4f7;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.state-title {
  margin: 0;
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.state-note {
  max-width: 340px;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.view-empty .state-title::before {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #b9c6e3;
  box-shadow: 0 0 0 8px #eef2f9;
}

.state-title-expired {
  color: #9a5b00;
}

.service-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.service-label {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.75;
}

.service-name {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.code-label {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.12em;
}

.code {
  margin: 6px 0 0;
  padding-left: 0.1em;
  color: #0b1220;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: clamp(38px, 13.5vw, 64px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 280px);
  min-height: 48px;
  margin-top: 22px;
  padding: 0 24px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 0.15s ease,
    transform 0.1s ease;
}

.copy-button:hover {
  background: var(--accent-strong);
}

.copy-button:active {
  transform: scale(0.985);
}

.copy-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 3px;
}

.copy-button.is-success {
  background: var(--success);
}

.copy-button.is-error {
  background: #b42318;
}

.meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 26px 0 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
}

.meta-item {
  min-width: 0;
}

.meta-item dt {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
}

.meta-item dd {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.remaining {
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 19px;
  letter-spacing: 0.02em;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.logout-link {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dashed #b9c2d6;
}

.logout-link:hover {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
}

.footer-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
}

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

.footer-link {
  color: var(--accent-strong);
  text-decoration: none;
  border-bottom: 1px dashed #9db6ee;
}

.footer-link:hover {
  border-bottom-color: var(--accent);
}

.login-card {
  max-width: 420px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 26px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.login-input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  letter-spacing: 0.08em;
}

.login-input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 1px;
}

.login-input-username {
  font-size: 16px;
  letter-spacing: normal;
}

.login-button {
  width: 100%;
  margin-top: 8px;
}

.notice-success {
  border-color: #b7e4c7;
  background: #eefaf2;
  color: var(--success);
  font-weight: 600;
}

.clipboard-helper {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  font-size: 16px;
}

@media (max-width: 430px) {
  .meta {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .meta-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  .meta-item dt {
    margin: 0;
  }

  .meta-item dd {
    text-align: right;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }

  .copy-button {
    transition: none;
  }
}

/* ---------- 管理后台 ---------- */

.admin-page {
  align-items: flex-start;
}

.admin-card {
  max-width: 1200px;
  min-width: 0;
}

.admin-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.admin-topbar h1 {
  text-align: left;
}

.admin-topbar .subtitle {
  text-align: left;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 13px;
}

.admin-current {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.admin-current strong {
  color: var(--text);
}

.admin-link {
  padding: 6px 11px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.admin-link:hover {
  background: #dfe9ff;
}

.flash-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.flash-list .notice {
  margin: 0;
}

.admin-section {
  margin-top: 30px;
}

.admin-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
  letter-spacing: 0.01em;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  margin-bottom: 8px;
}

.section-head h2 {
  margin: 0;
}

.section-note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.section-head .section-note {
  margin: 0;
}

.admin-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8faff;
}

.field {
  display: flex;
  flex: 1 1 190px;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 280px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.field input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 1px;
}

.field-action {
  flex: 0 0 auto;
  max-width: none;
  justify-content: flex-end;
}

.form-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #eef2f9;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.button:hover {
  background: #e1e8f4;
}

.button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

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

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

.button-secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--accent-strong);
}

.button-secondary:hover {
  background: var(--accent-soft);
}

.button-danger {
  border-color: var(--error-border);
  background: #ffffff;
  color: var(--error-text);
}

.button-danger:hover {
  background: var(--error-bg);
}

.button-small {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
}

.table-scroll {
  margin-top: 12px;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  -webkit-overflow-scrolling: touch;
}

.admin-form + .table-scroll {
  margin-top: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: #f5f8ff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.users-table {
  min-width: 780px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.page-link,
.page-current {
  min-width: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

.page-link:hover {
  border-color: var(--accent);
}

.page-current {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.logs-table {
  min-width: 900px;
}

.cell-user {
  font-weight: 600;
  white-space: nowrap;
}

.cell-time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cell-ip span[title] {
  cursor: help;
  border-bottom: 1px dotted #b9c2d6;
}

.cell-ua {
  max-width: 320px;
}

.ua-text {
  display: inline-block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.actions form {
  margin: 0;
}

.reset-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.reset-input {
  width: 180px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.reset-input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 1px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  background: #e8f7ee;
  color: var(--success);
}

.badge-muted {
  background: #eef2f9;
  color: var(--muted);
}

.badge-danger {
  background: var(--error-bg);
  color: var(--error-text);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.muted {
  color: var(--muted);
  font-size: 12.5px;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .admin-card {
    padding: 18px;
    border-radius: 18px;
  }

  .admin-topbar {
    flex-direction: column;
  }

  .admin-nav {
    width: 100%;
  }

  .admin-form {
    padding: 12px;
  }

  .field {
    flex: 1 1 100%;
    max-width: none;
  }

  .field-action {
    flex: 1 1 100%;
  }

  .field-action .button {
    width: 100%;
  }

  .reset-input {
    width: 100%;
  }
}

