:root {
  font-family: "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  color: #3e3a34;
  background: #f3f0e9;
  --paper: #fbfaf6;
  --warm: #f0ece3;
  --line: #ddd7cb;
  --ink: #3e3a34;
  --muted: #858078;
  --accent: #746b5e;
  --accent-dark: #574f45;
  --green: #65796a;
  --red: #9a665e;
  --shadow: 0 10px 30px rgba(61, 55, 47, .055);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--warm); }
button,input,select,textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 34px 24px; border-right: 1px solid var(--line); background: #f6f3ed; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 42px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid #968c7d; border-radius: 50%; color: var(--accent); font-family: Georgia, serif; font-size: 20px; }
.brand strong,.brand small { display: block; }
.brand strong { font-weight: 600; letter-spacing: .08em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 11px; letter-spacing: .12em; }
.nav-list { display: grid; gap: 6px; }
.nav-list button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); text-align: left; }
.nav-list button.active { background: #ebe6dc; color: var(--ink); }
.nav-list svg,.mobile-nav svg { width: 19px; height: 19px; stroke-width: 1.5; }
.sidebar-note { margin-top: auto; color: #aaa399; font-size: 12px; line-height: 1.9; }
main { min-width: 0; padding: 42px clamp(22px, 5vw, 72px) 70px; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 20px; max-width: 1180px; margin: 0 auto 30px; }
.topbar p { margin: 0 0 8px; color: var(--muted); font-size: 12px; letter-spacing: .12em; }
h1,h2,h3,p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; font-weight: 500; letter-spacing: .08em; }
h2 { font-size: 19px; font-weight: 500; }
h3 { font-size: 15px; font-weight: 500; }
.top-actions,.row-actions,.filters,.form-row,.segmented { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.content { max-width: 1180px; margin: auto; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4,minmax(0,1fr)); }
.panel,.metric { border: 1px solid var(--line); border-radius: 6px; background: rgba(251,250,246,.93); box-shadow: var(--shadow); }
.panel { padding: 22px; }
.metric { padding: 18px; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 10px; font-size: 25px; font-weight: 500; }
.income { color: var(--green); }
.expense,.over { color: var(--red); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-head h2,.section-head h3 { margin: 0; }
.account-list,.transaction-list,.budget-list,.category-list { display: grid; gap: 9px; }
.account-card,.transaction,.budget-row,.category-row { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid #e5dfd4; border-radius: 5px; background: #fdfcf9; }
.account-card { align-items: flex-start; }
.account-card .grow,.transaction .grow,.budget-row .grow,.category-row .grow { flex: 1; min-width: 0; }
.icon { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #eee9df; color: var(--accent); }
.icon svg { width: 19px; height: 19px; }
.account-card strong,.transaction strong,.category-row strong { font-weight: 500; }
.account-card small,.transaction small,.category-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 30px 10px; color: var(--muted); text-align: center; }
.progress { height: 6px; overflow: hidden; margin-top: 9px; border-radius: 10px; background: #e8e2d8; }
.progress span { display: block; height: 100%; background: var(--accent); }
.progress span.over { background: var(--red); }
button,.button-link { min-height: 40px; padding: 0 14px; border: 1px solid #cfc7ba; border-radius: 4px; background: #fbfaf6; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button.primary,.button-link.primary { border-color: var(--accent); background: var(--accent); color: white; }
button.danger { color: var(--red); }
button.text-btn { min-height: auto; padding: 0; border: 0; background: transparent; color: var(--accent); }
.icon-btn { width: 34px; min-height: 34px; padding: 0; border-radius: 50%; }
input,select,textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #d2cabd; border-radius: 4px; background: #fffefa; color: var(--ink); outline: none; }
input:focus,select:focus,textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(116,107,94,.1); }
textarea { min-height: 90px; resize: vertical; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.form-grid { display: grid; gap: 14px; }
.form-row > label { flex: 1; min-width: 150px; }
.segmented { padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: var(--warm); }
.segmented button { flex: 1; min-height: 34px; border: 0; background: transparent; }
.segmented button.active { background: var(--paper); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(54,50,44,.32); }
.modal-card { position: relative; width: min(560px,100%); max-height: 92vh; overflow-y: auto; padding: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); box-shadow: 0 30px 80px rgba(40,35,30,.2); }
.close-btn { position: absolute; right: 16px; top: 16px; font-size: 20px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; padding: 12px 16px; border-radius: 4px; background: var(--accent-dark); color: white; box-shadow: var(--shadow); }
.install-banner { position: fixed; right: 22px; bottom: 22px; z-index: 18; width: min(390px, calc(100vw - 28px)); padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); box-shadow: 0 18px 48px rgba(61,55,47,.16); display: flex; align-items: center; gap: 12px; }
.install-banner div { flex: 1; }
.install-banner strong,.install-banner small { display: block; }
.install-banner strong { font-weight: 500; }
.install-banner small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.bar-chart { height: 220px; display: flex; align-items: end; gap: 5px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.bar { flex: 1; min-width: 4px; max-width: 22px; background: #9a9184; border-radius: 2px 2px 0 0; }
.category-bar { display: grid; grid-template-columns: minmax(80px,140px) 1fr auto; align-items: center; gap: 12px; margin: 13px 0; }
.category-bar .track { height: 8px; background: #e7e1d6; border-radius: 10px; overflow: hidden; }
.category-bar .track span { display: block; height: 100%; background: var(--accent); }
.muted { color: var(--muted); }
.inactive { opacity: .5; }
.mobile-nav,.floating-add { display: none; }
@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  main { padding: 22px 14px 104px; }
  .topbar { align-items: center; margin-bottom: 20px; }
  .topbar h1 { font-size: 23px; }
  .top-actions .primary { display: none; }
  .top-actions input { max-width: 145px; }
  .grid-4,.grid-3,.grid-2 { grid-template-columns: 1fr 1fr; }
  .panel { padding: 16px; }
  .mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5,1fr); border-top: 1px solid var(--line); background: rgba(250,248,243,.96); backdrop-filter: blur(12px); }
  .mobile-nav button { min-height: 68px; padding: 8px 2px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; gap: 2px; font-size: 10px; }
  .mobile-nav button.active { color: var(--accent-dark); }
  .floating-add { position: fixed; right: 18px; bottom: 82px; z-index: 9; display: grid; place-items: center; width: 52px; height: 52px; border: 0; border-radius: 50%; background: var(--accent); color: white; font-size: 27px; box-shadow: 0 8px 22px rgba(61,55,47,.22); }
  .install-banner { right: 14px; bottom: 82px; }
}
@media (max-width: 560px) {
  .grid-4,.grid-3,.grid-2 { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .top-actions { justify-content: end; }
  .transaction { align-items: flex-start; }
  .transaction .row-actions { display: grid; }
  .modal { padding: 8px; align-items: end; }
  .modal-card { width: 100%; max-height: 94vh; border-radius: 10px 10px 0 0; padding: 24px 18px; }
}
