:root {
  --ink:      #1b2430;
  --paper:    #fbfaf7;
  --rule:     #dcd8cf;
  --muted:    #7a8290;
  --income:   #1f6f4f;
  --expense:  #a83b32;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 2rem 1rem 4rem;
  background: var(--paper);
  color: var(--ink);
  font-family: "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}
.wrap { max-width: 720px; margin: 0 auto; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 1.5rem; }

.summary {
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  padding: 1.25rem 0;
  margin-bottom: 2rem;
}
.balance {
  font-size: 2.75rem; font-weight: 600; letter-spacing: -0.02em;
  display: block; margin-bottom: 0.25rem;
}
.balance-label { color: var(--muted); font-size: 0.875rem; }
.totals { display: flex; gap: 2rem; margin-top: 1rem; font-size: 0.9375rem; }
.totals .income  { color: var(--income); }
.totals .expense { color: var(--expense); }

/* 页面上不止一个 form 了，所以样式按 class 挂，不再挂在 form 标签上 */
.add-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 2rem; }
.add-form .full { grid-column: 1 / -1; }
label { display: block; font-size: 0.8125rem; color: var(--muted); margin-bottom: 0.25rem; }
input, select {
  width: 100%; padding: 0.5rem 0.625rem;
  border: 1px solid var(--rule); border-radius: 3px;
  background: #fff; color: var(--ink); font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
button {
  padding: 0.625rem 1rem; border: none; border-radius: 3px;
  background: var(--ink); color: var(--paper);
  font: inherit; font-weight: 500; cursor: pointer;
}
button:hover { background: #000; }

.filters { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; align-items: center; }
.filter-form { display: flex; gap: 0.5rem; }
.filter-form select { width: auto; }
.clear-form { margin-left: auto; }

.row {
  display: grid; grid-template-columns: 4.5rem 1fr auto 2rem;
  align-items: center; gap: 0.75rem;
  padding: 0.75rem 0; border-bottom: 1px solid var(--rule);
}
.row .date  { color: var(--muted); font-size: 0.8125rem; }
.row .note  { color: var(--muted); font-size: 0.8125rem; }
.row .money { font-weight: 600; }
.row .money.income  { color: var(--income); }
.row .money.expense { color: var(--expense); }
/* 删除按钮现在被一个 form 包着，这个 form 不能占位、不能撑高 */
.del-form { display: flex; justify-content: flex-end; }
.del {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 0.25rem; font-size: 1rem; line-height: 1;
}
.del:hover { color: var(--expense); background: none; }
.empty { padding: 2.5rem 0; color: var(--muted); text-align: center; }

.danger {
  background: none; color: var(--muted);
  border: 1px solid var(--rule);
  padding: 0.5rem 0.75rem; font-size: 0.8125rem; font-weight: 400;
}
.danger:hover:not(:disabled) { background: var(--expense); color: var(--paper); border-color: var(--expense); }
.danger:disabled { opacity: 0.4; cursor: not-allowed; }

.cat { display: grid; grid-template-columns: 5rem 1fr 4.5rem; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; font-size: 0.875rem; }
.bar { height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--expense); }
h2 { font-size: 1rem; font-weight: 600; margin: 2.5rem 0 1rem; }

/* error.ejs 用 */
.error-detail { color: var(--expense); margin: 0 0 1.5rem; }
a { color: var(--ink); }

@media (max-width: 480px) {
  .add-form { grid-template-columns: 1fr; }
  .balance { font-size: 2.25rem; }
}
