/* ── BOND ANALYSIS ─────────────────────────────────────────────── */
.sim-page {
  flex: 1; overflow-x: hidden; overflow-y: auto; padding: 20px;
  background: var(--bg);
  box-sizing: border-box;
  min-width: 0;
}
.sim-page::-webkit-scrollbar { width: 6px; }
.sim-page::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* Responsive two-column layout: stacks to single column on narrow screens */
.sim-grid {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
@media (max-width: 900px) {
  .sim-grid { grid-template-columns: 1fr; }
}

.sim-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0; box-sizing: border-box; width: 100%;
}
.sim-title { font-family: var(--serif); font-size: calc(18px * var(--fs)); color: var(--text); margin-bottom: 14px; }
.sim-label { font-size: calc(11px * var(--fs)); font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; display: block; }
.sim-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); font-family: var(--mono); font-size: calc(12px * var(--fs));
  padding: 7px 10px; border-radius: var(--radius); margin-bottom: 10px;
  box-sizing: border-box;
}
.sim-input:focus { outline: none; border-color: var(--accent); background: var(--bg2); }
.sim-select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); font-family: var(--mono); font-size: calc(12px * var(--fs));
  padding: 7px 10px; border-radius: var(--radius); margin-bottom: 10px;
  appearance: none; cursor: pointer; box-sizing: border-box;
}
.sim-select:focus { outline: none; border-color: var(--accent); }
#sim-bond-select:not(.bond-selected) { border-color: var(--accent); }
.sim-run-btn {
  width: 100%; padding: 9px;
  background: var(--accent); color: #111; border: none;
  border-radius: var(--radius); font-family: var(--sans);
  font-size: calc(13px * var(--fs)); font-weight: 600;
  cursor: pointer; transition: background 0.15s;
  box-shadow: 0 2px 6px rgba(180,140,50,0.3);
}
.sim-run-btn:hover { background: var(--accent2); }

/* Metric cards: 4-column grid, wraps gracefully */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 700px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.metric-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  min-width: 0; box-sizing: border-box;
  overflow: hidden;
}
.metric-card-label {
  font-size: calc(10px * var(--fs)); color: var(--text2); margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.metric-card-val {
  font-family: var(--mono); font-size: calc(13px * var(--fs));
  font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.metric-card-val.green { color: var(--green); }
.metric-card-val.blue { color: var(--accent); }

.cashflow-table { width: 100%; border-collapse: collapse; font-size: calc(12px * var(--fs)); }
.cashflow-table th { background: var(--bg3); padding: 7px 10px; font-size: calc(10px * var(--fs)); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); text-align: left; border-bottom: 1px solid var(--border); }
.cashflow-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); font-family: var(--mono); color: var(--text2); }
.cashflow-table tr:last-child td { font-weight: 600; color: var(--text); background: var(--bg3); }
.cashflow-table .pos { color: var(--green); }

/* ── CHART AREA ───────────────────────────────────────────────────── */
.chart-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  box-shadow: var(--shadow); height: 300px; position: relative;
  margin-bottom: 16px;
}
.chart-placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text3); font-size: calc(13px * var(--fs));
  font-style: italic;
}

/* ── AI SCORE ─────────────────────────────────────────────────────── */
.ai-score-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.ai-stars { color: #d4a843; font-size: 13px; letter-spacing: 1px; line-height: 1; }
.ai-stars .empty { color: var(--border2); }
.ai-score-loading { font-size: 10px; color: var(--text3); font-style: italic; font-family: var(--mono); animation: blink2 1.2s infinite; }
@keyframes blink2 { 0%,100%{opacity:0.6}50%{opacity:0.2} }
.ai-score-num { font-family: var(--mono); font-size: 10px; color: var(--text3); }

/* ── DETAIL PANEL wrap fix ────────────────────────────────────────── */
.detail-panel {
  padding: 18px 20px;
  border-top: 2px solid var(--accent);
  background: var(--bg2);
  box-shadow: inset 0 2px 8px rgba(255,255,255,0.02);
  /* Key fix: constrain to the visible table area, not the full scrollable width */
  width: calc(100vw - 260px - 40px); /* viewport minus filter panel minus padding */
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}
.dp-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
  width: 100%;
}
.dp-v {
  font-family: var(--mono); font-size: calc(12px * var(--fs));
  color: var(--text); text-align: right;
  max-width: 100%; white-space: normal;
  word-break: break-word; line-height: 1.4;
}
.dp-k { font-size: calc(12px * var(--fs)); color: var(--text3); white-space: nowrap; min-width: 0; }
.dp-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
.dp-kv { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dp-overview {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 16px;
  width: 100%; box-sizing: border-box;
}
.dp-overview p { font-size: calc(12px * var(--fs)); color: var(--text2); line-height: 1.65; margin-bottom: 5px; white-space: normal; word-wrap: break-word; }
.ai-box {
  background: rgba(255,82,82,0.05); border: 1px solid rgba(255,82,82,0.18);
  border-radius: var(--radius-lg); padding: 14px 16px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}
.cashflow-table th { background: var(--bg3); padding: 7px 10px; font-size: calc(10px * var(--fs)); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); text-align: left; border-bottom: 1px solid var(--border2); }
.cashflow-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); font-family: var(--mono); color: var(--text2); }
.cashflow-table tr:last-child td { font-weight: 600; color: var(--text); background: var(--bg3); }
.yield-bar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 6px 16px; display: flex; align-items: center; gap: 16px;
  flex-shrink: 0; flex-wrap: wrap;
}
.yield-bar-label { font-size: calc(10px * var(--fs)); color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.yield-item { display: flex; align-items: baseline; gap: 4px; }
.yield-item-tenor { font-family: var(--mono); font-size: calc(10px * var(--fs)); color: var(--text3); }
.yield-item-val { font-family: var(--mono); font-size: calc(12px * var(--fs)); color: var(--green); font-weight: 600; }
