#cde-toggle-btn,
#cde-forecast-trigger-btn,
#cde-mf-trigger-btn,
#cde-test-toggle-btn {
  position: fixed;
  z-index: 9991;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 9, 20, 0.92);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  user-select: none;
}

#cde-toggle-btn {
  right: 18px;
  bottom: 104px;
  border: 1px solid rgba(0, 225, 214, 0.3);
  color: #00e1d6;
}

#cde-forecast-trigger-btn {
  right: 18px;
  bottom: 150px;
  border: 1px solid rgba(176, 92, 255, 0.3);
  color: #b05cff;
}

#cde-mf-trigger-btn {
  right: 18px;
  bottom: 196px;
  border: 1px solid rgba(0, 255, 200, 0.28);
  color: #00ffe0;
}

#cde-test-toggle-btn {
  left: 18px;
  bottom: 18px;
  border: 1px solid rgba(122, 92, 255, 0.28);
  color: #9b7aff;
}

#cde-panel,
#cde-fc-vis-panel,
#cde-mf-panel,
#cde-test-panel {
  position: fixed;
  z-index: 9988;
  background: rgba(3, 7, 16, 0.98);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  color: rgba(191, 207, 220, 0.88);
}

#cde-panel.cde-visible,
#cde-fc-vis-panel.vis-visible,
#cde-mf-panel.mf-visible,
#cde-test-panel.test-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#cde-panel {
  right: 18px;
  bottom: 148px;
  width: min(420px, calc(100vw - 36px));
  border: 1px solid rgba(0, 225, 214, 0.22);
  border-radius: 14px;
  overflow: hidden;
}

#cde-fc-vis-panel {
  left: 64px;
  bottom: 18px;
  width: min(520px, calc(100vw - 92px));
  border: 1px solid rgba(176, 92, 255, 0.24);
  border-radius: 14px;
  overflow: hidden;
}

#cde-mf-panel {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: min(640px, calc(100vw - 32px));
  border: 1px solid rgba(0, 255, 200, 0.2);
  border-radius: 16px;
  overflow: hidden;
}

#cde-mf-panel.mf-visible {
  transform: translate(-50%, -50%) scale(1);
}

#cde-test-panel {
  left: 18px;
  bottom: 64px;
  width: min(430px, calc(100vw - 32px));
  border: 1px solid rgba(122, 92, 255, 0.28);
  border-radius: 14px;
  overflow: hidden;
}

.cde-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: "Orbitron", sans-serif;
  font-size: 8.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#cde-header {
  background: rgba(0, 225, 214, 0.04);
}

#cde-fc-head {
  background: rgba(176, 92, 255, 0.05);
}

#cde-mf-head {
  background: rgba(0, 255, 200, 0.04);
}

#cde-test-head {
  background: rgba(122, 92, 255, 0.05);
}

#cde-title {
  color: #00e1d6;
}

#cde-fc-title {
  color: #b05cff;
}

#cde-mf-title {
  color: #00ffe0;
}

#cde-test-title {
  color: #9b7aff;
}

#cde-body {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cde-metric {
  padding: 10px 8px;
  text-align: center;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cde-metric:last-child {
  border-right: none;
}

.cde-metric-label {
  font-size: 7px;
  letter-spacing: 1.4px;
  color: rgba(191, 199, 213, 0.34);
  text-transform: uppercase;
}

.cde-metric-value {
  font-family: "Orbitron", sans-serif;
  font-size: 17px;
  line-height: 1;
}

.cde-metric-sub {
  font-size: 6.3px;
  color: rgba(191, 199, 213, 0.28);
  letter-spacing: 0.8px;
}

#cde-resonance-badge {
  font-family: "Share Tech Mono", monospace;
  font-size: 7.5px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 225, 214, 0.18);
  color: rgba(191, 199, 213, 0.5);
}

#cde-resonance-badge.active {
  color: #00ffe0;
  border-color: rgba(0, 255, 200, 0.32);
  box-shadow: 0 0 12px rgba(0, 255, 200, 0.18);
}

#cde-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(191, 199, 213, 0.22);
}

#cde-status-dot.live {
  background: #19d38a;
  box-shadow: 0 0 10px rgba(25, 211, 138, 0.55);
}

#cde-status-dot.mock {
  background: #ffd24a;
  box-shadow: 0 0 10px rgba(255, 210, 74, 0.35);
}

#cde-norm-row {
  display: flex;
  padding: 5px 12px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cde-norm-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.cde-norm-bar-bg {
  width: 80%;
  height: 2px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 1px;
  overflow: hidden;
}

.cde-norm-bar-fill {
  height: 100%;
  background: #00e1d6;
  border-radius: 1px;
  transition: width 0.5s;
}

.cde-norm-val {
  font-size: 6.4px;
  color: rgba(191, 199, 213, 0.33);
  letter-spacing: 0.8px;
}

#cde-risk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#cde-risk-label {
  font-size: 7.5px;
  letter-spacing: 1.6px;
  color: rgba(191, 199, 213, 0.35);
  text-transform: uppercase;
}

#cde-risk-bar-bg {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

#cde-risk-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #19d38a, #ffd24a, #ff5a5a);
  transition: width 0.5s;
}

#cde-risk-val {
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  width: 36px;
  text-align: right;
}

#cde-risk-level {
  font-size: 7px;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid currentColor;
  text-transform: uppercase;
}

#cde-drift-badge {
  font-size: 7.5px;
  color: rgba(191, 199, 213, 0.35);
}

#cde-sparkline {
  width: calc(100% - 24px);
  height: 32px;
  margin: 4px 12px 2px;
}

#cde-footer,
#cde-fc-footer,
#cde-test-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 13px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#cde-source-label,
#cde-ts-label,
#cde-fc-ts,
#cde-test-elapsed {
  font-family: "Share Tech Mono", monospace;
  font-size: 7.5px;
  color: rgba(191, 199, 213, 0.32);
  letter-spacing: 0.8px;
}

.cde-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  padding: 3px 10px;
  font-family: "Share Tech Mono", monospace;
  font-size: 7.5px;
  letter-spacing: 1.2px;
  cursor: pointer;
}

#cde-refresh-btn {
  color: #00e1d6;
  border-color: rgba(0, 225, 214, 0.2);
}

#cde-monitor-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-top: 1px solid rgba(0, 225, 214, 0.07);
  font-family: "Share Tech Mono", monospace;
  font-size: 7.5px;
  color: rgba(191, 199, 213, 0.38);
  background: rgba(0, 225, 214, 0.02);
}

#cde-monitor-bar.active {
  display: flex;
}

#cde-mon-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(191, 199, 213, 0.2);
}

#cde-mon-dot.recording {
  background: #19d38a;
  box-shadow: 0 0 8px rgba(25, 211, 138, 0.7);
}

#cde-mon-stats {
  flex: 1;
}

#cde-mon-export-btn {
  background: none;
  border: none;
  color: rgba(0, 225, 214, 0.45);
  cursor: pointer;
  font-family: "Share Tech Mono", monospace;
  font-size: 7.5px;
}

#cde-fc-canvas {
  display: block;
  width: 100%;
  height: 160px;
}

#cde-fc-windows {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid rgba(176, 92, 255, 0.1);
}

.fc-win-cell {
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-right: 1px solid rgba(176, 92, 255, 0.07);
}

.fc-win-cell:last-child {
  border-right: none;
}

.fc-win-label {
  font-size: 7px;
  letter-spacing: 1.3px;
  color: rgba(191, 199, 213, 0.34);
  text-transform: uppercase;
}

.fc-win-pct {
  font-family: "Orbitron", sans-serif;
  font-size: 18px;
  line-height: 1;
}

.fc-win-conf {
  font-size: 6.5px;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid currentColor;
  text-transform: uppercase;
}

.alta {
  color: #ff5a5a;
}

.media {
  color: #ffd24a;
}

.baixa {
  color: rgba(191, 199, 213, 0.45);
}

#cde-fc-ai-row {
  padding: 6px 13px;
  border-top: 1px solid rgba(0, 225, 214, 0.07);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Share Tech Mono", monospace;
  font-size: 8px;
}

#cde-fc-ai-label {
  color: rgba(0, 225, 214, 0.5);
  letter-spacing: 1.2px;
  white-space: nowrap;
}

#cde-fc-ai-conf-bar {
  flex: 1;
  height: 3px;
  background: rgba(0, 225, 214, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

#cde-fc-ai-conf-fill {
  height: 100%;
  width: 0%;
  background: #00e1d6;
  transition: width 0.5s;
}

#cde-fc-ai-stats {
  font-size: 7.5px;
  color: rgba(191, 199, 213, 0.35);
  letter-spacing: 0.8px;
  white-space: nowrap;
}

#cde-mf-fields {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid rgba(0, 255, 200, 0.08);
}

.mf-field-card {
  padding: 8px 6px;
  border-right: 1px solid rgba(0, 255, 200, 0.07);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.mf-field-card:last-child {
  border-right: none;
}

.mf-field-label {
  font-size: 6.3px;
  letter-spacing: 1.2px;
  color: rgba(191, 199, 213, 0.38);
  text-transform: uppercase;
}

.mf-field-risk {
  font-family: "Orbitron", sans-serif;
  font-size: 14px;
  line-height: 1;
}

.mf-field-bar-bg {
  width: 80%;
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 2px;
  overflow: hidden;
}

.mf-field-bar-fill {
  height: 100%;
  transition: width 0.4s;
}

.mf-field-level {
  font-size: 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.55;
}

#cde-mf-matrix {
  padding: 10px 14px 6px;
  border-bottom: 1px solid rgba(0, 255, 200, 0.07);
}

#cde-mf-heatmap {
  display: block;
  width: 100%;
  height: 130px;
}

#cde-mf-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

#cde-mf-pairs,
#cde-mf-global {
  padding: 8px 14px;
}

#cde-mf-pairs {
  border-right: 1px solid rgba(0, 255, 200, 0.07);
  max-height: 118px;
  overflow-y: auto;
}

.mf-pair-row {
  display: flex;
  gap: 6px;
  padding: 2px 0;
  font-size: 8px;
}

.mf-pair-fields {
  flex: 1;
  color: rgba(191, 199, 213, 0.55);
}

.mf-pair-corr {
  width: 44px;
  text-align: right;
  font-family: "Orbitron", sans-serif;
}

.mf-pair-leader {
  font-size: 6px;
  color: rgba(0, 255, 200, 0.45);
  letter-spacing: 0.8px;
}

.mf-global-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.mf-global-label {
  font-size: 7px;
  letter-spacing: 1.2px;
  color: rgba(191, 199, 213, 0.32);
  text-transform: uppercase;
}

.mf-global-val {
  font-family: "Orbitron", sans-serif;
  font-size: 16px;
}

#cde-mf-cluster-banner {
  display: none;
  padding: 6px 14px;
  background: rgba(255, 60, 60, 0.1);
  border-top: 1px solid rgba(255, 60, 60, 0.25);
  font-size: 8px;
  color: #ff5a5a;
  letter-spacing: 1px;
  text-align: center;
}

#cde-test-grade {
  font-family: "Orbitron", sans-serif;
  font-size: 20px;
  line-height: 1;
}

.grade-A {
  color: #19d38a;
}

.grade-B {
  color: #00e1d6;
}

.grade-C {
  color: #ff8c3a;
}

.grade-F {
  color: #ff5a5a;
}

#cde-test-progress-bar {
  height: 3px;
  background: rgba(122, 92, 255, 0.12);
}

#cde-test-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7a5cff, #00e1d6);
  transition: width 0.3s;
}

#cde-test-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid rgba(122, 92, 255, 0.1);
}

.test-summary-cell {
  padding: 7px 6px;
  text-align: center;
  border-right: 1px solid rgba(122, 92, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.test-summary-cell:last-child {
  border-right: none;
}

.test-summary-label {
  font-size: 7px;
  letter-spacing: 1.4px;
  color: rgba(191, 199, 213, 0.32);
  text-transform: uppercase;
}

.test-summary-val {
  font-family: "Orbitron", sans-serif;
  font-size: 15px;
  color: #9b7aff;
}

#cde-test-log {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0 2px;
}

.test-log-row {
  display: flex;
  gap: 7px;
  padding: 2px 12px;
  font-size: 9px;
  line-height: 1.5;
  border-left: 2px solid transparent;
}

.test-log-row.pass {
  border-left-color: rgba(25, 211, 138, 0.5);
}

.test-log-row.fail {
  border-left-color: rgba(255, 85, 85, 0.5);
}

.test-log-row.warn {
  border-left-color: rgba(255, 140, 58, 0.5);
}

.test-log-icon {
  width: 12px;
}

.test-log-msg {
  flex: 1;
}

#cde-test-scenarios {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid rgba(122, 92, 255, 0.12);
}

.test-scenario {
  padding: 8px 9px;
  border-right: 1px solid rgba(122, 92, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.test-scenario:last-child {
  border-right: none;
}

.test-scenario-label {
  font-size: 7px;
  letter-spacing: 1.2px;
  color: rgba(191, 199, 213, 0.4);
  text-transform: uppercase;
}

.test-scenario-score {
  font-family: "Orbitron", sans-serif;
  font-size: 16px;
  line-height: 1;
}

.test-scenario-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 2px;
  overflow: hidden;
}

.test-scenario-fill {
  height: 100%;
}

.test-scenario-meta {
  font-size: 6.4px;
  color: rgba(191, 199, 213, 0.35);
}

.fc-card-cde {
  position: relative;
  padding: 10px 14px 12px;
  border-radius: 6px;
  background: rgba(8, 10, 28, 0.9);
  border: 1px solid rgba(176, 92, 255, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.fc-card-cde::before {
  content: "CDE·FORECAST";
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 6px;
  letter-spacing: 1.4px;
  color: rgba(176, 92, 255, 0.4);
  font-family: "Share Tech Mono", monospace;
}

.fc-cde-window {
  font-size: 9px;
  letter-spacing: 2px;
  color: rgba(176, 92, 255, 0.55);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.fc-cde-pct {
  font-family: "Orbitron", sans-serif;
  font-size: 28px;
  line-height: 1;
  margin-bottom: 6px;
}

.fc-cde-bar-bg {
  height: 4px;
  background: rgba(176, 92, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 5px;
}

.fc-cde-bar-fill {
  height: 100%;
  transition: width 0.5s;
}

.fc-cde-meta {
  display: flex;
  justify-content: space-between;
  font-size: 7.5px;
  color: rgba(191, 199, 213, 0.35);
  letter-spacing: 0.7px;
}

@media (max-width: 720px) {
  #cde-panel,
  #cde-fc-vis-panel,
  #cde-test-panel {
    width: calc(100vw - 24px);
    right: 12px;
    left: 12px;
  }

  #cde-fc-vis-panel {
    bottom: 72px;
  }

  #cde-toggle-btn,
  #cde-forecast-trigger-btn,
  #cde-mf-trigger-btn {
    right: 12px;
  }

  #cde-mf-panel {
    width: calc(100vw - 18px);
  }
}
