:root {
  --ink: #14231e; --muted: #66736e; --paper: #f5f3eb; --panel: #fffdf8;
  --green: #173f34; --mint: #c9f27b; --line: #dddcd3; --danger: #a53b2d;
  --shadow: 0 12px 30px rgba(28, 46, 39, .08); --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--paper); font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 90% 0, #e6f3cf 0, transparent 31rem), var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
.topbar { height: 64px; padding: max(12px, env(safe-area-inset-top)) 20px 8px; display: flex; align-items: center; justify-content: space-between; max-width: 820px; margin: auto; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: .03em; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: white; background: var(--green); }
.pill { padding: 7px 11px; border-radius: 999px; font-size: 12px; background: #e8e9e3; color: var(--muted); }
.pill.ok { color: var(--green); background: #dff0c8; }
main { max-width: 760px; margin: auto; padding: 10px 16px 112px; }
.view { display: none; animation: enter .24s ease; }
.view.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } }
.hero { padding: 30px 4px 22px; }
.eyebrow { margin: 0 0 8px; color: #537164; font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(38px, 8vw, 64px); letter-spacing: -.055em; line-height: 1.02; }
h2 { margin: 0; font-size: 29px; letter-spacing: -.035em; }
h3 { margin: 0 0 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 28px; }
.stats div { padding: 13px; border-left: 2px solid #cdd4c9; }
.stats strong, .stats span { display: block; }
.stats strong { font-size: 18px; }
.stats span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.panel { background: rgba(255,253,248,.94); border: 1px solid rgba(215,215,205,.85); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field.full, .full { grid-column: 1 / -1; }
label, legend { font-weight: 700; font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 13px 12px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: #70927f; box-shadow: 0 0 0 3px rgba(112,146,127,.14); }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.primary, .secondary { border: 0; border-radius: 15px; padding: 14px 17px; font-weight: 800; }
.primary { display: flex; justify-content: space-between; align-items: center; color: white; background: var(--green); }
.primary:hover { background: #0f3028; }
.secondary { background: #e9eadf; color: var(--ink); }
.wide { width: 100%; }
.button-link { display: block; margin-bottom: 9px; text-align: center; text-decoration: none; }
.results { display: grid; gap: 12px; margin-top: 18px; }
.result-card { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 19px; }
.result-card:first-child { border: 2px solid var(--green); box-shadow: var(--shadow); }
.result-card:first-child::before { content: "最佳選擇"; position: absolute; right: 0; top: 0; padding: 7px 12px; background: var(--mint); font-size: 11px; font-weight: 900; border-radius: 0 0 0 12px; }
.result-top { display: flex; justify-content: space-between; gap: 16px; padding-right: 56px; }
.result-title { font-size: 19px; font-weight: 850; }
.result-bank { color: var(--muted); font-size: 12px; }
.reward { text-align: right; white-space: nowrap; }
.reward strong { display: block; font-size: 24px; }
.reward span { color: var(--muted); font-size: 12px; }
.plan-action { margin: 15px 0; padding: 12px; border-radius: 13px; background: #edf6da; }
.plan-action strong, .plan-action span { display: block; }
.plan-action span { color: #52604f; font-size: 12px; margin-top: 3px; line-height: 1.45; }
.plan-state-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.plan-state-grid > div { padding: 9px 10px; border-radius: 10px; background: rgba(255,255,255,.62); }
.plan-state-grid strong { margin-top: 3px; font-size: 14px; }
.plan-result { padding-top: 2px; }
.plan-result.needs-switch { color: #7a3e20; }
.eligible-plans { margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(82,96,79,.2); }
.eligible-plans > span { font-weight: 750; }
.eligible-plans > div { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 6px; margin-top: 6px; }
.eligible-plans > div strong { font-size: 13px; }
.eligible-plans > div em { font-size: 10px; font-style: normal; color: white; background: var(--green); padding: 2px 5px; border-radius: 999px; }
.eligible-plans > div b { font-size: 11px; white-space: nowrap; }
.reason-list { margin: 12px 0 0; padding-left: 18px; color: #46554f; font-size: 13px; line-height: 1.65; }
.warning { color: #82502c; background: #fff1dd; border-radius: 10px; padding: 9px 11px; font-size: 12px; margin-top: 10px; }
.verification-banner, .verification-note { color: #6f321f; background: #ffe5d8; border: 1px solid #efb49b; border-radius: 10px; padding: 9px 11px; font-size: 12px; font-weight: 750; line-height: 1.45; margin-top: 10px; }
.confidence { margin-top: 12px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.confidence i { height: 5px; border-radius: 5px; background: #83a48f; display: inline-block; }
.scenario-list { display: flex; flex-wrap: wrap; gap: 7px; }
.scenario-chip { border: 1px solid #b9c8bd; border-radius: 999px; padding: 8px 11px; background: #f4f8ee; color: var(--ink); font-size: 12px; }
.scenario-chip.selected { border-color: var(--green); color: white; background: var(--green); }
.scenario-analysis { margin-top: 16px; padding: 12px 14px; border: 1px solid #cbd8c7; border-radius: 14px; background: #f0f7e6; color: #40514a; font-size: 13px; line-height: 1.55; }
.preference-list { display: grid; gap: 8px; margin-top: 10px; }
.preference-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.preference-row:first-child { border-top: 0; }
.preference-row div, .preference-row span { display: block; }
.preference-row span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.empty.compact { padding: 14px 8px; }
.product-choices { display: grid; gap: 8px; }
.card-search-box { position: relative; }
.card-search-box > span { position: absolute; left: 14px; top: 50%; transform: translateY(-53%); color: var(--muted); font-size: 24px; pointer-events: none; }
.card-search-box input { padding-left: 44px; padding-right: 38px; font-size: 16px; box-shadow: 0 5px 18px rgba(28,46,39,.06); }
.field-help { color: var(--muted); font-size: 11px; line-height: 1.45; }
.search-summary { color: var(--muted); font-size: 12px; font-weight: 700; }
.product-choice { display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 14px; padding: 11px; background: white; color: var(--ink); transition: border-color .15s ease, background .15s ease, transform .15s ease; }
.product-choice:hover, .product-choice.highlighted { border-color: #88a295; background: #f7faf3; transform: translateY(-1px); }
.product-choice.selected { border: 2px solid var(--green); background: #f2f8e9; }
.product-choice:disabled { cursor: default; opacity: .62; transform: none; }
.product-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--green); color: white; font-weight: 900; }
.product-choice span { display: block; }
.product-choice small { color: var(--muted); font-size: 11px; }
.product-state { white-space: nowrap; }
.product-state.owned { color: #52604f; background: #e5eddc; border-radius: 999px; padding: 5px 8px; }
.network-badges { display: flex !important; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.network-badge { display: inline-flex !important; width: fit-content; padding: 3px 6px; border: 1px solid #cfd5ce; border-radius: 6px; color: #40514a !important; background: #f6f7f2; font-size: 9px !important; font-weight: 850; letter-spacing: .02em; }
.variant-section { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: #fafaf5; }
.variant-section > div:first-child { display: grid; gap: 4px; }
.variant-choices { display: grid; gap: 8px; margin-top: 10px; }
.variant-choice { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: white; font-weight: 600; }
.variant-choice input { width: auto; }
.variant-choice small { display: block; color: var(--muted); font-weight: 500; margin-top: 2px; }
.variant-auto { padding: 10px; border-radius: 11px; background: #edf6da; }
.variant-manual { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.search-empty { display: grid; gap: 4px; padding: 24px 14px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; }
.search-empty span { font-size: 12px; }
.offer-meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 11px 0; }
.status-badge, .period-badge { border-radius: 999px; padding: 6px 9px; font-size: 11px; background: #edf0e9; color: #52604f; }
.status-active, .status-expiring { background: #dff0c8; color: #274b38; }
.status-expiring { background: #fff0bf; color: #725514; }
.offer-details { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.offer-details summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 700; }
.offer-evaluation { padding: 9px 0; border-bottom: 1px solid #ecece5; font-size: 12px; }
.offer-evaluation:last-child { border-bottom: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; padding: 28px 3px 20px; }
.icon-button, .close { border: 0; background: var(--green); color: white; width: 42px; height: 42px; border-radius: 50%; font-size: 22px; }
.close { background: #e9e9e1; color: var(--ink); }
.card-list, .transaction-list { display: grid; gap: 11px; margin-bottom: 14px; }
.wallet-card { border-radius: 19px; padding: 19px; min-height: 158px; color: white; background: linear-gradient(135deg, #173f34, #2f6654); box-shadow: var(--shadow); }
.wallet-card:nth-child(2n) { background: linear-gradient(135deg, #292e4b, #515d86); }
.wallet-card-head { display: flex; justify-content: space-between; }
.wallet-card h3 { margin-top: 25px; font-size: 21px; }
.wallet-card .meta { opacity: .72; font-size: 12px; }
.catalog-only-note { display: inline-flex; margin-top: 12px; padding: 7px 9px; border-radius: 9px; background: rgba(255,255,255,.13); font-size: 11px; }
.wallet-card footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.wallet-card footer select { flex: 1 1 150px; }
.wallet-card select { padding: 9px; background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); color: white; }
.wallet-card option { color: var(--ink); }
.tiny-button { border: 0; padding: 9px 11px; border-radius: 10px; background: rgba(255,255,255,.15); color: white; white-space: nowrap; }
.transaction { display: grid; grid-template-columns: 45px 1fr auto; align-items: center; gap: 11px; background: var(--panel); padding: 14px; border: 1px solid var(--line); border-radius: 16px; }
.transaction-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: #eef0e5; }
.transaction strong, .transaction span { display: block; }
.transaction .meta { color: var(--muted); font-size: 11px; margin-top: 3px; }
.transaction .money { text-align: right; }
.transaction .money small { color: #477158; }
.delete-link { border: 0; color: var(--danger); background: none; font-size: 11px; padding: 4px 0; }
.empty { text-align: center; border: 1px dashed #c9cbc1; border-radius: 18px; padding: 38px 20px; color: var(--muted); }
.setting-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid #ecece5; }
.setting-row:last-of-type { border: 0; }
.muted, .about p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.warning-panel { background: #fff6e7; }
.warning-panel p { margin: 0; color: #674d32; font-size: 13px; line-height: 1.6; }
.admin-panel summary { cursor: pointer; font-weight: 800; }
.admin-panel label { display: block; margin: 13px 0 6px; }
.bottom-nav { position: fixed; z-index: 20; bottom: 12px; left: 50%; transform: translateX(-50%); width: min(calc(100% - 24px), 520px); display: grid; grid-template-columns: repeat(4,1fr); padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); border: 1px solid rgba(255,255,255,.5); border-radius: 22px; background: rgba(20,43,35,.94); backdrop-filter: blur(18px); box-shadow: 0 10px 35px rgba(10,30,24,.23); }
.bottom-nav button { display: flex; flex-direction: column; gap: 2px; align-items: center; border: 0; border-radius: 14px; padding: 8px; color: #b9c5c0; background: transparent; font-size: 11px; }
.bottom-nav button span { font-size: 17px; }
.bottom-nav button.active { color: #163d32; background: var(--mint); font-weight: 800; }
dialog { width: min(560px, calc(100% - 20px)); max-height: 88vh; padding: 0; border: 0; border-radius: 24px; background: var(--panel); box-shadow: 0 22px 70px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(10,27,21,.55); backdrop-filter: blur(4px); }
.dialog-body { padding: 21px; display: grid; gap: 14px; overflow-y: auto; max-height: 88vh; }
.dialog-title { display: flex; align-items: center; justify-content: space-between; }
.auth-fields { display: grid; gap: 12px; }
.inline-note { padding: 10px; background: #fff2dc; border-radius: 11px; color: #715136; font-size: 12px; }
.token-value { overflow-wrap: anywhere; user-select: all; }
.setup-detail { display: grid; gap: 7px; margin-top: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: #fafaf5; }
.setup-detail span { color: var(--muted); font-size: 11px; font-weight: 700; }
.setup-detail code { overflow-wrap: anywhere; user-select: all; font-size: 12px; }
.tiny-copy { justify-self: start; border: 0; border-radius: 9px; padding: 7px 9px; background: #e4eadf; color: var(--ink); font-weight: 750; font-size: 11px; }
fieldset { border: 1px solid var(--line); border-radius: 13px; padding: 12px; }
.checkbox-list { display: grid; gap: 9px; margin-top: 8px; }
.checkbox-list label { display: flex; gap: 8px; font-weight: 500; }
.checkbox-list input { width: auto; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 100px; transform: translate(-50%, 20px); width: min(90%, 480px); padding: 13px 16px; border-radius: 14px; color: white; background: #162b24; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .22s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: #822f28; }
.loading { opacity: .65; pointer-events: none; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } .field.full, .full { grid-column: auto; } main { padding-inline: 12px; } .panel { padding: 15px; } .product-choice { grid-template-columns: 38px 1fr; } .product-choice > .product-state { grid-column: 2; justify-self: start; } .variant-manual { grid-template-columns: 1fr; } }
@media (min-width: 760px) { .card-list { grid-template-columns: 1fr 1fr; } .topbar { padding-top: 15px; } }
