/* ============================================================
   青岚投资实验室 · 纸本金融
   米白纸底 / 墨色文字 / 青岚青强调 / 细分隔线 / 大留白
   ============================================================ */

:root {
  --paper: #FBFAF7;
  --paper-2: #F4F2EC;
  --ink: #1A1C20;
  --ink-2: #5A5E66;
  --ink-3: #9A9DA5;
  --hairline: #E8E4DC;
  --hairline-2: #DDD8CC;
  --accent: #2E6E5E;
  --accent-weak: #EAF1EE;
  --up: #C7443C;      /* 涨 · 中式红 */
  --down: #2E8B6E;    /* 跌 · 中式绿 */
  --up-weak: #F9ECEA;
  --down-weak: #E9F2EE;
  --gold: #B08D57;

  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(26,28,32,.04), 0 8px 28px -18px rgba(26,28,32,.18);
  --panel-w: 300px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(46,110,94,.05), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(46,110,94,.18); }

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

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

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(251,250,247,.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.brand-sub {
  font-size: 10px; letter-spacing: .22em; color: var(--ink-3);
  font-family: var(--sans); font-weight: 500;
}

.topbar-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.data-note { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.calc-status {
  font-size: 12px; color: var(--accent); white-space: nowrap;
  opacity: 0; transition: opacity .2s;
}
.calc-status.on { opacity: 1; }

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

.layout {
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr);
  gap: 28px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px 28px 60px;
  align-items: start;
}

.panel {
  position: sticky; top: 76px;
  display: flex; flex-direction: column; gap: 26px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 4px 2px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline-2) transparent;
}

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

/* ------------------------------------------------ 字段 ---- */

.field-title {
  font-size: 12px; font-weight: 600; letter-spacing: .12em;
  color: var(--ink-2); text-transform: uppercase;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.field-title::after {
  content: ""; flex: 1; height: 1px; background: var(--hairline);
}

/* 标的 */
.etf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.etf-chip {
  border: 1px solid var(--hairline);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  transition: border-color .15s, background .15s, transform .1s;
}
.etf-chip:hover { border-color: var(--accent); }
.etf-chip.active {
  border-color: var(--accent);
  background: var(--accent-weak);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.etf-chip .n { display: block; font-weight: 600; font-size: 13px; }
.etf-chip .c { display: block; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.etf-chip.active .c { color: var(--accent); }

/* 区间 */
.range-presets { display: flex; gap: 6px; margin-bottom: 10px; }
.range-presets button {
  flex: 1;
  border: 1px solid var(--hairline); background: #fff; color: var(--ink-2);
  border-radius: 6px; padding: 5px 0; font-size: 12px;
  transition: all .15s;
}
.range-presets button:hover { border-color: var(--accent); color: var(--accent); }
.range-presets button.active {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.range-inputs { display: flex; gap: 8px; }
.range-inputs label { flex: 1; display: flex; align-items: center; gap: 6px; }
.range-inputs span { font-size: 12px; color: var(--ink-3); }
.range-inputs input {
  width: 100%; min-width: 0;
  border: 1px solid var(--hairline); border-radius: 6px;
  padding: 5px 7px; font-size: 12px; background: #fff; color: var(--ink);
}
.range-inputs input:focus { outline: none; border-color: var(--accent); }

/* 策略 */
.preset-list { display: flex; flex-direction: column; gap: 6px; }
.preset-item {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--hairline); background: #fff;
  border-radius: 8px; padding: 9px 11px;
  text-align: left; transition: all .15s;
  width: 100%;
}
.preset-item:hover { border-color: var(--accent); }
.preset-item.active {
  border-color: var(--accent); background: var(--accent-weak);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.preset-item .dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--hairline-2); transition: background .15s;
}
.preset-item.active .dot { background: var(--accent); }
.preset-item .pn { font-weight: 600; font-size: 13px; }
.preset-item .pt {
  margin-left: auto; flex: none;
  font-size: 10px; color: var(--ink-3);
  border: 1px solid var(--hairline); border-radius: 4px; padding: 1px 6px;
  letter-spacing: .06em;
}
.preset-item.active .pt { color: var(--accent); border-color: rgba(46,110,94,.35); }

.ma-params { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.param-row { display: flex; align-items: center; gap: 10px; }
.param-label { font-size: 12px; color: var(--ink-2); flex: none; width: 44px; }
.param-row input[type="range"] {
  flex: 1; appearance: none; height: 3px; border-radius: 2px;
  background: var(--hairline-2); outline: none;
}
.param-row input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(26,28,32,.3); cursor: pointer;
}
.param-row output {
  flex: none; width: 34px; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px;
}
.param-hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.55; margin-top: 2px; }
.strategy-desc { font-size: 12px; color: var(--ink-2); line-height: 1.6; margin-top: 10px; }

/* 对比基线 */
.compare-list { display: flex; flex-direction: column; gap: 4px; }
.compare-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 7px; cursor: pointer;
  transition: background .15s; user-select: none;
}
.compare-item:hover { background: var(--paper-2); }
.compare-item input { display: none; }
.compare-item .box {
  width: 15px; height: 15px; flex: none;
  border: 1.5px solid var(--hairline-2); border-radius: 4px;
  display: grid; place-items: center; transition: all .15s;
  font-size: 10px; color: transparent; line-height: 1;
}
.compare-item input:checked + .box {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.compare-item .cn { font-size: 12.5px; color: var(--ink-2); }
.compare-item .swatch {
  margin-left: auto; width: 14px; height: 3px; border-radius: 2px; flex: none;
}

/* 高级 */
.advanced summary { cursor: pointer; list-style: none; }
.advanced summary::-webkit-details-marker { display: none; }
.adv-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.adv-grid label { font-size: 12px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.unit-input { display: flex; align-items: center; gap: 6px; }
.unit-input input {
  width: 100%;
  border: 1px solid var(--hairline); border-radius: 6px;
  padding: 6px 9px; font-size: 13px; background: #fff;
  font-variant-numeric: tabular-nums;
}
.unit-input input:focus { outline: none; border-color: var(--accent); }
.unit-input em { font-style: normal; font-size: 11px; color: var(--ink-3); flex: none; }

/* ------------------------------------------------ 指标 ---- */

.metric-hero { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric-card {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
}
.metric-label { font-size: 11.5px; letter-spacing: .1em; color: var(--ink-3); }
.metric-value {
  font-family: var(--serif);
  font-size: 30px; font-weight: 700; line-height: 1.25;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.metric-value.pos { color: var(--up); }
.metric-value.neg { color: var(--down); }
.metric-sub { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.metric-sub b { font-weight: 600; color: var(--ink-2); }

.metric-strip {
  display: flex; flex-wrap: wrap; gap: 8px 26px;
  padding: 10px 18px;
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  font-size: 12px; color: var(--ink-3);
}
.metric-strip b {
  color: var(--ink); font-weight: 600;
  font-variant-numeric: tabular-nums; margin-left: 4px;
}

/* ------------------------------------------------ 卡片/图表 ---- */

.card {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.chart-card { padding: 16px 18px 10px; }
.chart-card figcaption {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.chart-card h3 { font-size: 13.5px; font-weight: 600; letter-spacing: .02em; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.chart-legend .lg {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--ink-2); cursor: pointer;
  user-select: none; opacity: 1; transition: opacity .15s;
}
.chart-legend .lg.off { opacity: .35; }
.chart-legend .lg i {
  width: 14px; height: 3px; border-radius: 2px; display: inline-block;
}
.chart-legend .lg b { font-weight: 600; font-variant-numeric: tabular-nums; }

.chart { width: 100%; height: 300px; }
.chart-tall { height: 380px; }

.chart-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-duo .chart { height: 250px; }

/* 交易明细 */
.trades-card summary { cursor: pointer; list-style: none; padding: 14px 18px; }
.trades-card summary::-webkit-details-marker { display: none; }
.trades-card summary h3 { font-size: 13.5px; display: inline; }
.trades-card summary #trades-count { color: var(--ink-3); font-weight: 400; font-size: 12px; margin-left: 6px; }
.trades-card summary::after {
  content: "展开 ▾"; float: right; font-size: 11.5px; color: var(--ink-3);
}
.trades-card[open] summary::after { content: "收起 ▴"; }
.table-wrap { max-height: 420px; overflow: auto; padding: 0 8px 8px; }
.trades-card table { width: 100%; border-collapse: collapse; font-size: 12px; }
.trades-card th, .trades-card td {
  text-align: right; padding: 7px 10px;
  border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.trades-card th:first-child, .trades-card td:first-child { text-align: left; }
.trades-card th {
  position: sticky; top: 0; background: #fff;
  font-weight: 600; color: var(--ink-2); font-size: 11px;
  border-bottom: 1px solid var(--hairline-2);
}
.trades-card td.act-buy { color: var(--up); font-weight: 600; }
.trades-card td.act-sell { color: var(--down); font-weight: 600; }

/* 页脚 */
.site-foot {
  margin-top: 8px; padding: 14px 4px 0;
  border-top: 1px solid var(--hairline);
  font-size: 11.5px; color: var(--ink-3); line-height: 1.7;
}
.site-foot a { color: var(--accent); text-decoration: none; }
.site-foot a:hover { text-decoration: underline; }

/* ------------------------------------------------ 其他 ---- */

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  z-index: 100; animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

.hidden { display: none !important; }

.skeleton {
  position: relative; color: transparent !important; pointer-events: none;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(26,28,32,.06), transparent);
  animation: shimmer 1.1s infinite;
}
@keyframes shimmer { from { background-position: -200px 0; } to { background-position: 400px 0; } }

/* ------------------------------------------------ 响应式 ---- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .panel {
    position: static; max-height: none; overflow: visible;
    display: grid; grid-template-columns: 1fr 1fr; gap: 22px;
  }
  .metric-hero { grid-template-columns: repeat(2, 1fr); }
  .chart-duo { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .layout { padding: 18px 14px 40px; }
  .topbar { padding: 12px 14px; }
  .data-note { display: none; }
  .panel { grid-template-columns: 1fr; }
  .metric-hero { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-value { font-size: 24px; }
}
