:root {
    color-scheme: dark;
    --bg: #071021;
    --card: #0d1a2d;
    --text: #e6eef6;
    --muted: #9aa6b2;
    --line: rgba(255, 255, 255, .1);
    --brand: #ff7a59;
    --brand-dark: #ff9b7f;
    --card-shadow: rgba(0, 0, 0, .28);
    --table-head: rgba(255, 255, 255, .035);
    --soft-bg: rgba(255, 255, 255, .045);
    --notice-bg: rgba(255, 122, 89, .12);
    --notice-text: #ffb09b;
    --ok: #6ee7a0;
    --ok-bg: rgba(34, 197, 94, .13);
    --pending: #f7c65d;
    --pending-bg: rgba(245, 158, 11, .13);
}

html.light-theme {
    color-scheme: light;
    --bg: #f4f6fb;
    --card: #fff;
    --text: #202538;
    --muted: #667085;
    --line: #e4e7ec;
    --brand: #e85d3f;
    --brand-dark: #c9472e;
    --card-shadow: rgba(16, 24, 40, .06);
    --table-head: #fcfcfd;
    --soft-bg: #f8f9fa;
    --notice-bg: #fff6ed;
    --notice-text: #8b3e1f;
    --ok: #157f3c;
    --ok-bg: #ecfdf3;
    --pending: #9a6700;
    --pending-bg: #fffaeb;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { width: min(1080px, calc(100% - 32px)); margin: 0 auto; padding: 80px 0 56px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.brand { color: var(--text); font-size: 20px; font-weight: 800; }
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 10px 30px var(--card-shadow);
}
.login-card { max-width: 560px; margin: 8vh auto 0; padding: 36px; text-align: center; }
h1 { margin: 0 0 12px; font-size: clamp(26px, 4vw, 36px); }
h2 { margin: 0 0 8px; font-size: 20px; }
.lead, .muted { color: var(--muted); line-height: 1.7; }
.google-button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid #c7c7c7;
    border-radius: 9px;
    font-weight: 700;
    cursor: pointer;
}
.google-button { background: #fff; color: #202124; }
.button { background: var(--soft-bg); color: var(--text); border-color: var(--line); }
.google-button { width: 100%; margin: 18px 0 8px; }
.google-button:hover { background: #f8f9fa; text-decoration: none; }
.button:hover { border-color: var(--brand); text-decoration: none; }
.google-mark { color: #4285f4; font-size: 19px; }
.notice { margin: 18px 0; padding: 12px 14px; border-radius: 8px; background: var(--notice-bg); color: var(--notice-text); text-align: left; }
.profile { display: flex; align-items: center; gap: 14px; }
.profile-name { font-weight: 800; }
.profile-email { color: var(--muted); font-size: 14px; }
.logout-form { margin: 0; }
.logout-button { border: 0; background: transparent; color: var(--brand-dark); padding: 8px; cursor: pointer; }
.environment-badge { display: inline-block; margin-left: 6px; padding: 3px 8px; border-radius: 99px; font-size: 12px; vertical-align: middle; }
.environment-badge.prod { color: var(--ok); background: var(--ok-bg); }
.environment-badge.stage { color: var(--pending); background: var(--pending-bg); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 0 0 20px; }
.stat { padding: 20px; }
.stat-label { color: var(--muted); font-size: 14px; }
.stat-value { margin-top: 6px; font-size: 28px; font-weight: 800; }
.history-card { overflow: hidden; }
.history-header { padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; font-weight: 700; background: var(--table-head); }
.amount { white-space: nowrap; font-weight: 800; }
.status { display: inline-block; padding: 3px 8px; border-radius: 99px; font-size: 13px; font-weight: 700; }
.status-paid { color: var(--ok); background: var(--ok-bg); }
.status-pending { color: var(--pending); background: var(--pending-bg); }
.message { max-width: 360px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { padding: 42px 24px; text-align: center; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 20px; }
.pagination a { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.footnote { margin-top: 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }

@media (max-width: 700px) {
    .shell { width: min(100% - 20px, 1080px); padding-top: 64px; }
    .topbar { align-items: flex-start; }
    .stats { grid-template-columns: 1fr; gap: 10px; }
    .stat { padding: 16px; }
    .login-card { padding: 26px 20px; }
    th, td { padding: 12px; }
}
