:root {
  --ink: #17211c;
  --muted: #6f685e;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e4dccf;
  --forest: #1e3329;
  --forest-2: #294338;
  --brass: #9a7433;
  --brass-soft: #f3e7cf;
  --green: #1d7a4a;
  --red: #a33b32;
  --shadow: 0 16px 40px rgba(48, 36, 18, 0.06);
  color: var(--ink);
  background: var(--paper);
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
a { color: inherit; }

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(320px, 0.85fr);
}
.login-brand {
  position: relative;
  overflow: hidden;
  color: #f6f1e6;
  padding: 64px;
  background:
    repeating-linear-gradient(transparent, transparent 31px, rgba(215, 181, 106, 0.16) 32px),
    var(--forest);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 18px;
}
.login-brand::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 48px;
  width: 2px;
  background: rgba(196, 92, 78, 0.7);
}
.brand-kicker { letter-spacing: 0.18em; font-size: 12px; color: #d7b56a; }
.brand-title {
  font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", serif;
  font-size: 72px;
  line-height: 0.95;
  font-weight: 600;
}
.brand-copy { max-width: 420px; font-size: 18px; color: #efe6d6; }
.brand-points { margin: 8px 0 0; padding: 0; list-style: none; color: #d9d0c2; }
.brand-points li { padding: 6px 0 6px 16px; position: relative; }
.brand-points li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d7b56a;
  position: absolute;
  left: 0;
  top: 14px;
}
.login-panel { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(420px, 100%); display: grid; gap: 16px; }
.eyebrow { color: var(--brass); font-size: 13px; letter-spacing: 0.08em; }
.auth-card h1 { font-size: 32px; font-weight: 650; }
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #ddd4c6;
  background: white;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 42px;
  outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #9a7433; box-shadow: 0 0 0 3px rgba(154, 116, 51, 0.15); }
.form-error { color: var(--red); font-size: 13px; }
.form-error[hidden] { display: none; }

.btn {
  border: 1px solid transparent;
  background: var(--forest);
  color: #f6f1e6;
  border-radius: 999px;
  min-height: 40px;
  padding: 0 16px;
}
.btn:hover { background: var(--forest-2); }
.btn.ghost { background: transparent; color: var(--ink); border-color: #ddd4c6; }
.btn.ghost:hover { background: white; }
.btn.danger { background: transparent; color: var(--red); border-color: #efd0cc; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
  line-height: 1;
}

.app { min-height: 100vh; display: grid; grid-template-columns: 232px 1fr; }
.sidebar {
  background: var(--forest);
  color: #f4efe4;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #d7b56a;
  color: var(--forest);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 22px;
}
.brand-name { font-weight: 650; }
.brand-sub { color: #c9c0b2; font-size: 12px; }
.nav { display: grid; gap: 4px; }
.nav-btn {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  color: #e7e0d4;
}
.nav-btn.active, .nav-btn:hover { background: rgba(215, 181, 106, 0.16); color: #f8edd4; }
.side-foot { margin-top: auto; color: #b7b0a4; font-size: 12px; padding: 0 8px 8px; }
.main { padding: 22px 28px 40px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 18px; }
.top-title { font-size: 20px; font-weight: 650; }
.top-actions, .page-actions, .row-actions, .modal-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.user-chip { color: var(--muted); font-size: 13px; }
.page { display: grid; gap: 16px; }
.page-head { display: flex; justify-content: space-between; gap: 12px; align-items: end; }
.page-title { font-size: 28px; letter-spacing: -0.03em; }
.grid-4, .split, .account-grid, .master-grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split, .master-grid { grid-template-columns: 1.2fr 0.8fr; }
.account-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.stat, .panel, .account-card, .onboarding {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.stat { padding: 16px 18px; }
.stat-label, .panel-title, .eyebrow { color: var(--muted); }
.stat-value { font-size: 28px; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; margin-top: 6px; }
.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }
.stat-note, .muted, .sub { color: var(--muted); font-size: 13px; }
.panel { padding: 16px 18px 18px; }
.panel-title, .account-card header { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 12px; }
.panel h2, .account-card h2 { font-size: 16px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters .field { min-width: 140px; }
.filters .grow { flex: 1; min-width: 180px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; }
td, th { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; }
.summary { font-weight: 600; }
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  background: var(--brass-soft);
}
.badge.income { color: var(--green); background: #e5f4eb; }
.badge.expense { color: var(--red); background: #fbeceb; }
.badge.transfer { color: #3f4d6b; background: #e8eef8; }
.badge.reversal, .money.reversal { color: #8a1f2b; }
.badge.reversal { background: #fde8ea; }
.money { font-variant-numeric: tabular-nums; font-weight: 650; }
.money.income { color: var(--green); }
.money.expense { color: var(--red); }
.money.transfer { color: #3f4d6b; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.empty { padding: 28px 8px; color: var(--muted); }
.seg { display: flex; padding: 4px; background: #f6f1e7; border-radius: 999px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 999px; min-height: 34px; }
.seg button.active { background: var(--forest); color: #f6f1e6; }
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(23, 33, 28, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}
.modal {
  width: min(560px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { font-size: 20px; }
.months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; }
.month { text-align: center; }
.month-cols { height: 96px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.col { width: 7px; border-radius: 4px 4px 0 0; min-height: 0; }
.col.income { background: var(--green); }
.col.expense { background: var(--red); }
.month-label { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bars { display: grid; gap: 8px; }
.bar-row, .account-line, .master-item { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px; align-items: center; }
.account-line, .master-item { grid-template-columns: 1fr auto; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bar-track { height: 8px; background: #f3eee4; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; }
.bar-fill.income { background: var(--green); }
.bar-fill.expense { background: var(--red); }
.bar-label, .bar-value { font-size: 13px; }
.bar-value, .account-line strong { font-variant-numeric: tabular-nums; }
.kind-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--brass); }
.kind-dot.cash { background: #9a7433; }
.kind-dot.bank { background: #1d7a4a; }
.kind-dot.alipay { background: #1677ff; }
.kind-dot.wechat { background: #16a34a; }
.account-card { padding: 16px; display: grid; gap: 8px; }
.account-card .balance { font-size: 26px; font-variant-numeric: tabular-nums; }
.account-card.archived { opacity: 0.62; }
.onboarding { padding: 18px; }
.steps { margin: 10px 0 0; padding-left: 18px; }
.steps li + li { margin-top: 4px; }
.master-list { display: grid; }
.master-item.archived strong { color: var(--muted); text-decoration: line-through; }
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: var(--forest);
  color: white;
  border-radius: 12px;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 30;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--red); }
.help { font-size: 13px; color: var(--muted); }

@media (max-width: 980px) {
  .grid-4, .split, .master-grid { grid-template-columns: 1fr 1fr; }
  .months { grid-template-columns: repeat(6, minmax(0, 1fr)); row-gap: 12px; }
}
@media (max-width: 860px) {
  .login, .app { grid-template-columns: 1fr; }
  .login-brand { min-height: 280px; padding: 32px; }
  .brand-title { font-size: 56px; }
  .sidebar { position: sticky; top: 0; z-index: 5; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; }
  .nav { display: flex; }
  .nav-btn { white-space: nowrap; }
  .side-foot, .brand-sub { display: none; }
  .main { padding: 16px; }
  .grid-4, .split, .master-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
@media print {
  .sidebar, .topbar, .page-actions, .filters, .btn, .toast { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  body { background: white; }
}
