:root {
  --paper: #FAF6EE;
  --paper-deep: #F2ECDF;
  --ink: #2B2620;
  --ink-soft: #6E6455;
  --ink-faint: #A79A85;
  --green: #1F6D45;
  --green-soft: #E4EFE7;
  --red: #C34A36;
  --red-soft: #F7E6E1;
  --gold: #B98A2F;
  --line: #E3DAC8;
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", "PingFang SC", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 12% 8%, rgba(185, 138, 47, 0.06), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(31, 109, 69, 0.05), transparent 45%),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(43, 38, 32, 0.025) 32px);
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
}

.login-panel {
  padding: clamp(32px, 7vh, 96px) clamp(28px, 6vw, 88px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(160deg, var(--paper) 62%, var(--paper-deep));
  border-right: 1px solid var(--line);
}

.login-brand .brand-icon { width: 44px; height: 44px; color: var(--gold); }
.login-brand h1 {
  font-family: var(--serif);
  font-weight: 900;
  font-size: clamp(30px, 3.4vw, 44px);
  margin-top: 14px;
  letter-spacing: 0.06em;
}
.brand-sub {
  color: var(--ink-soft);
  margin-top: 8px;
  letter-spacing: 0.35em;
  font-size: 14px;
}

.login-steps { margin-top: 42px; max-width: 420px; }

.step-block { margin-bottom: 22px; }
.step-block label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}
.phone-row, .code-row { display: flex; align-items: stretch; gap: 10px; }
.phone-code {
  display: flex; align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-soft);
  font-family: var(--serif);
  background: #fff;
}
input, select {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 16px;
  font-family: var(--sans);
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--gold); }
.code-row input { flex: 1; }

.btn-ghost {
  padding: 12px 18px;
  border: 1px solid var(--gold);
  border-radius: 10px;
  background: transparent;
  color: var(--gold);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-ghost:hover { background: rgba(185, 138, 47, 0.08); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  width: 100%;
  padding: 14px;
  margin-top: 6px;
  border: none;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: #423a30; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.login-msg, .entry-msg { min-height: 20px; font-size: 13px; margin-top: 10px; }
.login-msg.err, .entry-msg.err { color: var(--red); }
.login-msg.ok, .entry-msg.ok { color: var(--green); }

.login-note { margin-top: 20px; font-size: 12.5px; line-height: 1.8; color: var(--ink-faint); }

.login-art {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.art-line {
  position: absolute;
  font-family: var(--serif);
  font-weight: 900;
  color: rgba(43, 38, 32, 0.05);
  line-height: 1;
  user-select: none;
}
.art-line-1 { font-size: 34vh; top: 2%; right: 6%; }
.art-line-2 { font-size: 28vh; bottom: -4%; left: 8%; }
.art-line-3 { font-size: 16vh; top: 40%; right: 34%; color: rgba(185, 138, 47, 0.10); }

/* ---------- 主界面 ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(250, 246, 238, 0.92);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-icon { width: 26px; height: 26px; color: var(--gold); }
.topbar-title { font-family: var(--serif); font-weight: 700; font-size: 19px; letter-spacing: 0.08em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-badge { font-size: 13px; color: var(--ink-soft); }
.btn-small { padding: 7px 14px; font-size: 13px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr);
  gap: clamp(20px, 3vw, 40px);
  padding: clamp(20px, 3.5vw, 44px) clamp(20px, 4vw, 48px);
  max-width: 1240px;
  margin: 0 auto;
  align-items: start;
}

/* 汇总 */
.month-summary {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: clamp(28px, 4vw, 56px);
  margin-bottom: 26px;
}
.summary-item { display: flex; flex-direction: column; gap: 4px; }
.summary-label { font-size: 12.5px; color: var(--ink-faint); letter-spacing: 0.18em; }
.summary-num {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(22px, 2.6vw, 32px);
  font-variant-numeric: tabular-nums;
}
.summary-num.expense { color: var(--red); }
.summary-num.income { color: var(--green); }

/* 流水 */
.records-list { display: flex; flex-direction: column; gap: 20px; }
.date-group {}
.date-head {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink-soft);
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.date-head::after { content: ""; flex: 1; border-bottom: 1px dashed var(--line); }
.date-total { font-size: 12.5px; color: var(--ink-faint); }

.record-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
  transition: transform .12s, box-shadow .12s;
}
.record-row:hover { transform: translateX(3px); box-shadow: 0 2px 10px rgba(43,38,32,.06); }
.record-cat {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.record-cat.expense { background: var(--red-soft); color: var(--red); }
.record-cat.income { background: var(--green-soft); color: var(--green); }
.record-main { flex: 1; min-width: 0; }
.record-note { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-meta { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.record-amount {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.record-amount.expense { color: var(--red); }
.record-amount.income { color: var(--green); }
.record-del {
  border: none; background: none; cursor: pointer;
  color: var(--ink-faint); padding: 6px;
  border-radius: 8px;
  visibility: hidden;
  transition: color .15s, background .15s;
}
.record-row:hover .record-del { visibility: visible; }
.record-del:hover { color: var(--red); background: var(--red-soft); }
.record-del svg { width: 16px; height: 16px; display: block; }

.empty-state {
  text-align: center;
  padding: 70px 0;
  color: var(--ink-faint);
}
.empty-icon { width: 46px; height: 46px; margin-bottom: 14px; opacity: .5; }

/* 记账面板 */
.entry-col { position: sticky; top: 86px; }
.entry-card {
  background: linear-gradient(170deg, #FFFDF8, #FDF9F0);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 24px;
  box-shadow: 0 10px 30px rgba(43, 38, 32, 0.06);
}
.entry-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 18px;
}
.type-btn {
  padding: 11px;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background .15s, color .15s;
}
.type-icon { width: 15px; height: 15px; }
.type-btn.active.type-expense { background: var(--red); color: #fff; }
.type-btn.active.type-income { background: var(--green); color: #fff; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 7px;
  letter-spacing: 0.08em;
}
.amount-wrap { position: relative; }
.amount-yen {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--gold);
}
.amount-wrap input { padding-left: 38px; font-family: var(--serif); font-size: 20px; font-weight: 700; }
.amount-wrap input::placeholder { font-weight: 400; color: var(--ink-faint); }
.entry-card .btn-primary { margin-top: 4px; }

/* toast */
.toast {
  position: fixed;
  bottom: 32px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 99;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

/* 响应式 */
@media (max-width: 880px) {
  .login-view { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .layout { grid-template-columns: 1fr; }
  .entry-col { position: static; order: -1; }
}
