:root {
  --bg: #f3f0e8;
  --bg-deep: #e8e2d4;
  --ink: #1c2a22;
  --muted: #5c6b62;
  --line: #cfc6b4;
  --card: #fffdf8;
  --accent: #1f6b4f;
  --accent-2: #c45c26;
  --income: #1f6b4f;
  --expense: #b33a3a;
  --warn: #a67c00;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(28, 42, 34, 0.08);
  --font: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "SimSun", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #dff0e6 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #f7e6d6 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; }

.site-header {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(243, 240, 232, 0.85);
  border-bottom: 1px solid rgba(207, 198, 180, 0.7);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 0; }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand-mark {
  width: 2.4rem; height: 2.4rem; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #1f6b4f, #2f8f6a);
  color: #fff; font-family: var(--display); font-weight: 700;
  box-shadow: 0 6px 16px rgba(31, 107, 79, 0.25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.05rem; }
.brand-text small { color: var(--muted); font-size: .8rem; }
.nav { display: flex; flex-wrap: wrap; gap: .35rem .9rem; align-items: center; }
.nav a { color: var(--muted); font-weight: 600; text-decoration: none; }
.nav a.on, .nav a:hover { color: var(--accent); }

.main { padding: 1.5rem 0 3rem; }
.site-footer { border-top: 1px solid var(--line); padding: 1.5rem 0 2.5rem; color: var(--muted); font-size: .9rem; }

.hero {
  display: grid; gap: 1.25rem;
  padding: 1.5rem 0 1rem;
  animation: rise .5s ease both;
}
.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: .02em;
}
.hero p { margin: 0; color: var(--muted); max-width: 40rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .9rem;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.45rem; font-weight: 700; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.stat.income .value { color: var(--income); }
.stat.expense .value { color: var(--expense); }
.stat.balance .value { color: var(--accent); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem;
  margin: 1rem 0;
  animation: rise .55s ease both;
}
.panel h2, .panel h3 { margin: 0 0 .8rem; font-family: var(--display); }
.muted { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0 1rem; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: .95rem;
}
table.data th, table.data td {
  padding: .7rem .55rem; border-bottom: 1px solid #ebe4d7; text-align: left; vertical-align: top;
}
table.data th { color: var(--muted); font-weight: 600; font-size: .82rem; white-space: nowrap; }
table.data tr:hover td { background: #faf7f0; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.amount.income { color: var(--income); }
.amount.expense { color: var(--expense); }

.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700;
  border: 1px solid transparent;
}
.badge-income { background: #e5f4ec; color: var(--income); }
.badge-expense { background: #f8e8e8; color: var(--expense); }
.badge-matched { background: #e5f4ec; color: var(--income); }
.badge-mismatch { background: #f8e8e8; color: var(--expense); }
.badge-pending { background: #fff4d6; color: var(--warn); }
.badge-unlinked { background: #eee; color: #555; }
.badge-open { background: #e5f4ec; color: var(--income); }
.badge-closed { background: #eee; color: #555; }
.badge-draft { background: #fff4d6; color: var(--warn); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 10px; padding: .55rem 1rem; font-weight: 700; cursor: pointer;
  text-decoration: none; font-size: .92rem;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: #e8f3ed; color: var(--accent); }
.btn-danger { background: var(--expense); border-color: var(--expense); }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; border-radius: 8px; }

.form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem;
}
.form-grid .full { grid-column: 1 / -1; }
label.field { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; font-weight: 600; }
label.field span { color: var(--muted); font-weight: 500; font-size: .8rem; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem .75rem; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; min-width: 140px; }

.alert {
  padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600;
}
.alert-success { background: #e5f4ec; color: var(--income); }
.alert-error { background: #f8e8e8; color: var(--expense); }
.alert-info { background: #eef4f8; color: #2a5878; }

.login-box {
  max-width: 420px; margin: 3rem auto; padding: 1.5rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-box h1 { margin-top: 0; font-family: var(--display); }

.poll-option {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem;
  background: #fff; cursor: pointer; transition: border-color .15s, background .15s;
}
.poll-option:hover, .poll-option:has(input:checked) {
  border-color: var(--accent); background: #f3faf6;
}
.poll-option input { margin-top: .25rem; }
.bar {
  height: 8px; background: #ebe4d7; border-radius: 99px; overflow: hidden; margin-top: .35rem;
}
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #1f6b4f, #3fa37a); border-radius: 99px; }

.detail-grid {
  display: grid; grid-template-columns: 1.2fr .8fr; gap: 1rem;
}
.kv { display: grid; grid-template-columns: 7rem 1fr; gap: .4rem .75rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

.name-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: .65rem;
}
.name-chip-form { margin: 0; }
.name-chip {
  width: 100%;
  min-height: 3.2rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  padding: .55rem .35rem;
  box-shadow: 0 4px 12px rgba(28,42,34,.05);
  transition: border-color .15s, transform .15s, background .15s;
}
button.name-chip:hover {
  border-color: var(--accent);
  background: #f3faf6;
  transform: translateY(-1px);
}
.name-chip.done {
  background: #e5f4ec;
  border-color: #b7dbc8;
  color: var(--income);
  cursor: default;
}
.name-chip.done small { font-weight: 600; font-size: .72rem; opacity: .85; }
.name-chip.muted-chip { opacity: .55; cursor: default; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
}
.photo-item {
  display: block;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f7f3ea;
  text-decoration: none;
  color: inherit;
  aspect-ratio: 1;
}
.photo-item img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .25s ease;
}
.photo-item:hover img { transform: scale(1.04); }
.photo-item span {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: .35rem .5rem; font-size: .75rem;
  background: linear-gradient(transparent, rgba(0,0,0,.55));
  color: #fff;
}
.admin-photo {
  aspect-ratio: auto;
  display: flex; flex-direction: column;
}
.admin-photo > a { aspect-ratio: 1; display: block; overflow: hidden; }
.admin-photo form { padding: .45rem; text-align: center; background: #fff; }

.media-list { display: flex; flex-direction: column; gap: .85rem; }
.media-card {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: .75rem;
  align-items: start;
  padding-bottom: .85rem;
  border-bottom: 1px solid #ebe4d7;
}
.media-card:last-child { border-bottom: 0; padding-bottom: 0; }
.media-thumb {
  display: block; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); aspect-ratio: 1; background: #f7f3ea;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 28, 24, 0.86);
  display: none; align-items: center; justify-content: center;
  padding: 1.5rem; cursor: zoom-out;
}
.lightbox.open { display: flex; animation: rise .2s ease; }
.lightbox img {
  max-width: min(960px, 100%);
  max-height: 88vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.lightbox .lb-caption {
  position: absolute; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  color: #fff; background: rgba(0,0,0,.45); padding: .35rem .8rem; border-radius: 999px;
  font-size: .85rem; max-width: 90%;
}
.lightbox .lb-close {
  position: absolute; top: 1rem; right: 1rem;
  border: 0; background: rgba(255,255,255,.15); color: #fff;
  width: 2.2rem; height: 2.2rem; border-radius: 999px; cursor: pointer; font-size: 1.2rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 800px) {
  .stats { grid-template-columns: 1fr; }
  .form-grid, .detail-grid, .media-card { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .kv { grid-template-columns: 5.5rem 1fr; }
}
