:root {
  --primary: #B86B2C;
  --primary-deep: #9C5A24;
  --accent: #D99A4E;
  --tint: #FBF0E0;
  --soft: #FAF6EF;
  --bg: #F7F3EB;
  --stage-bg: #EAE4D8;
  --ring: rgba(184, 107, 44, .14);
  --note: #9B7FC0;
  --maintain: #D9803F;
  --card: #FFFFFF;
  --ink: #1C2430;
  --muted: #6B7787;
  --line: #E8ECF2;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .06);
}

body[data-season="spring"] {
  --primary: #3E8E5A; --primary-deep: #2F7A4B; --accent: #6BBF7A;
  --tint: #EAF5EC; --soft: #F4F9F5; --bg: #F1F7F2; --stage-bg: #E3EDE5;
  --ring: rgba(62, 142, 90, .14); --note: #8C9BC8; --maintain: #C9A227;
}
body[data-season="summer"] {
  --primary: #D9663A; --primary-deep: #BC4F2A; --accent: #F2A65A;
  --tint: #FFF0E2; --soft: #FDF7F0; --bg: #FAF5EE; --stage-bg: #EFE5D8;
  --ring: rgba(217, 102, 58, .14); --note: #A67BC0; --maintain: #3E9D8C;
}
body[data-season="autumn"] {
  --primary: #B86B2C; --primary-deep: #9C5A24; --accent: #D99A4E;
  --tint: #FBF0E0; --soft: #FAF6EF; --bg: #F7F3EB; --stage-bg: #EAE4D8;
  --ring: rgba(184, 107, 44, .14); --note: #9B7FC0; --maintain: #D9803F;
}
body[data-season="winter"] {
  --primary: #4A6B62; --primary-deep: #38564F; --accent: #7FA89B;
  --tint: #EAF2EF; --soft: #F4F8F6; --bg: #EFF5F2; --stage-bg: #E0E9E4;
  --ring: rgba(74, 107, 98, .14); --note: #7C86B5; --maintain: #B07D45;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--stage-bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

#app {
  max-width: 440px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(0, 0, 0, .06);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ---------- 登录 ---------- */
.auth-wrap {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px;
  background: #12345B url('/login-snow.jpg') center 30% / cover no-repeat;
  --primary: #1B3A6B;
  --primary-deep: #2F6FD0;
  --accent: #2F6FD0;
  --tint: #EAF1FC;
  --soft: #F4F6FA;
  --ring: rgba(47, 111, 208, .12);
}
.auth-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 28, 56, .66) 0%, rgba(10, 28, 56, .24) 42%, rgba(10, 28, 56, .70) 100%);
  pointer-events: none;
}
.auth-wrap > * { position: relative; z-index: 1; }

.auth-brand { text-align: center; color: #fff; margin-bottom: 28px; }
.auth-logo {
  width: 72px; height: 72px; border-radius: 20px;
  background: #fff; color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 800; letter-spacing: -2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.auth-brand h1 { font-size: 22px; margin: 14px 0 4px; font-weight: 700; }
.auth-brand p { margin: 0; opacity: .75; font-size: 13px; }

.auth-card {
  background: #fff; border-radius: 20px; padding: 22px 20px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .16);
}
.auth-tabs { display: flex; gap: 6px; background: #EEF1F6; padding: 4px; border-radius: 12px; margin-bottom: 20px; }
.auth-tabs button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 9px 0; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.auth-tabs button.active { background: #fff; color: var(--primary); box-shadow: 0 1px 5px rgba(0, 0, 0, .08); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 13px; font-size: 15px; color: var(--ink); background: #FBFCFE;
  outline: none; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); background: #fff;
}
.field textarea { resize: vertical; min-height: 64px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 12px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 700;
  padding: 14px; cursor: pointer; transition: opacity .15s, transform .1s;
  font-family: inherit;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: var(--soft); color: var(--primary); }
.btn-sm { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 10px; }

.auth-tip { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 0; }

/* ---------- 主界面 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep)); color: #fff;
  padding: calc(env(safe-area-inset-top, 0) + 14px) 18px 14px;
  display: flex; align-items: center; gap: 10px;
}
.topbar .mini-logo {
  width: 34px; height: 34px; border-radius: 10px; background: #fff; color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; flex: 1; }
.topbar .phone { font-size: 12px; opacity: .7; }
.topbar button {
  border: 1px solid rgba(255, 255, 255, .35); background: transparent; color: #fff;
  font-size: 12px; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-family: inherit;
}

.page { padding: 14px; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card-title {
  font-size: 12px; color: var(--muted); font-weight: 700;
  letter-spacing: .5px; margin-bottom: 12px; display: flex; align-items: center; gap: 6px;
}
.card-title .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.range-picker { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.range-picker input, .range-picker button {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 8px; padding: 5px 7px; font-size: 11px; font-family: inherit;
}
.range-picker input { width: 104px; font-size: 10px; padding: 5px 4px; }
.range-sep { color: var(--muted); font-size: 10px; }
.range-picker button { cursor: pointer; font-size: 10px; padding: 5px 6px; }

/* 汇总 */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--soft); border-radius: 12px; padding: 12px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 30px; font-weight: 800; color: var(--primary); margin-top: 2px; letter-spacing: -1px; line-height: 1.15; }
.stat .v small { font-size: 12px; font-weight: 700; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.stat.hl { background: var(--tint); }
.summary-foot {
  margin-top: 10px; font-size: 12px; color: var(--muted);
  display: flex; justify-content: space-between; gap: 8px;
}
.summary-foot b { color: var(--primary); }

/* 录入 */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button {
  flex: 1; border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 10px; padding: 9px 0; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.hint { font-size: 11px; color: var(--muted); margin: -4px 0 12px; }
.ai-box { background: var(--tint); border-radius: 12px; padding: 10px; margin-bottom: 14px; }
.ai-input-row { display: flex; gap: 6px; }
.ai-input-row input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 11px; font-size: 13px; background: #fff; color: var(--ink);
  outline: none; font-family: inherit;
}
.ai-input-row input:focus { border-color: var(--accent); }
.ai-input-row button {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--primary);
  font-size: 13px; font-weight: 700; padding: 0 11px; border-radius: 9px;
  cursor: pointer; font-family: inherit;
}
.ai-input-row button#aiParse { background: var(--primary); color: #fff; border-color: var(--primary); }
.ai-status { font-size: 11px; color: var(--primary); margin-top: 7px; }
.editor-actions { display: flex; gap: 8px; margin-top: 4px; }
.editor-actions .btn { flex: 1; }
.editor-actions .btn-ghost { flex: 0 0 84px; }

/* 列表 */
.list-head { display: flex; align-items: center; justify-content: space-between; margin: 16px 4px 10px; }
.list-head h2 { font-size: 14px; margin: 0; }
.list-head span { font-size: 12px; color: var(--muted); }
.list-head select {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 12px; padding: 6px 8px; border-radius: 8px; font-family: inherit;
  max-width: 130px;
}
.record {
  background: #fff; border-radius: 14px; padding: 13px 14px; margin-bottom: 9px;
  box-shadow: var(--shadow); border-left: 4px solid var(--accent);
}
.record.type-note { border-left-color: var(--note); }
.record.type-maintain { border-left-color: var(--maintain); }
.record.type-cost { border-left-color: var(--note); }
.record .r-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.record .r-date { font-size: 12px; color: var(--muted); font-weight: 600; }
.record .r-kind { font-size: 10px; color: var(--muted); background: var(--soft); padding: 2px 7px; border-radius: 6px; }
.record .r-main { font-size: 15px; font-weight: 700; margin-top: 5px; }
.record .r-sub { font-size: 13px; color: #445; margin-top: 3px; }
.record .r-calc {
  font-size: 12px; color: var(--primary); background: var(--tint);
  display: inline-block; padding: 3px 9px; border-radius: 7px; margin-top: 8px; font-weight: 600;
}
.record .r-note { font-size: 12px; color: var(--muted); margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.record .r-ops { float: right; display: flex; gap: 8px; }
.record .r-ops button {
  border: 0; background: transparent; color: #9AA5B4; font-size: 12px; cursor: pointer; padding: 0;
  font-family: inherit;
}
.record .r-ops button.danger { color: #D65A5A; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; font-size: 13px; }
.empty .big { font-size: 40px; opacity: .35; margin-bottom: 8px; }

.offline-bar {
  background: #FFF4E0; color: #8A5A00; font-size: 12px;
  padding: 9px 14px; text-align: center;
}

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: rgba(28, 36, 48, .92); color: #fff; padding: 10px 18px;
  border-radius: 10px; font-size: 13px; z-index: 999; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 500px) {
  #app { min-height: 100vh; }
}
