/* ===== 光伏项目经济测算 - 移动端样式 ===== */
:root {
  --primary: #0a7d3c;
  --primary-dark: #075a2a;
  --primary-light: #13b86b;
  --primary-bg: #e8f5ec;
  --accent: #f59e0b;
  --danger: #e53935;
  --info: #1976d2;
  --text: #1a1a1a;
  --text-2: #555;
  --text-3: #999;
  --border: #e4e4e4;
  --bg: #f3f5f7;
  --card: #ffffff;
  --shadow: 0 2px 10px rgba(0,0,0,.06);
  --shadow-lg: 0 6px 24px rgba(0,0,0,.12);
  --radius: 14px;
  --radius-sm: 8px;
  --header-h: 52px;
  --nav-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg);
  -webkit-text-size-adjust: 100%; overflow-x: hidden;
  /* 禁止下拉橡皮筋，保留内部滚动 */
  overscroll-behavior-y: none;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

#app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* ===== IM 内置浏览器引导（微信/QQ/钉钉等） ===== */
.im-guide-mask {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.58); backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 80px 20px 20px;
}
.im-guide-mask.show { display: flex; }
.im-guide {
  position: relative;
  width: 100%; max-width: 360px;
  background: #fff; border-radius: var(--radius);
  padding: 28px 22px 22px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .25s ease;
}
.im-guide-close {
  position: absolute; top: 10px; right: 14px;
  font-size: 18px; color: var(--text-3); width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
}
.im-guide-close:active { background: var(--bg); color: var(--text); }
.im-guide-arrow {
  position: absolute; top: -28px; right: 18px;
  font-size: 44px; color: #fff;
  animation: bounceDown 1.4s ease-in-out infinite;
}
@keyframes bounceDown {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(10px); }
}
.im-guide-title { font-size: 17px; font-weight: 700; color: var(--primary-dark); margin-bottom: 8px; }
.im-guide-desc { font-size: 13px; color: var(--text-2); line-height: 1.6; margin-bottom: 14px; }
.im-guide-steps { background: var(--primary-bg); border-radius: var(--radius-sm); padding: 12px 14px; }
.ig-step { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--text-2); margin: 6px 0; line-height: 1.5; }
.ig-step .ig-num {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ===== 安全区顶部 ===== */
.safe-top { height: var(--safe-t); background: var(--primary); flex-shrink: 0; }

/* ===== 头部 ===== */
.app-header {
  height: var(--header-h);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 8px rgba(10,125,60,.25);
}
.header-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; }
.header-logo { font-size: 22px; filter: drop-shadow(0 0 4px rgba(255,255,255,.5)); }
.icon-btn { color: #fff; font-size: 22px; width: 36px; height: 36px; border-radius: 50%; }
.icon-btn:active { background: rgba(255,255,255,.2); }

/* ===== 主体 ===== */
.content { flex: 1; overflow-x: hidden; padding-bottom: 0; }
.view { display: none; padding: 14px; animation: fadeIn .25s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.bottom-spacer { height: calc(var(--nav-h) + var(--safe-b) + 16px); }

/* ===== 顶部横幅 ===== */
.page-banner {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff; border-radius: var(--radius); padding: 16px 18px;
  margin-bottom: 14px; box-shadow: var(--shadow);
}
.page-banner h2 { margin: 0 0 4px; font-size: 18px; }
.page-banner p { margin: 0; font-size: 12.5px; opacity: .92; }

/* ===== 按钮通用 ===== */
.btn {
  height: 44px; border-radius: var(--radius-sm); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .1s, background .2s; padding: 0 18px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: #eef0f2; color: var(--text-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .45; }
.action-row { display: flex; gap: 10px; margin: 14px 0; }
.action-row .btn { flex: 1; }
.btn-calc { flex: 2 !important; font-size: 16px; height: 48px; box-shadow: 0 4px 12px rgba(10,125,60,.3); }

/* ===== 参数表单 ===== */
.params-form { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; font-weight: 600; font-size: 15.5px;
  user-select: none; cursor: pointer;
}
.card-header .ch-left { display: flex; align-items: center; gap: 8px; }
.card-header .ch-icon { font-size: 18px; }
.card-header .ch-arrow { color: var(--text-3); transition: transform .25s; font-size: 14px; }
.card.collapsed .ch-arrow { transform: rotate(-90deg); }
.card-body { padding: 4px 16px 14px; display: block; }
.card.collapsed .card-body { display: none; }

.field { padding: 11px 0; border-bottom: 1px solid var(--border); }
.field:last-child { border-bottom: none; }
.field-label { display: block; font-size: 13.5px; color: var(--text-2); margin-bottom: 6px; }
.field-label .hint { color: var(--text-3); font-size: 11.5px; margin-left: 4px; }
.field-row { display: flex; align-items: center; gap: 8px; }

/* 数字输入 */
.num-input {
  flex: 1; height: 42px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 70px 0 12px; font-size: 16px; background: #fafbfc; width: 100%;
  transition: border-color .2s, background .2s;
}
.num-input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(10,125,60,.1); }
.unit {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 13px; pointer-events: none;
}
.field-num { position: relative; }
/* 步进器 */
.stepper { display: flex; align-items: center; }
.stepper .step-btn {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-bg);
  color: var(--primary); font-size: 18px; font-weight: 700; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.stepper .step-btn:active { background: var(--primary-light); color: #fff; }

/* 下拉/日期 */
.select-input, .date-input {
  flex: 1; height: 42px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 30px 0 12px; font-size: 16px; background: #fafbfc; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
.select-input:focus, .date-input:focus { outline: none; border-color: var(--primary); background-color: #fff; }
.date-input { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'><rect x='1' y='2.5' width='12' height='10' rx='1.5' fill='none' stroke='%23999' stroke-width='1.3'/><line x1='1' y1='5.5' x2='13' y2='5.5' stroke='%23999' stroke-width='1.3'/><line x1='4' y1='1' x2='4' y2='3.5' stroke='%23999' stroke-width='1.3'/><line x1='10' y1='1' x2='10' y2='3.5' stroke='%23999' stroke-width='1.3'/></svg>"); }

/* 开关 */
.switch-field { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); }
.switch-field:last-child { border-bottom: none; }
.switch-field .sf-label { font-size: 14px; }
.switch-field .sf-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.switch {
  position: relative; width: 48px; height: 28px; background: #d6d6d6; border-radius: 14px;
  transition: background .25s; flex-shrink: 0;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px;
  background: #fff; border-radius: 50%; transition: transform .25s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(20px); }

/* 子分组 */
.sub-group { background: #f8faf8; border-radius: var(--radius-sm); padding: 2px 12px; margin: 10px 0; border: 1px solid #e8f0e8; }
.sub-group-title { font-size: 12.5px; color: var(--primary-dark); font-weight: 600; padding: 8px 0 2px; }
.readonly-field { padding: 8px 0; }
.readonly-field .rf-label { font-size: 13px; color: var(--text-3); }
.readonly-field .rf-value { font-size: 16px; font-weight: 600; color: var(--primary-dark); }

/* ===== 结果页 ===== */
.empty-state { text-align: center; padding: 60px 24px; color: var(--text-3); }
.empty-icon { font-size: 52px; margin-bottom: 12px; opacity: .5; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.metric-card {
  background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  border-left: 4px solid var(--primary); position: relative; overflow: hidden;
}
.metric-card .mc-label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.metric-card .mc-value { font-size: 22px; font-weight: 700; color: var(--primary-dark); line-height: 1.1; }
.metric-card .mc-unit { font-size: 12px; color: var(--text-3); font-weight: 400; }
.metric-card.good { border-left-color: var(--primary-light); }
.metric-card.warn { border-left-color: var(--accent); }
.metric-card.bad { border-left-color: var(--danger); }
.metric-card .mc-value.warn { color: var(--accent); }
.metric-card .mc-value.bad { color: var(--danger); }

.metric-card.featured {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; grid-column: span 2;
}
.metric-card.featured .mc-label { color: rgba(255,255,255,.85); }
.metric-card.featured .mc-value { color: #fff; font-size: 28px; }
.metric-card.featured .mc-unit { color: rgba(255,255,255,.8); }

.detail-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-row .dr-label { font-size: 14px; color: var(--text-2); }
.detail-row .dr-value { font-size: 15px; font-weight: 600; color: var(--text); }
.detail-row .dr-value.good { color: var(--primary); }
.detail-row .dr-value.warn { color: var(--accent); }

/* 表格(可横向滚动) */
.table-wrap {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 14px;
}
.table-title { font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table { border-collapse: collapse; width: 100%; min-width: 560px; }
table.data-table th, table.data-table td { padding: 9px 10px; text-align: right; white-space: nowrap; font-size: 12.5px; }
table.data-table th { background: var(--primary-bg); color: var(--primary-dark); font-weight: 600; position: sticky; top: 0; z-weight: 2; }
table.data-table td:first-child, table.data-table th:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; min-width: 78px; }
table.data-table tr.build-row td { background: #fff3e0; }
table.data-table tr.early-row td { background: #e8f4ff; }
table.data-table tr.build-row td:first-child, table.data-table tr.early-row td:first-child { font-weight: 600; }
table.data-table td.neg { color: var(--danger); }

/* ===== 图表页 ===== */
.chart-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.chart-title { font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.chart-canvas-wrap { padding: 8px; }
canvas.chart { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 4px 12px 12px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }

/* ===== 方案页 ===== */
.scenario-list { display: flex; flex-direction: column; gap: 10px; }
.scenario-item {
  background: var(--card); border-radius: var(--radius-sm); padding: 13px 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px; border: 2px solid transparent; transition: border-color .2s;
}
.scenario-item.selected { border-color: var(--primary); background: var(--primary-bg); }
.scenario-item .si-info { flex: 1; min-width: 0; }
.scenario-item .si-name { font-weight: 600; font-size: 14.5px; }
.scenario-item .si-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.scenario-item .si-radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; }
.scenario-item.selected .si-radio { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 3px #fff; }
.scenario-empty { text-align: center; color: var(--text-3); padding: 30px; font-size: 13px; }
.compare-result { margin-top: 14px; }
.compare-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow); }
.compare-table th, .compare-table td { padding: 10px 8px; font-size: 13px; text-align: center; border-bottom: 1px solid var(--border); }
.compare-table th { background: var(--primary-bg); color: var(--primary-dark); }
.compare-table td:first-child { text-align: left; font-weight: 600; }
.compare-table .pos { color: var(--primary); font-weight: 600; }
.compare-table .neg { color: var(--danger); font-weight: 600; }

/* ===== 关于页 ===== */
.about-card { background: var(--card); border-radius: var(--radius); padding: 28px 20px; box-shadow: var(--shadow); text-align: center; margin-bottom: 14px; }
.about-logo { font-size: 56px; margin-bottom: 8px; filter: drop-shadow(0 4px 8px rgba(10,125,60,.3)); }
.about-card h2 { margin: 0 0 4px; color: var(--primary-dark); }
.version { color: var(--text-3); margin: 0 0 14px; font-size: 13px; }
.about-desc { color: var(--text-2); font-size: 13.5px; line-height: 1.7; margin: 0 0 20px; }
.about-features { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.feature-item { display: flex; gap: 12px; align-items: center; background: var(--primary-bg); padding: 12px; border-radius: var(--radius-sm); }
.feature-item .fi-icon { font-size: 24px; }
.feature-item b { display: block; font-size: 14px; }
.feature-item span { font-size: 12px; color: var(--text-2); }

/* ===== 结果提示（反算造价等） ===== */
.result-note { margin-top: 16px; background: #fff8e1; border: 1px solid #ffe082; border-radius: var(--radius-sm); padding: 12px; font-size: 12.5px; color: var(--text-2); text-align: left; line-height: 1.6; }
.result-note b { display: block; color: var(--accent); margin-bottom: 4px; }

/* ===== iOS 添加到主屏幕引导（仅 iOS 上显示） ===== */
.ios-guide { margin-top: 20px; background: #f5f5f7; border: 1px solid #d2d2d7; border-radius: var(--radius-sm); padding: 14px; font-size: 12.5px; color: var(--text-2); text-align: left; line-height: 1.6; }
.ios-guide b { display: block; color: #1d1d1f; margin-bottom: 6px; font-size: 13px; }
.ios-guide ol { margin: 8px 0 0; padding-left: 20px; }
.ios-guide ol li { margin: 4px 0; }

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.nav-items { display: flex; height: var(--nav-h); padding-bottom: var(--safe-b); }
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-3); font-size: 11px; transition: color .2s; padding-top: 6px;
}
.nav-item .nav-icon { font-size: 20px; line-height: 1; }
.nav-item.active { color: var(--primary); font-weight: 600; }
.nav-item.active .nav-icon { transform: scale(1.08); }

/* ===== 浮动按钮 ===== */
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #d97706); color: #fff;
  font-size: 24px; box-shadow: 0 4px 14px rgba(245,158,11,.5); z-index: 90;
  display: none; align-items: center; justify-content: center;
  transition: transform .1s;
}
.fab:active { transform: scale(.9); }
.fab.show { display: flex; }

/* ===== 加载遮罩 ===== */
.loading-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200;
  display: none; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.loading-mask.show { display: flex; }
.loading-box { background: #fff; border-radius: var(--radius); padding: 26px 34px; text-align: center; box-shadow: var(--shadow-lg); }
.spinner {
  width: 36px; height: 36px; border: 3.5px solid var(--primary-bg); border-top-color: var(--primary);
  border-radius: 50%; margin: 0 auto 12px; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box p { margin: 0; color: var(--text-2); font-size: 14px; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: rgba(0,0,0,.82); color: #fff; padding: 10px 20px; border-radius: 22px;
  font-size: 13.5px; z-index: 300; opacity: 0; pointer-events: none; transition: all .3s; max-width: 86%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 通用弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 250;
  display: none; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; }
.modal-box {
  background: #fff; border-radius: var(--radius); padding: 22px 18px; width: 100%; max-width: 360px;
  box-shadow: var(--shadow-lg); animation: fadeIn .25s ease;
}
.modal-title { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 14px; color: var(--primary-dark); }
.modal-body { font-size: 13.5px; color: var(--text-2); line-height: 1.7; }
.modal-body .step { display: flex; gap: 8px; margin: 8px 0; }
.modal-body .step-num { flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.modal-body .step-text { flex: 1; }
.modal-body .platform-badge { display: inline-block; background: var(--primary-bg); color: var(--primary-dark); font-size: 12px; padding: 3px 10px; border-radius: 12px; font-weight: 600; margin-bottom: 8px; }

/* ===== 右上角下拉菜单 ===== */
.dropdown-menu {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-t) - 4px);
  right: 8px;
  z-index: 220;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 170px;
  padding: 4px 0;
  animation: fadeIn .18s ease;
  transform-origin: top right;
}
.dropdown-menu .dm-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 11px 14px;
  text-align: left; font-size: 14px; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.dropdown-menu .dm-item:last-child { border-bottom: none; }
.dropdown-menu .dm-item:active { background: var(--bg); }

/* ===== 使用手册弹窗内容 ===== */
.modal-body .help-section { margin: 10px 0 14px; }
.modal-body .help-section h4 {
  margin: 0 0 6px; font-size: 14px; color: var(--primary-dark);
  display: flex; align-items: center; gap: 6px;
}
.modal-body .help-section p { margin: 4px 0; font-size: 13px; color: var(--text-2); line-height: 1.6; }
.modal-body .help-section ul { margin: 4px 0; padding-left: 20px; font-size: 13px; color: var(--text-2); line-height: 1.7; }
.modal-body .kbd {
  display: inline-block; padding: 1px 6px; background: var(--primary-bg);
  color: var(--primary-dark); border-radius: 4px; font-size: 12px; font-weight: 600;
}

/* ===== 大屏适配(平板) ===== */
@media (min-width: 640px) {
  .view { max-width: 640px; margin: 0 auto; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric-card.featured { grid-column: span 3; }
}
@media (min-width: 900px) {
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .metric-card.featured { grid-column: span 4; }
}
