/* 백테스팅 대시보드 (btd-*) — BuilderPageShell 내부 콘텐츠 스타일 */

.bps-page,
.se-page {
  --btd-gold: #c9a227;
  --btd-gold-light: #e8c547;
  --btd-gold-dark: #b8860b;
  --btd-gold-border: rgba(201, 162, 39, 0.18);
  --btd-gold-border-strong: rgba(201, 162, 39, 0.35);
  --btd-gold-bg: rgba(201, 162, 39, 0.08);
  --btd-gold-bg-hover: rgba(201, 162, 39, 0.14);
}

.se-page--light {
  --btd-gold-border: rgba(184, 134, 11, 0.28);
  --btd-gold-border-strong: rgba(184, 134, 11, 0.45);
  --btd-gold-bg: rgba(201, 162, 39, 0.1);
  --btd-gold-bg-hover: rgba(201, 162, 39, 0.16);
}

.bps-center-content .btd-empty span { font-size: 48px; opacity: 0.35; }
.btd-sidebar-hint { font-size: 0.72rem; opacity: 0.75; line-height: 1.6; }

.bps-panel-body .btd-timeline {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 4px 2px 8px 14px;
  min-height: 120px;
}

.bps-panel-body .btd-sidebar-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
  text-align: center;
  color: var(--se-text-dim);
  font-size: 0.78rem;
  gap: 8px;
}

.bps-center-content .btd-dashboard {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  overflow: hidden;
}

.bps-center-content .btd-empty {
  flex: 1;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--se-text-dim);
  font-size: 0.85rem;
}

.btd-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btd-meta-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--se-text);
}

.btd-footer-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.btd-footer-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--se-border);
  background: color-mix(in srgb, var(--se-bg-elevated) 88%, transparent);
}

.btd-footer-stat-label {
  font-size: 0.68rem;
  color: var(--se-text-muted);
}

.btd-footer-stat-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--se-text);
}

.btd-footer-stat-value.up { color: var(--se-up); }
.btd-footer-stat-value.down { color: var(--se-down); }

@media (max-width: 1200px) {
  .btd-footer-stats { grid-template-columns: repeat(2, 1fr); }
}

/* legacy page layout removed — shell handles structure */

.btd-timeline-line {
  position: absolute;
  left: 28px;
  top: 16px;
  bottom: 16px;
  width: 2px;
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.5), rgba(201, 162, 39, 0.08));
  border-radius: 1px;
  pointer-events: none;
}

.btd-timeline-item {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 0 0 0 16px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.btd-timeline-node {
  position: absolute;
  left: 0;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg3);
  border: 2px solid rgba(201, 162, 39, 0.45);
  z-index: 1;
}

.btd-timeline-item--active .btd-timeline-node {
  background: var(--btd-gold);
  border-color: var(--btd-gold-light);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.5);
}

.btd-timeline-card {
  background: var(--bg3);
  border: 1px solid var(--btd-gold-border);
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.btd-timeline-item:hover .btd-timeline-card {
  border-color: var(--btd-gold-border-strong);
}

.btd-timeline-item--active .btd-timeline-card {
  border-color: rgba(201, 162, 39, 0.65);
  box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.2), 0 4px 16px rgba(0, 0, 0, 0.15);
}

.btd-timeline-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.btd-timeline-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.btd-sparkline { flex-shrink: 0; opacity: 0.9; }

.btd-timeline-date {
  display: block;
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 6px;
}

.btd-timeline-roi {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 800;
}
.btd-timeline-roi.up {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.btd-timeline-roi.down {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ── 섹션 헤더 (금색 바) ── */
.btd-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.btd-section-bar {
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--btd-gold-light), var(--btd-gold-dark));
  flex-shrink: 0;
}

.btd-section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.btd-section-sub {
  margin: 1px 0 0;
  font-size: 9px;
  color: var(--text3);
  font-weight: 500;
}

.btd-section--kpi {
  flex: 0 0 auto;
}

.btd-section--chart {
  flex: 1.45;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.btd-section--table {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── KPI 카드 4열 ── */
.btd-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.btd-kpi-card {
  background: var(--bg2);
  border: 1px solid var(--btd-gold-border);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 0;
}

.btd-kpi-label {
  font-size: 10px;
  color: var(--text2);
  margin-bottom: 4px;
  font-weight: 600;
}

.btd-kpi-value {
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.5px;
}
.btd-kpi-value.up { color: #22c55e; }
.btd-kpi-value.down { color: #ef4444; }
.btd-kpi-value.gold { color: var(--btd-gold); }
.btd-kpi-value.neutral { color: var(--text2); }

.btd-kpi-desc {
  margin: 6px 0 0;
  font-size: 9px;
  color: var(--text3);
  line-height: 1.3;
}

.btd-kpi-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btd-kpi-icon {
  font-size: 20px;
  opacity: 0.6;
  color: var(--btd-gold);
}

.btd-kpi-dual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-top: 2px;
}

.btd-kpi-card--dual .btd-kpi-label {
  margin-bottom: 6px;
}

.btd-kpi-card--dual .btd-kpi-value {
  font-size: 22px;
}

/* ── 자산 곡선 차트 ── */
.btd-chart-card {
  flex: 1;
  min-height: 0;
  background: var(--bg2);
  border: 1px solid var(--btd-gold-border);
  border-radius: 10px;
  padding: 4px 8px 2px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.btd-chart-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
}

.btd-chart-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.btd-chart-grid {
  stroke: var(--sep);
  stroke-width: 1;
}

.btd-chart-label {
  fill: var(--text3);
}

.btd-chart-line-up { stroke: #22c55e; }
.btd-chart-line-down { stroke: #ef4444; }

/* ── 거래 내역 테이블 ── */
.btd-table-card {
  flex: 1;
  min-height: 0;
  background: var(--bg2);
  border: 1px solid var(--btd-gold-border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.btd-table-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
}

.btd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.btd-table thead {
  background: var(--btd-gold-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.btd-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--btd-gold);
  border-bottom: 1px solid var(--btd-gold-border);
  white-space: nowrap;
}

.btd-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--sep);
  color: var(--text);
}

.btd-table tbody tr:hover td {
  background: var(--btd-gold-bg);
}

.btd-table tbody tr:last-child td {
  border-bottom: none;
}

.btd-td-time {
  color: var(--text3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btd-table td.buy { color: var(--down, #3b82f6); font-weight: 700; }
.btd-table td.sell { color: var(--up, #ef4444); font-weight: 700; }
.btd-table td.up { color: #22c55e; font-weight: 700; }
.btd-table td.down { color: #ef4444; font-weight: 700; }

.btd-table-empty {
  text-align: center;
  color: var(--text3);
  padding: 24px !important;
}

@media (max-width: 1100px) {
  .btd-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .btd-page { flex-direction: column; height: auto; overflow: auto; }
  .btd-sidebar {
    width: 100%;
    max-height: 240px;
    border-right: none;
    border-bottom: 1px solid var(--btd-gold-border);
  }
  .btd-kpi-grid { grid-template-columns: 1fr 1fr; }
}
