:root {
  --bg: #FAF7F6;
  --card: #ffffff;
  --line: #EFE2E0;
  --text: #1E191A;
  --muted: #6B5F61;
  --accent: #A82638;
  --accent-soft: #FBEDEF;
  --up: #D8342C;
  --down: #0E8A5F;
  --warn: #9A6410;
  --warn-bg: #FDF6E8;
  --radius: 13px;
  --shadow: 0 1px 2px rgba(96, 30, 40, .05), 0 8px 24px -14px rgba(96, 30, 40, .16);
  --shadow-card: inset 0 1px 0 #fff, 0 1px 2px rgba(96, 30, 40, .05), 0 8px 24px -14px rgba(96, 30, 40, .16);
  --shadow-btn: inset 0 1px 0 rgba(255, 255, 255, .22), 0 6px 16px -6px rgba(150, 26, 46, .42);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --topbar-h: 52px;
  --tabbar-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  -webkit-text-size-adjust: 100%;   /* 微信里横屏/旋转后字号不放大 */
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  overflow-x: hidden;               /* 防止某个长数字把整页顶出横向滚动 */
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  touch-action: manipulation;       /* 去掉 iOS 300ms 点击延迟 */
}

/* ------------------------------------------------------------------ 布局 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 253, 253, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(160deg, #B93044, #8E1F2E);
  box-shadow: 0 0 0 3.5px rgba(185, 48, 68, .12), 0 2px 6px rgba(140, 30, 50, .3);
}
.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.nav::-webkit-scrollbar { display: none; }
.nav a, .nav button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.nav a.active, .nav button.active {
  background: var(--accent-soft);
  color: #8E1F2E;
  font-weight: 650;
  box-shadow: inset 0 0 0 1px rgba(185, 48, 68, .12);
}
.who {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.who b { color: var(--text); font-weight: 600; }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 16px 64px;
}

/* 底部标签栏：只在手机显示，微信里单手够得着 */
.tabbar { display: none; }

/* ------------------------------------------------------------------ 卡片 */
.card {
  background: linear-gradient(180deg, #fff 0%, #FFFCFC 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin-bottom: 14px;
}
.card h2, .card h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.card h2 .sub, .card h3 .sub {
  font-weight: 400;
  color: var(--muted);
  font-size: 12.5px;
}

/* 步骤序号：让人一眼看清「先填什么、后做什么」 */
.step-no {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 6px;
  background: linear-gradient(180deg, #FBEDEF, #F8E3E6);
  color: #8E1F2E;
  box-shadow: inset 0 0 0 1px rgba(185, 48, 68, .13);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 可折叠卡片（资金与成本）：默认收起，标题行给一句话摘要 */
.card.fold { padding: 0; }
.fold-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 15px 16px;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
}
.fold-head b { font-weight: 650; }
.fold-sum {
  margin-left: auto;
  min-width: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fold-head .chev {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: var(--muted); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform .18s ease;
}
.card.fold.open .chev { transform: rotate(90deg); }
/* 展开后摘要让位给真实字段，避免标题行挤成两截 */
.card.fold.open .fold-sum { display: none; }
.fold-body { display: none; padding: 0 16px 16px; }
.card.fold.open .fold-body { display: block; }

/* 折叠卡右侧的「展开明细」：做成蓝色胶囊，一眼能看出这里可以点 */
.fold-sub { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.fold-cta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px 4px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #A82638;
  box-shadow: inset 0 0 0 1px rgba(185, 48, 68, .1);
  font-size: 12.5px;
  font-weight: 600;
  flex: none;
}
.fold-cta .chev {
  width: 14px; height: 14px;
  stroke: currentColor;
  transition: transform .18s ease;
}

/* 通达信公式代码块：等宽字体 + 自动折行（手机上不横滑也能看全，复制拿到的仍是完整文本） */
pre.code {
  margin: 0;
  padding: 11px 12px;
  background: #FFFCFC;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.72;
  color: #2A2325;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  tab-size: 2;
}
.tdx-notes { line-height: 1.8; margin-top: 10px; }

/* 分享链接：手机上输入框独占一行，别被两个按钮挤成半截 */
.share-input { flex: 1 1 240px; min-width: 0; }
@media (max-width: 760px) {
  .input.share-input { flex: 1 1 100%; font-size: 13px; }
}

/* 参数名旁的「?」：点开看解释 */
.param-help {
  width: 16px; height: 16px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid #E7C3C8;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -3px;
  cursor: pointer;
}
.param-help:active { transform: scale(.92); }
.param-help.inline { pointer-events: none; vertical-align: 0; }

/* 有效邀请码一览：手机上也能直接看到、手动复制 */
.codes-block {
  border: 1px dashed #E8D6D3;
  border-radius: 9px;
  background: #FFFCFC;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.95;
  letter-spacing: .4px;
  margin-bottom: 12px;
  max-height: 176px;
  overflow-y: auto;
  word-break: break-all;
}

/* 主操作区：桌面跟在内容后面，手机吸在标签栏上方，单手就够得着 */
.actionbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 20px;
}
.actionbar .btn.primary { min-width: 150px; }
.actionbar-space { display: none; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ------------------------------------------------------------------ 表单 */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}
.input, select.input, textarea.input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
}
select.input {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%236b7280' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 26px;
}
.input:focus {
  border-color: #B93044;
  box-shadow: 0 0 0 3.5px rgba(185, 48, 68, .11);
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.6; }
.hint { font-size: 12px; color: var(--muted); }
.hint.bad { color: #B4232A; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* 日期用「年 / 月 / 日」三段下拉，代替手机上难拨的原生日期控件 */
.code-field { max-width: 320px; }

/* 股票输入联想：代码 / 简称 / 拼音都能搜，候选浮在输入框下方 */
.code-wrap { position: relative; flex: 1; min-width: 0; }
.code-wrap .input { width: 100%; }
.code-sug {
  display: none;
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  z-index: 20;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(96, 30, 40, .12);
  overflow: hidden auto;
  max-height: 264px;
}
.code-sug.open { display: block; }
.code-sug button {
  display: flex; align-items: baseline; gap: 8px;
  width: 100%; padding: 10px 12px;
  background: none; border: 0; text-align: left;
  font-size: 14px; cursor: pointer;
}
.code-sug button + button { border-top: 1px solid var(--line); }
.code-sug button:active { background: var(--accent-soft); }
.code-sug .sug-code { font-weight: 650; font-variant-numeric: tabular-nums; }
.code-sug .sug-name {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.code-sug .sug-mkt { font-size: 12px; color: var(--muted); flex: none; }
.code-sug .sug-empty { padding: 10px 12px; font-size: 13px; color: var(--muted); }
.date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.date-pick {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 6px;
}
.date-pick .input { padding-right: 22px; background-position: right 7px center; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.chips-label { font-size: 12px; color: var(--muted); }
.chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover, .chip:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
.chip:active { transform: scale(.97); }

.btn {
  display: inline-flex;
  white-space: nowrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 550;
  transition: background .15s, border-color .15s, transform .04s;
}
.btn:hover { background: #FFFDFD; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #B93044 0%, #8E1F2E 100%);
  border-color: #8E1F2E;
  color: #fff;
  font-weight: 620;
  letter-spacing: .3px;
  box-shadow: var(--shadow-btn);
}
.btn.primary:hover { background: linear-gradient(180deg, #C4394B 0%, #A82638 100%); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--up); border-color: #f3d5d5; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }

.seg {
  display: inline-flex;
  background: #F4EDEB;
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  max-width: 100%;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 550;
  white-space: nowrap;
}
.seg button.active {
  background: #fff; color: #8E1F2E;
  box-shadow: 0 1px 2px rgba(96, 30, 40, .07), inset 0 0 0 1px rgba(185, 48, 68, .1);
}

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; min-height: 38px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

/* ------------------------------------------------------------------ 策略选择 */
.presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.preset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fff;
}
.preset:hover { border-color: #E0C4C1; }
.preset.active {
  border-color: #B93044;
  background: linear-gradient(180deg, #FDF7F7, #FBEDEF);
  box-shadow: 0 0 0 3px rgba(185, 48, 68, .07), inset 0 1px 0 #fff;
}
.preset b { display: block; font-size: 14px; margin-bottom: 2px; }
.preset:last-child:nth-child(odd) { grid-column: 1 / -1; }
.preset span { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* ------------------------------------------------------------------ 积木条件行 */
.cond-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}
.cond-row .input { padding: 6px 8px; }
.cr-a { display: flex; gap: 6px; flex: 2 1 150px; min-width: 0; }
.cr-a .c-left { flex: 1 1 auto; }
.cr-a .c-left-n { width: 62px; flex: none; }
.cr-b { flex: 1 1 92px; min-width: 0; }
.cr-c { display: flex; gap: 6px; flex: 2 1 170px; min-width: 0; }
.cr-c .c-rtype { width: 66px; flex: none; }
.cr-c .c-val { width: 78px; flex: none; }
.cr-c .c-rind { flex: 1 1 auto; min-width: 0; }
.cr-c .c-rn { width: 56px; flex: none; }
.c-del { flex: none; }

/* 「全部满足 AND」这种小下拉：宽度自适应，右边留出箭头的位置 */
select.logic-select {
  width: auto;
  flex: none;
  padding: 6px 28px 6px 10px;
  font-size: 13px;
}

/* ------------------------------------------------------------------ 指标卡 */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric {
  background:
    radial-gradient(120% 130% at 0% 0%, rgba(185, 48, 68, .05), transparent 58%),
    #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  box-shadow: inset 0 1px 0 #fff;
}
.metric .k { font-size: 12px; color: var(--muted); }
.metric .v { font-size: 20px; font-weight: 680; letter-spacing: -.3px; margin-top: 2px; }
.metric .v.up { color: var(--up); }
.metric .v.down { color: var(--down); }
.metric .x { font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------------ 表格 */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: #F7F0EE;
  position: sticky;
  top: 0;
}
th:first-child, td:first-child { text-align: left; }
tbody tr:hover { background: #FDF5F5; }
td.num { font-variant-numeric: tabular-nums; }
td.wrap, th.wrap { white-space: normal; min-width: 120px; }

/* 手机上「左右滑动」提示 */
.scroll-hint {
  display: none;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
  text-align: right;
}

/* 手机卡片式列表（替代宽表格） */
.list-cards { display: none; }
.lcard {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 8px;
  background: #fff;
}
.lcard .lc-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  justify-content: space-between;
}
.lcard .lc-title { font-weight: 650; font-size: 14px; min-width: 0; }
.lcard .lc-arrow { color: var(--muted); font-size: 12px; }
.lcard .lc-mid { display: flex; gap: 10px; align-items: baseline; margin-top: 5px; }
.lcard .lc-big { font-size: 18px; font-weight: 680; letter-spacing: -.3px; }
.lcard .lc-kv {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--muted);
}
.lcard .lc-kv b { color: var(--text); font-weight: 550; font-variant-numeric: tabular-nums; }
.lcard .lc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  color: var(--muted);
}
.lcard .lc-acts { display: flex; gap: 6px; flex: none; }

/* ------------------------------------------------------------------ 图表 */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { display: block; width: 100%; touch-action: pan-y; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.legend i {
  display: inline-block; width: 10px; height: 3px; border-radius: 2px;
  vertical-align: middle; margin-right: 5px;
}

/* ------------------------------------------------------------------ 提示 */
.alert {
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #f5e3c3;
  margin-bottom: 12px;
  word-break: break-word;
}
.alert.error { background: #FDF1F0; color: #B4232A; border-color: #F0D2CE; }
.alert.ok { background: #EFF9F4; color: #0D7A50; border-color: #CDEBDD; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  background: #F4EDEB;
  color: var(--muted);
  white-space: nowrap;
}
.tag.green { background: #EDF8F2; color: #0D7A50; }
.tag.red { background: #FBEDEF; color: #B4232A; }
.tag.blue { background: var(--accent-soft); color: var(--accent); }

.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ 登录 */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;          /* 卡片 + 备案号竖排，否则页脚会跑到卡片右边把卡片压窄 */
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-b));
  background:
    radial-gradient(900px 460px at 50% -12%, rgba(185, 48, 68, .12) 0%, transparent 62%),
    radial-gradient(520px 300px at 90% 100%, rgba(194, 154, 98, .09) 0%, transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 24px;
  box-shadow: 0 10px 40px rgba(96, 30, 40, .08);
}
.auth-card h1 { font-size: 19px; margin: 0 0 4px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.auth-tabs button {
  flex: 1; border: 0; background: #F4EDEB; color: var(--muted);
  padding: 8px 4px; border-radius: 8px; cursor: pointer; font-weight: 550; font-size: 13px;
}
.auth-tabs button.active { background: var(--accent-soft); color: var(--accent); }

/* 加到手机桌面：微信拦未备案域名，桌面图标是主入口，这条提示放在登录页最显眼处 */
.install-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: -6px 0 16px;
  padding: 8px 11px;
  background: var(--accent-soft);
  border-radius: 9px;
  font-size: 12.5px;
  color: #7C1A2A;
  line-height: 1.5;
}
.link-btn {
  flex: none; padding: 0; border: 0; background: none;
  color: var(--accent); font-size: 12.5px; font-weight: 650;
  text-decoration: underline; cursor: pointer;
}
.steps { margin: 12px 0 0; padding-left: 20px; font-size: 13.5px; line-height: 1.95; }
.steps li { margin: 3px 0; }
.steps b { font-weight: 650; }

/* 备案号：大陆服务器上线后必须挂在首页底部，没配 BT_ICP_NO 时不渲染 */
.icp-foot {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.icp-foot a { color: var(--muted); text-decoration: none; }
.icp-foot a:active { color: var(--accent); }
.icp-foot .dot { margin: 0 6px; opacity: .55; }

/* ------------------------------------------------------------------ 回显清单 */
.echo {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 10px;
}
.echo .line {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.echo .line:last-child { border-bottom: 0; }
.echo .line .k { color: var(--muted); width: 42px; flex: none; font-size: 12.5px; }
.echo .line .v { flex: 1; word-break: break-word; }
.echo .line.bad { background: #FDF6F5; color: #B4232A; }

/* 自然语言解析：缺什么、为什么没看懂，逐条列出来 */
.nl-issues { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.nl-issue {
  padding: 9px 12px 10px;
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  background: #f7f8fa;
  font-size: 13px;
  line-height: 1.5;
}
.nl-issue b { display: block; color: #2A2325; font-weight: 600; }
.nl-issue span { display: block; margin-top: 3px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.nl-issue.error { border-left-color: #C62A2A; background: #FDF3F1; }
.nl-issue.warn { border-left-color: #B57500; background: #FDF7EC; }
.nl-issue.info { border-left-color: var(--accent); background: var(--accent-soft); }
.nl-sug { margin-top: 14px; }
.nl-sug .chips { margin-top: 8px; }
.nl-sug .chip { white-space: normal; text-align: left; line-height: 1.45; }

/* ------------------------------------------------------------------ 页面块 */
.page-head {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 20px; margin: 0; letter-spacing: -.3px; }
.page-head .meta { color: var(--muted); font-size: 13px; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid #EADCD9; border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.kv { display: grid; grid-template-columns: 84px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-all; }

/* ------------------------------------------------------------------ 弹窗（替代 prompt/confirm，微信 iOS 下原生弹窗不可靠） */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(96, 30, 40, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .16s ease-out;
}
.modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(18px + var(--safe-b));
  box-shadow: 0 -8px 40px rgba(96, 30, 40, .18);
  animation: rise .2s ease-out;
}
.modal h3 { margin: 0 0 6px; font-size: 16px; }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; line-height: 1.6; }
.modal .acts { display: flex; gap: 10px; margin-top: 16px; }
.modal .acts .btn { flex: 1; min-height: 42px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: .6; } }

/* ================================================================== 手机 */
@media (max-width: 760px) {
  :root { --topbar-h: 48px; }

  main { padding: 12px 12px calc(var(--tabbar-h) + var(--safe-b) + 20px); }
  .card { padding: 14px; border-radius: 11px; margin-bottom: 11px; }
  .card h2 { font-size: 14.5px; margin-bottom: 12px; }

  /* 日期三段下拉：手机上竖排，每行放得下三个，免得挤成火星文 */
  .code-field { max-width: none; }
  .date-range { grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
  .date-pick { gap: 5px; }
  .date-pick .input { padding: 10px 17px 10px 8px; background-position: right 3px center; }
  .chip { padding: 7px 12px; font-size: 13px; }

  /* 顶栏只留品牌与账号，导航挪到底部 */
  .topbar-inner { padding: 8px 12px; gap: 8px; }
  .nav.desktop-only { display: none; }
  .who .name { max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
  .brand { font-size: 15px; }

  .tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    background: rgba(255, 253, 253, .93);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--line);
    padding-bottom: var(--safe-b);
  }
  /* 底部固定标签栏 + 页脚备案号：留白要够，否则备案号被压在标签栏下面 */
  main { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 28px); }
  .tabbar a {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: var(--tabbar-h);
    color: var(--muted);
    font-size: 11px;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.7; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a:active { background: #FBF4F3; }

  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric { padding: 10px 11px; }
  .metric .v { font-size: 19px; }
  .presets { grid-template-columns: 1fr; }
  .preset { padding: 11px 12px; }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  /* 策略参数（周期数这类短数字）两列排，省掉一半滚动 */
  #params { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head h1 { font-size: 18px; }
  .page-head .meta { font-size: 12.5px; }

  /* 输入框字号必须 ≥16px，否则 iOS 微信点进去会自动放大整页 */
  .input, select.input, textarea.input { font-size: 16px; padding: 10px 11px; }
  select.input { padding-right: 28px; }   /* 给自绘的三角箭头留位，别压住文字 */
  .btn { min-height: 40px; padding: 9px 15px; }
  .btn.small { min-height: 32px; padding: 6px 10px; font-size: 12.5px; }
  .seg { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .seg button { flex: 1 0 auto; padding: 8px 12px; font-size: 13px; }

  /* 积木条件行：拆成三行，否则七个控件挤成一团 */
  .cond-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 9px 42px 9px 9px; position: relative; }
  .cr-a { flex: none; }
  .cr-b, .cr-c { flex: none; }
  .cr-c .c-rtype { width: 80px; }
  .c-del {
    position: absolute; top: 5px; right: 5px;
    width: 32px; height: 32px; min-height: 32px; padding: 0;
    font-size: 17px; line-height: 1; color: var(--muted);
  }

  table { font-size: 12.5px; }
  th, td { padding: 7px 9px; }
  .scroll-hint { display: block; }
  /* 手机已换成卡片列表，横向滑动提示就没意义了 */
  .list-cards + .scroll-hint { display: none; }

  /* 宽表格换成卡片列表 */
  .desk-only { display: none !important; }
  .hide-sm { display: none !important; }
  .list-cards { display: block; }

  .chart-tip { font-size: 11.5px !important; }
  .auth-wrap { padding: 18px 14px calc(18px + var(--safe-b)); }
  .auth-card { padding: 22px 18px; border-radius: 14px; }
  .auth-card h1 { font-size: 18px; }
  .kv { grid-template-columns: 76px 1fr; }
  .modal { padding: 18px 16px calc(16px + var(--safe-b)); }

  /* 主操作吸底：放在标签栏正上方，滚到哪儿都能一键开始 */
  .actionbar {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(var(--tabbar-h) + var(--safe-b));
    z-index: 35;
    margin: 0;
    padding: 8px 12px;
    background: rgba(255, 253, 253, .93);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 12px rgba(96, 30, 40, .05);
  }
  .actionbar .btn { min-height: 42px; }
  .actionbar .btn.primary { flex: 1 1 auto; min-width: 0; font-size: 15px; }
  .actionbar .btn:not(.primary) { flex: 0 0 auto; }
  .actionbar-space { display: block; height: 64px; }

  .card.fold { padding: 0; }
  .fold-head { padding: 14px; font-size: 14.5px; }
  .fold-body { padding: 0 14px 14px; }
  .fold-sum { max-width: 58%; }
  .step-no { width: 18px; height: 18px; border-radius: 5px; font-size: 11.5px; }
  .fold-cta { padding: 5px 9px 5px 12px; font-size: 12px; }
  .param-help { width: 18px; height: 18px; font-size: 12px; vertical-align: -4px; }
  pre.code { font-size: 12px; padding: 10px; }
}

/* 超小屏（iPhone SE 之类）再收一档 */
@media (max-width: 360px) {
  .metric .v { font-size: 17px; }
  .tabbar a { font-size: 10px; }
  .auth-tabs button { font-size: 12px; }
}
