/* Дерево */
.node circle {
  stroke-width: 2;
  cursor: pointer;
}
.node text {
  font-size: 11px;
  fill: #e5e7eb;
}
.node .label-id {
  font-weight: bold;
  font-size: 12px;
}
.node .label-rank {
  font-size: 9px;
  fill: #9ca3af;
}
.node .label-pv {
  font-size: 9px;
  fill: #6ee7b7;
}
.link {
  fill: none;
  stroke: #4b5563;
  stroke-width: 1.5;
}

/* Таблица бонусов */
.bonus-table {
  font-size: 12px;
  border-collapse: collapse;
  width: 100%;
  min-width: 600px;
}
.bonus-table th {
  background: #1f2937;
  color: #9ca3af;
  padding: 6px 8px;
  text-align: right;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 600;
}
.bonus-table th:first-child {
  text-align: left;
}
.bonus-table td {
  padding: 5px 8px;
  text-align: right;
  border-bottom: 1px solid #374151;
  white-space: nowrap;
}
.bonus-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: #d1d5db;
  position: sticky;
  left: 0;
  background: #111827;
  z-index: 1;
}
.bonus-table tr:hover td {
  background: #1f2937;
}
.bonus-table tr:hover td:first-child {
  background: #1f2937;
}
.bonus-table .zero {
  color: #6b7280;
}
.bonus-table .positive {
  color: #6ee7b7;
}
.bonus-table .burned {
  color: #f87171;
}
.bonus-table .total-row {
  font-weight: bold;
  color: #fbbf24;
}

/* Формы конструктора */
.custom-input {
  background: #374151;
  border: 1px solid #4b5563;
  color: #e5e7eb;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
  width: 100%;
  box-sizing: border-box;
}
.custom-input:focus {
  outline: none;
  border-color: #10b981;
}
.member-card, .order-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 8px;
}

/* Убираем стрелки в number-input для Chrome/Safari */
.custom-input[type="number"]::-webkit-inner-spin-button,
.custom-input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.custom-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Tooltip на заголовках бонусов */
.bonus-table th.has-tip {
  cursor: help;
  position: relative;
}
.bonus-table th.has-tip .tip-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  line-height: 14px;
  font-size: 9px;
  text-align: center;
  border-radius: 50%;
  background: #374151;
  color: #9ca3af;
  margin-left: 3px;
  vertical-align: middle;
}
.bonus-table th.has-tip .tip-text {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: 260px;
  padding: 8px 10px;
  background: #1f2937;
  border: 1px solid #4b5563;
  border-radius: 6px;
  color: #d1d5db;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  pointer-events: none;
}
.bonus-table th.has-tip:hover .tip-text {
  display: block;
}

/* Вкладки */
.tab-btn {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 4px;
  background: #374151;
  color: #9ca3af;
  border: 1px solid #4b5563;
  cursor: pointer;
}
.tab-btn:hover {
  background: #4b5563;
  color: #e5e7eb;
}
.tab-btn.active {
  background: #065f46;
  color: #6ee7b7;
  border-color: #10b981;
}

/* Информационная панель */
.info-panel {
  font-size: 12px;
  line-height: 1.5;
  color: #d1d5db;
}
.info-panel summary {
  cursor: pointer;
  color: #9ca3af;
  font-size: 12px;
  user-select: none;
}
.info-panel summary:hover {
  color: #e5e7eb;
}
.info-panel dt {
  color: #6ee7b7;
  font-weight: 600;
  margin-top: 6px;
}
.info-panel dd {
  margin: 0 0 2px 0;
  color: #d1d5db;
}

/* Proof-row: раскрываемые формулы */
.proof-toggle {
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  color: #6b7280;
  margin-right: 6px;
}
.proof-toggle:hover {
  color: #d1d5db;
}
.proof-row td {
  background: #0f1623 !important;
  padding: 0 !important;
  border-bottom: 1px solid #1f2937;
}
.proof-row.hidden {
  display: none;
}
.proof-content {
  padding: 12px 16px;
  font-size: 14px;
}
.proof-input {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 16px;
  margin-bottom: 10px;
}
.proof-input .kv {
  color: #9ca3af;
  font-size: 13px;
}
.proof-input .kv span {
  color: #d1d5db;
  font-weight: 600;
}
.proof-bonus {
  margin-top: 10px;
  border-top: 1px solid #1f2937;
  padding-top: 8px;
}
.proof-bonus-title {
  color: #6ee7b7;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.proof-formula {
  color: #d1d5db;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  white-space: pre-wrap;
  line-height: 1.6;
}
.proof-zero {
  color: #4b5563;
  font-style: italic;
  font-size: 13px;
}

/* Expand/Collapse All кнопка */
.proof-expand-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  background: #1f2937;
  color: #9ca3af;
  border: 1px solid #374151;
  cursor: pointer;
  margin-left: 8px;
}
.proof-expand-btn:hover {
  background: #374151;
  color: #e5e7eb;
}

/* Bidirectional highlight */
.bonus-table tr.highlight td {
  background: #1e3a5f !important;
}
.bonus-table tr.highlight td:first-child {
  background: #1e3a5f !important;
}
.node.highlight circle {
  stroke: #fbbf24 !important;
  stroke-width: 3 !important;
}
.node.highlight .label-id {
  fill: #fbbf24 !important;
}

/* Панель инвариантов */
#invariants-panel {
  margin: 8px 0;
  padding: 10px 14px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  font-size: 12px;
}
#invariants-panel summary {
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
}
#invariants-panel summary:hover {
  color: #e5e7eb;
}
.invariant-pass { color: #6ee7b7; }
.invariant-fail { color: #f87171; font-weight: bold; }
.invariant-list {
  margin-top: 6px;
  padding-left: 8px;
  line-height: 1.7;
}

/* Водопад доходов */
#revenue-waterfall {
  margin: 8px 0;
  padding: 10px 14px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  font-size: 12px;
}
.waterfall-title {
  font-size: 13px;
  font-weight: 600;
  color: #9ca3af;
  margin-bottom: 8px;
}
.waterfall-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.waterfall-label {
  width: 140px;
  text-align: right;
  color: #9ca3af;
  flex-shrink: 0;
  white-space: nowrap;
}
.waterfall-bar-wrap {
  flex: 1;
  background: #1f2937;
  border-radius: 2px;
  height: 16px;
  overflow: hidden;
}
.waterfall-bar {
  height: 100%;
  border-radius: 2px;
  min-width: 2px;
}
.waterfall-amount {
  width: 110px;
  text-align: right;
  color: #d1d5db;
  flex-shrink: 0;
}
.waterfall-pct {
  width: 50px;
  text-align: right;
  color: #6b7280;
  flex-shrink: 0;
}
.waterfall-separator {
  border-top: 1px dashed #374151;
  margin: 6px 0;
}
.waterfall-burned .waterfall-label { color: #f87171; }
.waterfall-burned .waterfall-bar { background: #991b1b; }
.waterfall-company .waterfall-label { color: #6ee7b7; }
.waterfall-company .waterfall-bar { background: #065f46; }

/* Универсальный тултип по data-tip */
[data-tip] {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted #4b5563;
}
[data-tip]::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: 280px;
  padding: 8px 10px;
  background: #1f2937;
  border: 1px solid #4b5563;
  border-radius: 6px;
  color: #d1d5db;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
  pointer-events: none;
}
[data-tip]:hover::after {
  display: block;
}
/* Для элементов в левой части — тултип вправо */
.waterfall-label[data-tip]::after {
  left: 0;
  bottom: auto;
  top: 100%;
  transform: none;
  margin-top: 4px;
}
/* Для инвариантов — тултип вправо от текста, не за экран */
.invariant-list [data-tip]::after {
  left: 0;
  bottom: auto;
  top: 100%;
  transform: none;
  margin-top: 4px;
}
#invariants-panel summary[data-tip]::after {
  left: 0;
  bottom: auto;
  top: 100%;
  transform: none;
  margin-top: 4px;
}
/* Сводная статистика — тултип вниз */
#summary-stats [data-tip] {
  border-bottom-style: dotted;
}
#summary-stats [data-tip]::after {
  left: 0;
  bottom: auto;
  top: 100%;
  transform: none;
  margin-top: 4px;
}

/* Гистограмма распределения доходов */
#income-histogram {
  margin: 8px 0;
  padding: 10px 14px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  font-size: 12px;
}

/* Сравнение сценариев */
#compare-panel {
  margin: 0;
  padding: 24px 24px 20px;
  background: #0f172a;
  border-bottom: 2px solid #6d28d9;
  max-height: 80vh;
  overflow-y: auto;
}
.compare-header {
  margin-bottom: 20px;
}
.compare-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.compare-title {
  font-size: 20px;
  font-weight: 700;
  color: #c4b5fd;
  margin: 0;
}
.compare-description {
  font-size: 15px;
  color: #9ca3af;
  line-height: 1.5;
  margin: 0 0 12px;
  max-width: 800px;
}
.compare-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #1e1b4b;
  border: 1px solid #4c1d95;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 4px;
  max-width: 700px;
}
.compare-hint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: #6d28d9;
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.compare-hint span {
  font-size: 14px;
  color: #c4b5fd;
  line-height: 1.4;
}
.compare-selectors {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.compare-selector-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.compare-label {
  font-size: 14px;
  font-weight: 600;
  color: #e5e7eb;
}
.compare-label-hint {
  font-size: 12px;
  color: #6b7280;
  margin: 0 0 4px;
}
.compare-select {
  min-width: 260px;
  max-width: 380px;
  background: #1f2937;
  color: #f3f4f6;
  font-size: 14px;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 8px 10px;
}
.compare-select:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124,58,237,0.3);
}
.compare-vs {
  font-size: 18px;
  font-weight: 800;
  color: #6d28d9;
  padding-bottom: 8px;
  user-select: none;
}
.compare-run-btn {
  background: #7c3aed;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 24px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.compare-run-btn:hover {
  background: #6d28d9;
}
.compare-status-text {
  display: block;
  font-size: 14px;
  color: #9ca3af;
  margin-bottom: 8px;
  min-height: 20px;
}
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.compare-side {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
}
.compare-side h4 {
  font-size: 16px;
  font-weight: 700;
  color: #c4b5fd;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #374151;
}
.compare-side-desc {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 10px;
  font-style: italic;
}
.compare-stat {
  font-size: 14px;
  color: #d1d5db;
  margin-bottom: 6px;
  line-height: 1.5;
}
.compare-delta-positive { color: #6ee7b7; font-weight: 600; }
.compare-delta-negative { color: #f87171; font-weight: 600; }
.compare-delta-zero { color: #6b7280; }
.compare-diff-section {
  margin-top: 20px;
  padding: 20px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
}
.compare-diff-title {
  font-size: 16px;
  font-weight: 700;
  color: #e5e7eb;
  margin-bottom: 4px;
}
.compare-diff-explain {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 14px;
  line-height: 1.4;
}
.compare-diff-section table {
  width: 100%;
  border-collapse: collapse;
}
.compare-diff-section th {
  font-size: 13px;
  font-weight: 600;
  color: #9ca3af;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid #374151;
}
.compare-diff-section td {
  font-size: 14px;
  color: #d1d5db;
  padding: 6px 12px;
  border-bottom: 1px solid #1f2937;
}
.compare-diff-section tr:hover td {
  background: #111827;
}
.compare-verdict {
  margin: 16px 0;
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid #374151;
}
.compare-verdict-tie {
  background: #1f2937;
  color: #9ca3af;
  font-size: 15px;
  text-align: center;
}
.compare-verdict-a {
  background: #0c2d48;
  border-color: #1d4ed8;
}
.compare-verdict-b {
  background: #2e1065;
  border-color: #6d28d9;
}
.compare-verdict-winner {
  font-size: 17px;
  font-weight: 700;
  color: #f3f4f6;
  margin-bottom: 4px;
}
.compare-verdict-pct {
  display: inline-block;
  background: #059669;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  vertical-align: middle;
}
.compare-verdict-explain {
  font-size: 14px;
  color: #9ca3af;
}

/* Маркер слабой ноги */
.weak-leg-text {
  font-size: 8px;
  fill: #f59e0b;
}
.strong-leg-text {
  font-size: 8px;
  fill: #6ee7b7;
}
