* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0a0e1a;
  color: #e6edf3;
  line-height: 1.5;
  min-height: 100vh;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: #0f1522;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.title h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
}

.subtitle {
  font-size: 0.85rem;
  color: #8b949e;
}

.date-display {
  font-size: 0.8rem;
  color: #58a6ff;
  margin-top: 0.25rem;
  font-weight: 500;
}

.last-signal {
  margin: 0.75rem 0;
}

.last-signal-box {
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.2);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
}

.last-signal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.last-signal-status {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.last-signal-status.pos {
  background: rgba(38, 166, 154, 0.2);
  color: #26a69a;
}

.last-signal-status.neg {
  background: rgba(239, 83, 80, 0.2);
  color: #ef5350;
}

.last-signal-status.pending {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
}

.last-signal-alloc {
  margin-top: 0.5rem;
  color: #8b949e;
  font-size: 0.8rem;
}

.last-signal-preview,
.pending-signal-text {
  margin-top: 0.5rem;
  color: #e6edf3;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.signal-warning {
  margin-top: 0.5rem;
  color: #ffd166;
  font-size: 0.78rem;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.controls label {
  font-size: 0.85rem;
  color: #8b949e;
}

.controls select, .controls input[type="number"] {
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e6edf3;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

button {
  background: #21262d;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e6edf3;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

button:hover {
  background: #30363d;
}

button.primary {
  background: #238636;
  border-color: #238636;
}

button.primary:hover {
  background: #2ea043;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mode-paper {
  background: #1f6feb;
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.mode-live {
  background: #da3633;
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.main {
  padding: 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.card {
  background: #0f1522;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.hint {
  font-size: 0.8rem;
  color: #8b949e;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 1.5rem;
}

@media (max-width: 600px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 800px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat {
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 1rem;
}

.stat-label {
  font-size: 0.75rem;
  color: #8b949e;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 600;
  color: #fff;
}

.stat-value.compact {
  font-size: 1rem;
}

.stat-value.pos { color: #3fb950; }
.stat-value.neg { color: #f85149; }

.balance-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.balance-control input {
  width: 80px;
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e6edf3;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
}

.allocation-section h3,
.positions-section h3 {
  font-size: 0.9rem;
  color: #8b949e;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}

.allocation-bars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.allocation-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.allocation-label {
  width: 60px;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: right;
}

.allocation-bar-bg {
  flex: 1;
  height: 20px;
  background: #161b22;
  border-radius: 4px;
  overflow: hidden;
}

.allocation-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.allocation-pct {
  width: 50px;
  font-size: 0.8rem;
  color: #8b949e;
  text-align: right;
}

.table-container {
  overflow-x: auto;
}

.table-scroll {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
}

.table-scroll::-webkit-scrollbar {
  width: 8px;
}

.table-scroll::-webkit-scrollbar-track {
  background: #161b22;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: #161b22;
  position: sticky;
  top: 0;
  z-index: 10;
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 500;
  color: #8b949e;
  font-size: 0.75rem;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

tr:hover td {
  background: rgba(255,255,255,0.02);
}

.pos-long { color: #3fb950; }
.pos-short { color: #f85149; }
.pos { color: #3fb950; }
.neg { color: #f85149; }

.empty {
  padding: 2rem;
  text-align: center;
  color: #8b949e;
  font-style: italic;
}

.chart-container {
  width: 100%;
  height: 400px;
  position: relative;
}

.chart-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.chart-controls select,
.signal-input select,
.card-header select {
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e6edf3;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
}

.chart-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #8b949e;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

.signal-input {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.signal-input textarea {
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e6edf3;
  padding: 0.75rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.status-success {
  color: #3fb950;
  margin-top: 0.5rem;
}

.status-error {
  color: #f85149;
  margin-top: 0.5rem;
}

.signal-text {
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.performance-summary {
  margin-bottom: 1rem;
}

.performance-table {
  max-height: 420px;
}

.performance-table th:first-child,
.performance-table td:first-child {
  min-width: 96px;
  white-space: nowrap;
}

.price-evidence {
  max-width: 520px;
  white-space: normal;
  color: #8b949e;
  font-size: 0.78rem;
}

/* Asset Charts Grid */
.asset-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}

.asset-chart-card {
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 1rem;
}

.asset-chart-card h4 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: #fff;
}

.asset-chart-card .mini-chart {
  width: 100%;
  height: 200px;
}

/* Toggle Switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #e6edf3;
}

.toggle-label input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 40px;
  height: 20px;
  background: #30363d;
  border-radius: 10px;
  transition: background 0.3s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}

.toggle-label input:checked + .toggle-slider {
  background: #238636;
}

.toggle-label input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

.auto-mode-control {
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: rgba(35, 134, 54, 0.1);
  border-radius: 6px;
  border: 1px solid rgba(35, 134, 54, 0.2);
}

/* Pending Signals */
.pending-signals {
  background: rgba(255, 215, 0, 0.05);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.pending-signal {
  background: #161b22;
  border: 1px solid rgba(255, 215, 0, 0.15);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.pending-signal-text {
  margin-bottom: 0.25rem;
}

.pending-signal-alloc {
  font-size: 0.8rem;
  color: #ffd700;
  margin-bottom: 0.5rem;
}

.pending-signal-actions {
  display: flex;
  gap: 0.5rem;
}

.approve-btn {
  background: #238636;
  border-color: #238636;
}

.approve-btn:hover {
  background: #2ea043;
}

.reject-btn {
  background: #da3633;
  border-color: #da3633;
}

.reject-btn:hover {
  background: #f85149;
}

.status-warning {
  color: #ffd700;
  margin-top: 0.5rem;
}

.pending {
  color: #ffd700;
  font-weight: 600;
}

/* Account panel */
.account-stats-grid .account-grand-total .stat-value {
  font-size: 2rem;
  color: #58a6ff;
}

.account-fetched-at {
  font-size: 0.75rem;
  color: #8b949e;
  margin-bottom: 1rem;
}

.account-section-title {
  font-size: 0.9rem;
  color: #8b949e;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}

.account-table {
  max-height: 360px;
}

.withdraw-warning {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: #f85149;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  vertical-align: middle;
}

.badge-official {
  background: rgba(35, 134, 54, 0.2);
  color: #3fb950;
  border: 1px solid rgba(35, 134, 54, 0.3);
}

.badge-live {
  background: rgba(31, 111, 235, 0.2);
  color: #58a6ff;
  border: 1px solid rgba(31, 111, 235, 0.3);
}

/* Gamblers settings row */
.gamblers-settings {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 215, 0, 0.06);
  border: 1px solid rgba(255, 215, 0, 0.15);
  border-radius: 6px;
}

.gamblers-pct-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gamblers-pct-control label {
  font-size: 0.85rem;
  color: #8b949e;
}

.gamblers-pct-control input {
  width: 65px;
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e6edf3;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* WP-E: Trader controls */
.trader-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.trader-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #30363d;
  transition: all 0.3s;
}

.trader-dot.active {
  background: #3fb950;
  box-shadow: 0 0 8px rgba(63, 185, 80, 0.6);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 4px rgba(63, 185, 80, 0.4); }
  50% { box-shadow: 0 0 14px rgba(63, 185, 80, 0.8); }
}

.btn-start {
  background: #238636;
  border-color: #238636;
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn-start:hover { background: #2ea043; }

.btn-stop {
  background: #da3633;
  border-color: #da3633;
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn-stop:hover { background: #f85149; }

.btn-execute {
  background: #d29922;
  border-color: #d29922;
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn-execute:hover { background: #e3b341; }

.trader-takeover-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: #8b949e;
  cursor: pointer;
  white-space: nowrap;
}
.trader-takeover-label input { accent-color: #58a6ff; }

/* Plan preview */
.plan-summary { margin-bottom: 1rem; }
.plan-blockers {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.25);
  border-radius: 6px;
  color: #f85149;
  font-size: 0.85rem;
}
.plan-blockers ul { margin: 0.5rem 0 0 1.5rem; }

/* Leverage badges */
.badge-ok {
  background: rgba(38, 166, 154, 0.2);
  color: #26a69a;
  border: 1px solid rgba(38, 166, 154, 0.3);
}
.badge-err {
  background: rgba(239, 83, 80, 0.2);
  color: #ef5350;
  border: 1px solid rgba(239, 83, 80, 0.3);
}

.plan-external {
  font-size: 0.8rem;
  color: #8b949e;
}

/* Disabled badge */
.disabled-badge {
  display: block;
  background: rgba(239, 83, 80, 0.12);
  border: 1px solid rgba(239, 83, 80, 0.25);
  color: #f85149;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  letter-spacing: 0.5px;
}

/* Gamblers card disabled state */
.gamblers-disabled .stats-grid,
.gamblers-disabled .allocation-section,
.gamblers-disabled .positions-section,
.gamblers-disabled .last-signal {
  opacity: 0.4;
}

/* ── WP-G: Venue chips & cap ───────────────────────────────────────── */
.venue-chip {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.venue-chip.spot {
  background: rgba(88, 166, 255, 0.2);
  color: #58a6ff;
  border: 1px solid rgba(88, 166, 255, 0.3);
}
.venue-chip.futures {
  background: rgba(217, 153, 34, 0.2);
  color: #d29922;
  border: 1px solid rgba(217, 153, 34, 0.3);
}
.venue-chip.futures-1x {
  background: rgba(217, 153, 34, 0.2);
  color: #d29922;
  border: 1px solid rgba(217, 153, 34, 0.3);
}

.cap-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cap-control label {
  font-size: 0.78rem;
  color: #8b949e;
  white-space: nowrap;
}

.cap-control input {
  width: 80px;
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e6edf3;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.82rem;
}

.cap-hint {
  font-size: 0.68rem;
  color: #8b949e;
  font-style: italic;
}

.cap-hint.uncapped {
  color: #3fb950;
}

.futures-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(217, 153, 34, 0.2);
  color: #d29922;
  border: 1px solid rgba(217, 153, 34, 0.3);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.4rem;
  text-transform: uppercase;
}

/* ── WP-C: Benchmark ────────────────────────────────────────────────── */

.section-nav {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 2rem;
  background: #0f1522;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 56px;
  z-index: 99;
  flex-wrap: wrap;
}

.section-nav a {
  color: #8b949e;
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.section-nav a:hover {
  color: #e6edf3;
  background: rgba(255,255,255,0.06);
}

.benchmark-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.benchmark-controls label {
  font-size: 0.85rem;
  color: #8b949e;
}

.benchmark-controls input {
  width: 100px;
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e6edf3;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.benchmark-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 800px) {
  .benchmark-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.benchmark-chart-container {
  width: 100%;
  margin-bottom: 1rem;
}

#benchmarkChart {
  width: 100%;
  height: 380px;
  position: relative;
}

.benchmark-period-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.period-btn {
  background: #21262d;
  border: 1px solid rgba(255,255,255,0.1);
  color: #8b949e;
  padding: 0.35rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s;
}

.period-btn:hover {
  color: #e6edf3;
  background: #30363d;
}

.period-btn.active {
  background: #238636;
  border-color: #238636;
  color: #fff;
}

.benchmark-barchart-container {
  margin-bottom: 1rem;
}

.benchmark-barchart-container h3 {
  font-size: 0.9rem;
  color: #8b949e;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

#benchmarkBarChart {
  width: 100%;
  height: 180px;
  display: block;
}

.benchmark-table-section h3 {
  font-size: 0.9rem;
  color: #8b949e;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
}

.benchmark-table-scroll {
  max-height: 420px;
}

.benchmark-alloc-cell {
  font-size: 0.8rem;
  color: #e6edf3;
}

/* Expandable call detail panel */
.call-detail-panel {
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.5rem 1rem 0.5rem 1rem;
}

.call-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}

.call-detail-item {
  color: #e6edf3;
}

.call-detail-item strong {
  color: #8b949e;
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.call-detail-mini-chart {
  width: 100%;
  height: 120px;
  margin-top: 0.5rem;
}

.call-detail-allocations {
  font-size: 0.8rem;
  color: #e6edf3;
  line-height: 1.5;
}

tr.call-expandable {
  cursor: pointer;
}

tr.call-expandable:hover td {
  background: rgba(255,255,255,0.04);
}

.benchmark-call-detail td {
  padding: 0;
  border-bottom: none;
}
