* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', sans-serif; background: #e8f0f6; color: #1a3a4a; font-size: 0.82rem; }

.app { max-width: 1600px; margin: 0 auto; padding: 0.6rem; }

/* HEADER */
.header { background: linear-gradient(135deg, #1a3a4a 0%, #2a6a8a 100%);
    color: white; border-radius: 0.8rem; padding: 0.8rem 1.2rem;
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.6rem; box-shadow: 0 4px 15px rgba(26,58,74,0.3); }
.header h1 { font-size: 1.1rem; font-weight: 700; }
.header-badges { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.badge { background: rgba(255,255,255,0.15); padding: 0.2rem 0.6rem;
    border-radius: 1rem; font-size: 0.65rem; }
.badge.green { background: rgba(42,122,74,0.4); }
.badge.orange { background: rgba(180,100,20,0.4); }

/* UPLOAD BAR */
.file-upload { background: white; border-radius: 0.8rem; padding: 0.6rem 1rem;
    display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.6rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08); flex-wrap: wrap; }
.file-upload input[type=file] { font-size: 0.72rem; max-width: 220px; }
.stats { font-size: 0.68rem; color: #4a7a9e; }

/* BUTTONS */
.btn { padding: 0.3rem 0.7rem; border: none; border-radius: 0.4rem;
    cursor: pointer; font-size: 0.7rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: 0.3rem; transition: all 0.2s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.15); }
.btn-primary { background: #1f6a86; color: white; }
.btn-danger  { background: #c0392b; color: white; }
.btn-info    { background: #2980b9; color: white; }
.btn-success { background: #27ae60; color: white; }
.btn-warning { background: #e67e22; color: white; }
.btn-secondary { background: #7f8c8d; color: white; }

/* TAGS */
.tag-success { background: #d4edda; color: #155724; padding: 0.2rem 0.5rem;
    border-radius: 0.4rem; font-size: 0.65rem; font-weight: 600; }
.tag-warning { background: #fff3cd; color: #856404; padding: 0.2rem 0.5rem;
    border-radius: 0.4rem; font-size: 0.65rem; font-weight: 600; }
.tag-danger  { background: #f8d7da; color: #721c24; padding: 0.2rem 0.5rem;
    border-radius: 0.4rem; font-size: 0.65rem; font-weight: 600; }

/* GRID */
.grid-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.6rem; }
@media(max-width:1100px) { .grid-3col { grid-template-columns: 1fr 1fr; } }
@media(max-width:700px)  { .grid-3col { grid-template-columns: 1fr; } }

/* PANELS */
.panel { background: white; border-radius: 0.8rem; padding: 0.7rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08); overflow: hidden; }
.panel-title { font-size: 0.78rem; font-weight: 700; color: #1f6a86;
    margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.4rem;
    border-bottom: 2px solid #e0ecf5; padding-bottom: 0.4rem; }
.info-badge { background: #e0ecf5; color: #1f6a86; padding: 0.1rem 0.4rem;
    border-radius: 0.4rem; font-size: 0.6rem; margin-left: auto; }

/* DATA ANALYSIS CANVAS */
.canvas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.5rem; }
.canvas-card { background: #f0f6fc; border-radius: 0.6rem; padding: 0.5rem;
    border: 1px solid #dce8f2; }
.canvas-card h4 { font-size: 0.68rem; color: #1f6a86; margin-bottom: 0.3rem;
    font-weight: 700; }
.stat-row { display: flex; justify-content: space-between; align-items: center;
    padding: 0.15rem 0; border-bottom: 1px solid #dce8f2; font-size: 0.65rem; }
.stat-row:last-child { border-bottom: none; }
.stat-val { font-weight: 700; color: #1a3a4a; }
.stat-label { color: #4a7a9e; }

/* FEATURE TABLE */
.feature-table { width: 100%; border-collapse: collapse; font-size: 0.65rem; }
.feature-table th { background: #e0ecf5; padding: 0.25rem 0.4rem;
    text-align: left; font-size: 0.63rem; position: sticky; top: 0; }
.feature-table td { padding: 0.2rem 0.4rem; border-bottom: 1px solid #eef3f8; }
.feature-table tr:hover td { background: #f5f9fc; }
.type-badge { padding: 0.1rem 0.3rem; border-radius: 0.3rem; font-size: 0.58rem; font-weight: 600; }
.type-num  { background: #d4edda; color: #155724; }
.type-cat  { background: #fff3cd; color: #856404; }
.type-bool { background: #d1ecf1; color: #0c5460; }
.type-date { background: #e2d9f3; color: #4a235a; }

/* MISSING BAR */
.missing-bar-wrap { width: 60px; height: 6px; background: #eee;
    border-radius: 3px; display: inline-block; vertical-align: middle; }
.missing-bar-fill { height: 100%; border-radius: 3px; }

/* DISTRIBUTION CHART */
.dist-chart-wrap { height: 120px; margin-top: 0.3rem; }

/* TARGET SELECTOR */
.target-selector { background: #fff8e1; border: 2px solid #f0c040;
    border-radius: 0.6rem; padding: 0.5rem; margin-bottom: 0.5rem; }
.target-selector h4 { font-size: 0.68rem; color: #856404; margin-bottom: 0.3rem; font-weight: 700; }
.target-selector select { width: 100%; padding: 0.3rem; border-radius: 0.4rem;
    border: 1px solid #f0c040; font-size: 0.7rem; background: white; }

/* COLUMN SELECTOR */
.col-select-grid { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; max-height: 120px; overflow-y: auto; }
.col-chip { padding: 0.15rem 0.4rem; border-radius: 0.4rem; font-size: 0.6rem;
    cursor: pointer; border: 1px solid #dce8f2; background: #f0f6fc;
    transition: all 0.15s; user-select: none; }
.col-chip.active   { background: #1f6a86; color: white; border-color: #1f6a86; }
.col-chip.target   { background: #e74c3c; color: white; border-color: #e74c3c; }
.col-chip.excluded { background: #eee; color: #999; text-decoration: line-through; }

/* CORRELATION */
.corr-grid { display: grid; gap: 2px; margin-top: 0.3rem; }
.corr-cell { width: 100%; aspect-ratio: 1; border-radius: 2px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.45rem; font-weight: 700; color: white; }

/* QUESTIONNAIRE */
.question-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.question-item { background: #f0f6fc; border-radius: 0.5rem; padding: 0.4rem; }
.question-item label { font-size: 0.62rem; color: #4a7a9e; display: block; margin-bottom: 0.2rem; font-weight: 600; }
.question-item select { width: 100%; padding: 0.2rem; border-radius: 0.3rem;
    border: 1px solid #dce8f2; font-size: 0.65rem; background: white; }

/* RECOMMENDATION */
.recommendation-box { background: linear-gradient(135deg,#e8f5e9,#f0f6fc);
    border: 1px solid #a5d6a7; border-radius: 0.6rem; padding: 0.5rem;
    margin-top: 0.4rem; font-size: 0.68rem; }
.hidden { display: none !important; }

/* STAGES */
.stage-list { display: flex; flex-direction: column; gap: 0.3rem; }
.stage-item { background: #f0f6fc; border-radius: 0.5rem; padding: 0.4rem 0.6rem;
    border: 1px solid #dce8f2; display: flex; flex-direction: column; gap: 0.3rem; }
.stage-item.active-stage { border-color: #1f6a86; background: #e0ecf5; }
.stage-header { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.stage-toggle { width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid #1f6a86; background: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stage-toggle.on { background: #1f6a86; }
.stage-toggle.on::after { content: '✓'; color: white; font-size: 0.5rem; font-weight: 900; }
.stage-params { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.2rem; }
.param-group { display: flex; flex-direction: column; gap: 0.1rem; }
.param-group label { font-size: 0.58rem; color: #4a7a9e; }
.param-group input, .param-group select { padding: 0.15rem 0.3rem;
    border-radius: 0.3rem; border: 1px solid #dce8f2; font-size: 0.65rem; width: 100px; }

/* CODE */
.code-wrap { background: #0b202b; border-radius: 0.8rem; padding: 0.7rem;
    font-family: monospace; font-size: 0.62rem; line-height: 1.8;
    color: #7ecfee; overflow-x: auto; white-space: pre; max-height: 500px;
    overflow-y: auto; }

/* TABS */
.explanation-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.tab-btn { padding: 0.25rem 0.6rem; border: 1px solid #dce8f2; border-radius: 0.4rem;
    background: #f0f6fc; cursor: pointer; font-size: 0.65rem; transition: all 0.2s; }
.tab-btn.active { background: #1f6a86; color: white; border-color: #1f6a86; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* SCORING TABLE */
.scoring-table { width: 100%; border-collapse: collapse; font-size: 0.68rem; }
.scoring-table th { background: #e0ecf5; padding: 0.3rem 0.5rem; text-align: left; }
.scoring-table td { padding: 0.25rem 0.5rem; border-bottom: 1px solid #dce8f2; }

/* CV DIAGRAM */
.cv-visualizer { margin-top: 0.4rem; }
.cv-fold-row { display: flex; gap: 2px; margin-bottom: 2px; align-items: center; }
.cv-fold-label { font-size: 0.55rem; width: 35px; color: #4a7a9e; flex-shrink: 0; }
.cv-fold-block { height: 12px; border-radius: 2px; flex: 1; }
.cv-fold-block.train { background: #1f6a86; }
.cv-fold-block.test  { background: #e74c3c; }
.cv-fold-block.val   { background: #f39c12; }

/* NESTED CV */
.nested-cv-diagram { background: #f0f6fc; border-radius: 0.8rem; padding: 0.6rem;
    margin: 0.4rem 0; border: 1px solid #dce8f2; }
.nested-cv-outer { border: 2px dashed #2a7a9e; border-radius: 0.6rem;
    padding: 0.4rem; margin-bottom: 0.4rem; }
.nested-cv-inner { border: 2px dashed #2a7a4a; border-radius: 0.4rem;
    padding: 0.3rem; margin-top: 0.3rem; }
.nested-label { font-size: 0.6rem; font-weight: 700; margin-bottom: 0.2rem; }
.nested-label.outer { color: #2a7a9e; }
.nested-label.inner { color: #2a7a4a; }

/* PROGRESS */
.progress-bar-wrap { background: #eee; border-radius: 4px; height: 6px; margin-top: 0.2rem; }
.progress-bar-fill { height: 100%; border-radius: 4px; background: #1f6a86; transition: width 0.3s; }

/* ALERT */
.alert { padding: 0.4rem 0.6rem; border-radius: 0.5rem; font-size: 0.68rem; margin: 0.3rem 0; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-danger  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

/* GLOSSARY */
.glossary-panel { background: white; border-radius: 0.8rem; padding: 0.7rem;
    margin-bottom: 0.6rem; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.glossary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
@media (max-width: 1100px) { .glossary-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .glossary-grid { grid-template-columns: 1fr; } }
.glossary-item { background: #f0f6fc; border-radius: 0.5rem; padding: 0.4rem; border-left: 3px solid #1f6a86; transition: all 0.2s; }
.glossary-item:hover { background: #e0ecf5; transform: translateX(2px); }
.glossary-item h4 { font-size: 0.65rem; color: #1f6a86; font-weight: 700; border-bottom: 1px solid #dce8f2; padding-bottom: 0.1rem; margin-bottom: 0.15rem; }
.glossary-item p  { font-size: 0.6rem; color: #4a7a9e; margin-top: 0.15rem; line-height: 1.6; }
.glossary-item code { background: #0b202b; color: #7ecfee; padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.58rem; font-family: monospace; }

/* SECTION DIVIDER */
.section-divider { height: 2px; background: linear-gradient(90deg,#e0ecf5,transparent);
    margin: 0.8rem 0; border-radius: 2px; }

/* 3D VISUALIZATION PANEL */
#viz-3d-panel { min-height: 480px; }

/* DATA PREVIEW TABLE */
.data-preview-wrap { overflow-x: auto; max-height: 180px; overflow-y: auto; }
.data-preview { border-collapse: collapse; font-size: 0.6rem; white-space: nowrap; }
.data-preview th { background: #1f6a86; color: white; padding: 0.2rem 0.4rem;
    position: sticky; top: 0; }
.data-preview td { padding: 0.15rem 0.4rem; border-bottom: 1px solid #eef3f8; }
.data-preview tr:hover td { background: #f5f9fc; }
.data-preview td.target-col { background: #fff3cd; font-weight: 700; }
.data-preview th.target-col { background: #e67e22; }

/* QUALITY INDICATORS */
.quality-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.3rem; margin-bottom: 0.4rem; }
.quality-card { background: #f0f6fc; border-radius: 0.5rem; padding: 0.4rem;
    text-align: center; border: 1px solid #dce8f2; }
.quality-card .q-val { font-size: 1rem; font-weight: 700; color: #1f6a86; }
.quality-card .q-label { font-size: 0.55rem; color: #4a7a9e; }
.quality-card.warn .q-val { color: #e67e22; }
.quality-card.danger .q-val { color: #e74c3c; }

/* SCROLLABLE */
.scrollable { overflow-y: auto; max-height: 300px; }

/* METRIC FORMULA */
.metric-formula { font-family: monospace; font-size: 0.62rem;
    background: #f0f6fc; padding: 0.1rem 0.3rem; border-radius: 3px; }
.metric-when { font-size: 0.62rem; color: #4a7a9e; font-style: italic; }

/* ===== Code-Tab Schritt-Erklärung (codeStepsExplain) ===== */
#codeStepsExplain {
  background: #0d1117;
  border: 1px solid #30363d;
  border-left: 3px solid #ffd54f;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  font-size: 0.72rem;
}
#codeStepsExplain .step-header {
  font-weight: 700;
  color: #ffd54f;
  margin-bottom: 3px;
}
#codeStepsExplain .step-explain {
  color: #8b949e;
  font-size: 0.68rem;
}

/* ===== Plot-Reihenfolge (Drag & Drop) ===== */
.plot-order-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 1.5rem;
}
.plot-order-empty {
  font-size: 0.6rem;
  color: #9bb3c2;
  font-style: italic;
  padding: 0.2rem 0;
}
.plot-order-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #f0f6fc;
  border: 1px solid #dce8f2;
  border-radius: 0.4rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.65rem;
  cursor: grab;
  user-select: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.plot-order-item:active { cursor: grabbing; }
.plot-order-item .order-handle {
  color: #9bb3c2;
  font-size: 0.6rem;
  flex-shrink: 0;
}
.plot-order-item .order-index {
  background: #1f6a86;
  color: white;
  font-weight: 700;
  font-size: 0.55rem;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.plot-order-item .order-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plot-order-item .order-remove {
  color: #c0392b;
  cursor: pointer;
  font-size: 0.6rem;
  flex-shrink: 0;
  padding: 0 0.15rem;
}
.plot-order-item.dragging {
  opacity: 0.4;
}
.plot-order-item.drag-over {
  box-shadow: 0 0 0 2px #1f6a86 inset;
  transform: translateY(1px);
}
