:root {
  --bg-base: #0a0e17;
  --bg-card: #111827;
  --bg-card-hover: #1e293b;
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f3f4f6;
  --text-muted: #94a3b8;
  --brand: #10b981;
  --brand-gradient: linear-gradient(135deg, #059669 0%, #10b981 100%);
  --brand-light: rgba(16, 185, 129, 0.15);
  --teal: #14b8a6;
  --blue: #3b82f6;
  --blue-light: rgba(59, 130, 246, 0.15);
  --amber: #f59e0b;
  --amber-light: rgba(245, 158, 11, 0.15);
  --red: #ef4444;
  --red-light: rgba(239, 68, 68, 0.15);
  --font-main: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-code: 'JetBrains Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-main);
  background: var(--bg-base);
  color: var(--text-main);
  line-height: 1.6;
  padding: 24px 20px;
  min-height: 100vh;
}

.quant-container {
  max-width: 1320px;
  margin: 0 auto;
}

/* Header */
.quant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 22px 28px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo-badge {
  background: var(--brand-gradient);
  color: #fff;
  font-family: var(--font-code);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 8px 14px;
  border-radius: 8px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.quant-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}

.header-sub {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-chip {
  font-size: 0.86rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 9999px;
  white-space: nowrap;
}

.live-chip {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Card Boxes */
.card-box {
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.card-box-header {
  margin-bottom: 18px;
}

.card-box-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Metrics Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.metric-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.metric-val {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-code);
  line-height: 1.2;
}

.metric-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.text-brand { color: #34d399; }
.text-green { color: #10b981; }
.text-red { color: #ef4444; }
.text-amber { color: #f59e0b; }
.text-blue { color: #38bdf8; }

/* Allocation Visual Bar */
.allocation-bar-container {
  margin: 16px 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

.allocation-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.86rem;
  font-weight: 600;
}

.allocation-bar {
  height: 14px;
  background: #334155;
  border-radius: 9999px;
  overflow: hidden;
  display: flex;
}

.bar-stock {
  background: linear-gradient(90deg, #10b981, #34d399);
  height: 100%;
  transition: width 0.4s ease;
}

.bar-cash {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  height: 100%;
  transition: width 0.4s ease;
}

/* Simulator Form */
.simulator-box {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin-bottom: 24px;
}

.sim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.sim-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.preset-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.preset-btn.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #34d399;
}

.sim-params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  align-items: end;
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.param-group label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-unit input,
.input-with-unit select {
  width: 100%;
  background: #0b1120;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-code);
  font-size: 0.95rem;
  padding: 10px 38px 10px 12px;
  outline: none;
  transition: var(--transition);
}

.input-with-unit input:focus,
.input-with-unit select:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.input-with-unit span {
  position: absolute;
  right: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-code);
  pointer-events: none;
}

.btn-run {
  width: 100%;
  height: 42px;
  justify-content: center;
}

/* Charts Section */
.chart-section {
  position: relative;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title-wrap h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.chart-legend-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
}

.legend-buy {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.legend-sell {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.legend-nav {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.legend-bnh {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.chart-controls {
  display: flex;
  gap: 6px;
}

.btn-time {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-time:hover,
.btn-time.active {
  background: rgba(16, 185, 129, 0.18);
  border-color: #10b981;
  color: #34d399;
}

.chart-container {
  width: 100%;
  height: 420px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0d131f;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sub-chart-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
  margin: 20px 0 10px 0;
  flex-wrap: wrap;
  gap: 8px;
}

.sub-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.sub-chart-container {
  width: 100%;
  height: 240px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0d131f;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Two Column Grid */
.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

/* Strategy Comparison Cards */
.compare-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-top: 12px;
}

.compare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.88rem;
}

.compare-row:last-child {
  border-bottom: none;
}

.compare-title {
  color: var(--text-muted);
}

.compare-val {
  font-family: var(--font-code);
  font-weight: 700;
}

/* Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.trades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.trades-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.trades-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-family: var(--font-code);
  color: #e2e8f0;
  white-space: nowrap;
}

.trades-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge-buy {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.76rem;
}

.badge-sell {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.76rem;
}

/* Cloudflare Blueprint Step Box */
.step-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.step-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.step-num {
  width: 28px;
  height: 28px;
  background: var(--brand-gradient);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.step-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.step-content p {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 16px 12px;
  }
  .quant-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 20px;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .chart-container {
    height: 320px;
  }
  .sub-chart-container {
    height: 180px;
  }
  .two-col-grid {
    grid-template-columns: 1fr;
  }
}
