/* Finance Vault Mobile PWA — 日系暖木 ＋ MusicVault 六組和色主題 */
:root,
body[data-theme="wood-light"] {
  --bg: #F5EFEB; --surface: #FFFFFF; --subtle: #EFE6DE;
  --text: #2C2523; --text-sec: #573C2C; --muted: #826E62; --border: #E2D5CA;
  --accent: #573C2C; --primary: #3F624D; --primary-soft: rgba(63,98,77,0.14);
  --btn-primary-text: #FFFFFF; --pos: #3F624D;
  --hero-grad: linear-gradient(135deg, #2C2523, #573C2C);
  --alt-grad: linear-gradient(135deg, #2C2523, #3F624D);
  --danger: #B44C3E; --danger-soft: rgba(180,76,62,0.14);
  --amber: #C4872D; --amber-soft: rgba(196,135,45,0.16);
}
body[data-theme="ink-indigo"] {
  --bg: #17191D; --surface: #1F2329; --subtle: #282D36;
  --text: #ECEFF4; --text-sec: #C8D1DC; --muted: #8E9AA8; --border: #303742;
  --accent: #7AB0CC; --primary: #7AB0CC; --primary-soft: rgba(122,176,204,0.18);
  --btn-primary-text: #111317; --pos: #6AC4A6;
  --hero-grad: linear-gradient(135deg, #1E2733, #2B4257);
  --alt-grad: linear-gradient(135deg, #1E2733, #254F5E);
  --danger: #E07A7A; --danger-soft: rgba(224,122,122,0.18);
  --amber: #E5B567; --amber-soft: rgba(229,181,103,0.18);
}
body[data-theme="washi-indigo"] {
  --bg: #FAF7F2; --surface: #FFFFFF; --subtle: #F1ECE3;
  --text: #232B30; --text-sec: #3E4F59; --muted: #74838C; --border: #E5DDD0;
  --accent: #356680; --primary: #356680; --primary-soft: rgba(53,102,128,0.13);
  --btn-primary-text: #FFFFFF; --pos: #2E7D63;
  --hero-grad: linear-gradient(135deg, #1F3645, #356680);
  --alt-grad: linear-gradient(135deg, #1F3645, #2E7D63);
  --danger: #B84A44; --danger-soft: rgba(184,74,68,0.13);
  --amber: #C48A2B; --amber-soft: rgba(196,138,43,0.15);
}
body[data-theme="kyo-matcha"] {
  --bg: #F5F8F2; --surface: #FFFFFF; --subtle: #EBF1E6;
  --text: #1E2B22; --text-sec: #374D3E; --muted: #6B7F71; --border: #DCE5D6;
  --accent: #3A6B4C; --primary: #3A6B4C; --primary-soft: rgba(58,107,76,0.13);
  --btn-primary-text: #FFFFFF; --pos: #3A6B4C;
  --hero-grad: linear-gradient(135deg, #223629, #3A6B4C);
  --alt-grad: linear-gradient(135deg, #223629, #8C6A2B);
  --danger: #B84C42; --danger-soft: rgba(184,76,66,0.13);
  --amber: #BD892C; --amber-soft: rgba(189,137,44,0.15);
}
body[data-theme="kissa-wood"] {
  --bg: #1B1815; --surface: #24201C; --subtle: #2F2924;
  --text: #F2EAE1; --text-sec: #D6C6B6; --muted: #9E8E7E; --border: #3B342D;
  --accent: #D49B54; --primary: #D49B54; --primary-soft: rgba(212,155,84,0.18);
  --btn-primary-text: #1B1815; --pos: #74B48C;
  --hero-grad: linear-gradient(135deg, #2A211B, #4E3927);
  --alt-grad: linear-gradient(135deg, #2A211B, #3F5A46);
  --danger: #E07A6B; --danger-soft: rgba(224,122,107,0.18);
  --amber: #E5B567; --amber-soft: rgba(229,181,103,0.18);
}
body[data-theme="sakura-washi"] {
  --bg: #FBF6F7; --surface: #FFFFFF; --subtle: #F3E7EA;
  --text: #2E2024; --text-sec: #593D45; --muted: #8C727A; --border: #EAD9DE;
  --accent: #9E4258; --primary: #9E4258; --primary-soft: rgba(158,66,88,0.13);
  --btn-primary-text: #FFFFFF; --pos: #3E7A5D;
  --hero-grad: linear-gradient(135deg, #5C2837, #9E4258);
  --alt-grad: linear-gradient(135deg, #5C2837, #3E7A5D);
  --danger: #B84255; --danger-soft: rgba(184,66,85,0.13);
  --amber: #C48435; --amber-soft: rgba(196,132,53,0.15);
}
body[data-theme="ajisai-night"] {
  --bg: #161622; --surface: #1E1E2E; --subtle: #28283D;
  --text: #EFEFF7; --text-sec: #CCCBE0; --muted: #9290AD; --border: #32324A;
  --accent: #A797E8; --primary: #A797E8; --primary-soft: rgba(167,151,232,0.18);
  --btn-primary-text: #161622; --pos: #6AC4A6;
  --hero-grad: linear-gradient(135deg, #242240, #3E376B);
  --alt-grad: linear-gradient(135deg, #242240, #2E5E54);
  --danger: #E87C8A; --danger-soft: rgba(232,124,138,0.18);
  --amber: #E6BA72; --amber-soft: rgba(230,186,114,0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.45;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.pos { color: var(--pos); font-weight: 700; }
.neg { color: var(--danger); font-weight: 700; }

/* Lock Screen */
.lock-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.lock-card {
  width: 100%; max-width: 390px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 26px 22px; text-align: center;
  box-shadow: 0 10px 28px rgba(0,0,0,0.10);
}
.lock-logo-img { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 12px; display: block; box-shadow: 0 6px 18px rgba(0,0,0,0.18); }
.lock-logo {
  width: 54px; height: 54px; border-radius: 15px; margin: 0 auto 10px;
  background: var(--hero-grad); color: #F8FAFC;
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
}
.lock-card h1 { font-size: 20px; margin-bottom: 6px; }
.lock-card p { margin-bottom: 18px; }

.stack-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.stack-form label, .field-lbl {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
input, select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 15px; font-family: inherit;
}
.btn-primary {
  background: var(--primary); color: var(--btn-primary-text); border: none;
  padding: 12px 16px; border-radius: 11px; font-size: 15px;
  font-weight: 700; cursor: pointer;
}

.btn-primary:disabled { opacity: 0.55; }
.btn-ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  padding: 10px; border-radius: 10px; font-size: 13px; cursor: pointer;
}
.full { width: 100%; }
.error-msg {
  margin-top: 12px; padding: 9px 12px; border-radius: 9px;
  background: var(--danger-soft); color: var(--danger); font-size: 13px;
}

/* Header */
.m-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 16px; display: flex; justify-content: space-between; align-items: center;
}
.m-title { font-size: 17px; font-weight: 700; }
.m-sub { font-size: 11px; color: var(--muted); }
.m-header-actions { display: flex; gap: 6px; }
.m-icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 15px; cursor: pointer;
}

/* Content */
.m-content { padding: 14px 14px 96px; max-width: 560px; margin: 0 auto; }
.m-panel { display: none; flex-direction: column; gap: 12px; }
.m-panel.active { display: flex; }

.m-hero-card {
  background: var(--hero-grad);
  color: #F8FAFC; border-radius: 16px; padding: 18px 18px;
}
.m-hero-card.alt-grad { background: var(--alt-grad); }
.hero-label { font-size: 12px; opacity: 0.82; }
.hero-value { font-size: 30px; font-weight: 800; margin: 4px 0; letter-spacing: -0.5px; }
.hero-sub { font-size: 12px; opacity: 0.86; }

.m-kpi-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.m-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 15px;
}
.m-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 14px; }
.k-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.k-val { font-size: 20px; font-weight: 700; margin-top: 2px; }

.m-progress { height: 8px; background: rgba(255,255,255,0.2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.m-progress-fill { height: 100%; background: #A8D5BA; border-radius: 999px; }
.bar-track { height: 8px; background: var(--subtle); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.bar-fill.warn { background: var(--amber); }
.bar-fill.danger { background: var(--danger); }

.m-list { display: flex; flex-direction: column; gap: 8px; }
.m-item {
  background: var(--subtle); border-radius: 11px; padding: 11px 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.m-item-left { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.m-item-title { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-item-sub { font-size: 11px; color: var(--muted); }
.m-item-right { text-align: right; flex-shrink: 0; font-size: 14px; font-weight: 700; }

.m-filter-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.m-filter-row select { flex: 1; padding: 8px; font-size: 14px; }
.m-toggle {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  border-radius: 10px; background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.m-toggle input { width: auto; }
.m-search { margin-bottom: 10px; font-size: 14px; padding: 8px 11px; }
.m-chart-box { height: 185px; position: relative; }
.m-summary-line { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }
.m-tag {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 5px;
  background: var(--surface); color: var(--text-sec); margin-right: 4px;
}

/* Theme Drawer List (MusicVault 和色樣式) */
.m-theme-list { display: flex; flex-direction: column; gap: 6px; }
.m-theme-opt {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: 13px; border: 1px solid transparent;
  background: transparent; color: var(--text); text-align: left; cursor: pointer;
}
.m-theme-opt.active { background: var(--primary-soft); border-color: var(--border); }
.m-swatch-box {
  width: 36px; height: 36px; border-radius: 10px; position: relative; flex-shrink: 0;
  border: 1px solid rgba(128,128,128,0.28);
}
.m-swatch-dot {
  width: 12px; height: 12px; border-radius: 50%;
  position: absolute; right: 4px; bottom: 4px;
}
.m-theme-meta { display: flex; flex-direction: column; flex: 1; }
.m-theme-name { font-size: 14px; font-weight: 700; color: var(--text); }
.m-theme-desc { font-size: 11px; color: var(--muted); }
.m-theme-check { font-size: 16px; font-weight: 700; color: var(--primary); }

/* Bottom Nav */
.m-bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr 1fr 64px 1fr 1fr;
  align-items: center; padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
}
.m-nav-btn {
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 17px; cursor: pointer; padding: 4px 0;
}
.m-nav-btn small { font-size: 11px; font-weight: 600; }
.m-nav-btn.active { color: var(--accent); }
.m-fab {
  width: 52px; height: 52px; border-radius: 50%; border: none;
  background: var(--primary); color: var(--btn-primary-text); font-size: 26px; font-weight: 700;
  margin: -22px auto 0; box-shadow: 0 6px 16px rgba(0,0,0,0.28);
  cursor: pointer; display: grid; place-items: center;
}

/* Drawers */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12, 14, 18, 0.58);
  display: flex; align-items: flex-end; justify-content: center;
}
.drawer-sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 16px 18px calc(24px + env(safe-area-inset-bottom));
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 16px; }
.m-mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--subtle); padding: 4px; border-radius: 10px; margin-bottom: 12px; }
.m-mode-btn { border: none; background: transparent; padding: 8px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.m-mode-btn.active { background: var(--surface); color: var(--text); }

.m-type-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.m-type-btn { padding: 9px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); font-weight: 700; color: var(--muted); }
.m-type-btn.active.expense { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.m-type-btn.active.income { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

.m-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.m-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.m-cat-chip {
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); font-size: 12px; font-weight: 600; color: var(--text);
}
.m-cat-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.m-quick {
  padding: 4px 9px; border-radius: 999px; border: 1px dashed var(--border);
  background: var(--subtle); color: var(--text-sec); font-size: 11px;
}
.m-dup-warn {
  padding: 9px 11px; border-radius: 10px; font-size: 12px;
  background: var(--amber-soft); border: 1px solid var(--amber);
}
.m-toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: #18181B; color: #fff; padding: 10px 16px;
  border-radius: 10px; font-size: 13px; font-weight: 600; z-index: 100;
  white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
