/* ========================================
   退休金计算器 - 移动端样式
   ======================================== */

:root {
  --primary: #e8590c;
  --primary-dark: #d9480f;
  --primary-light: #fff4e6;
  --success: #2f9e44;
  --warning: #e67700;
  --danger: #e03131;
  --info: #1971c2;
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #212529;
  --text-secondary: #868e96;
  --text-muted: #adb5bd;
  --border: #dee2e6;
  --border-light: #e9ecef;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --font-size-sm: 13px;
  --font-size: 15px;
  --font-size-lg: 17px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: var(--font-size);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ========== 通用组件 ========== */

.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 16px;
}

.page {
  min-height: 100vh;
  padding-bottom: var(--safe-bottom);
}

.header {
  background: linear-gradient(135deg, var(--primary), #fd7e14);
  color: #fff;
  padding: 24px 16px 20px;
  text-align: center;
}

.header h1 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  margin-bottom: 4px;
}

.header p {
  font-size: var(--font-size-sm);
  opacity: 0.9;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  margin: 12px 0;
}

.card-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-lg);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-appearance: none;
  outline: none;
}

.btn:active { transform: scale(0.98); opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #fd7e14);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-sm {
  padding: 8px 16px;
  font-size: var(--font-size-sm);
  width: auto;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select {
  display: block;
  width: 100%;
  padding: 12px 14px;
  font-size: var(--font-size);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  transition: border-color 0.2s;
  -webkit-appearance: none;
  outline: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder { color: var(--text-muted); }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group { flex: 1; }

/* ========== 支付页 ========== */

.pay-hero {
  text-align: center;
  padding: 40px 16px 20px;
}

.pay-hero .icon-calc {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary-light), #ffe8cc);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 36px;
}

.pay-hero h2 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin-bottom: 8px;
}

.pay-hero .subtitle {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.6;
}

.price-card {
  text-align: center;
  padding: 24px;
  margin: 16px 0;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary-light);
}

.price-amount {
  font-size: 40px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.price-amount .unit {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.price-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: 8px;
}

.feature-list {
  margin: 20px 0;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--font-size-sm);
}

.feature-item:last-child { border-bottom: none; }

.feature-item .check {
  width: 22px;
  height: 22px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.pay-qrcode {
  text-align: center;
  padding: 20px;
}

.qrcode-img {
  width: 200px;
  height: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  font-size: 14px;
  color: var(--text-muted);
}

.pay-status {
  text-align: center;
  padding: 12px;
  font-size: var(--font-size-sm);
}

.pay-status .spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 计算器页 ========== */

.calc-header {
  background: linear-gradient(135deg, var(--primary), #fd7e14);
  color: #fff;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calc-header .brand {
  font-size: var(--font-size);
  font-weight: 700;
}

.calc-header .session-info {
  font-size: 12px;
  opacity: 0.85;
}

.result-hero {
  background: linear-gradient(135deg, #0ca678, #20c997);
  color: #fff;
  text-align: center;
  padding: 24px 16px;
  border-radius: var(--radius);
  margin: 16px 0;
  box-shadow: var(--shadow-lg);
}

.result-hero .amount {
  font-size: 48px;
  font-weight: 800;
  line-height: 1.1;
  margin: 8px 0;
}

.result-hero .amount .unit {
  font-size: var(--font-size-xl);
  font-weight: 500;
}

.result-hero .label {
  font-size: var(--font-size-sm);
  opacity: 0.9;
}

.result-hero .rate {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  margin-top: 8px;
}

.breakdown-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.breakdown-item:last-child {
  border-bottom: none;
  font-weight: 700;
  color: var(--primary);
  font-size: var(--font-size-lg);
}

.breakdown-item .name {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.breakdown-item .value {
  font-weight: 600;
  font-size: var(--font-size-lg);
}

.advice-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}

.advice-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--font-size-sm);
  line-height: 1.6;
}

.advice-item:last-child { border-bottom: none; }

.advice-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}

.advice-icon.good { background: #d3f9d8; color: #2b8a3e; }
.advice-icon.medium { background: #fff3bf; color: #e67700; }
.advice-icon.warning { background: #ffe3e3; color: #c92a2a; }
.advice-icon.info { background: #d0ebff; color: #1864ab; }

/* ========== 公式展示 ========== */

.formula-card {
  background: #f8f9fa;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
  border-left: 3px solid var(--primary);
}

.formula-card code {
  background: #e9ecef;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--primary-dark);
}

/* ========== 支付遮罩层 ========== */

.pay-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.pay-modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  margin: 16px;
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.pay-modal h3 {
  font-size: var(--font-size-lg);
  margin-bottom: 12px;
}

.pay-modal p {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  margin-bottom: 20px;
}

/* ========== Toast消息 ========== */

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: var(--font-size-sm);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ========== Loading ========== */

.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1500;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* ========== 隐藏类 ========== */
.hidden { display: none !important; }

/* ========== 内联提示/计算结果预览 ========== */
.inline-result {
  margin-top: 6px;
  padding: 8px 12px;
  background: #f0f9ff;
  border-left: 3px solid var(--info);
  border-radius: 4px;
  font-size: 12px;
  color: var(--info);
  line-height: 1.6;
}

.inline-result.warn {
  background: #fff9db;
  border-left-color: var(--warning);
  color: #e67700;
}

.inline-result.success {
  background: #ebfbee;
  border-left-color: var(--success);
  color: #2b8a3e;
}

/* ========== 小字说明 ========== */
.form-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.form-note strong {
  color: var(--text-secondary);
}

/* ========== 分隔线 ========== */
.divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 16px 0;
}

/* ========== 高级选项面板 ========== */
.advanced-panel {
  background: #f8f9fa;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
}

.advanced-panel .section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ========== 响应式微调 ========== */
@media (max-width: 360px) {
  .result-hero .amount { font-size: 40px; }
  .form-row { flex-direction: column; gap: 0; }
}

/* ========== 复选框样式 ========== */
.form-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
}

/* ========== 替代率解说表格 ========== */
.rate-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 8px;
}

.rate-row {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--font-size-sm);
}

.rate-row:last-child {
  border-bottom: none;
}

.rate-level {
  width: 80px;
  font-weight: 600;
  flex-shrink: 0;
}

.rate-value {
  width: 60px;
  text-align: center;
  font-weight: 600;
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 4px;
  margin-right: 12px;
}

.rate-desc {
  flex: 1;
  color: var(--text-secondary);
}

.rate-row-danger .rate-value {
  background: #ffe3e3;
  color: #c92a2a;
}

.rate-row-warning .rate-value {
  background: #fff9db;
  color: #e67700;
}

.rate-row-info .rate-value {
  background: #d0ebff;
  color: #1864ab;
}

.rate-row-success .rate-value {
  background: #d3f9d8;
  color: #2b8a3e;
}

/* ========== 打印样式 ========== */
@media print {
  body { background: #fff; }
  .calc-header, #inputCard, .btn, .toast, .loading-overlay, .pay-overlay { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .page { padding: 0; }
  .result-hero {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
    border: 2px solid #000;
    border-radius: 0;
    margin: 10px 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .result-hero .rate {
    background: #f0f0f0 !important;
    color: #000 !important;
  }
  .card, .breakdown-card, .advice-card, .formula-card {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }
  .formula-card {
    border-left: 3px solid #000;
    background: #fafafa;
  }
  .advice-icon.good { background: #d3f9d8; color: #2b8a3e; }
  .advice-icon.medium { background: #fff3bf; color: #e67700; }
  .advice-icon.warning { background: #ffe3e3; color: #c92a2a; }
  .advice-icon.info { background: #d0ebff; color: #1864ab; }
  .rate-row-danger .rate-value { background: #ffe3e3; color: #c92a2a; }
  .rate-row-warning .rate-value { background: #fff9db; color: #e67700; }
  .rate-row-info .rate-value { background: #d0ebff; color: #1864ab; }
  .rate-row-success .rate-value { background: #d3f9d8; color: #2b8a3e; }
  .hidden { display: none !important; }
  #resultSection { display: block !important; }
  #resultSection .hidden { display: none !important; }
}

/* ========== 调节按钮（spinner） ========== */
.spinner-group {
  display: flex;
  align-items: center;
  gap: 0;
}
.spinner-btn {
  width: 34px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.spinner-btn:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
}
.spinner-btn:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}
.spinner-btn:hover {
  background: var(--primary-light, #e8f0fe);
  border-color: var(--primary);
  color: var(--primary);
}
.spinner-btn:active {
  background: var(--primary);
  color: #fff;
}
.spinner-input {
  width: 70px;
  text-align: center;
  border-radius: 0;
  border-left: none;
  border-right: none;
  -moz-appearance: textfield;
}
.spinner-input::-webkit-inner-spin-button,
.spinner-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.spinner-unit {
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
