:root {
  color-scheme: light;
  --bg: #f6f2f5;
  --card: #ffffff;
  --ink: #1d2230;
  --muted: #5f6675;
  --line: #e3dde2;
  --brand: #b8166f;
  --brand-dark: #96105a;
  --brand-soft: #fbe8f2;
  --ok: #17754c;
  --ok-soft: #e2f3ea;
  --warn: #8a5800;
  --warn-soft: #fcefd3;
  --bad: #b3261e;
  --bad-soft: #fce8e6;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Sukhumvit Set", "Noto Sans Thai", "Leelawadee UI", Thonburi, "Segoe UI", sans-serif;
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

.page {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px calc(40px + env(safe-area-inset-bottom));
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- ส่วนหัว ---------- */
.hero {
  text-align: center;
  padding: 8px 0 6px;
}

.hero-logo {
  width: auto;
  height: 92px;
  mix-blend-mode: multiply; /* พื้นขาวของไฟล์โลโก้กลืนไปกับพื้นหลัง */
}

.hero-club {
  margin-top: 8px;
  color: var(--brand-dark);
  font-size: 0.9rem;
  font-weight: 600;
}

.hero h1 {
  margin-top: 4px;
  font-size: 1.45rem;
  line-height: 1.35;
  text-wrap: balance;
}

.hero-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- การ์ด ---------- */
.card {
  margin-top: 16px;
  padding: 18px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.08rem;
  line-height: 1.4;
}

.step {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 0.9rem;
}

.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.center {
  text-align: center;
}

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

/* ---------- บัญชีชมรม ---------- */
.account {
  margin-top: 14px;
  padding: 4px 14px;
  background: var(--brand-soft);
  border-radius: 12px;
}

.account > div {
  padding: 10px 0;
}

.account > div + div {
  border-top: 1px solid rgb(184 22 111 / 0.16);
}

.account dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.account dd {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-no {
  font-size: 1.45rem;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  user-select: all;
}

/* ---------- ฟอร์ม ---------- */
.field {
  margin-top: 16px;
}

label,
.label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

input[type="text"],
input[type="tel"],
input[type="password"],
input[type="search"],
textarea {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 11px 14px;
  border: 1.5px solid #cfc8ce;
  border-radius: 10px;
  background: #fff;
  color: inherit;
  font: inherit;
  appearance: none;
}

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

input:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible,
.slip-drop:focus-within {
  outline: 3px solid rgb(184 22 111 / 0.35);
  outline-offset: 1px;
  border-color: var(--brand);
}

input[aria-invalid="true"] {
  border-color: var(--bad);
}

.with-suffix {
  position: relative;
}

.with-suffix input {
  padding-right: 56px;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.with-suffix span {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--muted);
}

.err {
  margin-top: 6px;
  color: var(--bad);
  font-size: 0.9rem;
}

.err:empty {
  display: none;
}

.form-err {
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--bad-soft);
  border-radius: 10px;
}

.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* แนบสลิป */
.slip-drop {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 132px;
  margin: 0;
  padding: 16px;
  border: 1.5px dashed #bdb3bb;
  border-radius: 12px;
  background: #fcfafb;
  color: var(--muted);
  font-weight: 400;
  text-align: center;
  cursor: pointer;
}

.slip-drop.has-file {
  border-style: solid;
  background: #fff;
}

.slip-empty {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.slip-empty strong {
  color: var(--brand-dark);
}

.slip-empty small {
  font-size: 0.85rem;
}

#slip-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
}

.slip-change {
  color: var(--brand-dark);
  font-size: 0.9rem;
  font-weight: 600;
}

/* ช่องติ๊ก */
.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  font-weight: 400;
  cursor: pointer;
}

.check input {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 1px 0 0;
  accent-color: var(--brand);
}

.check small {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.tax-toggle {
  margin-top: 20px;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
}

.tax-toggle:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.tax-fields {
  margin-top: 4px;
  padding: 0 2px 4px;
}

.tax-fields .check {
  margin-top: 14px;
  font-size: 0.93rem;
}

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 18px;
  border: 1.5px solid #cfc8ce;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.btn.primary:active {
  background: var(--brand-dark);
}

.btn.ok {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
}

.btn.danger {
  border-color: var(--bad);
  color: var(--bad);
}

.btn.block {
  width: 100%;
}

.btn.small {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

form .btn.block {
  margin-top: 18px;
}

/* ---------- หน้าขอบคุณ ---------- */
.done {
  padding: 28px 18px 22px;
  text-align: center;
}

.done:focus {
  outline: none;
}

.done h2 {
  display: block;
  margin-top: 10px;
  font-size: 1.2rem;
}

.done-mark {
  color: var(--ok);
}

.done-amount {
  margin: 10px 0 6px;
  font-size: 1.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ref {
  font-size: 1.15rem;
  letter-spacing: 0.06em;
}

.done .btn {
  margin-top: 18px;
}

/* ====================== หน้าแอดมิน ====================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand);
  color: #fff;
}

.topbar strong {
  display: block;
  line-height: 1.3;
}

.topbar small {
  opacity: 0.85;
}

.topbar .btn {
  border-color: rgb(255 255 255 / 0.5);
  background: transparent;
  color: #fff;
}

.page.wide {
  max-width: 720px;
  padding-top: 14px;
}

.banner {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bad-soft);
  color: var(--bad);
  font-weight: 600;
}

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tile {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: inherit;
  font: inherit;
  text-align: left;
}

button.tile {
  cursor: pointer;
}

.tile span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.tile strong {
  display: block;
  font-size: 1.5rem;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.tile small {
  color: var(--muted);
  font-size: 0.82rem;
}

.tile.alert {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.tile.alert strong,
.tile.alert span {
  color: var(--bad);
}

.chips {
  display: flex;
  gap: 8px;
  margin: 14px -16px 0;
  padding: 2px 16px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 1.5px solid #cfc8ce;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.93rem;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}

#q {
  margin-top: 8px;
}

.list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.row {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.row.state-pass,
.row.state-approved {
  border-left-color: var(--ok);
}

.row.state-suspect {
  border-left-color: var(--bad);
}

.row.state-unverified,
.row.state-pending {
  border-left-color: #d99a1c;
}

.row.state-rejected {
  border-left-color: #9aa0ab;
  opacity: 0.75;
}

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

.row-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.row-amount {
  flex: none;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.row-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.row-reason {
  margin-top: 6px;
  color: var(--bad);
  font-size: 0.9rem;
}

.row.state-unverified .row-reason,
.row.state-pending .row-reason {
  color: var(--warn);
}

.pill {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  background: #eceef2;
  color: #3d4350;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill.state-pass,
.pill.state-approved {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.state-suspect {
  background: var(--bad-soft);
  color: var(--bad);
}

.pill.state-unverified,
.pill.state-pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.tax {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.empty {
  margin-top: 28px;
  text-align: center;
  color: var(--muted);
}

#more {
  margin-top: 12px;
}

.export .btn {
  width: 100%;
  margin-top: 10px;
}

/* รายละเอียด */
dialog {
  width: 100%;
  max-width: 600px;
  height: 100%;
  max-height: 100%;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(20 16 24 / 0.55);
}

@media (min-width: 640px) {
  dialog {
    height: auto;
    max-height: 92vh;
    margin: 4vh auto;
    border-radius: 16px;
  }
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  font-size: 1.05rem;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.3rem;
  cursor: pointer;
}

.sheet-body {
  padding: 14px 16px calc(28px + env(safe-area-inset-bottom));
}

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

.d-name {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.d-amount {
  flex: none;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.d-amount small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.reasons {
  margin-top: 12px;
  padding: 10px 14px 10px 30px;
  border-radius: 12px;
  background: var(--bad-soft);
  color: var(--bad);
  font-weight: 600;
}

.reasons.soft {
  background: var(--warn-soft);
  color: var(--warn);
}

.reasons li + li {
  margin-top: 4px;
}

.slip-view {
  display: block;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: center;
  overflow: hidden;
}

.slip-view img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  margin: 0 auto;
}

.section {
  margin-top: 14px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.section h3 {
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.kv {
  display: grid;
  grid-template-columns: minmax(96px, 36%) 1fr;
  gap: 6px 12px;
  font-size: 0.95rem;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.kv a {
  color: var(--brand-dark);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.actions-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toast {
  margin-top: 10px;
  color: var(--bad);
  font-size: 0.9rem;
}

.toast:empty {
  display: none;
}
