:root {
  --bg: #f5efe7;
  --paper: rgba(255, 252, 247, 0.92);
  --paper-solid: #fffaf3;
  --ink: #2d211c;
  --muted: #76665e;
  --line: #e6d7c9;
  --red: #b33b2e;
  --red-dark: #8d2c23;
  --gold: #d3a652;
  --green: #3c7a60;
  --shadow: 0 18px 45px rgba(75, 47, 31, 0.10);
  --radius: 22px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background:
    radial-gradient(circle at 12% 4%, rgba(211, 166, 82, 0.22), transparent 24%),
    radial-gradient(circle at 92% 1%, rgba(179, 59, 46, 0.13), transparent 20%),
    var(--bg);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0 20px 110px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 26px 2px 18px;
}

.topbar h1, .section-head h3, .modal-head h3 {
  margin: 0;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  letter-spacing: 0.04em;
}

.topbar h1 { font-size: clamp(30px, 5vw, 44px); }

.eyebrow, .section-kicker {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--red);
  font-weight: 700;
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: 240px;
  border-radius: 30px;
  padding: clamp(28px, 6vw, 58px);
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  color: white;
  background:
    linear-gradient(125deg, rgba(104, 22, 17, 0.96), rgba(179, 59, 46, 0.91)),
    repeating-linear-gradient(45deg, transparent 0 14px, rgba(255,255,255,.04) 14px 16px);
  box-shadow: 0 25px 60px rgba(116, 33, 26, .24);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
}

.hero::before { width: 330px; height: 330px; right: -110px; top: -165px; }
.hero::after { width: 190px; height: 190px; right: 70px; top: -90px; }

.hero > * { position: relative; z-index: 1; }
.hero-date { margin: 0 0 16px; opacity: .82; }
.hero h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: clamp(34px, 7vw, 62px);
  font-weight: 700;
}
.hero-copy { max-width: 650px; margin: 14px 0 0; line-height: 1.75; opacity: .88; }

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 700;
  transition: .2s ease;
}

.primary-btn {
  color: #fff;
  background: var(--red);
  box-shadow: 0 10px 24px rgba(179,59,46,.26);
}
.hero .primary-btn {
  min-width: 126px;
  color: var(--red-dark);
  background: #fff7ec;
  box-shadow: none;
}
.primary-btn:hover { transform: translateY(-1px); background: var(--red-dark); }
.hero .primary-btn:hover { background: white; }

.secondary-btn {
  color: var(--red-dark);
  background: #f6e6d9;
}
.secondary-btn:hover { background: #efd6c4; }

.ghost-btn {
  color: var(--ink);
  background: rgba(255,255,255,.64);
  border: 1px solid var(--line);
}
.ghost-btn:hover { background: white; }

.danger-btn {
  color: #9b2d25;
  background: #f9dfda;
}
.danger-btn:hover { background: #f3cbc4; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0;
}

.stat-card, .panel {
  background: var(--paper);
  border: 1px solid rgba(230, 215, 201, .9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.stat-card {
  border-radius: 20px;
  padding: 20px;
}
.stat-card span { display: block; font-size: 13px; color: var(--muted); }
.stat-card strong { display: block; margin-top: 8px; font-size: clamp(22px, 3vw, 32px); }

.panel {
  margin-top: 18px;
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 28px);
}

.reminder-panel {
  background:
    linear-gradient(135deg, rgba(255,250,243,.96), rgba(252,238,221,.94));
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.section-head h3, .modal-head h3 { font-size: 24px; }
.section-head-wrap { align-items: flex-end; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 12px;
  color: var(--red-dark);
  background: #f1d9c5;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.search-input, .select-input, .form-grid input, .form-grid select, .form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  outline: 0;
  color: var(--ink);
  background: rgba(255,255,255,.8);
  border-radius: 13px;
  padding: 12px 13px;
  transition: .2s ease;
}

.search-input { min-width: 220px; }
.select-input { width: auto; min-width: 115px; }

.search-input:focus, .select-input:focus,
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  border-color: rgba(179,59,46,.56);
  box-shadow: 0 0 0 4px rgba(179,59,46,.08);
  background: white;
}

.record-list, .reminder-list { display: grid; gap: 12px; }

.record-card, .reminder-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 15px;
  background: rgba(255,255,255,.70);
}

.record-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 15px;
  font-size: 22px;
}
.record-mark.paid { color: #9d352b; background: #f6d9d2; }
.record-mark.received { color: #2e7256; background: #d8eadf; }

.record-main { min-width: 0; }
.record-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 5px;
}
.record-title strong { font-size: 17px; }
.record-meta, .record-remark {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.record-remark { margin-top: 6px; white-space: pre-wrap; }

.record-side {
  text-align: right;
}
.record-amount {
  display: block;
  font-size: 20px;
  font-weight: 800;
}
.record-amount.paid { color: var(--red); }
.record-amount.received { color: var(--green); }

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}
.mini-btn {
  border: 0;
  border-radius: 10px;
  padding: 6px 9px;
  color: var(--muted);
  background: #f2e9e1;
}
.mini-btn:hover { color: var(--ink); background: #eadccf; }
.mini-btn.danger { color: #a13228; }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.status-pill.pending { color: #8a5c13; background: #f7e7bd; }
.status-pill.done { color: #2f7457; background: #dceee4; }
.status-pill.overdue { color: #9e3028; background: #f7d7d2; }

.reminder-card.today {
  border-color: rgba(179,59,46,.35);
  background: #fff6ed;
}
.reminder-days {
  min-width: 66px;
  text-align: center;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}
.reminder-days strong { display: block; font-size: 25px; }

.note-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.note-card {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.78), rgba(252,245,235,.88));
}
.note-card h4 { margin: 0 0 8px; font-size: 18px; }
.note-content {
  margin: 0;
  color: var(--muted);
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  flex: 1;
}
.note-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: end;
  margin-top: 18px;
}
.note-tag { color: var(--red); font-size: 12px; font-weight: 700; }
.note-date { color: var(--muted); font-size: 12px; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 38px 18px;
  color: var(--muted);
  border: 1px dashed #d9c6b5;
  border-radius: 16px;
  background: rgba(255,255,255,.34);
}
.empty-state strong { display: block; margin-bottom: 6px; color: var(--ink); }

.data-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
}
.data-panel h3 { margin: 0; }
.data-panel p:not(.section-kicker) { margin: 8px 0 0; color: var(--muted); line-height: 1.6; }
.integration-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 13px;
}
.integration-status strong { color: var(--green); }
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(60,122,96,.12);
}

.data-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.file-btn { display: inline-flex; align-items: center; }
.file-btn input { display: none; }

.modal {
  width: min(700px, calc(100% - 24px));
  max-height: calc(100vh - 28px);
  border: 0;
  padding: 0;
  border-radius: 24px;
  background: transparent;
}
.modal::backdrop {
  background: rgba(45,33,28,.52);
  backdrop-filter: blur(6px);
}
.modal-card {
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  background: var(--paper-solid);
  box-shadow: 0 30px 80px rgba(37,23,18,.28);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: #f1e6dc;
  font-size: 26px;
  line-height: 1;
}
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  margin-bottom: 18px;
  border-radius: 15px;
  background: #eee2d7;
}
.segmented input { display: none; }
.segmented span {
  display: block;
  text-align: center;
  padding: 11px;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 700;
}
.segmented input:checked + span {
  color: white;
  background: var(--red);
  box-shadow: 0 7px 16px rgba(179,59,46,.2);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label { display: grid; gap: 7px; }
.form-grid label > span, .check-row span { color: var(--muted); font-size: 13px; font-weight: 700; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid textarea { resize: vertical; }

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
}
.check-row input { width: 18px; height: 18px; accent-color: var(--red); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 92px;
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 30px);
  padding: 12px 18px;
  color: white;
  background: rgba(45,33,28,.94);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
  box-shadow: 0 12px 30px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.bottom-nav {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 28px));
  display: none;
  grid-template-columns: 1fr 72px 1fr;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid rgba(230,215,201,.92);
  border-radius: 24px;
  background: rgba(255,250,243,.88);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 40px rgba(75,47,31,.18);
}
.nav-item, .nav-add {
  border: 0;
  background: transparent;
}
.nav-item {
  display: grid;
  place-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
}
.nav-item span { font-size: 18px; }
.nav-add {
  width: 52px;
  height: 52px;
  justify-self: center;
  border-radius: 50%;
  color: white;
  background: var(--red);
  font-size: 28px;
  box-shadow: 0 10px 22px rgba(179,59,46,.3);
}

@media (max-width: 860px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .note-grid { grid-template-columns: repeat(2, 1fr); }
  .section-head-wrap { align-items: stretch; flex-direction: column; }
  .toolbar { justify-content: flex-start; }
  .data-panel { align-items: stretch; flex-direction: column; }
  .data-actions { justify-content: flex-start; }
}

@media (max-width: 640px) {
  .app-shell { padding: 0 12px 112px; }
  .topbar { padding: 18px 2px 13px; }
  .topbar .ghost-btn { padding: 10px 14px; font-size: 13px; }
  .hero { min-height: 265px; align-items: stretch; flex-direction: column; padding: 28px 22px; }
  .hero .primary-btn { align-self: flex-start; }
  .stats-grid { gap: 9px; margin: 12px 0; }
  .stat-card { padding: 15px; }
  .panel { margin-top: 12px; padding: 17px 14px; border-radius: 19px; }
  .section-head { align-items: flex-start; }
  .toolbar { width: 100%; }
  .search-input { min-width: 100%; }
  .select-input { flex: 1; }
  .record-card, .reminder-card {
    grid-template-columns: auto 1fr;
    align-items: start;
  }
  .record-side {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-left: 62px;
    text-align: left;
  }
  .card-actions { margin-top: 0; }
  .note-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .modal-card { padding: 20px 16px; }
  .bottom-nav { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
