/* 保险利益演算台 —— 深色底 + 绿色主色。
   配色只用于区分数据系列，不代表任何好坏含义。 */

:root {
  --bg: #0b0f14;
  --panel: #131a22;
  --panel-2: #182029;
  --line: #232c37;
  --line-soft: #1b232c;
  --text: #e6edf3;
  --text-2: #9aa7b4;
  --text-3: #6b7784;
  --primary: #3fb950;
  --primary-dim: rgba(63, 185, 80, .12);
  --accent: #58a6ff;
  --soft: #a371f7;
  --muted: #5d6b7a;
  --warn: #d29922;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #101821, #0d1319);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 14px; }

.logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: radial-gradient(circle at 30% 30%, #4ade80, #15803d 70%);
  box-shadow: 0 0 0 1px rgba(63,185,80,.25), 0 6px 18px rgba(21,128,61,.28);
  flex: 0 0 auto;
}

.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.topbar p { margin: 1px 0 0; font-size: 12px; color: var(--text-3); }

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 11px;
  border: 1px solid rgba(63,185,80,.32);
  background: var(--primary-dim);
  border-radius: 999px;
  font-size: 12.5px;
  color: #9ce8a8;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(63,185,80,.18);
}
.badge.bad { border-color: rgba(210,153,34,.4); background: rgba(210,153,34,.1); color: #f0c674; }
.badge.bad .dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(210,153,34,.18); }

/* ---------------- 布局 ---------------- */

.layout {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 22px;
  padding: 22px 28px 60px;
  max-width: 1560px;
  margin: 0 auto;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 88px;
}

.panel-head h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-3);
  margin: 0 0 10px;
  font-weight: 600;
}

/* ---------------- 产品列表 ---------------- */

.product-list { display: flex; flex-direction: column; gap: 7px; }

/* 大类分组标题：表头按类统一，列表也要看得出「同类」是哪几款 */
.prod-group {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 6px 0 1px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line-soft);
}
.prod-group:first-child { margin-top: 0; }
.prod-group .pg-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.prod-group .pg-count { font-size: 11px; color: var(--primary); font-variant-numeric: tabular-nums; }
.prod-group .pg-hint { font-size: 10.5px; color: var(--text-3); margin-left: auto; }

.prod {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-family: inherit;
  font-size: 13px;
}
.prod:hover { border-color: #2f3d4b; background: #1c242e; }
.prod.active {
  border-color: rgba(63,185,80,.55);
  background: linear-gradient(180deg, rgba(63,185,80,.10), rgba(63,185,80,.03));
  box-shadow: inset 0 0 0 1px rgba(63,185,80,.12);
}
.prod .p-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prod .p-name { font-weight: 500; line-height: 1.35; }
.prod .p-meta { display: flex; gap: 6px; align-items: center; margin-top: 5px; font-size: 11px; color: var(--text-3); }
.prod .p-check { font-size: 10.5px; color: var(--primary); font-variant-numeric: tabular-nums; white-space: nowrap; }

.chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  line-height: 1.5;
  border: 1px solid var(--line);
  color: var(--text-2);
  background: #0f151c;
  white-space: nowrap;
}
.chip.kind { color: #7cc4ff; border-color: rgba(88,166,255,.25); background: rgba(88,166,255,.08); }
.chip.tag { color: #c0a8ff; border-color: rgba(163,113,247,.25); background: rgba(163,113,247,.08); }

/* ---------------- 表单 ---------------- */

.form { display: flex; flex-direction: column; gap: 12px; }

.field label {
  display: block;
  font-size: 11.5px;
  color: var(--text-2);
  margin-bottom: 5px;
  letter-spacing: .2px;
}

.field select, .field input {
  width: 100%;
  background: #0f151c;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 13.5px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color .15s;
  appearance: none;
}
.field select:focus, .field input:focus { border-color: rgba(63,185,80,.6); }
.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.field .range-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }

.quick-amounts { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }
.qa {
  flex: 1 0 auto;
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: #0f151c;
  color: var(--text-3);
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all .12s;
  font-variant-numeric: tabular-nums;
}
.qa:hover { color: var(--text); border-color: #33414f; }
.qa.on { color: var(--primary); border-color: rgba(63,185,80,.5); background: rgba(63,185,80,.08); }

.param-actions { display: flex; gap: 8px; margin-top: 16px; }

.btn {
  flex: 1;
  padding: 9px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: #33414f; color: var(--text); background: #1c242e; }
.btn.ghost:active { transform: translateY(1px); }

.note-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.6;
}
.note-box .nb-title { color: var(--text-2); margin-bottom: 5px; font-size: 11.5px; }
.note-box ul { margin: 6px 0 0; padding-left: 16px; }
.note-box li { margin-bottom: 5px; }

/* ---------------- 结果区 ---------------- */

.results { min-width: 0; display: flex; flex-direction: column; gap: 18px; }

.placeholder {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 80px 20px;
  text-align: center;
  color: var(--text-3);
}

.result-body { display: flex; flex-direction: column; gap: 18px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
}

.kpi {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
}
.kpi .k-label { font-size: 11.5px; color: var(--text-3); letter-spacing: .2px; }
.kpi .k-value {
  font-size: 22px;
  font-weight: 600;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.3px;
  color: var(--text);
}
.kpi .k-value .unit { font-size: 12.5px; color: var(--text-3); font-weight: 400; margin-left: 3px; }
.kpi.accent .k-value { color: var(--primary); }
.kpi .k-hint { font-size: 11px; color: var(--text-3); margin-top: 6px; line-height: 1.45; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { height: 0; border-top: 2px dashed currentColor; }

/* ---------------- 图表 ---------------- */

.chart-wrap { position: relative; width: 100%; height: 340px; }
#chart { width: 100%; height: 100%; display: block; overflow: visible; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(16,22,29,.96);
  border: 1px solid #2b3644;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  white-space: nowrap;
  z-index: 5;
  transform: translate(-50%, -100%);
  font-variant-numeric: tabular-nums;
}
.tooltip .tt-x { color: var(--text-3); margin-bottom: 3px; font-size: 11px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; }
.tooltip .tt-row i { width: 8px; height: 8px; border-radius: 2px; }
.tooltip .tt-row b { font-weight: 500; color: var(--text-2); }
.tooltip .tt-row em { font-style: normal; margin-left: auto; padding-left: 12px; }

/* ---------------- 时间轴 ---------------- */

.timeline { display: flex; gap: 0; overflow-x: auto; padding-bottom: 4px; }

.tl-item {
  position: relative;
  flex: 1 0 auto;
  min-width: 180px;
  padding: 0 18px 0 0;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: 0; top: 7px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(63,185,80,.15);
}
.tl-item::after {
  content: "";
  position: absolute;
  left: 12px; top: 11px; right: 6px;
  border-top: 1px dashed var(--line);
}
.tl-item:last-child::after { display: none; }
.tl-inner { padding-left: 20px; }
.tl-age { font-size: 12px; color: var(--primary); font-variant-numeric: tabular-nums; }
.tl-title { font-size: 13px; margin-top: 1px; }
.tl-detail { font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }

/* ---------------- 表格 ---------------- */

.table-tools { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--text-2); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--primary); width: 13px; height: 13px; }
.hint { color: var(--text-3); font-size: 11.5px; }

.table-wrap {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }

thead th {
  position: sticky;
  top: 0;
  background: #171f28;
  color: var(--text-2);
  font-weight: 500;
  font-size: 11.5px;
  text-align: right;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  z-index: 2;
}
thead th:first-child, tbody td:first-child { text-align: left; }
thead th.primary { color: var(--primary); }

/* 分红型的两级表头：第一行是分组（保险费 / 当年度增额红利 / 现金价值…），
   第二行是「保证利益 / 红利利益」。两行都要 sticky，第二行得错开第一行的高度，
   否则滚动时两行会叠在一起，看起来像只有一行。 */
thead th.grp {
  height: 32px;
  padding: 0 12px;
  text-align: center;
  color: var(--text);
  font-weight: 600;
  border-left: 1px solid var(--line);
}
thead th.sub {
  top: 32px;
  height: 30px;
  padding: 0 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text-2);
  border-left: 1px solid var(--line-soft);
}
thead th.sub.est { color: #8a9aad; background: #141b24; }

tbody td {
  padding: 7px 12px;
  text-align: right;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
}
tbody td.primary { color: var(--text); font-weight: 500; }
/* 红利利益列：官方演示值，比保证利益列弱一档，避免被当成承诺 */
tbody td.est { color: #7d8b9c; }
tbody tr:hover td { background: #161e27; }
tbody tr.mark td { background: rgba(63,185,80,.06); }
tbody tr.mark td:first-child { box-shadow: inset 2px 0 0 var(--primary); }
tbody td:first-child { color: var(--text-2); }

.badge-mini {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 10px;
  background: rgba(63,185,80,.14);
  color: #7fdc8e;
  vertical-align: 1px;
}

.disclaimer {
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.7;
  border-left: 2px solid var(--line);
  padding-left: 12px;
  margin: 0;
}

.error-box {
  border: 1px solid rgba(210,153,34,.35);
  background: rgba(210,153,34,.07);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: #f0c674;
  font-size: 13px;
}
.error-box .e-hint { color: var(--text-2); font-size: 12.5px; margin-top: 6px; }

/* ---------------- 打印 ---------------- */

@media print {
  /* 分红型双栏表是 18 列，A4 纵向无论如何塞不下——右侧「现金价值」会被裁掉，
     而现金价值恰恰是客户最先看的一列。所以打印一律走横向。 */
  @page { size: A4 landscape; margin: 10mm; }
  :root { --bg: #fff; --panel: #fff; --panel-2: #fff; --text: #111; --text-2: #333;
          --text-3: #666; --line: #ddd; --line-soft: #eee; }
  body { background: #fff; color: #111; }
  .topbar, .panel, .param-actions, .table-tools, .tooltip { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .card { break-inside: avoid; border-color: #ddd; }
  .kpi { break-inside: avoid; }
  .table-wrap { max-height: none; overflow: visible; }
  thead th { background: #f4f4f4; color: #111; }
  tbody td { color: #111; }

  /* 18 列 × 10 个数字，字号和留白必须压下来，否则一行就折行 */
  table { font-size: 9px; }
  thead th, tbody td { padding: 2px 5px; }
  thead th.grp { height: 20px; }
  thead th.sub { top: 20px; height: 18px; font-size: 8px; }
  .table-note { font-size: 8.5px; padding: 5px 8px; background: #fafafa; }

  .kpi .k-value.accent, .kpi.accent .k-value { color: #111; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .panel { position: static; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* ---------------- 大都会在售产品库 ---------------- */

.lib-btn {
  width: 100%;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.lib-count {
  padding: 0 6px;
  border-radius: 9px;
  background: var(--primary-dim);
  color: var(--primary);
  font-size: 11px;
  font-family: var(--mono);
}

.library-view { padding: 4px 2px 0; }
.library-intro {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-3);
}
.library-table th:nth-child(3),
.library-table th:nth-child(4),
.library-table th:nth-child(5) { text-align: center; width: 92px; }
.library-table td:nth-child(3),
.library-table td:nth-child(4),
.library-table td:nth-child(5) { text-align: center; }
.library-table th:nth-child(2) { width: 92px; }
.lib-name { color: var(--text); }
.lib-yes { color: var(--primary); font-family: var(--mono); }
.lib-no { color: var(--text-3); font-family: var(--mono); }
.lib-reason { font-size: 11.5px; color: var(--text-3); }
.lib-loading { padding: 28px; text-align: center; color: var(--text-3); }
.lib-go {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(63, 185, 80, .4);
  background: var(--primary-dim);
  color: var(--primary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.lib-go:hover { background: rgba(63, 185, 80, .22); }

/* 表格上方的数据来源说明 */
.table-note {
  margin: 0 0 10px;
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--warn, #d29922);
  border-radius: 6px;
  background: #151d26;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.65;
}
.table-note.ok { border-left-color: var(--primary); }

/* 18 列的表横向滚动时，保单年度要钉在左边，否则滚到右边就不知道看的是第几年 */
thead th.stick, tbody td.stick {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 3;
}
thead th.stick { top: 0; z-index: 4; }
tbody tr:hover td.stick { background: #161e27; }
tbody tr.mark td.stick { background: #14201b; }
thead th.grp.stick, thead th.sub.stick { background: #171f28; }

/* 未命中官方演示时，把可用的官方参数做成可点的按钮 */
.case-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.case-chip {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-2);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
}
.case-chip:hover { border-color: var(--primary); color: var(--primary); }
