/* ============================================================
   人生规划器 · 组件样式
   目录：布局 / 封面 / 按钮 / 顶部栏 / 步骤条 / 表单 / 结果页
   ============================================================ */

/* ---------- 布局 ---------- */
.shell {
  width: min(100% - 36px, var(--maxw));
  margin: 0 auto;
  padding: 22px 0 80px;
}

/* ---------- 封面 ---------- */
.intro {
  display: grid;
  place-items: center;
  padding: 44px 22px 56px;
}

.intro-inner {
  width: min(100%, 700px);
  animation: rise .55s ease both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: .24em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.brand::before {
  content: "";
  width: 30px;
  height: 1px;
  background: var(--accent-2);
}

.intro h1 {
  font-family: var(--font-display);
  font-size: clamp(56px, 13vw, 112px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: .01em;
  margin: 24px 0 18px;
}

.intro h1 em {
  position: relative;
  z-index: 0;
  font-style: normal;
  color: var(--accent);
}

.intro h1 em::after {
  content: "";
  position: absolute;
  left: -1%;
  right: -1%;
  bottom: 8px;
  height: 14px;
  background: rgba(200, 155, 60, .28);
  transform: skewX(-9deg);
  z-index: -1;
}

.intro-sub {
  font-family: var(--font-display);
  font-size: clamp(20px, 4vw, 28px);
  color: var(--ink);
  letter-spacing: .04em;
}

.intro-desc {
  max-width: 34em;
  margin-top: 14px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.8;
}

.intro-art {
  margin: 30px 0 8px;
}

.intro-art svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 150px;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 26px;
}

.footnote {
  margin-top: 22px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.7;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease,
    border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  color: var(--paper-2);
  box-shadow: 0 10px 24px rgba(30, 42, 50, .18);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 15px 30px rgba(30, 42, 50, .22);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:hover {
  background: rgba(30, 42, 50, .04);
}

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

.btn[disabled] {
  opacity: .55;
  pointer-events: none;
}

.btn .arrow {
  font-size: 17px;
  line-height: 1;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .06em;
  cursor: pointer;
}

.brand-mini::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(200, 155, 60, .16);
}

/* ---------- 步骤条 ---------- */
.progress {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 18px;
}

.progress-step {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
  color: var(--ink-3);
  font-size: 12px;
}

.progress-step::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 3px;
  background: var(--line-soft);
}

.progress-step.on::before,
.progress-step.done::before {
  background: var(--accent);
}

.progress-step.on {
  color: var(--ink);
  font-weight: 700;
}

.progress-step span {
  font-size: 10px;
  letter-spacing: .12em;
}

.progress-step b {
  font-weight: inherit;
}

/* ---------- 表单 ---------- */
.form-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px 30px;
  animation: rise .4s ease both;
}

.step-head {
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.step-head h2 {
  margin: 8px 0 8px;
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.2;
}

.step-desc {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.75;
}

.field {
  display: block;
  margin-top: 20px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
}

.input-wrap {
  position: relative;
  display: block;
}

.input-wrap input {
  width: 100%;
  padding: 14px 78px 14px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
  -moz-appearance: textfield;
  appearance: textfield;
}

.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 92, .13);
}

.input-wrap input::placeholder {
  color: var(--ink-3);
}

.input-wrap .unit {
  position: absolute;
  top: 50%;
  right: 15px;
  transform: translateY(-50%);
  color: var(--ink-3);
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
}

.field-hint {
  display: block;
  margin-top: 7px;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.65;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row .field {
  margin-top: 0;
}

/* 分段选择 */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: var(--paper-3);
}

.seg.seg-wrap {
  grid-auto-flow: row;
  grid-template-columns: repeat(2, 1fr);
}

.seg button {
  padding: 11px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}

.seg button:hover {
  color: var(--ink);
}

.seg button.on {
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(30, 42, 50, .10);
}

.subcard {
  margin-top: 18px;
  padding: 15px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.75;
}

.subcard b {
  color: var(--ink);
}

.loan-preview {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.65;
  font-variant-numeric: tabular-nums;
}

.form-nav {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.form-nav .btn {
  flex: 1;
}

.form-nav .btn-ghost {
  flex: 0 0 116px;
}

/* ---------- 结果页 ---------- */
.report-head {
  margin: 10px 0 22px;
  animation: rise .45s ease both;
}

.report-head h1 {
  margin: 10px 0 10px;
  font-family: var(--font-display);
  font-size: clamp(34px, 7vw, 54px);
  line-height: 1.15;
}

.report-head h1 em {
  font-style: normal;
  color: var(--accent);
}

.report-meta {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.7;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-2);
  box-shadow: 0 6px 18px rgba(30, 42, 50, .05);
}

.kpi-label {
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: .06em;
}

.kpi-value {
  margin: 8px 0 4px;
  font-family: var(--font-display);
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kpi-value small {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
}

.kpi-note {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.55;
}

.kpi.good .kpi-value {
  color: var(--good);
}

.kpi.fair .kpi-value {
  color: var(--fair);
}

.kpi.warn .kpi-value {
  color: var(--warn);
}

.panel {
  margin-top: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  box-shadow: 0 8px 26px rgba(30, 42, 50, .05);
  animation: rise .45s ease both;
}

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.25;
}

.panel-sub {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}

/* 预算环 */
.donut-layout {
  display: grid;
  grid-template-columns: minmax(180px, 250px) 1fr;
  gap: 24px;
  align-items: center;
}

.donut svg {
  display: block;
  width: 100%;
  height: auto;
}

.donut-kicker {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: .14em;
  fill: var(--ink-3);
}

.donut-value {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  fill: var(--ink);
}

.donut-note {
  font-family: var(--font-ui);
  font-size: 9px;
  fill: var(--ink-3);
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.legend-row {
  display: grid;
  grid-template-columns: 11px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-name {
  overflow: hidden;
  color: var(--ink-2);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.legend-pct {
  min-width: 44px;
  color: var(--ink-3);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.legend-gap {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  color: var(--warn);
  font-size: 12px;
  line-height: 1.6;
}

/* 走势图 */
.chart-wrap {
  width: 100%;
  overflow: hidden;
}

.chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 12px;
  color: var(--ink-2);
  font-size: 12px;
}

.chart-legend i {
  display: inline-block;
  width: 18px;
  height: 3px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: middle;
}

/* 建议 */
.advice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.advice {
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-top: 3px solid var(--accent);
  border-radius: 14px;
  background: var(--paper);
}

.advice.tone-good {
  border-top-color: var(--good);
}

.advice.tone-notice {
  border-top-color: var(--accent-2);
}

.advice.tone-warn {
  border-top-color: var(--warn);
}

.advice h4 {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 700;
}

.advice p {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.75;
}

/* 警告 */
.warnings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.warning {
  display: flex;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid rgba(180, 71, 46, .20);
  border-radius: 12px;
  background: var(--warn-soft);
  color: #7E3A28;
  font-size: 13px;
  line-height: 1.65;
}

.warning::before {
  content: "!";
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--warn);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
}

.warning.notice {
  border-color: rgba(200, 155, 60, .28);
  background: rgba(200, 155, 60, .09);
  color: #7A5A1E;
}

.warning.notice::before {
  background: var(--accent-2);
}

/* 时间线 */
.timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
}

.timeline-item b {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 15px;
}

/* 每年计划表 */
.table-wrap {
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}

.plan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.plan-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  background: var(--paper-3);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-align: right;
  white-space: nowrap;
}

.plan-table th:first-child,
.plan-table td:first-child {
  text-align: left;
}

.plan-table td {
  padding: 9px 12px;
  border-top: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
}

.plan-table tr.retire td {
  background: var(--accent-soft);
  font-weight: 700;
}

.plan-table td.neg {
  color: var(--warn);
}

.table-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  color: var(--ink-3);
  font-size: 12px;
}

.assumptions {
  margin-top: 18px;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.8;
}

.result-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.result-actions .btn {
  flex: 1;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 50;
  transform: translate(-50%, 16px);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-2);
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
  max-width: calc(100vw - 40px);
  text-align: center;
}

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

/* ---------- 响应式 ---------- */
@media (max-width: 680px) {
  .shell {
    width: min(100% - 28px, var(--maxw));
    padding-top: 16px;
  }

  .intro {
    padding: 32px 20px 44px;
  }

  .form-card {
    padding: 22px 18px 24px;
  }

  .panel {
    padding: 18px 16px;
  }

  .progress-step b {
    display: none;
  }

  .donut-layout {
    grid-template-columns: 1fr;
  }

  .donut {
    max-width: 240px;
    margin: 0 auto;
  }

  .advice-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .panel-sub {
    text-align: left;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .field-row .field {
    margin-top: 20px;
  }

  .legend {
    gap: 8px;
  }

  .result-actions {
    flex-direction: column-reverse;
  }

  .plan-table th,
  .plan-table td {
    padding: 9px 8px;
    font-size: 12px;
  }

  .plan-table .col-expense {
    display: none;
  }

  .intro-actions .btn {
    width: 100%;
  }
}

@media (min-width: 720px) {
  .kpis {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 400px) {
  .seg button {
    font-size: 13px;
    padding: 10px 4px;
  }

  .kpi {
    padding: 15px 13px;
  }

  .kpi-value {
    font-size: 25px;
  }
}
