:root {
  --ink: #18201b;
  --ink-soft: #35423a;
  --muted: #68736c;
  --line: #dce3de;
  --line-strong: #c5d0c8;
  --surface: #ffffff;
  --canvas: #f3f5f4;
  --green: #138a43;
  --green-dark: #0a6730;
  --green-soft: #e9f5ed;
  --blue-soft: #edf4fa;
  --blue: #315f87;
  --red: #b42318;
  --red-soft: #fff1ef;
  --amber: #8a5800;
  --amber-soft: #fff6dc;
  --shadow: 0 8px 26px rgba(25, 44, 32, 0.07);
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { min-height: 100vh; margin: 0; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button, .button { min-height: 42px; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { border-color: var(--line-strong); background: white; color: var(--ink-soft); }
.button.secondary:hover, .button.ghost:hover { border-color: var(--green); color: var(--green-dark); }
.button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.button.danger-outline { border-color: #e7b8b3; background: white; color: var(--red); }
.button.danger-outline:hover { border-color: var(--red); background: var(--red-soft); }
.button.wide { width: 100%; }
.text-button { min-height: 30px; padding: 2px 0; border: 0; background: transparent; cursor: pointer; font-size: 13px; font-weight: 700; }
.text-button.danger { color: var(--red); }

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 7px;
  background: var(--green);
  color: white;
  font-size: 22px;
  font-weight: 800;
}
.brand-mark.small { width: 32px; height: 32px; font-size: 15px; }

/* Authentication */
.auth-page { background: #e9eeeb; }
.auth-shell { display: grid; min-height: 100vh; padding: 24px; place-items: center; }
.auth-panel {
  width: min(100%, 410px);
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-panel .brand-mark { margin-bottom: 28px; }
.auth-panel h1 { margin: 0 0 8px; font-size: 27px; letter-spacing: 0; }
.auth-panel > .muted { margin: 0 0 28px; line-height: 1.6; }
.stack-form { display: grid; gap: 10px; }
.stack-form label, .field label { color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.stack-form input, .field input, .field textarea {
  width: 100%;
  border: 1px solid #cbd4cd;
  border-radius: 5px;
  background: white;
  color: var(--ink);
  outline: none;
}
.stack-form input, .field input { height: 44px; padding: 0 12px; }
.field textarea { min-height: 92px; padding: 11px 12px; resize: vertical; }
.stack-form input:focus, .field input:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(19, 138, 67, 0.12); }
.stack-form .button { margin-top: 8px; }
.auth-foot { margin: 28px 0 0; color: #8a938c; font-size: 12px; text-align: center; }

/* Admin */
.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 10px max(24px, calc((100% - 1200px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; text-decoration: none; }
.topbar form { margin: 0; }
.admin-shell { width: min(1200px, calc(100% - 48px)); margin: 42px auto 60px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 26px; }
.page-heading h1 { margin: 0; font-size: 32px; letter-spacing: 0; }
.summary-strip { display: grid; grid-template-columns: repeat(3, minmax(105px, 1fr)); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.summary-strip > span { display: grid; gap: 2px; padding: 11px 18px; border-left: 1px solid var(--line); }
.summary-strip > span:first-child { border-left: 0; }
.summary-strip b { font-size: 21px; }
.summary-strip small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.workspace { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 5px 18px rgba(28, 49, 35, 0.045); }
.section-heading { display: flex; min-height: 65px; align-items: center; justify-content: space-between; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.section-heading > div { display: flex; align-items: center; gap: 12px; }
.section-heading h2 { margin: 0; font-size: 16px; letter-spacing: 0; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.section-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 5px; background: var(--green-soft); color: var(--green-dark); font-size: 23px; line-height: 1; }
.create-form { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto; gap: 16px; align-items: end; padding: 20px; }
.field { display: grid; gap: 7px; align-content: start; min-width: 0; }
.field small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.notice { margin-bottom: 18px; padding: 12px 14px; border: 1px solid; border-radius: 5px; font-size: 14px; }
.notice.success { border-color: #b9dec6; background: var(--green-soft); color: var(--green-dark); }
.notice.error { border-color: #efc2bd; background: var(--red-soft); color: var(--red); }
.auth-panel .notice { margin-top: -10px; }

.entries-section { margin-top: 34px; }
.list-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 13px; }
.list-heading > div { display: flex; align-items: center; gap: 9px; }
.list-heading h2 { margin: 0; font-size: 19px; }
.list-heading span { display: grid; min-width: 24px; height: 24px; place-items: center; border-radius: 4px; background: #e2e7e4; color: var(--ink-soft); font-size: 12px; font-weight: 800; }
.list-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.entry-list { display: grid; gap: 14px; }
.entry-card { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 5px 18px rgba(28, 49, 35, 0.045); }
.entry-card-header { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.entry-title { display: flex; min-width: 0; align-items: center; gap: 11px; }
.entry-avatar { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border-radius: 5px; background: var(--blue-soft); color: var(--blue); font-size: 14px; font-weight: 800; }
.entry-title h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.entry-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.entry-state { display: flex; flex: 0 0 auto; align-items: center; gap: 13px; }
.status-dot { padding: 5px 8px; border-radius: 4px; background: var(--green-soft); color: var(--green-dark); font-size: 11px; font-weight: 800; }
.status-dot.waiting { background: var(--amber-soft); color: var(--amber); }
.scan-count { color: var(--muted); font-size: 12px; }
.scan-count b { color: var(--ink-soft); font-size: 15px; }
.entry-card-main { display: grid; grid-template-columns: 174px 36px 174px minmax(250px, 1fr); gap: 17px; align-items: center; padding: 20px; }
.code-column { min-width: 0; }
.code-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.code-label span { color: var(--ink-soft); font-size: 12px; font-weight: 800; }
.code-label small { color: var(--muted); font-size: 10px; }
.code-frame { display: grid; width: 100%; aspect-ratio: 1; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: white; }
.code-frame.entry-code { padding: 7px; }
.code-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.actual-code { background: #f7f9f8; }
.empty-code { color: #89938c; font-size: 13px; font-weight: 700; }
.pair-arrow { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); font-size: 20px; font-weight: 800; }
.entry-operations { display: grid; min-width: 0; gap: 11px; }
.entry-url { display: grid; min-width: 0; gap: 4px; padding: 9px 10px; border-left: 3px solid #89a8c3; background: var(--blue-soft); }
.entry-url span { color: var(--blue); font-size: 10px; font-weight: 800; }
.entry-url code { overflow: hidden; color: #294961; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.action-grid .button { min-height: 38px; padding: 7px 10px; font-size: 12px; }
.action-grid .span-2 { grid-column: 1 / -1; }
.upload-form { display: grid; grid-template-columns: auto minmax(60px, 1fr) auto; gap: 7px; align-items: center; }
.upload-form input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-form .button { min-height: 38px; padding: 7px 11px; font-size: 12px; }
.file-name { min-width: 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.entry-settings { border-top: 1px solid var(--line); background: #fafbfa; }
.entry-settings > summary, .global-settings > summary { padding: 14px 20px; cursor: pointer; color: var(--ink-soft); font-size: 13px; font-weight: 800; }
.entry-settings[open] > summary, .global-settings[open] > summary { border-bottom: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; padding: 20px; }
.field.span-2, .form-actions.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 20px 20px; padding-top: 16px; border-top: 1px solid #ead6d3; }
.danger-zone > div { display: grid; gap: 3px; }
.danger-zone strong { color: var(--red); font-size: 13px; }
.danger-zone span { color: var(--muted); font-size: 11px; }
.empty-list { display: grid; min-height: 260px; place-items: center; align-content: center; gap: 8px; border: 1px dashed var(--line-strong); border-radius: 7px; background: rgba(255, 255, 255, 0.45); text-align: center; }
.empty-list h3 { margin: 8px 0 0; font-size: 17px; }
.empty-list p { margin: 0; color: var(--muted); font-size: 13px; }
.global-settings { margin-top: 28px; box-shadow: none; }
.admin-footer { padding: 0 24px 32px; color: #7a847d; font-size: 11px; text-align: center; }

/* Public payment page */
.pay-page { min-height: 100vh; background: #f3f5f3; }
.pay-header { padding: max(30px, env(safe-area-inset-top)) 20px 26px; background: #118c43; color: white; text-align: center; }
.pay-header h1 { margin: 6px 0 0; font-size: 24px; letter-spacing: 0; overflow-wrap: anywhere; }
.pay-kicker { opacity: 0.72; font-size: 10px; font-weight: 800; letter-spacing: 0; }
.pay-shell { width: min(100%, 520px); margin: 0 auto; padding: 24px 18px 38px; }
.payment-area { text-align: center; }
.payment-label { margin: 0 0 16px; color: var(--green-dark); font-size: 19px; font-weight: 800; }
.payment-code-frame { display: grid; width: min(82vw, 340px); aspect-ratio: 1; margin: 0 auto; place-items: center; padding: 18px; border: 1px solid #d5dcd7; border-radius: 7px; background: white; box-shadow: 0 10px 30px rgba(22, 56, 35, 0.09); }
.payment-code-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.payment-area h2 { margin: 17px 0 8px; font-size: 20px; overflow-wrap: anywhere; letter-spacing: 0; }
.verified-line { margin: 0; color: var(--muted); font-size: 13px; }
.verified-line span { display: inline-grid; width: 19px; height: 19px; margin-right: 4px; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 12px; font-weight: 800; }
.payment-code-frame .empty-code { display: grid; gap: 6px; color: var(--muted); }
.payment-code-frame .empty-code span { font-size: 20px; font-weight: 800; }
.payment-code-frame .empty-code small { font-size: 13px; }
.pay-guide { margin-top: 28px; padding: 20px; border-top: 1px solid #dce2dd; border-bottom: 1px solid #dce2dd; text-align: center; }
.pay-guide > p { margin: 0 0 18px; color: var(--ink-soft); font-size: 14px; line-height: 1.7; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.steps span { display: grid; gap: 8px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.steps b { display: grid; width: 26px; height: 26px; margin: 0 auto; place-items: center; border-radius: 50%; background: white; color: var(--green); box-shadow: 0 0 0 1px #cbd6ce; }
.pay-footer { padding: 0 20px calc(22px + env(safe-area-inset-bottom)); color: #89918b; font-size: 11px; text-align: center; }

@media (max-width: 960px) {
  .entry-card-main { grid-template-columns: minmax(150px, 190px) 36px minmax(150px, 190px) 1fr; }
  .entry-operations { grid-column: 1 / -1; grid-template-columns: minmax(210px, 1fr) minmax(230px, 1fr); align-items: start; }
	.entry-operations .upload-form { grid-column: 1 / -1; }
  .entry-operations > form:last-child { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .admin-shell { width: min(100% - 28px, 1200px); margin-top: 28px; }
  .page-heading { display: grid; align-items: start; }
  .summary-strip { width: 100%; }
  .summary-strip > span { padding-inline: 10px; }
  .create-form { grid-template-columns: 1fr 1fr; }
  .create-form > .button { grid-column: 1 / -1; }
  .entry-card-main { grid-template-columns: minmax(120px, 1fr) 30px minmax(120px, 1fr); padding: 16px; gap: 10px; }
  .entry-operations { grid-template-columns: 1fr; }
  .entry-settings .form-grid, .global-settings .form-grid { grid-template-columns: 1fr; }
  .field.span-2, .form-actions.span-2 { grid-column: 1; }
}

@media (max-width: 500px) {
  .topbar { padding: 10px 14px; }
  .brand > span:last-child { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-heading h1 { font-size: 27px; }
  .summary-strip small { white-space: normal; }
  .create-form { grid-template-columns: 1fr; padding: 16px; }
  .create-form > .button { grid-column: 1; }
  .list-heading { align-items: center; }
  .list-heading p { display: none; }
  .entry-card-header { align-items: flex-start; padding: 13px 14px; }
  .entry-state { display: grid; justify-items: end; gap: 6px; }
  .entry-card-main { grid-template-columns: 1fr; }
  .pair-arrow { margin: 0 auto; transform: rotate(90deg); }
  .code-column { width: min(100%, 260px); margin: 0 auto; }
  .entry-operations { width: 100%; }
  .upload-form { grid-template-columns: auto minmax(50px, 1fr); }
  .upload-form .primary { grid-column: 1 / -1; }
  .danger-zone { align-items: flex-start; }
  .danger-zone > div span { max-width: 170px; }
  .auth-panel { padding: 30px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
