:root {
  --page: #dfe5ea;
  --surface: #fff;
  --muted-surface: #f1f4f6;
  --sunk-surface: #e7ecf0;
  --text: #0f1720;
  --muted: #374151;
  --text-muted: var(--muted);
  --subtle: #4b5563;
  --primary: #0b645d;
  --primary-hover: #084f4a;
  --primary-soft: #ccfbf1;
  --border: #cbd5df;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --sidebar: 240px;
  /* 高度：邊界與陰影同一組宣告，不再另外疊 1px border */
  --ring: 0 0 0 1px rgb(17 32 43 / .09);
  --ring-strong: 0 0 0 1px rgb(17 32 43 / .16);
  --e1: var(--ring), 0 1px 2px rgb(17 32 43 / .05), 0 4px 10px -5px rgb(17 32 43 / .09);
  --e2: var(--ring), 0 2px 4px rgb(17 32 43 / .06), 0 10px 22px -8px rgb(17 32 43 / .14);
  --e3: var(--ring), 0 4px 8px rgb(17 32 43 / .07), 0 22px 44px -14px rgb(17 32 43 / .22);
  --inset: inset 0 0 0 1px rgb(17 32 43 / .13), inset 0 1px 2px rgb(17 32 43 / .05);
  --r-sm: 8px; --r-md: 12px; --r-lg: 14px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; color: var(--text); background: var(--page); font-family: "Noto Sans TC", "PingFang TC", system-ui, -apple-system, sans-serif; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.65rem; font-weight: 700; }
h2 { margin-bottom: .25rem; font-size: 1.15rem; font-weight: 650; }
h3 { margin-top: 1.5rem; font-size: 1rem; font-weight: 650; }
small { color: var(--subtle); }
.numeric { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.up { color: var(--success) !important; }
.eyebrow { margin-bottom: .25rem; color: var(--primary); font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }

.demo-banner { position: fixed; inset: 0 0 auto; z-index: 1100; height: 28px; display: grid; place-items: center; color: #fff; background: #314250; font-size: .72rem; letter-spacing: .04em; }
.app-layout { min-height: 100vh; padding-top: 28px; }
.sidebar { position: fixed; inset: 28px auto 0 0; z-index: 1030; width: var(--sidebar); min-height: 0; display: flex; flex-direction: column; padding: 20px 12px calc(14px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; background: var(--surface); box-shadow: 1px 0 0 rgb(17 32 43 / .07), 6px 0 18px -12px rgb(17 32 43 / .22); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.brand div:last-child { display: grid; }
.brand small { font-size: .62rem; letter-spacing: .09em; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 auto; object-fit: contain; }
.brand-mark.large { width: 56px; height: 56px; }
.sidebar nav { min-height: 0; display: grid; gap: 4px; overflow-y: auto; overscroll-behavior: contain; }
.nav-group-label { margin: 16px 12px 4px; color: var(--subtle); font-size: .7rem; font-weight: 800; letter-spacing: .1em; }
.nav-link { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px; color: var(--muted); border-radius: 6px; font-weight: 600; }
.nav-link span:first-child { width: 20px; color: var(--subtle); text-align: center; }
.nav-icon { width: 20px; height: 20px; display: block; }
.nav-link:hover { color: var(--primary); background: var(--muted-surface); }
.nav-link.active { color: var(--primary); background: var(--surface); box-shadow: var(--ring), 0 1px 2px rgb(17 32 43 / .07); }
.sidebar-foot { display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px; margin-top: auto; padding: 14px 6px 0; border-top: 1px solid var(--border); }
.sidebar-foot div { min-width: 0; display: grid; }
.sidebar-foot strong { overflow: hidden; font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot small { font-size: .72rem; }
.logout-form { margin: 0; }
.logout-link { min-height: 44px; display: grid; place-items: center; padding: 0 8px; color: var(--muted); background: transparent; border: 0; border-radius: 7px; font-size: .78rem; text-decoration: none; cursor: pointer; }
.logout-link:hover { color: var(--primary); background: var(--muted-surface); }
.logout-link:focus-visible { outline: 3px solid rgb(15 118 110 / .3); outline-offset: 2px; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted); background: var(--surface); border-radius: 50%; font-weight: 700; box-shadow: var(--ring), 0 1px 2px rgb(17 32 43 / .07); }
.avatar.large { width: 48px; height: 48px; font-size: 1.15rem; }
.main-content { max-width: 1440px; min-height: 100vh; margin-left: var(--sidebar); padding: 32px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.role-chip { padding: 7px 10px; color: var(--muted); background: var(--surface); border-radius: 999px; font-size: .78rem; box-shadow: var(--ring); }
.mobile-topbar, .nav-backdrop { display: none; }

.surface { padding: 20px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--e1); }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head p { margin-bottom: 0; color: var(--subtle); font-size: .82rem; }
.summary-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.summary-row > div:first-child { display: grid; }
.summary-row span, .kpi-card span { color: var(--subtle); font-size: .78rem; }
.summary-row small { font-size: .7rem; }
.segmented { display: inline-flex; padding: 3px; background: var(--sunk-surface); border-radius: var(--r-md); box-shadow: var(--inset); }
.segmented button, .segmented a { min-height: 34px; display: inline-flex; align-items: center; padding: 0 12px; color: var(--muted); background: transparent; border: 0; border-radius: 5px; }
.segmented button.active, .segmented a.active { color: var(--text); background: var(--surface); box-shadow: 0 0 0 1px rgb(17 32 43 / .1), 0 1px 2px rgb(17 32 43 / .14); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-card { min-width: 0; display: grid; padding: 18px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--e2); }
.kpi-card strong { margin: 7px 0 4px; overflow: hidden; font-size: 1.65rem; font-variant-numeric: tabular-nums; text-overflow: ellipsis; }
.kpi-card small { font-size: .72rem; }
.balance-editor { align-content: start; }
.balance-editor-trigger { min-width: 0; min-height: 44px; display: grid; justify-items: start; padding: 0; color: inherit; background: transparent; border: 0; text-align: start; cursor: pointer; }
.balance-editor-trigger[hidden] { display: none; }
.balance-editor-trigger strong { max-width: 100%; }
.balance-editor-trigger small { color: var(--primary); font-weight: 700; }
.balance-editor-trigger:focus-visible { outline: 3px solid rgb(15 118 110 / .3); outline-offset: 2px; border-radius: 8px; }
.balance-editor-form { min-width: 0; display: grid; gap: 8px; margin-block-start: 9px; }
.balance-editor-form[hidden] { display: none; }
.balance-editor-form input { width: 100%; min-width: 0; min-height: 44px; font-size: 1rem; font-variant-numeric: tabular-nums; }
.balance-editor-form small { line-height: 1.45; }
.balance-editor-form .button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.balance-editor-form button { min-width: 0; min-height: 44px; padding-inline: 10px; }
.balance-editor-status { min-height: 1.4em; margin: 7px 0 0; color: var(--success); font-size: .78rem; overflow-wrap: anywhere; }
.balance-editor-status.is-error { color: var(--danger); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); gap: 16px; }
.task-row { min-height: 62px; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; padding: 10px 0; color: var(--text); border-top: 1px solid var(--border); }
.task-row span:nth-child(2) { display: grid; }
.task-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 7px; font-style: normal; font-weight: 700; }
.task-icon.warning { color: var(--warning); background: var(--warning-soft); }
.task-icon.danger { color: var(--danger); background: var(--danger-soft); }
.task-icon.neutral { color: var(--muted); background: var(--muted-surface); }
.service-row { min-height: 43px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); }
.service-row span { display: flex; align-items: center; gap: 8px; }
.service-row strong { font-size: .78rem; font-weight: 600; }
.service-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: var(--subtle); }
.service-dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

.page-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.search { min-height: 44px; flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface); border-radius: var(--r-sm); box-shadow: var(--inset); }
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(15 118 110 / .13); }
.search input { width: 100%; border: 0; outline: 0; background: transparent; }
.btn { min-height: 44px; border-radius: 8px; font-weight: 600; }
.btn-sm { min-height: 34px; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-hover); --bs-btn-hover-border-color: var(--primary-hover); }
.btn-outline-secondary { --bs-btn-color: var(--muted); --bs-btn-border-color: var(--border); --bs-btn-hover-color: var(--text); --bs-btn-hover-bg: var(--muted-surface); --bs-btn-hover-border-color: var(--border); }
.table-scroll { max-width: 100%; overflow-x: auto; }
.desktop-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; color: var(--subtle); background: var(--muted-surface); font-size: .72rem; font-weight: 600; white-space: nowrap; }
td { height: 52px; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
tbody tr:hover { background: #f9fbfb; }
.link-button { display: grid; padding: 0; color: var(--text); text-align: left; background: none; border: 0; }
.link-button:hover strong { color: var(--primary); }
.link-button small { font-size: .7rem; }
.more-button, .icon-button { min-width: 38px; min-height: 38px; display: grid; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 7px; }
.more-button { padding: 0 8px; color: var(--primary); font-size: .78rem; font-weight: 650; }
.icon-button { font-size: 1.4rem; }
.more-button:hover, .icon-button:hover { background: var(--muted-surface); }
.mobile-data-list { display: none; }
.status { display: inline-flex; width: max-content; align-items: center; padding: 3px 8px; border-radius: 99px; font-size: .7rem; font-weight: 650; white-space: nowrap; }
.status-success { color: var(--success); background: var(--success-soft); }
.status-warning { color: var(--warning); background: var(--warning-soft); }
.status-danger { color: var(--danger); background: var(--danger-soft); }
.status-neutral { color: var(--muted); background: var(--muted-surface); }
.empty-state { min-height: 300px; display: grid; place-items: center; align-content: center; padding: 30px; text-align: center; }
.empty-state > div { font-size: 2rem; color: var(--subtle); }
.empty-state p { margin: 4px 0 14px; color: var(--subtle); }
.compact-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.compact-actions form { margin: 0; }
.attempt-list { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: .78rem; }
.attempt-list li + li { margin-top: 6px; }
.data-card dl { margin: 8px 0; }
.data-card dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.data-card dt { color: var(--subtle); font-size: .75rem; font-weight: 500; }
.data-card dd { margin: 0; text-align: right; }

.tabs { display: flex; gap: 20px; margin: -4px 0 20px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { min-height: 44px; display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs b { display: grid; min-width: 18px; height: 18px; place-items: center; color: #fff; background: var(--warning); border-radius: 99px; font-size: .65rem; }
.lock { padding: 1px 5px; color: var(--primary); background: var(--primary-soft); border-radius: 4px; font-size: .62rem; }
.report-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.report-grid article { display: grid; padding: 16px; background: var(--muted-surface); border-radius: var(--r-sm); }
.report-grid strong { font-variant-numeric: tabular-nums; }
.report-grid span, .report-grid small { color: var(--subtle); font-size: .72rem; }
.report-grid strong { margin: 5px 0; font-size: 1.3rem; }
.metric-positive { color: var(--success); }
.metric-negative { color: var(--danger); }
.callout { padding: 14px; background: #f0fdfa; border-left: 3px solid var(--primary); border-radius: 0 7px 7px 0; }
.callout p { margin: 3px 0 0; color: var(--muted); }
.settings-layout { display: grid; grid-template-columns: 1fr 260px; gap: 24px; }
.form-grid, .weight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.surface details pre { max-width: min(72vw, 720px); overflow: auto; padding: 12px; border-radius: 8px; background: var(--page); white-space: pre-wrap; overflow-wrap: anywhere; }
.weight-grid { margin-top: 8px; }
form label { display: grid; gap: 5px; color: var(--muted); font-size: .78rem; font-weight: 600; }
input, select, textarea { width: 100%; min-height: 42px; padding: 8px 10px; color: var(--text); background: var(--surface); border: 0; border-radius: var(--r-sm); box-shadow: var(--inset); }
input:hover, select:hover, textarea:hover { box-shadow: inset 0 0 0 1px rgb(17 32 43 / .22), inset 0 1px 2px rgb(17 32 43 / .06); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 3px solid rgb(15 118 110 / .13); }
input:disabled, select:disabled, textarea:disabled { color: #7b8794; background: #e2e7eb; border-color: #c5ced7; cursor: not-allowed; }
form label.is-disabled { color: #7b8794; opacity: .68; }
fieldset:disabled { opacity: .75; }
.version-card { padding: 16px; background: var(--muted-surface); border-radius: 8px; }
.version-card > div { display: grid; grid-template-columns: 1fr auto; padding: 12px 0; border-bottom: 1px solid var(--border); }
.version-card small { grid-column: 1 / -1; }
.version-card p:last-child { margin: 14px 0 0; color: var(--muted); font-size: .75rem; }

.switch-list > label, .permission-list > label { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.switch-list span, .permission-list span { display: grid; }
.switch-list input, .permission-list input { width: 42px; height: 22px; accent-color: var(--primary); }
.permission-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.permission-head p { color: var(--subtle); }
.locked-permission { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px; background: var(--muted-surface); border-radius: 7px; }
.locked-permission div { display: grid; }
.admin-list article { min-height: 62px; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.admin-list article div { display: grid; }
.audit-list article { min-height: 66px; display: grid; grid-template-columns: 46px 36px 1fr; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.audit-list article div { display: grid; }
.audit-list time { color: var(--subtle); font-variant-numeric: tabular-nums; }

.detail-drawer { position: fixed; inset: 28px 0 0 auto; z-index: 1060; width: min(440px, 100%); display: flex; flex-direction: column; background: var(--surface); box-shadow: -12px 0 35px rgb(23 32 42 / .12); animation: slide-in .2s ease-out; }
.drawer-backdrop { position: fixed; inset: 28px 0 0; z-index: 1050; background: rgb(23 32 42 / .42); border: 0; }
.drawer-head { display: flex; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; }
.drawer-body { flex: 1; overflow: auto; padding: 20px; }
.member-tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0 12px; border-bottom: 1px solid var(--border); }
.member-tabs button { min-height: 46px; padding: 0 8px; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; font-weight: 600; }
.member-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.member-tabs button:hover { color: var(--primary); background: #f9fbfb; }
.member-tab-panel { padding-top: 16px; }
.member-profile { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.member-profile p { margin: 5px 0 0; color: var(--subtle); }
.mini-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini-kpis div { display: grid; padding: 12px; background: var(--muted-surface); border-radius: 7px; }
.mini-kpis span { color: var(--subtle); font-size: .72rem; }
.detail-list div, .activity-row { min-height: 43px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); }
.detail-list dt { color: var(--subtle); font-weight: 500; }
.detail-list dd { margin: 0; }
.member-records { display: grid; gap: 10px; }
.member-record { padding: 14px; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--e1); }
.member-record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.member-record-head > div { display: grid; }
.member-record dl { margin: 10px 0 0; }
.member-record dl > div { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); }
.member-record dt { color: var(--subtle); font-size: .75rem; font-weight: 500; }
.member-record dd { margin: 0; text-align: right; }
.member-empty { min-height: 260px; display: grid; place-items: center; align-content: center; padding: 24px; text-align: center; }
.member-empty > span { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 10px; color: var(--subtle); background: var(--muted-surface); border-radius: 50%; }
.member-empty p { margin: 4px 0 0; color: var(--subtle); }
.drawer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border); }
.drawer-actions.single { grid-template-columns: 1fr; }
.drawer-form { min-height: 0; display: flex; flex: 1; flex-direction: column; }
.top-up-member { display: flex; align-items: center; gap: 12px; margin: 14px 0; padding: 12px; background: var(--muted-surface); border-radius: 8px; }
.top-up-member > div { display: grid; }
.top-up-member.is-empty { color: var(--subtle); }
.member-search-hint { margin-top: 8px; padding: 10px 12px; color: var(--subtle); background: var(--muted-surface); border-radius: 7px; font-size: .75rem; }
.member-search-hint.selected { color: var(--primary); background: var(--primary-soft); }
.member-search-results { max-height: 220px; margin-top: 8px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.member-search-result { width: 100%; min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; color: var(--text); background: var(--surface); border: 0; border-bottom: 1px solid var(--border); text-align: left; }
.member-search-result:last-child { border-bottom: 0; }
.member-search-result:hover, .member-search-result:focus-visible { background: var(--primary-soft); outline: 0; }
.member-search-result > span:first-child { display: grid; }
.member-search-result > span:last-child { flex: 0 0 auto; font-size: .75rem; }
.form-error { margin: -4px 0 12px; padding: 9px 11px; color: var(--danger); background: var(--danger-soft); border-radius: 7px; font-size: .78rem; }
.confirmation-list > div { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); }
.confirmation-list span { color: var(--subtle); }
.confirmation-list strong { text-align: right; }
.success-panel { display: grid; place-items: center; align-content: center; min-height: 360px; text-align: center; }
.success-panel > span { width: 56px; height: 56px; display: grid; place-items: center; margin-bottom: 14px; color: var(--success); background: var(--success-soft); border-radius: 50%; font-size: 1.5rem; }
.success-panel p { max-width: 300px; color: var(--muted); }
.demo-dialog { max-width: 420px; padding: 24px; border: 0; border-radius: 10px; box-shadow: 0 20px 60px rgb(23 32 42 / .2); }
.demo-dialog::backdrop { background: rgb(23 32 42 / .45); }
.dialog-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; background: transparent; border: 0; font-size: 1.3rem; }
.settle-source-list { display: grid; gap: 4px; margin: 0 0 14px; padding: 0; list-style: none; }
.settle-source-row { display: grid; grid-template-columns: minmax(0, 2fr) 1fr 1fr minmax(160px, 1.4fr); gap: 12px; align-items: end; padding: 10px 0; border-bottom: 1px solid var(--border); }
.settle-source-member { display: grid; gap: 2px; min-width: 0; }
.settle-source-member code { color: var(--subtle); font-size: .75rem; }
.settle-source-figure { display: grid; gap: 2px; }
.settle-source-figure span { color: var(--subtle); font-size: .75rem; }
.settle-source-input label { display: grid; gap: 4px; font-size: .75rem; color: var(--subtle); }
.settle-source-input input { width: 100%; min-height: 44px; }
@media (max-width: 767px) {
  .settle-source-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .settle-source-member, .settle-source-input { grid-column: 1 / -1; }
}
.credit-error-dialog h2 { margin-bottom: 8px; font-size: 1rem; }
.credit-error-dialog p { margin-bottom: 16px; color: var(--muted); }
.activation-link-dialog { width: min(92vw, 640px); }
.activation-link-dialog input[readonly] { width: 100%; margin-block: 8px 4px; }
.copy-feedback { color: var(--success); }
.demo-toast { position: fixed; right: 18px; bottom: 18px; z-index: 1200; width: min(380px, calc(100vw - 36px)); display: grid; grid-template-columns: 32px 1fr 28px; align-items: center; gap: 8px; padding: 12px; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--e3); }
.demo-toast > span { width: 30px; height: 30px; display: grid; place-items: center; color: var(--success); background: var(--success-soft); border-radius: 50%; }
.demo-toast div { display: grid; }
.demo-toast button { background: transparent; border: 0; font-size: 1.2rem; }

.login-page { min-height: 100vh; background: var(--page); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 8vw; align-items: center; max-width: 1180px; margin: auto; padding: 72px 32px 40px; }
.login-intro { max-width: 560px; }
.login-intro h1 { max-width: 520px; margin: 20px 0 14px; font-size: clamp(2.2rem, 5vw, 4rem); line-height: 1.1; letter-spacing: -.04em; }
.login-intro > p:not(.eyebrow) { max-width: 520px; color: var(--muted); font-size: 1.05rem; }
.login-card { padding: 32px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--e3); }
.login-card h2 { margin-top: 14px; font-size: 1.5rem; }
.login-card p { color: var(--muted); }
.login-card form { display: grid; gap: 14px; margin-top: 20px; }
.login-card form label { gap: 6px; }
.login-card .btn { width: 100%; display: inline-grid; place-items: center; color: #fff; background: var(--primary); border: 1px solid var(--primary); cursor: pointer; }
.login-card .btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.login-card .btn-outline-secondary { color: var(--text); background: var(--surface); border-color: var(--border); }
.login-card .btn-outline-secondary:hover { background: var(--muted-surface); border-color: var(--border); }
.secondary-form { padding-top: 4px; border-top: 1px solid var(--border); }
.mfa-qr { display: block; width: min(256px, 100%); height: auto; margin: 20px auto; border: 1px solid var(--border); border-radius: 8px; }
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 20px 0; padding: 0; list-style: none; }
.recovery-codes li { padding: 9px 8px; color: var(--text); background: var(--muted-surface); border-radius: 7px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; text-align: center; }
.role-options { display: grid; gap: 8px; margin: 8px 0 18px; }
.role-options label { display: block; cursor: pointer; }
.role-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.role-options span { display: grid; padding: 12px; border: 1px solid var(--border); border-radius: 8px; }
.role-options input:checked + span { background: var(--primary-soft); border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.login-note { display: block; margin-top: 16px; text-align: center; }
.authenticator-downloads { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.login-card .authenticator-downloads > p { margin: 0 0 10px; color: var(--text); font-size: .8rem; font-weight: 600; text-align: center; }
.authenticator-download-actions { display: flex; align-items: center; justify-content: center; gap: 12px; }
.authenticator-download-actions a { width: 144px; height: 56px; display: grid; place-items: center; padding: 2px; border-radius: 8px; }
.authenticator-download-actions img { display: block; width: auto; object-fit: contain; }
.authenticator-download-actions .app-store-badge { height: 40px; }
/* Google 的官方 PNG 上下含透明留白；52px 才能與 40px 高的 App Store 可見邊界一致。 */
.authenticator-download-actions .google-play-badge { height: 52px; }
.authenticator-download-actions a:hover { opacity: .86; }
.authenticator-download-actions a:focus-visible { outline: 3px solid rgb(15 118 110 / .25); outline-offset: 2px; }

.admin-form-section, .data-section { margin-bottom: 18px; }
.admin-form-section > h2, .data-section h2 { margin-top: 0; }
.admin-form-section > p { color: var(--muted); }
.admin-grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: end; }
.admin-grid-form label, .stack-form label { display: grid; gap: 6px; }
.admin-grid-form input, .admin-grid-form select, .stack-form input { width: 100%; }
.member-create-form { align-items: start; }
.member-create-form small { min-height: 1.45em; }
.form-button-field { display: grid; align-self: start; gap: 6px; }
.form-button-field > span { color: transparent; font-size: .78rem; font-weight: 600; }
.settlement-form-grid > label { align-content: start; align-self: start; }
.settlement-run-field { grid-column: 1 / -1; }
.reconciliation-admin-section { margin-block-end: 16px; }
.reconciliation-admin-grid { display: grid; gap: 20px; margin-block: 16px 24px; }
@media (min-width: 960px) { .reconciliation-admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.permission-fieldset { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 14px; border: 1px solid var(--border); border-radius: 8px; }
.permission-fieldset legend { padding-inline: 5px; font-weight: 700; }
.permission-fieldset label { display: flex; grid-auto-flow: column; align-items: center; gap: 7px; }
.permission-fieldset input { width: auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.stack-form { display: grid; gap: 12px; margin-top: 16px; }
.history-list { display: grid; gap: 8px; padding-left: 20px; }
.profile-kpis { margin-bottom: 18px; }
.profile-facts, .compact-facts { margin: 0; }
.profile-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.profile-facts > div, .compact-facts > div { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.profile-facts dt, .compact-facts dt { color: var(--subtle); }
.profile-facts dd, .compact-facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.record-table { overflow-x: auto; }
.record-table .member-table { min-width: 720px; }
.performance-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.performance-grid > article { padding: 14px; background: var(--muted-surface); border-radius: 8px; }
.performance-grid > article > span { color: var(--subtle); font-size: .8rem; }
.performance-grid > article > strong { display: block; margin: 5px 0 10px; font-size: 1.45rem; }
.performance-grid dl { margin: 0; }
.performance-grid dl div { display: flex; justify-content: space-between; gap: 8px; padding-block: 3px; }
.performance-grid dt { color: var(--subtle); }
.performance-grid dd { margin: 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tag-list li { padding: 7px 9px; background: var(--muted-surface); border-radius: 6px; }
.empty-copy { margin-bottom: 0; color: var(--muted); }
.account-security-form, .recovery-code-result { max-width: 560px; }

.result-operations-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.result-operations-feedback:empty { display: none; }
.result-operations-feedback .form-success { margin: 0 0 16px; padding: 11px 13px; color: var(--success); background: var(--success-soft); border-radius: 8px; font-weight: 700; }
.result-operations-section + .result-operations-section { margin-top: 16px; }
.result-operations-section table { table-layout: fixed; }
.result-operations-section td { white-space: normal; }
.result-operations-section :is(th, td):nth-child(1) { width: 22%; }
.result-operations-section :is(th, td):nth-child(2) { width: 12%; }
.result-operations-section :is(th, td):nth-child(3) { width: 9%; }
.result-operations-section :is(th, td):nth-child(4) { width: 18%; }
.result-operations-section :is(th, td):nth-child(5) { width: 24%; }
.result-operations-section :is(th, td):nth-child(6) { width: 15%; }
.result-operations-section code, .result-job-card dd { overflow-wrap: anywhere; word-break: break-word; }
.result-job-action { margin-top: 12px; }
.result-job-action .htmx-indicator { display: none; }
.result-job-action.htmx-request .htmx-indicator { display: inline; }
.operation-note { margin: 12px 0 0; color: var(--primary); font-weight: 700; }
.status-info { color: var(--primary); background: var(--primary-soft); }
.compact-button { width: 100%; min-width: 0; padding-inline: 10px; }
.recovery-round-list { display: grid; gap: 12px; }
.recovery-round-row { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(360px, 1.2fr); gap: 20px; align-items: end; padding: 16px; background: var(--muted-surface); border: 1px solid var(--border); border-radius: 8px; }
.recovery-round-summary { min-width: 0; display: grid; gap: 5px; }
.recovery-round-summary code { font-size: .78rem; }
.recovery-round-summary span, .recovery-round-summary small { color: var(--subtle); }
.round-recovery-form { display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 12px; align-items: end; }
.round-recovery-form label { min-width: 0; }
.round-recovery-form input { min-height: 44px; }
.compact-actions { align-items: stretch; gap: 8px; }
.button-danger { min-height: 44px; padding: 0 16px; color: #fff; background: var(--danger); border: 1px solid var(--danger); border-radius: 8px; font-weight: 700; }
.button-danger:hover { background: var(--danger); border-color: var(--danger); }
.button-danger:focus-visible { outline: 3px solid rgb(185 28 28 / .28); outline-offset: 2px; }
.button-danger:disabled { color: var(--subtle); background: var(--muted-surface); border-color: var(--border); opacity: .72; cursor: not-allowed; }

@keyframes slide-in { from { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; } }

@media (max-width: 991px) {
  .sidebar { height: 100vh; height: 100dvh; max-height: 100dvh; transform: translateX(-100%); transition: transform .18s ease; }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-backdrop { position: fixed; inset: 28px 0 0; z-index: 1020; background: rgb(23 32 42 / .42); border: 0; }
  body.nav-open .nav-backdrop { display: block; }
  .mobile-topbar { position: fixed; inset: 28px 0 auto; z-index: 1010; height: 56px; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: 0 8px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .mobile-topbar strong { text-align: center; }
  .pending-dot { width: 26px; height: 26px; display: grid; place-items: center; justify-self: end; color: var(--warning); background: var(--warning-soft); border-radius: 50%; font-size: .72rem; font-weight: 700; }
  .main-content { width: 100%; margin-left: 0; padding: 80px 18px 24px; }
  .role-chip { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr 420px; gap: 30px; }
}

@media (max-width: 767px) {
  html { font-size: 16px; }
  h1 { font-size: 1.35rem; }
  .main-content { padding-inline: 12px; }
  .page-head { margin-bottom: 16px; }
  .summary-row { align-items: flex-end; }
  .summary-row .segmented button, .summary-row .segmented a { padding-inline: 8px; font-size: .72rem; }
  .kpi-grid { gap: 8px; }
  .kpi-card { padding: 13px; }
  .kpi-card strong { font-size: 1.25rem; }
  .surface { padding: 14px; }
  .page-actions { position: sticky; top: 88px; z-index: 5; flex-wrap: wrap; padding: 4px 0; background: var(--page); }
  .page-actions .search { flex-basis: 100%; }
  .page-actions > .btn { flex: 1 1 calc(50% - 4px); white-space: nowrap; }
  .filter-button { display: none; }
  .desktop-table { display: none; }
  .mobile-data-list { display: grid; gap: 8px; }
  .data-card { padding: 13px; border-radius: var(--r-md); box-shadow: var(--ring); }
  .data-card-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
  .data-card > div:not(.data-card-head) { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
  .data-card > div span { color: var(--subtle); font-size: .75rem; }
  .data-card > div strong { font-size: .8rem; text-align: right; }
  .data-card > small { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
  .card-action-form { display: grid; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
  .card-action-form input { width: 100%; min-height: 44px; }
  .card-action-form button { min-height: 44px; }
  .data-card-button { width: 100%; color: var(--text); background: var(--surface); text-align: left; }
  .data-card-button > span:not(.data-card-head) { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
  .data-card-button > span:not(.data-card-head) > span { color: var(--subtle); font-size: .75rem; }
  .data-card-button > small { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
  .tabs { gap: 16px; }
  .system-tabs { display: grid; grid-template-columns: repeat(4, max-content); }
  .report-grid { grid-template-columns: 1fr 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .admin-grid-form, .detail-grid { grid-template-columns: 1fr; }
	.result-operations-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.recovery-round-row, .round-recovery-form { grid-template-columns: 1fr; }
	.compact-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .form-button-field > span { display: none; }
  .performance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .version-card { order: -1; }
  .login-shell { display: block; padding: 64px 16px 32px; }
  .login-intro { margin-bottom: 22px; }
  .login-intro h1 { margin: 14px 0 10px; font-size: 2rem; }
  .login-intro > p:not(.eyebrow) { font-size: .88rem; }
  .login-card { padding: 22px; }
  .recovery-codes { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .summary-row { align-items: stretch; flex-direction: column; }
  .summary-row .segmented { align-self: flex-start; }
  .page-actions .btn-primary { padding-inline: 10px; }
  .form-grid, .weight-grid, .report-grid { grid-template-columns: 1fr; }
  .profile-facts, .performance-grid { grid-template-columns: 1fr; }
	.result-operations-summary, .compact-actions { grid-template-columns: 1fr; }
	.result-job-action .button-primary, .round-recovery-form .button-secondary, .round-recovery-form .button-danger { width: 100%; }
  .authenticator-download-actions { flex-wrap: wrap; }
}

/* 需要注意的局：條件式警示，僅用邊框區隔，不加彩色光暈 */
.attention { margin-bottom: 16px; padding: 14px 16px; border: 1px solid #dcbc72; border-radius: var(--r-md); background: #fdf7e8; }
.attention h2 { margin: 0 0 4px; font-size: .95rem; }
.attention p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.attention .attention-links { margin-top: 6px; }
.attention a { color: var(--primary); font-weight: 600; }
/* 區塊內的表格不再自成一張卡，避免卡中卡 */
.surface .member-table-wrap { border-radius: 0; box-shadow: none; }
