/* Global CSS & Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background: #f7f8fa;
  color: #1a1a2e;
  min-height: 100vh;
}

/* Topbar Styles */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e2e4e9;
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a2e;
}

.topbar-title span {
  color: #888;
  font-weight: 400;
}

/* Main Layout Grid */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 56px);
}

/* Sidebar Panel Styles */
.sidebar {
  background: #fff;
  border-right: 1px solid #e2e4e9;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 8px;
}

.dataset-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dataset-btn {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid #e2e4e9;
  border-radius: 6px;
  background: #fff;
  color: #1a1a2e;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, border-color 0.1s;
}

.dataset-btn:hover {
  background: #f7f8fa;
}

.dataset-btn.active {
  background: #eef2ff;
  border-color: #6366f1;
  color: #4338ca;
}

/* CSV Upload File Buttons */
.upload-label {
  display: block;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px dashed #c8cad0;
  border-radius: 6px;
  color: #888;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.1s;
}

.upload-label:hover {
  border-color: #6366f1;
  color: #6366f1;
}

#fileInput {
  display: none;
}

.csv-notice {
  font-size: 11px;
  color: #f59e0b;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 5px;
  padding: 6px 10px;
  margin-top: 6px;
  display: none;
}

.csv-notice.visible {
  display: block;
}

/* Toggle (Gini / Entropy) Controls */
.toggle-row {
  display: flex;
  border: 1px solid #e2e4e9;
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  flex: 1;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 8px;
  border: none;
  background: #fff;
  color: #888;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn.active {
  background: #eef2ff;
  color: #4338ca;
}

/* Param sliders */
.param-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.param-row:last-child {
  margin-bottom: 0;
}

.param-label {
  font-size: 13px;
  color: #444;
}

input[type=range] {
  flex: 1;
  accent-color: #6366f1;
}

.param-val {
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  color: #1a1a2e;
  min-width: 28px;
  text-align: right;
}

.build-btn {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 10px;
  width: 100%;
  border: none;
  border-radius: 7px;
  background: #6366f1;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.build-btn:hover {
  background: #4338ca;
}

.formula-box {
  background: #f7f8fa;
  border: 1px solid #e2e4e9;
  border-radius: 6px;
  padding: 10px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #444;
  line-height: 1.8;
}

.formula-box .hi {
  color: #6366f1;
  font-weight: 500;
}

/* Main Display Area and Tabs */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tabs {
  display: flex;
  border-bottom: 1px solid #e2e4e9;
  background: #fff;
  padding: 0 1.5rem;
}

.tab {
  font-size: 13px;
  font-weight: 500;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: #888;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: #1a1a2e;
}

.tab.active {
  color: #4338ca;
  border-bottom-color: #6366f1;
}

.tab-content {
  display: none;
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
}

.tab-content.active {
  display: block;
}

/* SVG tree scroll wrapper */
.tree-scroll {
  overflow: auto;
  background: #fff;
  border: 1px solid #e2e4e9;
  border-radius: 8px;
  padding: 1rem;
}

.tree-scroll svg {
  display: block;
  font-family: 'Inter', sans-serif;
}

/* Data table tab */
.data-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.data-controls label {
  font-size: 13px;
  color: #444;
}

.row-select {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid #e2e4e9;
  border-radius: 6px;
  background: #fff;
  color: #1a1a2e;
  cursor: pointer;
}

.data-table-wrap {
  overflow: auto;
  background: #fff;
  border: 1px solid #e2e4e9;
  border-radius: 8px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

th {
  background: #f7f8fa;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #888;
  border-bottom: 1px solid #e2e4e9;
  position: sticky;
  top: 0;
}

td {
  padding: 7px 12px;
  border-bottom: 1px solid #f0f0f3;
  color: #1a1a2e;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #fafafa;
}

.label-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

/* Split logs tab */
.split-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-card {
  background: #fff;
  border: 1px solid #e2e4e9;
  border-radius: 8px;
  padding: 12px 16px;
}

.log-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.log-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a2e;
}

.log-card-score {
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: #6366f1;
}

.log-card-body {
  font-size: 12px;
  color: #666;
  line-height: 1.7;
  font-family: 'JetBrains Mono', monospace;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #aaa;
  gap: 8px;
}

.empty-state p {
  font-size: 14px;
}

.accuracy-bar {
  background: #fff;
  border: 1px solid #e2e4e9;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 13px;
}

.accuracy-val {
  font-size: 20px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: #6366f1;
}

/* Calculations details Popup Modal */
#nodePopup {
  position: fixed;
  z-index: 1000;
  background: #fff;
  border: 1px solid #c8cad0;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.13);
  width: 480px;
  max-height: 520px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
}

#nodePopup.visible {
  display: flex;
}

.popup-header {
  padding: 10px 14px;
  border-bottom: 1px solid #e2e4e9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #f7f8fa;
}

.popup-title {
  font-weight: 600;
  font-size: 13px;
  color: #1a1a2e;
}

.popup-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #888;
  line-height: 1;
  padding: 0 2px;
}

.popup-close:hover {
  color: #1a1a2e;
}

.popup-meta {
  padding: 8px 14px;
  font-size: 12px;
  color: #666;
  border-bottom: 1px solid #f0f0f3;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.popup-tabs {
  display: flex;
  border-bottom: 1px solid #e2e4e9;
  flex-shrink: 0;
  background: #fff;
}

.popup-tab {
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: #888;
  transition: color 0.12s, border-color 0.12s;
}

.popup-tab:hover {
  color: #1a1a2e;
}

.popup-tab.active {
  color: #4338ca;
  border-bottom-color: #6366f1;
}

.popup-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.popup-panel.active {
  display: block;
}

.calc-block {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f3;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.9;
  color: #333;
}

.calc-block:last-child {
  border-bottom: none;
}

.calc-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 6px;
  font-family: 'Inter', sans-serif;
}

.calc-line {
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex-wrap: wrap;
}

.calc-label {
  color: #888;
  min-width: 140px;
  flex-shrink: 0;
}

.calc-val {
  color: #1a1a2e;
  font-weight: 500;
}

.calc-highlight {
  color: #6366f1;
  font-weight: 600;
}

.calc-sub {
  color: #aaa;
  font-size: 11px;
}

.calc-divider {
  border: none;
  border-top: 1px dashed #e2e4e9;
  margin: 8px 0;
}

.calc-gain-row {
  background: #eef2ff;
  border-radius: 6px;
  padding: 7px 12px;
  margin-top: 8px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calc-gain-label {
  color: #4338ca;
  font-weight: 500;
}

.calc-gain-val {
  color: #4338ca;
  font-weight: 700;
  font-size: 15px;
}

.popup-table-wrap {
  overflow-y: auto;
}

.popup-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.popup-table th {
  background: #f7f8fa;
  padding: 6px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #888;
  border-bottom: 1px solid #e2e4e9;
  position: sticky;
  top: 0;
}

.popup-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #f5f5f7;
  color: #1a1a2e;
}

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

.popup-table tr:hover td {
  background: #fafafa;
}

.popup-table .sr-col {
  color: #aaa;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.popup-table .correct {
  color: #10b981;
}

.popup-table .wrong {
  color: #ef4444;
}
