/* 記帳日記 — 樣式（editorial / 分頁版，對應設計方案 0908） */

:root {
  --bg: #F4F1EA;
  --paper: #FFFDF9;
  --surface: #F8F5EE;
  --surface-2: #F8F5EE;
  --surface-3: #F3EFE6;
  --surface-active: #F4F1EA;
  --line: #E7E0D3;
  --line-dash: #DED6C6;
  --line-2: #E4DCCC;
  --line-3: #EBE4D6;
  --line-row: #F0EBDF;
  --ink: #1A1713;
  --ink-2: #5A5145;
  --ink-3: #8A8072;
  --ink-4: #A79C8A;
  --ink-5: #C4B9A4;
  --accent: #111111;
  --accent-hover: #332E27;
  --save: #6E6558;
  --other: #E9E2D3;
  --other-2: #C9BFAB;
  --neg: #B45A4A;
  --cc: #3E7CA6;
  --cc-bg: #EAF1F6;
  --cc-line: #C6D9E4;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Noto Sans TC', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --pad-x: 20px;
  --loan-danger: #8C3A2B;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

input, button, select { font-family: inherit; color: inherit; }
input { border: none; background: transparent; }
input:focus, select:focus { outline: none; }
button { cursor: pointer; border: none; background: none; }
select { cursor: pointer; }

.mono { font-family: var(--mono); }
.klabel { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--ink-4); }

/* ============================================================
 * 外殼：左側選單（≥820px）／底部分頁列（<820px）
 * ========================================================== */

.shell { min-height: 100vh; display: flex; justify-content: center; padding: 0 clamp(0px, 2vw, 28px); }
.shell__inner {
  width: 100%; max-width: 1120px; min-height: 100vh;
  background: var(--paper);
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  display: flex; align-items: stretch;
}

.nav {
  flex: 0 0 208px; border-right: 1px solid var(--line);
  padding: 26px 0; display: flex; flex-direction: column; gap: 26px;
}
.nav__brand { display: flex; align-items: center; gap: 10px; padding: 0 22px; }
.nav__logo { width: 22px; height: 22px; border-radius: 7px; background: var(--accent); flex: 0 0 auto; }
.nav__name { font-size: 14px; font-weight: 500; letter-spacing: .02em; }
.nav__list { display: flex; flex-direction: column; }
.nav__item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 11px 22px; cursor: pointer;
  border-left: 2px solid transparent; background: transparent; width: 100%; text-align: left;
}
.nav__item:hover { background: var(--surface); }
.nav__item.is-active { border-left-color: var(--accent); background: var(--surface-active); }
.nav__item-label { flex: 1 1 auto; font-size: 13.5px; color: var(--ink-2); }
.nav__item.is-active .nav__item-label { color: var(--ink); }
.nav__item-hint { flex: 0 0 auto; font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.nav__today { margin-top: auto; padding: 0 22px; display: flex; flex-direction: column; gap: 5px; }
.nav__today-v { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.nav__today-x { font-size: 11px; color: var(--ink-3); }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* 頂列：月份切換 / 收入 / 同步狀態 / 登出 */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px var(--pad-x); border-bottom: 1px solid var(--line);
}
.topbar__left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar__right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.month { display: flex; align-items: center; gap: 2px; }
.month__btn {
  width: 26px; height: 24px; display: grid; place-items: center;
  border-radius: 6px; font-size: 14px; color: var(--ink-2);
}
.month__nextwrap { display: flex; }
.month__btn:hover:not(:disabled) { background: var(--bg); }
.month__btn:disabled { opacity: .3; cursor: default; }
.month__label { font-family: var(--mono); font-size: 13px; padding: 0 4px; min-width: 72px; text-align: center; }

.income { display: flex; align-items: center; gap: 7px; }
.income__label { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; flex: 0 0 auto; }
.income__prefix { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--ink-4); white-space: nowrap; flex: 0 0 auto; }
.income__input {
  width: 96px; flex: 0 0 auto; text-align: right;
  font-family: var(--mono); font-size: 14px; font-weight: 500; color: var(--ink);
  border-bottom: 1px solid var(--line-dash); border-radius: 0; padding: 3px 2px;
}
.income__input:focus { border-color: var(--accent); }
.income__total { font-family: var(--mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; }

.sync { font-size: 11px; color: var(--ink-3); white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.sync__dot { width: 6px; height: 6px; border-radius: 999px; background: var(--ink-4); flex: 0 0 auto; }
.sync--saved .sync__dot { background: #5C8A5C; }
.sync--saving .sync__dot { background: #C6A15B; }
.sync--error .sync__dot { background: var(--neg); }
.sync--offline .sync__dot { background: var(--ink-4); }

/* 手機頂部標題列 */
.mtitle { display: none; }

/* 區塊 */
.sect + .sect { border-top: 1px solid var(--line); }
.sect__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px 10px;
  flex-wrap: wrap; padding: 18px var(--pad-x) 14px;
}
.sect__title { font-size: 15px; font-weight: 500; white-space: nowrap; }
.sect__meta { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.sect__body { padding: 4px var(--pad-x) 24px; display: flex; flex-direction: column; gap: 16px; }
.sect__body--flush { padding: 0; }

/* 底部分頁列（手機） */
.bottomnav-spacer { display: none; }
.bottomnav { display: none; }

/* ============================================================
 * 總覽
 * ========================================================== */

.ov-free {
  padding: 24px var(--pad-x); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 12px;
}
.ov-free__row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.ov-free__formula { font-size: 11px; color: var(--ink-4); letter-spacing: .02em; }
.ov-big { display: flex; align-items: baseline; gap: 8px; }
.ov-big__unit { font-family: var(--mono); font-size: 17px; color: var(--ink-4); }
.ov-big__val {
  font-family: var(--mono); font-size: clamp(38px, 5.4vw, 58px); font-weight: 500;
  line-height: 1; letter-spacing: -.02em;
}
.ov-big__val.is-neg { color: var(--neg); }
.ov-bar { height: 4px; background: #EFEAE0; overflow: hidden; display: flex; }
.ov-bar > div { background: var(--accent); }
.ov-lines {
  display: flex; flex-wrap: wrap; gap: 6px 20px;
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
}
.ov-lines span { white-space: nowrap; }

.ov-perday {
  padding: 16px var(--pad-x); border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.ov-perday__label { font-size: 12px; color: var(--ink-3); }
.ov-perday__val { font-family: var(--mono); font-size: 20px; font-weight: 500; white-space: nowrap; }

.ov-list { display: flex; flex-direction: column; }
.ov-row {
  display: flex; align-items: center; gap: 12px; padding: 15px var(--pad-x);
  border-bottom: 1px solid var(--line-row); cursor: pointer; width: 100%; text-align: left; background: none;
}
.ov-row:hover { background: var(--surface); }
.ov-row__bar { flex: 0 0 auto; width: 3px; height: 26px; }
.ov-row__id { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ov-row__title { font-size: 14px; }
.ov-row__sub { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-row__val { flex: 0 0 auto; font-family: var(--mono); font-size: 16px; font-weight: 500; white-space: nowrap; }
.ov-row__caret { flex: 0 0 auto; font-size: 14px; color: var(--ink-5); }

.ov-add { padding: 20px var(--pad-x); display: flex; flex-direction: column; gap: 11px; }
.ov-add__box {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-dash); border-radius: 9px; padding: 6px 6px 6px 12px;
}
.ov-add__name { flex: 1 1 auto; min-width: 0; font-size: 14px; color: var(--ink); }
.ov-add__amt {
  width: 66px; flex: 0 0 auto; text-align: right;
  font-family: var(--mono); font-size: 14px; color: var(--ink);
}

/* ============================================================
 * 共用小元件
 * ========================================================== */

.hint { font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.col__hint { font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.col__head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 8px; flex-wrap: wrap; }
.col__title { font-size: 14px; font-weight: 500; white-space: nowrap; }
.col__meta { font-family: var(--mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.eyebrow { font-size: 13px; color: var(--ink-3); letter-spacing: .04em; }
.formula { font-family: var(--sans); font-size: 11px; color: var(--ink-4); letter-spacing: .02em; line-height: 1.4; }

/* 上月結餘 */
.carry { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; }
.carry__label { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.carry__sign {
  flex: 0 0 auto; width: 26px; height: 26px; position: relative;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--paper);
  font-size: 0; color: var(--ink-3);
  cursor: pointer; transition: background .12s, border-color .12s, color .12s, transform .08s;
}
.carry__sign::before, .carry__sign::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  background: currentColor; border-radius: 1px;
}
.carry__sign::before { width: 10px; height: 2px; transform: translate(-50%, -50%); }
.carry__sign::after  { width: 2px; height: 10px; transform: translate(-50%, -50%); }
.carry__sign.is-neg::after { display: none; }
.carry__sign:hover { border-color: var(--accent); color: var(--accent); }
.carry__sign:active { transform: scale(.92); }
.carry__sign.is-neg { background: #F6E8E3; border-color: #C67C6C; color: #A9483A; }
.carry__sign.is-neg:hover { border-color: #A9483A; color: #A9483A; }
.carry__prefix { font-family: var(--mono); font-size: 12px; color: var(--ink-4); white-space: nowrap; }
.carry__input {
  width: 78px; text-align: right; font-family: var(--mono); font-size: 14px; color: var(--ink);
  border-bottom: 1px solid var(--line-2); border-radius: 0; padding: 4px 2px;
}
.carry__input:focus { border-color: var(--accent); }
.carry__auto-note { align-self: flex-start; font-size: 11px; color: var(--ink-4); margin-top: -4px; }

.bar { height: 4px; background: #EFEAE0; overflow: hidden; display: flex; }
.bar__fill { background: var(--accent); }
.rowbetween { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* 分類配置條 + 統計 */
.alloc { display: flex; height: 10px; overflow: hidden; }
.alloc--empty { align-items: center; padding-left: 2px; height: auto; }
.alloc__empty { font-size: 12px; color: var(--ink-4); }
.alloc__seg { min-width: 0; }
.alloc__seg--fixed { background: var(--accent); }
.alloc__seg--save { background: var(--save); }
.alloc__seg--other { background: var(--other-2); }

.rep-legend { display: flex; flex-direction: column; }
.rep-legend__row { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-row); }
.rep-legend__row:last-child { border-bottom: none; }
.rep-legend__dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 2px; }
.rep-legend__name { flex: 1 1 auto; font-size: 13.5px; }
.rep-legend__share { flex: 0 0 auto; font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.rep-legend__amt { flex: 0 0 auto; font-family: var(--mono); font-size: 14px; min-width: 74px; text-align: right; }

/* 按鈕 */
.btn-plain {
  padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 7px;
  font-size: 11.5px; color: var(--ink-2); white-space: nowrap; background: var(--paper);
}
.btn-plain:hover { border-color: var(--accent); color: var(--accent); }
.btn-solid {
  flex: 0 0 auto; white-space: nowrap; padding: 8px 15px;
  background: var(--accent); color: var(--paper); border-radius: 7px; font-size: 13px; text-align: center;
}
.btn-solid:hover { background: var(--accent-hover); }
.btn-outline-dark {
  padding: 5px 10px; border: 1px solid var(--accent); border-radius: 7px;
  font-size: 11.5px; color: var(--accent); white-space: nowrap; background: var(--paper);
}
.btn-outline-dark:hover { background: var(--accent); color: var(--paper); }

.iconbtn {
  flex: 0 0 auto; width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 7px; font-size: 13px; color: var(--ink-5);
}
.iconbtn:hover { background: #F1ECE1; color: var(--accent); }

.dashed-btn {
  margin-top: 6px; padding: 11px; border: 1px dashed #D8CFBC; border-radius: 9px;
  text-align: center; font-size: 13px; color: var(--ink-3); width: 100%;
}
.dashed-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ============================================================
 * 固定支出
 * ========================================================== */

.fx { display: flex; flex-direction: column; gap: 2px; }
.fx__colhead {
  display: flex; align-items: center; gap: 8px; padding: 9px var(--pad-x);
  margin: 0 calc(-1 * var(--pad-x)); background: var(--surface);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--ink-4);
}
.fx__colhead-item { flex: 1 1 auto; }
.fx__colhead-day { flex: 0 0 auto; width: 50px; text-align: right; }
.fx__colhead-amt { flex: 0 0 auto; width: 62px; text-align: right; }
.fx__colhead-pad { flex: 0 0 auto; width: 64px; }
.fx__row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line-row); }
.fx__name { flex: 1 1 auto; min-width: 0; font-size: 14px; color: var(--ink); border-radius: 6px; padding: 5px; margin-left: -5px; }
.fx__name:focus { background: var(--surface); }
.fx__day { width: 50px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: flex-end; gap: 2px; font-family: var(--mono); font-size: 12px; color: var(--ink-4); padding: 5px 0; }
.fx__day-n { width: 24px; text-align: right; color: inherit; font: inherit; line-height: 1; padding: 3px 0; border-radius: 6px; -webkit-appearance: none; appearance: none; }
.fx__day-n:focus { background: var(--surface); }
.fx__amt { width: 62px; flex: 0 0 auto; text-align: right; font-family: var(--mono); font-size: 14px; color: var(--ink); border-radius: 6px; padding: 5px 0; }
.fx__amt:focus { background: var(--surface); }
.fx__row--ro { color: var(--ink-2); padding-right: 64px; }
.fx__row--ro .fx__name { padding: 5px 0; margin: 0; }
.col--fixed .col__meta { padding-right: 64px; }

.fx__wrap { border-bottom: 1px solid var(--line-row); }
.fx__wrap .fx__row { border-bottom: none; }
.fx__row--dim { opacity: .45; }
.fx__cal { font-size: 12px; }
.fx__cal.is-set { color: var(--accent); }
.fx__rangebar { padding: 0 0 8px 5px; }
.fx__range-tag {
  display: inline-block; margin-left: 6px; font-size: 10px; color: var(--ink-4);
  background: var(--surface-3); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 6px;
  font-family: var(--mono);
}
.fx__row--ro .fx__range-tag { margin-left: 6px; }
.fx__range-edit { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.fx__range-edit label { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--ink-4); letter-spacing: .04em; }
.fx__range-edit input {
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line-3); border-radius: 7px; padding: 5px 6px;
}
.fx__range-edit input:focus { border-color: var(--accent); }
.fx__range-hint { flex: 1 1 100%; font-size: 10px; color: var(--ink-4); line-height: 1.5; }
.fx__ovr-row {
  flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  padding-top: 8px; margin-top: 2px; border-top: 1px dashed var(--line-2);
}
.fx__ovr-mo { font-size: 10px; color: var(--ink-4); letter-spacing: .04em; }
.fx__ovr-in { width: 92px; text-align: right; }
.fx__ovr-row .btn-plain { padding: 3px 10px; font-size: 11px; }

/* ============================================================
 * 存錢帳戶
 * ========================================================== */

.acc {
  padding: 14px 0; border-bottom: 1px solid var(--line-row);
  display: flex; flex-direction: column; gap: 12px;
}
.acc:last-child { border-bottom: none; }
.acc__top { display: flex; align-items: flex-start; gap: 11px; }
.acc__tag { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 7px; background: #EFEAE0; display: grid; place-items: center; font-size: 12px; color: var(--ink-2); }
.acc__id { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.acc__bank { font-size: 14px; font-weight: 500; line-height: 1.3; }
.acc__meta { font-size: 11px; color: var(--ink-3); line-height: 1.4; word-break: break-word; }
/* 遮罩帳號：用系統拉丁字型（不用等寬字）；顯示 3 顆點 + 末四碼 */
.acc__no { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans TC', sans-serif; }
.acc__right { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.acc__monthly { font-family: var(--mono); font-size: 15px; font-weight: 500; white-space: nowrap; }
.acc__monthly.is-neg { color: var(--neg); }
.acc__monthly-label { font-size: 10px; color: var(--ink-4); white-space: nowrap; }
.acc__bar { height: 4px; background: #EFEAE0; overflow: hidden; }
.acc__bar > div { height: 100%; background: var(--save); }
.acc__bar--empty { background: var(--surface-3); }
.acc__foot { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.acc__actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.acc__quick { display: flex; align-items: center; gap: 6px; }
.acc__quick-label { font-size: 11px; color: var(--ink-4); white-space: nowrap; flex: 0 0 auto; }
.acc__quick .carry__input { flex: 0 0 auto; width: 84px; }

.led { display: flex; flex-direction: column; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.led__row { display: flex; flex-direction: column; }
.led__line { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 7px; cursor: pointer; }
.led__line:hover { background: var(--surface-2); }
.led__line:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.led__date { font-family: var(--mono); font-size: 11px; color: var(--ink-3); flex: 0 0 auto; width: 42px; }
.led__amt { font-family: var(--mono); font-size: 13px; color: var(--save); font-weight: 500; flex: 0 0 auto; width: 82px; text-align: right; }
.led__amt.is-neg { color: var(--neg); }
.led__note { font-size: 11px; color: var(--ink-3); flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.led__edit { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 10px; padding: 4px 4px 8px; }
.led__edit label { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--ink-4); }
.led__edit input[type=date],
.led__edit input:not([type]),
.led__edit input[type=text] {
  font-size: 12px; color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line-3); border-radius: 7px; padding: 5px 7px;
}
.led__edit input { max-width: 120px; }
.led__edit label > span { display: flex; }
.led__add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 0 2px; }
.led__add input {
  font-size: 12px; color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line-3); border-radius: 7px; padding: 5px 7px;
}
.led__add input:focus { border-color: var(--accent); }
.led__amt-in { width: 92px; text-align: right; font-family: var(--mono); }
.led__note-in { flex: 1 1 110px; min-width: 90px; }

.field-input {
  width: 100%; font-size: 14px; font-weight: 500; color: var(--ink);
  background: transparent; border-bottom: 1px solid var(--line-dash); border-radius: 0; padding: 5px 2px;
}
.field-input:focus { border-color: var(--accent); }

.acc__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 11px 14px; padding: 12px 0 2px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field__label { font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; color: var(--ink-4); }
.field__in {
  width: 100%; font-size: 13px; color: var(--ink-2);
  background: transparent; border-bottom: 1px solid var(--line-dash); border-radius: 0; padding: 5px 2px;
}
.field__in:focus { border-color: var(--accent); }
.field__in.mono { font-family: var(--mono); font-size: 12.5px; color: var(--ink); text-align: right; }

/* ============================================================
 * 其他開銷（記帳）
 * ========================================================== */

/* 桌機：記帳框在左、快速標籤補到右邊那片空白；手機（≤819）改回上下堆疊 */
.quick { display: flex; flex-direction: row; align-items: flex-start; gap: 24px; flex-wrap: wrap; }
.quick__entry {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--line-dash); border-radius: 9px; background: var(--paper);
  flex: 0 1 540px;
}
.quick__tags { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.quick__name { width: 100%; font-size: 14px; color: var(--ink); }
.quick__row2 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.quick__row3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quick__date {
  flex: 0 1 112px; min-width: 104px; font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line-3); border-radius: 7px; padding: 6px 2px;
}
.quick__date:focus { border-color: var(--accent); }
.quick__amt {
  width: 118px; flex: 0 0 auto; text-align: right; font-family: var(--mono); font-size: 16px; font-weight: 500; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-3); border-radius: 7px; padding: 8px 10px;
}
.quick__amt:focus { border-color: var(--accent); }
.quick__cat {
  flex: 0 0 auto; font-size: 12px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line-3); border-radius: 7px;
  padding: 6px 4px; max-width: 72px;
}
.quick__cat:focus { border-color: var(--accent); }
.quick__paylabel { font-size: 12px; color: var(--ink-3); }
.quick__pay {
  flex: 0 0 auto; font-size: 12px; color: var(--cc);
  background: var(--surface-2); border: 1px solid var(--line-3); border-radius: 7px; padding: 5px 6px; max-width: 130px;
}
.quick__pay:focus { border-color: var(--cc); }
.quick__payhint { font-size: 11px; color: var(--cc); }
.meta-pend { color: var(--cc); }

.tags__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tags__hint { font-size: 12px; color: var(--ink-3); }
.tags__list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: flex; align-items: center; gap: 2px; padding: 5px 6px 5px 12px;
  border: 1px solid var(--line-2); border-radius: 7px; background: var(--paper); color: var(--ink-2);
}
.tag:hover { border-color: var(--accent); color: var(--accent); }
.tag__text { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.tag__text:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.tag__x { width: 22px; height: 22px; margin-left: 2px; display: grid; place-items: center; border-radius: 6px; font-size: 12px; color: var(--ink-5); }
.tag__x:hover { background: #F1ECE1; color: var(--accent); }
.tag__pad { width: 6px; display: inline-block; }

.exp-hd {
  display: flex; align-items: center; gap: 10px; padding: 9px var(--pad-x);
  margin: 0 calc(-1 * var(--pad-x)); background: var(--surface);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--ink-4);
}
.exp-hd__date { flex: 0 0 auto; min-width: 38px; }
.exp-hd__item { flex: 1 1 auto; }
.exp-hd__amt { flex: 0 0 auto; width: 56px; text-align: right; }
.exp-hd__pad { flex: 0 0 auto; width: 30px; }

.expenses { display: flex; flex-direction: column; gap: 0; max-height: 340px; overflow-y: auto; }
.exp { display: flex; flex-direction: column; border-bottom: 1px solid var(--line-row); }
.exp__main { display: flex; align-items: center; gap: 10px; padding: 10px 0; cursor: pointer; border-radius: 6px; }
.exp__main:hover { background: var(--surface); }
.exp__main:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); }
.exp--open .exp__main { background: var(--surface); }
.exp__date { font-family: var(--mono); font-size: 11px; color: var(--ink-4); min-width: 38px; flex: 0 0 auto; }
.exp__name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.exp__nameline { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp__note { font-size: 11px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp__cat {
  flex: 0 0 auto; font-size: 11px; color: var(--ink-3); max-width: 58px;
  background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 3px 2px;
}
.exp__cat:hover { border-color: var(--line-2); }
.exp__cat:focus { border-color: var(--accent); color: var(--ink); }
.exp__amt { font-family: var(--mono); font-size: 14px; min-width: 56px; text-align: right; flex: 0 0 auto; }
.exp__empty { font-size: 12px; color: var(--ink-4); padding: 16px 0; text-align: center; }
.exp__edit {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 10px;
  padding: 10px 4px 12px;
}
.exp__edit label { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--ink-4); letter-spacing: .04em; }
.exp__edit input, .exp__edit select {
  font-size: 13px; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line-3); border-radius: 7px; padding: 6px 7px;
}
.exp__edit input:focus, .exp__edit select:focus { border-color: var(--accent); }

.exp--pend .exp__main { opacity: .6; }
.exp__cctag {
  margin-left: 6px; font-size: 10px; font-family: var(--mono);
  background: var(--cc-bg); color: var(--cc); border: 1px solid var(--cc-line);
  border-radius: 6px; padding: 1px 6px; white-space: nowrap;
}
.exp__cctag.is-pend { background: transparent; }

/* 搜尋 / 篩選 */
.filter-btn {
  margin-left: 8px; width: 22px; height: 22px; border-radius: 6px;
  border: 1px solid var(--line-2); color: var(--ink-3); font-size: 13px; line-height: 1;
  vertical-align: middle;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.is-on { background: var(--accent); color: var(--paper); border-color: var(--accent); }
.filterbar {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line-dash); border-radius: 9px;
}
.filterbar input, .filterbar select {
  font-size: 12px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line-2); border-radius: 7px; padding: 6px 8px;
}
.filterbar input:focus, .filterbar select:focus { border-color: var(--accent); }
.filterbar__text { flex: 1 1 120px; min-width: 100px; }
.filterbar__sum {
  flex: 1 1 100%; font-size: 12px; color: var(--ink-2); font-family: var(--mono);
  padding: 2px 2px 0; letter-spacing: .01em;
}

/* 信用卡 */
.cards-mgr { display: flex; flex-direction: column; gap: 8px; }
.cards-mgr > .btn-plain { align-self: flex-start; }
.cards-list {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--cc-line); background: var(--cc-bg); border-radius: 9px; padding: 10px;
}
.cardrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cardrow input {
  font-size: 13px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line-2); border-radius: 7px; padding: 6px 8px;
}
.cardrow input:focus { border-color: var(--cc); }
.cardrow__name { flex: 1 1 140px; min-width: 120px; }
.cardrow__l4 { width: 68px; text-align: center; }
.cardrow__cd { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-3); }
.cardrow__cd input { width: 46px; text-align: right; }

.pendcard {
  margin-top: 4px; background: var(--cc-bg); border: 1px solid var(--cc-line);
  border-radius: 9px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.pendcard__head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 500; color: var(--cc); }
.pendcard__head .mono { font-family: var(--mono); font-size: 15px; }
.pendcard__rows { display: flex; flex-direction: column; gap: 4px; }
.pendcard__row { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); }
.pendcard__row .mono { font-family: var(--mono); }
.pendcard .col__hint { font-size: 11px; color: var(--cc); opacity: .85; }

/* ============================================================
 * 報表
 * ========================================================== */

.report__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 34px; }
.rep { display: flex; flex-direction: column; gap: 5px; padding: 6px 0; }
.rep__top { display: flex; align-items: baseline; gap: 8px; }
.rep__cat { flex: 1; min-width: 0; font-size: 13.5px; }
.rep__share { font-family: var(--mono); font-size: 11px; color: var(--ink-4); }
.rep__amt { font-family: var(--mono); font-size: 14px; }
.rep__bar { height: 4px; background: #EFEAE0; overflow: hidden; }
.rep__bar > div { height: 100%; }

.trend { display: flex; flex-direction: column; gap: 10px; }
.trend__svg { width: 100%; height: auto; max-height: 240px; }
.trend__val { font-family: var(--mono); font-size: 11px; fill: var(--ink-3); }
.trend__mon { font-family: var(--sans); font-size: 12px; fill: var(--ink-4); }
.trend__mon.is-cur { fill: var(--ink); font-weight: 500; }
.trend__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.trend__mom { font-size: 12px; color: var(--ink-2); }
.trend__legend { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.trend__lg { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-3); }
.trend__lg i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* ============================================================
 * 分期（貸款／分期付款）
 * ========================================================== */

.loan__next {
  padding: 14px var(--pad-x); background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.loan__next .col__hint { margin: 0; }
.loan__nextline { font-size: 13.5px; color: var(--ink); line-height: 1.5; }
.loan__over { font-size: 12px; color: var(--loan-danger); line-height: 1.5; }

.loan { border-bottom: 1px solid var(--line-row); }
.loan .ov-row { border-bottom: none; }

.loan__kind {
  flex: 0 0 auto; padding: 3px 7px;
  border: 1px solid var(--line-2); border-radius: 5px;
  font-size: 10.5px; color: var(--ink-2); white-space: nowrap;
}
.loan__permo { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); white-space: nowrap; }

.loan__prog {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 0 var(--pad-x) 14px;
}
.loan__prog .acc__bar { flex: 1 1 140px; min-width: 0; }
.loan__prog > span { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); white-space: nowrap; }
.loan__prog .btn-plain { flex: 0 0 auto; }

.loan__edit {
  background: var(--surface); border-top: 1px solid var(--line-row);
  padding: 14px var(--pad-x) 18px; display: flex; flex-direction: column; gap: 12px;
}
.loan__edit .acc__grid { padding: 0; }
.loan__edit .acc__actions { flex-wrap: wrap; }

/* ============================================================
 * 登入 / 載入 / 提示
 * ========================================================== */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login {
  width: 100%; max-width: 360px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 30px 26px; display: flex; flex-direction: column; gap: 16px;
}
.login__brand { display: flex; align-items: center; gap: 12px; }
.login__logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); }
.login__title { font-size: 17px; font-weight: 500; }
.login__sub { font-size: 12px; color: var(--ink-3); margin-top: -6px; }
.login__field { display: flex; flex-direction: column; gap: 4px; }
.login__label { font-size: 12px; color: var(--ink-3); }
.login__input {
  width: 100%; font-size: 14px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-3);
  border-radius: 8px; padding: 10px 12px;
}
.login__input:focus { border-color: var(--accent); }
.login__btn {
  width: 100%; padding: 11px; background: var(--accent); color: var(--paper);
  border-radius: 8px; font-size: 14px; font-weight: 500;
}
.login__btn:hover { background: var(--accent-hover); }
.login__btn:disabled { opacity: .55; cursor: default; }
.login__err { font-size: 12px; color: var(--neg); }
.login__note { font-size: 11px; color: var(--ink-4); line-height: 1.6; }

.loading { min-height: 100vh; display: grid; place-items: center; color: var(--ink-3); font-size: 13px; }

.banner {
  margin: 0; background: #FBF3E2; border-bottom: 1px solid #EAD9B0;
  padding: 10px var(--pad-x); font-size: 12px; color: #7A6A45;
}
.banner b { font-weight: 500; }
.banner--warn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: #FBECEC; border-color: #E7C4C0; color: #8A4A42;
}
.banner__act {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 500;
  background: var(--accent); color: var(--paper);
}
.banner__act:hover { background: var(--accent-hover); }

.monthnote {
  margin: 12px var(--pad-x) 0;
  background: var(--surface-3); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 12px; font-size: 12px; color: var(--ink-2); line-height: 1.5;
}
.monthnote b { font-weight: 500; color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 50; display: flex; align-items: center; gap: 14px;
  background: var(--accent); color: var(--paper);
  border-radius: 10px; padding: 10px 12px 10px 16px; font-size: 13px;
  box-shadow: 0 8px 24px -8px rgba(40, 34, 24, .45);
  max-width: calc(100vw - 32px);
}
.toast button {
  color: var(--paper); font-size: 13px; font-weight: 500;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 7px; padding: 5px 12px;
}
.toast button:hover { background: rgba(255, 255, 255, .15); }

/* ============================================================
 * 手機版（< 820px）
 * ========================================================== */

@media (max-width: 819px) {
  .shell { padding: 0; }
  .shell__inner { border-left: none; border-right: none; }
  .nav { display: none; }

  .mtitle {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px 11px; border-bottom: 1px solid var(--line);
  }
  .mtitle__logo { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 7px; background: var(--accent); }
  .mtitle__name { flex: 1 1 auto; font-size: 14.5px; font-weight: 500; }
  .mtitle__meta { flex: 0 0 auto; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); white-space: nowrap; }

  .topbar { padding: 12px 16px; }

  .bottomnav-spacer { display: block; height: 86px; }
  .bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; gap: 1px; padding: 8px 6px calc(12px + env(safe-area-inset-bottom));
    background: var(--paper); border-top: 1px solid var(--line);
    box-shadow: 0 -8px 20px -16px rgba(40, 34, 24, .5);
  }
  .bottomnav__item {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 10px 1px; border-radius: 9px; background: var(--bg); color: var(--ink-2);
  }
  .bottomnav__item.is-active { background: var(--accent); color: var(--paper); }
  .bottomnav__short { font-size: 12px; white-space: nowrap; }
  .bottomnav__hint {
    max-width: 100%; font-family: var(--mono); font-size: 9px; opacity: .6;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  :root { --pad-x: 16px; }

  .iconbtn { width: 34px; height: 34px; }
  .fx__row .iconbtn { width: 28px; height: 28px; }
  .month__btn { width: 38px; height: 34px; }
  .filter-btn { width: 30px; height: 30px; font-size: 15px; }
  .btn-plain { padding: 8px 12px; }
  .carry__sign { width: 32px; height: 32px; }
  .carry__sign::before { width: 12px; }
  .carry__sign::after { height: 12px; }
  .carry, .acc__quick { gap: 8px; }
  /* 開銷清單在手機上也要能捲（不然一長串會把整頁撐爆） */
  .expenses { max-height: 58vh; }
  .quick { flex-direction: column; gap: 10px; }
  .quick__entry { flex: none; max-width: none; }
  .quick__tags { flex: none; width: 100%; }
  .quick__date { flex: 0 1 130px; min-width: 118px; }
  .quick__amt { width: 108px; }
  .quick__row2 .btn-solid { flex: 1 0 100%; margin-top: 2px; padding: 10px 16px; }
  .ov-big__val { font-size: 46px; }
  /* 復原 / 記帳確認 toast 要浮在底部分頁列「上方」，不要蓋到分頁入口 */
  .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
}
