:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --text: #182621;
  --muted: #66736e;
  --line: #d9e1dd;
  --accent: #08766c;
  --accent-strong: #075d56;
  --accent-soft: #e5f3f0;
  --highlight: #f4c84a;
  --danger: #b42318;
  --success: #18794e;
  --shadow: 0 14px 34px rgba(24, 38, 33, 0.09);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", Arial, sans-serif; font-size: 15px; line-height: 1.5; letter-spacing: 0; }
body.modal-open { overflow: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }
.is-hidden { display: none !important; }
.content-width { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: #edf2ef; }
.auth-shell { width: min(470px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.login-panel { width: min(430px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.auth-shell .login-panel { width: 100%; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
.auth-mode-switch { display: grid; grid-template-columns: 1fr 1fr; margin-top: 24px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #eef2f0; }
.auth-mode-button { min-height: 40px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-weight: 800; }
.auth-mode-button.is-active { color: var(--accent-strong); background: #fff; box-shadow: 0 2px 8px rgba(24, 38, 33, 0.08); }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; background: var(--highlight); color: #17231f; font-size: 20px; font-weight: 900; }
.brand-lockup strong, .brand-lockup span { display: block; }
.brand-lockup strong { font-size: 17px; }
.brand-lockup div > span { color: var(--muted); font-size: 12px; }
.login-panel header { margin: 30px 0 24px; }
.login-panel h1 { margin: 0; font-size: 27px; }
.login-panel header p { margin: 6px 0 0; color: var(--muted); }
label { display: grid; gap: 7px; margin-bottom: 16px; color: var(--muted); font-size: 14px; font-weight: 700; }
label small { color: var(--muted); font-size: 12px; font-weight: 500; }
input { width: 100%; min-width: 0; min-height: 48px; border: 1px solid var(--line); border-radius: 8px; padding: 0 14px; color: var(--text); background: #fff; font-size: 16px; }
input:focus { outline: 3px solid rgba(8, 118, 108, 0.13); border-color: var(--accent); }
.primary-button, .secondary-button { min-height: 44px; border-radius: 8px; padding: 0 16px; font-weight: 800; }
.primary-button { border: 1px solid var(--accent); color: #fff; background: var(--accent); }
.primary-button:hover { background: var(--accent-strong); }
.primary-button:disabled { border-color: #a9b5b0; background: #a9b5b0; cursor: not-allowed; }
.secondary-button { border: 1px solid var(--line); color: var(--text); background: #fff; }
.secondary-button:hover { border-color: #aab8b2; background: #f8faf9; }
.login-panel .primary-button { width: 100%; }
.message { min-height: 22px; margin: 0 0 12px; color: var(--danger); font-weight: 700; }

.topbar { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.96); }
.topbar-inner { width: min(1180px, calc(100% - 40px)); min-height: 72px; margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.compact .brand-mark { width: 38px; height: 38px; font-size: 17px; }
.account-actions { display: flex; align-items: center; gap: 12px; }
.notification-shortcut { min-width: 82px; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: #fff; font-weight: 800; }
.notification-shortcut:hover { border-color: #aab8b2; background: #f8faf9; }
.notification-badge, .tab-badge { min-width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 10px; padding: 0 6px; color: #fff; background: var(--danger); font-size: 11px; line-height: 1; }
.tab-badge { margin-left: 5px; vertical-align: middle; }
.points-chip { min-width: 126px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid #ead17b; border-radius: 8px; background: #fff8dc; }
.points-chip span { color: #75601e; font-size: 12px; font-weight: 700; }
.points-chip strong { font-size: 19px; }

.account-band { border-bottom: 1px solid var(--line); background: #fff; }
.account-grid { min-height: 146px; display: grid; grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(140px, 1fr)); align-items: center; gap: 22px; }
.account-name span, .account-stat span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.account-name h1 { margin: 4px 0 0; font-size: 28px; }
.account-stat { min-height: 62px; padding-left: 22px; border-left: 1px solid var(--line); }
.account-stat strong { display: block; margin-top: 7px; font-size: 18px; overflow-wrap: anywhere; }
.account-stat.emphasis strong { color: var(--accent); font-size: 25px; }

.portal-tabs { position: sticky; top: 72px; z-index: 15; border-bottom: 1px solid var(--line); background: #fff; }
.tab-list { display: flex; gap: 4px; overflow-x: auto; }
.tab-button { flex: 0 0 auto; min-height: 52px; border: 0; border-bottom: 3px solid transparent; padding: 0 18px; color: var(--muted); background: transparent; font-weight: 800; }
.tab-button.is-active { border-bottom-color: var(--accent); color: var(--accent); }
.portal-content { padding-block: 34px 70px; }
.section-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-header h2 { margin: 0; font-size: 24px; }
.section-header p { margin: 4px 0 0; color: var(--muted); }
.search-form { width: min(390px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.reward-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.reward-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 22px rgba(24, 38, 33, 0.05); }
.reward-card img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: #eef2f0; }
.reward-card-body { display: grid; gap: 12px; padding: 18px; }
.reward-meta { min-height: 22px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 800; }
.reward-type { padding: 3px 7px; border-radius: 4px; color: #4c4330; background: #fff4ca; }
.reward-card h3 { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.reward-description { min-height: 45px; margin: 0; color: var(--muted); display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.reward-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.reward-points span { display: block; color: var(--muted); font-size: 12px; }
.reward-points strong { color: var(--accent); font-size: 21px; }
.reward-card .primary-button { min-width: 94px; }
.availability { min-height: 21px; color: var(--danger); font-size: 13px; font-weight: 700; }
.availability.is-ok { color: var(--success); }

.record-list { display: grid; gap: 10px; }
.notification-list { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.notification-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px; min-height: 104px; padding: 18px 20px; }
.notification-row + .notification-row { border-top: 1px solid var(--line); }
.notification-row.is-unread { background: var(--accent-soft); }
.notification-copy { min-width: 0; }
.notification-copy header { display: flex; align-items: center; gap: 9px; }
.notification-copy h3 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.notification-copy p { margin: 6px 0; color: #42504b; overflow-wrap: anywhere; }
.notification-copy time { color: var(--muted); font-size: 12px; }
.unread-dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--accent); }
.notification-read-button { min-width: 88px; }
.record-row { display: grid; grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(120px, 0.8fr)); align-items: center; gap: 16px; min-height: 94px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.record-main { min-width: 0; }
.record-main strong { display: block; font-size: 16px; overflow-wrap: anywhere; }
.record-main span, .record-cell span { display: block; color: var(--muted); font-size: 12px; }
.record-cell strong { display: block; margin-top: 4px; }
.status-pill { display: inline-flex !important; width: fit-content; padding: 4px 8px; border-radius: 4px; color: #46544f !important; background: #edf1ef; font-size: 13px !important; }
.status-pill.pending, .status-pill.preparing { color: #725c17 !important; background: #fff4c9; }
.status-pill.approved, .status-pill.not_required, .status-pill.shipped, .status-pill.delivered { color: #126341 !important; background: #e5f5ec; }
.status-pill.rejected, .status-pill.cancelled { color: #96261f !important; background: #fdeceb; }
.amount-positive { color: var(--success); }
.amount-negative { color: var(--danger); }
.empty-state { padding: 48px 20px; border: 1px dashed #b9c6c0; border-radius: 8px; color: var(--muted); background: #fff; text-align: center; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 24px; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 26, 22, 0.64); }
.modal-panel { position: relative; z-index: 1; width: min(760px, 94vw); max-height: 90vh; overflow: auto; display: grid; grid-template-columns: minmax(260px, 0.9fr) minmax(330px, 1.1fr); border-radius: 8px; background: #fff; box-shadow: 0 28px 80px rgba(15, 26, 22, 0.28); }
.modal-panel > img { width: 100%; height: 100%; min-height: 430px; object-fit: cover; background: #eef2f0; }
.modal-content { padding: 34px; }
.close-button { position: absolute; top: 12px; right: 12px; z-index: 2; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--text); background: #fff; font-size: 25px; line-height: 1; }
.eyebrow { color: var(--accent); font-size: 13px; font-weight: 800; }
.modal-content h2 { margin: 7px 0 12px; font-size: 25px; }
.modal-content > p { color: var(--muted); }
.redeem-facts { display: grid; gap: 0; margin: 24px 0; border-block: 1px solid var(--line); }
.redeem-facts div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; }
.redeem-facts div + div { border-top: 1px solid var(--line); }
.redeem-facts dt { color: var(--muted); }
.redeem-facts dd { margin: 0; font-weight: 800; text-align: right; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: min(380px, calc(100% - 40px)); padding: 13px 16px; border-radius: 8px; color: #fff; background: #173a32; box-shadow: var(--shadow); font-weight: 700; }

@media (max-width: 900px) {
  .reward-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-grid { grid-template-columns: repeat(3, 1fr); padding-block: 24px; }
  .account-name { grid-column: 1 / -1; }
  .account-stat:first-of-type { padding-left: 0; border-left: 0; }
  .record-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .content-width, .topbar-inner { width: min(100% - 24px, 1180px); }
  .login-screen { padding: 14px; }
  .login-panel { padding: 24px 20px; }
  .auth-shell { padding: 24px 20px; }
  .auth-shell .login-panel { padding: 0; }
  .topbar-inner { min-height: 66px; }
  .compact div { display: none; }
  .points-chip { min-width: 112px; }
  .notification-shortcut { min-width: 64px; padding-inline: 10px; }
  .account-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
  .account-name { grid-column: 1 / -1; }
  .account-stat { padding-left: 0; border-left: 0; }
  .portal-tabs { top: 66px; }
  .tab-list { width: 100%; }
  .tab-button { flex: 1 0 auto; }
  .portal-content { padding-top: 24px; }
  .section-header { align-items: stretch; flex-direction: column; }
  .search-form { width: 100%; }
  .reward-grid { grid-template-columns: 1fr; }
  .reward-card img { aspect-ratio: 16 / 10; }
  .record-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .notification-row { grid-template-columns: 1fr; gap: 12px; padding: 16px; }
  .notification-read-button { width: 100%; }
  .record-main { grid-column: 1 / -1; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .modal { padding: 12px; }
  .modal-panel { grid-template-columns: 1fr; }
  .modal-panel > img { height: 210px; min-height: 210px; }
  .modal-content { padding: 24px 20px; }
  .modal-actions .primary-button, .modal-actions .secondary-button { flex: 1; }
}
