:root {
  --teal: #0f766e;
  --teal-dark: #115e59;
  --danger: #b91c1c;
  --ok: #15803d;
  --bg: #ecfdf5;
  --card: #ffffff;
  --text: #042f2e;
  --muted-text: #115e59;
  --border: #2dd4bf;
  --border-strong: #0f766e;
  --shadow: 0 8px 28px rgba(15, 118, 110, 0.18);
  --radius: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 19px; }
@media (min-width: 700px) { html { font-size: 22px; } }
@media (min-width: 1100px) { html { font-size: 24px; } }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "PingFang TC", "Noto Sans", sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100%; min-height: 100dvh; width: 100%;
  line-height: 1.45; -webkit-text-size-adjust: 100%;
}
body { padding-bottom: calc(40px + var(--safe-bottom)); width: 100%; }
#app {
  width: 100%; max-width: none; margin: 0 auto;
  padding: 18px 16px; min-height: 100dvh;
}
@media (min-width: 700px) {
  #app { width: min(96vw, 1280px); max-width: 1280px; padding: 36px 48px 48px; }
  .role-pick { grid-template-columns: 1fr 1fr; gap: 20px; }
  .role-pick .role-admin { grid-column: 1 / -1; }
  .wallet-stats { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (min-width: 1100px) {
  #app { width: min(94vw, 1400px); max-width: 1400px; padding: 40px 56px 56px; }
  .role-pick { grid-template-columns: 1fr 1fr 1fr; }
  .role-pick .role-admin { grid-column: auto; }
}
h1 { font-size: 2rem; margin: 0 0 10px; font-weight: 900; color: #042f2e; }
h2 { font-size: 1.45rem; margin: 0 0 16px; font-weight: 900; color: #042f2e; }
.sub { color: var(--muted-text); font-size: 1.1rem; margin: 0 0 18px; font-weight: 600; }
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow);
  border: 3px solid var(--border); width: 100%;
}
.role-badge {
  display: inline-block; font-size: 1.05rem; font-weight: 900;
  padding: 10px 16px; border-radius: 999px; margin-bottom: 12px;
  background: #042f2e; color: #fff;
}
.btn {
  display: block; width: 100%; border: none; border-radius: 18px;
  padding: 22px 24px; font-size: 1.3rem; font-weight: 900;
  cursor: pointer; margin-top: 14px; min-height: 68px; letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { background: #f0fdfa; color: var(--teal-dark); border: 3px solid var(--border-strong); }
.btn-danger { background: #fecaca; color: #7f1d1d; border: 3px solid #ef4444; }
.btn-ok { background: #86efac; color: #14532d; border: 4px solid #16a34a; }
.btn-row { display: flex; gap: 14px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 140px; }
label { display: block; font-weight: 900; margin: 18px 0 10px; font-size: 1.15rem; color: #042f2e; }
input[type="text"], input[type="number"], textarea, select {
  width: 100%; padding: 20px 18px; font-size: 1.4rem;
  border: 3px solid var(--border-strong); border-radius: 16px;
  background: #fff; color: #042f2e; outline: none; font-weight: 700; min-height: 64px;
}
input:focus { border-color: #042f2e; box-shadow: 0 0 0 4px rgba(15,118,110,0.25); }
.amount-input {
  font-size: 2.5rem !important; font-weight: 900; text-align: right;
  font-variant-numeric: tabular-nums; min-height: 80px !important;
}
.prefix-row { display: flex; align-items: center; gap: 12px; }
.prefix-row .cur { font-size: 2rem; font-weight: 900; color: #042f2e; min-width: 70px; }
.stats { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 20px; width: 100%; }
@media (min-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .wallet-stats .stat.remain { grid-column: 1 / -1; }
}
@media (min-width: 700px) {
  .wallet-stats .stat.remain { grid-column: auto; }
}
.stat {
  background: #fff; border-radius: 18px; padding: 20px 16px;
  text-align: center; border: 3px solid var(--border-strong);
}
.stat .label { font-size: 1.05rem; font-weight: 800; color: var(--muted-text); margin-bottom: 8px; }
.stat .val { font-size: 1.8rem; font-weight: 900; font-variant-numeric: tabular-nums; color: #042f2e; word-break: break-word; }
.stat.remain { background: #042f2e; border-color: #042f2e; }
.stat.remain .label { color: #99f6e4; }
.stat.remain .val { color: #fff; font-size: 2.2rem; }
.entry {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 18px 0; border-bottom: 2px solid #99f6e4;
}
.entry:last-child { border-bottom: none; }
.thumb {
  width: 88px; height: 88px; border-radius: 14px; object-fit: cover;
  background: #ccfbf1; flex-shrink: 0; border: 3px solid var(--border-strong); cursor: pointer;
}
.thumb-placeholder {
  width: 88px; height: 88px; border-radius: 14px; background: #ccfbf1;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: var(--teal-dark); font-weight: 800; flex-shrink: 0;
  border: 3px dashed var(--border-strong);
}
.entry-body { flex: 1; min-width: 0; }
.entry-name { font-weight: 900; font-size: 1.3rem; color: #042f2e; }
.entry-amt { font-size: 1.75rem; font-weight: 900; color: #042f2e; font-variant-numeric: tabular-nums; margin-top: 6px; }
.entry-meta { font-size: 1rem; color: var(--muted-text); margin-top: 4px; font-weight: 700; }
.badge {
  display: inline-block; padding: 8px 14px; border-radius: 999px;
  font-size: 1rem; font-weight: 900; vertical-align: middle; margin-left: 0;
}
.badge-ok { background: #15803d; color: #fff; }
.badge-mismatch { background: #b91c1c; color: #fff; }
.role-pick { display: grid; gap: 20px; margin-top: 28px; width: 100%; }
.role-card {
  background: var(--card); border: 4px solid var(--border-strong); border-radius: 24px;
  padding: 32px 24px; text-align: center; cursor: pointer; box-shadow: var(--shadow);
  min-height: 180px; width: 100%;
}
.role-card:hover { background: #f0fdfa; border-color: #042f2e; }
.role-card .emoji { font-size: 3.2rem; margin-bottom: 12px; }
.role-card h2 { margin: 0 0 10px; font-size: 1.8rem; }
.role-card .role-tag {
  display: inline-block; background: #042f2e; color: #fff;
  font-size: 1rem; font-weight: 900; padding: 8px 14px; border-radius: 999px; margin-bottom: 12px;
}
.role-card p { margin: 0; color: var(--muted-text); font-size: 1.15rem; font-weight: 700; }
.role-card.role-admin { border-color: #1e3a8a; background: #eff6ff; }
.role-card.role-admin:hover { background: #dbeafe; border-color: #1e3a8a; }
.role-card.role-admin .role-tag { background: #1e3a8a; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 14px; flex-wrap: wrap; width: 100%;
}
.topbar .back {
  background: #042f2e; border: none; color: #fff;
  font-size: 1.15rem; font-weight: 900; cursor: pointer;
  padding: 16px 20px; border-radius: 16px; min-height: 56px;
}
.banner {
  padding: 18px 20px; border-radius: 16px; margin-bottom: 16px; font-weight: 900; font-size: 1.15rem;
  border: 3px solid transparent;
}
.banner.info { background: #dbeafe; color: #1e3a8a; border-color: #2563eb; }
.banner.warn { background: #ffedd5; color: #7c2d12; border-color: #ea580c; }
.photo-preview {
  width: 100%; max-height: 320px; object-fit: contain; border-radius: 16px;
  background: #f8fafc; margin-top: 12px; border: 3px solid var(--border-strong);
}
.file-btn-wrap { position: relative; overflow: hidden; margin-top: 4px; }
.file-btn-wrap .btn { margin-top: 0; }
.file-btn-wrap input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 100px;
}
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 8px; }
.lightbox .close {
  position: absolute; top: 16px; right: 16px; background: #fff; border: none;
  border-radius: 999px; width: 60px; height: 60px; font-size: 1.8rem; cursor: pointer; font-weight: 900;
}
.empty { text-align: center; padding: 36px 12px; color: var(--muted-text); font-size: 1.2rem; font-weight: 700; }
.footer-note { text-align: center; font-size: 1.05rem; color: var(--muted-text); margin-top: 28px; font-weight: 700; }
.chip-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0 8px; }
.chip {
  border: 3px solid var(--border-strong); background: #fff; border-radius: 999px;
  padding: 16px 20px; font-weight: 900; font-size: 1.2rem; cursor: pointer; color: #042f2e; min-height: 56px;
}
.chip:active, .chip.active { background: var(--teal); color: #fff; }
.verify-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px 0; border-bottom: 2px dashed #99f6e4; font-size: 1.3rem; font-weight: 800;
}
.verify-row strong { font-variant-numeric: tabular-nums; font-weight: 900; color: #042f2e; }
.result-banner {
  border-radius: 28px; padding: 44px 24px; text-align: center; margin-bottom: 20px;
  box-shadow: var(--shadow); color: #fff; border: 5px solid rgba(0,0,0,0.12); width: 100%;
}
.result-banner.ok { background: #15803d; }
.result-banner.bad { background: #b91c1c; }
.result-word {
  font-size: clamp(3.2rem, 12vw, 5.5rem); font-weight: 900; letter-spacing: 0.06em;
  line-height: 1.05; text-shadow: 0 3px 0 rgba(0,0,0,0.25);
}
.result-sub { font-size: 1.3rem; margin-top: 14px; font-weight: 900; }
.lang-switch { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.lang-chip {
  flex: 1; min-width: 140px; border: 3px solid var(--border-strong);
  background: #fff; color: #042f2e; border-radius: 999px;
  padding: 12px 16px; font-size: 1.05rem; font-weight: 900;
  cursor: pointer; min-height: 52px;
}
.lang-chip.active { background: #042f2e; color: #fff; border-color: #042f2e; }
.photo-label { font-size: 1.35rem !important; color: #9a3412 !important; margin-top: 22px !important; }
.photo-btn-wrap { margin-top: 8px; }
.btn-photo {
  background: #ea580c !important; color: #fff !important;
  border: 4px solid #9a3412 !important; font-size: 1.45rem !important;
  min-height: 84px !important; padding: 24px 20px !important;
  box-shadow: 0 8px 20px rgba(234, 88, 12, 0.35);
}
.btn-photo:hover { background: #c2410c !important; }

.photo-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.photo-actions .btn-secondary {
  min-height: 64px !important; font-size: 1.2rem !important; font-weight: 900;
  border: 3px solid var(--border-strong); background: #fff; color: #042f2e;
}

/* Calendar */
.cal-wrap { overflow: hidden; }
.cal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 16px;
}
.cal-head h2 { margin: 0; font-size: 1.35rem; text-align: center; flex: 1; }
.cal-head .chip { min-height: 48px; padding: 10px 16px; font-size: 1.2rem; }
.cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  margin-bottom: 8px; text-align: center;
  font-weight: 900; color: var(--muted-text); font-size: 0.95rem;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px;
}
.cal-cell {
  border: 3px solid #99f6e4; background: #fff; border-radius: 14px;
  padding: 10px 4px; min-height: 72px; cursor: pointer;
  font-weight: 900; color: #042f2e; text-align: center;
}
.cal-cell.empty { border: none; background: transparent; cursor: default; min-height: 0; }
.cal-cell.today { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.25); }
.cal-cell.selected { border-color: #042f2e; background: #ccfbf1; }
.cal-cell.has-spend { border-color: #0f766e; }
.cal-cell:hover:not(.empty) { background: #f0fdfa; }
.cal-num { font-size: 1.15rem; margin-bottom: 4px; }
.cal-amt { font-size: 0.72rem; font-weight: 800; color: #0f766e; line-height: 1.15; word-break: break-all; }
.cal-amt.muted { color: #99f6e4; }
@media (min-width: 700px) {
  .cal-cell { min-height: 96px; padding: 14px 8px; }
  .cal-amt { font-size: 0.9rem; }
  .cal-num { font-size: 1.3rem; }
}
.actions-card .btn { font-size: 1.35rem; }

a.role-card { text-decoration: none; color: inherit; display: block; }
a.role-card:visited { color: inherit; }

/* Family PIN gate */
.pin-gate {
  max-width: 28rem; margin: 0 auto; padding: 12px 4px 40px; text-align: center;
}
.pin-gate h1 { margin-bottom: 20px; }
.pin-dots {
  display: flex; justify-content: center; gap: 18px; margin: 18px 0 8px;
}
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--border-strong); background: #fff;
}
.pin-dot.on { background: var(--teal); border-color: var(--teal-dark); }
.pin-err {
  color: #b91c1c; font-weight: 900; font-size: 1.15rem; min-height: 1.6em; margin: 8px 0 12px;
}
.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  margin-top: 12px; max-width: 22rem; margin-left: auto; margin-right: auto;
}
.pin-key {
  border: 3px solid var(--border-strong); background: #fff; color: #042f2e;
  border-radius: 20px; font-size: 2rem; font-weight: 900;
  min-height: 76px; cursor: pointer; box-shadow: var(--shadow);
}
.pin-key:active { transform: scale(0.96); background: #ccfbf1; }
.pin-key-empty { visibility: hidden; box-shadow: none; border: none; }
.pin-key-del { font-size: 1.6rem; background: #f0fdfa; }
