:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef4f2;
  --ink: #16201d;
  --muted: #68736f;
  --line: #dfe7e3;
  --primary: #087f6f;
  --primary-2: #e0f3ee;
  --accent: #2e5aac;
  --warn: #b7791f;
  --warn-bg: #fff4d8;
  --danger: #c2413a;
  --danger-bg: #ffe8e5;
  --ok: #277a4d;
  --ok-bg: #e8f6ed;
  --shadow: 0 18px 50px rgba(24, 40, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(8, 127, 111, 0.08), transparent 260px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 92px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
}

h3 {
  font-size: 15px;
}

.range-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  flex: 0 0 118px;
  padding: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 8px;
}

.chip,
.nav-item,
.primary-action,
.secondary-action,
.danger-action,
.file-action,
.small-action {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.chip {
  min-height: 30px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
}

.chip.active {
  color: var(--surface);
  background: var(--primary);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-panel,
.section-block,
.metric-card,
.event-card,
.account-card,
.asset-card,
.liability-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.hero-panel {
  position: relative;
  padding: 20px 18px 18px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(8, 127, 111, 0.07), rgba(46, 90, 172, 0.05) 44%, rgba(255, 255, 255, 0.98) 76%),
    #fff;
}

/* ── Hero 新结构 ── */

/* 1. 判断行：badge + 危险日期 */
.hero-verdict-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.hero-danger-date {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* 2. 数字区 */
.hero-cash-label {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.main-metric {
  margin: 0 0 6px;
  font-size: 48px;
  line-height: 1;
  font-weight: 850;
  overflow-wrap: anywhere;
  color: var(--ink);
  transition: color 0.2s;
}

/* 数字颜色跟随风险等级 */
.hero-panel:has(.risk-critical) .main-metric,
.hero-panel:has(.risk-danger) .main-metric {
  color: var(--danger);
}

.hero-panel:has(.risk-tight) .main-metric {
  color: var(--warn);
}

.hero-panel:has(.risk-stable) .main-metric {
  color: var(--ok);
}

.status-detail {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* 3. 账面 vs 占用对比条 */
.hero-cash-compare {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0 0 14px;
  padding: 12px 14px;
  background: rgba(0,0,0,0.025);
  border-radius: 10px;
}

.hero-cash-col {
  flex: 1;
}

.hero-cash-col span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}

.hero-cash-col strong {
  font-size: 17px;
  font-weight: 700;
}

.hero-compare-arrow {
  color: var(--muted);
  font-size: 16px;
  padding: 0 10px;
  flex-shrink: 0;
}

/* 4. 低点区 */
.hero-lowpoint-wrap {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.hero-lowpoint-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.hero-lowpoint-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hero-lowpoint-date {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.hero-lowpoint-amount {
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
}

/* 风险 badge：在 hero 里更突出 */
.risk-verdict {
  font-size: 13px;
  min-height: 30px;
  padding: 0 14px;
  letter-spacing: 0.02em;
}

/* ── 通用 badge/tag 基础 ── */
.risk-badge,
.tag,
.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.risk-critical,
.risk-danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.risk-tight {
  color: var(--warn);
  background: var(--warn-bg);
}

.risk-stable {
  color: var(--ok);
  background: var(--ok-bg);
}

/* ── 旧元素保留 ── */
.metric-label {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.status-headline {
  margin-top: 6px;
  max-width: 620px;
  font-size: 24px;
  line-height: 1.25;
}

.home-pressure-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.home-pressure-strip > div {
  min-height: 78px;
  padding: 10px;
  border: 1px solid rgba(46, 90, 172, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.home-pressure-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.home-pressure-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 17px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.home-pressure-strip > div:first-child strong {
  color: var(--danger);
}

.home-pressure-strip > div:nth-child(3) strong {
  color: var(--accent);
}

.lowpoint-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.lowpoint-box > div,
.reason-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.lowpoint-box > div {
  padding: 10px;
}

.lowpoint-box span,
.reason-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.lowpoint-box strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}

.reason-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.reason-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
}

.reason-item strong {
  white-space: nowrap;
}

.hint,
.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.compact-metrics {
  margin: 0;
}

.metric-card {
  min-height: 86px;
  padding: 14px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 20px;
}

.section-block {
  margin-top: 12px;
  padding: 14px;
}

.section-heading {
  margin-bottom: 12px;
}

.chart {
  min-height: 190px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 248, 0.92)),
    repeating-linear-gradient(0deg, transparent 0, transparent 34px, rgba(104, 115, 111, 0.08) 35px);
  border-radius: 8px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 190px;
}

.cash-water-area {
  fill: url(#cashWaterFill);
}

.cash-water-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cash-water-floor {
  stroke: var(--danger);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.cash-water-danger {
  fill: rgba(194, 65, 58, 0.08);
}

.cash-water-marker line {
  stroke: rgba(183, 121, 31, 0.24);
  stroke-width: 1;
}

.cash-water-marker circle {
  fill: var(--warn);
}

.cash-water-low {
  fill: var(--danger);
  stroke: #fff;
  stroke-width: 1.8;
}

.cash-water-start {
  fill: var(--accent);
}

.cash-water-end {
  fill: var(--primary);
}

.cash-water-label {
  fill: var(--muted);
  font-size: 11px;
}

.cash-water-floor-label,
.cash-water-low-label {
  fill: var(--danger);
  font-size: 11px;
  font-weight: 700;
}

.rescue-plan {
  display: grid;
  gap: 10px;
}

.rescue-summary,
.rescue-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.rescue-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.rescue-summary.danger,
.rescue-summary.critical {
  border-color: rgba(194, 65, 58, 0.32);
  background: var(--danger-bg);
}

.rescue-summary.stable {
  border-color: rgba(39, 122, 77, 0.28);
  background: var(--ok-bg);
}

.rescue-days {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--danger);
  font-size: 12px;
  font-weight: 850;
}

.rescue-grid {
  display: grid;
  gap: 8px;
}

.rescue-card {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 12px;
}

.rescue-card > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 13px;
  font-weight: 850;
}

.rescue-card.warning {
  border-color: rgba(183, 121, 31, 0.32);
  background: var(--warn-bg);
}

.rescue-card.stable {
  border-color: rgba(39, 122, 77, 0.28);
  background: var(--ok-bg);
}

.rescue-list {
  display: grid;
  gap: 6px;
  padding: 0;
  margin: 8px 0 10px;
  list-style: none;
}

.rescue-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(104, 115, 111, 0.16);
  color: var(--muted);
  font-size: 12px;
}

.rescue-list strong {
  color: var(--danger);
  white-space: nowrap;
}

.spending-layout {
  display: grid;
  gap: 14px;
}

.pie-chart {
  display: grid;
  place-items: center;
  width: 168px;
  aspect-ratio: 1;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
}

.pie-chart span {
  display: grid;
  place-items: center;
  width: 86px;
  aspect-ratio: 1;
  border-radius: 50%;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.spending-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.lightweight-mode {
  background: #fbfdfc;
}

.bill-safety-panel {
  border-color: rgba(183, 121, 31, 0.28);
  background: #fffdf7;
}

.bill-safety-grid {
  display: grid;
  gap: 10px;
}

.bill-safety-grid article {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(183, 121, 31, 0.22);
  border-radius: 8px;
  background: #fff;
}

.bill-safety-grid span {
  color: var(--muted);
  font-size: 12px;
}

.bill-safety-grid strong {
  font-size: 22px;
  line-height: 1.15;
}

.bill-safety-grid p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.lightweight-grid {
  display: grid;
  gap: 10px;
}

.lightweight-grid article {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lightweight-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.stack {
  display: grid;
  gap: 10px;
}

.empty-state {
  padding: 14px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 14px;
}

.event-card,
.account-card {
  padding: 12px;
  box-shadow: none;
}

.event-top {
  justify-content: space-between;
  align-items: flex-start;
}

.event-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.event-title strong {
  overflow-wrap: anywhere;
}

.event-amount {
  font-size: 18px;
  font-weight: 850;
  white-space: nowrap;
}

.amount-in {
  color: var(--ok);
}

.amount-out {
  color: var(--danger);
}

.amount-transfer {
  color: var(--accent);
}

.event-meta {
  flex-wrap: wrap;
  margin-top: 10px;
}

.tag {
  color: var(--muted);
  background: #eef1f0;
  font-weight: 700;
}

.state-confirm {
  color: var(--warn);
  background: var(--warn-bg);
}

.state-overdue {
  color: var(--danger);
  background: var(--danger-bg);
}

.state-completed {
  color: var(--ok);
  background: var(--ok-bg);
}

.state-upcoming {
  color: var(--accent);
  background: #e6efff;
}

.state-cancelled {
  color: var(--muted);
  background: #ecefec;
}

.action-row {
  flex-wrap: wrap;
  margin-top: 12px;
}

.tab-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.tab-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-weight: 800;
}

.tab-button.active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.small-action {
  min-height: 32px;
  padding: 0 10px;
  color: var(--primary);
  background: var(--primary-2);
}

.small-action.warning {
  color: var(--warn);
  background: var(--warn-bg);
}

.small-action.danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.primary-action,
.secondary-action,
.danger-action,
.file-action {
  padding: 0 14px;
}

.primary-action {
  color: #fff;
  background: var(--primary);
}

.secondary-action,
.file-action {
  color: var(--primary);
  background: var(--primary-2);
}

.danger-action {
  color: var(--danger);
  background: var(--danger-bg);
}

.form-grid {
  display: grid;
  gap: 10px;
}

.compact-form {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 127, 111, 0.13);
}

textarea {
  min-height: 96px;
  padding-top: 10px;
  resize: vertical;
}

.wide-field {
  grid-column: 1 / -1;
}

.checkbox-line {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink);
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
}

.checkbox-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  grid-column: 1 / -1;
}

.checkbox-group .checkbox-line {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.hidden {
  display: none !important;
}

.timeline {
  display: grid;
  gap: 10px;
}

.day-group {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.day-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.account-card {
  display: grid;
  gap: 10px;
}

.asset-card {
  display: grid;
  gap: 10px;
  box-shadow: none;
}

.liability-card {
  display: grid;
  gap: 10px;
  box-shadow: none;
}

.liability-group {
  border-color: rgba(8, 127, 111, 0.24);
  background: rgba(251, 253, 252, 0.96);
}

.institution-summary {
  cursor: pointer;
  list-style: none;
}

.institution-summary::-webkit-details-marker {
  display: none;
}

.institution-summary .account-top::after {
  content: "展开";
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.liability-group[open] .institution-summary .account-top::after {
  content: "收起";
}

.liability-detail-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.liability-schedule-details {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.liability-schedule-details summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.liability-schedule-details .stack {
  margin-top: 8px;
}

.account-balance {
  font-size: 23px;
  font-weight: 850;
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-box {
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-box strong {
  display: block;
  margin-top: 5px;
}

.settings-row {
  align-items: flex-end;
}

.settings-row label {
  flex: 1;
}

.backup-actions {
  flex-wrap: wrap;
  margin-top: 12px;
}

.file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.file-action input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.warning-card {
  border-color: #f4c66c;
  background: var(--warn-bg);
}

.danger-card {
  border-color: #f2aaa5;
  background: var(--danger-bg);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(calc(100% - 24px), 438px);
  padding: 6px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 40px rgba(24, 40, 35, 0.18);
}

.fab-button {
  position: fixed;
  right: max(18px, calc((100vw - 438px) / 2 + 18px));
  bottom: 86px;
  z-index: 18;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 14px 32px rgba(8, 127, 111, 0.32);
  font-size: 34px;
  line-height: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(15, 23, 20, 0.36);
}

.modal-sheet {
  width: min(100%, 560px);
  max-height: min(86vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(12, 20, 18, 0.26);
  padding: 16px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.quick-type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.quick-type {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-weight: 800;
}

.quick-type.active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.month-calendar {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.calendar-month-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  min-height: 58px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  text-align: left;
}

.calendar-day.is-empty {
  visibility: hidden;
}

.calendar-day.has-activity {
  color: var(--ink);
  background: var(--soft);
}

.calendar-day.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(8, 127, 111, 0.13);
}

.calendar-day span,
.calendar-day strong,
.calendar-day small {
  display: block;
}

.calendar-day span {
  font-size: 11px;
  font-weight: 800;
}

.calendar-day strong {
  margin-top: 4px;
  color: var(--danger);
  font-size: 11px;
}

.calendar-day small {
  color: var(--muted);
  font-size: 10px;
}

.nav-item {
  color: var(--muted);
  background: transparent;
}

.nav-item.active {
  color: var(--surface);
  background: var(--primary);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  z-index: 20;
  width: min(calc(100% - 32px), 420px);
  padding: 12px 14px;
  transform: translate(-50%, 18px);
  border-radius: 8px;
  color: #fff;
  background: rgba(22, 32, 29, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── Wizard ── */
.wizard-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 300;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 24px 16px 60px;
}

.wizard-overlay.hidden {
  display: none;
}

.wizard-shell {
  width: min(100%, 460px);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.wizard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.wizard-dots {
  display: flex;
  gap: 6px;
}

.wdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition: background 0.2s;
}

.wdot.active {
  background: var(--primary);
}

.wizard-demo-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-step.hidden {
  display: none;
}

.wizard-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  margin: 4px 0 0;
}

.wizard-desc {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

.wizard-cta {
  margin-top: 8px;
}

/* Intro cards */
/* 欢迎页勾选列表 */
.wizard-check-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.wizard-check-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
}

.wizard-check-line::before {
  content: "✓";
  color: var(--primary);
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* 旧 intro cards（保留不报错） */
.wizard-intro-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wizard-intro-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  gap: 14px;
  align-items: baseline;
  font-size: 14px;
}

.wizard-intro-icon {
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  min-width: 58px;
  flex-shrink: 0;
}

/* Item list shared */
.wizard-item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wizard-add-btn {
  align-self: flex-start;
}

/* Account row */
.wizard-account-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) minmax(120px, 0.8fr) minmax(140px, 1fr) 32px;
  gap: 8px;
  align-items: center;
}

.wizard-account-row select,
.wizard-account-row input[type="text"],
.wizard-account-row input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 15px;
  background: var(--surface-2);
  width: 100%;
}

@media (max-width: 640px) {
  .home-pressure-strip {
    grid-template-columns: 1fr;
  }

  .home-pressure-strip > div {
    min-height: 0;
  }

  .wizard-account-row {
    grid-template-columns: 1fr 32px;
  }

  .wizard-account-row .wizard-field-label {
    grid-column: 1 / -1;
  }

  .wizard-account-row .wizard-remove-btn {
    grid-column: 2;
  }
}

/* Bill row */
.wizard-bill-row,
.wizard-liability-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wizard-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.wizard-bill-row input[type="text"],
.wizard-bill-row input[type="number"],
.wizard-liability-row input[type="text"],
.wizard-liability-row input[type="number"],
.wizard-liability-row select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 15px;
  background: var(--surface-2);
  width: 100%;
}

.wizard-bill-grid,
.wizard-liability-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.wizard-field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.wizard-field-label input {
  color: var(--ink);
}

/* Expense row */
.wizard-expense-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wizard-expense-row input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 15px;
  background: var(--surface-2);
  width: 100%;
}

.wizard-expense-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Remove button */
.wizard-remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  border-radius: 4px;
}

.wizard-remove-btn:hover {
  color: var(--danger);
}

/* Safety floor */
.wizard-floor-wrap {
  display: flex;
  align-items: center;
  border: 2px solid var(--primary);
  border-radius: 12px;
  background: var(--surface);
  padding: 0 16px;
}

.wizard-floor-prefix {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-right: 4px;
}

.wizard-floor-input {
  border: none;
  background: none;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  padding: 14px 0;
  width: 100%;
  outline: none;
}

.wizard-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* Footer actions */
.wizard-footer-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px;
  margin-top: 4px;
}

/* Result screen */
.wizard-result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.wizard-result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.wizard-result-row:last-child {
  border-bottom: none;
}

.wizard-result-row.is-highlight {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
  padding-top: 12px;
  margin-top: 4px;
}

.wizard-result-row.is-deduct {
  color: var(--muted);
}

.wizard-callout {
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
}

.wizard-callout.danger {
  background: var(--danger-bg);
  border: 1px solid #f5c6c3;
}

.wizard-callout.ok {
  background: var(--ok-bg);
  border: 1px solid #b2dfc6;
}

.wizard-callout strong {
  display: block;
  margin-bottom: 4px;
}

@media (min-width: 740px) {
  .app-shell {
    width: min(100%, 920px);
  }

  main {
    max-width: 920px;
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .spending-layout {
    grid-template-columns: 190px 1fr;
    align-items: center;
  }

  .form-grid .primary-action {
    align-self: end;
  }

  .compact-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .bottom-nav {
    width: min(100% - 24px, 560px);
  }
}
