/* ═══════════════════════════════════════════
   套保调整计算器 — 专业金融风 (v1.0)
   配色沿用 Kimi 可视化设计语言:
   极深蓝 #0A2540 · 暗金 #C5A059 · 青 #1A7A7A
   ═══════════════════════════════════════════ */
:root {
  --navy: #0A2540;
  --navy-2: #12365c;
  --gold: #C5A059;
  --gold-soft: #e6cf9d;
  --teal: #1A7A7A;
  --bg: #f2f4f8;
  --card: #ffffff;
  --line: #e3e8ef;
  --text: #1c2733;
  --muted: #7a8699;
  --good: #1a7a5a;
  --bad: #b03a3a;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

/* ── 顶栏 ─────────────────────────── */
.topbar { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff; }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 18px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { font-size: 30px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
.brand h1 { font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,.6); letter-spacing: .8px; margin-top: 2px; }
.pill { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); padding: 6px 14px; border-radius: 999px; font-size: 12.5px; white-space: nowrap; }
.pill.loading { animation: pulse 1.2s infinite; }
.pill b { color: var(--gold-soft); }
@keyframes pulse { 50% { opacity: .55; } }

/* ── 布局 ─────────────────────────── */
.container { max-width: 1080px; margin: 22px auto 40px; padding: 0 24px; display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; box-shadow: 0 1px 3px rgba(10,37,64,.06); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { font-size: 16.5px; color: var(--navy); font-weight: 700; }
.hint { font-size: 12px; color: var(--muted); }
.estate-file { font-size: 12px; color: var(--muted); font-family: var(--mono); }

/* ── 状态卡 ───────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat.accent { background: linear-gradient(150deg, var(--navy), var(--navy-2)); border-color: var(--navy); }
.stat.accent .stat-label, .stat.accent .stat-sub { color: rgba(255,255,255,.7); }
.stat.accent .stat-value { color: var(--gold-soft); }
.stat.accent2 { background: #fbf7ee; border-color: #e8d9b5; }
.stat.accent2 .stat-value { color: #8a6d1f; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 700; font-family: var(--mono); color: var(--navy); letter-spacing: -.5px; }
.stat-sub { font-size: 11px; color: var(--muted); }
.state-meta { margin-top: 12px; font-size: 12px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.state-meta .warn { color: var(--bad); }

/* ── 表单 ─────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.field .unit { font-size: 11px; color: var(--muted); font-weight: 400; }
.field input[type=number], .field input[type=text] {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 8px;
  font-size: 14px; font-family: var(--mono); color: var(--text); background: #fbfcfe;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(26,122,122,.12); }
.field-note { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.preview { color: var(--teal); font-weight: 600; }

/* 分段选择 */
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-sm { flex: 0 0 132px; }
.sub-row { display: flex; gap: 8px; align-items: stretch; }
.sub-row input { flex: 1; }
.sub-row .seg-btn { padding: 8px 6px; }
.seg-btn { flex: 1; padding: 9px 6px; background: #fbfcfe; border: none; font-size: 12.5px; color: var(--muted); cursor: pointer; transition: all .15s; font-weight: 600; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.active { background: var(--navy); color: #fff; }

/* 小标题 */
.sub-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.sub-head h3 { font-size: 14px; color: var(--navy); font-weight: 700; }
.badge { background: var(--gold); color: #fff; font-size: 11px; padding: 2px 9px; border-radius: 999px; font-weight: 700; margin-left: 6px; vertical-align: 2px; }

/* 表格 */
.table-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
table { width: 100%; border-collapse: collapse; }
th { background: #f0f3f8; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 12px; text-align: left; white-space: nowrap; }
td { padding: 6px 12px; border-top: 1px solid var(--line); font-size: 13px; }
.trade-table td, .fut-table td { vertical-align: middle; }
.th-note { font-weight: 400; font-size: 11px; }
.ta-r { text-align: right; } .ta-l { text-align: left; }
tfoot td { font-size: 12.5px; color: var(--navy); font-weight: 700; padding: 9px 12px; background: #fafbfd; border-top: 1px solid var(--line); }

.trade-table input, .fut-table input {
  width: 100%; padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 7px;
  font-size: 13px; font-family: var(--mono); background: #fbfcfe;
}
.trade-table input:focus, .fut-table input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(26,122,122,.1); }
.trade-table input.oad-auto { color: var(--muted); font-style: italic; }
.trade-table select {
  width: 100%; padding: 7px 8px; border: 1.5px solid var(--line); border-radius: 7px;
  font-size: 13px; background: #fbfcfe; color: var(--text);
}
td .code-cell { font-family: var(--mono); }
td.fut-info { font-family: var(--mono); color: var(--muted); font-size: 12px; white-space: nowrap; }
td.fut-ctd { font-size: 12px; font-family: var(--mono); color: var(--muted); }

/* 按钮 */
.btn { border: none; border-radius: 8px; cursor: pointer; font-weight: 600; transition: all .15s; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-gold { background: var(--gold); color: #fff; padding: 6px 14px; font-size: 12.5px; border-radius: 8px; border: none; cursor: pointer; font-weight: 700; }
.btn-gold:hover { background: #b08a42; }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--muted); border-radius: 8px; padding: 5px 12px; font-size: 12px; cursor: pointer; font-weight: 600; }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }
.btn-danger { background: transparent; border: none; color: var(--bad); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.btn-danger:hover { background: #fdecec; }

.action-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), #a8843f); color: #fff;
  border: none; padding: 13px 34px; border-radius: 10px; font-size: 15px; font-weight: 700;
  cursor: pointer; letter-spacing: 1px; box-shadow: 0 4px 14px rgba(197,160,89,.35);
  transition: transform .12s, box-shadow .12s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(197,160,89,.45); }
.btn-primary:disabled { opacity: .6; cursor: wait; transform: none; }
.calc-status { font-size: 12.5px; color: var(--muted); }

/* ── 结果 ─────────────────────────── */
.adjust-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.adjust-card { border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fafbfd; }
.adjust-card .ac-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.adjust-card .ac-contract { font-size: 16px; font-weight: 800; color: var(--navy); font-family: var(--mono); }
.adjust-card .ac-dpl { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.adjust-card .ac-action { font-size: 17px; font-weight: 800; padding: 4px 10px; border-radius: 8px; display: inline-block; }
.ac-action.add { background: #e7f4ee; color: var(--good); }
.ac-action.cut { background: #fdecec; color: var(--bad); }
.ac-action.hold { background: #eef1f6; color: var(--muted); }
.adjust-card .ac-nums { display: flex; gap: 18px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.adjust-card .ac-nums b { color: var(--text); font-family: var(--mono); }

.after-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }

.detail { border: 1px dashed var(--line); border-radius: 10px; padding: 12px 16px; margin-top: 4px; }
.detail summary { cursor: pointer; font-size: 13px; color: var(--navy); font-weight: 700; }
.detail-body { margin-top: 10px; font-size: 12.5px; color: var(--text); line-height: 1.8; font-family: var(--mono); white-space: pre-wrap; }
.detail-body .ok { color: var(--good); }
.detail-body .no { color: var(--bad); }

/* ── 页脚 ─────────────────────────── */
.foot { font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.8; padding: 8px 0 4px; }
.foot-warn { color: #b98a2e; }

/* ── Toast ─────────────────────────── */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--navy); color: #fff; padding: 11px 22px; border-radius: 999px; font-size: 13px; opacity: 0; transition: all .25s; z-index: 99; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--bad); }

@media (max-width: 720px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .topbar-inner { padding: 14px 16px; }
  .container { padding: 0 14px; }
}
