﻿:root {
  --bg: #f3f6ef;
  --ink: #020617;
  --muted: #64748b;
  --line: #e2e8f0;
  --card: #ffffff;
  --emerald: #022c22;
  --emerald-2: #064e3b;
  --teal: #115e59;
  --accent: #047857;
  --danger: #be123c;
  --shadow: 0 18px 50px rgba(2, 44, 34, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.icon { width: 1.15rem; height: 1.15rem; display: block; }
.icon use { pointer-events: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 64px;
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  backdrop-filter: blur(16px);
}
.topbar-inner, .page {
  width: min(72rem, 100%);
  margin: 0 auto;
}
.topbar-inner { flex-wrap: wrap; }
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-mark, .icon-btn, .hero-code, .heading-icon, .empty-icon, .tx-icon, .ledger-icon, .coupon-icon, .avatar {
  display: grid;
  place-items: center;
}
.logo-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--emerald); color: #fff;
}
.logo-name { display: block; font-size: 14px; font-weight: 650; }
.logo-en { display: block; font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.nav-desktop { display: none; gap: 4px; margin-left: 8px; }
.nav-link {
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.nav-link.is-active { background: #ecfdf5; color: #065f46; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.brand-wrap { position: relative; }
.brand-select {
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 28px 0 12px;
  font-size: 12px;
  font-weight: 700;
  appearance: none;
}
.brand-chevron {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  color: #94a3b8; pointer-events: none;
}
.brand-locked {
  display: inline-flex; align-items: center; height: 40px; padding: 0 12px;
  border-radius: 12px; border: 1px solid var(--line); background: #fff;
  font-size: 12px; font-weight: 700;
}
.field select:disabled { color: inherit; background: #f8fafc; opacity: 1; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: transparent; color: #334155;
}
.icon-btn:hover { background: #f8fafc; }
.page { padding: 20px 16px 96px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.page-head h1, .login-copy h2, .otp-copy h2 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.page-head p, .muted { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.heading-icon, .hero-code {
  width: 44px; height: 44px; border-radius: 16px; background: var(--emerald); color: #fff;
}
.stack { display: grid; gap: 16px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.channel, .mode-switch a { display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.mode-switch a { display: grid; }
.hero {
  position: relative; overflow: hidden; color: #fff;
  border-radius: 28px; padding: 22px;
  background: linear-gradient(135deg, var(--emerald), var(--emerald-2) 55%, var(--teal));
  box-shadow: 0 18px 40px rgba(2, 44, 34, 0.16);
}
.hero h1 { margin: 4px 0 0; font-size: 28px; }
.kicker { margin: 0; font-size: 12px; color: rgba(236, 253, 245, 0.7); }
.hero-row, .split, .coupon-top, .profile-id, .tx-row, .ledger-row, .summary-head, .help-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 3px 8px; font-size: 12px; font-weight: 700;
  background: #f1f5f9; color: #475569;
}
.badge-light { background: rgba(255,255,255,.12); color: #fff; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-line { background: transparent; border: 1px solid var(--line); }
.member-no { font-size: 12px; color: rgba(236, 253, 245, 0.75); }
.hero-code { width: 56px; height: 56px; border-radius: 18px; background: #fff; color: var(--emerald); }
.hero-action {
  margin-top: 22px; height: 44px; border-radius: 16px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.1); color: #fff; font-weight: 700; font-size: 14px;
}
#itmOpen.hero-action {
  background: linear-gradient(135deg, #e10600, #ff6600);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .08em;
}
#itmOpen.hero-action:hover, #itmOpen.hero-action:focus-visible { filter: brightness(1.08); }
.hero-itm-note { margin: 14px 0 0; color: rgba(236, 253, 245, .92); font-size: 14px; line-height: 1.6; }
.grid-4, .grid-2, .coupon-grid { display: grid; gap: 12px; }
.grid-4 { grid-template-columns: 1fr 1fr; }
.card {
  background: var(--card); border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 20px; box-shadow: var(--shadow);
}
.balance { display: block; padding: 16px; }
.tone { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.tone-violet { background: #f5f3ff; color: #6d28d9; }
.tone-amber { background: #fffbeb; color: #b45309; }
.tone-rose { background: #fff1f2; color: #be123c; }
.tone-blue { background: #eff6ff; color: #1d4ed8; }
.balance .label, .stat dt, .field-label { color: var(--muted); font-size: 12px; }
.balance strong, .stat dd { display: block; margin-top: 4px; font-size: 16px; }
.stat { background: #f8fafc; border-radius: 16px; padding: 14px; }
.stat dt { font-size: 11px; }
.stat dd { margin: 4px 0 0; font-size: 14px; }
.pad { padding: 20px; }
.section-title { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.section-title .more { margin-left: auto; color: var(--accent); font-size: 12px; flex-shrink: 0; white-space: nowrap; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.tx-row, .ledger-row, .profile-row { padding: 16px 20px; }
.tx-row + .tx-row, .ledger-row + .ledger-row, .profile-row + .profile-row { border-top: 1px solid var(--line); }
.tx-icon, .ledger-icon, .coupon-icon {
  width: 40px; height: 40px; border-radius: 12px; background: #ecfdf5; color: var(--accent); flex: 0 0 auto;
}
.ledger-icon { width: 36px; height: 36px; background: #f1f5f9; color: #64748b; }
.tx-main, .ledger-main { min-width: 0; flex: 1; }
.tx-main p, .ledger-main p, .profile-row dd { margin: 0; }
.sub { margin-top: 4px !important; color: #94a3b8; font-size: 12px; }
.amount { font-weight: 750; white-space: nowrap; flex-shrink: 0; }
.ledger-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #f8fafc; padding: 16px 20px; }
.cup-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin-top: 8px; }
.cup-qty-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: #475569; }
.cup-qty { height: 36px; border-radius: 10px; border: 1px solid var(--line); padding: 0 8px; background: #fff; }
.ledger-head p { margin: 0; }
.ledger-head strong { display: block; margin-top: 4px; font-size: 20px; }
.empty, .error-box { padding: 28px 20px; text-align: center; }
.empty-icon {
  width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 16px;
  background: #f8fafc; color: #94a3b8;
}
.coupon-grid { grid-template-columns: 1fr; }
.coupon-card { padding: 20px; }
.coupon-qr { margin-top: 12px; }
.coupon-qr canvas { width: 180px; height: 180px; }
.coupon-icon { background: #eff6ff; color: #1d4ed8; }
.is-dim { opacity: .6; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; }
.profile-id { justify-content: flex-start; background: #f8fafc; border-bottom: 1px solid var(--line); }
.avatar { width: 56px; height: 56px; border-radius: 16px; background: var(--emerald); color: #fff; font-size: 20px; font-weight: 700; }
.profile-row dd { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.field { display: block; font-size: 14px; font-weight: 650; }
.field input, .field select {
  width: 100%; height: 44px; margin-top: 8px; border-radius: 12px;
  border: 1px solid var(--line); padding: 0 12px; background: #fff;
}
.secret { position: relative; display: block; margin-top: 8px; }
.field .secret input { margin-top: 0; padding-right: 44px; }
.secret-toggle {
  position: absolute; right: 4px; top: 0; width: 40px; height: 44px;
  border: 0; padding: 0; background: transparent; color: #64748b;
  display: grid; place-items: center; cursor: pointer;
}
.secret-toggle:hover, .secret-toggle:focus-visible { color: var(--ink); }
.secret .icon-hide { display: none; }
.secret.is-shown .icon-show { display: none; }
.secret.is-shown .icon-hide { display: block; }
.field-note { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; font-weight: 450; line-height: 1.5; }
.otp-input { text-align: center; letter-spacing: .35em; font-size: 20px; }
.check {
  display: flex; gap: 10px; align-items: flex-start;
  background: #f8fafc; border-radius: 16px; padding: 14px; color: #475569; font-size: 14px; line-height: 1.6;
}
.btn {
  height: 44px; border: 0; border-radius: 12px; padding: 0 16px;
  background: var(--emerald); color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-block { width: 100%; }
.btn-line { background: #06c755; color: #fff; text-decoration: none; }
.btn-line:hover { background: #05b34c; }
.login-or {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  margin: 18px 0 14px; color: #94a3b8; font-size: 13px;
}
.login-or:before, .login-or:after { content: ""; height: 1px; background: var(--line); }
.btn-ghost {
  background: #fff; color: var(--ink); border: 1px solid var(--line);
}
.btn:disabled { opacity: .55; cursor: default; }
.alert { border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.alert-error { background: #fff1f2; color: #be123c; }
.alert-ok { background: #ecfdf5; color: #065f46; }
.note { display: flex; gap: 10px; padding: 14px; border-radius: 16px; background: #ecfdf5; color: #022c22; font-size: 14px; line-height: 1.6; }
.note-warn { background: rgba(236, 253, 245, .7); border: 1px solid #d1fae5; }
.qr-wrap { display: grid; place-items: center; padding: 28px 16px; background: #fff; }
.qr-frame {
  display: inline-block;
  padding: 8px;
  background: #fff;
  border: 6px solid #e10600;
  border-radius: 12px;
  line-height: 0;
}
.qr-wrap canvas {
  width: min(256px, calc(100vw - 96px));
  height: min(256px, calc(100vw - 96px));
}
.itm-qr { text-align: center; }
.itm-deal {
  display: flex; align-items: center; justify-content: center;
  width: min(100%, 280px); min-height: 64px; margin: 8px auto 0;
  border-radius: 16px; text-decoration: none; color: #fff;
  background: linear-gradient(135deg, #e10600, #ff6600);
  font-size: 22px; font-weight: 800; letter-spacing: .12em;
}
.itm-deal:hover, .itm-deal:focus-visible { filter: brightness(1.08); }
.itm-install { margin-top: 18px; }
.itm-install-lead { margin: 0 0 12px; color: #0f172a; font-size: 16px; font-weight: 800; }
.itm-store {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: min(100%, 280px); min-height: 58px; margin: 0 auto 10px; padding: 8px 16px;
  border-radius: 14px; text-decoration: none; color: #fff;
}
.itm-store-name { font-size: 18px; font-weight: 800; line-height: 1.2; }
.itm-store-os { margin-top: 2px; font-size: 13px; font-weight: 600; opacity: .92; }
.itm-store-apple { background: #000; }
.itm-store-play { background: #01875f; }
.itm-store:hover, .itm-store:focus-visible { filter: brightness(1.12); }
.qr-logo { position: absolute; width: auto; height: auto; left: -9999px; }
.qrcode-text {
  margin: 12px 0 0;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(to right, #ff6600, #ffaa00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.card-face { padding: 22px; color: #fff; background: linear-gradient(135deg, var(--emerald), var(--emerald-2), var(--teal)); }
.card-shell { overflow: hidden; border: 0; }
.narrow { width: min(32rem, 100%); margin: 0 auto; }
.medium { width: min(40rem, 100%); margin: 0 auto; }
.nav-mobile {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 4px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
}
.nav-mobile a {
  min-height: 56px; border-radius: 12px; color: #94a3b8;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 10px; font-weight: 650;
}
.nav-mobile a.is-active { background: #ecfdf5; color: #065f46; }

.login-page { min-height: 100vh; padding: 24px 16px; position: relative; overflow: hidden; }
.blob { position: absolute; width: 380px; height: 380px; border-radius: 999px; filter: blur(50px); z-index: 0; }
.blob-a { left: -120px; top: -140px; background: rgba(110, 231, 183, .35); }
.blob-b { right: -120px; bottom: -140px; background: rgba(190, 242, 100, .35); }
.help-fab {
  position: fixed; right: 16px; top: 16px; z-index: 20; height: 40px;
}
.login-shell {
  position: relative; z-index: 1; width: min(64rem, 100%); margin: 24px auto;
  display: grid; background: #fff; border-radius: 32px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(2, 44, 34, 0.12);
}
.login-hero { display: none; background: var(--emerald); color: #fff; padding: 40px; }
.login-form { padding: 28px 22px 32px; }
.mode-switch, .channel-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.mode-switch { background: #f1f5f9; padding: 4px; border-radius: 16px; gap: 0; }
.mode-switch button, .channel {
  height: 40px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: #64748b; font-weight: 700;
}
.mode-switch .is-on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.channel.is-on { border-color: var(--accent); background: #ecfdf5; color: #064e3b; }
.channel { background: #fff; border-color: var(--line); }
.form-stack { display: grid; gap: 14px; margin-top: 18px; }
.back-link { background: none; border: 0; color: #64748b; padding: 0; margin-bottom: 18px; font-weight: 650; }
.demo-code { display: flex; justify-content: space-between; align-items: center; border: 1px solid #d1fae5; background: #ecfdf5; border-radius: 16px; padding: 12px 16px; }
.help-list { display: grid; gap: 10px; margin-top: 18px; }
.help-row { align-items: flex-start; background: #fff; }
.help-row h2 { margin: 0; font-size: 15px; }
.help-row p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

@media (min-width: 768px) {
  .nav-desktop { display: flex; }
  .nav-mobile { display: none; }
  .page { padding-bottom: 32px; }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .split { display: grid; grid-template-columns: .9fr 1.1fr; align-items: stretch; }
  .coupon-grid { grid-template-columns: 1fr 1fr; }
  .login-hero { display: flex; flex-direction: column; }
  .login-shell { grid-template-columns: 1.05fr .95fr; }
  .login-form { padding: 44px; }
  .logo-text { display: block; }
}
@media (max-width: 767px) {
  .topbar .logo-text, .help-fab .logo-text { display: none; }
  .nav-desktop { display: none; }
  .split { flex-direction: column; align-items: stretch; }
  .split > * { width: 100%; min-width: 0; }
  .page { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  body:has(.card-page) { height: 100svh; overflow: hidden; }
  .page:has(.card-page) {
    box-sizing: border-box;
    height: calc(100svh - 64px);
    min-height: 0;
    padding: 10px 16px calc(76px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .card-page {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .card-page .page-head h1 { font-size: 20px; }
  .card-page .page-head p { margin-top: 2px; font-size: 13px; }
  .card-page .heading-icon { width: 36px; height: 36px; border-radius: 12px; }
  .card-page .card-shell {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
  }
  .card-page .card-face { flex: 0 0 auto; padding: 12px 16px; }
  .card-page .card-face h2 { font-size: 22px; }
  .card-page .card-face .mono { margin-top: 8px !important; }
  .card-page .qr-wrap {
    flex: 1 1 auto;
    min-height: 0;
    padding: 8px 12px 12px;
    align-content: center;
  }
  .card-page .qr-frame { padding: 6px; border-width: 4px; }
  .card-page .qrcode-text { margin-top: 6px; font-size: 15px; }
  .card-page .qr-wrap canvas {
    --qr: min(256px, calc(100vw - 108px), calc(100svh - 400px));
    width: max(148px, var(--qr));
    height: max(148px, var(--qr));
  }
}
