/* ===== 小清新浅色主题 · 移动端优先 ===== */
:root {
  --bg: #f4f7fb;
  --bg-soft: #eef3fa;
  --card: #ffffff;
  --card-2: #f7fafd;
  --line: #e7eef6;
  --text: #24324a;
  --muted: #8fa0b8;
  --up: #2bb673;
  --up-soft: #e8f7f0;
  --down: #ef6a6a;
  --down-soft: #fdeeee;
  --accent: #4f8ef7;
  --accent-soft: #e8f1fe;
  --warn: #f5a623;
  --warn-soft: #fff6e6;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(38, 64, 110, 0.07);
  --shadow-soft: 0 1px 4px rgba(38, 64, 110, 0.05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "MiSans", "HarmonyOS Sans", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
input, select, textarea, button { font-family: inherit; font-size: 15px; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

/* ===== 顶部栏 ===== */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(244, 247, 251, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-title { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, #6fb1ff, #4f8ef7);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
  box-shadow: 0 3px 8px rgba(79, 142, 247, 0.35);
}
.app-title h1 { margin: 0; font-size: 17px; font-weight: 700; color: var(--text); }
.app-title p { margin: 0; font-size: 11px; color: var(--muted); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--card); color: var(--accent); font-size: 17px; cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.icon-btn:active { transform: scale(0.95); }

/* ===== 视图 ===== */
.view { padding: 12px 14px 20px; max-width: 560px; margin: 0 auto; }
.view h2 { font-size: 16px; margin: 8px 0 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.big-num { font-size: 32px; font-weight: 800; letter-spacing: 0.3px; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }

.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-top: 10px; }
.kv { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.kv .k { font-size: 11px; color: var(--muted); }
.kv .v { font-size: 15px; font-weight: 700; margin-top: 2px; }

/* 资产占比条 */
.alloc-bar {
  display: flex; height: 12px; border-radius: 99px; overflow: hidden;
  margin: 8px 0 4px; background: var(--bg-soft);
}
.alloc-bar div { height: 100%; }

/* ===== 持仓卡片 ===== */
.pos-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 2px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.pos-row:last-child { border-bottom: none; }
.pos-name { font-weight: 700; font-size: 15px; }
.pos-code { font-size: 11px; color: var(--muted); margin-top: 2px; }
.pos-price { font-size: 15px; font-weight: 700; }
.pos-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.pos-right { text-align: right; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 700; margin-left: 6px;
  vertical-align: 1px;
}
.badge.up { background: var(--up-soft); color: var(--up); }
.badge.down { background: var(--down-soft); color: var(--down); }

/* ===== 计划 ===== */
.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.cfg-grid label { font-size: 11px; color: var(--muted); }
.cfg-grid input {
  width: 100%; background: var(--card-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); padding: 8px 10px; margin-top: 3px;
}
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table.plan {
  width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px;
  min-width: 430px;
}
table.plan th {
  color: var(--muted); font-weight: 500; text-align: right; padding: 5px 5px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.plan th:first-child, table.plan td:first-child { text-align: left; }
table.plan td { text-align: right; padding: 7px 5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.triggered { color: var(--warn); font-weight: 800; }
.fired { color: var(--muted); text-decoration: line-through; }

/* 加仓计划/卖回计划(纵向列表,免横向滑动) */
.lv-row {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 11px; margin-bottom: 8px; background: var(--card-2);
}
.lv-row.fired { opacity: .62; }
.lv-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lv-idx {
  font-size: 11px; font-weight: 800; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px; padding: 2px 7px;
}
.lv-trigger { font-size: 13px; }
.lv-drop { font-size: 12px; font-weight: 700; margin-left: auto; }
.lv-sub {
  font-size: 11px; color: var(--muted); margin-top: 5px;
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.lv-status { font-size: 11px; }
.lv-action { margin-top: 8px; }
.lv-action .btn { width: 100%; }
.lv-done { font-size: 12px; font-weight: 800; color: var(--up); }

.batch-row {
  border: 1px dashed var(--line); border-radius: 12px;
  padding: 9px 11px; margin-bottom: 8px; background: var(--card);
}
.batch-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.batch-name { font-size: 13px; font-weight: 700; }
.batch-sell { font-size: 13px; }
.batch-status { margin-left: auto; font-size: 12px; font-weight: 600; }
.batch-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.tag.ok { background: var(--up-soft); color: var(--up); }

.alert-item {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 11px 12px; border-radius: 12px; margin-bottom: 8px;
  font-size: 13px;
}
.alert-item.warn { background: var(--warn-soft); border-left: 3px solid var(--warn); }
.alert-item.ok { background: var(--up-soft); border-left: 3px solid var(--up); }
.alert-item .ico { font-size: 15px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-block; border: none; border-radius: 12px;
  padding: 11px 16px; font-weight: 700; cursor: pointer;
  background: var(--accent); color: #fff; text-align: center;
  box-shadow: 0 3px 8px rgba(79, 142, 247, 0.28);
}
.btn:active { transform: scale(0.97); filter: brightness(0.95); }
.btn.block { display: block; width: 100%; }
.btn.ghost {
  background: var(--card); color: var(--accent);
  border: 1px solid var(--accent); box-shadow: none;
}
.btn.warn { background: var(--warn); box-shadow: 0 3px 8px rgba(245, 166, 35, 0.28); }
.btn.danger { background: var(--down); box-shadow: 0 3px 8px rgba(239, 106, 106, 0.28); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; }

/* ===== 导入(手动) ===== */
.hint {
  font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.7;
}
textarea.csv {
  width: 100%; min-height: 130px; background: var(--card-2);
  border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  padding: 10px; font-size: 13px; line-height: 1.7;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
textarea.csv:focus { border-color: var(--accent); outline: none; }
.review-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 460px; }
.review-table th { color: var(--muted); font-size: 11px; text-align: left; padding: 5px; border-bottom: 1px solid var(--line); }
.review-table td { padding: 5px; }
.review-table input {
  width: 100%; background: var(--card-2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); padding: 6px 8px; font-size: 13px;
  min-height: 36px;
}
.review-table input:focus { border-color: var(--accent); outline: none; }
.progress-bar { height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-bar div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* ===== 设置 ===== */
.row-line {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 0; border-bottom: 1px solid var(--line); gap: 10px;
}
.row-line:last-child { border-bottom: none; }
.row-line .lbl { font-size: 14px; font-weight: 600; }
.row-line .sub { font-size: 11px; color: var(--muted); }
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: #d8e2ef; border-radius: 99px; transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--up); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ===== 底部导航 ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(38, 64, 110, 0.05);
}
.tab {
  flex: 1; padding: 7px 0 7px; background: none; border: none;
  color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab .tab-ico { font-size: 18px; line-height: 1; }
.tab.active { color: var(--accent); }
.tab.active .tab-ico { transform: scale(1.08); }

/* ===== 弹窗(底部抽屉) ===== */
.modal-root {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(30, 45, 70, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(30, 45, 70, 0.18);
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.modal h3 { margin: 0 0 12px; font-size: 17px; }

/* ===== 提示 ===== */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(36, 50, 74, 0.94); color: #fff;
  padding: 10px 18px; border-radius: 99px; z-index: 99;
  font-size: 13px; box-shadow: 0 6px 20px rgba(30, 45, 70, 0.3);
  max-width: 88vw; text-align: center;
}

/* 资金曲线 */
svg.chart { width: 100%; height: 150px; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.empty-tip { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; }

/* 列表项操作按钮 */
.mini-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ===== 持仓页(清爽列表) ===== */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar .btn { flex: 1; }

.pos-list { margin: 0 -2px; }
.pos-item { padding: 13px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pos-item:last-child { border-bottom: none; }
.pos-item:active { background: var(--card-2); border-radius: 10px; }
.pos-item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pos-item-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.pos-name { font-weight: 700; font-size: 15px; }
.pos-code { font-size: 11px; color: var(--muted); }
.tag {
  font-size: 10px; padding: 1px 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
  white-space: nowrap;
}
.pos-item-right { text-align: right; flex-shrink: 0; }
.pos-px { font-size: 16px; font-weight: 700; }
.chg { font-size: 11px; margin-left: 5px; font-weight: 600; }
.pos-item-sub {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 5px; gap: 10px;
}
.meta { font-size: 11px; color: var(--muted); }
.pnl { font-size: 13px; font-weight: 700; white-space: nowrap; }
