:root {
  --ink: #18211d;
  --muted: #66736c;
  --faint: #89958d;
  --line: #d9dfd8;
  --paper: #fffdf8;
  --surface: #f4f6f2;
  --panel: #ffffff;
  --nav: #111b17;
  --nav-2: #17241f;
  --green: #13804f;
  --green-dark: #0d5f3a;
  --mint: #e7f5ec;
  --gold: #b4832d;
  --red: #b9413d;
  --shadow: 0 16px 36px rgba(25, 34, 29, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
  letter-spacing: 0;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

button:active,
a:active {
  transform: translateY(1px);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.12);
}

.brand-logo {
  display: block;
  height: auto;
  object-fit: contain;
}

.login-logo {
  width: min(100%, 360px);
  margin: -4px 0 12px;
}

.side-logo {
  width: 238px;
  max-width: 100%;
}

.public-logo {
  width: min(100%, 320px);
  margin: -2px auto 12px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(19, 128, 79, 0.10), rgba(244, 246, 242, 0) 42%),
    var(--surface);
}

.login-card {
  width: min(460px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 6px 0 24px;
  font-size: 30px;
  line-height: 1.15;
}

.login-card label,
.code-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.login-card input,
.code-form input,
.code-form textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.code-form textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.6;
}

.login-card input:focus,
.code-form input:focus,
.code-form textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(19, 128, 79, 0.12);
}

.login-card form {
  display: grid;
  gap: 16px;
}

.login-card button,
.save,
.new-link,
.public-button {
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  cursor: pointer;
  font-weight: 800;
}

.login-card button:hover,
.save:hover,
.new-link:hover,
.public-button:hover {
  background: var(--green-dark);
}

.login-card button,
.save {
  min-height: 44px;
}

.form-error,
.flash.error {
  color: var(--red);
}

.admin-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  background: #eef2ed;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--nav);
  padding: 20px;
}

.brand {
  margin-bottom: 20px;
  padding: 2px 0 6px;
}

.new-link {
  display: block;
  text-align: center;
  padding: 12px;
  margin-bottom: 10px;
  background: #1a8c5a;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.side-menu {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.side-menu a {
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 800;
}

.side-menu a:hover,
.side-menu a.active {
  color: #fff;
  border-color: rgba(231, 245, 236, 0.24);
  background: rgba(255, 255, 255, 0.1);
}

.code-nav {
  display: grid;
  gap: 8px;
}

.code-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
  background: var(--nav-2);
}

.code-pill:hover,
.code-pill.active {
  border-color: rgba(90, 211, 142, 0.55);
  background: #1d312a;
}

.code-pill b,
.code-pill small {
  display: block;
}

.code-pill small {
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.5);
}

.code-pill em {
  color: #9be6bc;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.side .empty {
  color: rgba(255, 255, 255, 0.56);
}

.logout {
  width: 100%;
  margin-top: 20px;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  cursor: pointer;
}

.logout:hover {
  background: rgba(255, 255, 255, 0.08);
}

.admin-main {
  padding: 28px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 22px;
  margin-bottom: 18px;
}

.admin-header h1,
.section-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.admin-header h1 {
  font-size: clamp(25px, 3vw, 36px);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
}

.metrics div,
.editor,
.logs {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metrics div {
  padding: 15px 16px;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metrics strong {
  display: block;
  margin-top: 7px;
  color: #10251a;
  font-size: 26px;
  line-height: 1;
}

.flash {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #bfdfc9;
  border-radius: 8px;
  background: var(--mint);
  color: var(--green-dark);
  font-weight: 700;
}

.editor,
.logs {
  margin-bottom: 18px;
  padding: 20px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.editor-actions {
  display: flex;
  gap: 8px;
}

.danger {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #e6b8b6;
  border-radius: 8px;
  color: var(--red);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.danger:hover {
  background: #fff4f3;
}

.edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
}

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

.code-form .wide {
  grid-column: 1 / -1;
}

.code-form select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.radio-row {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 18px;
}

.radio-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-weight: 700;
}

.radio-row input {
  width: auto;
  min-height: 0;
}

.save {
  grid-column: 1 / -1;
  justify-self: start;
  min-width: 160px;
  padding: 0 18px;
}

.qr-pool {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid #dce5dc;
  border-radius: 8px;
  background: #f8faf6;
}

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

.pool-head h3 {
  margin: 0;
  font-size: 20px;
}

.pool-head span,
.section-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--mint);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.pool-note {
  margin: -2px 0 2px;
  color: var(--muted);
  line-height: 1.65;
}

.pool-row {
  display: grid;
  grid-template-columns: 74px minmax(120px, 1fr) 130px minmax(160px, 1.2fr) minmax(140px, 0.9fr) 76px 74px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid #e3e9e1;
  border-radius: 8px;
  background: #fff;
}

.pool-row-new {
  grid-template-columns: 74px minmax(140px, 1fr) minmax(180px, 1.1fr) minmax(150px, 0.9fr);
}

.pool-thumb {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.pool-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pool-thumb-empty {
  color: var(--green);
  background: var(--mint);
  font-size: 26px;
  font-weight: 900;
}

.pool-url {
  min-width: 0;
}

.pool-stat {
  display: grid;
  align-content: center;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #edf1ea;
  border-radius: 8px;
  background: #f8fbf6;
}

.pool-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pool-stat strong {
  font-size: 18px;
}

.pool-delete {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid #f0d2d2;
  border-radius: 8px;
  background: #fff8f7;
  color: #9f1d1d;
  font-size: 13px;
  font-weight: 900;
}

.pool-delete input {
  width: 16px;
  height: 16px;
  accent-color: #b3261e;
}

.new-pool-title {
  margin-top: 6px;
  color: var(--ink);
  font-weight: 900;
}

.qr-card {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid #e5e9e2;
  border-radius: 8px;
  background: #f9fbf7;
}

.qr-preview {
  display: grid;
  place-items: center;
  min-height: 270px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.qr-preview-img {
  max-width: 100%;
  max-height: 308px;
  object-fit: contain;
}

.pool-preview-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  padding: 10px;
}

.pool-preview-stack .qr-preview-img {
  width: 100%;
  aspect-ratio: 1;
  max-height: none;
  padding: 8px;
  border: 1px solid #edf1ea;
  border-radius: 8px;
  background: #fff;
}

.qr-empty {
  padding: 20px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.public-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.public-link span {
  padding: 11px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-link button {
  min-width: 82px;
  border: 0;
  border-left: 1px solid var(--line);
  background: #edf4ee;
  cursor: pointer;
  font-weight: 800;
}

.public-link button:hover {
  background: #dceee2;
}

.qr-card dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0;
}

.qr-card dl div {
  padding: 12px;
  border: 1px solid #edf1ea;
  border-radius: 8px;
  background: #fff;
}

.qr-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.qr-card dd {
  margin: 6px 0 0;
  font-weight: 800;
}

.log-list {
  display: grid;
  gap: 8px;
}

.log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 18px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #dce4d8;
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 900;
}

.filter-chip:hover,
.filter-chip.active {
  color: var(--green-dark);
  border-color: #b9d8c3;
  background: var(--mint);
}

.log-list div {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 72px 92px 128px 128px minmax(120px, 0.8fr);
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid #edf1ea;
  border-radius: 8px;
  background: #fff;
}

.log-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-list span small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-list b {
  color: var(--green-dark);
}

.log-list em {
  color: var(--muted);
  font-style: normal;
}

.log-list code {
  overflow: hidden;
  padding: 5px 7px;
  border-radius: 6px;
  color: #506057;
  background: #f4f7f1;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.public-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(19, 128, 79, 0.12), rgba(244, 246, 242, 0) 36%),
    var(--surface);
}

.wechat-card {
  width: min(440px, 100%);
  padding: 24px 20px 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}

.public-brand {
  display: inline-block;
  margin-bottom: 14px;
  padding: 6px 11px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--mint);
  font-size: 13px;
  font-weight: 900;
}

.assigned-label {
  display: inline-block;
  margin: 11px 0 0;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--green-dark);
  background: #eef8f1;
  font-size: 13px;
  font-weight: 900;
}

.wechat-card h1 {
  margin: 0;
  font-size: clamp(23px, 6vw, 31px);
  line-height: 1.22;
}

.public-desc {
  margin: 13px auto 17px;
  color: var(--muted);
  line-height: 1.75;
}

.wechat-qr-box {
  margin: 16px auto 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.wechat-qr-img {
  display: block;
  width: 100%;
  max-width: 330px;
  max-height: 68vh;
  margin: 0 auto;
  object-fit: contain;
  -webkit-touch-callout: default;
  user-select: auto;
}

.wechat-hint {
  margin: 13px 0 0;
  color: #000;
  font-weight: 900;
  line-height: 1.55;
}

.public-button {
  display: block;
  margin-top: 16px;
  padding: 13px 16px;
}

@media (max-width: 980px) {
  .admin-page {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    height: auto;
  }

  .admin-header,
  .edit-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .login-card,
  .wechat-card {
    padding: 22px 16px;
  }

  .admin-main {
    padding: 14px;
  }

  .code-form {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
  }

  .log-list div {
    grid-template-columns: 1fr;
  }

  .pool-row,
  .pool-row-new {
    grid-template-columns: 1fr;
  }

  .pool-head {
    display: grid;
  }

  .public-link {
    grid-template-columns: 1fr;
  }

  .public-link button {
    min-height: 40px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
