:root {
  --bg: #f8f1e4;
  --panel: #fffaf0;
  --panel-strong: #fffdf7;
  --ink: #233427;
  --muted: #746d5b;
  --green: #52734f;
  --green-dark: #345339;
  --orange: #c77a45;
  --line: rgba(88, 78, 49, 0.14);
  --shadow: 0 18px 44px rgba(66, 54, 29, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(246, 221, 172, 0.34), transparent 34%),
    linear-gradient(180deg, #fbf6eb 0%, #f4ead9 50%, var(--bg) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: var(--green-dark);
  font-weight: 700;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.92);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--ink);
  font-size: 20px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topnav form {
  margin: 0;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

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

.login-card {
  width: min(460px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: var(--shadow);
}

.login-card h1,
.panel h1,
.panel h2 {
  margin: 8px 0 8px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.muted,
.panel-head p {
  color: var(--muted);
}

.flash {
  margin-bottom: 18px;
  padding: 14px 18px;
  border-radius: 12px;
  font-weight: 800;
}

.flash--success {
  background: rgba(82, 115, 79, 0.12);
  color: var(--green-dark);
}

.flash--error {
  background: rgba(199, 91, 69, 0.12);
  color: #9a3c2d;
}

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

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 247, 0.9);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 22px;
}

.stat-card span {
  display: block;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 40px;
}

.action-grid,
.two-column,
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 24px;
}

.panel--highlight {
  background:
    linear-gradient(135deg, rgba(255, 253, 247, 0.96), rgba(238, 228, 208, 0.72)),
    var(--panel);
}

.admin-quick-actions {
  margin-bottom: 18px;
}

.collapse-stack {
  display: grid;
  gap: 10px;
}

.collapse-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.76);
  box-shadow: 0 10px 24px rgba(66, 54, 29, 0.06);
}

.collapse-panel[open] {
  padding-bottom: 18px;
  background: rgba(255, 253, 247, 0.92);
}

.collapse-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

.collapse-summary::-webkit-details-marker {
  display: none;
}

.collapse-summary::after {
  content: "展开";
  min-width: 54px;
  padding: 7px 12px;
  border: 1px solid rgba(82, 115, 79, 0.25);
  border-radius: 999px;
  color: var(--green-dark);
  background: rgba(82, 115, 79, 0.08);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.collapse-panel[open] .collapse-summary::after {
  content: "收起";
}

.collapse-summary > span:first-child {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.collapse-summary strong {
  font-size: 20px;
  line-height: 1.2;
}

.summary-note {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}

.collapse-panel > .stack-form,
.collapse-panel > .config-grid,
.collapse-panel > p {
  margin: 0 18px;
}

.list-panel {
  background: rgba(255, 253, 247, 0.96);
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label,
.inline-fields label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
  color: var(--ink);
  font: inherit;
}

input,
select {
  min-height: 52px;
  padding: 0 14px;
}

textarea {
  min-height: 180px;
  padding: 14px;
  line-height: 1.6;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(82, 115, 79, 0.18);
  border-color: rgba(82, 115, 79, 0.55);
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.config-group {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.62);
}

.config-group legend {
  padding: 0 8px;
  color: var(--green-dark);
  font-weight: 900;
}

.check-label {
  align-content: start;
}

.check-label input {
  width: 24px;
  min-height: 24px;
}

.check-label em {
  color: var(--muted);
  font-style: normal;
  font-weight: 500;
}

.upload-control {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: -6px;
}

.upload-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(82, 115, 79, 0.3);
  border-radius: 999px;
  background: rgba(82, 115, 79, 0.1);
  color: var(--green-dark);
  cursor: pointer;
  font-weight: 900;
  overflow: hidden;
}

.upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-preview {
  width: 120px;
  height: 76px;
  display: block;
  border-radius: 12px;
  object-fit: cover;
  background: #eadfc9;
}

.upload-preview--qr {
  width: 88px;
  height: 88px;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.image-preview-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  border-radius: 12px;
  object-fit: cover;
  background: #eadfc9;
}

.rich-editor {
  min-height: 260px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
  line-height: 1.72;
  font-weight: 500;
  overflow-x: hidden;
  overflow-wrap: anywhere;
}

.rich-editor:focus {
  outline: 3px solid rgba(82, 115, 79, 0.18);
  border-color: rgba(82, 115, 79, 0.55);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.rich-editor img {
  max-width: 100%;
  width: 100%;
  height: auto;
  display: block;
  margin: 12px 0;
  border-radius: 12px;
  object-fit: contain;
  box-sizing: border-box;
}

.button-row,
.search-form,
.list-filter {
  display: flex;
  align-items: end;
  gap: 12px;
}

.list-filter {
  flex-wrap: wrap;
  margin: -4px 0 18px;
}

.list-filter label {
  display: grid;
  gap: 7px;
  width: min(320px, 100%);
  color: var(--ink);
  font-weight: 800;
}

.list-filter .secondary-button {
  min-height: 52px;
}

.list-filter .helper-link {
  align-self: center;
  margin-top: 22px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.primary-button {
  background: var(--green);
  color: #fffaf0;
  box-shadow: 0 12px 26px rgba(82, 115, 79, 0.22);
}

.secondary-button {
  border: 1px solid rgba(82, 115, 79, 0.3);
  background: rgba(82, 115, 79, 0.1);
  color: var(--green-dark);
}

.secondary-button--link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.danger-button {
  border-color: rgba(154, 60, 45, 0.28);
  background: rgba(199, 91, 69, 0.12);
  color: #9a3c2d;
}

.danger-link {
  color: #9a3c2d;
}

.helper-link {
  display: inline-block;
  margin-top: 14px;
}

.scanner {
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(35, 52, 39, 0.08);
}

.scanner video {
  width: 100%;
  max-height: 280px;
  border-radius: 12px;
  background: #111;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(35, 52, 39, 0.38);
  backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none;
}

.choice-dialog {
  width: min(620px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal-close-button {
  color: var(--green-dark);
  font-weight: 900;
}

.users-list-panel {
  background: rgba(255, 253, 247, 0.96);
}

.users-page-head {
  margin-bottom: 16px;
}

.users-search-form {
  margin-bottom: 18px;
}

.user-create-dialog .button-row {
  justify-content: flex-end;
}

.user-choice-list {
  display: grid;
  gap: 10px;
}

.user-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(82, 115, 79, 0.22);
  border-radius: 14px;
  background: rgba(82, 115, 79, 0.07);
  cursor: pointer;
}

.user-choice input {
  width: 22px;
  min-height: 22px;
}

.user-choice span,
.user-choice strong,
.user-choice em {
  display: block;
  min-width: 0;
}

.user-choice strong {
  overflow-wrap: anywhere;
}

.user-choice em {
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
  font-weight: 700;
}

.user-choice b {
  color: var(--green-dark);
  white-space: nowrap;
}

.user-choice--disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

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

th {
  color: var(--muted);
  font-size: 14px;
}

.article-thumb {
  width: 84px;
  height: 54px;
  display: block;
  border-radius: 10px;
  object-fit: cover;
  background: #eadfc9;
}

.table-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(116, 109, 91, 0.12);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill--success {
  background: rgba(82, 115, 79, 0.13);
  color: var(--green-dark);
}

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

.table-actions form {
  margin: 0;
}

.card-row--void {
  opacity: 0.7;
}

.card-action-stack {
  display: grid;
  gap: 8px;
  min-width: 180px;
}

.card-action-stack form {
  margin: 0;
}

.inline-redeem {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-redeem input {
  max-width: 112px;
  min-height: 42px;
}

.card-action-stack .secondary-button,
.inline-redeem .secondary-button {
  min-height: 42px;
  padding: 0 14px;
}

.card-edit-row td {
  padding-top: 0;
  background: rgba(82, 115, 79, 0.045);
}

.card-edit-panel {
  border: 1px solid rgba(82, 115, 79, 0.18);
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.72);
}

.card-edit-panel summary {
  padding: 12px 14px;
  color: var(--green-dark);
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}

.card-edit-panel summary::-webkit-details-marker {
  display: none;
}

.card-edit-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 0 14px 14px;
}

.card-edit-form label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.card-edit-form input,
.card-edit-form select {
  min-height: 44px;
}

.card-edit-upload {
  display: flex;
  align-items: end;
  min-height: 74px;
}

.card-edit-upload .upload-control {
  margin-top: 0;
}

.form-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.pagination a,
.pagination-current,
.pagination-disabled {
  min-width: 42px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 900;
}

.pagination a {
  border: 1px solid rgba(82, 115, 79, 0.25);
  background: rgba(82, 115, 79, 0.08);
}

.pagination-current {
  background: var(--green);
  color: #fffaf0;
}

.pagination-disabled {
  color: rgba(116, 109, 91, 0.62);
  background: rgba(116, 109, 91, 0.08);
}

.empty {
  color: var(--muted);
  text-align: center;
}

.profile-panel {
  background:
    linear-gradient(135deg, rgba(255, 253, 247, 0.98), rgba(238, 228, 208, 0.6)),
    var(--panel);
}

.large-phone {
  margin: 8px 0;
  color: var(--green-dark);
  font-size: 24px;
  font-weight: 900;
}

.meta-line {
  display: flex;
  gap: 14px;
  color: var(--muted);
}

.remaining-box {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 20px;
  padding: 18px;
  border-radius: 16px;
  background: rgba(82, 115, 79, 0.12);
}

.remaining-box strong {
  color: var(--green-dark);
  font-size: 44px;
}

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

.remaining-pill {
  padding: 14px;
  border-radius: 14px;
  background: rgba(199, 122, 69, 0.11);
  text-align: center;
}

.remaining-pill span,
.remaining-pill strong {
  display: block;
}

.remaining-pill span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.remaining-pill strong {
  margin-top: 4px;
  color: var(--orange);
  font-size: 28px;
}

.inline-redeem {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.inline-redeem input {
  width: 92px;
  min-height: 40px;
}

.inline-redeem .secondary-button {
  min-height: 40px;
  padding: 0 14px;
  white-space: nowrap;
}

.plan-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.plan-summary > div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(82, 115, 79, 0.08);
}

.plan-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.plan-summary strong {
  color: var(--green-dark);
  font-size: 20px;
}

.field-list {
  display: grid;
  gap: 12px;
}

.field-row {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.62);
}

.field-row-form {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(150px, 0.8fr) minmax(90px, 0.5fr) minmax(88px, 0.4fr) auto;
  gap: 10px;
  align-items: end;
}

.field-row-form label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

.field-row-form .check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
}

.field-row > .inline-redeem {
  justify-content: flex-end;
}

.upload-control--stacked {
  margin: 28px 0 12px;
}

.image-link {
  display: inline-flex;
  margin: 0 6px 6px 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(82, 115, 79, 0.08);
  font-size: 13px;
}

.history-note {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(116, 109, 91, 0.1);
  color: var(--muted);
}

.qr-box {
  margin-top: 20px;
  text-align: center;
}

.qr-box img {
  width: 190px;
  height: 190px;
  border-radius: 12px;
  background: #fff;
}

.qr-box p {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}

.wechat-info-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 14px;
}

.wechat-info-grid > div {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  border-radius: 14px;
  background: rgba(82, 115, 79, 0.08);
}

.wechat-info-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.wechat-info-grid code,
.wechat-info-grid strong,
.wechat-info-grid a {
  overflow-wrap: anywhere;
}

.unbind-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 0;
}

@media (max-width: 820px) {
  .topbar,
  .topnav,
  .unbind-form,
  .button-row,
  .search-form {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid,
  .action-grid,
  .two-column,
    .detail-layout,
    .config-grid,
    .wechat-info-grid,
    .card-edit-form,
    .field-row-form,
    .inline-fields,
    .plan-summary,
    .remaining-grid {
    grid-template-columns: 1fr;
  }

  .collapse-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .collapse-summary::after {
    justify-self: start;
  }

  .collapse-summary > span:first-child {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .summary-note {
    text-align: left;
  }

  .user-choice {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .user-choice b {
    grid-column: 2;
    white-space: normal;
  }
}
