/* ============================================================
   够花 — 样式表
   配色 token：8 套主题 × 深浅两种模式，全部用 CSS 变量
   ============================================================ */

:root {
  --page: #EDEAE4;
  --bg: #F6F5F2;
  --card: #FFFFFF;
  --ink: #1A1C20;
  --sub: #787D85;
  --mute: #A0A5AC;
  --line: #E8E6E1;
  --soft: #F1EFEA;
  --sheet: #FBFAF8;
  --field: #F7F6F3;
  --shadow: 0 8px 30px -12px rgba(20, 22, 26, .28);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

/* ---------- 深色底 ---------- */
body[data-mode="dark"] {
  --page: #0B0C0E;
  --bg: #16181C;
  --card: #1E2126;
  --ink: #ECE9E3;
  --sub: #8E939B;
  --mute: #6C717A;
  --line: #2A2D33;
  --soft: #212429;
  --sheet: #1E2126;
  --field: #1E2126;
  --shadow: 0 10px 34px -12px rgba(0, 0, 0, .65);
}

/* ---------- 8 套强调色 ---------- */
body[data-accent="ink"][data-mode="light"]      { --accent: #31527A; --accent-ink: #FFFFFF; --accent-soft: #E9EEF5; }
body[data-accent="ink"][data-mode="dark"]       { --accent: #9DBBDA; --accent-ink: #14161A; --accent-soft: rgba(157,187,218,.13); }

body[data-accent="indigo"][data-mode="light"]   { --accent: #4B4278; --accent-ink: #FFFFFF; --accent-soft: #ECEAF4; }
body[data-accent="indigo"][data-mode="dark"]    { --accent: #B3A9DE; --accent-ink: #14161A; --accent-soft: rgba(179,169,222,.13); }

body[data-accent="mauve"][data-mode="light"]    { --accent: #6E4A62; --accent-ink: #FFFFFF; --accent-soft: #F2EAEF; }
body[data-accent="mauve"][data-mode="dark"]     { --accent: #CFA3BE; --accent-ink: #14161A; --accent-soft: rgba(207,163,190,.13); }

body[data-accent="brick"][data-mode="light"]    { --accent: #8C4A48; --accent-ink: #FFFFFF; --accent-soft: #F5EAE9; }
body[data-accent="brick"][data-mode="dark"]     { --accent: #D69C99; --accent-ink: #14161A; --accent-soft: rgba(214,156,153,.13); }

body[data-accent="ochre"][data-mode="light"]    { --accent: #9A5B33; --accent-ink: #FFFFFF; --accent-soft: #F6EBE1; }
body[data-accent="ochre"][data-mode="dark"]     { --accent: #D9A07C; --accent-ink: #14161A; --accent-soft: rgba(217,160,124,.13); }

body[data-accent="gold"][data-mode="light"]     { --accent: #7A6A2F; --accent-ink: #FFFFFF; --accent-soft: #F3EEDF; }
body[data-accent="gold"][data-mode="dark"]      { --accent: #CDBB7A; --accent-ink: #14161A; --accent-soft: rgba(205,187,122,.13); }

body[data-accent="graphite"][data-mode="light"] { --accent: #5B5F66; --accent-ink: #FFFFFF; --accent-soft: #EEEEEF; }
body[data-accent="graphite"][data-mode="dark"]  { --accent: #B9BDC4; --accent-ink: #14161A; --accent-soft: rgba(185,189,196,.13); }

body[data-accent="mono"][data-mode="light"]     { --accent: #2B2B2B; --accent-ink: #FFFFFF; --accent-soft: #EFEFEF; }
body[data-accent="mono"][data-mode="dark"]      { --accent: #D8D8D8; --accent-ink: #14161A; --accent-soft: rgba(216,216,216,.13); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
input, textarea { font: inherit; color: inherit; touch-action: manipulation; }
b, strong { font-weight: 600; }

input[type="month"] { -webkit-appearance: none; appearance: none; }
input[type="month"]::-webkit-date-and-time-value { text-align: right; }
input[type="month"]::-webkit-calendar-picker-indicator { opacity: .45; margin-left: 4px; }
.ends-select {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13.5px;
  color: var(--sub);
  text-align: right;
  text-align-last: right;
  max-width: 140px;
  padding-right: 2px;
}

.num, .amt, .hero-num, .tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ============================ 外壳 ============================ */
.app {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 600px) {
  .app { height: 100vh; height: 100dvh; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.views { flex: 1; position: relative; overflow: hidden; }

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 26px calc(24px + var(--safe-b));
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.view.on { opacity: 1; visibility: visible; transform: none; }

/* ============================ 顶部 ============================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-t)) 26px 22px;
}
.brand {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .14em;
  text-indent: .14em;
}
.period {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sub);
}
.period svg { width: 13px; height: 13px; opacity: .7; }

/* ============================ 首页 ============================ */
.hero { padding-bottom: 22px; }
.hero-label {
  font-size: 11.5px;
  letter-spacing: .14em;
  color: var(--sub);
  margin-bottom: 10px;
}
.hero-num {
  display: flex;
  align-items: flex-start;
  gap: 3px;
  letter-spacing: -.03em;
  white-space: nowrap;
}
.hero-num .cur { font-size: 20px; font-weight: 500; margin-top: 11px; opacity: .4; }
.hero-num .int { font-size: 46px; font-weight: 600; line-height: 1; }
.hero-num .dec { font-size: 20px; font-weight: 500; opacity: .36; align-self: flex-end; margin-bottom: 5px; }
.hero-num.long .int { font-size: 38px; }
.hero-num.long .dec { font-size: 17px; }
.hero-num.xlong .int { font-size: 30px; letter-spacing: -.02em; }
.hero-num.xlong .dec { font-size: 15px; }
.hero-num.xlong .cur { font-size: 17px; margin-top: 8px; }

.hero-split {
  margin-top: 13px;
  font-size: 12.5px;
  color: var(--sub);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.hero-split em { font-style: normal; font-weight: 600; color: var(--ink); }

/* 未填现金时的提示条 */
.setup {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  margin-bottom: 20px;
  width: 100%;
  text-align: left;
  line-height: 1.5;
}
.setup svg { width: 15px; height: 15px; flex: 0 0 15px; opacity: .8; }

/* 区块标题 */
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 2px 0 2px;
  margin-top: 4px;
}
.sec-head .t { font-size: 11.5px; letter-spacing: .14em; color: var(--sub); }
.sec-head .n { font-size: 11.5px; color: var(--mute); }

/* 清单 */
.list { margin-top: 2px; }

.row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 0;
  position: relative;
  width: 100%;
  text-align: left;
  transition: opacity .2s ease;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0; left: 36px; right: 0;
  height: 1px;
  background: var(--line);
}
.row:active { opacity: .55; }

.tick {
  width: 23px; height: 23px;
  flex: 0 0 23px;
  border-radius: 50%;
  border: 1.6px solid #CFCBC4;
  display: grid;
  place-items: center;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
body[data-mode="dark"] .tick { border-color: #43474E; }
.tick svg { width: 12px; height: 12px; stroke: none; fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.row.paid .tick { background: var(--accent); border-color: var(--accent); }
.row.paid .tick svg { stroke: var(--accent-ink); }

.tick.pop { transform: scale(.86); }

.row-meta { flex: 1; min-width: 0; }
.row-name {
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: .01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-sub {
  font-size: 11.5px;
  margin-top: 4px;
  color: var(--sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.amt {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  text-align: right;
  flex: 0 0 auto;
  transition: opacity .2s ease;
}
.row.paid .amt { opacity: .34; font-weight: 500; }
.row.paid .row-name { color: var(--sub); }

/* 清单底部两个入口 */
.list-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 0 0 36px;
  font-size: 12.5px;
  letter-spacing: .02em;
  color: var(--mute);
}
.list-actions button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  color: inherit;
}
.list-actions svg { width: 12px; height: 12px; }
.list-actions button:active { opacity: .5; }

/* 空状态 */
.empty {
  padding: 34px 0 26px;
  text-align: center;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.7;
}

/* 总结条 */
.punch {
  margin-top: 18px;
  padding: 13px 15px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  line-height: 1.6;
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.punch .bar { width: 2px; border-radius: 2px; background: currentColor; opacity: .4; flex: 0 0 2px; }
.punch b { font-variant-numeric: tabular-nums; font-weight: 600; }

/* 迷你趋势 */
.spark { padding: 20px 0 4px; }
.spark .hd {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.spark .hd .t { font-size: 11px; letter-spacing: .12em; color: var(--mute); }
.spark .hd .v { font-size: 11px; color: var(--mute); }
.spark svg { display: block; width: 100%; height: 44px; overflow: visible; }

/* ============================ 趋势页 ============================ */
.trend-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 132px;
  padding: 16px 0 0;
}
.trend-bars .b {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 7px;
  height: 100%;
}
.trend-bars .bar-fill {
  width: 100%;
  border-radius: 5px 5px 3px 3px;
  background: var(--accent);
  opacity: .82;
  min-height: 3px;
  transition: height .4s cubic-bezier(.2,.8,.2,1);
}
.trend-bars .b.dim .bar-fill { opacity: .32; }
.trend-bars .lb { font-size: 9.5px; color: var(--mute); letter-spacing: .02em; }

.kv-list { margin-top: 6px; }
.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  position: relative;
  gap: 12px;
}
.kv + .kv::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--line);
}
.kv .k { font-size: 14px; }
.kv .k small { display: block; font-size: 11.5px; color: var(--sub); margin-top: 3px; }
.kv .v { font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.kv .v.sm { font-size: 13px; font-weight: 500; color: var(--sub); }

.note-line {
  margin-top: 14px;
  font-size: 12px;
  color: var(--sub);
  line-height: 1.75;
}

/* ============================ 设置页 ============================ */
.group { margin-top: 26px; }
.group:first-of-type { margin-top: 6px; }
.group-title {
  font-size: 11.5px;
  letter-spacing: .14em;
  color: var(--sub);
  margin-bottom: 10px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.swatch {
  position: relative;
  height: 58px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 10.5px;
  color: var(--sub);
  letter-spacing: .04em;
  transition: border-color .16s, background .16s;
}
.swatch i {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: block;
}
.swatch.on {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent-soft);
}
.swatch.on::after {
  content: "";
  position: absolute;
  top: 7px; right: 7px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  background: var(--soft);
}
.segmented button {
  flex: 1;
  padding: 9px 0;
  border-radius: 9px;
  font-size: 13px;
  color: var(--sub);
  transition: background .16s, color .16s;
}
.segmented button.on {
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
body[data-mode="dark"] .segmented button.on { background: #2F333A; box-shadow: none; }

.btn-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 0;
  font-size: 14px;
  position: relative;
}
.btn-line + .btn-line::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--line);
}
.btn-line .arrow { width: 14px; height: 14px; opacity: .3; }
.btn-line.danger { color: #B4553F; }
body[data-mode="dark"] .btn-line.danger { color: #D69C99; }

.sub-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.sub-form input { flex: 1; min-width: 0; }
.footnote {
  font-size: 11.5px;
  color: var(--mute);
  line-height: 1.7;
  margin-top: 10px;
}

/* ============================ 底部导航 ============================ */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 15px 30px calc(18px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--bg);
  position: relative;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--mute);
  padding: 2px 14px;
  transition: color .16s;
}
.tab svg {
  width: 22px; height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab.on { color: var(--accent); }

/* ============================ 弹层 ============================ */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(16, 18, 22, .44);
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility .22s;
  z-index: 40;
}
.scrim.on { opacity: 1; visibility: visible; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 560px;
  transform: translate(-50%, 110%);
  visibility: hidden;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility .28s;
  background: var(--sheet);
  border-radius: 26px 26px 0 0;
  border-top: 1px solid var(--line);
  padding: 10px 24px calc(26px + var(--safe-b));
  z-index: 41;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -18px 50px -22px rgba(10, 12, 16, .5);
}
.sheet.on { transform: translate(-50%, 0); visibility: visible; }
.sheet.flush { padding-bottom: 0; }
.sheet-foot {
  position: sticky;
  bottom: 0;
  background: var(--sheet);
  padding: 14px 0 calc(24px + var(--safe-b));
  margin-top: 16px;
}
.sheet-foot::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: -18px;
  height: 18px;
  background: linear-gradient(to bottom, rgba(0,0,0,0), var(--sheet));
  pointer-events: none;
}
.sheet-foot .btn { margin-top: 0; }
@media (min-width: 600px) { .sheet { border-radius: 26px; bottom: 3vh; } }

.grab {
  width: 36px; height: 4px;
  border-radius: 4px;
  background: var(--line);
  margin: 0 auto 16px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.sheet-head .ttl { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.sheet-head .side { font-size: 12px; color: var(--sub); display: flex; align-items: center; gap: 5px; }
.sheet-head .side svg { width: 13px; height: 13px; }
.sheet-head .side.danger { color: #B4553F; }
body[data-mode="dark"] .sheet-head .side.danger { color: #D69C99; }

/* 金额编辑 */
.amt-edit { padding-bottom: 4px; }
.amt-edit .lab2 { font-size: 11px; letter-spacing: .12em; color: var(--mute); }
.ednum {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-top: 7px;
  border-bottom: 1.5px dashed var(--line);
  padding-bottom: 9px;
}
.ednum .c { font-size: 19px; font-weight: 500; opacity: .4; }
.ednum input {
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -.028em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  border: 0;
  outline: 0;
  background: none;
  width: 100%;
  min-width: 0;
  padding: 0;
}
.ednum input::placeholder { color: var(--mute); opacity: .55; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.chip {
  font-size: 13px;
  letter-spacing: .01em;
  padding: 8px 14px;
  border-radius: 9px;
  background: var(--soft);
  color: var(--sub);
  font-variant-numeric: tabular-nums;
  transition: background .14s, color .14s;
}
.chip.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chiplab { font-size: 11px; letter-spacing: .1em; color: var(--mute); margin-top: 11px; }

/* 输入框 */
.field {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1.4px solid var(--line);
  background: var(--field);
  outline: 0;
  transition: border-color .16s;
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--mute); }
textarea.field { height: 76px; padding: 12px 14px; resize: none; line-height: 1.5; }

.lab3 { font-size: 11px; letter-spacing: .12em; color: var(--mute); margin: 13px 0 7px; }

/* 设置行 */
.srow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  border-top: 1px solid var(--line);
  gap: 12px;
}
.srow:first-child { border-top: 0; }
.srow .k { font-size: 14px; }
.srow .v { font-size: 13.5px; color: var(--sub); display: flex; align-items: center; gap: 6px; }
.srow .v svg { width: 13px; height: 13px; opacity: .5; }

.switch {
  width: 44px; height: 26px;
  border-radius: 20px;
  background: var(--line);
  position: relative;
  flex: 0 0 44px;
  transition: background .18s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
  transition: transform .18s;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); }

/* 按钮 */
.btn {
  width: 100%;
  height: 50px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .03em;
  margin-top: 18px;
  transition: opacity .16s, transform .1s;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .35; }
.btn.ghost {
  background: none;
  color: var(--sub);
  border: 1.4px solid var(--line);
  font-weight: 500;
}
.acts { display: flex; gap: 10px; margin-top: 18px; }
.acts .btn { margin-top: 0; }
.acts .ghost { flex: 1; }
.acts .primary { flex: 1.4; }

/* AI 结果卡 */
.heard {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--soft);
  margin-bottom: 16px;
}
.heard .q { font-size: 13.5px; line-height: 1.5; color: var(--sub); word-break: break-word; }
.heard .q b { color: var(--ink); }
.heard .mic { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 2px; opacity: .45; }

.card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2px 16px;
  background: var(--card);
}
.card .r {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  gap: 16px;
}
.card .r + .r { border-top: 1px solid var(--line); }
.card .k { font-size: 11.5px; letter-spacing: .1em; color: var(--mute); flex: 0 0 auto; }
.card .v { font-size: 14.5px; font-weight: 500; text-align: right; word-break: break-word; }
.card .v.big { font-size: 19px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ 登录 / 首启 ============================ */
.auth {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--bg);
  z-index: 60;
  gap: 22px;
}
.auth.hide { display: none; }
.auth .mark {
  font-size: 27px;
  font-weight: 600;
  letter-spacing: .18em;
  text-indent: .18em;
  color: var(--ink);
}
.auth .tip { font-size: 13px; color: var(--sub); text-align: center; line-height: 1.7; max-width: 300px; }
.auth form { width: 100%; max-width: 300px; display: flex; flex-direction: column; gap: 12px; }
.auth .err { font-size: 12.5px; color: #B4553F; min-height: 18px; text-align: center; }
body[data-mode="dark"] .auth .err { color: #D69C99; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(94px + var(--safe-b));
  transform: translate(-50%, 10px);
  background: rgba(28, 30, 34, .93);
  color: #fff;
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 12px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, transform .2s, visibility .2s;
  z-index: 80;
  max-width: 76vw;
  text-align: center;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.5);
  backdrop-filter: blur(6px);
}
.toast.on { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 自定义确认框 */
.modal-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(16, 18, 22, .46);
  opacity: 0;
  visibility: hidden;
  transition: opacity .18s ease, visibility .18s;
  z-index: 70;
}
.modal-wrap.on { opacity: 1; visibility: visible; }
.modal {
  width: 100%;
  max-width: 300px;
  background: var(--sheet);
  border-radius: 20px;
  padding: 22px 20px 16px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .55);
  transform: scale(.97);
  transition: transform .18s ease;
}
.modal-wrap.on .modal { transform: scale(1); }
.modal-ttl { font-size: 15.5px; font-weight: 600; letter-spacing: .01em; }
.modal-txt { font-size: 13px; color: var(--sub); line-height: 1.6; margin-top: 7px; }
.modal-acts { display: flex; gap: 9px; margin-top: 18px; }
.modal-acts .btn { margin-top: 0; height: 44px; font-size: 14px; }
.modal-acts .ghost { flex: 1; }
.modal-acts .danger {
  flex: 1;
  background: #A8402F;
  color: #fff;
  font-weight: 600;
}
body[data-mode="dark"] .modal-acts .danger { background: #B84A3E; }

/* ================= 决策层：曲线 + 试算 ================= */
.grid { display: flex; flex-direction: column; }
.grid > [data-area="chart"] { order: 5; margin-top: 26px; }
.grid > [data-area="sechead"] { order: 2; margin-top: 4px; }
.grid > [data-area="list"] { order: 3; }
.grid > [data-area="actions"] { order: 4; }
.grid > [data-area="insight"] { order: 1; margin-top: 10px; }
@media (min-width: 900px) {
  .app { max-width: 1080px; }
  .grid {
    display: grid;
    grid-template-columns: 396px minmax(0, 1fr);
    grid-template-areas:
      "hero    chart"
      "setup   chart"
      "sim     chart"
      "insight chart"
      "sechead chart"
      "list    chart"
      "actions chart";
    grid-template-rows: auto auto auto auto auto 1fr auto;
    gap: 0 46px;
    align-items: start;
  }
  .view { padding-left: 34px; padding-right: 34px; }
  .grid > [data-area="hero"] { grid-area: hero; }
  .grid > [data-area="setup"] { grid-area: setup; }
  .grid > [data-area="sim"] { grid-area: sim; }
  .grid > [data-area="insight"] { grid-area: insight; }
  .grid > [data-area="sechead"] { grid-area: sechead; }
  .grid > [data-area="list"] { grid-area: list; }
  .grid > [data-area="actions"] { grid-area: actions; }
  .grid > [data-area="chart"] { grid-area: chart; margin-top: 0; order: 0; }
  .chartcard { padding: 22px 22px 18px; }
  .chartcard svg { height: 330px; }
  .chartcard .chart-hd .t { font-size: 12px; }
  .chart-legend { margin-top: 16px; }
}

.sim {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 15px 13px;
  background: var(--card);
  margin-bottom: 22px;
}
.sim-hint { font-size: 11.5px; letter-spacing: .06em; color: var(--mute); margin-bottom: 10px; }
.sim-row { display: flex; align-items: center; gap: 8px; }
.sim-cur { font-size: 17px; opacity: .38; font-weight: 500; }
.sim-in {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  font-size: 24px; font-weight: 600; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.sim-in::placeholder { color: var(--mute); opacity: .5; font-weight: 500; }
.sim-go {
  flex: 0 0 auto; padding: 9px 15px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13.5px; font-weight: 600; letter-spacing: .02em;
}
.sim-go:active { opacity: .8; }
.sim-res { font-size: 12.5px; line-height: 1.65; margin-top: 11px; color: var(--sub); display: none; }
.sim-res.on { display: block; }
.sim-res b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sim-res.bad b { color: #B4553F; }
body[data-mode="dark"] .sim-res.bad b { color: #D69C99; }

.chartcard {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 18px 14px;
  background: var(--card);
}
.chart-hd { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.chart-hd .t { font-size: 11.5px; letter-spacing: .12em; color: var(--sub); }
.chart-hd .n { font-size: 11.5px; color: var(--mute); }
.chartcard svg { display: block; width: 100%; height: 210px; overflow: visible; }
@media (max-width: 899px) { .chartcard svg { height: 160px; } }
.chart-axis {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--mute); margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.chart-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 10.5px; color: var(--mute); }
.chart-legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 5px; border-radius: 2px; }
.chart-legend .lg-a { background: var(--accent); }
.chart-legend .lg-b { background: currentColor; opacity: .3; }

.insight { margin-top: 16px; margin-bottom: 18px; font-size: 12.5px; line-height: 1.75; color: var(--sub); padding: 0 2px; }
.insight b { color: var(--ink); font-variant-numeric: tabular-nums; }
.insight .warn { color: #B4553F; font-weight: 600; }
body[data-mode="dark"] .insight .warn { color: #D69C99; }

/* 中枢页 */
.kv-btn { width: 100%; text-align: left; border: 0; background: none; padding: 14px 0; }
.kv-btn:active { opacity: .55; }
.kv-btn .v:not(.inc), .amt:not(.inc) { color: #A8403C; }
body[data-mode="dark"] .kv-btn .v:not(.inc), body[data-mode="dark"] .amt:not(.inc) { color: #E6A09B; }
.kv-btn .v.inc, .amt.inc { color: #2F7A5A; }
body[data-mode="dark"] .kv-btn .v.inc, body[data-mode="dark"] .amt.inc { color: #7FC2A0; }

/* 滑动删除 */
.rowwrap { position: relative; overflow: hidden; }
.rowwrap + .rowwrap::before {
  content: ""; position: absolute; top: 0; left: 36px; right: 0; height: 1px;
  background: var(--line); z-index: 2;
}
.rowwrap .row { position: relative; z-index: 1; background: var(--bg); transition: transform .18s ease; }
.row-del {
  position: absolute; top: 0; right: 0; bottom: 0; width: 92px;
  background: #A8402F; color: #fff; font-size: 13px; font-weight: 600;
  letter-spacing: .04em; display: flex; align-items: center; justify-content: center;
}
.rowwrap.swiped .row { transform: translateX(-92px); }
body[data-mode="dark"] .row-del { background: #B84A3E; }
.rowwrap .kv { position: relative; z-index: 1; background: var(--bg); transition: transform .18s ease; }
.rowwrap.swiped .kv { transform: translateX(-92px); }

/* 桌面端图表高度（放在最后覆盖基础规则） */
@media (min-width: 900px) {
  .chartcard { padding: 22px 22px 18px; }
  .chartcard svg { height: 300px; }
}

/* 基础交互与窄屏修复：保留主题及页面结构。 */
:root { --sub: #60656D; --mute: #666B73; }
body[data-mode="dark"] { --sub: #ACB1BA; --mute: #A3A9B3; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button:disabled { cursor: wait; }
.rowwrap { touch-action: pan-y; user-select: none; }
.rowwrap .row, .rowwrap .kv {
  transition: transform 220ms cubic-bezier(.22, 1, .36, 1);
}
.rowwrap.dragging .row, .rowwrap.dragging .kv { transition: none; cursor: grabbing; }
.rowwrap.dragging { user-select: none; }
.rowwrap .row-del { visibility: hidden; pointer-events: none; }
.rowwrap.swiped .row-del, .rowwrap.dragging .row-del { visibility: visible; pointer-events: auto; }
.rowwrap:focus-within .row-del { visibility: visible; pointer-events: auto; }
/* 删除键只有展开时可点击；键盘直接从编辑面板删除。 */
.rowwrap:not(.swiped):not(.dragging) .row-del { visibility: hidden; }
.row { gap: 10px; min-height: 78px; }
.row:active { opacity: 1; }
.tick { width: 44px; height: 44px; flex-basis: 44px; border: 0; border-radius: 10px; }
.tick::before {
  content: ''; position: absolute; width: 23px; height: 23px;
  border: 1.6px solid var(--sub); border-radius: 50%;
}
.tick { position: relative; }
.tick svg { position: relative; }
.row.paid .tick { background: none; }
.row.paid .tick::before { background: var(--accent); border-color: var(--accent); }
.tick:disabled { opacity: .55; }
.row-meta { text-align: left; padding: 7px 0; }
.row-name { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
.row-sub { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
.amt { min-height: 44px; max-width: 52%; white-space: nowrap; }
.row.paid .amt { opacity: 1; color: var(--sub); }
body[data-mode] .row.paid .amt:not(.inc) { color: var(--sub); }
.row.paid .amt.inc { color: var(--sub); }
.kv .k { min-width: 0; overflow-wrap: anywhere; line-height: 1.55; }
.kv .k small { line-height: 1.6; }
.kv .v { white-space: nowrap; }
.kv-btn { min-height: 78px; }
.chart-hd { flex-wrap: wrap; gap: 6px 16px; }
.hero-num { max-width: 100%; flex-wrap: wrap; align-items: baseline; }
.hero-num .int { overflow-wrap: anywhere; min-width: 0; }
.hero-num .dec { white-space: nowrap; opacity: 1; color: var(--sub); }
.hero-num .cur { opacity: 1; color: var(--sub); }
#view-center .hero-num .int { font-size: 36px; }
.hero-split > span { display: inline-block; }
.chartcard svg { overflow: hidden; }
.tab { min-width: 64px; min-height: 44px; }
.list-actions button { min-height: 44px; color: var(--accent); }
.sim-in::placeholder, .ednum input::placeholder { opacity: 1; }
.sheet { border-radius: 16px 16px 0 0; border-top: 0; }
.sheet-head { padding-right: 40px; min-height: 32px; }
.sheet-close {
  position: absolute; right: 14px; top: 15px; width: 44px; height: 44px;
  font-size: 24px; color: var(--sub); border-radius: 10px;
}
.sheet-head .side { min-height: 44px; flex-shrink: 0; }
.switch { min-height: 26px; }
.sheet .srow { min-height: 52px; }
.ends-select { min-height: 40px; font: inherit; }
.modal { border-radius: 16px; }
.modal-ttl { overflow-wrap: anywhere; }
@media (hover: hover) {
  .row-meta:hover, .kv-btn:hover { color: var(--accent); }
  .amt:hover { text-decoration: underline; text-underline-offset: 4px; }
  .btn:hover:not(:disabled), .sim-go:hover:not(:disabled) { opacity: .9; }
  .sheet-close:hover { background: var(--soft); }
}
@media (max-width: 420px) {
  .view { padding-left: 20px; padding-right: 20px; }
  .topbar { padding-left: 20px; padding-right: 20px; }
  .row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 0 8px; padding: 12px 0; }
  .tick { grid-column: 1; align-self: center; }
  .row-meta { grid-column: 2; padding: 0; }
  .amt { grid-column: 3; min-height: 44px; max-width: none; font-size: 14px; }
  .kv .k { flex: 1; }
  .kv .v { font-size: 14px; }
  .sheet { padding-left: 20px; padding-right: 20px; }
  .hero-num .int { font-size: 38px; }
  .hero-num.xlong .int { font-size: 27px; }
  .sim-go { padding-left: 12px; padding-right: 12px; }
}
@media (min-width: 600px) { .sheet { border-radius: 16px; } }
@media (min-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; }
  #view-center, #view-settings { max-width: 720px; margin-inline: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.hero-label, .sec-head .t, .group-title, .lab3, .sim-hint { font-size: 12px; letter-spacing: .04em; }
