:root {
  --primary: #ff3f35;
  --accent: #10a7e8;
  --surface: #fff7ef;
  --ink: #172033;
  --muted: #667085;
  --line: #e7ebf2;
  --card: #ffffff;
  --shadow: 0 16px 42px rgba(23, 32, 51, 0.12);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  color: var(--ink);
  background: #edf1f6;
  overflow-x: hidden;
}

body:not(.admin-body) {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 430px);
  justify-content: center;
  align-items: stretch;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

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

.phone-page {
  width: min(100vw, 430px);
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  justify-self: center;
  background:
    radial-gradient(circle at 18% 8%, color-mix(in srgb, var(--primary), white 76%), transparent 26%),
    linear-gradient(180deg, var(--surface) 0%, #f7f8fb 45%, #eef2f6 100%);
  overflow: hidden;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  border-radius: 9px;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--primary), transparent 72%);
  font-weight: 900;
}

.copy-button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

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

.section {
  padding: 18px 12px 30px;
  overflow: hidden;
}

.coupon-list {
  display: grid;
  gap: 22px;
}

.coupon-card {
  overflow: hidden;
  width: 100%;
  min-width: 0;
  background: var(--card);
  border: 1px solid rgba(231, 235, 242, 0.92);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(23, 32, 51, 0.09);
}

.card-image-wrap {
  padding: 0;
  background: #fff;
}

.card-body {
  padding: 13px;
}

.code-box {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 10px;
  color: var(--primary);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 900;
}

.copy-button {
  width: 100%;
  margin-top: 10px;
  color: #fff;
  background: var(--primary);
}

.copy-button.copied {
  background: #4cd964;
  box-shadow: 0 4px 10px rgba(76, 217, 100, 0.3);
}

.card-clean-page {
  max-width: 430px;
  margin: 0 auto;
  padding: 14px 12px 36px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--primary), white 88%) 0%, #f7f9fc 22%, #eef2f7 100%);
}

.card-clean-page .section {
  padding: 0;
  overflow: visible;
}

.card-clean-page .coupon-list {
  gap: 16px;
}

.card-announcement {
  position: relative;
  min-height: 38px;
  overflow: hidden;
  color: color-mix(in srgb, var(--primary), #172033 24%);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.82)),
    color-mix(in srgb, var(--primary), white 86%);
  border: 1px solid color-mix(in srgb, var(--primary), white 76%);
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
}

.card-announcement::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  z-index: 1;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 999px;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary), transparent 84%);
  transform: translateY(-50%);
}

.announcement-track {
  width: 100%;
  min-width: 0;
  display: flex;
  gap: 34px;
  align-items: center;
  padding: 10px 18px 10px 34px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 900;
}

.announcement-track span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-announcement.is-marquee .announcement-track {
  width: max-content;
  max-width: none;
  animation: announcementMove 9s ease-in-out infinite alternate;
}

.card-announcement.is-marquee:hover .announcement-track {
  animation-play-state: paused;
}

@keyframes announcementMove {
  from { transform: translateX(0); }
  to { transform: translateX(calc(100vw - 100% - 76px)); }
}

.card-clean-page .coupon-card {
  padding: 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(231, 235, 242, 0.96);
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.1);
}

.card-clean-page .card-image-wrap {
  width: 92%;
  margin: 0 auto 12px;
  overflow: hidden;
  background: #fff;
  border-radius: 14px;
}

.card-clean-page .type-bimg {
  width: 100%;
  max-width: 100%;
  display: block;
  margin: 0 auto;
  border-radius: 14px;
  box-shadow: none;
}

.card-clean-page .card-body {
  padding: 0 2px 3px;
}

.card-clean-page .code-box {
  min-height: 54px;
  padding: 13px 12px;
  color: #172033;
  background: linear-gradient(180deg, #fff 0%, #fafbfc 100%);
  border: 1px solid #e8edf4;
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  line-height: 1.55;
  font-size: 15px;
  font-weight: 800;
}

.card-clean-page .copy-button {
  min-height: 48px;
  margin-top: 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary), white 8%), var(--primary));
  box-shadow: 0 12px 22px color-mix(in srgb, var(--primary), transparent 74%);
  font-size: 16px;
}

.card-clean-page .copy-button.copied {
  background: #4cd964;
  box-shadow: 0 12px 22px rgba(76, 217, 100, 0.24);
}

.more-token-hint {
  margin-top: 10px;
  color: #98a2b3;
  text-align: center;
  line-height: 1.4;
  font-size: 12px;
  font-weight: 800;
}

.poster-page {
  max-width: 430px;
  padding: 20px 15px 44px;
  background: #f7f8fa;
}

.poster-page .section {
  padding: 0;
}

.poster-page .coupon-list {
  display: block;
}

.collection-page {
  width: min(100vw, 430px);
  max-width: 430px;
  background: var(--surface, #f5f6f8);
}

.collection-page .section {
  padding: 0 10px 28px;
}

.collection-page .coupon-list {
  display: block;
}

.collection-single {
  width: 100%;
}

.collection-hero {
  margin: 0 -10px 12px;
}

.collection-hero img,
.collection-item img {
  width: 100%;
  display: block;
}

.collection-items {
  display: grid;
  gap: 12px;
}

.collection-item {
  display: block;
  width: 100%;
  overflow: hidden;
  min-height: 72px;
  color: #172033;
  text-align: center;
  text-decoration: none;
  background: #fff;
  border: 4px solid #fff;
  border-radius: 8px;
  padding: 0;
  font: inherit;
  box-shadow: 0 10px 26px rgba(23, 32, 51, 0.08);
  cursor: pointer;
}

.collection-item span {
  display: grid;
  min-height: 96px;
  place-items: center;
  padding: 16px;
  font-size: 18px;
  font-weight: 900;
}

.link-qr-page {
  width: min(100vw, 430px);
  max-width: 430px;
  padding: 14px 12px 36px;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
}

.link-qr-page .section {
  padding: 0;
  overflow: visible;
}

.linkqr-single {
  display: grid;
  gap: 16px;
}

.linkqr-guide {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  color: #344054;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(231, 235, 242, 0.96);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.06);
  font-size: 14px;
  font-weight: 900;
  white-space: pre-line;
}

.linkqr-group {
  display: grid;
  gap: 10px;
}

.linkqr-date {
  margin: 0;
  padding: 0 2px;
  color: #172033;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 900;
}

.linkqr-items {
  display: grid;
  gap: 10px;
}

.linkqr-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 13px;
  background: #fff;
  border: 1px solid rgba(231, 235, 242, 0.96);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
  overflow: hidden;
}

.linkqr-card::after {
  display: none;
  content: none;
}

.linkqr-watermark {
  position: absolute;
  z-index: 0;
  color: #0f172a;
  font-weight: 900;
  letter-spacing: 2px;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.linkqr-card > * {
  position: relative;
  z-index: 1;
}

.linkqr-card > .linkqr-watermark {
  position: absolute;
  z-index: 0;
}

.linkqr-card.is-expired {
  color: #98a2b3;
  background: #f2f4f7;
  border-color: #e4e7ec;
  box-shadow: none;
}

.linkqr-card.is-expired .linkqr-watermark {
  color: #667085;
}

.linkqr-card.is-urgent {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #fff7f5 0%, #fff 100%);
  border-color: #ff6b5f;
  box-shadow: 0 12px 26px rgba(255, 63, 53, 0.18);
  animation: urgentPulse 1.35s ease-in-out infinite;
}

.linkqr-card.is-urgent .linkqr-watermark {
  color: #ff3f35;
}

.linkqr-card.is-urgent::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 63, 53, 0.18);
}

.linkqr-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.linkqr-limit {
  flex: 0 0 auto;
  max-width: 52%;
  padding: 5px 9px;
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #ffb4a8;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.linkqr-limit.is-corner {
  position: absolute;
  top: 0;
  right: 0;
  width: 54px;
  height: 54px;
  max-width: none;
  padding: 0;
  overflow: hidden;
  color: transparent;
  background: transparent;
  border: 0;
  border-radius: 0;
  pointer-events: none;
}

.linkqr-limit.is-corner::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-top: 54px solid #ff3f35;
  border-left: 54px solid transparent;
}

.linkqr-limit.is-corner span {
  content: "限量";
  position: absolute;
  top: 8px;
  right: -3px;
  width: 54px;
  color: #fff;
  text-align: center;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  transform: rotate(45deg);
  transform-origin: center;
  content: normal;
}

.linkqr-expiry {
  min-width: 0;
  flex: 1 1 auto;
  color: #667085;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.linkqr-card.is-expired .linkqr-limit {
  color: #667085;
  background: #e4e7ec;
  border-color: #d0d5dd;
}

.linkqr-card.is-expired .linkqr-limit.is-corner {
  background: transparent;
  border: 0;
}

.linkqr-card.is-expired .linkqr-limit.is-corner::before {
  border-top-color: #98a2b3;
}

.linkqr-card.is-expired .linkqr-expiry {
  color: #98a2b3;
}

.linkqr-card.is-urgent .linkqr-expiry {
  color: #d92d20;
}

.linkqr-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
}

.linkqr-open,
.linkqr-qr {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 900;
}

.linkqr-open {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 10px 20px color-mix(in srgb, var(--primary), transparent 76%);
}

.linkqr-card.is-opened .linkqr-open {
  color: #fff;
  background: #12b76a;
  box-shadow: 0 10px 20px rgba(18, 183, 106, 0.2);
}

.linkqr-qr {
  color: #172033;
  background: #eef2f6;
}

.linkqr-card.is-qr-viewed .linkqr-qr {
  color: #175cd3;
  background: #d1e9ff;
}

.linkqr-card.is-expired .linkqr-open,
.linkqr-card.is-expired .linkqr-qr {
  color: #667085;
  background: #e4e7ec;
  box-shadow: none;
}

.linkqr-card.is-expired.is-opened .linkqr-open {
  color: #667085;
  background: #d0d5dd;
}

.linkqr-card.is-expired.is-qr-viewed .linkqr-qr {
  color: #667085;
  background: #d0d5dd;
}

.linkqr-card.is-urgent .linkqr-open {
  background: #ff3f35;
  box-shadow: 0 12px 22px rgba(255, 63, 53, 0.28);
}

.linkqr-card.is-urgent.is-opened .linkqr-open {
  background: #12b76a;
  box-shadow: 0 10px 20px rgba(18, 183, 106, 0.2);
}

.linkqr-card.is-urgent .linkqr-qr {
  color: #b42318;
  background: #ffe9e6;
}

.linkqr-card.is-urgent.is-qr-viewed .linkqr-qr {
  color: #175cd3;
  background: #d1e9ff;
}

@keyframes urgentPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.62);
  -webkit-user-select: none;
  user-select: none;
}

.qr-modal.show {
  display: grid;
}

.qr-card {
  position: relative;
  width: min(320px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.26);
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
}

.qr-title {
  font-size: 17px;
  font-weight: 900;
}

.qr-box {
  display: grid;
  place-items: center;
  padding: 10px;
  background: #fff;
  border: 1px solid #e7ebf2;
  border-radius: 14px;
}

.qr-box svg,
.qr-image {
  width: min(240px, 100%);
  height: auto;
  display: block;
}

.qr-image {
  image-rendering: pixelated;
  -webkit-touch-callout: default;
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
}

.qr-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  color: #667085;
  background: #f2f4f7;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.poster-single {
  width: 100%;
}

.poster-single > .drugsword:first-child {
  padding-top: 14px;
}

.scenograph {
  text-align: center;
  margin-bottom: 25px;
}

#type-bimg,
.type-bimg {
  max-width: 100%;
  display: block;
  margin: 0 auto;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.poster-empty-image {
  min-height: 360px;
  display: grid;
  place-items: center;
  color: rgba(23, 32, 51, 0.62);
  background:
    repeating-linear-gradient(135deg, rgba(23, 32, 51, 0.08) 0 1px, transparent 1px 15px),
    #fff;
  border: 1px dashed #d8dee8;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  font-weight: 900;
}

.drugsword {
  max-width: 400px;
  margin: 0 auto;
}

.medicine-bag {
  position: relative;
  margin-bottom: 20px;
  margin-top: 2px;
  padding: 22px 15px;
  background: #fff;
  border: 2px dashed #ff6b6b;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.title-tip {
  position: absolute;
  top: -11px;
  left: 50%;
  max-width: calc(100% - 20px);
  padding: 4px 14px;
  color: #fff;
  background: #ff4757;
  border-radius: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 900;
  transform: translateX(-50%);
}

#np,
.poster-code-text {
  color: #333;
  text-align: center;
  word-break: break-all;
  line-height: 26px;
  font-size: 16px;
  font-weight: 500;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.icopy {
  display: block;
  width: 100%;
  padding: 14px 0;
  color: #fff;
  background: #ff6b6b;
  border: 0;
  border-radius: 50px;
  outline: none;
  box-shadow: 0 4px 10px rgba(255, 107, 107, 0.3);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
  font-weight: 900;
  transition: transform 0.2s, background-color 0.2s;
}

.icopy:active {
  transform: scale(0.97);
}

.icopy.copied,
.open-url {
  background: #4cd964;
  box-shadow: 0 4px 10px rgba(76, 217, 100, 0.3);
}

.finger-group {
  margin: 6px 0;
  text-align: center;
}

.finger {
  display: inline-block;
  margin: 0 2px;
  font-size: 24px;
  animation: fingerUp 1.2s infinite ease-in-out;
}

@keyframes fingerUp {
  0% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

.notice {
  margin: 14px 0 0;
  padding: 12px;
  color: #5d3208;
  background: #fff7e8;
  border: 1px solid #ffe1ad;
  border-radius: 14px;
  line-height: 1.65;
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  width: min(360px, calc(100% - 28px));
  padding: 12px 14px;
  color: #fff;
  background: rgba(23, 32, 51, 0.94);
  border-radius: 999px;
  box-shadow: 0 14px 32px rgba(23, 32, 51, 0.22);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.admin-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
  color: var(--ink);
}

.admin-body {
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.admin-layout {
  width: min(1560px, 100%);
  max-width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 380px;
  gap: 18px;
  margin: 0 auto;
  padding: 18px;
  color: var(--ink);
  overflow: visible;
}

.admin-layout.gallery-mode {
  grid-template-columns: 230px minmax(0, 1fr);
}

.admin-layout.gallery-mode .admin-preview {
  display: none !important;
}

.admin-sidebar {
  align-self: start;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: hidden auto;
  padding: 14px;
  background: #101828;
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(16, 24, 40, 0.16);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 18px;
  color: #fff;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
}

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

.nav-item {
  min-height: 42px;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.74);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-weight: 900;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.admin-main {
  min-width: 0;
  min-height: calc(100vh - 36px);
  overflow: visible;
  padding-right: 2px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 14px 34px rgba(23, 32, 51, 0.08);
}

.module-header h1,
.module-header p {
  margin: 0;
}

.module-header h1 {
  font-size: 24px;
}

.module-header p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.page-manager {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.page-list {
  display: grid;
  gap: 10px;
  align-content: start;
}

.page-list-item {
  min-height: 72px;
  display: grid;
  gap: 6px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.06);
  cursor: pointer;
  text-align: left;
}

.page-list-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary), transparent 84%);
}

.page-list-item strong,
.page-list-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-list-item span {
  color: var(--muted);
  font-size: 12px;
}

.page-list-item.is-token-warning strong,
.page-list-item.is-token-expired strong {
  color: #e11d48;
}

.page-list-item.is-token-warning {
  border-color: #fecdd3;
  background: #fff7f7;
}

.page-list-item.is-token-expired {
  border-color: #fda4af;
  background: #fff1f2;
}

.page-editor {
  margin: 0;
}

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

.admin-preview {
  align-self: start;
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
}

.admin-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 14px 34px rgba(23, 32, 51, 0.08);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h1,
.panel-header h2 {
  margin: 0;
  font-size: 22px;
}

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

.admin-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field.full {
  grid-column: 1 / -1;
}

.field span {
  color: #344054;
  font-size: 13px;
  font-weight: 900;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d8dee8;
  border-radius: 10px;
  outline: none;
}

.field textarea {
  min-height: 76px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 82%);
}

.token-expiry-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: #175cd3;
  background: #eff8ff;
  border: 1px solid #b2ddff;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 900;
}

.token-expiry-badge.warning {
  color: #b54708;
  background: #fffaeb;
  border-color: #fedf89;
}

.token-expiry-badge.expired {
  color: #b42318;
  background: #fff1f3;
  border-color: #fecdca;
}

.token-expiry-badge.pending {
  color: #027a48;
  background: #ecfdf3;
  border-color: #abefc6;
}

.image-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.color-code-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.color-code-row input[type="color"] {
  width: 76px;
  padding: 4px;
}

.token-editor {
  display: grid;
  gap: 10px;
}

.token-editor-item,
.collection-editor-item,
.link-qr-editor-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.token-editor-item.dragging,
.collection-editor-item.dragging,
.link-qr-editor-item.dragging {
  opacity: .55;
  border-color: var(--accent);
  box-shadow: 0 14px 28px rgba(16, 167, 232, .16);
}

.token-sort-cell {
  display: grid;
  gap: 6px;
  align-content: start;
}

.token-drag-handle {
  width: 32px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #667085;
  background: #fff;
  border: 1px solid #d8dee8;
  border-radius: 9px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.token-drag-handle:active {
  cursor: grabbing;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.checkbox-field span {
  min-width: 0;
  white-space: nowrap;
}

.token-drag-handle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.token-index {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 9px;
  font-weight: 900;
}

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

.link-qr-editor-item .token-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.link-qr-editor-item .field.full {
  grid-column: 1 / -1;
}

.link-qr-editor-item .link-qr-item-actions {
  grid-column: 1 / -1;
  align-self: end;
  justify-self: stretch;
  width: 100%;
  max-width: 100%;
}

.link-qr-filter-row {
  width: 100%;
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.link-qr-filter-row .field {
  width: min(240px, 100%);
}

.link-qr-filter-row .danger-button {
  min-height: 42px;
}

.link-qr-pager {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: #475467;
  font-size: 13px;
  font-weight: 900;
}

.link-qr-pager .small-button {
  min-height: 36px;
  padding: 0 12px;
}

.link-qr-pager .small-button:disabled {
  color: #98a2b3;
  cursor: not-allowed;
  background: #f2f4f7;
}

.link-qr-item-actions {
  display: grid;
  grid-template-columns: minmax(0, max-content) max-content;
  align-items: center;
  justify-content: start;
  gap: 10px;
  justify-items: start;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.link-qr-click-count {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  color: #175cd3;
  background: #eff8ff;
  border: 1px solid #b2ddff;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 900;
  max-width: 100%;
  white-space: nowrap;
}

.link-qr-item-actions .danger-button {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1500px) {
  .link-qr-item-actions {
    grid-template-columns: minmax(0, max-content) max-content;
  }
}

@media (max-width: 1180px) {
  .link-qr-item-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1500px) {
  .admin-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .admin-preview {
    display: none;
  }
}

.link-qr-limit-control {
  grid-column: 1 / 2;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #d8dee8;
  border-radius: 10px;
}

.link-qr-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  white-space: nowrap;
  cursor: pointer;
}

.link-qr-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 auto;
  background: #d0d5dd;
  border-radius: 999px;
  transition: background .18s ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .24);
  transition: transform .18s ease;
}

.link-qr-switch input:checked + .switch-ui {
  background: var(--primary);
}

.link-qr-switch input:checked + .switch-ui::after {
  transform: translateX(14px);
}

.link-qr-switch strong {
  color: #344054;
  font-size: 13px;
  font-weight: 900;
}

.small-button,
.save-button,
.danger-button {
  min-height: 40px;
  padding: 0 13px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font-weight: 900;
}

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

.save-button.is-saving {
  opacity: 0.72;
  pointer-events: none;
}

.small-button {
  color: var(--ink);
  background: #eef2f6;
}

.danger-button {
  color: #b42318;
  background: #fff1f0;
}

.preview-frame {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 28px;
  background: #111827;
  padding: 12px;
}

.preview-frame iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  border: 0;
  border-radius: 20px;
  background: #fff;
}

.image-manager {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px;
}

.empty-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.image-item {
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.image-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: contain;
  background:
    repeating-linear-gradient(135deg, rgba(23, 32, 51, 0.08) 0 1px, transparent 1px 12px),
    #eef2f6;
}

.admin-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  color: #fff;
  background: rgba(23, 32, 51, 0.94);
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(23, 32, 51, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 180ms ease, transform 180ms ease;
  font-weight: 900;
}

.admin-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.admin-toast.success {
  background: #0b7a42;
}

.admin-toast.error {
  background: #b42318;
}

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

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

.admin-modal-card {
  width: min(380px, 100%);
  padding: 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.admin-modal-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
}

.admin-modal-card p {
  margin: 10px 0 18px;
  color: #475467;
  line-height: 1.7;
  font-weight: 700;
}

.admin-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.image-meta {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.image-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

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

.image-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.uploading {
  opacity: 0.68;
  pointer-events: none;
}

@media (max-width: 860px) {
  .admin-body {
    height: auto;
    overflow: auto;
  }

  .admin-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .admin-sidebar,
  .admin-preview {
    position: static;
    min-height: auto;
    max-height: none;
    height: auto;
    overflow: visible;
  }

  .admin-main {
    height: auto;
    overflow: visible;
  }

  .page-manager {
    grid-template-columns: 1fr;
  }

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

  .preview-frame {
    position: static;
  }

  .preview-frame iframe {
    height: 760px;
  }
}

@media (min-width: 760px) {
  .phone-page {
    width: 430px;
    max-width: 430px;
    margin: 0 auto;
    justify-self: center;
  }
}

@media (max-width: 560px) {
  .field-grid,
  .token-fields {
    grid-template-columns: 1fr;
  }

  .image-field-row {
    grid-template-columns: 1fr;
  }

  .admin-page {
    padding: 10px;
  }
}

.daily-stats {
  display: grid;
  gap: 10px;
}

.daily-stat-summary,
.daily-stat-row,
.daily-stat-token-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.daily-stat-summary span,
.daily-stat-token-row span,
.daily-stat-row {
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  background: #f8fafc;
  color: #10213d;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 10px;
}

.daily-stat-summary strong {
  color: #ff3f35;
  font-size: 18px;
}

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

.token-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
}

.token-action-row .danger-button {
  flex: 0 0 240px;
  max-width: 240px;
  white-space: nowrap;
}

.token-copy-stats {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
  margin-left: auto;
  white-space: nowrap;
}

.token-copy-stats span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #b2ddff;
  border-radius: 999px;
  background: #eff8ff;
  color: #175cd3;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
