:root {
  --bg: #f3efe6;
  --ink: #1d1915;
  --muted: #7a7166;
  --card: #fffdf8;
  --line: rgba(29, 25, 21, 0.08);
  --spend: #c44b32;
  --earn: #2f7a52;
  --green: #2f7a52;
  --yellow: #c8962a;
  --backup: #c46a1d;
  --shadow: 0 10px 30px rgba(56, 40, 18, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

button,
input {
  font: inherit;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px 36px;
}

.records-entry {
  width: 100%;
  margin: 0 0 14px;
  border: 0;
  background: var(--card);
  color: var(--ink);
  border-radius: 16px;
  min-height: 48px;
  padding: 0 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 700;
}

.records-entry-arrow {
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.subhead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.subhead h2 {
  font-size: 20px;
}

.back-btn {
  border: 0;
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  min-height: 36px;
  padding: 0 14px;
  box-shadow: var(--shadow);
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0.04em;
}

.ghost-btn {
  border: 0;
  background: rgba(255, 253, 248, 0.8);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.money-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  border: 0;
  text-align: left;
  padding: 18px 16px 16px;
  border-radius: 20px;
  color: #fff;
  box-shadow: var(--shadow);
  min-height: 118px;
  position: relative;
  overflow: hidden;
}

.stat-card.spend {
  background: linear-gradient(160deg, #d86248 0%, #b13a28 100%);
}

.stat-card.earn {
  background: linear-gradient(160deg, #3e9466 0%, #246346 100%);
}

.stat-card .label {
  display: block;
  opacity: 0.85;
  font-size: 14px;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-card em {
  position: absolute;
  right: 14px;
  bottom: 12px;
  font-style: normal;
  font-size: 13px;
  opacity: 0.75;
}

.stat-card.spend {
  min-height: 138px;
}

.spend-split {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 12px;
  padding-right: 22px;
  font-size: 12px;
  line-height: 1.3;
}

.spend-split b {
  font-weight: 700;
}

.plate-block {
  margin-top: 12px;
}

.plate-label {
  margin: 0 4px 8px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.plate-card {
  background: var(--card);
  border-radius: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.plate-item {
  padding: 16px 8px;
  text-align: center;
}

.plate-item + .plate-item {
  border-left: 1px solid var(--line);
}

.plate-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.plate-item strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.plate-item.green strong { color: var(--green); }
.plate-item.yellow strong { color: var(--yellow); }
.plate-item.backup strong { color: var(--backup); }

.screw-card {
  margin-top: 12px;
  width: 100%;
  border: 0;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: inherit;
  text-align: left;
}

.screw-card span {
  color: var(--muted);
  font-size: 13px;
}

.screw-card strong {
  font-size: 26px;
  color: #4a6d8c;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 22px;
}

.action {
  border: 0;
  background: var(--card);
  color: var(--ink);
  border-radius: 14px;
  min-height: 46px;
  box-shadow: var(--shadow);
}

.action.main {
  background: #e0b03a;
  color: #1d1915;
}

.action.plate {
  background: #e0b03a;
  color: #1d1915;
}

.action.screw {
  background: #4a6d8c;
  color: #fff;
}

.action.spend {
  background: var(--spend);
  color: #fff;
}

.action.earn {
  background: var(--earn);
  color: #fff;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.list-head h2 {
  font-size: 18px;
}

.tabs {
  display: flex;
  background: rgba(255, 253, 248, 0.9);
  border-radius: 999px;
  padding: 3px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 8px;
  font-size: 13px;
}

.tab.active {
  background: var(--ink);
  color: #fff8ee;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty {
  background: var(--card);
  border-radius: 18px;
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  box-shadow: var(--shadow);
}

.record {
  background: var(--card);
  border-radius: 18px;
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.badge {
  min-width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.badge.in { background: var(--earn); }
.badge.out { background: var(--spend); }

.record h4 {
  margin: 0;
  font-size: 16px;
}

.record p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.amount {
  font-size: 18px;
  font-weight: 700;
  text-align: right;
}

.amount.in { color: var(--earn); }
.amount.out { color: var(--spend); }

.del {
  display: block;
  margin-top: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 0;
}

.mask {
  position: fixed;
  inset: 0;
  background: rgba(29, 25, 21, 0.42);
  z-index: 20;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  background: #fffdf8;
  border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  box-shadow: 0 -12px 40px rgba(29, 25, 21, 0.16);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: #ddd4c6;
  margin: 4px auto 12px;
}

.sheet h3 {
  margin-bottom: 14px;
  font-size: 20px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
  border: 1px solid #eadfce;
  background: #fff;
  border-radius: 12px;
  min-height: 46px;
  padding: 0 12px;
  font-size: 16px;
  outline: none;
}

.seg {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
}

.seg-btn {
  border: 1px solid #eadfce;
  background: #fff;
  border-radius: 12px;
  min-height: 42px;
  color: var(--muted);
}

.seg-btn.active {
  background: #e0b03a;
  border-color: #e0b03a;
  color: #1d1915;
}

.hint {
  min-height: 20px;
  margin: 0 0 12px;
  color: var(--spend);
  font-size: 13px;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28%;
  transform: translateX(-50%);
  background: rgba(29, 25, 21, 0.88);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  z-index: 30;
  font-size: 14px;
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}
