* {
  box-sizing: border-box;
}

:root {
  --bg: #fff3dc;
  --card: #fffaf0;
  --text: #4a3225;
  --muted: #8a6a55;
  --primary: #d8895b;
  --primary-dark: #b86c43;
  --border: #eed4ad;
  --soft: #ffe8bd;
  --danger: #e76f51;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #ffe2a8 0, transparent 28%),
    radial-gradient(circle at 90% 20%, #ffd8c7 0, transparent 24%),
    radial-gradient(circle at 50% 100%, #fff0c7 0, transparent 32%),
    var(--bg);
}

.bg-pets {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.float {
  position: absolute;
  font-size: 54px;
  opacity: 0.22;
  animation: float 5s ease-in-out infinite;
}

.p1 {
  top: 8%;
  left: 7%;
}

.p2 {
  top: 14%;
  right: 9%;
  animation-delay: 0.8s;
}

.p3 {
  bottom: 18%;
  left: 8%;
  animation-delay: 1.2s;
}

.p4 {
  bottom: 10%;
  right: 12%;
  animation-delay: 1.8s;
}

.p5 {
  top: 48%;
  left: 3%;
  animation-delay: 2.2s;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0) rotate(-4deg);
  }

  50% {
    transform: translateY(-14px) rotate(5deg);
  }
}

.app {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  margin-bottom: 24px;
}

.hero h1 {
  margin: 0;
  font-size: 46px;
  color: #7a4428;
  letter-spacing: 2px;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
}

.bubble {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fff7e8;
  border: 2px solid #f1cb8f;
  font-size: 36px;
  box-shadow: 0 8px 20px rgba(160, 103, 61, 0.15);
}

.card {
  margin-bottom: 22px;
  padding: 24px;
  border-radius: 26px;
  background: rgba(255, 250, 240, 0.94);
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(132, 84, 47, 0.12);
}

.summary {
  background: linear-gradient(135deg, #fff8e7, #ffe2bd);
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h2 {
  margin: 0;
  color: #6e3f27;
}

.tag {
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff0ca;
  color: #8a5a2d;
  border: 1px solid #f2ca84;
  font-size: 13px;
}

.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.total-box {
  padding: 20px;
  border-radius: 20px;
  background: #fffdf7;
  border: 1px solid #f2d4aa;
}

.total-box span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.total-box strong {
  font-size: clamp(20px, 4vw, 30px);
  color: #7a4428;
  overflow-wrap: anywhere;
}

.month-filter {
  width: 180px;
  flex-shrink: 0;
}

.month-filter label {
  font-size: 13px;
}

.month-filter input {
  padding: 10px 12px;
  font-size: 14px;
}

.summary-hint,
.field-hint {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.field-hint {
  margin-top: 6px;
}

.category-summary {
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--soft);
  line-height: 1.6;
}

.category-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 5px 0;
  color: #7a4428;
  font-size: 21px;
  overflow-wrap: anywhere;
}

.category-summary small {
  color: var(--muted);
}

.status {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.6;
  background: #fff0ca;
  color: #6e3f27;
  overflow-wrap: anywhere;
}

.status.error {
  background: #ffebe2;
  color: #9b3e2b;
}

.status[hidden] {
  display: none;
}

[hidden] {
  display: none !important;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.import-preview {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: var(--soft);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.import-preview p {
  margin: 0 0 12px;
}

button:focus-visible {
  outline: 3px solid var(--primary-dark);
  outline-offset: 3px;
}

.rate-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.55);
  border: 1px dashed #e5bd7e;
}

.rate-box p {
  margin: 6px 0 4px;
  line-height: 1.5;
}

.rate-box small {
  color: var(--muted);
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  margin-bottom: 7px;
  font-weight: bold;
  color: #6e3f27;
}

input,
select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fffdf8;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(216, 137, 91, 0.15);
}

.primary-btn,
.small-btn {
  border: none;
  cursor: pointer;
  transition: 0.2s ease;
}

.primary-btn {
  width: 100%;
  padding: 15px;
  border-radius: 18px;
  background: var(--primary);
  color: white;
  font-size: 17px;
  font-weight: bold;
  box-shadow: 0 8px 18px rgba(216, 137, 91, 0.25);
}

.primary-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.primary-btn:disabled,
.small-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.small-btn {
  white-space: nowrap;
  padding: 10px 13px;
  border-radius: 14px;
  background: #fff8e7;
  color: #7a4428;
  border: 1px solid #e8c17f;
}

.record-title {
  align-items: flex-end;
}

.filter {
  min-width: 180px;
}

.filter label {
  font-size: 13px;
}

.filter select {
  padding: 10px 12px;
  font-size: 14px;
}

.expense-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.expense-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  background: #fffdf8;
  border: 1px solid #f0d7b4;
  overflow-wrap: anywhere;
}

.expense-item > div:first-child {
  min-width: 0;
}

.expense-title {
  margin-bottom: 7px;
  font-weight: bold;
  color: #6e3f27;
}

.pill {
  display: inline-block;
  margin-right: 8px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ffefcc;
  color: #8a5a2d;
  font-size: 13px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.amounts {
  min-width: 150px;
  text-align: right;
  white-space: nowrap;
}

.amounts div {
  margin-bottom: 4px;
  font-weight: bold;
}

.delete-btn {
  margin-top: 8px;
  padding: 7px 11px;
  border: none;
  border-radius: 12px;
  background: var(--danger);
  color: white;
  cursor: pointer;
}

.delete-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border-radius: 20px;
  background: #fffdf8;
  border: 1px dashed #e5bd7e;
}

@media (max-width: 680px) {
  .hero {
    gap: 10px;
  }

  .hero h1 {
    font-size: 36px;
  }

  .bubble {
    width: 54px;
    height: 54px;
    font-size: 30px;
  }

  .totals,
  .form-row {
    grid-template-columns: 1fr;
  }

  .title-row,
  .rate-box,
  .expense-item {
    flex-direction: column;
    align-items: stretch;
  }

  .amounts {
    text-align: left;
  }

  .filter,
  .month-filter {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .float {
    animation: none;
  }
}
