:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --accent-dim: #2654a3;
  --border: #2a3548;
  --error-bg: #3d2020;
  --error-text: #ffb4b4;
  --call-bg: rgba(34, 197, 94, 0.14);
  --call-bg-hover: rgba(34, 197, 94, 0.22);
  --call-text: #4ade80;
  --put-bg: rgba(239, 68, 68, 0.14);
  --put-bg-hover: rgba(239, 68, 68, 0.22);
  --put-text: #f87171;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 3rem;
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.65rem;
  font-weight: 600;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.scan-telemetry {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}

.tele-line {
  margin: 0.2rem 0;
  font-size: 0.9rem;
}

.tele-k {
  color: var(--muted);
}

.tele-history-wrap summary {
  cursor: pointer;
  margin-top: 0.5rem;
}

.tele-history {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.btn {
  font: inherit;
  padding: 0.55rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--panel);
  color: var(--text);
}

.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  border-color: var(--accent);
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  background: var(--error-bg);
  color: var(--error-text);
  padding: 1rem;
  border-radius: 8px;
  white-space: pre-wrap;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.35rem;
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.h3 {
  margin: 1.25rem 0 0.6rem;
  font-size: 1rem;
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.stat .k {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat .v {
  font-size: 1.1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.table-wrap.scroll {
  max-height: 360px;
  overflow-y: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.data th,
table.data td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
}

table.data tbody tr:hover {
  background: rgba(61, 139, 253, 0.08);
}

table.data tbody tr.row-call {
  background: var(--call-bg);
}

table.data tbody tr.row-call:hover {
  background: var(--call-bg-hover);
}

table.data tbody tr.row-call td.sig {
  color: var(--call-text);
  font-weight: 600;
}

table.data tbody tr.row-put {
  background: var(--put-bg);
}

table.data tbody tr.row-put:hover {
  background: var(--put-bg-hover);
}

table.data tbody tr.row-put td.sig {
  color: var(--put-text);
  font-weight: 600;
}

table.data td.score-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Strategy Configuration Styles */
.strategy-config {
  margin-bottom: 1.5rem;
}

.config-controls {
  display: grid;
  gap: 1.5rem;
}

.config-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: var(--bg);
}

.config-group h3 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  color: var(--text);
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  margin-bottom: 1rem;
}

.toggle-switch input[type="checkbox"] {
  position: relative;
  width: 44px;
  height: 24px;
  appearance: none;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle-switch input[type="checkbox"]:checked {
  background: var(--accent);
}

.toggle-switch input[type="checkbox"]::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle-switch input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

.toggle-switch .label {
  color: var(--text);
  font-weight: 500;
}

.input-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.input-group input[type="number"] {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.9rem;
}

.input-group input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(61, 139, 253, 0.2);
}

.config-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn.secondary {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text);
}

.btn.secondary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.active-conditions {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.active-conditions h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  color: var(--text);
}

.active-conditions p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-family: monospace;
}

/* Three Table Layout Styles */
.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
}

@media (min-width: 1200px) {
  .dashboard {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1600px) {
  .dashboard {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Top 10 Table Special Styling */
.panel:nth-child(3) {
  border: 2px solid var(--accent);
  background: linear-gradient(135deg, var(--panel), rgba(61, 139, 253, 0.05));
}

.panel:nth-child(3) h2 {
  color: var(--accent);
  font-weight: 700;
}

/* Table Column Widths */
.table-wrap table.data th:nth-child(1),
.table-wrap table.data td:nth-child(1) { width: 80px; } /* Symbol */
.table-wrap table.data th:nth-child(2),
.table-wrap table.data td:nth-child(2) { width: 60px; } /* Signal */
.table-wrap table.data th:nth-child(3),
.table-wrap table.data td:nth-child(3) { width: 90px; } /* Spot Price */
.table-wrap table.data th:nth-child(4),
.table-wrap table.data td:nth-child(4) { width: 90px; } /* Strike Price */
.table-wrap table.data th:nth-child(5),
.table-wrap table.data td:nth-child(5) { width: 80px; } /* Premium */
.table-wrap table.data th:nth-child(6),
.table-wrap table.data td:nth-child(6) { width: 60px; } /* Lot Size */
.table-wrap table.data th:nth-child(7),
.table-wrap table.data td:nth-child(7) { width: 70px; } /* Type */
.table-wrap table.data th:nth-child(8),
.table-wrap table.data td:nth-child(8) { width: 70px; } /* Confidence */
.table-wrap table.data th:nth-child(9),
.table-wrap table.data td:nth-child(9) { width: 60px; } /* PCR */

/* Responsive adjustments */
@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  
  .table-wrap {
    font-size: 0.75rem;
  }
  
  .panel h2 {
    font-size: 1rem;
  }
}
