/* chart_engine.css — Chart Engine dashboard styles */

/* Page-level tinting like R&D */
body[data-env="chart_engine"] .page-wrap {
  background: linear-gradient(180deg, rgba(16,185,129,0.03) 0%, transparent 30%);
}

/* Leaderboard cards */
.ce-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.ce-card:active { transform: scale(.98); }
.ce-card.strong { border-color: rgba(16,185,129,0.4); background: rgba(16,185,129,0.06); }
.ce-card.medium { border-color: rgba(16,185,129,0.2); background: rgba(16,185,129,0.03); }
.ce-card.bear.strong { border-color: rgba(255,59,92,0.4); background: rgba(255,59,92,0.06); }
.ce-card.bear.medium { border-color: rgba(255,59,92,0.2); background: rgba(255,59,92,0.03); }
.ce-card-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ce-card-right { flex-shrink: 0; text-align: right; max-width: 55%; }

.ce-ticker { font-size: 16px; font-weight: 800; font-family: monospace; letter-spacing: .5px; }
.ce-dir-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.ce-dir-badge.bull { background: var(--go-dim); color: var(--go); }
.ce-dir-badge.bear { background: var(--stop-dim); color: var(--stop); }
.ce-dir-badge.neutral { background: var(--neutral-dim); color: var(--text-3); }

.ce-strength-wrap { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.ce-strength-bar {
  width: 60px; height: 5px;
  background: var(--bg-3); border-radius: 3px; overflow: hidden;
}
.ce-strength-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.ce-strength-fill.bull { background: var(--go); }
.ce-strength-fill.bear { background: var(--stop); }
.ce-strength-num { font-family: monospace; font-size: 12px; font-weight: 700; }

.ce-note { font-size: 10px; color: var(--text-2); font-style: italic; line-height: 1.4; margin-bottom: 4px; }
.ce-stats { font-size: 10px; color: var(--text-3); }
.ce-signals { font-size: 10px; color: var(--text-2); margin-top: 2px; line-height: 1.4; }

/* Divergence Matrix */
.ce-matrix {
  border-collapse: collapse;
  font-size: 11px;
  width: 100%;
  min-width: 500px;
}
.ce-matrix th {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 6px 8px;
  text-align: center;
  background: var(--bg-2);
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}
.ce-matrix th:first-child { text-align: left; position: sticky; left: 0; z-index: 3; }
.ce-matrix td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-family: monospace;
  white-space: nowrap;
}
.ce-matrix td:first-child {
  text-align: left;
  font-weight: 700;
  position: sticky;
  left: 0;
  background: var(--bg-1);
  z-index: 1;
}
.ce-matrix tr:hover td { background: var(--bg-2); }
.ce-matrix tr:hover td:first-child { background: var(--bg-3); }

.ce-cell-bull { color: var(--go); }
.ce-cell-bear { color: var(--stop); }
.ce-cell-none { color: var(--text-3); }

/* Quality intensity backgrounds */
.ce-q6 { background: rgba(16,185,129,0.25) !important; }
.ce-q5 { background: rgba(16,185,129,0.20) !important; }
.ce-q4 { background: rgba(16,185,129,0.15) !important; }
.ce-q3 { background: rgba(16,185,129,0.10) !important; }
.ce-q2 { background: rgba(16,185,129,0.06) !important; }
.ce-q1 { background: rgba(16,185,129,0.03) !important; }
.ce-q6.bear-bg { background: rgba(255,59,92,0.25) !important; }
.ce-q5.bear-bg { background: rgba(255,59,92,0.20) !important; }
.ce-q4.bear-bg { background: rgba(255,59,92,0.15) !important; }
.ce-q3.bear-bg { background: rgba(255,59,92,0.10) !important; }
.ce-q2.bear-bg { background: rgba(255,59,92,0.06) !important; }
.ce-q1.bear-bg { background: rgba(255,59,92,0.03) !important; }

/* Mini chart containers */
.ce-chart-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s;
}
.ce-chart-card:hover { border-color: var(--accent); }
.ce-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.ce-chart-ticker { font-weight: 700; font-size: 13px; }
.ce-chart-score { font-family: monospace; font-size: 11px; font-weight: 700; }
.ce-chart-body { height: 200px; position: relative; }

/* Timeframe selector */
.ce-tf-btns { display: flex; gap: 2px; }
.ce-tf-btn {
  font-size: 9px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent; color: var(--text-3);
  cursor: pointer;
}
.ce-tf-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

/* Detail panel */
.ce-detail {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.ce-detail-chart { height: 350px; position: relative; }
.ce-detail-info { padding: 14px 16px; }
.ce-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.ce-detail-cell {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.ce-detail-cell label { font-size: 9px; color: var(--text-3); display: block; margin-bottom: 2px; }
.ce-detail-cell .val { font-size: 13px; font-weight: 700; font-family: monospace; }

/* Health cards */
.ce-health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ce-health-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.ce-health-card .label { font-size: 10px; color: var(--text-2); margin-bottom: 2px; }
.ce-health-card .value { font-size: 14px; font-weight: 700; }
.ce-health-card.ok { border-color: rgba(0,214,143,.3); }
.ce-health-card.ok .value { color: var(--go); }
.ce-health-card.warn { border-color: rgba(255,176,32,.3); }
.ce-health-card.warn .value { color: var(--warn); }
.ce-health-card.err { border-color: rgba(255,59,92,.3); }
.ce-health-card.err .value { color: var(--stop); }

/* Mobile responsive — leaderboard cards */
@media (max-width: 768px) {
  .ce-card {
    flex-direction: column;
    gap: 8px;
  }
  .ce-card-left {
    width: 100%;
  }
  .ce-card-right {
    max-width: 100%;
    width: 100%;
    text-align: left;
  }
  .ce-ticker {
    font-size: 18px;
    display: block;
    margin-bottom: 4px;
  }
  .ce-dir-badge {
    display: inline-block;
    margin-right: 6px;
    margin-bottom: 4px;
  }
  .ce-strength-wrap {
    margin-bottom: 6px;
  }
  .ce-note {
    margin-top: 6px;
    margin-bottom: 6px;
  }
  .ce-stats {
    display: block;
    margin-bottom: 2px;
  }
  .ce-signals {
    display: block;
    word-wrap: break-word;
  }
  /* Health grid single column on mobile */
  .ce-health-grid {
    grid-template-columns: 1fr;
  }
  /* Detail grid single column on mobile */
  .ce-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Tooltip */
.ce-tooltip {
  position: fixed;
  background: var(--bg-3);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 10px;
  color: var(--text);
  z-index: 200;
  pointer-events: none;
  max-width: 220px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  line-height: 1.5;
}
