:root {
  --amber: #F5A623;
  --amber-dark: #E8940A;
  --amber-light: #FFF8EE;
  --bg: #F5F5F7;
  --surface: #ffffff;
  --text: #1A1A2E;
  --text-muted: #8B8B9A;
  --border: #EBEBF0;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --radius: 16px;
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

/* ── Views ── */
.view {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
}
.view.active { display: flex; }

.view-header {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
}
.view-header h1 { font-size: 1.1rem; font-weight: 700; }

/* ── Home Cover Photo ── */
.home-cover-wrap {
  position: relative;
  width: 100%;
}
#home-cover-input {
  display: none;
}
.home-cover-area {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 7;
  overflow: hidden;
  cursor: pointer;
  background: var(--border);
  position: relative;
  transition: aspect-ratio 0.3s ease;
}
.home-cover-area[data-size="S"] { aspect-ratio: 16 / 4; }
.home-cover-area[data-size="M"] { aspect-ratio: 16 / 7; }
.home-cover-area[data-size="L"] { aspect-ratio: 16 / 10; }
.home-cover-area[data-size="XL"] { aspect-ratio: 1 / 1; }
.home-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease;
}
.home-cover-dots {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}
.home-cover-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.home-cover-dot.active {
  background: #fff;
  transform: scale(1.25);
}
.home-cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s;
}
.home-cover-area:active .home-cover-placeholder {
  background: rgba(0,0,0,0.04);
}
.home-cover-plus {
  font-size: 2rem;
  line-height: 1;
  color: var(--text-muted);
}
.home-cover-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}
.home-cover-action-btn {
  background: rgba(0,0,0,0.45);
  color: #fff;
  border: none;
  border-radius: 99px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  letter-spacing: 0.02em;
  min-width: 44px;
  text-align: center;
}
.home-cover-action-btn:active { opacity: 0.7; }

/* ── Home ── */
.home-header {
  padding: 20px 20px 4px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.home-greeting {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
}
.home-month-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.home-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 16px 4px;
}
.home-stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.home-stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  margin-bottom: 6px;
}
.home-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.home-stat-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.home-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 20px 8px;
}

/* ── Capture ── */
.capture-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  color: var(--text-muted);
}
.upload-icon { font-size: 64px; }
.upload-area input[type="file"] { display: none; }

.preview-container {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.preview-container img {
  width: 100%;
  border-radius: var(--radius);
  object-fit: contain;
  max-height: 50dvh;
  border: 1px solid var(--border);
}

.capture-actions {
  padding: 0 20px 16px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--amber); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-large { width: 100%; padding: 16px; font-size: 1.05rem; min-height: 52px; }

.btn-icon {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--text-muted);
}
.btn-icon:active { opacity: 0.6; }
#btn-select-mode {
  border-radius: 10px;
  transition: all 0.3s ease;
}
#btn-select-mode:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.12);
  background-color: #fff;
  color: #2979FF;
}
#btn-tag-filter {
  border-radius: 10px;
  transition: all 0.2s ease;
}
#btn-tag-filter:hover {
  background-color: color-mix(in srgb, var(--amber) 12%, transparent);
  color: var(--amber);
}
#btn-tag-filter.active {
  background: var(--amber);
  color: #fff;
  border-radius: 10px;
}
.tag-filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: var(--surface);
  border-bottom: 2px solid var(--amber);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  box-shadow: 0 4px 12px rgba(245,166,35,0.12);
}

/* ── Spinner ── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Form ── */
.form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  min-height: 48px;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--amber);
}
.form-group textarea { resize: vertical; }

/* ── Banner ── */
.banner {
  margin: 12px 20px 0;
  padding: 12px 16px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  font-size: 0.9rem;
  color: #9a3412;
}

/* ── Month Nav ── */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px 8px;
  font-weight: 700;
  font-size: 1rem;
}
.month-picker-wrap {
  position: relative;
}
.month-label-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--accent);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  padding: 2px 6px 2px 6px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.month-label-btn::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--accent);
  flex-shrink: 0;
}
.month-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  min-width: 220px;
}
.month-dropdown-year {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 700;
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.year-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  min-width: 100px;
}
.month-grid-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 8px 0;
  cursor: pointer;
}
.month-grid-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.month-grid-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}

/* ── Stats ── */
.stats-summary-strip {
  display: flex;
  align-items: center;
  background: var(--surface);
  margin: 12px 16px 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 0;
}
.stats-summary-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stats-summary-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
  flex-shrink: 0;
}
.stats-summary-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}
.stats-summary-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.stats-section-card {
  margin: 12px 16px 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.stats-section-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
}
.stats-section-icon { font-size: 1rem; }
.stats-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.stats-chart-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.stats-donut-wrap {
  position: relative;
  flex-shrink: 0;
}
.stats-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.stats-donut-label { font-size: 0.68rem; color: var(--text-muted); }
.stats-total-amount { font-size: 1rem; font-weight: 800; color: var(--amber); }

.stats-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.stats-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
}
.stats-legend-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.stats-legend-name { color: var(--text-muted); flex: 1; }
.stats-legend-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.stats-legend-amt { font-weight: 700; font-size: 0.8rem; }
.stats-legend-pct { font-size: 0.68rem; color: var(--text-muted); }

.stats-categories {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stats-cat-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stats-cat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stats-cat-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stats-cat-emoji {
  font-size: 1rem;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stats-cat-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.stats-cat-count { font-size: 0.72rem; color: var(--text-muted); }
.stats-cat-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.stats-cat-amount { font-weight: 800; font-size: 0.92rem; }
.stats-cat-pct { font-size: 0.7rem; color: var(--text-muted); }
.stats-cat-fx  { font-size: 0.7rem; color: var(--accent); margin-top: 1px; }
.stats-fx-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 16px 4px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.stats-fx-item { font-size: 0.82rem; color: var(--text); display: flex; align-items: center; gap: 4px; }
.stats-fx-cur  { font-weight: 700; color: var(--accent); }
.stats-fx-ntd  { color: var(--text-muted); font-size: 0.75rem; }
.stats-cat-bar-wrap {
  height: 7px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.stats-cat-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}

/* AI 月報 */
.btn-ai-gen {
  margin-left: auto;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 20px;
  border: none;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-ai-gen:disabled { opacity: 0.55; cursor: not-allowed; }
.ai-report-loading {
  padding: 16px 0 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}
.ai-report-text {
  margin-top: 14px;
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ── Manual add button ── */
.btn-icon-round {
  background: var(--amber);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}
.btn-icon-round:active { opacity: 0.75; }

/* ── Edit button on receipt card ── */
.btn-edit {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.3;
  padding: 2px 4px;
  border-radius: 6px;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1;
}
.btn-edit:hover { opacity: 1; background: var(--amber-light); }

/* ── Year trend chart ── */
.stats-year-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 700;
}
.stats-trend-tooltip {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--amber);
  padding: 4px 0 2px;
}

/* ── Home Budget Progress ── */
.home-budget-section {
  margin: 0 16px 4px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.home-budget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.home-budget-pct {
  font-weight: 800;
  font-size: 0.9rem;
}
.home-budget-bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}
.home-budget-bar {
  height: 100%;
  border-radius: 99px;
  background: #22c55e;
  transition: width 0.5s ease;
}
.home-budget-bar.ok     { background: #22c55e; }
.home-budget-bar.warn   { background: #eab308; }
.home-budget-bar.danger { background: #ef4444; }
.home-budget-pct        { font-weight: 800; font-size: 0.9rem; }
.home-budget-pct.ok     { color: #16a34a; }
.home-budget-pct.warn   { color: #a16207; }
.home-budget-pct.danger { color: #dc2626; }
.home-budget-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
}

/* ── Stats 上月比較列 ── */
.stats-compare-strip {
  margin: 8px 16px 0;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.stats-compare-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
  flex-shrink: 0;
}
.stats-compare-badge.up   { background: #fee2e2; color: #dc2626; }
.stats-compare-badge.down { background: #dcfce7; color: #16a34a; }
.stats-compare-badge.same { background: var(--border); color: var(--text-muted); }
.stats-compare-detail { color: var(--text); font-weight: 600; }

/* ── Stats 預算狀態列 ── */
.stats-budget-strip {
  margin: 8px 16px 0;
  padding: 11px 14px 10px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
}
.stats-budget-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.stats-budget-label { color: var(--text-muted); font-weight: 600; }
.stats-budget-pct   { font-weight: 800; }
.stats-budget-pct.ok   { color: var(--amber); }
.stats-budget-pct.warn { color: #f97316; }
.stats-budget-pct.over { color: #ef4444; }
.stats-budget-bar-wrap {
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 5px;
}
.stats-budget-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--amber);
  transition: width 0.5s ease;
}
.stats-budget-bar.warn { background: #f97316; }
.stats-budget-bar.over { background: #ef4444; }
.stats-budget-remain {
  font-size: 0.75rem;
  text-align: right;
  color: var(--text-muted);
}
.stats-budget-remain strong { color: var(--text); }
.stats-budget-remain strong.over { color: #ef4444; }

/* ── Currency row ── */
.currency-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.currency-rate-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Settings input ── */
.settings-item-input {
  flex-wrap: wrap;
  gap: 8px;
}
.settings-input {
  width: 100px;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  text-align: right;
}
.settings-input:focus {
  outline: none;
  border-color: var(--amber);
}
.btn-settings-save {
  background: var(--amber);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-settings-save:active { opacity: 0.75; }

/* ── Settings ── */
.settings-content {
  padding: 8px 0 16px;
}
.settings-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 16px 20px 6px;
}
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.settings-item:first-of-type { border-top: 1px solid var(--border); }
.settings-item-label {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
}
.settings-item-value {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: right;
  max-width: 55%;
}

/* ── History / Receipt List ── */
.center-msg {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.receipt-list {
  list-style: none;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.receipt-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: default;
}
.receipt-card.has-detail { cursor: pointer; }

.receipt-cat-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.receipt-body {
  flex: 1;
  min-width: 0;
}
.receipt-store {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.receipt-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.receipt-date { font-size: 0.78rem; color: var(--text-muted); }
.receipt-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}
.receipt-badge-trip {
  background: #E3F0FF;
  color: #2979FF;
  transition: all 0.3s ease;
  cursor: default;
}
.receipt-badge-trip:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(41,121,255,0.18);
  background-color: #fff;
}
.receipt-detail {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}
.receipt-card.expanded .receipt-detail { display: block; }

.receipt-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.receipt-amount-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.receipt-amount {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--amber);
  white-space: nowrap;
}
.receipt-amount-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.btn-delete {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.3;
  padding: 2px 4px;
  border-radius: 6px;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1;
}
.btn-delete:hover { opacity: 1; background: #fee2e2; }

/* ── Bottom Nav (5 tabs) ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding-bottom: var(--safe-bottom);
  z-index: 100;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.05);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  height: 100%;
  transition: color 0.15s;
  letter-spacing: 0.01em;
}
.nav-item.active { color: var(--amber); }

.nav-icon {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  transition: stroke 0.15s;
}

/* Center scan button */
.nav-item-scan {
  position: relative;
  flex: 1.1;
}
.nav-item-scan .nav-icon { display: none; }

.nav-scan-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--amber);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(245, 166, 35, 0.45);
  transform: translateY(-12px);
  transition: transform 0.12s, background 0.15s;
  margin-bottom: -4px;
}
.nav-item-scan:active .nav-scan-btn {
  transform: translateY(-12px) scale(0.92);
}
.nav-item-scan.active .nav-scan-btn {
  background: var(--amber-dark);
}
.nav-item-scan.active {
  color: var(--amber);
}

/* ── Toast ── */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 10px 22px;
  border-radius: 99px;
  font-size: 0.9rem;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

/* ── Batch action bar ── */
.batch-action-bar {
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  left: 0; right: 0;
  background: var(--surface);
  border-top: 2px solid var(--amber);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 90;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
}
.batch-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  min-width: 52px;
}
.batch-trip-select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}
.batch-trip-select:focus { outline: none; border-color: var(--amber); }
.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
  min-height: 36px;
  white-space: nowrap;
  border-radius: 8px;
}

/* ── Receipt card: selection mode ── */
.receipt-check-wrap {
  display: flex;
  align-items: center;
  padding-right: 10px;
  flex-shrink: 0;
}
.receipt-check {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  transition: background 0.15s, border-color 0.15s;
}
.receipt-check.checked {
  background: var(--amber);
  border-color: var(--amber);
}
.receipt-card.selectable { cursor: pointer; user-select: none; }
.receipt-card.selectable:active { opacity: 0.75; }
.receipt-card.card-selected { background: color-mix(in srgb, var(--amber) 10%, var(--surface)); }
.btn-icon.active {
  background: var(--amber);
  color: #fff;
  border-radius: 6px;
}

/* ── Settings API section ── */
.settings-badge {
  font-size: 0.7rem;
  background: var(--accent, var(--amber));
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  font-weight: 500;
}
.settings-item-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.settings-link {
  color: var(--amber);
  text-decoration: underline;
}
.settings-guide {
  margin: 0 20px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.settings-guide-summary {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-guide-summary::-webkit-details-marker { display: none; }
.settings-guide-summary::before { content: '▶'; font-size: 0.65rem; transition: transform 0.2s; }
details[open] .settings-guide-summary::before { transform: rotate(90deg); }
.settings-guide-body {
  padding: 4px 16px 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.settings-guide-body ol { padding-left: 18px; }
.settings-guide-body li { margin-bottom: 6px; }
.settings-guide-body code {
  background: var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.8rem;
}
.settings-guide-note { margin-top: 8px; font-style: italic; }

/* ── Settings Transfer (Export/Import) ── */
.settings-transfer-wrap {
  padding: 4px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-transfer-row {
  display: flex;
  gap: 8px;
}
.settings-code-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-code-area {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.78rem;
  font-family: monospace;
  background: var(--bg);
  color: var(--text);
  resize: none;
  word-break: break-all;
}
.settings-code-area:focus {
  outline: none;
  border-color: var(--amber);
}

/* ── Settings: Usage Guide (top) ── */
.settings-guide-top {
  margin: 12px 20px 8px;
}
.settings-guide-top > .settings-guide-summary {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 700;
}
.settings-guide-body ul.settings-guide-ul {
  padding-left: 18px;
  margin: 4px 0 10px;
}
.settings-guide-body ul.settings-guide-ul li { margin-bottom: 6px; }
.settings-guide-body p { margin: 8px 0 4px; }

/* ── Settings Subsection (within a section) ── */
.settings-subsection-title {
  padding: 14px 20px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ── Local Mode Hint ── */
.settings-local-hint {
  margin: 0 20px 8px;
  padding: 10px 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  font-size: 0.82rem;
  color: #9a3412;
  line-height: 1.5;
}

/* ── 出差 ── */
.trip-filter-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.trip-filter-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.trip-select {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.85rem;
  padding: 6px 10px; outline: none;
}
.trip-banner {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 8px 16px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  flex-wrap: wrap;
}
.trip-banner-name  { font-weight: 700; font-size: 0.95rem; color: var(--accent); }
.trip-banner-dates { font-size: 0.78rem; color: var(--text-muted); }
.trip-settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--surface);
  border-radius: 10px; margin-bottom: 6px;
}
.trip-settings-info { display: flex; flex-direction: column; gap: 2px; }
.trip-settings-name  { font-weight: 600; font-size: 0.9rem; }
.trip-settings-dates { font-size: 0.75rem; color: var(--text-muted); }

/* ── 智慧標籤 ── */
.receipt-badge-tag {
  background: #F3E5F5;
  color: #7B1FA2;
}
.tag-chips-form {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 32px; align-items: center;
  padding: 2px 0;
}
.tag-chip {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: 99px;
  background: var(--border); color: var(--text-muted);
  font-size: 0.8rem; font-weight: 600;
  border: 1.5px solid transparent; cursor: pointer;
  transition: all 0.15s;
}
.tag-chip.selected {
  background: var(--amber); color: #fff;
  border-color: var(--amber-dark);
}
.tag-chip-empty { font-size: 0.82rem; color: var(--text-muted); }
.tag-batch-chips-wrap {
  display: flex; gap: 6px; flex: 1; min-width: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 2px 0;
}
.tag-batch-chip {
  padding: 5px 12px; border-radius: 99px; white-space: nowrap;
  background: var(--bg); color: var(--text-muted);
  font-size: 0.8rem; font-weight: 600;
  border: 1.5px solid var(--border); cursor: pointer;
  transition: all 0.15s; flex-shrink: 0;
}
.tag-batch-chip.active { background: var(--amber); color: #fff; border-color: var(--amber); }
.tag-batch-chip-clear  { border-color: #fca5a5; color: #ef4444; }
.tag-batch-chip-clear.active { background: #ef4444; border-color: #ef4444; color: #fff; }
.tag-filter-chips { display: flex; gap: 6px; }
.tag-filter-chip {
  padding: 4px 12px; border-radius: 99px;
  background: var(--border); color: var(--text-muted);
  font-size: 0.8rem; font-weight: 600;
  border: none; cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
.tag-filter-chip.active { background: var(--amber); color: #fff; }

/* ── Utils ── */
.hidden { display: none !important; }

/* ── 對獎 Modal ── */
.lottery-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
.lottery-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.lottery-modal-card {
  position: relative; width: 100%; max-width: 480px;
  background: var(--bg); border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 16px);
  max-height: 80vh; display: flex; flex-direction: column;
}
.lottery-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; font-weight: 700; font-size: 1rem;
  border-bottom: 1px solid var(--border);
}
.lottery-modal-body { overflow-y: auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.lottery-result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 12px; background: var(--surface);
}
.lottery-result-row.won { border-left: 4px solid #22c55e; }
.lottery-result-row.lost { border-left: 4px solid var(--border); opacity: 0.7; }
.lottery-result-left { display: flex; flex-direction: column; gap: 2px; }
.lottery-invoice { font-size: 0.95rem; font-weight: 700; font-family: monospace; letter-spacing: 1px; }
.lottery-store { font-size: 0.75rem; color: var(--text-muted); }
.lottery-result-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.lottery-prize { font-size: 0.9rem; font-weight: 700; color: #22c55e; }
.lottery-amount { font-size: 0.8rem; color: var(--text-muted); }
.lottery-no-win { font-size: 0.85rem; color: var(--text-muted); }
.lottery-not-yet { font-size: 0.85rem; color: #f59e0b; font-weight: 600; }
.lottery-result-row.not-yet { background: #fffbeb; }
.lottery-empty { text-align: center; padding: 24px 16px; color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; }
.btn-lottery { background: none; border: none; cursor: pointer; padding: 2px; line-height: 1; }
.lottery-badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f7d060, #d4900a);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
  box-shadow: 0 1px 5px rgba(212,144,10,0.45);
  transition: transform 0.12s;
}
.btn-lottery:active .lottery-badge-icon { transform: scale(0.9); }
