/* optionpayoff — tool-specific styles
   Only what is unique to this tool. Shared appearance (toolbox, field, alert,
   chips) already lives in the shell's global stylesheet.

   ★ 统计卡用本工具自己的 .op-kv：工具样式按工具隔离加载，
     .ts-kv 定义在 timestamp 的样式表里，在这里**不存在** ——
     第一版借类名导致统计卡退化成裸文本列（2026-09-29 师傅目检抓到）。

   ★ 盈亏两色的语义：绿色 = 利润区、红色 = 亏损区（国际期权平台的通行画法，
     图上另有文字图例说明，颜色不是唯一的信息通道）。
   ★ 两套色都随主题走：浅色/深色各给一组，用 html[data-theme="dark"] 覆盖 ——
     不往全局样式表里加任何变量。 */

.op-leg {
  display: grid;
  grid-template-columns: 88px 92px 1fr 1fr 76px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.op-leg--head {
  margin-bottom: 10px;
}

.op-leg--head .field__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
}

.op-leg--head span:last-child {
  width: 36px;
}

.op-sel {
  width: 100%;
}

.op-qty {
  max-width: 76px;
}

.op-addrow {
  margin-top: 4px;
}

/* 统计卡网格：与 timestamp 的 .ts-kv / phone 的 .ph-kv 同一种重复是有意接受的
   （工具样式隔离 ⇒ 每个 widget 自带一份，见 tools/regex/styles.css 头注）。 */
.op-kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.op-kv__item {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.op-kv__k {
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
}

.op-kv__v {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--fg);
  word-break: break-all;
}

.op-stat__note {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--fg-faint);
}

/* 图表 */
.op-chart {
  --op-profit: rgba(23, 133, 83, 0.22);
  --op-profit-line: #178553;
  --op-loss: rgba(198, 40, 40, 0.18);
  --op-loss-line: #c62828;

  display: block;
  width: 100%;
  height: auto;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

html[data-theme='dark'] .op-chart {
  --op-profit: rgba(74, 178, 128, 0.25);
  --op-profit-line: #5cc491;
  --op-loss: rgba(224, 110, 110, 0.22);
  --op-loss-line: #e07e7e;
}

.op-grid line {
  stroke: var(--line);
  stroke-width: 1;
}

.op-grid text {
  font-family: var(--mono);
  font-size: 10.5px;
  fill: var(--fg-faint);
}

.op-zero {
  stroke: var(--fg-muted);
  stroke-width: 1.2;
  stroke-dasharray: 5 4;
}

.op-area-profit {
  fill: var(--op-profit);
  stroke: none;
}

.op-area-loss {
  fill: var(--op-loss);
  stroke: none;
}

.op-line {
  fill: none;
  stroke: var(--fg);
  stroke-width: 2;
  stroke-linejoin: round;
}

.op-be {
  fill: var(--accent);
  stroke: var(--accent-fg);
  stroke-width: 1.5;
}

.op-axis {
  font-family: var(--mono);
  font-size: 10.5px;
  fill: var(--fg-faint);
}

.op-axis-title {
  font-size: 11px;
  font-weight: 600;
  fill: var(--fg-muted);
  letter-spacing: 0.05em;
}

/* 图例 */
.op-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--fg-muted);
}

.op-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.op-legend__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.op-legend__swatch--profit {
  background: rgba(23, 133, 83, 0.55);
}

.op-legend__swatch--loss {
  background: rgba(198, 40, 40, 0.5);
}

.op-legend__swatch--be {
  background: var(--accent);
  border-radius: 50%;
  width: 10px;
  height: 10px;
}

.op-legend__hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--fg-faint);
}

/* 窄屏：腿编辑器折成两行（选择一行、数字一行），表头隐藏 */
@media (max-width: 640px) {
  .op-leg {
    grid-template-columns: 1fr 1fr 1fr;
    grid-auto-rows: auto;
    row-gap: 6px;
  }

  .op-leg--head {
    display: none;
  }

  .op-leg .op-num[data-k='strike'],
  .op-leg .op-num[data-k='premium'] {
    grid-column: auto;
  }

  .op-leg .op-qty {
    max-width: none;
  }
}
