:root {
  --paper: #efe6d6;
  --paper-2: #f7f1e6;
  --rule: #d9cdb8;
  --ink: #2c241d;
  --muted: #6b5e52;
  --expense: #b3392d;
  --income: #1f6f5b;
  --gold: #c4a35a;
  --shadow: 0 12px 40px rgba(44, 36, 29, 0.12);
  --safe-b: env(safe-area-inset-bottom);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #d8cbb6; color: var(--ink); }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0.01em;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { font-family: "Songti SC", "Noto Serif SC", "STSong", serif; font-weight: 700; margin: 0; }
.muted { color: var(--muted); }
.err { color: var(--expense); }
.ok { color: var(--income); }
.warn { color: #8a5a12; background: #f3e4c4; padding: 8px 10px; border-radius: 8px; }
.link { background: none; border: 0; color: var(--ink); text-decoration: underline; padding: 0; }
.link.danger { color: var(--expense); }
.primary, .ghost, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; padding: 10px 18px; border: 1px solid var(--ink);
}
.primary { background: var(--ink); color: var(--paper); }
.ghost { background: transparent; }
.block { width: 100%; margin-top: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.boot, .login-wrap { min-height: 100dvh; display: grid; place-items: center; }
.login-book {
  width: min(420px, calc(100vw - 32px));
  background: var(--paper);
  padding: 48px 36px 40px;
  box-shadow: var(--shadow);
  border: 1px solid #cbbda6;
  background-image: repeating-linear-gradient(to bottom, transparent, transparent 31px, var(--rule) 32px);
}
.login-book h1 { font-size: 48px; margin: 8px 0 4px; }
.login-kicker { letter-spacing: 0.18em; text-transform: lowercase; color: var(--muted); margin: 0; font-size: 12px; }
.login-sub { margin: 0 0 28px; color: var(--muted); }
.login-book label { display: block; font-size: 13px; margin-bottom: 6px; }
.login-book input {
  width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--ink);
  padding: 8px 0 10px; margin-bottom: 18px; outline: none;
}
.login-book button { width: 100%; }
.shell { min-height: 100dvh; display: grid; grid-template-columns: 220px 1fr; }
.side {
  background: #2c241d; color: #efe6d6; padding: 28px 18px;
  display: flex; flex-direction: column; gap: 24px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.seal {
  width: 42px; height: 42px; border: 2px solid #c4a35a; color: #c4a35a;
  display: grid; place-items: center; font-family: "Songti SC", serif; font-size: 22px;
}
.brand small { display: block; color: #cbbda6; font-size: 12px; }
.side nav { display: flex; flex-direction: column; gap: 6px; }
.side nav button, .side-out {
  background: transparent; border: 0; color: #efe6d6; text-align: left; padding: 10px 12px; border-radius: 8px;
}
.side nav button.on, .side nav button:hover { background: rgba(239,230,214,.12); }
.side-out { margin-top: auto; color: #cbbda6; }
.paper {
  background: var(--paper);
  background-image:
    linear-gradient(90deg, #e7d3c0 0 18px, transparent 18px),
    repeating-linear-gradient(to bottom, transparent, transparent 31px, rgba(44,36,29,.06) 32px);
  padding: 28px 28px 96px 40px;
  min-height: 100dvh;
}
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.top h2 { font-size: 32px; }
.top-actions { display: flex; gap: 8px; }
.month-switch { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.month-switch button { background: none; border: 0; font-size: 22px; }
.hero-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stamp { background: var(--paper-2); border: 1px solid var(--rule); padding: 16px 18px; box-shadow: var(--shadow); }
.stamp span { display: block; font-size: 13px; color: var(--muted); }
.stamp b { display: block; font-size: 28px; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.stamp.expense b { color: var(--expense); }
.stamp.income b { color: var(--income); }
.grid-2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 12px; margin-bottom: 12px; }
.card { background: rgba(247,241,230,.86); border: 1px solid var(--rule); padding: 16px; margin-bottom: 12px; }
.card h3 { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.empty { color: var(--muted); padding: 18px 0; }
.bars { list-style: none; padding: 0; margin: 0; }
.bars li { display: grid; grid-template-columns: 88px 1fr 84px; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 14px; }
.bar { height: 8px; background: #e5d8c4; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--expense); }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--rule); }
.tx-list { list-style: none; padding: 0; margin: 0; }
.tx-list li { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.tx-list .ico { width: 36px; height: 36px; display: grid; place-items: center; background: #efe0cc; border-radius: 10px; }
.tx-list small { display: block; color: var(--muted); font-size: 12px; }
.tx-list em { font-style: normal; font-variant-numeric: tabular-nums; }
.tx-list em.expense { color: var(--expense); }
.tx-list em.income { color: var(--income); }
.tx-list em.transfer { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.filters input, .filters select, .form-grid input, .form-grid select, .card input, .card select {
  background: var(--paper-2); border: 1px solid var(--rule); padding: 8px 10px; border-radius: 8px;
}
.sum-line { color: var(--muted); margin-bottom: 12px; }
.day-group h4 { margin: 18px 0 4px; display: flex; gap: 10px; align-items: baseline; }
.day-group h4 small { color: var(--muted); font-weight: 400; font-size: 13px; font-family: inherit; }
.capture .drop {
  border: 2px dashed #b9a88e; padding: 36px 20px; text-align: center; background: rgba(247,241,230,.7); margin-bottom: 16px;
}
.capture .drop.hot { border-color: var(--ink); background: #f3e8d4; }
.review { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.review img { width: 100%; border: 1px solid var(--rule); background: #fff; }
.ai-card { border: 1px solid var(--rule); padding: 12px; margin: 12px 0; background: var(--paper-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label, .card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.span2 { grid-column: span 2; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.year-bars { display: flex; gap: 8px; align-items: flex-end; height: 180px; }
.yb { flex: 1; text-align: center; color: var(--muted); font-size: 12px; }
.yb .col { height: 150px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.yb i { display: block; width: 8px; min-height: 2px; }
.yb i.inc { background: var(--income); }
.yb i.exp { background: var(--expense); }
.day-heat { display: grid; grid-template-columns: repeat(16, 1fr); gap: 4px; }
.day-heat span { height: 14px; background: var(--expense); border-radius: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.chips span { border: 1px solid var(--rule); padding: 6px 10px; border-radius: 999px; cursor: pointer; background: var(--paper-2); }
.modal { position: fixed; inset: 0; background: rgba(44,36,29,.35); display: grid; place-items: end center; z-index: 20; }
.sheet {
  width: min(560px, 100%); background: var(--paper); padding: 20px 20px calc(20px + var(--safe-b));
  border-radius: 16px 16px 0 0; max-height: 92dvh; overflow: auto;
}
.seg { display: flex; gap: 6px; margin: 12px 0; }
.seg button { flex: 1; border: 1px solid var(--ink); background: transparent; padding: 8px; border-radius: 999px; }
.seg button.on { background: var(--ink); color: var(--paper); }
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; z-index: 30;
}
.bottom { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .paper { padding: 18px 14px 108px; background-image: repeating-linear-gradient(to bottom, transparent, transparent 31px, rgba(44,36,29,.06) 32px); }
  .hero-cards, .grid-2, .review, .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .top { flex-direction: column; align-items: stretch; }
  .bottom {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    background: #2c241d; color: #efe6d6; padding: 8px 6px calc(8px + var(--safe-b)); z-index: 10;
  }
  .bottom button { background: none; border: 0; color: #cbbda6; font-size: 12px; padding: 8px 0; }
  .bottom button.on { color: #efe6d6; }
  .fab { background: #c4a35a !important; color: #2c241d !important; border-radius: 999px; font-weight: 700; }
  .bars li { grid-template-columns: 72px 1fr 72px; }
}
