/* ===== FlexPay style ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand: #4f46e5;
  --brand2: #7c3aed;
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1e1e2e;
  --muted: #6b7280;
  --green: #059669;
  --red: #dc2626;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(79,70,229,.10), 0 2px 6px rgba(0,0,0,.06);
}
html, body { height: 100%; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.view { max-width: 480px; margin: 0 auto; padding: 16px; min-height: 100vh; }
.hidden { display: none !important; }

/* ===== ロゴ ===== */
.logo {
  font-size: 40px; font-weight: 800; letter-spacing: -1px;
  background: linear-gradient(120deg, var(--brand), var(--brand2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-align: center;
}
.logo.small { font-size: 24px; }
.tagline { text-align: center; color: var(--muted); margin: 6px 0 20px; }

/* ===== 認証 ===== */
#view-auth { display: flex; align-items: center; justify-content: center; }
.auth-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 22px; width: 100%;
}
.tabs { display: flex; gap: 8px; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 10px; border: none; border-radius: 10px; background: transparent;
  font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--card); color: var(--brand); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label, .amount-label, .note-label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
input {
  font-size: 16px; padding: 12px 14px; border: 2px solid #e5e7eb; border-radius: 12px;
  outline: none; background: #fff; color: var(--text); width: 100%;
}
input:focus { border-color: var(--brand); }

.q-type { font-size: 14px; font-weight: 700; }
.type-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 8px; border: 2px solid #e5e7eb; border-radius: 14px; background: #fff;
  cursor: pointer; transition: .15s;
}
.type-card.selected { border-color: var(--brand); background: #eef2ff; box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.tc-icon { font-size: 30px; }
.tc-name { font-weight: 700; font-size: 15px; }
.tc-desc { font-size: 12px; color: var(--muted); }
.bonus-note { font-size: 13px; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px; border-radius: 10px; text-align: center; }
.auth-error { color: var(--red); font-size: 13px; margin-top: 12px; text-align: center; min-height: 18px; }

/* ===== ボタン ===== */
.btn {
  border: none; border-radius: 12px; padding: 13px; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: .15s;
}
.btn-primary { background: linear-gradient(120deg, var(--brand), var(--brand2)); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.35); }
.btn-primary:active { transform: scale(.97); }
.btn-ghost { background: transparent; color: var(--muted); font-size: 14px; padding: 8px 10px; }
.btn-green { background: linear-gradient(120deg, #059669, #10b981); color: #fff; box-shadow: 0 4px 14px rgba(5,150,105,.35); }

/* ===== ヘッダー ===== */
.app-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.app-header h2 { font-size: 18px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.user-badge { font-size: 12px; font-weight: 700; background: #eef2ff; color: var(--brand); padding: 6px 10px; border-radius: 999px; }

/* ===== 残高カード ===== */
.balance-card {
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.balance-card::after {
  content: "💳"; position: absolute; right: 12px; top: 8px; font-size: 64px; opacity: .18;
}
.balance-label { font-size: 13px; opacity: .85; }
.balance-value { font-size: 44px; font-weight: 800; line-height: 1.15; }
.balance-value .unit { font-size: 20px; margin-left: 6px; opacity: .9; }
.balance-pid { font-size: 13px; opacity: .85; margin-top: 4px; }

/* ===== メニュー ===== */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.menu-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--card); border: none; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 10px; font-size: 14px; font-weight: 700; cursor: pointer; color: var(--text);
}
.menu-btn:active { transform: scale(.96); }
.menu-btn.primary {
  grid-column: 1 / -1; flex-direction: row; justify-content: center; font-size: 17px;
  background: linear-gradient(120deg, var(--brand), var(--brand2)); color: #fff;
}
.mb-icon { font-size: 30px; }

/* ===== 取引リスト ===== */
.recent h3 { font-size: 15px; margin-bottom: 8px; color: var(--muted); }
.tx-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.tx-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--card); border-radius: 12px; padding: 12px 14px; box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.tx-main { min-width: 0; }
.tx-counter { font-weight: 700; font-size: 14px; }
.tx-meta { font-size: 11px; color: var(--muted); }
.tx-amount { font-weight: 800; font-size: 16px; white-space: nowrap; }
.tx-amount.in { color: var(--green); }
.tx-amount.out { color: var(--red); }
.tx-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 20px; background: transparent !important; box-shadow: none !important; }

/* ===== 独自QR ===== */
.qr-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 20px; text-align: center; }
.qr-pid { font-weight: 800; font-size: 18px; margin-bottom: 14px; word-break: break-all; }
.qr-box { display: flex; justify-content: center; margin-bottom: 14px; }
.qr-box img { width: 230px; height: 230px; image-rendering: pixelated; }
.qr-code-label { font-size: 12px; color: var(--muted); }
.qr-code { font-size: 34px; font-weight: 800; letter-spacing: 6px; color: var(--brand); }
.qr-timer-bar { height: 6px; background: #e5e7eb; border-radius: 3px; margin: 16px 0 10px; overflow: hidden; }
.qr-timer-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand2)); width: 100%; transition: width 1s linear; }
.qr-hint { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ===== スキャン ===== */
.scan-area { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.video-wrap { position: relative; border-radius: 12px; overflow: hidden; background: #111; aspect-ratio: 1; }
#scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame {
  position: absolute; inset: 12%; border: 3px solid rgba(255,255,255,.9); border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.25); pointer-events: none;
}
.scan-status { text-align: center; font-size: 13px; color: var(--muted); padding: 10px 0 2px; }
.scan-manual { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.scan-manual p { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; font-size: 20px; letter-spacing: 4px; text-align: center; }
.inline-form .btn { padding: 10px 18px; }

/* ===== お会計 ===== */
.store-note { font-size: 12px; color: var(--muted); text-align: center; margin: -6px 0 14px; }
.checkout-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 18px; display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.co-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.co-amount { font-size: 52px; font-weight: 800; color: var(--green); line-height: 1.1; }
.co-amount .unit { font-size: 22px; margin-left: 6px; color: var(--muted); }
.co-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.co-qbtn {
  padding: 14px 4px; border: 2px solid #e5e7eb; border-radius: 12px; background: #fff;
  font-size: 17px; font-weight: 800; color: var(--text); cursor: pointer;
}
.co-qbtn:active { transform: scale(.94); background: #eef2ff; border-color: var(--brand); }
.co-qbtn.clear { color: var(--red); border-color: #fecaca; }
.btn-big { font-size: 18px; padding: 16px; }
.co-code-row { margin-top: 4px; }

/* ===== 移転バナー ===== */
.migrate {
  background: #fef3c7; border: 2px solid #f59e0b; border-radius: 12px;
  padding: 12px; font-size: 13px; line-height: 1.6; margin-bottom: 14px; color: #92400e;
}
.migrate-row { margin-top: 8px; }
.migrate-row input { font-size: 14px; letter-spacing: 0; text-align: left; }
.migrate-note { font-size: 11px; color: #a16207; }

/* ===== QRダウンロード ===== */
#btn-qr-download { margin: 14px 0 10px; width: 100%; }
.qr-hint { font-size: 12px; color: var(--muted); line-height: 1.7; margin-top: 6px; }

/* ===== モーダル ===== */
.modal {
  position: fixed; inset: 0; background: rgba(15,15,40,.55); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-card {
  background: var(--card); width: 100%; max-width: 480px; border-radius: 22px 22px 0 0;
  padding: 24px 20px 30px; display: flex; flex-direction: column; gap: 14px;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(60px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.modal-target-label { font-size: 13px; color: var(--muted); }
.modal-target { font-size: 20px; font-weight: 800; word-break: break-all; }
#modal-amount { font-size: 28px; font-weight: 800; text-align: center; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }

/* ===== トースト ===== */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #1e1e2e; color: #fff; padding: 14px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 700; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  max-width: 90vw; text-align: center;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
